{"nl": {"description": "This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either\u00a0\u2014 although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number $$$n$$$.In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could \"see\" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too.Given $$$n$$$, determine the total number of possible bus number variants.", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\leq n \\leq 10^{18}$$$)\u00a0\u2014 the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with $$$0$$$.", "output_spec": "Output a single integer\u00a0\u2014 the amount of possible variants of the real bus number.", "sample_inputs": ["97", "2028"], "sample_outputs": ["2", "13"], "notes": "NoteIn the first sample, only variants $$$97$$$ and $$$79$$$ are possible.In the second sample, the variants (in the increasing order) are the following: $$$208$$$, $$$280$$$, $$$802$$$, $$$820$$$, $$$2028$$$, $$$2082$$$, $$$2208$$$, $$$2280$$$, $$$2802$$$, $$$2820$$$, $$$8022$$$, $$$8202$$$, $$$8220$$$."}, "positive_code": [{"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": "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": "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": "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": "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 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()\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": "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": "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": "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": "# ---------------------------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": "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": "\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 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 __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": "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": "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 = 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": "\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 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": "#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()\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": "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\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 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": "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": "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": "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)"}, {"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": "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": "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": "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": "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 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": "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": "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"}, {"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": "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": "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": "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 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 __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": "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": "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 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 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": "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": "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": "# -*- 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": "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": "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": "\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": "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": "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": "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": "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": "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": "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": "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 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": "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": "#!/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": "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": "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": "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": "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": "#!/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": "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": "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 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": "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": "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": "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()\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": "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": "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": "\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": "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=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": "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": "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 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 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 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": "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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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": "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))"}], "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 i0 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< 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<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"} {"nl": {"description": "The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets $$$w$$$ points, and the opposing team gets $$$0$$$ points. If the game results in a draw, both teams get $$$d$$$ points.The manager of the Berland capital team wants to summarize the results of the season, but, unfortunately, all information about the results of each match is lost. The manager only knows that the team has played $$$n$$$ games and got $$$p$$$ points for them.You have to determine three integers $$$x$$$, $$$y$$$ and $$$z$$$ \u2014 the number of wins, draws and loses of the team. If there are multiple answers, print any of them. If there is no suitable triple $$$(x, y, z)$$$, report about it.", "input_spec": "The first line contains four integers $$$n$$$, $$$p$$$, $$$w$$$ and $$$d$$$ $$$(1 \\le n \\le 10^{12}, 0 \\le p \\le 10^{17}, 1 \\le d < w \\le 10^{5})$$$ \u2014 the number of games, the number of points the team got, the number of points awarded for winning a match, and the number of points awarded for a draw, respectively. Note that $$$w > d$$$, so the number of points awarded for winning is strictly greater than the number of points awarded for draw.", "output_spec": "If there is no answer, print $$$-1$$$. Otherwise print three non-negative integers $$$x$$$, $$$y$$$ and $$$z$$$ \u2014 the number of wins, draws and losses of the team. If there are multiple possible triples $$$(x, y, z)$$$, print any of them. The numbers should meet the following conditions: $$$x \\cdot w + y \\cdot d = p$$$, $$$x + y + z = n$$$. ", "sample_inputs": ["30 60 3 1", "10 51 5 4", "20 0 15 5"], "sample_outputs": ["17 9 4", "-1", "0 0 20"], "notes": "NoteOne of the possible answers in the first example \u2014 $$$17$$$ wins, $$$9$$$ draws and $$$4$$$ losses. Then the team got $$$17 \\cdot 3 + 9 \\cdot 1 = 60$$$ points in $$$17 + 9 + 4 = 30$$$ games.In the second example the maximum possible score is $$$10 \\cdot 5 = 50$$$. Since $$$p = 51$$$, there is no answer.In the third example the team got $$$0$$$ points, so all $$$20$$$ games were lost."}, "positive_code": [{"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": "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=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()))\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": "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": "\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": "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": "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": "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=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": "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 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": "''' 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": "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": "n,p,w,d=map(int,input().split())\ny=0\nwhile y= 0 and b >= 0 and a + b <= n:\n print(a, b, n - a - b)\nelse:\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": "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 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": "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": "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": "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 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": "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)"}, {"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": "\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 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": "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": "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": "def solve():\n n,p,w,d=map(int,input().split())\n x=p//w\n y=0\n while x>=0 and y=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": "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": "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": "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": "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": "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 = 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": "\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": "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": "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": "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": "##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": "\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=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": "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": "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": " \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 = 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": "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": "from math import *\nn,p,w,d=map(int,input().split())\nif p%gcd(w,d)!=0 or w*n

=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": "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": "# -*- 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": "#------------------------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": "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 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": "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": "\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": "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": "#!/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": "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": "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": "#!/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": "# 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(' '))\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=0 and x*w+y*d==p):\n print(\"%d %d %d\"%(x,y,z))\nelse:\n print(\"-1\")\n \n"}, {"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 = 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": "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": "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": "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": "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": "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": "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*n0)):\n print (-1)\nelse:\n print (int(nw),\" \",int(nd),\" \",int(nl))\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": "#!/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": "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": "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=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": "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": "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=[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": "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": "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 (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,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=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": "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) 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)"}, {"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": "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": "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": "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 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\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": "\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().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\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 p0:\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": "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": "n,p,w,d=map(int,input().split())\nif n*w

0 and p 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": "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=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=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 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": "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=0 and y>=0 and z>=0:\n\t\tprint((x),y,int(z))\n\t\texit(0)\nprint(-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"}], "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=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(a0):\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 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 winsn:\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 winsn:\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=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= 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=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 p0:\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=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=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=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 winsn:\n low=mid+1\n elif (a+(p-a*w)//d)= 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=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= 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 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(ay):\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"} {"nl": {"description": "Bob likes to draw camels: with a single hump, two humps, three humps, etc. He draws a camel by connecting points on a coordinate plane. Now he's drawing camels with t humps, representing them as polylines in the plane. Each polyline consists of n vertices with coordinates (x1,\u2009y1), (x2,\u2009y2), ..., (xn,\u2009yn). The first vertex has a coordinate x1\u2009=\u20091, the second \u2014 x2\u2009=\u20092, etc. Coordinates yi might be any, but should satisfy the following conditions: there should be t humps precisely, i.e. such indexes j (2\u2009\u2264\u2009j\u2009\u2264\u2009n\u2009-\u20091), so that yj\u2009-\u20091\u2009<\u2009yj\u2009>\u2009yj\u2009+\u20091, there should be precisely t\u2009-\u20091 such indexes j (2\u2009\u2264\u2009j\u2009\u2264\u2009n\u2009-\u20091), so that yj\u2009-\u20091\u2009>\u2009yj\u2009<\u2009yj\u2009+\u20091, no segment of a polyline should be parallel to the Ox-axis, all yi are integers between 1 and 4. For a series of his drawings of camels with t humps Bob wants to buy a notebook, but he doesn't know how many pages he will need. Output the amount of different polylines that can be drawn to represent camels with t humps for a given number n.", "input_spec": "The first line contains a pair of integers n and t (3\u2009\u2264\u2009n\u2009\u2264\u200920, 1\u2009\u2264\u2009t\u2009\u2264\u200910).", "output_spec": "Output the required amount of camels with t humps.", "sample_inputs": ["6 1", "4 2"], "sample_outputs": ["6", "0"], "notes": "NoteIn the first sample test sequences of y-coordinates for six camels are: 123421, 123431, 123432, 124321, 134321 \u0438 234321 (each digit corresponds to one value of yi)."}, "positive_code": [{"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"}, {"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"}, {"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)"}], "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"} {"nl": {"description": "It's that time of the year when the Russians flood their countryside summer cottages (dachas) and the bus stop has a lot of people. People rarely go to the dacha on their own, it's usually a group, so the people stand in queue by groups.The bus stop queue has n groups of people. The i-th group from the beginning has ai people. Every 30 minutes an empty bus arrives at the bus stop, it can carry at most m people. Naturally, the people from the first group enter the bus first. Then go the people from the second group and so on. Note that the order of groups in the queue never changes. Moreover, if some group cannot fit all of its members into the current bus, it waits for the next bus together with other groups standing after it in the queue.Your task is to determine how many buses is needed to transport all n groups to the dacha countryside.", "input_spec": "The first line contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100). The next line contains n integers: a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u2009m).", "output_spec": "Print a single integer \u2014 the number of buses that is needed to transport all n groups to the dacha countryside.", "sample_inputs": ["4 3\n2 3 2 1", "3 4\n1 2 1"], "sample_outputs": ["3", "1"], "notes": null}, "positive_code": [{"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 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 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": "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())\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": "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": "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,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": "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 = 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": "#!/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": "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": "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": "'''\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": "#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": "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())\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())\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": "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": "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": "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": "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\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": "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": "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 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(' '))\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 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": "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": "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": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ncount=0\nsum=0\ni=0\nwhile(i m:\n res+=1\n su = a[i]\nprint(res)"}, {"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": "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": "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": "\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 tm:\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": "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": "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 emptyempty:\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 = 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": "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": "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())\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": "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(iy):\n sum +=1\n inc=l[i]\n else:\n inc+=l[i]\n i+=1 \nprint(sum)\n \n"}, {"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": "#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": "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": "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, raw_input().split())\na = map(int, raw_input().split())\ns = 0\ncnt = 0\ni=0\nwhile im:\n i-=1\n s=0\n cnt+=1\n i+=1\nprint cnt+1"}, {"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, 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, 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": "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": "[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": "#!/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= freeSeats + arrayQueue[i]:\n freeSeats += arrayQueue[i]\n else:\n busAmount += 1\n freeSeats = 0\n freeSeats += arrayQueue[i]\nprint(busAmount)"}, {"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,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": "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": "#!/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, 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": "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())\ni=0\nb=1\nc=m\nwhile i 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": "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, 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": "# -*- 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, 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": "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": "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": "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": "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": "# -*- 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(im:\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=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, raw_input().split())\na = map(int, raw_input().split())\ni = 0\nans = 0\ns = 0\nwhile i m:\n\t\ts = a[i]\n\t\tans += 1\n\ti += 1\nprint ans + 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,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": "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": "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": "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(i0):\n cnt+=1\n print(cnt)"}, {"source_code": "n,m=map(int,input().split())\nl=list(map(int,input().split()))\ncount=0\nsum=0\ni=0\nwhile(im):\n sum=0\n count=count+1\n else:\n i=i+1\nif(sum0):\n count=count+1\n i=i+1\nprint(count)"}, {"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": "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": "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": "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())\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": "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": "n,m=map(int,input().split())\nl=[int(i) for i in input().split()]\ni=0 \nsm=0 \ncnt=1 \nwhile im:\n cnt+=1 \n sm=l[i]\n i+=1 \nprint(cnt)"}, {"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": "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": "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": "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": "# -*- 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())\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"}], "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 r0:\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\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= 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 im:\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 im:\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=a[first] and first0:\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(im):\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=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 rm:\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 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=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(im):\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 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 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]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 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": "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=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": "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": "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": "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": "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": "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": "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 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()\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": "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": " \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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "\"\"\"\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()\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": "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=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": "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": "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=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 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)\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": "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": "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": "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": "\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 = 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": "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()\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": "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": "#\n# Uian Sol Gorgonio \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": "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 = 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 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": "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\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": "def check(word,i,j):\n while i 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": "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(ij):\n s3=s[0:i]+'a'+s[(j+1):]\n print(s3)\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": "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": "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": "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": "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": "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')"}, {"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()\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": "\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": "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()\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": "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": "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": "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": "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 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,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": "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": "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": "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": "# -*- 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": "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": "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": "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 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": "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": "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": "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": "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": "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": "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()\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": "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": "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": "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()\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 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": "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": "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": "\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": "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"}], "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 j0:\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(ij):\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\",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 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 :\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"} {"nl": {"description": "Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.", "input_spec": "The only line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091018). Please do not use the %lld specificator to read or write 64-bit numbers in \u0421++. It is preferred to use the cin, cout streams or the %I64d specificator.", "output_spec": "Print on the single line \"YES\" if n is a nearly lucky number. Otherwise, print \"NO\" (without the quotes).", "sample_inputs": ["40047", "7747774", "1000000000000000000"], "sample_outputs": ["NO", "YES", "NO"], "notes": "NoteIn the first sample there are 3 lucky digits (first one and last two), so the answer is \"NO\".In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is \"YES\".In the third sample there are no lucky digits, so the answer is \"NO\"."}, "positive_code": [{"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": "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": "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": "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": "\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": "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 = 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": "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": "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": "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)"}, {"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": "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": "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": "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": "s = input()\nprint( 'NYOE S'[sum([s.count('4') + s.count('7')])in [4,7] ::2] )\n"}, {"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": "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": "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 = 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": "\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=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": "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": "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 = 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": "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": "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=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": "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": "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())\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=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": "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=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": "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": "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=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()\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": "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": "#110A\na = input()\nlcount = a.count('4') + a.count('7')\nprint('YES' if (lcount == 4 or lcount == 7) else '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": "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": "# 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": "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": "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": "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": "t = input()\nprint(['NO', 'YES'][t.count('4') + t.count('7') in [4, 7]])"}, {"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=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": "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": "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": "#!/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=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": "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": "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)"}, {"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": "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": "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": "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": "#110A\na = input()\nlcount = a.count('4') + a.count('7')\nprint('YES' if (lcount == 4 or lcount == 7) else '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": "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": "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": "number = raw_input()\ntotal = number.count(\"4\") + number.count(\"7\")\nprint 'YES' if total == 4 or total == 7 else 'NO'\n"}, {"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=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": "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": "#!/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": "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": "#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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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())\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": "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": "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": "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": "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": "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": "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": "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": "#110A\na = input()\nlcount = a.count('4') + a.count('7')\nprint('YES' if (lcount == 4 or lcount == 7) else '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": "# -*- 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": "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": "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": "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": "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=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": "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()\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": "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())))"}], "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_number0:\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 i1 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"} {"nl": {"description": "Little Petya was given this problem for homework:You are given function (here represents the operation of taking the remainder). His task is to count the number of integers x in range [a;b] with property f(x)\u2009=\u2009x.It is a pity that Petya forgot the order in which the remainders should be taken and wrote down only 4 numbers. Each of 24 possible orders of taking the remainder has equal probability of being chosen. For example, if Petya has numbers 1, 2, 3, 4 then he can take remainders in that order or first take remainder modulo 4, then modulo 2, 3, 1. There also are 22 other permutations of these numbers that represent orders in which remainder can be taken. In this problem 4 numbers wrote down by Petya will be pairwise distinct.Now it is impossible for Petya to complete the task given by teacher but just for fun he decided to find the number of integers with property that probability that f(x)\u2009=\u2009x is not less than 31.4159265352718281828459045%. In other words, Petya will pick up the number x if there exist at least 7 permutations of numbers p1,\u2009p2,\u2009p3,\u2009p4, for which f(x)\u2009=\u2009x.", "input_spec": "First line of the input will contain 6 integers, separated by spaces: p1,\u2009p2,\u2009p3,\u2009p4,\u2009a,\u2009b (1\u2009\u2264\u2009p1,\u2009p2,\u2009p3,\u2009p4\u2009\u2264\u20091000,\u20090\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009\u2264\u200931415). It is guaranteed that numbers p1,\u2009p2,\u2009p3,\u2009p4 will be pairwise distinct.", "output_spec": "Output the number of integers in the given range that have the given property.", "sample_inputs": ["2 7 1 8 2 8", "20 30 40 50 0 100", "31 41 59 26 17 43"], "sample_outputs": ["0", "20", "9"], "notes": null}, "positive_code": [{"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": "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": "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"}, {"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": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])"}, {"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": "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": "p1,p2,p3,p4,a,b = map(int,input().strip().split())\nm=min(min(min(p1,p2),p3),p4)\nif m= 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": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\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": "*l, a, b = map(int, input().split())\nprint(max(0, min(b + 1, *l) - a))"}, {"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 ma and m>b):\n\t\tprint b-a+1\n\telse: \n\t\tprint 0\n"}, {"source_code": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\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": "x1,x2,x3,x4,a,b = map(int,input().split(' '))\nminValue = min(x1,x2,x3,x4)\nif(b= 7\nprint ans\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": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\n"}, {"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= 7):\n ans+=1;\n \nprint ans; "}, {"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": "l=map(int,raw_input().split())\nmn=min(l[:-2])\nprint min(l[-1]+1,mn)-min(l[-2],mn)"}, {"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"}, {"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": "s=[int(x) for x in raw_input().split()]\np=min(s[0:4])\na,b=s[4:6]\nif b= 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": "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": "a = map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\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": "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 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": "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": "a=map(int,raw_input().split())\nprint max(0,min(a[:4]+[a[-1]+1])-a[-2])\n"}, {"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": "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": "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": "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,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= 7\nprint ans\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": "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": "line = raw_input().split()\np,a,b = map(int, line[:4]), int(line[4]), int(line[5])\nprint sum( [i 6:\n result += 1\n print result\n\nif __name__ == '__main__':\n main()\n"}, {"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": "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": "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": "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": "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"}, {"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": "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": "# 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": "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": "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": "*l, a, b = map(int, input().split())\nprint(max(0, min(b + 1, *l) - a))"}, {"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": "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 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": "p1, p2, p3, p4, a, b = map(int, input().split())\nprint(max(0, min(p1, p2, p3, p4, b + 1) - a))"}, {"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": "*l, a, b = map(int, input().split())\nprint(max(0, min(b + 1, *l) - a))"}, {"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": "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": "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": "#!/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": "line = raw_input().split()\np,a,b = map(int, line[:4]), int(line[4]), int(line[5])\nprint sum( [i=0):\n a=min(b,mylist[5]-mylist[4]+1)\nprint(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": "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": "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= 0.314159265352718281828459045:\n res += 1\n\nprint res\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": "*l, a, b = map(int, input().split())\nprint(max(0, min(b + 1, *l) - a))"}, {"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": "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": "\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": "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": "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": "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": "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"}], "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(ka):\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= 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]=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 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 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=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= 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"} {"nl": {"description": "Two bears are playing tic-tac-toe via mail. It's boring for them to play usual tic-tac-toe game, so they are a playing modified version of this game. Here are its rules.The game is played on the following field. Players are making moves by turns. At first move a player can put his chip in any cell of any small field. For following moves, there are some restrictions: if during last move the opposite player put his chip to cell with coordinates (xl,\u2009yl) in some small field, the next move should be done in one of the cells of the small field with coordinates (xl,\u2009yl). For example, if in the first move a player puts his chip to lower left cell of central field, then the second player on his next move should put his chip into some cell of lower left field (pay attention to the first test case). If there are no free cells in the required field, the player can put his chip to any empty cell on any field.You are given current state of the game and coordinates of cell in which the last move was done. You should find all cells in which the current player can put his chip.A hare works as a postman in the forest, he likes to foul bears. Sometimes he changes the game field a bit, so the current state of the game could be unreachable. However, after his changes the cell where the last move was done is not empty. You don't need to find if the state is unreachable or not, just output possible next moves according to the rules.", "input_spec": "First 11 lines contains descriptions of table with 9 rows and 9 columns which are divided into 9 small fields by spaces and empty lines. Each small field is described by 9 characters without spaces and empty lines. character \"x\" (ASCII-code 120) means that the cell is occupied with chip of the first player, character \"o\" (ASCII-code 111) denotes a field occupied with chip of the second player, character \".\" (ASCII-code 46) describes empty cell. The line after the table contains two integers x and y (1\u2009\u2264\u2009x,\u2009y\u2009\u2264\u20099). They describe coordinates of the cell in table where the last move was done. Rows in the table are numbered from up to down and columns are numbered from left to right. It's guaranteed that cell where the last move was done is filled with \"x\" or \"o\". Also, it's guaranteed that there is at least one empty cell. It's not guaranteed that current state of game is reachable.", "output_spec": "Output the field in same format with characters \"!\" (ASCII-code 33) on positions where the current player can put his chip. All other cells should not be modified.", "sample_inputs": ["... ... ...\n... ... ...\n... ... ...\n\n... ... ...\n... ... ...\n... x.. ...\n\n... ... ...\n... ... ...\n... ... ...\n6 4", "xoo x.. x..\nooo ... ...\nooo ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n\nx.. x.. x..\n... ... ...\n... ... ...\n7 4", "o.. ... ...\n... ... ...\n... ... ...\n\n... xxx ...\n... xox ...\n... ooo ...\n\n... ... ...\n... ... ...\n... ... ...\n5 5"], "sample_outputs": ["... ... ... \n... ... ... \n... ... ... \n\n... ... ... \n... ... ... \n... x.. ... \n\n!!! ... ... \n!!! ... ... \n!!! ... ...", "xoo x!! x!! \nooo !!! !!! \nooo !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!! \n\nx!! x!! x!! \n!!! !!! !!! \n!!! !!! !!!", "o!! !!! !!! \n!!! !!! !!! \n!!! !!! !!! \n\n!!! xxx !!! \n!!! xox !!! \n!!! ooo !!! \n\n!!! !!! !!! \n!!! !!! !!! \n!!! !!! !!!"], "notes": "NoteIn the first test case the first player made a move to lower left cell of central field, so the second player can put a chip only to cells of lower left field.In the second test case the last move was done to upper left cell of lower central field, however all cells in upper left field are occupied, so the second player can put his chip to any empty cell.In the third test case the last move was done to central cell of central field, so current player can put his chip to any cell of central field, which is already occupied, so he can move anywhere. Pay attention that this state of the game is unreachable."}, "positive_code": [{"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": "#!/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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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": "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 = [[[] 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\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": "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": "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 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": "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": "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": "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": "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": "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": "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": "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 = []\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": "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": "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": "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": "'''\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": "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": "#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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "#!/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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 = []\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": "'''\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": "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": "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": "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": "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": "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": "\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"}, {"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": "#!/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": "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": "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": "'''\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "'''\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": "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": "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": "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": "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": "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": "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": "# 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"}], "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"} {"nl": {"description": "A big company decided to launch a new series of rectangular displays, and decided that the display must have exactly n pixels. Your task is to determine the size of the rectangular display \u2014 the number of lines (rows) of pixels a and the number of columns of pixels b, so that: there are exactly n pixels on the display; the number of rows does not exceed the number of columns, it means a\u2009\u2264\u2009b; the difference b\u2009-\u2009a is as small as possible. ", "input_spec": "The first line contains the positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009106)\u00a0\u2014 the number of pixels display should have.", "output_spec": "Print two integers\u00a0\u2014 the number of rows and columns on the display. ", "sample_inputs": ["8", "64", "5", "999999"], "sample_outputs": ["2 4", "8 8", "1 5", "999 1001"], "notes": "NoteIn the first example the minimum possible difference equals 2, so on the display should be 2 rows of 4 pixels.In the second example the minimum possible difference equals 0, so on the display should be 8 rows of 8 pixels.In the third example the minimum possible difference equals 4, so on the display should be 1 row of 5 pixels."}, "positive_code": [{"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=1:\n if n%i==0 and n%(n//i)==0:\n print(i,n//i)\n break\n i-=1"}, {"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": "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": "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=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": "# -*- 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": "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)n/i:\n break\na=min(aopt,bopt)\nb=max(aopt,bopt)\nprint(a,b)\n"}, {"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": "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=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": "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": "# 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())\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=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": "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": "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=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": "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\nn = input()\nfes = math.sqrt(n)\nfes = int(fes)\nwhile n%fes>=1:\n fes-=1\nprint fes,n/fes\n \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) 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": "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": "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\nn=int(input())\na=int(math.sqrt(n))\nwhile n%a !=0:\n a=a-1\nprint(a,n//a)"}, {"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": "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": "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": "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": "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(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": "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": "\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 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 = 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": "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": "pixels = int(input())\nroot = int(pixels**0.5)\nwhile pixels%root != 0:\n root -= 1\nprint(root, pixels//root)"}, {"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": "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": "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": "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": "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": "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=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": "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": "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 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": "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) 0:\n if float(num)/float(root) == num/root:\n print root, num/root\n break\n root -= 1\n"}, {"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": "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": "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": "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": "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\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": "\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": "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\nn = int(input())\n\ns = math.floor(math.sqrt(n))\nwhile n % s != 0:\n s -= 1\nprint(s,\" \", n // s)"}, {"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": "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)=i and n/i-in:\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 = 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": "#!/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 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 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": "\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": "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": "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=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": "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)= i:\n ans = i\n break\nprint(ans, n // ans)\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": "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": "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": "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": "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": "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": "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": "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": "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"}], "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=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 kn/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 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"} {"nl": {"description": "The weather is fine today and hence it's high time to climb the nearby pine and enjoy the landscape.The pine's trunk includes several branches, located one above another and numbered from 2 to y. Some of them (more precise, from 2 to p) are occupied by tiny vile grasshoppers which you're at war with. These grasshoppers are known for their awesome jumping skills: the grasshopper at branch x can jump to branches .Keeping this in mind, you wisely decided to choose such a branch that none of the grasshoppers could interrupt you. At the same time you wanna settle as high as possible since the view from up there is simply breathtaking.In other words, your goal is to find the highest branch that cannot be reached by any of the grasshoppers or report that it's impossible.", "input_spec": "The only line contains two integers p and y (2\u2009\u2264\u2009p\u2009\u2264\u2009y\u2009\u2264\u2009109).", "output_spec": "Output the number of the highest suitable branch. If there are none, print -1 instead.", "sample_inputs": ["3 6", "3 4"], "sample_outputs": ["5", "-1"], "notes": "NoteIn the first sample case grasshopper from branch 2 reaches branches 2, 4 and 6 while branch 3 is initially settled by another grasshopper. Therefore the answer is 5.It immediately follows that there are no valid branches in second sample case."}, "positive_code": [{"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": "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": "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 = 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": "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": "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"}, {"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": "\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())\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": "# -*- 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": "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": "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": "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": "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 pp:\n \n y-=1\n else:\n y=-1\n \n break\nprint(y)\n"}, {"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": "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": "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": "\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": "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\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": "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": "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": "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": "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": "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": "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": "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=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": "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": "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": "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(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())\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,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": "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": "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": "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": "\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": "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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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": "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": "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(int(x ** .5), p) + 1)):\n print(x)\n exit()\nprint(-1)"}, {"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())\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": "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 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 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": "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": "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, 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": "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": "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": "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 pp:\n \n y-=1\n else:\n y=-1\n \n break\nprint(y)\n"}, {"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, 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\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": "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": "\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": "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": "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": "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 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": "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": "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": "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 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": "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": "\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": "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": "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": "\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": "#!/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": "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": "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": "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= [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 ip:\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": "\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": "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 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": "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": "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": "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": "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 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\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": "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 = 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": "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)"}], "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 in):\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:\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]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 ipppp:\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 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 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:\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"} {"nl": {"description": "Kitahara Haruki has bought n apples for Touma Kazusa and Ogiso Setsuna. Now he wants to divide all the apples between the friends.Each 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.But 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?", "input_spec": "The 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.", "output_spec": "In 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).", "sample_inputs": ["3\n100 200 100", "4\n100 100 100 200"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first test sample Kitahara Haruki can give the first and the last apple to Ogiso Setsuna and the middle apple to Touma Kazusa."}, "positive_code": [{"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": "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": "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())\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": "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": "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=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())\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": "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(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": "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(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": "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(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": "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": "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(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())\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": "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": "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\""}, {"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": "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": "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": "#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= 2 and n_100 % 2 == 0:\n print \"YES\"\nelse:\n print \"NO\""}, {"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())\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": "num_apple=int(input())\nweight=input().split()\nif num_apple!=1:\n count1=0\n count2=0\n i=0\n while ic2%2 and (c1-2*c2%2)%2==0 else 'NO')\n"}, {"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": "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": "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": "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": "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(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": "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": "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": "_, 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 = 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": "# -*- 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": "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": "#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": "\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 = 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": "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": "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": "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 = 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": "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": "#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": "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": "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= 2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"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": "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\")"}, {"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": "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": "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": "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": "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": "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": "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 = 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": "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(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": "#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 1) and (not(ev%2))):\n print('YES')\nelse:\n print('NO')\n#Balamar"}, {"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": "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 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": "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": "#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())\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(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": "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 = 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": "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()\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(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": "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=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(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(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": "# 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": "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": "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": "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=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())\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": "#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": "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 = 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": "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())\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(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"}], "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 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= 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 a0:\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 ic:\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 i1 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"} {"nl": {"description": "Manao is taking part in a quiz. The quiz consists of n consecutive questions. A correct answer gives one point to the player. The game also has a counter of consecutive correct answers. When the player answers a question correctly, the number on this counter increases by 1. If the player answers a question incorrectly, the counter is reset, that is, the number on it reduces to 0. If after an answer the counter reaches the number k, then it is reset, and the player's score is doubled. Note that in this case, first 1 point is added to the player's score, and then the total score is doubled. At the beginning of the game, both the player's score and the counter of consecutive correct answers are set to zero.Manao remembers that he has answered exactly m questions correctly. But he does not remember the order in which the questions came. He's trying to figure out what his minimum score may be. Help him and compute the remainder of the corresponding number after division by 1000000009 (109\u2009+\u20099).", "input_spec": "The single line contains three space-separated integers n, m and k (2\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u2009109;\u00a00\u2009\u2264\u2009m\u2009\u2264\u2009n).", "output_spec": "Print a single integer \u2014 the remainder from division of Manao's minimum possible score in the quiz by 1000000009 (109\u2009+\u20099).", "sample_inputs": ["5 3 2", "5 4 2"], "sample_outputs": ["3", "6"], "notes": "NoteSample 1. Manao answered 3 questions out of 5, and his score would double for each two consecutive correct answers. If Manao had answered the first, third and fifth questions, he would have scored as much as 3 points.Sample 2. Now Manao answered 4 questions. The minimum possible score is obtained when the only wrong answer is to the question 4.Also note that you are asked to minimize the score and not the remainder of the score modulo 1000000009. For example, if Manao could obtain either 2000000000 or 2000000020 points, the answer is 2000000000\u00a0mod\u00a01000000009, even though 2000000020\u00a0mod\u00a01000000009 is a smaller number."}, "positive_code": [{"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, 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())\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": "\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": "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": "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 =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": "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": "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": "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": "'''\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": "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": "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": "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": "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": "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())\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": "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,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": "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": "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": "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": "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": "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 #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": "\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": "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())\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())\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": "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": "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": "#/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, 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": "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, 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": "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": "# 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": "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, 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": "# 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 = 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": "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\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": "'''\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": "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": "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,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": "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(0, m - n + n / k)\nprint (m - k * x + k * (pow(2, x + 1, M) - 2) + M) % M \n"}, {"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())\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": "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": "# 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": "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<= 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())\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": "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": "#------------------------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": "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": "# -*- 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": "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": "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": "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": "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"}, {"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": "#!/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<= 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": "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,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": "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": "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<= 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": "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": "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": "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())\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": "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": "# -*- 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": "# 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": "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": "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": "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": "'''\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": "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": "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": "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": "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": "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": "# 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": "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": "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": "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,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": "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": "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": "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": "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": "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\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": "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"}], "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<= 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<= 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"} {"nl": {"description": "After finishing eating her bun, Alyona came up with two integers n and m. She decided to write down two columns of integers\u00a0\u2014 the first column containing integers from 1 to n and the second containing integers from 1 to m. Now the girl wants to count how many pairs of integers she can choose, one from the first column and the other from the second column, such that their sum is divisible by 5.Formally, Alyona wants to count the number of pairs of integers (x,\u2009y) such that 1\u2009\u2264\u2009x\u2009\u2264\u2009n, 1\u2009\u2264\u2009y\u2009\u2264\u2009m and equals 0.As usual, Alyona has some troubles and asks you to help.", "input_spec": "The only line of the input contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091\u2009000\u2009000).", "output_spec": "Print the only integer\u00a0\u2014 the number of pairs of integers (x,\u2009y) such that 1\u2009\u2264\u2009x\u2009\u2264\u2009n, 1\u2009\u2264\u2009y\u2009\u2264\u2009m and (x\u2009+\u2009y) is divisible by 5.", "sample_inputs": ["6 12", "11 14", "1 5", "3 8", "5 7", "21 21"], "sample_outputs": ["14", "31", "1", "5", "7", "88"], "notes": "NoteFollowing pairs are suitable in the first sample case: for x\u2009=\u20091 fits y equal to 4 or 9; for x\u2009=\u20092 fits y equal to 3 or 8; for x\u2009=\u20093 fits y equal to 2, 7 or 12; for x\u2009=\u20094 fits y equal to 1, 6 or 11; for x\u2009=\u20095 fits y equal to 5 or 10; for x\u2009=\u20096 fits y equal to 4 or 9. Only the pair (1,\u20094) is suitable in the third sample case."}, "positive_code": [{"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": "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"}, {"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 = 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=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": "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": "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": "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())\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": "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": "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 = 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": "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": "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": "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) = [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=(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": "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, 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": "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": "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,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": "#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,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": "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, 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=(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": "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": "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": "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(\" \"))\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": "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 = 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())\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": "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 = 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": "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": "#!/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": "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": "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": "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,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())\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": "\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,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": "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": "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 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": "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 = 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": "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": "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": "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": "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": "#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": "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": "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": "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": "[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, 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": "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(\" \"))\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": "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": "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": "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": "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": "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": "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": "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, 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": "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": "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": "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, 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": "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": "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": "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=map(int,input().split())\nc=0\nfor i in range(1,n+1):\n c=c+(m+(i%5))//5\nprint(c)"}, {"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,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, 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=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": "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": "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=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": "#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": "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": "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": "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": "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": "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, 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": "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\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 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')=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": "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": "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"}, {"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": "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": "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"}], "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 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 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 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"} {"nl": {"description": "Arpa is taking a geometry exam. Here is the last problem of the exam.You are given three points a,\u2009b,\u2009c.Find a point and an angle such that if we rotate the page around the point by the angle, the new position of a is the same as the old position of b, and the new position of b is the same as the old position of c.Arpa is doubting if the problem has a solution or not (i.e. if there exists a point and an angle satisfying the condition). Help Arpa determine if the question has a solution or not.", "input_spec": "The only line contains six integers ax,\u2009ay,\u2009bx,\u2009by,\u2009cx,\u2009cy (|ax|,\u2009|ay|,\u2009|bx|,\u2009|by|,\u2009|cx|,\u2009|cy|\u2009\u2264\u2009109). It's guaranteed that the points are distinct.", "output_spec": "Print \"Yes\" if the problem has a solution, \"No\" otherwise. You can print each letter in any case (upper or lower).", "sample_inputs": ["0 1 1 1 1 0", "1 1 0 0 1000 1000"], "sample_outputs": ["Yes", "No"], "notes": "NoteIn the first sample test, rotate the page around (0.5,\u20090.5) by .In the second sample test, you can't find any solution."}, "positive_code": [{"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": "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": "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": "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": "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, 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())\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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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": "''' ===============================\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": "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": "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": "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": "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": "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": "#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": "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": "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": "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 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": "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(' '))\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, 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": "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": "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": "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\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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(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": "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": "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": "# 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": "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": "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": "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": "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": "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": "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": "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": "[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": "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": "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 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": "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": "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": "#!/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": "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": "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": "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": "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": "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": "#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": "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": "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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "''' ===============================\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": "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": "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": "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": "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": "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": "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": "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\")"}, {"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\")"}], "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"} {"nl": {"description": "Alice and Bob begin their day with a quick game. They first choose a starting number X0\u2009\u2265\u20093 and try to reach one million by the process described below. Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it is selects a prime number smaller than the current number, and announces the smallest multiple of this prime number that is not smaller than the current number.Formally, he or she selects a prime p\u2009<\u2009Xi\u2009-\u20091 and then finds the minimum Xi\u2009\u2265\u2009Xi\u2009-\u20091 such that p divides Xi. Note that if the selected prime p already divides Xi\u2009-\u20091, then the number does not change.Eve has witnessed the state of the game after two turns. Given X2, help her determine what is the smallest possible starting number X0. Note that the players don't necessarily play optimally. You should consider all possible game evolutions.", "input_spec": "The input contains a single integer X2 (4\u2009\u2264\u2009X2\u2009\u2264\u2009106). It is guaranteed that the integer X2 is composite, that is, is not prime.", "output_spec": "Output a single integer\u00a0\u2014 the minimum possible X0.", "sample_inputs": ["14", "20", "8192"], "sample_outputs": ["6", "15", "8191"], "notes": "NoteIn the first test, the smallest possible starting number is X0\u2009=\u20096. One possible course of the game is as follows: Alice picks prime 5 and announces X1\u2009=\u200910 Bob picks prime 7 and announces X2\u2009=\u200914. In the second case, let X0\u2009=\u200915. Alice picks prime 2 and announces X1\u2009=\u200916 Bob picks prime 5 and announces X2\u2009=\u200920. "}, "positive_code": [{"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())\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": "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 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 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 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 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 (ansm:\n break\n d=m-m%p\n if d+p<=number:\n answer=min(answer,d+1)\nprint(answer)"}, {"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"}, {"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"}, {"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=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": "\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"}], "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"} {"nl": {"description": "The only difference between the easy and the hard versions is constraints.A subsequence is a string that can be derived from another string by deleting some or no symbols without changing the order of the remaining symbols. Characters to be deleted are not required to go successively, there can be any gaps between them. For example, for the string \"abaca\" the following strings are subsequences: \"abaca\", \"aba\", \"aaa\", \"a\" and \"\" (empty string). But the following strings are not subsequences: \"aabaca\", \"cb\" and \"bcaa\".You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.In one move you can take any subsequence $$$t$$$ of the given string and add it to the set $$$S$$$. The set $$$S$$$ can't contain duplicates. This move costs $$$n - |t|$$$, where $$$|t|$$$ is the length of the added subsequence (i.e. the price equals to the number of the deleted characters).Your task is to find out the minimum possible total cost to obtain a set $$$S$$$ of size $$$k$$$ or report that it is impossible to do so.", "input_spec": "The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n, k \\le 100$$$) \u2014 the length of the string and the size of the set, correspondingly. The second line of the input contains a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters.", "output_spec": "Print one integer \u2014 if it is impossible to obtain the set $$$S$$$ of size $$$k$$$, print -1. Otherwise, print the minimum possible total cost to do it.", "sample_inputs": ["4 5\nasdf", "5 6\naaaaa", "5 7\naaaaa", "10 100\najihiushda"], "sample_outputs": ["4", "15", "-1", "233"], "notes": "NoteIn the first example we can generate $$$S$$$ = { \"asdf\", \"asd\", \"adf\", \"asf\", \"sdf\" }. The cost of the first element in $$$S$$$ is $$$0$$$ and the cost of the others is $$$1$$$. So the total cost of $$$S$$$ is $$$4$$$."}, "positive_code": [{"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] = [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": "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": "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, 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": "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": "#!/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": "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": "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": "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": "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": "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": "\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": "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 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": "# 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, 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": "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": "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": "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": "# @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": "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": "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,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)= 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, 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": "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)= d:\n\tprint(wyn)\nelse:\n\tprint(-1)\n\t"}, {"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": "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": "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": "#!/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, 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": "\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": "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": "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": "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": "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": "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": "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 nxt0:\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": "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": "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": "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": "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": "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": "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": "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": "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": "\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 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": "\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": "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())\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": "# 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": "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 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": "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": "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": "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": "# 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": "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, 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": "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 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": "# 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": "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": "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": "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": "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": "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": "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 )| | \\/ / __ \\_\\ \\_/ \\\\ \\_/ \\ / /\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": "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": "\"\"\"\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 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 break\n print(sumu)\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\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": "# @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": "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": "# 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": "from collections import deque\nn,m=map(int,input().split())\ns=input()\nd=deque([s])\nans=1\nan=0\ndd={}\nwhile d and ans 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 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": "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": "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": "\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": "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) 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": "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\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])=0):\n if s+dp[-1][j]= 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": "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": "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 k0:\n print(-1)\nelse:\n print(ans)\n#print(k,ans,st)"}, {"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": "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 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"}], "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 \n# Date : 30.08.2019\n# Last Modified Date: 30.08.2019\n# Last Modified By : JCHRYS \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])=0):\n if s+dp[-1][j]= 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 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 cost\n if len(output)=k:\n return cost\n if len(output)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"} {"nl": {"description": "Sometimes Mister B has free evenings when he doesn't know what to do. Fortunately, Mister B found a new game, where the player can play against aliens.All characters in this game are lowercase English letters. There are two players: Mister B and his competitor.Initially the players have a string s consisting of the first a English letters in alphabetical order (for example, if a\u2009=\u20095, then s equals to \"abcde\").The players take turns appending letters to string s. Mister B moves first.Mister B must append exactly b letters on each his move. He can arbitrary choose these letters. His opponent adds exactly a letters on each move.Mister B quickly understood that his opponent was just a computer that used a simple algorithm. The computer on each turn considers the suffix of string s of length a and generates a string t of length a such that all letters in the string t are distinct and don't appear in the considered suffix. From multiple variants of t lexicographically minimal is chosen (if a\u2009=\u20094 and the suffix is \"bfdd\", the computer chooses string t equal to \"aceg\"). After that the chosen string t is appended to the end of s.Mister B soon found the game boring and came up with the following question: what can be the minimum possible number of different letters in string s on the segment between positions l and r, inclusive. Letters of string s are numerated starting from 1.", "input_spec": "First and only line contains four space-separated integers: a, b, l and r (1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u200912, 1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009109) \u2014 the numbers of letters each player appends and the bounds of the segment.", "output_spec": "Print one integer \u2014 the minimum possible number of different letters in the segment from position l to position r, inclusive, in string s.", "sample_inputs": ["1 1 1 8", "4 2 2 6", "3 7 4 6"], "sample_outputs": ["2", "3", "1"], "notes": "NoteIn the first sample test one of optimal strategies generate string s\u2009=\u2009\"abababab...\", that's why answer is 2.In the second sample test string s\u2009=\u2009\"abcdbcaefg...\" can be obtained, chosen segment will look like \"bcdbc\", that's why answer is 3.In the third sample test string s\u2009=\u2009\"abczzzacad...\" can be obtained, chosen, segment will look like \"zzz\", that's why answer is 1."}, "positive_code": [{"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": "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": "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))"}, {"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 "}, {"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))"}], "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=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=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=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+1a:\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=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=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"} {"nl": {"description": "Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with queen, and the cell contains a piece of the enemy color, the queen is able to move to this square. After that the enemy's piece is removed from the board. The queen cannot move to a cell containing an enemy piece if there is some other piece between it and the queen. There is an n\u2009\u00d7\u2009n chessboard. We'll denote a cell on the intersection of the r-th row and c-th column as (r,\u2009c). The square (1,\u20091) contains the white queen and the square (1,\u2009n) contains the black queen. All other squares contain green pawns that don't belong to anyone.The players move in turns. The player that moves first plays for the white queen, his opponent plays for the black queen.On each move the player has to capture some piece with his queen (that is, move to a square that contains either a green pawn or the enemy queen). The player loses if either he cannot capture any piece during his move or the opponent took his queen during the previous move. Help Vasya determine who wins if both players play with an optimal strategy on the board n\u2009\u00d7\u2009n.", "input_spec": "The input contains a single number n (2\u2009\u2264\u2009n\u2009\u2264\u2009109) \u2014 the size of the board.", "output_spec": "On the first line print the answer to problem \u2014 string \"white\" or string \"black\", depending on who wins if the both players play optimally. If the answer is \"white\", then you should also print two integers r and c representing the cell (r,\u2009c), where the first player should make his first move to win. If there are multiple such cells, print the one with the minimum r. If there are still multiple squares, print the one with the minimum c.", "sample_inputs": ["2", "3"], "sample_outputs": ["white\n1 2", "black"], "notes": "NoteIn the first sample test the white queen can capture the black queen at the first move, so the white player wins.In the second test from the statement if the white queen captures the green pawn located on the central vertical line, then it will be captured by the black queen during the next move. So the only move for the white player is to capture the green pawn located at (2,\u20091). Similarly, the black queen doesn't have any other options but to capture the green pawn located at (2,\u20093), otherwise if it goes to the middle vertical line, it will be captured by the white queen.During the next move the same thing happens \u2014 neither the white, nor the black queen has other options rather than to capture green pawns situated above them. Thus, the white queen ends up on square (3,\u20091), and the black queen ends up on square (3,\u20093). In this situation the white queen has to capture any of the green pawns located on the middle vertical line, after that it will be captured by the black queen. Thus, the player who plays for the black queen wins."}, "positive_code": [{"source_code": "#br = open('d.in')\nn = int(raw_input())\nprint [\"white\\n%d %d\" % (1, 2), \"black\"][n % 2]\n"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")\n#\n"}, {"source_code": "print[\"white\\n1 2\",\"black\"][input()%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": "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())\n\nif n % 2:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"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 \"white\\n1 2\" if int(raw_input()) % 2 == 0 else \"black\""}, {"source_code": "print(\"black\"if int(input())%2else \"white\\n1 2\")"}, {"source_code": "a=input()\nif(a%2==0):\n\tprint \"white\"\n\tprint \"1 2\"\nelse:\n\tprint \"black\"\n"}, {"source_code": "__author__ = 'zhan'\n\nprint(\"black\" if int(input())&1 else \"white\\n1 2\")"}, {"source_code": "n=int(input())\nprint(\"white\\n1 2\" if (n % 2==0) else \"black\");\n"}, {"source_code": "print(\"black\" if int(input()) % 2 else \"white\\n1 2\")"}, {"source_code": "n = int(input())\nif n%2==1:\n print('black')\nelse:\n print('white\\n1 2')"}, {"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": "print (\"white\\n1 2\",\"black\")[input()%2]"}, {"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(raw_input())\n\nif n % 2 == 0:\n\tprint 'white\\n1 2'\nelse:\n\tprint 'black'"}, {"source_code": "n = int(input())\nif n & 1 == 0:\n print('white\\n1 2')\nelse:\n print('black')\n"}, {"source_code": "n =int (input())\nif n%2==0:\n print (\"white\\n1 2\")\nelse:\n print(\"black\")"}, {"source_code": "n=input()\nif n%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": "n=int(input())\nif n%2==0 :\n print(\"white\")\n print(\"1 2\")\nelse :\n print(\"black\")\n \n"}, {"source_code": "print('white\\n1 2' if int(input()) % 2 == 0 else 'black')\n"}, {"source_code": "print( \"white\\n1 2\" if int(input())%2==0 else \"black\" )\n"}, {"source_code": "a = input()\nif a % 2 == 0:\n\tprint '''white\n1 2'''\nelse:\n\tprint 'black'\n"}, {"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() )\nif n % 2:\n\tprint ( \"black\" )\nelse:\n\tprint ( \"white\\n1 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())\nif n % 2:\n print \"black\"\nelse:\n print \"white\"\n print 1, 2\n"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")\n#\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": "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": "n = int(input())\nif n % 2 == 0:\n print(\"white\")\n print(\"1 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": "print \"white\\n1 2\" if int(raw_input()) % 2 == 0 else \"black\""}, {"source_code": "n=int(input())\nif n%2==0:\n print('white')\n print('1 2')\nelse:\n print('black')"}, {"source_code": "if input()&1==0: print \"white\\n1 2\"\nelse: print \"black\""}, {"source_code": "n = int (input ())\nif n%2==0 :\n print(\"white\\n1 2\")\nelse :\n print (\"black\")"}, {"source_code": "print (\"white\\n1 2\",\"black\")[input()%2]\n"}, {"source_code": "n = int(input())\nif n%2:\n\tprint('black')\nelse:\n\tprint('white')\n\tprint('1 2')"}, {"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": "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": "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"}, {"source_code": "i = int(input())\n\nif i % 2 == 1:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "a=input()\nif a%2==0:\n print \"white\"\n print \"1 2\"\nelse:\n print \"black\"\n"}, {"source_code": "n = input()\nif n & 1:\n\tprint 'black'\nelse:\n\tprint 'white\\n1 2'"}, {"source_code": "n = input()\nif n % 2 == 0:\n print \"white\"\n print 1, 2\nelse:\n print \"black\""}, {"source_code": "print \"black\" if input()&1 else \"white\\n1 2\""}, {"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\") \n \n"}, {"source_code": "n=input()\nif n%2==0:\n\tprint \"white\"\n\tprint 1,2\nelse:\n\tprint \"black\"\n"}, {"source_code": "n=int(input())\nif n%2==0:\n print(\"white\\n1 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": "n = int(input())\n\nif n % 2 != 0:\n print(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "n = int(input())\n\nif n % 2 == 0:\n print(\"white\\n1 2\")\nelse:\n print(\"black\")\n#######\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": "print 'black' if int(raw_input())%2 else 'white\\n1 2'\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": "__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": "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": "n = int(input())\nif n % 2 == 0:\n print('white')\n print('1 2')\nelse:\n print('black')\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()\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 (\"white\\n1 2\",\"black\")[input()%2]\n"}, {"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' if int(input()) % 2 == 0 else 'black')\n"}, {"source_code": "if int(raw_input())%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(\"black\")\nelse:\n print(\"white\")\n print(\"1 2\")"}, {"source_code": "print(\"black\"if int(input().split()[0])%2 else\"white\\n1 2\")\n"}, {"source_code": "n = int(input())\nif (n % 2 == 1):\n\tprint(\"black\")\nelse:\n\tprint(\"white\\n1 2\")"}, {"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 & 0b1:\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": "if(input()%2==0):print \"white\\n1 2\"\nelse:print \"black\""}, {"source_code": "n = int(input())\nif n%2==0:\n print(\"white\")\n print(\"1 2\")\nelse:\n print(\"black\")"}, {"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": "n = int(input())\nif n%2==0:\n print('white\\n1 2')\nelse:\n print('black')"}, {"source_code": "print('white\\n1 2' if int(input()) % 2 == 0 else 'black')\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": "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(raw_input())\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": "n=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(input()) % 2 == 0 else 'black')\n"}, {"source_code": "print \"white\\n1 2\" if int(raw_input()) % 2 is 0 else \"black\""}, {"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())\nif(n%2==0):\n print(\"white\")\n print(1,2)\nelse:\n print(\"black\")"}, {"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": "n = int(raw_input())\n\nif n % 2 == 0:\n print \"white\"\n print \"1 2\"\nelse:\n print \"black\"\n"}, {"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 = input()\nif(n&1==1):\n print \"black\"\nelse:\n print \"white\"\n print \"1 2\"\n"}, {"source_code": "print (\"white\\n1 2\",\"black\")[input()%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(input())\nif n%2==1:\n print(\"black\")\nelse:\n print(\"white\")\n print(1,2)"}, {"source_code": "#br = open('d.in')\nn = int(raw_input())\nprint [\"white\\n%d %d\" % (1, 2), \"black\"][n % 2]\n"}, {"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==0:\n print('white')\n print('1 2')\nelse:\n print('black')"}], "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"} {"nl": {"description": "After a wonderful evening in the restaurant the time to go home came. Leha as a true gentlemen suggested Noora to give her a lift. Certainly the girl agreed with pleasure. Suddenly one problem appeared: Leha cannot find his car on a huge parking near the restaurant. So he decided to turn to the watchman for help.Formally the parking can be represented as a matrix 109\u2009\u00d7\u2009109. There is exactly one car in every cell of the matrix. All cars have their own machine numbers represented as a positive integer. Let's index the columns of the matrix by integers from 1 to 109 from left to right and the rows by integers from 1 to 109 from top to bottom. By coincidence it turned out, that for every cell (x,\u2009y) the number of the car, which stands in this cell, is equal to the minimum positive integer, which can't be found in the cells (i,\u2009y) and (x,\u2009j), 1\u2009\u2264\u2009i\u2009<\u2009x,\u20091\u2009\u2264\u2009j\u2009<\u2009y. The upper left fragment 5\u2009\u00d7\u20095 of the parking Leha wants to ask the watchman q requests, which can help him to find his car. Every request is represented as five integers x1,\u2009y1,\u2009x2,\u2009y2,\u2009k. The watchman have to consider all cells (x,\u2009y) of the matrix, such that x1\u2009\u2264\u2009x\u2009\u2264\u2009x2 and y1\u2009\u2264\u2009y\u2009\u2264\u2009y2, and if the number of the car in cell (x,\u2009y) does not exceed k, increase the answer to the request by the number of the car in cell (x,\u2009y). For each request Leha asks the watchman to tell him the resulting sum. Due to the fact that the sum can turn out to be quite large, hacker asks to calculate it modulo 109\u2009+\u20097.However the requests seem to be impracticable for the watchman. Help the watchman to answer all Leha's requests.", "input_spec": "The first line contains one integer q (1\u2009\u2264\u2009q\u2009\u2264\u2009104)\u00a0\u2014 the number of Leha's requests. The next q lines contain five integers x1,\u2009y1,\u2009x2,\u2009y2,\u2009k (1\u2009\u2264\u2009x1\u2009\u2264\u2009x2\u2009\u2264\u2009109,\u20091\u2009\u2264\u2009y1\u2009\u2264\u2009y2\u2009\u2264\u2009109,\u20091\u2009\u2264\u2009k\u2009\u2264\u20092\u00b7109)\u00a0\u2014 parameters of Leha's requests.", "output_spec": "Print exactly q lines\u00a0\u2014 in the first line print the answer to the first request, in the second\u00a0\u2014 the answer to the second request and so on.", "sample_inputs": ["4\n1 1 1 1 1\n3 2 5 4 5\n1 1 5 5 10000\n1 4 2 5 2"], "sample_outputs": ["1\n13\n93\n0"], "notes": "NoteLet's analyze all the requests. In each case the requested submatrix is highlighted in blue.In the first request (k\u2009=\u20091) Leha asks only about the upper left parking cell. In this cell the car's number is 1. Consequentally the answer is 1.In the second request (k\u2009=\u20095) suitable numbers are 4,\u20091,\u20092,\u20093,\u20092,\u20091. Consequentally the answer is 4\u2009+\u20091\u2009+\u20092\u2009+\u20093\u2009+\u20092\u2009+\u20091\u2009=\u200913.In the third request (k\u2009=\u200910000) Leha asks about the upper left frament 5\u2009\u00d7\u20095 of the parking. Since k is big enough, the answer is equal to 93.In the last request (k\u2009=\u20092) none of the cur's numbers are suitable, so the answer is 0."}, "positive_code": [{"source_code": "mod = 1000000007\ndef sum(x,y,k,add) :\n if kk:\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"}, {"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 kk: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"} {"nl": {"description": "Today Vasya visited a widely known site and learned that the continuation of his favourite game Codecraft II will appear after exactly k months. He looked at the calendar and learned that at the moment is the month number s. Vasya immediately got interested in what month Codecraft III will appear. Help him understand that.All the twelve months in Vasya's calendar are named using their usual English names: January, February, March, April, May, June, July, August, September, October, November, December.", "input_spec": "The first input line contains the name of the current month. It is guaranteed that it is a proper English name of one of twelve months. The first letter is uppercase, the rest are lowercase. The second line contains integer k (0\u2009\u2264\u2009k\u2009\u2264\u2009100) \u2014 the number of months left till the appearance of Codecraft III.", "output_spec": "Print starting from an uppercase letter the name of the month in which the continuation of Codeforces II will appear. The printed name must be contained in the list January, February, March, April, May, June, July, August, September, October, November, December.", "sample_inputs": ["November\n3", "May\n24"], "sample_outputs": ["February", "May"], "notes": null}, "positive_code": [{"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": "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": "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=['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": "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": "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": "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": "# 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "# -*- 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": "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": "# -*- 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": "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": "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": "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": "# 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "a=[\"January\",\"February\",\"March\",\"April\",\"May\",\"June\",\"July\",\"August\",\"September\",\"October\",\"November\",\"December\"]\nprint a[(a.index(raw_input())+input())%12]"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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']\n\nmonth = input()\nk = int(input())\n\nprint(months[(k + months.index(month)) % 12])\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": "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": "# -*- 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": "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": "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": "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": "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": "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": "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": "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": "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 = 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": "from datetime import datetime\nimport calendar\nprint calendar.month_name[(datetime.strptime(raw_input(), \"%B\").month - 1 + int(raw_input())) % 12 + 1]"}, {"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": "#!/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": "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": "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": "#!/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": "# 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": "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"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 = 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": "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": "months ='January,February,March,April,May,June,July,August,September,October,November,December'.split(',')\nprint(months[(months.index(input()) + int(input()))%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": "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"}], "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"} {"nl": {"description": "Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully submitted it at the first attempt. Misha solved the problem that costs a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contest started and Vasya submitted the problem d minutes after the contest started. As you know, on Codeforces the cost of a problem reduces as a round continues. That is, if you submit a problem that costs p points t minutes after the contest started, you get points. Misha and Vasya are having an argument trying to find out who got more points. Help them to find out the truth.", "input_spec": "The first line contains four integers a, b, c, d (250\u2009\u2264\u2009a,\u2009b\u2009\u2264\u20093500, 0\u2009\u2264\u2009c,\u2009d\u2009\u2264\u2009180). It is guaranteed that numbers a and b are divisible by 250 (just like on any real Codeforces round).", "output_spec": "Output on a single line: \"Misha\" (without the quotes), if Misha got more points than Vasya. \"Vasya\" (without the quotes), if Vasya got more points than Misha. \"Tie\" (without the quotes), if both of them got the same number of points.", "sample_inputs": ["500 1000 20 30", "1000 1000 1 1", "1500 1000 176 177"], "sample_outputs": ["Vasya", "Tie", "Misha"], "notes": null}, "positive_code": [{"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": "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 = 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": "\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 = map(int, raw_input().split())\nmishascore=max(3*a/10,a-a/250*c)\nvasyascore=max(3*b/10,b-b/250*d)\nif mishascorevasyascore:\n print \"Misha\"\nelse:\n print \"Tie\"\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": "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())\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,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": "\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,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 t1mv:\n print('Misha')\nelif mm==mv:\n print('Tie')\nelse:\n print('Vasya')"}, {"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": "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": "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": "# 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": "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 My):\n print(\"Misha\")\nelif(y>x):\n print(\"Vasya\")\nelse:\n print(\"Tie\")\n"}, {"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": "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())\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 b:\n print(\"Misha\")\nelif a < b:\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())\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,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())\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=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": "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": "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 v : print(\"Misha\")\nelif v > m : print(\"Vasya\")\nelse : print(\"Tie\")\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": "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,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 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, 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())\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": "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= 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 (MishaY:\n\tprint(\"Misha\")\nelse:\n\tprint(\"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": "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\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": "#!/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": "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": "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": "#-*-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": "\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 = 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, 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": "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 mscore2:\n\tprint('Misha')\nelif score2>score1:\n\tprint('Vasya')\nelse:\n\tprint('Tie')\t\t"}, {"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 p1judge(b,d) else 'Vasya' if judge(a,c)s2,s1 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())\nmishascore=max(3*a/10,a-a/250*c)\nvasyascore=max(3*b/10,b-b/250*d)\nif mishascorevasyascore:\n print \"Misha\"\nelse:\n print \"Tie\"\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= 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 = [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": "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(xx2):\n print(\"Misha\")\nelif(x2>x1):\n print(\"Vasya\")\nelse:\n print(\"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": "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": "\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())\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": "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": "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 V:\n print 'Misha'\nelif M < V:\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(x>y):\n print(\"Misha\")\nelif(xans2:\n\tprint 'Misha'\nelif ans1==ans2:\n\tprint 'Tie'\nelse:\n\tprint 'Vasya'\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 = 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": "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": "\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": "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": "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_maxp2:\n print(\"Misha\")\nelif p2>p1:\n print(\"Vasya\")\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 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": "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": "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": "'''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": "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": "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": "\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": "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": "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": "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) max(3*b/10,b-b/250*d):\n\tprint \"Misha\"\nelse:\n\tprint \"Tie\""}, {"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": "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 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": "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(abd:\n print(\"Misha\")\nelif acv:print('Misha')\nelif v>m:print('Vasya')\nelse:print('Tie')\n"}, {"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 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": "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": "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": "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"}], "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 sMvasya:\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 xv:\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 vb 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 pasV: print \"Misha\"\nelif sMy:\n print(\"Misha\")\nelif x 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 cv:\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 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 sMy:\n print(\"Misha\")\nelif x1:\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()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 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(ap2):\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 cd):\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 xans2:\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 mp2:\n print(\"Misha\")\nelif p1 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(as2:\n\tprint \"Misha\"\nelse:print \"Vasya\""}], "src_uid": "95b19d7569d6b70bd97d46a8541060d0"} {"nl": {"description": "Developing tools for creation of locations maps for turn-based fights in a new game, Petya faced the following problem.A field map consists of hexagonal cells. Since locations sizes are going to be big, a game designer wants to have a tool for quick filling of a field part with identical enemy units. This action will look like following: a game designer will select a rectangular area on the map, and each cell whose center belongs to the selected rectangle will be filled with the enemy unit.More formally, if a game designer selected cells having coordinates (x1,\u2009y1) and (x2,\u2009y2), where x1\u2009\u2264\u2009x2 and y1\u2009\u2264\u2009y2, then all cells having center coordinates (x,\u2009y) such that x1\u2009\u2264\u2009x\u2009\u2264\u2009x2 and y1\u2009\u2264\u2009y\u2009\u2264\u2009y2 will be filled. Orthogonal coordinates system is set up so that one of cell sides is parallel to OX axis, all hexagon centers have integer coordinates and for each integer x there are cells having center with such x coordinate and for each integer y there are cells having center with such y coordinate. It is guaranteed that difference x2\u2009-\u2009x1 is divisible by 2.Working on the problem Petya decided that before painting selected units he wants to output number of units that will be painted on the map.Help him implement counting of these units before painting. ", "input_spec": "The only line of input contains four integers x1,\u2009y1,\u2009x2,\u2009y2 (\u2009-\u2009109\u2009\u2264\u2009x1\u2009\u2264\u2009x2\u2009\u2264\u2009109,\u2009\u2009-\u2009109\u2009\u2264\u2009y1\u2009\u2264\u2009y2\u2009\u2264\u2009109) \u2014 the coordinates of the centers of two cells.", "output_spec": "Output one integer \u2014 the number of cells to be filled.", "sample_inputs": ["1 1 5 5"], "sample_outputs": ["13"], "notes": null}, "positive_code": [{"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, raw_input().split())\nprint (x2 - x1) / 2 * ((y2 - y1) / 2) + ((x2 - x1) / 2 + 1) * ((y2 - y1) / 2 + 1)\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": "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": "\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": "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(' '))\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": "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": "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, 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": "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": "# -*- 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": "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": "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": "a, b, c, d = map(int, raw_input().split())\nprint (c - a + 1) * (d - b + 1) + 1 >> 1\n"}, {"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": "xo, yo, xk, yk = map(int, input().split())\nprint((xk - xo + 1) * (yk - yo + 1) // 2 + 1)"}, {"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())\nprint(((y2 - y1)//2 + 1) * ((x2 - x1)//2 + 1) + ((y2 - y1)//2) * ((x2 - x1)//2))\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": "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": "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 = [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())\nn = (y2 - y1) // 2 + 1\nk = x2 - x1 + 1\nprint(n * (k // 2 + 1) + (n - 1) * (k // 2))\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 .\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())\nprint(((y2 - y1)//2 + 1) * ((x2 - x1)//2 + 1) + ((y2 - y1)//2) * ((x2 - x1)//2))\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 = [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())\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": "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 = map(int,input().split())\nprint(((y2 - y1)//2 + 1) * ((x2 - x1)//2 + 1) + ((y2 - y1)//2) * ((x2 - x1)//2))\n"}, {"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": "# -*- 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": "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": "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 = 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": "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": "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": "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": "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": "# -*- 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": "x1,y1,x2,y2 = map(int,input().split())\nprint(((y2-y1)//2 + 1)*(x2-x1+1)-(x2-x1)//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": "#!/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 .\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": "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())\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": "A, B, C, D = map(int, raw_input().split())\nprint (C - A + 1) * (D - B + 1) // 2 + 1"}, {"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": "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": "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())\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": "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"}, {"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,input().split())\na=(y2-y1+2)//2\nb=(x2-x1+1)\nc=(a*b)-((x2-x1)//2)\nprint(int(c))"}, {"source_code": "a,b,c,d = map(int,input().split(\" \"))\n\nf = (c-a+1)*(d-b+1)\nprint((f+1)//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\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(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": "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": "a, b, c, d = map(int, input().split(' '))\ndy = (d-b)//2+1\ndx = c - a + 1\nprint(dy*dx - (dx//2))"}, {"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": "a,b,c,d=map(int,input().split(' '))\nprint((((c-a+1)*(d-b+1)+1)//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": "#!/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": "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": "x1, y1, x2, y2 = map(int, input().split())\nprint(((y2 - y1) // 2 + 1) * (x2 - x1 + 1) - (x2 - x1) // 2)\n"}, {"source_code": "a,b,c,d = map(int,input().split(\" \"))\n\nf = (c-a+1)*(d-b+1)\nprint((f+1)//2)"}, {"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": "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())\nprint(((x2-x1)//2+1)*((y2-y1)//2+1)+((x2-x1)//2)*((y2-y1)//2))"}, {"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": "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"}, {"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": "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 = list(map(int, input().split(' ')))\nprint(((x2 - x1) // 2 + 1) * ((y2 - y1) // 2 + 1) + ((x2 - x1) // 2) * ((y2 - y1) // 2))"}, {"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 = map(int,input().split())\nprint(((y2-y1)//2 + 1)*(x2-x1+1)-(x2-x1)//2)"}, {"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": "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": "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": "x1,y1,x2,y2 = map(int,input().split())\nprint(((y2-y1)//2 + 1)*(x2-x1+1)-(x2-x1)//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, input().split())\nans = (((y2 - y1) // 2) + 1) * (x2 - x1 + 1) - (x2 - x1) // 2\nprint(ans)\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": "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"}, {"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": "# 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,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": "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": "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())\nx = x2 - x1\ny = y2 - y1\nprint((y//2+(y//2+1))*x//2+y//2+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": "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": "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,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 = 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(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())\na, b = (x2 - x1) // 2, (y2 - y1) // 2\nprint(a * b + (a + 1) * (b + 1))"}, {"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())\n\ndx, dy = (x2 - x1) // 2, (y2 - y1) // 2\nprint(dx + 1 + (2 * dx + 1) * dy)"}], "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 .\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 .\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 .\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"} {"nl": {"description": "Vasya has got an undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. This graph doesn't contain any self-loops or multiple edges. Self-loop is an edge connecting a vertex to itself. Multiple edges are a pair of edges such that they connect the same pair of vertices. Since the graph is undirected, the pair of edges $$$(1, 2)$$$ and $$$(2, 1)$$$ is considered to be multiple edges. Isolated vertex of the graph is a vertex such that there is no edge connecting this vertex to any other vertex.Vasya wants to know the minimum and maximum possible number of isolated vertices in an undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges. ", "input_spec": "The only line contains two integers $$$n$$$ and $$$m~(1 \\le n \\le 10^5, 0 \\le m \\le \\frac{n (n - 1)}{2})$$$. It is guaranteed that there exists a graph without any self-loops or multiple edges with such number of vertices and edges.", "output_spec": "In the only line print two numbers $$$min$$$ and $$$max$$$ \u2014 the minimum and maximum number of isolated vertices, respectively.", "sample_inputs": ["4 2", "3 1"], "sample_outputs": ["0 1", "1 1"], "notes": "NoteIn the first example it is possible to construct a graph with $$$0$$$ isolated vertices: for example, it should contain edges $$$(1, 2)$$$ and $$$(3, 4)$$$. To get one isolated vertex, we may construct a graph with edges $$$(1, 2)$$$ and $$$(1, 3)$$$. In the second example the graph will always contain exactly one isolated vertex."}, "positive_code": [{"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, 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": "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": "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": "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": "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": "n,m = map(int, input().split())\nk=0\nwhile k*(k-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 = 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": "#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())\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": "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": "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,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": "'''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": "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": "# 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 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": "#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": "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": "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": "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": "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": "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": "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\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\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": "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=b:\n print (a-i)\n h=1\n break\n i+=1\nif h==0:\n print (0)"}, {"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#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 = 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 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": "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": "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\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": "#!/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": "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": "n,e=map(int,input().split())\nmaxi=-1\nfor i in range(n+1):\n if (i*(i-1))/2= m:\n y = mid\n lo = mid + 1\n else:\n hi = mid - 1\nprint x, y\n"}, {"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,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": "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": "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": "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": "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": "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": "#!/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": "n,m=[int(i) for i in input().split()]\nx = 0\nwhile((x*(x+1))//2=1:\n while a*(a-1)/20:\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": "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": "n,m=map(int,input().split())\nif m==0:\n mx=n\nelse:\n i=2\n while i*(i-1)/2=n:\n mn=0\nelse:\n mn=n-2*m\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:\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, 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())\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": "#!/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": "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,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": "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= 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 s0])"}, {"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 = 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": "#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": "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": "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": "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": "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": "#!/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": "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": "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:\n break\n\nmaxi = max(0, n-i)\n\nprint mini, maxi"}, {"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": "n,m=map(int,input().split())\nif m==0:\n mx=n\nelse:\n i=2\n while i*(i-1)/2=n:\n mn=0\nelse:\n mn=n-2*m\nprint(mn,mx)"}, {"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, 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": "#!/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": "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())\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())\nmini = max(0, n - 2*m)\ntemp = 1\ncount = 1\nwhile(tempx[1]:\n max=x[0]-(i+1)\n break\nprint(min,max)"}, {"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": "\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 e:\n\t\t\thigh = mid\n\t\telse:\n\t\t\tlow = mid\n\tprint(mini,maxi)"}, {"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= 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": "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)"}], "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 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=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 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 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= 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"} {"nl": {"description": "Pak Chanek has a grid that has $$$N$$$ rows and $$$M$$$ columns. Each row is numbered from $$$1$$$ to $$$N$$$ from top to bottom. Each column is numbered from $$$1$$$ to $$$M$$$ from left to right.Each tile in the grid contains a number. The numbers are arranged as follows: Row $$$1$$$ contains integers from $$$1$$$ to $$$M$$$ from left to right. Row $$$2$$$ contains integers from $$$M+1$$$ to $$$2 \\times M$$$ from left to right. Row $$$3$$$ contains integers from $$$2 \\times M+1$$$ to $$$3 \\times M$$$ from left to right. And so on until row $$$N$$$. A domino is defined as two different tiles in the grid that touch by their sides. A domino is said to be tight if and only if the two numbers in the domino have a difference of exactly $$$1$$$. Count the number of distinct tight dominoes in the grid.Two dominoes are said to be distinct if and only if there exists at least one tile that is in one domino, but not in the other.", "input_spec": "The only line contains two integers $$$N$$$ and $$$M$$$ ($$$1 \\leq N, M \\leq 10^9$$$) \u2014 the number of rows and columns in the grid.", "output_spec": "An integer representing the number of distinct tight dominoes in the grid.", "sample_inputs": ["3 4", "2 1"], "sample_outputs": ["9", "1"], "notes": "NoteThe picture below is the grid that Pak Chanek has in the first example. The picture below is an example of a tight domino in the grid. "}, "positive_code": [{"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": "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": "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": "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 test1:\r\n print(n*(m-1))\r\nelse:\r\n print((n-1)*m)"}, {"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 M1):\r\n print(a*(b-1))\r\nelif(b==1):\r\n print(a-1)\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": "n, m = map(int, input().split())\r\n\r\nprint(max(n-1, n * (m-1)))"}, {"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))"}, {"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": "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 \r\n# #include \r\n# using namespace __gnu_pbds;\r\n# #define ll long long\r\n# #define ordered_set tree, rb_tree_tag,tree_order_statistics_node_update>\r\n# #define ordered_multiset tree, 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": "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": "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())\r\n\r\nif m == 1:\r\n print(n-1)\r\n\r\nelse:\r\n print((m-1)*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": "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": "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": "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\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": "\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": "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": "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": "a,b=map(int, input().split())\r\nif b>1:\r\n print(a*(b-1))\r\nelse:print(a-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\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": "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": "n,m=map(int,input().split())\r\nif m==1:print(n-1)\r\nif m!=1:print(n*(m-1))"}, {"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": "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\n\r\nif N == 1 or M == 1:\r\n print((N*M) - 1)\r\nelse:\r\n print((N * M) - 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(' '))\nif(m == 1):\n\tprint(n-1)\nelse:\n\tprint(n*(m-1))\n"}, {"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": "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": "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": "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": "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": "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": "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 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": "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))"}, {"source_code": "print(*map(lambda x: max(int(x[0])-1, int(x[0])*(int(x[1])-1)), [input().split()]))"}, {"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": "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": "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": "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": "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": "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": "a, b = map(int, input().split())\r\nprint(max((b == 1) * (a - 1), (b - 1) * a))"}, {"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": "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": "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": "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\nif M == 1:\r\n print(N - 1)\r\n exit()\r\nprint((M - 1) * N)\r\n"}, {"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": "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": "print((lambda a: a[0]*(a[1]-1) or (a[0]-1)) (list(map(int,input().split()))))"}, {"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": "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": "# 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": "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": "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": "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 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 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": "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": "# 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 = [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": "\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": "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 = map(int, input().split())\r\nif m != 1:\r\n print((m - 1) * n)\r\nelse:\r\n print(n - 1)"}, {"source_code": "n,m=map(int,input().split())\r\nif(m==1): n,m=m,n\r\nprint(n*(m-1))"}, {"source_code": "n,m=map(int,input().split())\r\nif(m==1): n,m=m,n\r\nprint(n*(m-1))"}, {"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": "\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": "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": "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": "print(*map(lambda x: max(int(x[0])-1, int(x[0])*(int(x[1])-1)), [input().split()]))"}, {"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": "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 = 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())\n\nif M == 1:\n print(N - 1)\nelse:\n print(\n N * (M - 1)\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": "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": "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 = [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": "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": "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": "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,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())\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": "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": "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,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"}], "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 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\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+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 nm:\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 nm:\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 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 nm:\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"} {"nl": {"description": "Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s consisting only of lowercase and uppercase Latin letters.Let A be a set of positions in the string. Let's call it pretty if following conditions are met: letters on positions from A in the string are all distinct and lowercase; there are no uppercase letters in the string which are situated between positions from A (i.e. there is no such j that s[j] is an uppercase letter, and a1\u2009<\u2009j\u2009<\u2009a2 for some a1 and a2 from A). Write a program that will determine the maximum number of elements in a pretty set of positions.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009200) \u2014 length of string s. The second line contains a string s consisting of lowercase and uppercase Latin letters.", "output_spec": "Print maximum number of elements in pretty set of positions for string s.", "sample_inputs": ["11\naaaaBaabAbA", "12\nzACaAbbaazzC", "3\nABC"], "sample_outputs": ["2", "3", "0"], "notes": "NoteIn the first example the desired positions might be 6 and 8 or 7 and 8. Positions 6 and 7 contain letters 'a', position 8 contains letter 'b'. The pair of positions 1 and 8 is not suitable because there is an uppercase letter 'B' between these position.In the second example desired positions can be 7, 8 and 11. There are other ways to choose pretty set consisting of three elements.In the third example the given string s does not contain any lowercase letters, so the answer is 0."}, "positive_code": [{"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": "# cook your dish here\nn=int(input())\nstring=str(input())\nc=0\nmaxi=0\na=[]\ni=0\nwhile i < len(string):\n while(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": "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": "import re\ninput()\nprint max(map(len,map(set,re.split('[A-Z]',raw_input()))))"}, {"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": "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": "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": "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": "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": "#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())\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": "# 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": "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": "import re\nn = input()\ns = raw_input()\nprint max(map(lambda x: len(set(x)), re.split(r'[A-Z]', s)))\n"}, {"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(input())\ns = input()+\"A\"\nl,r=0,0\nans = 0\nwhile l96:\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()\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": "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": "\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 = 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())\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())\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": "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())\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()\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": "\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": "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()\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 = 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 = 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": "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())\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": "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": "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": "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": "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(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": "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": "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=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": "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": "\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": "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())\ns = input()\nsm = set()\nme=0\nl=[]\nfor i in range(n):\n if s[i].islower():\n sm.add(s[i])\n if(me0):\n print(max(l))\nelse:\n print(0)"}, {"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 = 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 = 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": "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": "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": "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": "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": "# 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)"}, {"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": "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": "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": "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= 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": "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": "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": "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": "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": "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(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": "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": "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": "# -*- 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": "import re\nn = input()\ns = raw_input()\nprint max(map(lambda x: len(set(x)), re.split(r'[A-Z]', s)))\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": "n = int(input())\ns = input()+\"A\"\nl,r=0,0\nans = 0\nwhile l 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())\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 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": "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": "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\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": "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())\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()\nsm = set()\nme=0\nl=[]\nfor i in range(n):\n if s[i].islower():\n sm.add(s[i])\n if(me0):\n print(max(l))\nelse:\n print(0)"}, {"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": "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": "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": "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"}, {"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": "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": "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)"}], "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=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(max1min):\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 r95:\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=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 (x0):\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=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"} {"nl": {"description": "Mashmokh's boss, Bimokh, didn't like Mashmokh. So he fired him. Mashmokh decided to go to university and participate in ACM instead of finding a new job. He wants to become a member of Bamokh's team. In order to join he was given some programming tasks and one week to solve them. Mashmokh is not a very experienced programmer. Actually he is not a programmer at all. So he wasn't able to solve them. That's why he asked you to help him with these tasks. One of these tasks is the following.A sequence of l integers b1,\u2009b2,\u2009...,\u2009bl (1\u2009\u2264\u2009b1\u2009\u2264\u2009b2\u2009\u2264\u2009...\u2009\u2264\u2009bl\u2009\u2264\u2009n) is called good if each number divides (without a remainder) by the next number in the sequence. More formally for all i (1\u2009\u2264\u2009i\u2009\u2264\u2009l\u2009-\u20091).Given n and k find the number of good sequences of length k. As the answer can be rather large print it modulo 1000000007 (109\u2009+\u20097).", "input_spec": "The first line of input contains two space-separated integers n,\u2009k\u00a0(1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u20092000).", "output_spec": "Output a single integer \u2014 the number of good sequences of length k modulo 1000000007 (109\u2009+\u20097).", "sample_inputs": ["3 2", "6 4", "2 1"], "sample_outputs": ["5", "39", "2"], "notes": "NoteIn the first sample the good sequences are: [1,\u20091],\u2009[2,\u20092],\u2009[3,\u20093],\u2009[1,\u20092],\u2009[1,\u20093]."}, "positive_code": [{"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\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": "#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": "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": "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": "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": "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": "# 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": "\"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": "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": "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": "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": "#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": "\"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": "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": "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": "# 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": "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": "\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": "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": "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": "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\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": "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": "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": "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 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": "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 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": "#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": "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": "\"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": "\"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": "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": "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": "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": "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": "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": "\"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": "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": "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, 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": "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": "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": "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": "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": "\"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": "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": "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": "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": "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": "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": "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": "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": "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": "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, 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": "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": "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": "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": "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": "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": "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 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": "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": "\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": "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": "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": "\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": "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": "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": "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": "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": "# 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": "\"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": "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": "\"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": "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"}, {"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": "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 0:\n cp *= cf(K, ej)\n cp %= M\n ans += cp\n ans %= M\nprint ans\n\n\n"}, {"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,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": "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,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": "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": "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": "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())\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": "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": "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 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)"}], "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"} {"nl": {"description": "There are five people playing a game called \"Generosity\". Each person gives some non-zero number of coins b as an initial bet. After all players make their bets of b coins, the following operation is repeated for several times: a coin is passed from one player to some other player.Your task is to write a program that can, given the number of coins each player has at the end of the game, determine the size b of the initial bet or find out that such outcome of the game cannot be obtained for any positive number of coins b in the initial bet.", "input_spec": "The input consists of a single line containing five integers c1,\u2009c2,\u2009c3,\u2009c4 and c5 \u2014 the number of coins that the first, second, third, fourth and fifth players respectively have at the end of the game (0\u2009\u2264\u2009c1,\u2009c2,\u2009c3,\u2009c4,\u2009c5\u2009\u2264\u2009100).", "output_spec": "Print the only line containing a single positive integer b \u2014 the number of coins in the initial bet of each player. If there is no such value of b, then print the only value \"-1\" (quotes for clarity).", "sample_inputs": ["2 5 4 0 4", "4 5 9 2 1"], "sample_outputs": ["3", "-1"], "notes": "NoteIn the first sample the following sequence of operations is possible: One coin is passed from the fourth player to the second player; One coin is passed from the fourth player to the fifth player; One coin is passed from the first player to the third player; One coin is passed from the fourth player to the second player. "}, "positive_code": [{"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 = [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": "s = sum(map(int, raw_input().split()))\nprint s / 5 if s % 5 == 0 and s / 5 else -1\n\n"}, {"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": "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": "s = sum(map(int, raw_input().split(' ')))\nprint (s // 5) if s > 0 and s % 5 == 0 else -1\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": "\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": "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": "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": "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": "n=sum(list(map(int,input().split())))\nprint(-1 if n%5 or n==0 else n//5)"}, {"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": "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 = 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": "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": "#!/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": "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 = 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": "# 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": "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": "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(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": "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": "s = sum(map(int, raw_input().split(' ')))\nprint (s // 5) if s > 0 and s % 5 == 0 else -1\n"}, {"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": "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": "initial = sum(list(map(int, input().split()))) / 5\nprint(int(initial)) if initial.is_integer() and initial > 0 else print(-1)\n"}, {"source_code": "r = sum(map(int, raw_input().split()))\nprint -1 if r % 5 or r / 5 == 0 else r / 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": "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": "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": "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": "bet = sum(list(map(int , input().split())))\nif bet%5!=0 or bet==0:\n print(-1)\nelse:\n print(bet//5)"}, {"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": "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": "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": "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": "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": "#\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": "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()))\nprint s / 5 if s % 5 == 0 and s / 5 else -1\n\n"}, {"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": "s = sum((map(int, input().split())))\nprint([s//5, -1][s%5>0 or s==0])"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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 = sum(map(int, input().split()))\nif a % 5 or a // 5 == 0:\n print(-1)\nelse:\n print(a // 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": "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": "r = sum(map(int, raw_input().split()))\nprint -1 if r % 5 or r / 5 == 0 else r / 5\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": "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": "cn = sum(map(int,input().split()))\nprint(cn//5 if cn%5 == 0 and cn>0 else '-1')"}, {"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": "# -*- 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": "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": "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": "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": "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": "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": "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": "s = sum(map(int, raw_input().split()))\nprint [s / 5, -1][s % 5 != 0 or s == 0]"}, {"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": "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": "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": "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": "s=sum(map(int,raw_input().split()))\nif s==0 or s%5!=0:print -1\nelse:print s//5\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": "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": "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": "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": "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": "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": "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": "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": "ls = list(map(int,input().split()))\ns = sum(ls)\nprint([s//5,-1][s%5 != 0 or not s])"}, {"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": "sum=eval(raw_input().replace(' ','+'))\nprint [-1,sum/5][sum%5==0 and sum>0]"}, {"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"}, {"source_code": "n = sum(list(map(int, input().split())))\nprint(n//5 if n % 5 == 0 and n != 0 else -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": "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": "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": "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": "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=[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": "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": "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": "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": "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": "# 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": "b = sum([int(x) for x in input().split()])\nprint(int(b / 5) if (b > 0) and (b % 5 == 0) else -1)"}], "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 [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"} {"nl": {"description": "Vasilisa the Wise from a far away kingdom got a present from her friend Helga the Wise from a farther away kingdom. The present is a surprise box, yet Vasilisa the Wise doesn't know yet what the surprise actually is because she cannot open the box. She hopes that you can help her in that.The box's lock is constructed like that. The box itself is represented by an absolutely perfect black cube with the identical deepening on each face (those are some foreign nanotechnologies that the far away kingdom scientists haven't dreamt of). The box is accompanied by six gems whose form matches the deepenings in the box's faces. The box can only be opened after it is correctly decorated by the gems, that is, when each deepening contains exactly one gem. Two ways of decorating the box are considered the same if they can be obtained one from the other one by arbitrarily rotating the box (note that the box is represented by a perfect nanotechnological cube)Now Vasilisa the Wise wants to know by the given set of colors the following: in how many ways would she decorate the box in the worst case to open it? To answer this question it is useful to know that two gems of one color are indistinguishable from each other. Help Vasilisa to solve this challenging problem.", "input_spec": "The first line contains exactly 6 characters without spaces from the set {R, O, Y, G, B, V} \u2014 they are the colors of gems with which the box should be decorated.", "output_spec": "Print the required number of different ways to decorate the box.", "sample_inputs": ["YYYYYY", "BOOOOB", "ROYGBV"], "sample_outputs": ["1", "2", "30"], "notes": null}, "positive_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(\"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": "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"}, {"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": "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 [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": "a,b,c=map(int,input().split())\nif((a+b)<=c):\n print(2*(a+b))\nelif((a+c)=(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": "a,b,c=map(int,input().split())\nprint(min(a+b+c,2*(a+b),2*(a+c),2*(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": "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": "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": "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": "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": "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": "''''\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": "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": "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,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": "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": "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": "#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": "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": "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": "# 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": "#!/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": "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": "x=map(int,raw_input().split())\nif x[0]+x[1] 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": "\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=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": "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": "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, b, c=map(int, input().split())\nprint(min(a+b+c,a+b<<1,a+c<<1,b+c<<1))"}, {"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"}, {"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": "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": "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": "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()))\nL.sort()\nprint(min(2*(L[0]+L[1]),(L[0]+L[1]+L[2])))"}, {"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,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= 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": "d1,d2,d3=map(int,input().split())\nsum=0\nif(d1=c:\n print(a+b+c)\nelse:\n print(2*a+2*b)"}, {"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": "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": "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": "d1,d2,d3=map(int,input().split())\nprint(min([2*(d1+d2),d1+d2+d3,2*(d3+min(d1,d2))]))"}, {"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": "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": "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": "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": "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": "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": "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": "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 = 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": "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": "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": "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": "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": "Ptienda,Stienda,DosTienda=[int(x) for x in raw_input().split() ]\nsuma=Ptienda+Stienda\nMinimo=min(Ptienda,Stienda)\nMaximo=max(Ptienda,Stienda)\nif(DosTienda*2z[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, raw_input().split())\n\n\nprint min([d1+d2+d3, d1*2+d2*2, d2*2+d3*2, d3*2+d1*2])"}, {"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": "# 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 = 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": "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": "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": "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,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": "d1, d2, d3 = map(int, input().split())\nprint(min(d1+d2+d3, 2*(d1+d2), 2*(d3+d2), 2*(d1+d3)))"}, {"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": "a, b, c=map(int, input().split())\nprint(min(2*(a+b), 2*(b+c), 2*(a+c), a+b+c))"}], "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\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+d3a+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 \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+ba[2]: \n if a[0]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 (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 an:\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(a1b1):\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=c):\n d = a+b+c\nif((a+b)= 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"} {"nl": {"description": "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 t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this. 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).", "input_spec": "The first line contains the chessboard coordinates of square s, the second line \u2014 of square t. Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.", "output_spec": "In the first line print n \u2014 minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD. L, R, U, D 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. ", "sample_inputs": ["a8\nh1"], "sample_outputs": ["7\nRD\nRD\nRD\nRD\nRD\nRD\nRD"], "notes": null}, "positive_code": [{"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 y2x1 and y2==y1):\n x1+=1\n steps+=1\n arr.append(\"R\" ) \n elif (x2y1):\n x1-=1\n y1+=1\n steps+=1\n arr.append(\"LU\" ) \n elif (x2y1):\n y1+=1\n arr.append(\"U\" )\n steps+=1 \n elif (x2==x1 and y2 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": "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": "\ufeff\"\"\"\n

A. Shortest path of the king
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

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 t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this.

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).

Input

The first line contains the chessboard coordinates of square s, the second line \u2014 of square t.

Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.

Output

In the first line print n \u2014 minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.

L, R, U, D 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.

Examples
Input
a8
h1
Output
7
RD
RD
RD
RD
RD
RD
RD
\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": "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": "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": "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": "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": "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": "# 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": "\ufeff\"\"\"\n
A. Shortest path of the king
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

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 t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this.

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).

Input

The first line contains the chessboard coordinates of square s, the second line \u2014 of square t.

Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.

Output

In the first line print n \u2014 minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.

L, R, U, D 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.

Examples
Input
a8
h1
Output
7
RD
RD
RD
RD
RD
RD
RD
\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": "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": "#!/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": "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": "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 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_ydestination_x:\n for i in range(d):\n print(\"RU\")\n elif source_ydestination_y:\n for i in range(d):\n print(\"LU\")\nelse:\n if source_xdestination_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_ydestination_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": "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": "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": "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": "\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": "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()\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": "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": "\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": "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": "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 s1e2:\n ss+='D'\n else:\n ss+='U'\n s2-=(s2-e2)//abs(s2-e2)\n \n print(ss)\n"}, {"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": "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": "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": "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": "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": "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": "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 = 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": "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": "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": "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": "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\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 kxdy:\n move=move+'D'\n ky-=1\n elif ky0: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": "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": "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": "\ufeff\"\"\"\n
A. Shortest path of the king
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

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 t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this.

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).

Input

The first line contains the chessboard coordinates of square s, the second line \u2014 of square t.

Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.

Output

In the first line print n \u2014 minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.

L, R, U, D 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.

Examples
Input
a8
h1
Output
7
RD
RD
RD
RD
RD
RD
RD
\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": "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": "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": "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": "#!/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": "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": "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": "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": "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[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[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[0]):\n if(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()\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[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[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[0]):\n if(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": "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 cb:\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": "#!/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": "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) 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": "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": "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": "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": "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 xy2:\n y-=1\n b+='D'\n if y0: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": "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": "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=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\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 kxdy:\n move=move+'D'\n ky-=1\n elif ky 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": "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": "# -*- 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": "\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": "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": "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": "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[0] and l[3]==l[1]):\n l[0]+=1\n steps+=1\n arr.append(\"R\" ) \n elif (l[2]l[1]):\n l[0]-=1\n l[1]+=1\n steps+=1\n arr.append(\"LU\" ) \n elif (l[2]l[1]):\n l[1]+=1\n arr.append(\"U\" )\n steps+=1 \n elif (l[2]==l[0] and l[3] 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": "'''\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": "# -*- 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": "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 a0: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": "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)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 j0:\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": "#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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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": "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": "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": "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": "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) 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 = 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 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": "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"}], "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[1]:\n print('LU')\n if xy[0]>x0y0[0] and xy[1]x0y0[0] and xy[1]==x0y0[1]: print('R')\n if xy[0]x0y0[1] and xy[0]==x0y0[0]: print('U')\n if xy[1]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] 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[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] 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[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)_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)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[1]:\n arr1.append('L')\n x[1]-=1\n elif x[1]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[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('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('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]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('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('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 xy2:\n y-=1\n b+='D'\n if yx0y0[0] and xy[1]>x0y0[1]:\n print('RU')\n if xy[0]x0y0[1]:\n print('LU')\n if xy[0]>x0y0[0] and xy[1]x0y0[0] and xy[1]==x0y0[1]: print('R')\n if xy[0]x0y0[1] and xy[0]==x0y0[0]: print('U')\n if xy[1] 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[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('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('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]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('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('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] 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[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(col1row2 ):\n cond2=1\nelif(col1>col2 and row10:\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
A. Shortest path of the king
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

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 t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this.

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).

Input

The first line contains the chessboard coordinates of square s, the second line \u2014 of square t.

Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8.

Output

In the first line print n \u2014 minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD.

L, R, U, D 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.

Examples
Input
a8
h1
Output
7
RD
RD
RD
RD
RD
RD
RD
\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('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[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('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('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]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('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('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[1]:\n print('LU')\n x0y0[0]-=1\n x0y0[1]+=1\n if xy[0]>x0y0[0] and xy[1]x0y0[0] and xy[1]==x0y0[1]:\n print('R')\n x0y0[0]+=1\n if xy[0]x0y0[1] and xy[0]==x0y0[0]:\n print('U')\n x0y0[1]+=1\n if xy[1]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('LU')\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[1]:\n route.append('U')\n start[1]+= 1\n elif terminal[1]=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) 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[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('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('D')\n A[1]=A[1]-1\nwhile A[1]!=B[1]:\n if A[0]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('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('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[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('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('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)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 j0:\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)=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(yx1 and yx1 and y>y1):\n l.append('LD')\n x-=1\n y-=1\n elif(xy1):\n l.append('LU')\n x+=1\n y-=1\n elif(x0 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 a0 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 xy2:\n y-=1\n b+='D'\n if y 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": "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": "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": "print 42834>>input()&1\n"}, {"source_code": "s = '1001010111001010'\nprint(s[int(input()) - 1])"}, {"source_code": "r = '1001010111001010'\ni=input()\nprint r[i-1]\n"}, {"source_code": "print 42834>>input()&1"}, {"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": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "r = '1001010111001010'\ni=input()\nprint r[i-1]\n"}, {"source_code": "print 42834>>input()&1"}, {"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": "s = '1001010111001010'\nprint(s[int(input()) - 1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "out = \"1001010111001010\"\nprint out[input()-1]"}, {"source_code": "out = \"1001010111001010\"\nprint out[input()-1]"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print(\"1001010111001010\"[int(input())-1])"}, {"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": "print('1001010111001010'[int(input())-1])"}, {"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": "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"}, {"source_code": "print 42834>>input()&1"}, {"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": "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": "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": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print[0,1][42834&1<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\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 42834>>input()&1"}, {"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": "r = '1001010111001010'\ni=input()\nprint r[i-1]\n"}, {"source_code": "print('1001010111001010'[int(input())-1])"}, {"source_code": "print 42834>>input()&1\n"}, {"source_code": "print(\"01001010111001010\"[int(input())])\n# @Anticyclone \u53cc\u51fb666\u554a\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": "print(\"01001010111001010\"[int(input())])"}, {"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": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "s=\"01001010111001010\"\nprint(s[int(input())])"}, {"source_code": "print 42834>>input()&1"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"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": "print([1,0,0,1,0,1,0,1,1,1,0,0,1,0,1,0][int(input())-1])"}, {"source_code": "print 42834>>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 42834>>input()&1"}, {"source_code": "print [0,1][42834&1<0]"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"source_code": "s = '1001010111001010'\nprint(s[int(input()) - 1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"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(\"01001010111001010\"[int(input())])\n"}, {"source_code": "s = '1001010111001010'\nn = int(input()) - 1\nprint(s[n])"}, {"source_code": "print('1001010111001010'[int(input())-1])"}, {"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": "# 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": "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": "s = \"A1001010111001010\";print(s[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]\nm = int(raw_input())\nprint a[m-1]\n"}, {"source_code": "print(\"01001010111001010\"[eval(input())])"}, {"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 42834>>input()&1\n"}, {"source_code": "s=\"01001010111001010\"\nprint(s[int(input())])"}, {"source_code": "print('.1001010111001010'[int(input())])"}, {"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 42834>>input()&1\n"}, {"source_code": "print 42834>>input()&1\n"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"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]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "print(\"01001010111001010\"[int(input())])"}, {"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": "print(\"01001010111001010\"[int(input())])"}, {"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": "print(\"01001010111001010\"[int(input())]) # Learned/learnt something new."}, {"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": "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": "print(\"01001010111001010\"[int(input())])"}, {"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"}], "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"} {"nl": {"description": "Lavrenty, a baker, is going to make several buns with stuffings and sell them.Lavrenty has n grams of dough as well as m different stuffing types. The stuffing types are numerated from 1 to m. Lavrenty knows that 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. Such bun can be sold for di tugriks.Also he can make buns without stuffings. Each of such buns requires c0 grams of dough and it can be sold for d0 tugriks. So Lavrenty can cook any number of buns with different stuffings or without it unless he runs out of dough and the stuffings. Lavrenty throws away all excess material left after baking.Find the maximum number of tugriks Lavrenty can earn.", "input_spec": "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). 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).", "output_spec": "Print the only number \u2014 the maximum number of tugriks Lavrenty can earn.", "sample_inputs": ["10 2 2 1\n7 3 2 100\n12 3 1 10", "100 1 25 50\n15 5 20 10"], "sample_outputs": ["241", "200"], "notes": "NoteTo get the maximum number of tugriks in the first sample, you need to cook 2 buns with stuffing 1, 4 buns with stuffing 2 and a bun without any stuffing.In the second sample Lavrenty should cook 4 buns without stuffings."}, "positive_code": [{"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"}, {"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": "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\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 = [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": "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": "# 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": "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= 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": "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": "#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= 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": "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": "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": "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,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, 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": "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]\n\n\n"}, {"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"}, {"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": "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": "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": "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": "#!/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,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": "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": "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": "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": "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": "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": "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,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"}], "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"} {"nl": {"description": "Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it is constant; after that it is strictly decreasing. The first block (increasing) and the last block (decreasing) may be absent. It is allowed that both of this blocks are absent.For example, the following three arrays are unimodal: [5,\u20097,\u200911,\u200911,\u20092,\u20091], [4,\u20094,\u20092], [7], but the following three are not unimodal: [5,\u20095,\u20096,\u20096,\u20091], [1,\u20092,\u20091,\u20092], [4,\u20095,\u20095,\u20096].Write a program that checks if an array is unimodal.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of elements in the array. The second line contains n integers a1,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20091\u2009000) \u2014 the elements of the array.", "output_spec": "Print \"YES\" if the given array is unimodal. Otherwise, print \"NO\". You can output each letter in any case (upper or lower).", "sample_inputs": ["6\n1 5 5 5 4 2", "5\n10 20 30 20 10", "4\n1 2 1 2", "7\n3 3 3 3 3 3 3"], "sample_outputs": ["YES", "YES", "NO", "YES"], "notes": "NoteIn the first example the array is unimodal, because it is strictly increasing in the beginning (from position 1 to position 2, inclusively), that it is constant (from position 2 to position 4, inclusively) and then it is strictly decreasing (from position 4 to position 6, inclusively)."}, "positive_code": [{"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": "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": "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=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": "count = input()\nchisla = [int(symbol) for symbol in input().split()]\n\n\ndef strictly_increasing(L):\n return all(xy 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": "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())\na = list(map(int,input().split()))[:n]\nch = 0\nwhile(cha[ch+1]):\n ch += 1\nch += 1\nif(ch!=n):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"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": "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(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": "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": "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]l1[i+1]:\n decrement(l1,i+1)\n print(\"yes\")"}, {"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 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": "R= lambda: map(int,input().split())\nn=int(input())\nl=list(R())\ni,s1,s2,s3=1,0,0,0\nwhile il[i-1]: i+=1\ns1=i-1\nwhile i 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": "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": "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": "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 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": "n = int(input())\na = list(map(int,input().split()))[:n]\nch = 0\nwhile(cha[ch+1]):\n ch += 1\nch += 1\nif(ch!=n):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"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')"}, {"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": "#!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 printed=True\n print('NO')\n break\n elif 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": "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": "#!/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": "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": "#!/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 = 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]: 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": "__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": "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": "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()\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())\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())\nx = list(map(int, input().split(\" \")))\ni,j=1,n-1\nwhile ix[i-1]:i+=1\nwhile j>0 and x[j] arr[i+1]: i += 1\n else:\n could = False\n break\n\nprint(\"YES\" if could else \"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": "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": "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": "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]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": "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] nums[i]):\n i+=1\n \nif(i==x):\n print(\"YES\")\nelse:\n print(\"NO\")\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": "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 ta[i+1]:\n print \"NO\"\n exit()\nfor i in range(p,n):\n if a[i] 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": "# 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": "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 = 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": "n = int(input())\na = list(map(int,input().split()))\ni = 0\nj = n-1\nwhile i+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": "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 = 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": "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": "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": "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\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(ilista[i+1]):\n i += 1\n\nif(i == largo-1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"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\nif i==n-1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"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 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": "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": "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": "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": "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 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": "\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": "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": "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\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] 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": "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 inda[ind+1]:ind+=1\n\nif ind==n-1:\n print 'YES'\nelse:\n print 'NO'\n"}, {"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": "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": "R= lambda: map(int,input().split())\nn=int(input())\nl=list(R())\ni,s1,s2,s3=1,0,0,0\nwhile il[i-1]: i+=1\ns1=i-1\nwhile ia[ch+1]):\n ch += 1\nch += 1\nif(ch!=n):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"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\t\tf = False\n\t\t\t\tbreak\nif f==True:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"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=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+10 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": "import sys\nn = int(raw_input().strip())\nar = map(int, raw_input().strip().split(' '))\ni=0\t\nwhile (iar[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+11 and a[j-1]1 and a[j-1]l2[j+1]:\n decrement(l2,j+1)\n if l2[j]l1[i+1]:\n decrement(l1,i+1)\n print(\"yes\")"}, {"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+10 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(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": "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())\na = list(map(int, input().split(' ')))\nl1 = 0; l2 = n-1\nwhile l1a[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": "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": "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": "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(ilista[i+1]):\n i += 1\n\nif(i == largo-1):\n print(\"YES\")\nelse:\n print(\"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]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]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=int(input())\na=map(int,raw_input().split())\ni=0\nj=n\nwhile i+10 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": "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"}, {"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": "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(i) for i in input().split()]\ni=1 \nc=0\nwhile il[i-1]:\n i+=1 \n c+=1 \nwhile i 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\""}], "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] 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]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] 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]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(xy 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]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 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[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]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] 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\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]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 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]= 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(cha[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 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\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]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]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"} {"nl": {"description": "Earlier, when there was no Internet, each bank had a lot of offices all around Bankopolis, and it caused a lot of problems. Namely, each day the bank had to collect cash from all the offices.Once Oleg the bank client heard a dialogue of two cash collectors. Each day they traveled through all the departments and offices of the bank following the same route every day. The collectors started from the central department and moved between some departments or between some department and some office using special roads. Finally, they returned to the central department. The total number of departments and offices was n, the total number of roads was n\u2009-\u20091. In other words, the special roads system was a rooted tree in which the root was the central department, the leaves were offices, the internal vertices were departments. The collectors always followed the same route in which the number of roads was minimum possible, that is 2n\u2009-\u20092.One of the collectors said that the number of offices they visited between their visits to offices a and then b (in the given order) is equal to the number of offices they visited between their visits to offices b and then a (in this order). The other collector said that the number of offices they visited between their visits to offices c and then d (in this order) is equal to the number of offices they visited between their visits to offices d and then c (in this order). The interesting part in this talk was that the shortest path (using special roads only) between any pair of offices among a, b, c and d passed through the central department.Given the special roads map and the indexes of offices a, b, c and d, determine if the situation described by the collectors was possible, or not.", "input_spec": "The first line contains single integer n (5\u2009\u2264\u2009n\u2009\u2264\u20095000)\u00a0\u2014 the total number of offices and departments. The departments and offices are numbered from 1 to n, the central office has index 1. The second line contains four integers a, b, c and d (2\u2009\u2264\u2009a,\u2009b,\u2009c,\u2009d\u2009\u2264\u2009n)\u00a0\u2014 the indexes of the departments mentioned in collector's dialogue. It is guaranteed that these indexes are offices (i.e. leaves of the tree), not departments. It is guaranteed that the shortest path between any pair of these offices passes through the central department. On the third line n\u2009-\u20091 integers follow: p2,\u2009p3,\u2009...,\u2009pn (1\u2009\u2264\u2009pi\u2009<\u2009i), where pi denotes that there is a special road between the i-th office or department and the pi-th department. Please note the joint enumeration of departments and offices. It is guaranteed that the given graph is a tree. The offices are the leaves, the departments are the internal vertices.", "output_spec": "If the situation described by the cash collectors was possible, print \"YES\". Otherwise, print \"NO\".", "sample_inputs": ["5\n2 3 4 5\n1 1 1 1", "10\n3 8 9 10\n1 2 2 2 2 2 1 1 1", "13\n13 12 9 7\n1 1 1 1 5 5 2 2 2 3 3 4"], "sample_outputs": ["YES", "NO", "YES"], "notes": "NoteIn the first example the following collector's route was possible: . We can note that between their visits to offices a and b the collectors visited the same number of offices as between visits to offices b and a; the same holds for c and d (the collectors' route is infinite as they follow it each day).In the second example there is no route such that between their visits to offices c and d the collectors visited the same number of offices as between visits to offices d and c. Thus, there situation is impossible. In the third example one of the following routes is: ."}, "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=[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"}, {"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"} {"nl": {"description": "An elephant decided to visit his friend. It turned out that the elephant's house is located at point 0 and his friend's house is located at point x(x\u2009>\u20090) of the coordinate line. In one step the elephant can move 1, 2, 3, 4 or 5 positions forward. Determine, what is the minimum number of steps he need to make in order to get to his friend's house.", "input_spec": "The first line of the input contains an integer x (1\u2009\u2264\u2009x\u2009\u2264\u20091\u2009000\u2009000)\u00a0\u2014 The coordinate of the friend's house.", "output_spec": "Print the minimum number of steps that elephant needs to make to get from point 0 to point x.", "sample_inputs": ["5", "12"], "sample_outputs": ["1", "3"], "notes": "NoteIn the first sample the elephant needs to make one step of length 5 to reach the point x.In the second sample the elephant can get to point x if he moves by 3, 5 and 4. There are other ways to get the optimal answer but the elephant cannot reach x in less than three moves."}, "positive_code": [{"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": "n=input()\nif n%5<>0: print n/5+1\nelse: print n/5\n"}, {"source_code": "n = int(raw_input())\nprint((n + 4) // 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": "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": "n = int(raw_input())\nprint (n + 4) / 5"}, {"source_code": "print((int(input())+4)//5)"}, {"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": "x=input()\nn=x%5\nif(n==0):\n jump=x/5\nelse:\n jump=(x/5)+1\nprint jump\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": "\"\"\"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": "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": "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": "# 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())\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": "n=int(input())\nm=n//5\nif(n%5==0):\n print(m)\nelse:\n print(m+1)\n\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(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": "print -(input() // -5)\n"}, {"source_code": "a = input()\nif a%5==0 : print a/5\nelse : print a/5 +1"}, {"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": "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": "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": "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": "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": "x = int(input())\nif x % 5 == 0:\n print(x // 5)\nelse:\n print(x // 5 + 1)\n"}, {"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": "x = int(input())\nif x % 5 == 0:\n print(x // 5)\nelse:\n print(x // 5 + 1)\n"}, {"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": "import math\nprint(math.ceil(int(input())/5))"}, {"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": "# 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": "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": "s = int(input())\nif s%5:\n print(s//5 + 1)\nelse:\n print(s//5)"}, {"source_code": "print (input()+4)/5"}, {"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": "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": "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": "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": "n = int(input())\nb = -n//5\nprint(abs(b))\n"}, {"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": "x,count=int(input()),0\nwhile x>=5:\n count+=1\n x-=5\nif x>0:count+=1\nprint(count)"}, {"source_code": "import math\na = input()\nprint int(math.ceil(1.*a/5))\n"}, {"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": "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": "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 = input()\n\nif N % 5 == 0:\n print (N / 5)\nelse:\n print (N / 5 + 1)\n"}, {"source_code": "a = int(raw_input())\nif a%5 == 0:\n print a/5\nelse:\n print a/5 + 1 "}, {"source_code": "x=eval(input())\nprint((x+4)//5)\n"}, {"source_code": "n=int(input())\n\nif(n%5 != 0):\n print(n//5 + 1)\nelse:\n print(n//5)"}, {"source_code": "n=input()\nprint '1' if n<=5 else -(n/-5)"}, {"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": "x=int(input())\ny=0\nif(x%5==0):\n print(x//5)\nelse:\n print((x//5)+1)\n"}, {"source_code": "n=int(input())\nif n%5:\n print(int(n/5+1))\nelse:\n print(int(n/5))"}, {"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": "a=input()\nb=a/5\nif a%5!=0:\n print b+1\nelse:\n print b"}, {"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": "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"}, {"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": "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": "n = int(input())\nprint(n // 5 + (n / 5 != n // 5))\n"}, {"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": "print (input()+4)/5"}, {"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": "# 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": "\nnum = int(raw_input())\nresultado = num // 5\nif num % 5 != 0:\n resultado += 1\nprint resultado\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": "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": "a = int(raw_input())\nif a%5 == 0:\n print a/5\nelse:\n print a/5 + 1 "}, {"source_code": "i = int(input())\np = i // 5\nif i % 5 > 0:\n p = p + 1\nprint(p)"}, {"source_code": "n=input()\nprint '1' if n<=5 else -(n/-5)"}, {"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": "x = int(raw_input())\n\nres = x / 5\n\nif x % 5 > 0:\n\tres += 1\n\nprint res"}, {"source_code": "x = float(raw_input())\n\nimport math\n\nprint int(math.ceil(x/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": "# =======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": "from math import ceil\nprint(ceil(int(input())/5))"}, {"source_code": "import math\n\nx = int(raw_input())\nprint int(math.ceil(x * 1.0 / 5))\n"}, {"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": "print((int(input())+4)//5)"}, {"source_code": "print -(input() // -5)"}, {"source_code": "n = int(raw_input())\n\nprint n // 5 if n % 5 == 0 else (n // 5) + 1"}, {"source_code": "print(-(-int(input())//5))"}, {"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": "a=int(raw_input(\"\"))\nb=a/5\nif(a%5!=0):\n b=b+1 \nprint b\n"}, {"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": "n=int(input())\ntemp=n+4\nprint(temp//5)\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": "s=0\nx=int(input())\nfor i in range(1,x+1,5):\n s+=1\nprint(s)\n"}, {"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": "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": "n=int(raw_input())\nif n%5 == 0:\n print n/5\nelse:\n print 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=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": "from sys import stdin\n\nx = int(stdin.readline())\nprint((x+4)//5)\n"}, {"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\nc=1\nn=int(input())\nif n%5==0:\n print(n//5)\nelse:\n print((n//5)+1)"}, {"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": "n = int(input())\nprint(n // 5 + (n / 5 != n // 5))\n"}], "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= 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= 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"} {"nl": {"description": "Overlooking the captivating blend of myriads of vernal hues, Arkady the painter lays out a long, long canvas.Arkady has a sufficiently large amount of paint of three colours: cyan, magenta, and yellow. On the one-dimensional canvas split into n consecutive segments, each segment needs to be painted in one of the colours.Arkady has already painted some (possibly none or all) segments and passes the paintbrush to you. You are to determine whether there are at least two ways of colouring all the unpainted segments so that no two adjacent segments are of the same colour. Two ways are considered different if and only if a segment is painted in different colours in them.", "input_spec": "The first line contains a single positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the length of the canvas. The second line contains a string s of n characters, the i-th of which is either 'C' (denoting a segment painted in cyan), 'M' (denoting one painted in magenta), 'Y' (one painted in yellow), or '?' (an unpainted one).", "output_spec": "If there are at least two different ways of painting, output \"Yes\"; otherwise output \"No\" (both without quotes). You can print each character in any case (upper or lower).", "sample_inputs": ["5\nCY??Y", "5\nC?C?Y", "5\n?CYC?", "5\nC??MM", "3\nMMY"], "sample_outputs": ["Yes", "Yes", "Yes", "No", "No"], "notes": "NoteFor the first example, there are exactly two different ways of colouring: CYCMY and CYMCY.For the second example, there are also exactly two different ways of colouring: CMCMY and CYCMY.For the third example, there are four ways of colouring: MCYCM, MCYCY, YCYCM, and YCYCY.For the fourth example, no matter how the unpainted segments are coloured, the existing magenta segments will prevent the painting from satisfying the requirements. The similar is true for the fifth example."}, "positive_code": [{"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": "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=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": "t = input()\na = list(input())\ni=0\nmaxm =1\nn =len(a)\nwhile i=1:\n if a[i+1] == a[i-1] :\n maxm = 2\n elif i=2 and f!=1):\n print(\"Yes\")\n elif(c<2 and f!=1):\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 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 = 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": "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": "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"}, {"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": "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": "\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#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=0 and i+11 or q>1) else \"NO\")\n"}, {"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": "#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\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 = 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": "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()\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": "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": "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": "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=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": "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()\nans = 0\nfor i in range(n):\n if (i 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())\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()\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+11):\n print(\"Yes\")\n else:\n print(\"No\")"}, {"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": "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, 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()\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": "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": "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": "#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": "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": "_,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________ _____________ ______\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": "n=int(input())\ns=input()\ni=1\nans=1\nif s[0]==\"?\":\n\tans=2\nwhile(i1:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\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": "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())\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 = 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": "\"\"\"\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": "n=int(input())\ns=input()\ni=1\nans=1\nif s[0]==\"?\":\n\tans=2\nwhile(i1:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n\n"}, {"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 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#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=0 and i+11 or q>1) else \"NO\")\n"}, {"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": "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": "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()\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": "# 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 i1):\n f=1 \n break\n i+=1 \nif f==1: print(\"Yes\")\nelse : print(\"No\")\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": "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": "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(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": "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": "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": "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": "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": "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": "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": "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 = 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()\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": "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": "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": "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 = 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": "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()\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": "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 = input()\nans = 0\nfor i in range(n):\n if (i 1):\n print('Yes')\nelse:\n print('No')"}, {"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())\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": "# -*- 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": "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": "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": "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": "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": "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": "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=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": "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": "\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": "'''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": "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": "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": "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(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()\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+11):\n print(\"Yes\")\n else:\n print(\"No\")"}, {"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": "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": "a=int(input());b='!'+input()+'@';ans=1;i=1;ok=0\nwhile i1:ok=1\n i+=1\nif ans and ok:print(\"YES\")\nelse:print(\"NO\")"}, {"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"}], "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=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 i0:\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 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=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 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 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 i0:\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=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=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 i0:\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"} {"nl": {"description": "Vasya studies divisibility rules at school. Here are some of them: Divisibility by 2. A number is divisible by 2 if and only if its last digit is divisible by 2 or in other words, is even. Divisibility by 3. A number is divisible by 3 if and only if the sum of its digits is divisible by 3. Divisibility by 4. A number is divisible by 4 if and only if its last two digits form a number that is divisible by 4. Divisibility by 5. A number is divisible by 5 if and only if its last digit equals 5 or 0. Divisibility by 6. A number is divisible by 6 if and only if it is divisible by 2 and 3 simultaneously (that is, if the last digit is even and the sum of all digits is divisible by 3). Divisibility by 7. Vasya doesn't know such divisibility rule. Divisibility by 8. A number is divisible by 8 if and only if its last three digits form a number that is divisible by 8. Divisibility by 9. A number is divisible by 9 if and only if the sum of its digits is divisible by 9. Divisibility by 10. A number is divisible by 10 if and only if its last digit is a zero. Divisibility by 11. A number is divisible by 11 if and only if the sum of digits on its odd positions either equals to the sum of digits on the even positions, or they differ in a number that is divisible by 11.Vasya got interested by the fact that some divisibility rules resemble each other. In fact, to check a number's divisibility by 2, 4, 5, 8 and 10 it is enough to check fulfiling some condition for one or several last digits. Vasya calls such rules the 2-type rules.If checking divisibility means finding a sum of digits and checking whether the sum is divisible by the given number, then Vasya calls this rule the 3-type rule (because it works for numbers 3 and 9).If we need to find the difference between the sum of digits on odd and even positions and check whether the difference is divisible by the given divisor, this rule is called the 11-type rule (it works for number 11).In some cases we should divide the divisor into several factors and check whether rules of different types (2-type, 3-type or 11-type) work there. For example, for number 6 we check 2-type and 3-type rules, for number 66 we check all three types. Such mixed divisibility rules are called 6-type rules. And finally, there are some numbers for which no rule works: neither 2-type, nor 3-type, nor 11-type, nor 6-type. The least such number is number 7, so we'll say that in such cases the mysterious 7-type rule works, the one that Vasya hasn't discovered yet. Vasya's dream is finding divisibility rules for all possible numbers. He isn't going to stop on the decimal numbers only. As there are quite many numbers, ha can't do it all by himself. Vasya asked you to write a program that determines the divisibility rule type in the b-based notation for the given divisor d.", "input_spec": "The first input line contains two integers b and d (2\u2009\u2264\u2009b,\u2009d\u2009\u2264\u2009100) \u2014 the notation system base and the divisor. Both numbers are given in the decimal notation.", "output_spec": "On the first output line print the type of the rule in the b-based notation system, where the divisor is d: \"2-type\", \"3-type\", \"11-type\", \"6-type\" or \"7-type\". If there are several such types, print the one that goes earlier in the given sequence. If a number belongs to the 2-type, print on the second line the least number of the last b-based digits that we will need to use to check the divisibility.", "sample_inputs": ["10 10", "2 3"], "sample_outputs": ["2-type\n1", "11-type"], "notes": "NoteThe divisibility rule for number 3 in binary notation looks as follows: \"A number is divisible by 3 if and only if the sum of its digits that occupy the even places differs from the sum of digits that occupy the odd places, in a number that is divisible by 3\". That's an 11-type rule. For example, 2110\u2009=\u2009101012. For it the sum of digits on odd positions equals 1\u2009+\u20091\u2009+\u20091\u2009=\u20093, an on even positions \u2014 0\u2009+\u20090\u2009=\u20090. The rule works and the number is divisible by 3. In some notations a number can fit into the 3-type rule and the 11-type rule. In this case the correct answer is \"3-type\"."}, "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": "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"}, {"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"} {"nl": {"description": "So many wall designs to choose from! Even modulo 106\u2009+\u20093, it's an enormous number. Given that recently Heidi acquired an unlimited supply of bricks, her choices are endless! She really needs to do something to narrow them down.Heidi is quick to come up with criteria for a useful wall: In a useful wall, at least one segment is wider than W bricks. This should give the zombies something to hit their heads against. Or, in a useful wall, at least one column is higher than H bricks. This provides a lookout from which zombies can be spotted at a distance. This should rule out a fair amount of possibilities, right? Help Heidi compute the number of useless walls that do not confirm to either of these criteria. In other words, a wall is useless if every segment has width at most W and height at most H.Parameter C, the total width of the wall, has the same meaning as in the easy version. However, note that the number of bricks is now unlimited.Output the number of useless walls modulo 106\u2009+\u20093.", "input_spec": "The first and the only line of the input contains three space-separated integers C, W and H (1\u2009\u2264\u2009C\u2009\u2264\u2009108, 1\u2009\u2264\u2009W,\u2009H\u2009\u2264\u2009100).", "output_spec": "Output the number of different walls, modulo 106\u2009+\u20093, which are useless according to Heidi's criteria.", "sample_inputs": ["1 1 1", "1 2 2", "1 2 3", "3 2 2", "5 4 9", "40 37 65"], "sample_outputs": ["2", "3", "4", "19", "40951", "933869"], "notes": "NoteIf there is no brick in any of the columns, the structure is considered as a useless wall."}, "positive_code": [{"source_code": "mod = 10 ** 6 + 3\n\ndef prod(a, b):\n return [[sum([a[i][k] * b[k][j] for k in range(len(b))]) % mod for j in range(len(b[0]))] for i in range(len(a))]\n\nc, w, h = map(int, input().split())\n\na = [[0] * (w + 1) for _ in range(w + 1)]\nfor i in range(w):\n a[i][i + 1] = 1\n \nfor cnt in range(0, w + 1):\n a[-1][-1 - cnt] = h ** cnt\n\nans = [[0] for _ in range(w + 1)]\nans[-1][0] = 1\nans[-2][0] = 1\n\nwhile c > 0:\n if c % 2 == 1:\n ans = prod(a, ans)\n c = c // 2\n if c > 0:\n a = prod(a, a)\n\nprint(ans[-1][0])"}], "negative_code": [], "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1"} {"nl": {"description": "You are given three integers $$$n$$$, $$$k$$$ and $$$f$$$.Consider all binary strings (i.\u2009e. all strings consisting of characters $$$0$$$ and/or $$$1$$$) of length from $$$1$$$ to $$$n$$$. For every such string $$$s$$$, you need to choose an integer $$$c_s$$$ from $$$0$$$ to $$$k$$$.A multiset of binary strings of length exactly $$$n$$$ is considered beautiful if for every binary string $$$s$$$ with length from $$$1$$$ to $$$n$$$, the number of strings in the multiset such that $$$s$$$ is their prefix is not exceeding $$$c_s$$$.For example, let $$$n = 2$$$, $$$c_{0} = 3$$$, $$$c_{00} = 1$$$, $$$c_{01} = 2$$$, $$$c_{1} = 1$$$, $$$c_{10} = 2$$$, and $$$c_{11} = 3$$$. The multiset of strings $$$\\{11, 01, 00, 01\\}$$$ is beautiful, since: for the string $$$0$$$, there are $$$3$$$ strings in the multiset such that $$$0$$$ is their prefix, and $$$3 \\le c_0$$$; for the string $$$00$$$, there is one string in the multiset such that $$$00$$$ is its prefix, and $$$1 \\le c_{00}$$$; for the string $$$01$$$, there are $$$2$$$ strings in the multiset such that $$$01$$$ is their prefix, and $$$2 \\le c_{01}$$$; for the string $$$1$$$, there is one string in the multiset such that $$$1$$$ is its prefix, and $$$1 \\le c_1$$$; for the string $$$10$$$, there are $$$0$$$ strings in the multiset such that $$$10$$$ is their prefix, and $$$0 \\le c_{10}$$$; for the string $$$11$$$, there is one string in the multiset such that $$$11$$$ is its prefix, and $$$1 \\le c_{11}$$$. Now, for the problem itself. You have to calculate the number of ways to choose the integer $$$c_s$$$ for every binary string $$$s$$$ of length from $$$1$$$ to $$$n$$$ in such a way that the maximum possible size of a beautiful multiset is exactly $$$f$$$.", "input_spec": "The only line of input contains three integers $$$n$$$, $$$k$$$ and $$$f$$$ ($$$1 \\le n \\le 15$$$; $$$1 \\le k, f \\le 2 \\cdot 10^5$$$).", "output_spec": "Print one integer \u2014 the number of ways to choose the integer $$$c_s$$$ for every binary string $$$s$$$ of length from $$$1$$$ to $$$n$$$ in such a way that the maximum possible size of a beautiful multiset is exactly $$$f$$$. Since it can be huge, print it modulo $$$998244353$$$.", "sample_inputs": ["1 42 2", "2 37 13", "4 1252 325", "6 153 23699", "15 200000 198756"], "sample_outputs": ["3", "36871576", "861735572", "0", "612404746"], "notes": "NoteIn the first example, the three ways to choose the integers $$$c_s$$$ are: $$$c_0 = 0$$$, $$$c_1 = 2$$$, then the maximum beautiful multiset is $$$\\{1, 1\\}$$$; $$$c_0 = 1$$$, $$$c_1 = 1$$$, then the maximum beautiful multiset is $$$\\{0, 1\\}$$$; $$$c_0 = 2$$$, $$$c_1 = 0$$$, then the maximum beautiful multiset is $$$\\{0, 0\\}$$$. "}, "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"}, {"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() "}], "negative_code": [], "src_uid": "4b8161259545e44c7d1046be2e4fe014"} {"nl": {"description": "Recently Ivan the Fool decided to become smarter and study the probability theory. He thinks that he understands the subject fairly well, and so he began to behave like he already got PhD in that area.To prove his skills, Ivan decided to demonstrate his friends a concept of random picture. A picture is a field of $$$n$$$ rows and $$$m$$$ columns, where each cell is either black or white. Ivan calls the picture random if for every cell it has at most one adjacent cell of the same color. Two cells are considered adjacent if they share a side.Ivan's brothers spent some time trying to explain that it's not how the randomness usually works. Trying to convince Ivan, they want to count the number of different random (according to Ivan) pictures. Two pictures are considered different if at least one cell on those two picture is colored differently. Since the number of such pictures may be quite large, print it modulo $$$10^9 + 7$$$.", "input_spec": "The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\le n, m \\le 100\\,000$$$), the number of rows and the number of columns of the field.", "output_spec": "Print one integer, the number of random pictures modulo $$$10^9 + 7$$$.", "sample_inputs": ["2 3"], "sample_outputs": ["8"], "notes": "NoteThe picture below shows all possible random pictures of size $$$2$$$ by $$$3$$$. "}, "positive_code": [{"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": "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 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()]\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": "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())\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": "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": "# -*- 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": "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": "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": "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": "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": "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 = [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": "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": "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": "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": "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": "# 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 i1:\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": "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())\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": "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 i0:\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 l0:\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]=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# 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=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": "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)"}, {"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": "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": "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())\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": "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 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())\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": "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=[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": "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": "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": "\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": "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": "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": "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": "# 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(100009):\n F.append((F[-1]+F[-2])%P)\nprint((F[N-1]+F[M-1]-1)*2%P)\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": "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=mod:\n\t\tfib[-1]%=mod\nprint((2*(fib[n-1]%mod+fib[m-1]%mod)-2)%mod)\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": "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": "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": "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 = [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": "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": "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": "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())\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())\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": "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": "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": "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": "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(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())\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": "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 = 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 nm:\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())\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)"}, {"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": "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": "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": "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": "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": "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": "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": "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# 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": "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": "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": "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": "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": "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().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": "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": "# 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 i1:\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": "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": "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": "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": "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": "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())\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# 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": "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)"}], "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 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 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 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"} {"nl": {"description": "Xenia the beginner mathematician is a third year student at elementary school. She is now learning the addition operation.The teacher has written down the sum of multiple numbers. Pupils should calculate the sum. To make the calculation easier, the sum only contains numbers 1, 2 and 3. Still, that isn't enough for Xenia. She is only beginning to count, so she can calculate a sum only if the summands follow in non-decreasing order. For example, she can't calculate sum 1+3+2+1 but she can calculate sums 1+1+2 and 3+3.You've got the sum that was written on the board. Rearrange the summans and print the sum in such a way that Xenia can calculate the sum.", "input_spec": "The first line contains a non-empty string s \u2014 the sum Xenia needs to count. String s contains no spaces. It only contains digits and characters \"+\". Besides, string s is a correct sum of numbers 1, 2 and 3. String s is at most 100 characters long.", "output_spec": "Print the new sum that Xenia can count.", "sample_inputs": ["3+2+1", "1+1+3+1+3", "2"], "sample_outputs": ["1+2+3", "1+1+1+3+3", "2"], "notes": null}, "positive_code": [{"source_code": "n = raw_input()\nl=[]\nfor i in n[::2]:\n\tl.append((i))\nl = sorted(l)\nprint \"+\".join(l)"}, {"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": "\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": "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": "print \"+\".join(sorted(raw_input()[::2]))\n"}, {"source_code": "print '+'.join(map(str, sorted(map(int, raw_input().split('+')))))\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": "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": "print(\"+\".join(sorted(input()[::2])))"}, {"source_code": "if __name__ == \"__main__\":\n print \"+\".join(map(str, sorted(map(int, raw_input().split(\"+\")))))"}, {"source_code": "num=map(str,raw_input().split('+'))\nprint \"+\".join(sorted(num))\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": "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=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": "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": "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": "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": "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": "print \"+\".join(sorted(raw_input()[::2]))"}, {"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": "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 i0 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": "print ('+'.join(sorted(raw_input().split('+'))))\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": "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()\narr = s.split('+')\narr.sort()\nprint(\"+\".join(map(str, arr)))"}, {"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": "print '+'.join(sorted(raw_input().split('+')))"}, {"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": "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": "print('+'.join(sorted(input().replace(\"+\",\"\"),key=str)))\n"}, {"source_code": "line = [int(e) for e in input().split('+')]\nline.sort()\nprint('+'.join([str(e) for e in line]))"}, {"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": "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": "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": "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=raw_input()\no='1+' * s.count('1')+'2+' * s.count('2') +'3+' * s.count('3')\nprint o[:-1]"}, {"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": "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": "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": "a = input()\nl = len(a)\narr = list()\ni = 0\nwhile i 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": "\na=[w for w in input().split('+')]\na.sort(key=int)\nprint('+'.join(w for w in a))"}, {"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": "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": "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": "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": "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()\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": "txt = [ int(i) for i in input().split(\"+\")]\nprint(\"+\".join([str(i) for i in sorted(txt)]))\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": "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": "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": "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": "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": "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": "def heapify(a,i,n):\n l = i\n lc=2*i +1\n rc=2*i +2\n \n if lcint(a[l]):\n l=lc\n if rcint(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": "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": "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": "#!/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": "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": "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": "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 = sorted([s for s in input().split('+')])\nprint('+'.join(S))\n"}, {"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 = 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": "\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": "print '+'.join(map(str, sorted(map(int, raw_input().split('+')))))\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": "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": "print '+'.join(map(str, sorted(map(int, raw_input().split('+')))))\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 ['1', '2', '3']:\n s += [key] * c[key]\nprint '+'.join(s)\n"}, {"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": "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": "from sys import stdin, stdout\na = stdin.readline().rstrip().split(\"+\")\nprint '+'.join(sorted(a))"}, {"source_code": "numbers = raw_input().split('+')\nnumbers.sort()\nprint '+'.join(numbers)"}, {"source_code": "s = map(int, raw_input().split('+'))\ns.sort()\nprint '+'.join(map(str, s))"}, {"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 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": "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": "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": "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": "print '+'.join(sorted(raw_input().split('+')))"}, {"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": "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=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": "arr = sorted(input().split('+'))\nn = len(arr)\nfor i in range(n-1): print(arr[i], end=\"+\")\nprint(arr[-1])"}, {"source_code": "x = str(input())\nn = 0\na = 0\nb = 0\nc = 0\nwhile n0:\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": "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": "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"}], "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 (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 (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"} {"nl": {"description": "Today Tavas got his test result as an integer score and he wants to share it with his girlfriend, Nafas.His phone operating system is Tavdroid, and its keyboard doesn't have any digits! He wants to share his score with Nafas via text, so he has no choice but to send this number using words. He ate coffee mix without water again, so right now he's really messed up and can't think.Your task is to help him by telling him what to type.", "input_spec": "The first and only line of input contains an integer s (0\u2009\u2264\u2009s\u2009\u2264\u200999), Tavas's score. ", "output_spec": "In the first and only line of output, print a single string consisting only from English lowercase letters and hyphens ('-'). Do not use spaces.", "sample_inputs": ["6", "99", "20"], "sample_outputs": ["six", "ninety-nine", "twenty"], "notes": "NoteYou can find all you need to know about English numerals in http://en.wikipedia.org/wiki/English_numerals ."}, "positive_code": [{"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": "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": "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": "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": "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": "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"}, {"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": "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": "#!/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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "# -*- 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 = {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": "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": "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": "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": "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": "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=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": "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": "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": "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": "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": "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\".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 = 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": "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": "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())\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": "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": "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": "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())\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": "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": "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": "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": "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": "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": "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": "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\".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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "#!/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": "'''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 = 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "#!/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": "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": "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": "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": "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": "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 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": "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=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": "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": "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": "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": "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 = 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": "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": "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": "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": "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": "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": "\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": "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 \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": "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": "#!/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": "#!/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/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())\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]))"}], "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: -*-\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: -*-\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"} {"nl": {"description": "Let's define a function $$$f(p)$$$ on a permutation $$$p$$$ as follows. Let $$$g_i$$$ be the greatest common divisor (GCD) of elements $$$p_1$$$, $$$p_2$$$, ..., $$$p_i$$$ (in other words, it is the GCD of the prefix of length $$$i$$$). Then $$$f(p)$$$ is the number of distinct elements among $$$g_1$$$, $$$g_2$$$, ..., $$$g_n$$$.Let $$$f_{max}(n)$$$ be the maximum value of $$$f(p)$$$ among all permutations $$$p$$$ of integers $$$1$$$, $$$2$$$, ..., $$$n$$$.Given an integers $$$n$$$, count the number of permutations $$$p$$$ of integers $$$1$$$, $$$2$$$, ..., $$$n$$$, such that $$$f(p)$$$ is equal to $$$f_{max}(n)$$$. Since the answer may be large, print the remainder of its division by $$$1000\\,000\\,007 = 10^9 + 7$$$.", "input_spec": "The only line contains the integer $$$n$$$ ($$$2 \\le n \\le 10^6$$$)\u00a0\u2014 the length of the permutations.", "output_spec": "The only line should contain your answer modulo $$$10^9+7$$$.", "sample_inputs": ["2", "3", "6"], "sample_outputs": ["1", "4", "120"], "notes": "NoteConsider the second example: these are the permutations of length $$$3$$$: $$$[1,2,3]$$$, $$$f(p)=1$$$. $$$[1,3,2]$$$, $$$f(p)=1$$$. $$$[2,1,3]$$$, $$$f(p)=2$$$. $$$[2,3,1]$$$, $$$f(p)=2$$$. $$$[3,1,2]$$$, $$$f(p)=2$$$. $$$[3,2,1]$$$, $$$f(p)=2$$$. The maximum value $$$f_{max}(3) = 2$$$, and there are $$$4$$$ permutations $$$p$$$ such that $$$f(p)=2$$$."}, "positive_code": [{"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]>= 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": "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*=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)"}], "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]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"} {"nl": {"description": "One 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:\u2014Shuffle the digits in this number in order to obtain the smallest possible number without leading zeroes.\u2014No problem! \u2014 said Bob and immediately gave her an answer.Alice 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.", "input_spec": "The 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.", "output_spec": "Print OK if Bob's answer is correct and WRONG_ANSWER otherwise.", "sample_inputs": ["3310\n1033", "4\n5"], "sample_outputs": ["OK", "WRONG_ANSWER"], "notes": null}, "positive_code": [{"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": "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": "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": "\"\"\"\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": "\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": "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": "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 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": "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": "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": "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": "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": "# -*- 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": "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": "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": "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 = 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": "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": "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": "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": "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": "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": "#!/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": "# -*- 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": "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": "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": "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": "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": "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=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": "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": "\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": "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": "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": "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": "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": "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": "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": "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": "\"\"\"\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": "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": "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": "n=input()\nb=input()\nl=[]\nfor i in range(len(n)):\n l.append(n[i])\nl.sort()\ni=0\nwhile( 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": "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": "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": "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": "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": "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": "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": "#------------------------------------------------------------------------\n# Name: module2\n# Purpose:\n#\n# Author: co\n#\n# Created: 05/10/2011\n# Copyright: (c) u161283f 2011\n# 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 = 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": "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": "#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": "#!/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": "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": "#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": "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": "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": "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": "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 ir+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=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": "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": "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": "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": "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": "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"}, {"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": "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, 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": "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# - 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": "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": "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 = 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": "# -*- 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": "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": "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": "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": "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": "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": "\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": "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')"}], "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 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 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-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 j0:\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 k0:\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 i0 and i!=0:\n if i0:\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 i0 and i!=0:\n if 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 j0:\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 permut0:\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 i0:\n if i0:\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 i0:\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(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 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"} {"nl": {"description": "zscoder wants to generate an input file for some programming competition problem.His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.Initially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.zscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.", "input_spec": "The only line contains three integers n, x and y (1\u2009\u2264\u2009n\u2009\u2264\u2009107, 1\u2009\u2264\u2009x,\u2009y\u2009\u2264\u2009109) \u2014 the number of letters 'a' in the input file and the parameters from the problem statement.", "output_spec": "Print the only integer t \u2014 the minimum amount of time needed to generate the input file.", "sample_inputs": ["8 1 1", "8 1 10"], "sample_outputs": ["4", "8"], "notes": null}, "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": "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\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": "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 "}, {"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 dub0:\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)= 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 dub0:\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"} {"nl": {"description": "Chris the Rabbit has been interested in arrays ever since he was a child. At the moment he is researching arrays with the length of n, containing only integers from 1 to n. He is not good at math, that's why some simple things drive him crazy. For example, yesterday he grew keen on counting how many different beautiful arrays there are. Chris thinks that an array is beautiful if it meets one of the two conditions: each elements, starting from the second one, is no more than the preceding one each element, starting from the second one, is no less than the preceding one Having got absolutely mad at himself and at math, Chris came to Stewie and Brian to ask them for help. However, they only laughed at him and said that the answer is too simple and not interesting. Help Chris the Rabbit to find the answer at last.", "input_spec": "The single line contains an integer n which is the size of the array (1\u2009\u2264\u2009n\u2009\u2264\u2009105).", "output_spec": "You must print the answer on a single line. As it can be rather long, you should print it modulo 1000000007.", "sample_inputs": ["2", "3"], "sample_outputs": ["4", "17"], "notes": null}, "positive_code": [{"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": "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": "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"}, {"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] 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"}, {"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": "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)"}], "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"} {"nl": {"description": "After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the shape of a rectangle in his backyard. He has set up coordinate axes, and he wants the sides of the rectangle to be parallel to them. Of course, the area of the rectangle must be positive. Wilbur had all four vertices of the planned pool written on a paper, until his friend came along and erased some of the vertices.Now Wilbur is wondering, if the remaining n vertices of the initial rectangle give enough information to restore the area of the planned swimming pool.", "input_spec": "The first line of the input contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u20094)\u00a0\u2014 the number of vertices that were not erased by Wilbur's friend. Each of the following n lines contains two integers xi and yi (\u2009-\u20091000\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u20091000)\u00a0\u2014the coordinates of the i-th vertex that remains. Vertices are given in an arbitrary order. It's guaranteed that these points are distinct vertices of some rectangle, that has positive area and which sides are parallel to the coordinate axes.", "output_spec": "Print the area of the initial rectangle if it could be uniquely determined by the points remaining. Otherwise, print \u2009-\u20091. ", "sample_inputs": ["2\n0 0\n1 1", "1\n1 1"], "sample_outputs": ["1", "-1"], "notes": "NoteIn the first sample, two opposite corners of the initial rectangle are given, and that gives enough information to say that the rectangle is actually a unit square.In the second sample there is only one vertex left and this is definitely not enough to uniquely define the area."}, "positive_code": [{"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": "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": "# 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": "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": "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": "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": "#!/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": "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= 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": "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": "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": "#----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": "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": "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": "__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 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": "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())\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": "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": "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": "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": "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": "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())\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": "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": "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": "__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 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": "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": "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": "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": "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": "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": "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": "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": "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())\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": "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": "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(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=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": "# 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": "# -*- 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": "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\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": "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": "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": "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": "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": "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": "#!/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 = 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": "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": "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": "\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": "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": "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": "__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": "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": "\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": "# 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": "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": "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": "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())\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=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": "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": "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": "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": "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 = 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": "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": "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": "#!/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": "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": "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(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": "# -*- 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": "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": "# 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"}, {"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": "#!/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": "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": "\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 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": "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": "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": "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 0 else -1)"}, {"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": "# -*- 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": "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": "# -*- 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"}], "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])ymax :\n ymax=int(s[k][1])\n if int(s[k][1])= 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])ymax :\n ymax=int(s[k][1])\n if int(s[k][1])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 \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 \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 j0:\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"} {"nl": {"description": "You have two variables a and b. Consider the following sequence of actions performed with these variables: If a\u2009=\u20090 or b\u2009=\u20090, end the process. Otherwise, go to step 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; 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.Initially the values of a and b are positive integers, and so the process will be finite.You have to determine the values of a and b after the process ends.", "input_spec": "The only line of the input contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091018). n is the initial value of variable a, and m is the initial value of variable b.", "output_spec": "Print two integers \u2014 the values of a and b after the end of the process.", "sample_inputs": ["12 5", "31 12"], "sample_outputs": ["0 1", "7 12"], "notes": "NoteExplanations to the samples: a\u2009=\u200912, b\u2009=\u20095 a\u2009=\u20092, b\u2009=\u20095 a\u2009=\u20092, b\u2009=\u20091 a\u2009=\u20090, b\u2009=\u20091; a\u2009=\u200931, b\u2009=\u200912 a\u2009=\u20097, b\u2009=\u200912."}, "positive_code": [{"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": "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 >= 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": "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": "\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().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())\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, 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": "\"\"\"\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": "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())\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())\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": "a,b=map(int,input().split())\nwhile a*b and not a<2*b<4*a:\n if b= 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": "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": "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": "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": "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, 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())\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": "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": "# 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": "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, 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": "\"\"\"\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": "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": "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": "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": "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": "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": "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": "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": "\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 = 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": "\"\"\"\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 = 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": "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": "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": "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": "# 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": "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": "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": "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": "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": "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 = 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())\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": "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=[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": "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": "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": "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": "\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": "\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": "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,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 = 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": "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": "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": "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": "#!/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": "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": "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,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": "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"}, {"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": "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())\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 = 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())\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": "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": "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": "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, 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=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 a*b and not a<2*b<4*a:\n if b= 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"}, {"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())\nfor _ in[0]*36:\n if b:a%=2*b\n if a:b%=2*a\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": "\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": "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": "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": "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": "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": "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 = 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": "\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": "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": "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": "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": "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, 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 = [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": "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": "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 = (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": "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\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"}], "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=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= 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 ab:\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=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=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"} {"nl": {"description": "You are given an infinite checkered field. You should get from a square (x1; y1) to a square (x2; y2). Using the shortest path is not necessary. You can move on the field squares in four directions. That is, when you are positioned in any square, you can move to any other side-neighboring one. A square (x; y) is considered bad, if at least one of the two conditions is fulfilled: |x\u2009+\u2009y|\u2009\u2261\u20090 (mod\u00a02a), |x\u2009-\u2009y|\u2009\u2261\u20090 (mod\u00a02b). Your task is to find the minimum number of bad cells one will have to visit on the way from (x1; y1) to (x2; y2).", "input_spec": "The only line contains integers a, b, x1, y1, x2 and y2 \u2014 the parameters of the bad squares, the coordinates of the initial and the final squares correspondingly (2\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009109 and |x1|,|y1|,|x2|,|y2|\u2009\u2264\u2009109). It is guaranteed that the initial and the final square aren't bad.", "output_spec": "Print a single number \u2014 the minimum number of bad cells that one will have to visit in order to travel from square (x1; y1) to square (x2; y2).", "sample_inputs": ["2 2 1 0 0 1", "2 2 10 11 0 1", "2 4 3 -1 3 7"], "sample_outputs": ["1", "5", "2"], "notes": "NoteIn the third sample one of the possible paths in (3;-1)->(3;0)->(3;1)->(3;2)->(4;2)->(4;3)->(4;4)->(4;5)->(4;6)->(4;7)->(3;7). Squares (3;1) and (4;4) are bad."}, "positive_code": [{"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/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"}, {"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())\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": "#!/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())\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": "\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)"}, {"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))"}, {"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"}], "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"} {"nl": {"description": "The finalists of the \"Russian Code Cup\" competition in 2214 will be the participants who win in one of the elimination rounds.The elimination rounds are divided into main and additional. Each of the main elimination rounds consists of c problems, the winners of the round are the first n people in the rating list. Each of the additional elimination rounds consists of d problems. The winner of the additional round is one person. Besides, k winners of the past finals are invited to the finals without elimination.As a result of all elimination rounds at least n\u00b7m people should go to the finals. You need to organize elimination rounds in such a way, that at least n\u00b7m people go to the finals, and the total amount of used problems in all rounds is as small as possible.", "input_spec": "The first line contains two integers c and d (1\u2009\u2264\u2009c,\u2009d\u2009\u2264\u2009100)\u00a0\u2014 the number of problems in the main and additional rounds, correspondingly. The second line contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009100). Finally, the third line contains an integer k (1\u2009\u2264\u2009k\u2009\u2264\u2009100)\u00a0\u2014 the number of the pre-chosen winners. ", "output_spec": "In the first line, print a single integer \u2014 the minimum number of problems the jury needs to prepare.", "sample_inputs": ["1 10\n7 2\n1", "2 2\n2 1\n2"], "sample_outputs": ["2", "0"], "notes": null}, "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": "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=req:\n if c*i+j*d0:\n if a 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": "#!/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, 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": "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": "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": "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": "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 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 x=(rou+1)*c\n print min(s,x)\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 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= 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"}, {"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": "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 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": "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"}, {"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": "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": "\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": "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], [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": "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": "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": "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 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": "#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=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"}], "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=req:\n if c*i+j*d=req:\n if c*i+j*d=req:\n## if i*c+j*d=req:\n if i+j=req:\n if i+j=req:\n if i+j=req:\n if i+j=req:\n if i*c+j*d=req:\n if i+j0:\n if a0:\n if a 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 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 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 ik : \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= 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= 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"} {"nl": {"description": "Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.There are $$$n$$$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind.Also, there are $$$m$$$ boxes. All of them are for different people, so they are pairwise distinct (consider that the names of $$$m$$$ friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box.Alice wants to pack presents with the following rules: She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of $$$n$$$ kinds, empty boxes are allowed); For each kind at least one present should be packed into some box. Now Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo $$$10^9+7$$$.See examples and their notes for clarification.", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$, separated by spaces ($$$1 \\leq n,m \\leq 10^9$$$)\u00a0\u2014 the number of kinds of presents and the number of boxes that Alice has.", "output_spec": "Print one integer \u00a0\u2014 the number of ways to pack the presents with Alice's rules, calculated by modulo $$$10^9+7$$$", "sample_inputs": ["1 3", "2 2"], "sample_outputs": ["7", "9"], "notes": "NoteIn the first example, there are seven ways to pack presents:$$$\\{1\\}\\{\\}\\{\\}$$$$$$\\{\\}\\{1\\}\\{\\}$$$$$$\\{\\}\\{\\}\\{1\\}$$$$$$\\{1\\}\\{1\\}\\{\\}$$$$$$\\{\\}\\{1\\}\\{1\\}$$$$$$\\{1\\}\\{\\}\\{1\\}$$$$$$\\{1\\}\\{1\\}\\{1\\}$$$In the second example there are nine ways to pack presents:$$$\\{\\}\\{1,2\\}$$$$$$\\{1\\}\\{2\\}$$$$$$\\{1\\}\\{1,2\\}$$$$$$\\{2\\}\\{1\\}$$$$$$\\{2\\}\\{1,2\\}$$$$$$\\{1,2\\}\\{\\}$$$$$$\\{1,2\\}\\{1\\}$$$$$$\\{1,2\\}\\{2\\}$$$$$$\\{1,2\\}\\{1,2\\}$$$For example, the way $$$\\{2\\}\\{2\\}$$$ is wrong, because presents of the first kind should be used in the least one box."}, "positive_code": [{"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": "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": "n,m = map(int,input().split())\nM = (10**9) +7\n\nprint(pow((pow(2,m,M) -1),n,M))"}, {"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())\nM=10**9+7\nprint(pow(pow(2,m,M)-1,n,M))"}, {"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(pow(2**m-1,n,(int)(1e9+7)))"}, {"source_code": "input = __import__(\"sys\").stdin.readline\npresents, boxes = map(int, input().split())\nprint(pow((2 ** boxes - 1), presents, 1000000007))"}, {"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": "n,m=map(int,input().split())\nprint(pow(2**m-1,n,10**9+7))"}, {"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": "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": "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())\nmod=1000000007\nans=(pow(2,m,mod)-1+mod)%mod\nans=pow(ans,n,mod)\nprint(ans)"}, {"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": "n,m = map(int,input().split())\np = 10**9+7\nprint(pow((pow(2,m,p)-1),n,p))\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 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": "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())\nb = int(pow(2,m,1000000007))\nan = pow(b-1,n,1000000007)\nprint(int(an))"}, {"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": "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": "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": "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": "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": "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": "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": "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": "c = 10 ** 9 + 7\nn, m = map(int, input().split())\nres = pow(pow(2, m, c) - 1, n, c)\nprint(res)\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 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().split())\nprint(pow(pow(2,m,10**9+7)-1,n,10**9+7))"}, {"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": "#-*- 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": "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": "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 = 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": "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))"}, {"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": "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": "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": "from sys import *\nmod=10**9+7\nn,k=map(int,input().split())\nprint(pow(2**k-1,n,mod))"}, {"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": "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) : \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": "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": "# 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": "n,m=map(int,input().split())\nM=10**9+7\nprint(pow(pow(2,m,M)-1,n,M))"}, {"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": "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": "a,b=map(int,input().split())\nk=10**9+7\nprint(pow(pow(2,b,k)-1,a,k))\n"}, {"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": "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": "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": "n, m = map(int, input().split())\nmod = 10**9+7\nprint(pow(pow(2, m, mod) - 1, n, mod))\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())\np = 10**9 + 7\nprint(pow((pow(2, m, p) - 1), n, p))\n"}, {"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))"}, {"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": "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())\nb = int(pow(2,m,1000000007))\nan = pow(b-1,n,1000000007)\nprint(int(an))"}, {"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": "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": "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,raw_input().split())\nmod = 10**9 + 7\nprint pow(pow(2,m,mod)-1,n,mod)"}, {"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, raw_input().split())\np = (int)(1e9+7) \nprint(pow((pow(2, m) - 1), n, p))"}, {"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": "n,m = map(int,input().split())\nprint(pow(2**m-1, n, 10**9+7))"}, {"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": "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))"}, {"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": "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, 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\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": "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": "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())\nmod=1000000007;\ny=pow((pow(2,m,mod)-1)%mod,n,mod)\nprint(y)\n"}, {"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": "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": "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, input().split())\nmax = 10**9+7\nx = pow(2,m,max)-1\nans = pow(x,n,max)\nprint(ans)"}, {"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=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())\nM = 1000000007\nx = (pow(2, m, M) - 1 + M) % M\nprint(pow(x, n, M))\n"}, {"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": "n,m=map(int,input().split())\nM=1000000007\nprint( pow((pow(2,m,M)-1+M)%M,n,M) )"}, {"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( pow(2, m, 1000000007) - 1, n, 1000000007) )"}, {"source_code": "n,m=map(int,raw_input().split())\nprint pow(pow(2,m,1000000007)-1,n,1000000007)\n"}, {"source_code": "a,b=map(int,input().split())\nprint(pow(pow(2,b,10**9+7)-1,a,10**9+7))"}, {"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": "n,m=map(int,input().split())\nmaxi=10**9+7\nprint(pow(pow(2,m,maxi)-1,n,maxi))"}, {"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())\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": "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": "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": "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())\nprint(pow(2**m-1, n, 10**9+7))"}, {"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"}], "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<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< 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<>= 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"}, {"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"} {"nl": {"description": "A burglar got into a matches warehouse and wants to steal as many matches as possible. In the warehouse there are m containers, in the i-th container there are ai matchboxes, and each matchbox contains bi matches. All the matchboxes are of the same size. The burglar's rucksack can hold n matchboxes exactly. Your task is to find out the maximum amount of matches that a burglar can carry away. He has no time to rearrange matches in the matchboxes, that's why he just chooses not more than n matchboxes so that the total amount of matches in them is maximal.", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u00b7108) and integer m (1\u2009\u2264\u2009m\u2009\u2264\u200920). The i\u2009+\u20091-th line contains a pair of numbers ai and bi (1\u2009\u2264\u2009ai\u2009\u2264\u2009108,\u20091\u2009\u2264\u2009bi\u2009\u2264\u200910). All the input numbers are integer.", "output_spec": "Output the only number \u2014 answer to the problem.", "sample_inputs": ["7 3\n5 10\n2 5\n3 6", "3 3\n1 3\n2 2\n3 1"], "sample_outputs": ["62", "7"], "notes": null}, "positive_code": [{"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": "#!/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": "\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": "# 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": "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": "[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": "# 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": "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": "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": "# 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": "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 = [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": "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": "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": "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": "'''\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=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, 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": "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=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": "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": "[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": "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": "\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": "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": "\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": "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": "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": "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]=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": "#!/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": "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": "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": "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": "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": "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": "__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": "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, 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": "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": "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"}, {"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": "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())\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": "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": "#!/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": "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": "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 0:\n x = min(n - matchboxes, mbs[i])\n matches += x * i\n matchboxes += x\n i -= 1\nprint(matches)"}, {"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": "\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": "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": "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=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(na:\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=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 i0:\n\tmaxs+=min(n,arr[i][1])*arr[i][0]\n\tn-=min(n,arr[i][1])\n\ti+=1\nprint maxs"}, {"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": "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": "#! /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": "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=[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=[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 i0 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 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": "# 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": "\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": "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())\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": "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": "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": "\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": "[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": "# -*- 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": "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 = 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": "\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": "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())\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())\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": "\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": "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=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": "# 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": "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=[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 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": "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"}], "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 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 n0:\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 i0):\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 count0:\n\t# \tcount+=1\n\t# \ttotal+=i[1]\n\t# \ti[0]-=1\n\tif 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(z0):\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]=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 ans0:\n\t# \tcount+=1\n\t# \ttotal+=i[1]\n\t# \ti[0]-=1\n\tif 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 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 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 count0:\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:\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:\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(z0):\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=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 i0):\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 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]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= 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]=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 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"} {"nl": {"description": "Dante is engaged in a fight with \"The Savior\". Before he can fight it with his sword, he needs to break its shields. He has two guns, Ebony and Ivory, each of them is able to perform any non-negative number of shots.For every bullet that hits the shield, Ebony deals a units of damage while Ivory deals b units of damage. In order to break the shield Dante has to deal exactly c units of damage. Find out if this is possible.", "input_spec": "The first line of the input contains three integers a, b, c (1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009c\u2009\u2264\u200910\u2009000)\u00a0\u2014 the number of units of damage dealt by Ebony gun and Ivory gun, and the total number of damage required to break the shield, respectively.", "output_spec": "Print \"Yes\" (without quotes) if Dante can deal exactly c damage to the shield and \"No\" (without quotes) otherwise.", "sample_inputs": ["4 6 15", "3 2 7", "6 11 6"], "sample_outputs": ["No", "Yes", "Yes"], "notes": "NoteIn the second sample, Dante can fire 1 bullet from Ebony and 2 from Ivory to deal exactly 1\u00b73\u2009+\u20092\u00b72\u2009=\u20097 damage. In the third sample, Dante can fire 1 bullet from ebony and no bullets from ivory to do 1\u00b76\u2009+\u20090\u00b711\u2009=\u20096 damage. "}, "positive_code": [{"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": "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": "\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, 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": "# -*- 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": "#!/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": "\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": "(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": "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,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": "'''\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\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 = [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": "'''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": "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": "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": "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": "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": "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())\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": "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": "\"\"\"\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": "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": "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": "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())\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": "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": "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": "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": "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": "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())\nfor i in range(c//a+1):\n if (c-i*a)%b==0: print('Yes'); break\nelse: print('No')"}, {"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": "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": "'''\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": "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": "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": "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, 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": "# -*- 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 = 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": "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": "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": "\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": "'''\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": "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=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, 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": "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": "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": "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": "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": "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": "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": "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": "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": "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())\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": "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": "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": "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": "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": "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": "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": "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": "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": "vals = [int(x) for x in raw_input().split()]\nif vals[0]-1 and t%a==0:\n print(\"Yes\")\n quit()\n\nprint(\"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 = 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": "# -*- 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=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": "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": "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": "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": "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,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": "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": "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": "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": "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": "#!/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": "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())\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": "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": "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": "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": "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)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": "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": "# -*- 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 (ab: 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"}, {"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,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": "__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())\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())\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": "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,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\")"}], "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=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(z0):\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=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 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 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=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 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"} {"nl": {"description": "Consider a playoff tournament where $$$2^n$$$ athletes compete. The athletes are numbered from $$$1$$$ to $$$2^n$$$.The tournament is held in $$$n$$$ stages. In each stage, the athletes are split into pairs in such a way that each athlete belongs exactly to one pair. In each pair, the athletes compete against each other, and exactly one of them wins. The winner of each pair advances to the next stage, the athlete who was defeated gets eliminated from the tournament.The pairs are formed as follows: in the first stage, athlete $$$1$$$ competes against athlete $$$2$$$; $$$3$$$ competes against $$$4$$$; $$$5$$$ competes against $$$6$$$, and so on; in the second stage, the winner of the match \"$$$1$$$\u2013$$$2$$$\" competes against the winner of the match \"$$$3$$$\u2013$$$4$$$\"; the winner of the match \"$$$5$$$\u2013$$$6$$$\" competes against the winner of the match \"$$$7$$$\u2013$$$8$$$\", and so on; the next stages are held according to the same rules. When athletes $$$x$$$ and $$$y$$$ compete, the winner is decided as follows: if $$$x+y$$$ is odd, the athlete with the lower index wins (i.\u2009e. if $$$x < y$$$, then $$$x$$$ wins, otherwise $$$y$$$ wins); if $$$x+y$$$ is even, the athlete with the higher index wins. The following picture describes the way the tournament with $$$n = 3$$$ goes. Your task is the following one: given the integer $$$n$$$, determine the index of the athlete who wins the tournament.", "input_spec": "The first line contains one integer $$$t$$$ ($$$1 \\le t \\le 30$$$) \u2014 the number of test cases. Each test case consists of one line containing one integer $$$n$$$ ($$$1 \\le n \\le 30$$$).", "output_spec": "For each test case, print one integer \u2014 the index of the winner of the tournament.", "sample_inputs": ["2\n3\n1"], "sample_outputs": ["7\n1"], "notes": "NoteThe case $$$n = 3$$$ is shown in the picture from the statement.If $$$n = 1$$$, then there's only one match between athletes $$$1$$$ and $$$2$$$. Since $$$1 + 2 = 3$$$ is an odd number, the athlete with the lower index wins. So, the athlete $$$1$$$ is the winner."}, "positive_code": [{"source_code": "for i in range(int(input())):\r\n print(2**(int(input()))-1)\r\n"}, {"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": "for _ in range(int(input())):\r\n n = int(input())\r\n p = 2**n\r\n print(2**n-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": "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": "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": "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": "for i in range (int(input())):\r\n n = int(input())\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 i in range(int(input())):\r\n print(2**int(input())-1)"}, {"source_code": "for _ in range(int(input())):\n print((1 << int(input())) - 1)\n"}, {"source_code": "for g in[*open(0)][1:]:print(2**int(g)-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": "a=int(input())\r\nfor i in range(a):\r\n b=int(input())\r\n print(2**b-1)\r\n"}, {"source_code": "t = int(input())\r\nwhile t > 0:\r\n print(2 ** int(input()) - 1)\r\n t-=1\r\n"}, {"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": "n = int(input())\r\nfor i in range(n):\r\n athlete = 2**int(input())\r\n print(athlete-1)\r\n"}, {"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": "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": "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": "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": "for _ in range(int(input())):\r\n print(2**int(input()) - 1)"}, {"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": "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": "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": "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<0:\r\n t-=1\r\n n=int(stdin.readline())\r\n print(2**n-1)"}, {"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 z in range(t):\r\n n=int(input(\"\"))\r\n p=2**n\r\n print(p-1)"}, {"source_code": "cases = int(input())\r\nfor x in range(cases):\r\n n = int(input())\r\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": "#!/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 print(2**(int(input()))-1)\r\n"}, {"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": "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": "\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\nprint(*[2 ** int(input()) - 1 for i in range(t)], sep=\"\\n\")"}, {"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)\r\n"}, {"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": "t=int(input())\r\nwhile t:\r\n n=int(input())\r\n print(2**n-1)\r\n t-=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 print((2**n)-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": "x = int(input())\r\nfor i in range(x):\r\n \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\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 i in range(int(input())):\r\n n=int(input())\r\n print(max(2**n-1,1))\r\n"}, {"source_code": "n=int(input())\r\nfor _ in range(n):\r\n x=int(input())\r\n print(2**x-1)"}, {"source_code": "for _ in range(int(input())):\r\n\tn = int(input())\r\n\tprint(2 ** n - 1)"}, {"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": "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\n\r\nfor _ 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 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": "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": "t = int(input())\r\nfor i in range(t):\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 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 print(2**n-1)"}, {"source_code": "s = int(input())\nfor _ in range(s):\n n = int(input())\n print(2 ** n - 1)"}, {"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": "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\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": "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\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": "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 _ in range(int(input())):\r\n n = int(input())\r\n print((1< 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"} {"nl": {"description": "In Berland each high school student is characterized by academic performance \u2014 integer value between 1 and 5.In 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 value between 1 and 5.The 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 number 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 academic performance the numbers of students in both groups are equal.To 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 student of class B. After that, they both change their groups.Print the least number of exchanges, in order to achieve the desired equal numbers of students for each academic performance.", "input_spec": "The first line of the input contains integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 number of students in both groups. The 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. The 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.", "output_spec": "Print the required minimum number of exchanges or -1, if the desired distribution of students can not be obtained.", "sample_inputs": ["4\n5 4 4 4\n5 5 4 5", "6\n1 1 1 1 1 1\n5 5 5 5 5 5", "1\n5\n3", "9\n3 2 5 5 2 3 3 3 2\n4 1 4 1 1 2 4 4 1"], "sample_outputs": ["1", "3", "-1", "4"], "notes": null}, "positive_code": [{"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": "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\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": "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": "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": "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": "\"\"\" 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": "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(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=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": "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": "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": "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": "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": "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().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())\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": "\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": "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": "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": "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": "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": "# 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(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": "# 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": "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": "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": "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": "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": "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": "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": "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": "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": "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"}, {"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": "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": "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": "# 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\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": "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()\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": "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": "# 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": "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 = 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": "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": "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"}, {"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": "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": "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(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())\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": "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(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=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": "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().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 = 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": "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(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(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": "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": "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()))\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": "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": "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 = 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": "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": "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 = 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": "# -*- 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": "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 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": "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": "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": "\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": "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": "##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": "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": "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": "#!/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": "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": "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": "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": "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(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": "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": "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": "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()))\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": "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": "#!/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": "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())\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": "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": "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": "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": "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"}], "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 \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 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(i0):\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(i0):\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"} {"nl": {"description": "The dragon and the princess are arguing about what to do on the New Year's Eve. The dragon suggests flying to the mountains to watch fairies dancing in the moonlight, while the princess thinks they should just go to bed early. They are desperate to come to an amicable agreement, so they decide to leave this up to chance.They take turns drawing a mouse from a bag which initially contains w white and b black mice. The person who is the first to draw a white mouse wins. After each mouse drawn by the dragon the rest of mice in the bag panic, and one of them jumps out of the bag itself (the princess draws her mice carefully and doesn't scare other mice). Princess draws first. What is the probability of the princess winning?If there are no more mice in the bag and nobody has drawn a white mouse, the dragon wins. Mice which jump out of the bag themselves are not considered to be drawn (do not define the winner). Once a mouse has left the bag, it never returns to it. Every mouse is drawn from the bag with the same probability as every other one, and every mouse jumps out of the bag with the same probability as every other one.", "input_spec": "The only line of input data contains two integers w and b (0\u2009\u2264\u2009w,\u2009b\u2009\u2264\u20091000).", "output_spec": "Output the probability of the princess winning. The answer is considered to be correct if its absolute or relative error does not exceed 10\u2009-\u20099.", "sample_inputs": ["1 3", "5 5"], "sample_outputs": ["0.500000000", "0.658730159"], "notes": "NoteLet's go through the first sample. The probability of the princess drawing a white mouse on her first turn and winning right away is 1/4. The probability of the dragon drawing a black mouse and not winning on his first turn is 3/4 * 2/3 = 1/2. After this there are two mice left in the bag \u2014 one black and one white; one of them jumps out, and the other is drawn by the princess on her second turn. If the princess' mouse is white, she wins (probability is 1/2 * 1/2 = 1/4), otherwise nobody gets the white mouse, so according to the rule the dragon wins."}, "positive_code": [{"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\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"}, {"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": "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": "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": "#!/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": "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 = [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": "# -*- 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 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 k0\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 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 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": "w,b,k,p,q=map(float,raw_input().split()+[0,0,1])\ns=w+b\nwhile q and k0):\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= 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)"}], "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"} {"nl": {"description": "Daenerys Targaryen has an army consisting of k groups of soldiers, the i-th group contains ai soldiers. She wants to bring her army to the other side of the sea to get the Iron Throne. She has recently bought an airplane to carry her army through the sea. The airplane has n rows, each of them has 8 seats. We call two seats neighbor, if they are in the same row and in seats {1,\u20092}, {3,\u20094}, {4,\u20095}, {5,\u20096} or {7,\u20098}. A row in the airplane Daenerys Targaryen wants to place her army in the plane so that there are no two soldiers from different groups sitting on neighboring seats.Your task is to determine if there is a possible arranging of her army in the airplane such that the condition above is satisfied.", "input_spec": "The first line contains two integers n and k (1\u2009\u2264\u2009n\u2009\u2264\u200910000, 1\u2009\u2264\u2009k\u2009\u2264\u2009100)\u00a0\u2014 the number of rows and the number of groups of soldiers, respectively. The second line contains k integers a1,\u2009a2,\u2009a3,\u2009...,\u2009ak (1\u2009\u2264\u2009ai\u2009\u2264\u200910000), where ai denotes the number of soldiers in the i-th group. It is guaranteed that a1\u2009+\u2009a2\u2009+\u2009...\u2009+\u2009ak\u2009\u2264\u20098\u00b7n.", "output_spec": "If we can place the soldiers in the airplane print \"YES\" (without quotes). Otherwise print \"NO\" (without quotes). You can choose the case (lower or upper) for each letter arbitrary.", "sample_inputs": ["2 2\n5 8", "1 2\n7 1", "1 2\n4 4", "1 4\n2 2 1 2"], "sample_outputs": ["YES", "NO", "YES", "YES"], "notes": "NoteIn the first sample, Daenerys can place the soldiers like in the figure below: In the second sample, there is no way to place the soldiers in the plane since the second group soldier will always have a seat neighboring to someone from the first group.In the third example Daenerys can place the first group on seats (1,\u20092,\u20097,\u20098), and the second group an all the remaining seats.In the fourth example she can place the first two groups on seats (1,\u20092) and (7,\u20098), the third group on seats (3), and the fourth group on seats (5,\u20096)."}, "positive_code": [{"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": "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": "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": "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": "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,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": "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": "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, 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\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": "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"}, {"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*2 or (s==a*2and k==a and n>0) else 'YES')\n\n\n\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": "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": "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": "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,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": "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": "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,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"}, {"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": "\"\"\"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\")"}], "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=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 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 i3 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 i0:\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 i0:\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 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=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"} {"nl": {"description": "Welcome to Codeforces Stock Exchange! We're pretty limited now as we currently allow trading on one stock, Codeforces Ltd. We hope you'll still be able to make profit from the market!In the morning, there are $$$n$$$ opportunities to buy shares. The $$$i$$$-th of them allows to buy as many shares as you want, each at the price of $$$s_i$$$ bourles.In the evening, there are $$$m$$$ opportunities to sell shares. The $$$i$$$-th of them allows to sell as many shares as you want, each at the price of $$$b_i$$$ bourles. You can't sell more shares than you have.It's morning now and you possess $$$r$$$ bourles and no shares.What is the maximum number of bourles you can hold after the evening?", "input_spec": "The first line of the input contains three integers $$$n, m, r$$$ ($$$1 \\leq n \\leq 30$$$, $$$1 \\leq m \\leq 30$$$, $$$1 \\leq r \\leq 1000$$$) \u2014 the number of ways to buy the shares on the market, the number of ways to sell the shares on the market, and the number of bourles you hold now. The next line contains $$$n$$$ integers $$$s_1, s_2, \\dots, s_n$$$ ($$$1 \\leq s_i \\leq 1000$$$); $$$s_i$$$ indicates the opportunity to buy shares at the price of $$$s_i$$$ bourles. The following line contains $$$m$$$ integers $$$b_1, b_2, \\dots, b_m$$$ ($$$1 \\leq b_i \\leq 1000$$$); $$$b_i$$$ indicates the opportunity to sell shares at the price of $$$b_i$$$ bourles.", "output_spec": "Output a single integer \u2014 the maximum number of bourles you can hold after the evening.", "sample_inputs": ["3 4 11\n4 2 5\n4 4 5 4", "2 2 50\n5 7\n4 2"], "sample_outputs": ["26", "50"], "notes": "NoteIn the first example test, you have $$$11$$$ bourles in the morning. It's optimal to buy $$$5$$$ shares of a stock at the price of $$$2$$$ bourles in the morning, and then to sell all of them at the price of $$$5$$$ bourles in the evening. It's easy to verify that you'll have $$$26$$$ bourles after the evening.In the second example test, it's optimal not to take any action."}, "positive_code": [{"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=maxi:\n\tprint(r)\nelse:\n\tb=r//mini\n\tr+=(maxi-mini)*b\n\tprint(r)\n"}, {"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())\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": "#!/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": "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": "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": "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": "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\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 ir:\n\tprint(y+left)\nelse:\n\tprint(r)"}, {"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": "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,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": "i=lambda:map(int,input().split())\n_,_,r=i()\ns=min(i())\nb=max(s,*i())\nprint(r%s+r//s*b)"}, {"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": "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": "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": "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 = [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=[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 = 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": "#!/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 = [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": "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": "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())\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": "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": "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": "\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": "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": "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= b[0]:\n print(r)\n exit()\nq = r // a[0]\nr -= q * a[0]\nr += q * b[0]\nprint(r)"}, {"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": "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] = 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"}, {"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": "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": "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": "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": "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 = 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, 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())\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": "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": "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": "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())\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,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": "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, 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=[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]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": "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": "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": "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": "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": "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] = 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"}, {"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 = [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": "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": "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": "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, 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": "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 = 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": "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": "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": "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": "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": "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,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": "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": "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": "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 = 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": "'''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 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": "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": "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 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": "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": "# 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())\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": "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": "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 = min(map(int, input().split()))\nprint(r // b * max(b, *map(int, input().split())) + r % b)"}, {"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,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": "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": "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 i0:\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,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": "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": "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"}], "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 buymin(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 n2n2:\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 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 i0:\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 buyr:\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"} {"nl": {"description": "Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors from bottom to top with integers from 1 to n. Now you're on the floor number a. You are very bored, so you want to take the lift. Floor number b has a secret lab, the entry is forbidden. However, you already are in the mood and decide to make k consecutive trips in the lift.Let us suppose that at the moment you are on the floor number x (initially, you were on floor a). For another trip between floors you choose some floor with number y (y\u2009\u2260\u2009x) and the lift travels to this floor. As you cannot visit floor b with the secret lab, you decided that the distance from the current floor x to the chosen y must be strictly less than the distance from the current floor x to floor b with the secret lab. Formally, it means that the following inequation must fulfill: |x\u2009-\u2009y|\u2009<\u2009|x\u2009-\u2009b|. After the lift successfully transports you to floor y, you write down number y in your notepad.Your task is to find the number of distinct number sequences that you could have written in the notebook as the result of k trips in the lift. As the sought number of trips can be rather large, find the remainder after dividing the number by 1000000007 (109\u2009+\u20097).", "input_spec": "The first line of the input contains four space-separated integers n, a, b, k (2\u2009\u2264\u2009n\u2009\u2264\u20095000, 1\u2009\u2264\u2009k\u2009\u2264\u20095000, 1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009n, a\u2009\u2260\u2009b).", "output_spec": "Print a single integer \u2014 the remainder after dividing the sought number of sequences by 1000000007 (109\u2009+\u20097).", "sample_inputs": ["5 2 4 1", "5 2 4 2", "5 3 4 1"], "sample_outputs": ["2", "2", "0"], "notes": "NoteTwo sequences p1,\u2009p2,\u2009...,\u2009pk and q1,\u2009q2,\u2009...,\u2009qk are distinct, if there is such integer j (1\u2009\u2264\u2009j\u2009\u2264\u2009k), that pj\u2009\u2260\u2009qj.Notes to the samples: In the first sample after the first trip you are either on floor 1, or on floor 3, because |1\u2009-\u20092|\u2009<\u2009|2\u2009-\u20094| and |3\u2009-\u20092|\u2009<\u2009|2\u2009-\u20094|. In the second sample there are two possible sequences: (1,\u20092); (1,\u20093). You cannot choose floor 3 for the first trip because in this case no floor can be the floor for the second trip. In the third sample there are no sought sequences, because you cannot choose the floor for the first trip. "}, "positive_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)%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 j1:\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"}, {"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 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"}, {"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"}], "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 j1:\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"} {"nl": {"description": "A group of university students wants to get to the top of a mountain to have a picnic there. For that they decided to use a cableway.A cableway is represented by some cablecars, hanged onto some cable stations by a cable. A cable is scrolled cyclically between the first and the last cable stations (the first of them is located at the bottom of the mountain and the last one is located at the top). As the cable moves, the cablecar attached to it move as well.The number of cablecars is divisible by three and they are painted three colors: red, green and blue, in such manner that after each red cablecar goes a green one, after each green cablecar goes a blue one and after each blue cablecar goes a red one. Each cablecar can transport no more than two people, the cablecars arrive with the periodicity of one minute (i. e. every minute) and it takes exactly 30 minutes for a cablecar to get to the top.All students are divided into three groups: r of them like to ascend only in the red cablecars, g of them prefer only the green ones and b of them prefer only the blue ones. A student never gets on a cablecar painted a color that he doesn't like,The first cablecar to arrive (at the moment of time 0) is painted red. Determine the least time it will take all students to ascend to the mountain top.", "input_spec": "The first line contains three integers r, g and b (0\u2009\u2264\u2009r,\u2009g,\u2009b\u2009\u2264\u2009100). It is guaranteed that r\u2009+\u2009g\u2009+\u2009b\u2009>\u20090, it means that the group consists of at least one student. ", "output_spec": "Print a single number \u2014 the minimal time the students need for the whole group to ascend to the top of the mountain.", "sample_inputs": ["1 3 2", "3 2 1"], "sample_outputs": ["34", "33"], "notes": "NoteLet's analyze the first sample.At the moment of time 0 a red cablecar comes and one student from the r group get on it and ascends to the top at the moment of time 30.At the moment of time 1 a green cablecar arrives and two students from the g group get on it; they get to the top at the moment of time 31.At the moment of time 2 comes the blue cablecar and two students from the b group get on it. They ascend to the top at the moment of time 32.At the moment of time 3 a red cablecar arrives but the only student who is left doesn't like red and the cablecar leaves empty.At the moment of time 4 a green cablecar arrives and one student from the g group gets on it. He ascends to top at the moment of time 34.Thus, all the students are on the top, overall the ascension took exactly 34 minutes."}, "positive_code": [{"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": "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": "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": "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": "\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": "# 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())\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": "\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": "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": "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": "# 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": "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": "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": "print max([0, (n + 1) / 2 * 3 + i + 27][n > 0] for i, n in enumerate(map(int, raw_input().split())))"}, {"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": "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": "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": "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 = [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": "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": "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": "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": "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": "\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": "print max([0, (n + 1) / 2 * 3 + i + 27][n > 0] for i, n in enumerate(map(int, raw_input().split())))"}, {"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": "q=raw_input().split();print 30+max(i+~-int(q[i])/2*3for i in(0,1,2))"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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"}, {"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=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": "#!/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": "\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=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": "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": "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= 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": "#!/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/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": "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": "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": "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": "#! /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": "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": "q=raw_input().split();print 30+max(i+~-int(q[i])/2*3for i in(0,1,2))"}, {"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": "#!/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": "# 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": "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()))\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": "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": "\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 = 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": "#!/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,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": "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": "\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": "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": "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": "#!/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": "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": "\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": "# -*- 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": "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": "# -*- 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": "\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,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": "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,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": "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": "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": "# 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": "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())\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": "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": "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": "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": "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-22 :\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"}, {"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": "(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 = 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": "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": "#!/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": "\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": "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": "(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": "#!/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": "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": "q=raw_input().split();print 30+max(i+~-int(q[i])/2*3for i in(0,1,2))"}], "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"} {"nl": {"description": "In a small but very proud high school it was decided to win ACM ICPC. This goal requires to compose as many teams of three as possible, but since there were only 6 students who wished to participate, the decision was to build exactly two teams.After practice competition, participant number i got a score of ai. Team score is defined as sum of scores of its participants. High school management is interested if it's possible to build two teams with equal scores. Your task is to answer that question.", "input_spec": "The single line contains six integers a1,\u2009...,\u2009a6 (0\u2009\u2264\u2009ai\u2009\u2264\u20091000) \u2014 scores of the participants", "output_spec": "Print \"YES\" (quotes for clarity), if it is possible to build teams with equal score, and \"NO\" otherwise. You can print each character either upper- or lowercase (\"YeS\" and \"yes\" are valid when the answer is \"YES\").", "sample_inputs": ["1 3 2 1 2 1", "1 1 1 1 1 99"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, first team can be composed of 1st, 2nd and 6th participant, second \u2014 of 3rd, 4th and 5th: team scores are 1\u2009+\u20093\u2009+\u20091\u2009=\u20092\u2009+\u20091\u2009+\u20092\u2009=\u20095.In the second sample, score of participant number 6 is too high: his team score will be definitely greater."}, "positive_code": [{"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "# 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": "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": "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": "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(' ')))\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": "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()))\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, 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": "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": "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<= 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": "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": "'''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": "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": "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": "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": "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": "\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": "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=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"}, {"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": "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": "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": "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": "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": "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": "'''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": "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": "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": "\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "\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": "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": "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\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": "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 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\""}], "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(max1d):\n d+=z\nelif(c 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"} {"nl": {"description": "Find the minimum number with the given sum of digits $$$s$$$ such that all digits in it are distinct (i.e. all digits are unique).For example, if $$$s=20$$$, then the answer is $$$389$$$. This is the minimum number in which all digits are different and the sum of the digits is $$$20$$$ ($$$3+8+9=20$$$).For the given $$$s$$$ print the required number.", "input_spec": "The first line contains an integer $$$t$$$ ($$$1 \\le t \\le 45$$$) \u2014 the number of test cases. Each test case is specified by a line that contains the only integer $$$s$$$ ($$$1 \\le s \\le 45$$$).", "output_spec": "Print $$$t$$$ integers \u2014 the answers to the given test cases.", "sample_inputs": ["4\n\n20\n\n8\n\n45\n\n10"], "sample_outputs": ["389\n8\n123456789\n19"], "notes": null}, "positive_code": [{"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 _ 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 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": "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": "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": "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": "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": "\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": "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": "# 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": "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": "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')"}, {"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 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": "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": "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": "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": "\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": "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": "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": "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": "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": "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\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": "# 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:\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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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": "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= 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": "# 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": "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": "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 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": "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": "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": "'''\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": "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": "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\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": "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 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": "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": "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 num9 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": "'''\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": "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": "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": "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": "# -*- 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": "# 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": "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": "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": "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": "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": "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": "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": "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": "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": "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\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": "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": "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\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 _ 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": "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": "\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": "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 _ 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": "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)"}], "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= 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"} {"nl": {"description": "Alice has a string $$$s$$$. She really likes the letter \"a\". She calls a string good if strictly more than half of the characters in that string are \"a\"s. For example \"aaabb\", \"axaa\" are good strings, and \"baca\", \"awwwa\", \"\" (empty string) are not.Alice can erase some characters from her string $$$s$$$. She would like to know what is the longest string remaining after erasing some characters (possibly zero) to get a good string. It is guaranteed that the string has at least one \"a\" in it, so the answer always exists.", "input_spec": "The first line contains a string $$$s$$$ ($$$1 \\leq |s| \\leq 50$$$) consisting of lowercase English letters. It is guaranteed that there is at least one \"a\" in $$$s$$$.", "output_spec": "Print a single integer, the length of the longest good string that Alice can get after erasing some characters from $$$s$$$.", "sample_inputs": ["xaxxxxa", "aaabaa"], "sample_outputs": ["3", "6"], "notes": "NoteIn the first example, it's enough to erase any four of the \"x\"s. The answer is $$$3$$$ since that is the maximum number of characters that can remain.In the second example, we don't need to erase any characters."}, "positive_code": [{"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 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=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 = raw_input()\nn1 = len(s)\nn2 =s.count('a')\nprint min(n1,n2*2-1)"}, {"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": "s = raw_input()\nn = len(s)\nc = s.count('a')\nprint min(n, c+c-1)\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": "# 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": "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": "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 = 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": "s=raw_input()\nc=s.count('a')\nprint min(len(s),2*c-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()\na=s.count('a')\nif a>(len(s)//2):\n print(len(s))\nelse:\n print(a+a-1)\n "}, {"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()\na=s.count('a')\nif a>(len(s)//2):\n print(len(s))\nelse:\n print(a+a-1)\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": "# 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": "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": "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": "\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()\nk = s.count('a')\nprint(min(max(k + k - 1, 0), len(s)))\n"}, {"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": "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": "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": "#!/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": "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": "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 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": "string=input()\nprint(min(2*string.count('a')-1,len(string)))\n\n\n"}, {"source_code": "s = input()\nprint(min(len(s),2*s.count('a')-1))"}, {"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": "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": "#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=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": "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": "s=raw_input()\nprint(len(s) if s.count('a')>len(s)//2 else 2*s.count('a')-1)"}, {"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": "\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": "s = input()\nprint(min(len(s), s.count('a')*2 - 1))\n"}, {"source_code": "s = input()\nk = s.count('a')\nprint(min(max(k + k - 1, 0), len(s)))\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": "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()\na = s.count('a')\nif a > len(s) // 2:\n print(len(s))\nelse:\n print(a * 2 - 1)\n"}, {"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()\nc=s.count('a')\nprint min(len(s),2*c-1)\n"}, {"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 = 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\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": "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": "\n\nn = input()\nprint(min(((2 * n.count('a') - 1), len(n))))\n"}, {"source_code": "s = raw_input()\nprint min(len(s), s.count('a') * 2 - 1)\n"}, {"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 = 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()\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": "import math\ns=input()\nprint(min(len(s),2*s.count('a')-1))"}, {"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": "#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": "n=input()\nr=n.count(\"a\")\nprint(min(len(n),2*r-1))"}, {"source_code": "s=input()\nprint(min(len(s),s.count('a')*2-1))\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(s)/2):\n print(len(s))\nelse:\n print(aCnt * 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()\nprint(min(s.count('a')*2-1, len(s)))"}, {"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()\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": "s=raw_input()\nc=s.count('a')\nprint min(c*2-1,len(s))"}, {"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=raw_input()\nn=len(s)\na=sum(k=='a' for k in s)\nprint(min(n,2*a-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=input()\nx=s.count('a')\nif len(s) <= x*2-1:\n print(len(s))\nelse:\n print(x*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"}, {"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 = raw_input()\n\na = s.count('a')\n\nprint min(len(s), a * 2 - 1)\n"}, {"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": "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": "#!/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 = 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": "s = input().strip()\na = s.count('a')\nprint(len(s)) if a > len(s)/2 else print(a*2-1)"}, {"source_code": "s = input()\nprint(min(len(s), s.count('a')*2-1))\n"}, {"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()\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": "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": "# ~*~ 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()\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()\nprint(min(len(s), s.count('a') * 2 - 1))\n"}, {"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": "# -*- 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": "\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()\na = s.count('a')\nprint(min(2*a-1,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()\n\ntemp=s.count('a')\n\nif temp*2>len(s):\n print(len(s))\nelse:\n print((2*temp)-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": "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 = 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()\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()\n\nc = s.count('a')\nif 2*c > len(s):\n\tprint len(s)\nelse:\n\tprint 2*c -1"}, {"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": "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"}], "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 fr):\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(valr):\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]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:\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=(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)-k1):\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 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 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(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) 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 (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)/2p//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"} {"nl": {"description": "Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?", "input_spec": "The input contains a single integer n (0\u2009\u2264\u2009n\u2009\u2264\u20092000000000).", "output_spec": "Output a single integer.", "sample_inputs": ["11", "14", "61441", "571576", "2128506"], "sample_outputs": ["2", "0", "2", "10", "3"], "notes": null}, "positive_code": [{"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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(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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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)"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "print sum([\"046889abbd\".count(x)for x in hex(int(input()))])-1"}, {"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": "print sum([\"046889abbd\".count(x)for x in hex(int(input()))])-1"}, {"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": "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": "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": "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": "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": "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": "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"}, {"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": "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": "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": "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": "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": "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": "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": "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 = 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": "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": "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 = 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": "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": "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": "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": "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 = 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": "print(sum([\"046889ABBDabbd\".count(x) for x in hex(int(input()))])-1)"}, {"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": "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": "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": "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": "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": "print sum([(i in'46890abd')+(i in'8b')for i in hex(int(raw_input()))])-1"}, {"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": "\"\"\"\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=[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": "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": "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": "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": "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": "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": "# 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": "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)"}, {"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": "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": "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": "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": "print sum([\"046889abbd\".count(x)for x in hex(int(input()))])-1"}, {"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 = 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:].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"}], "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"} {"nl": {"description": "This year, as in previous years, MemSQL is inviting the top 25 competitors from the Start[c]up qualification round to compete onsite for the final round. Not everyone who is eligible to compete onsite can afford to travel to the office, though. Initially the top 25 contestants are invited to come onsite. Each eligible contestant must either accept or decline the invitation. Whenever a contestant declines, the highest ranked contestant not yet invited is invited to take the place of the one that declined. This continues until 25 contestants have accepted invitations.After the qualifying round completes, you know K of the onsite finalists, as well as their qualifying ranks (which start at 1, there are no ties). Determine the minimum possible number of contestants that declined the invitation to compete onsite in the final round.", "input_spec": "The first line of input contains K (1\u2009\u2264\u2009K\u2009\u2264\u200925), the number of onsite finalists you know. The second line of input contains r1,\u2009r2,\u2009...,\u2009rK (1\u2009\u2264\u2009ri\u2009\u2264\u2009106), the qualifying ranks of the finalists you know. All these ranks are distinct.", "output_spec": "Print the minimum possible number of contestants that declined the invitation to compete onsite.", "sample_inputs": ["25\n2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19 20 21 22 23 24 25 26 28", "5\n16 23 8 15 4", "3\n14 15 92"], "sample_outputs": ["3", "0", "67"], "notes": "NoteIn the first example, you know all 25 onsite finalists. The contestants who ranked 1-st, 13-th, and 27-th must have declined, so the answer is 3."}, "positive_code": [{"source_code": "n=int(input())\na=list(map(int,input().split()))\nprint(max(0,max(a)-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\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": "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": "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())\narr = map(int, raw_input().split())\n\nprint max(0, max(arr) - 25)\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": "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 = 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 = 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": "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": "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": "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())\nl = list(map(int, input().split()))\ng = max(l)\n\nif g <= 25:\n print(0)\nelse:\n print(g - 25) "}, {"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": "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": "'''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())\nmx = max([int(x) for x in input().split()])\nprint(max(0, mx - 25))\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": "\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=input()\nt=list(map(int,input().split()))\nif max(t)<=25:\n print(0)\nelse:\n print(max(t)-25)\n"}, {"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": "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": "\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": "#!/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": "# 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": "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": "k=input();\nl=max(map(int, input().split()));\nif l>25:\n print(l-25)\nelse:\n print(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=sorted(list(map(int,input().split())))\nif a[-1]<=25:\n print(0)\nelse:\n print(abs(a[-1]-25))"}, {"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": "a = int(input())\nc = list(map(int,input().split()))\nif max(c)-25 < 0: print(0)\nelse: print(max(c)-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": "\nraw_input()\n\nxs = map(int, raw_input().split(' '))\n\nprint max(0, max(xs) - 25)\n\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": "n = input()\narr = map(int,raw_input().strip().split())\nprint max(0,max(arr)-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(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": "n, s = int(input()), max(list(map(int,input().split(' '))))\nprint(0 if s<=25 else s-25 )"}, {"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": "#!/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": "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": "_ = input()\nx = max(int(i) for i in input().split())\nif x <= 25:\n print(0)\nelse:\n print(x-25)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nprint(max(0,max(l)-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": "input()\nprint(max(25, max(map(int, input().split()))) - 25)\n"}, {"source_code": "kohli = input()\nprint max(max(map(int, raw_input().split())) - 25, 0)"}, {"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": "n = input()\nl = map(int,raw_input().split())\nprint max(0,max(l)-25)\n"}, {"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": "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": "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": "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())\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": "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=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": "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": "\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": "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": "__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": "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": "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())\nl=list(map(int,input().split()))\nif max(l)<=25:print(0) \nelse:print(max(l)-25)"}, {"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": "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": "n = int(input())\np = [*map(int,input().split())]\nprint(0 if(max(p)-25)<0 else max(p)-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": "\"\"\"\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 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')=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= 0:\n\tprint(max(a)-25)\nelse:\n\tprint(0) \n"}, {"source_code": "input();print(max(0,max(map(int,input().split()))-25))"}, {"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())\nls = list(map(int, input().split(\" \")))\nmx = max(ls)\nif mx > 25:\n print(mx - 25)\nelse:\n print(0)"}, {"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": "n=int(raw_input())\nx=max(map(int,raw_input().split()))\nprint max(0,x-25)"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nprint(max(0,max(arr)-25))\n"}, {"source_code": "input();k=max(map(int,input().split()));print(0 if k<=25 else k-25)"}, {"source_code": "raw_input()\nprint(max(list(map(int,raw_input().split()))+[25])-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": "raw_input()\nprint(max(list(map(int,raw_input().split()))+[25])-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(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": "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": "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=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 = input()\na = map(int,raw_input().split(\" \"))\n\nif max(a)<= 25:\n print \"0\"\nelse:\n print max(a) - 25"}, {"source_code": "n = input()\na = map(int, raw_input().split())\nprint max(0, max(a) - 25)"}, {"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": "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": "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": "n = int(input())\nr = list(map(int, input().split()))\nprint(max(r) - 25) if max(r) > 25 else print(0)\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=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": "k=input()\nr=list(map(int,input().split()))\nif max(r)>25:\n\tprint(max(r)-25)\nelse:\n\tprint(0)"}, {"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": "raw_input()\nprint max(max(map(int, raw_input().split())) - 25, 0)\n"}, {"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": "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": "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 = 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)"}], "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 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')=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(e25:\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"} {"nl": {"description": "Polycarp takes part in a quadcopter competition. According to the rules a flying robot should: start the race from some point of a field, go around the flag, close cycle returning back to the starting point. Polycarp knows the coordinates of the starting point (x1,\u2009y1) and the coordinates of the point where the flag is situated (x2,\u2009y2). Polycarp\u2019s quadcopter can fly only parallel to the sides of the field each tick changing exactly one coordinate by 1. It means that in one tick the quadcopter can fly from the point (x,\u2009y) to any of four points: (x\u2009-\u20091,\u2009y), (x\u2009+\u20091,\u2009y), (x,\u2009y\u2009-\u20091) or (x,\u2009y\u2009+\u20091).Thus the quadcopter path is a closed cycle starting and finishing in (x1,\u2009y1) and containing the point (x2,\u2009y2) strictly inside. The picture corresponds to the first example: the starting (and finishing) point is in (1,\u20095) and the flag is in (5,\u20092). What is the minimal length of the quadcopter path?", "input_spec": "The first line contains two integer numbers x1 and y1 (\u2009-\u2009100\u2009\u2264\u2009x1,\u2009y1\u2009\u2264\u2009100) \u2014 coordinates of the quadcopter starting (and finishing) point. The second line contains two integer numbers x2 and y2 (\u2009-\u2009100\u2009\u2264\u2009x2,\u2009y2\u2009\u2264\u2009100) \u2014 coordinates of the flag. It is guaranteed that the quadcopter starting point and the flag do not coincide.", "output_spec": "Print the length of minimal path of the quadcopter to surround the flag and return back.", "sample_inputs": ["1 5\n5 2", "0 1\n0 0"], "sample_outputs": ["18", "8"], "notes": null}, "positive_code": [{"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": "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": "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, 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": "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": "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": "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": "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": "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": "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": "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())\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": "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)"}, {"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(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": "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": "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": "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())\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": "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": "'''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": "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,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": "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": "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": "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": "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": "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": "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)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": "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": "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": "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": "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": "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": "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())\nprint(2 * max(abs(x2 - x1), 1) + 2 * max(abs(y2 - y1), 1) + 4)\n\n\n"}, {"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": "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": "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": "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": "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"}, {"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": "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, 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": "x1,y1=map(int,input().split())\nx2,y2=map(int,input().split())\nq=x1==x2 or y1==y2\nif x2x1:\n x2+=1\nif y2y1:\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": "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": "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": "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 = 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": "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": "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": "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[1]) :\n while (q[1]>f[1]+1) :\n q[1]-=1\n compteur+=1\nelif(q[1]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\n\nprint(compteur)\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": "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": "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": "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())\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": "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, 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": "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": "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())\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": "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": "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": "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": "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": "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=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": "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": "# 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": "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())\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())\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": "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": "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())\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": "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": "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": "#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": "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": "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": "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": "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": "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\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": "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": "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 bd:\n u=(b-d)+1\n u*=2\n ans+=u\n elif bd:\n u=(b-d)+1\n u*=2\n ans+=u\n elif b1:\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"} {"nl": {"description": "You're given a row with $$$n$$$ chairs. We call a seating of people \"maximal\" if the two following conditions hold: There are no neighbors adjacent to anyone seated. It's impossible to seat one more person without violating the first rule. The seating is given as a string consisting of zeros and ones ($$$0$$$ means that the corresponding seat is empty, $$$1$$$ \u2014 occupied). The goal is to determine whether this seating is \"maximal\".Note that the first and last seats are not adjacent (if $$$n \\ne 2$$$).", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 1000$$$)\u00a0\u2014 the number of chairs. The next line contains a string of $$$n$$$ characters, each of them is either zero or one, describing the seating.", "output_spec": "Output \"Yes\" (without quotation marks) if the seating is \"maximal\". Otherwise print \"No\". You are allowed to print letters in whatever case you'd like (uppercase or lowercase).", "sample_inputs": ["3\n101", "4\n1011", "5\n10001"], "sample_outputs": ["Yes", "No", "No"], "notes": "NoteIn sample case one the given seating is maximal.In sample case two the person at chair three has a neighbour to the right.In sample case three it is possible to seat yet another person into chair three."}, "positive_code": [{"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": "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 = 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())\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": "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())\ns = '0'+input()+'0'\nans = 'No' if '000' in s or '11' in s else 'Yes'\nprint(ans)\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 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": "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 = 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": "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": "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 i3):\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": "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": "\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": "# 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": "input()\ns = '0'+input()+'0'\nprint(\"No\" if '000' in s or '11' in s else \"Yes\")\n"}, {"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": "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": "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(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()\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 = 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": "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": "# 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": "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": "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": "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()\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": "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": "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=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": "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": "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 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(input())\na = '0'+input()+'0'\nif '000' in a or '11' in a:print('No')\nelse:print('Yes')"}, {"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": "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] == '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()\ni = 0\nres = True\ncount = 0\nwhile(i2 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())\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())\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": "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": "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\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": "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 = 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": "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": "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": "#[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": "input()\ns = \"0\"+input()+\"0\"\nprint(\"NO\" if (\"000\" in s or \"11\" in s) else \"YES\")"}, {"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": "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": "#!/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": "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": "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": "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": "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": "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": "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 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": "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": "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())\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": "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": "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": "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 = 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": "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": "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\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": "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": "\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": "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": "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": "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\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())\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": "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=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())\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=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": "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": "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": "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": "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, 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": "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": "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, 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": "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 position2 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": "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": "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)"}, {"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": "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": "input()\ns = '0' + input() + '0'\nprint(\"No\" if \"11\" in s or \"000\" in s else \"Yes\")\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"}], "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(i2 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-1):\n if(r>maximum):\n maximum =r\n if(rmaximum):\n maximum =l\n if(l 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-1):\n\n if(diff>maximum):\n maximum = diff\n if(diff -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 x0:\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 x0:\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 x0:\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 i1:\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"} {"nl": {"description": "A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer.Limak can discard (throw out) some cards. His goal is to minimize the sum of numbers written on remaining (not discarded) cards.He is allowed to at most once discard two or three cards with the same number. Of course, he won't discard cards if it's impossible to choose two or three cards with the same number.Given five numbers written on cards, cay you find the minimum sum of numbers on remaining cards?", "input_spec": "The only line of the input contains five integers t1, t2, t3, t4 and t5 (1\u2009\u2264\u2009ti\u2009\u2264\u2009100)\u00a0\u2014 numbers written on cards.", "output_spec": "Print the minimum possible sum of numbers written on remaining cards.", "sample_inputs": ["7 3 7 3 20", "7 9 3 1 8", "10 10 10 10 10"], "sample_outputs": ["26", "28", "20"], "notes": "NoteIn the first sample, Limak has cards with numbers 7, 3, 7, 3 and 20. Limak can do one of the following. Do nothing and the sum would be 7\u2009+\u20093\u2009+\u20097\u2009+\u20093\u2009+\u200920\u2009=\u200940. Remove two cards with a number 7. The remaining sum would be 3\u2009+\u20093\u2009+\u200920\u2009=\u200926. Remove two cards with a number 3. The remaining sum would be 7\u2009+\u20097\u2009+\u200920\u2009=\u200934. You are asked to minimize the sum so the answer is 26.In the second sample, it's impossible to find two or three cards with the same number. Hence, Limak does nothing and the sum is 7\u2009+\u20099\u2009+\u20091\u2009+\u20093\u2009+\u20098\u2009=\u200928.In the third sample, all cards have the same number. It's optimal to discard any three cards. The sum of two remaining numbers is 10\u2009+\u200910\u2009=\u200920."}, "positive_code": [{"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": "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": "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": "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": "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": "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": "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": "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=[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": "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": "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": "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 = 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": "# -*- 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": "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": "# 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": "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": "#!/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": "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": "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": "#!/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": "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": "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=[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": "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": "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": "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": "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 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": "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": "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": "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": "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()))\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": "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": "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": "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": "#!/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": "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))"}, {"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, 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": "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": "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": "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": "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": "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": "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": "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": "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": "# 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": "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": "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 = 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": "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()))\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 c1:\n min1=c\nprint(min1)\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": "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": "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": "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": "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": "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": "#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": "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": "# 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": "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": "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": "def solution(l1):\n l1.sort()\n i=0\n ans=[0]\n while i=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 = 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": "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": "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 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()));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": "#!/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": "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": "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": "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)"}], "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]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=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_ansans):\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 maxGk2):\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]= 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 cy:\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] 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= 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_ans1:\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 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] 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"} {"nl": {"description": "IT City company developing computer games decided to upgrade its way to reward its employees. Now it looks the following way. After a new game release users start buying it actively, and the company tracks the number of sales with precision to each transaction. Every time when the next number of sales is not divisible by any number from 2 to 10 every developer of this game gets a small bonus.A game designer Petya knows that the company is just about to release a new game that was partly developed by him. On the basis of his experience he predicts that n people will buy the game during the first month. Now Petya wants to determine how many times he will get the bonus. Help him to know it.", "input_spec": "The only line of the input contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u20091018) \u2014 the prediction on the number of people who will buy the game.", "output_spec": "Output one integer showing how many numbers from 1 to n are not divisible by any number from 2 to 10.", "sample_inputs": ["12"], "sample_outputs": ["2"], "notes": null}, "positive_code": [{"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 .\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": "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": "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())\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": "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()\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=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": "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 // 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": "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": "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())\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": "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())\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())\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()\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": "#!/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": "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": "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(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(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": "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\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": "# 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": "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": "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())\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())\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": "# 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": "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())\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": "#!/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": "# 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())\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())\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())\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": "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(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": "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": "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"}, {"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": "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=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": "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 // (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(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": "# 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": "\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": "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(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 = 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": "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": "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(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()\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": "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 & 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": "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": "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(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": "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": "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": "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": "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": "\"\"\"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": "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())\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": "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": "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": "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": "# -*- 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=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()\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 = 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": "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(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": "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 = 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": "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": "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": "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())\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": "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(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": "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())\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())\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(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": "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": "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": "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())\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//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": "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"}], "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"} {"nl": {"description": "Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s1\u2009=\u2009a), and the difference between any two neighbouring elements is equal to c (si\u2009-\u2009si\u2009-\u20091\u2009=\u2009c). In particular, Vasya wonders if his favourite integer b appears in this sequence, that is, there exists a positive integer i, such that si\u2009=\u2009b. Of course, you are the person he asks for a help.", "input_spec": "The first line of the input contain three integers a, b and c (\u2009-\u2009109\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u2009109)\u00a0\u2014 the first element of the sequence, Vasya's favorite number and the difference between any two neighbouring elements of the sequence, respectively.", "output_spec": "If b appears in the sequence s print \"YES\" (without quotes), otherwise print \"NO\" (without quotes).", "sample_inputs": ["1 7 3", "10 10 0", "1 -4 5", "0 60 50"], "sample_outputs": ["YES", "YES", "NO", "NO"], "notes": "NoteIn the first sample, the sequence starts from integers 1, 4, 7, so 7 is its element.In the second sample, the favorite integer of Vasya is equal to the first element of the sequence.In the third sample all elements of the sequence are greater than Vasya's favorite integer.In the fourth sample, the sequence starts from 0, 50, 100, and all the following elements are greater than Vasya's favorite integer."}, "positive_code": [{"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": "[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]=[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": "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": "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": "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, 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": "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": "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": "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 , 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": "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=(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": "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": "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": "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>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 = 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,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": "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": "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())\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": "\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"}, {"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": "# -*- 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": "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": "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, 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())\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())\nd=b-a\nprint ['NO','YES'][d==0 or(d*c>0 and d%c==0)]\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 and (b-a)/c >= 0:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'"}, {"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": "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": "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": "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())\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": "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,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": "a,b,c=[int(e) for e in raw_input().split()]\nt=a\npresent=False\nif (c>0 and b= 0:\n\t\tprint 'YES'\n\telse:\n\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 = [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, 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 = 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": "#@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": "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=(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": "#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": "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 = map(int, input().split()); print(['NO', 'YES'][a == b or ( c != 0 and (b-a)%c == 0 and (b-a)//c >= 0)])"}, {"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": "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,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, 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 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, 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": "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": "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:\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": "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": "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, 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": "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 ba or (a-b)%(-c)!=0:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"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": "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 b0:\n print(\"NO\")\nelif a= 0 else \"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": "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,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": "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": "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": "# -*- 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 = 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": "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": "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": "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": "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": "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": "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 ab :\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 (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 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\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": "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": "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": "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": "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": "\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": "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": "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, 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": "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"}, {"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": "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 = [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": "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": "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())\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": "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": "# 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": "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(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\""}], "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 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 ((a0) 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 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 a0 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 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]= 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 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[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 ((a0) 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 ((a0) 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 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 ((a0) 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"} {"nl": {"description": "In this problem you have to solve a simple classification task: given an image, determine whether it depicts a Fourier doodle. You are given a set of 50 images with ids 1 through 50. You are also given a text file labels.txt containing the labels for images with ids 1 through 20, which comprise the learning data set. You have to output the classification results for images with ids 21 through 50 in the same format.", "input_spec": "Download the images and the training labels Each line of the file labels.txt contains a single integer 0 or 1. Line $$$i$$$ (1-based) contains the label of the image {i}.png. Label 1 means that the image depicts a Fourier doodle, label 0 - that it does not.", "output_spec": "Output 30 lines, one line per image 21 through 50. Line $$$i$$$ (1-based) should contain the classification result for the image {i + 20}.png.", "sample_inputs": [], "sample_outputs": [], "notes": null}, "positive_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(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))"}, {"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\\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)\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"}], "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"} {"nl": {"description": "Anya loves to fold and stick. Today she decided to do just that.Anya has n cubes lying in a line and numbered from 1 to n from left to right, with natural numbers written on them. She also has k stickers with exclamation marks. We know that the number of stickers does not exceed the number of cubes.Anya can stick an exclamation mark on the cube and get the factorial of the number written on the cube. For example, if a cube reads 5, then after the sticking it reads 5!, which equals 120.You need to help Anya count how many ways there are to choose some of the cubes and stick on some of the chosen cubes at most k exclamation marks so that the sum of the numbers written on the chosen cubes after the sticking becomes equal to S. Anya can stick at most one exclamation mark on each cube. Can you do it?Two ways are considered the same if they have the same set of chosen cubes and the same set of cubes with exclamation marks.", "input_spec": "The first line of the input contains three space-separated integers n, k and S (1\u2009\u2264\u2009n\u2009\u2264\u200925, 0\u2009\u2264\u2009k\u2009\u2264\u2009n, 1\u2009\u2264\u2009S\u2009\u2264\u20091016)\u00a0\u2014\u00a0the number of cubes and the number of stickers that Anya has, and the sum that she needs to get. The second line contains n positive integers ai (1\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014\u00a0the numbers, written on the cubes. The cubes in the input are described in the order from left to right, starting from the first one. Multiple cubes can contain the same numbers.", "output_spec": "Output the number of ways to choose some number of cubes and stick exclamation marks on some of them so that the sum of the numbers became equal to the given number S.", "sample_inputs": ["2 2 30\n4 3", "2 2 7\n4 3", "3 1 1\n1 1 1"], "sample_outputs": ["1", "1", "6"], "notes": "NoteIn the first sample the only way is to choose both cubes and stick an exclamation mark on each of them.In the second sample the only way is to choose both cubes but don't stick an exclamation mark on any of them.In the third sample it is possible to choose any of the cubes in three ways, and also we may choose to stick or not to stick the exclamation mark on it. So, the total number of ways is six."}, "positive_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) 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 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"}, {"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": "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"}, {"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"}], "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"} {"nl": {"description": "Iahub and Iahubina went to a picnic in a forest full of trees. Less than 5 minutes passed before Iahub remembered of trees from programming. Moreover, he invented a new problem and Iahubina has to solve it, otherwise Iahub won't give her the food. Iahub asks Iahubina: can you build a rooted tree, such that each internal node (a node with at least one son) has at least two sons; node i has ci nodes in its subtree? Iahubina has to guess the tree. Being a smart girl, she realized that it's possible no tree can follow Iahub's restrictions. In this way, Iahub will eat all the food. You need to help Iahubina: determine if there's at least one tree following Iahub's restrictions. The required tree must contain n nodes.", "input_spec": "The first line of the input contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u200924). Next line contains n positive integers: the i-th number represents ci (1\u2009\u2264\u2009ci\u2009\u2264\u2009n).", "output_spec": "Output on the first line \"YES\" (without quotes) if there exist at least one tree following Iahub's restrictions, otherwise output \"NO\" (without quotes). ", "sample_inputs": ["4\n1 1 1 4", "5\n1 1 5 2 1"], "sample_outputs": ["YES", "NO"], "notes": null}, "positive_code": [{"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 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"}, {"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"}, {"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"}], "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"} {"nl": {"description": "A girl named Sonya is studying in the scientific lyceum of the Kingdom of Kremland. The teacher of computer science (Sonya's favorite subject!) invented a task for her.Given an array $$$a$$$ of length $$$n$$$, consisting only of the numbers $$$0$$$ and $$$1$$$, and the number $$$k$$$. Exactly $$$k$$$ times the following happens: Two numbers $$$i$$$ and $$$j$$$ are chosen equiprobable such that ($$$1 \\leq i < j \\leq n$$$). The numbers in the $$$i$$$ and $$$j$$$ positions are swapped. Sonya's task is to find the probability that after all the operations are completed, the $$$a$$$ array will be sorted in non-decreasing order. She turned to you for help. Help Sonya solve this problem.It can be shown that the desired probability is either $$$0$$$ or it can be represented as $$$\\dfrac{P}{Q}$$$, where $$$P$$$ and $$$Q$$$ are coprime integers and $$$Q \\not\\equiv 0~\\pmod {10^9+7}$$$.", "input_spec": "The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \\leq n \\leq 100, 1 \\leq k \\leq 10^9$$$)\u00a0\u2014 the length of the array $$$a$$$ and the number of operations. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\le a_i \\le 1$$$)\u00a0\u2014 the description of the array $$$a$$$.", "output_spec": "If the desired probability is $$$0$$$, print $$$0$$$, otherwise print the value $$$P \\cdot Q^{-1}$$$ $$$\\pmod {10^9+7}$$$, where $$$P$$$ and $$$Q$$$ are defined above.", "sample_inputs": ["3 2\n0 1 0", "5 1\n1 1 1 0 0", "6 4\n1 0 0 1 1 0"], "sample_outputs": ["333333336", "0", "968493834"], "notes": "NoteIn the first example, all possible variants of the final array $$$a$$$, after applying exactly two operations: $$$(0, 1, 0)$$$, $$$(0, 0, 1)$$$, $$$(1, 0, 0)$$$, $$$(1, 0, 0)$$$, $$$(0, 1, 0)$$$, $$$(0, 0, 1)$$$, $$$(0, 0, 1)$$$, $$$(1, 0, 0)$$$, $$$(0, 1, 0)$$$. Therefore, the answer is $$$\\dfrac{3}{9}=\\dfrac{1}{3}$$$.In the second example, the array will not be sorted in non-decreasing order after one operation, therefore the answer is $$$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": "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)])"}, {"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"} {"nl": {"description": "Nowadays all circuses in Berland have a round arena with diameter 13 meters, but in the past things were different.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.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.You are given the coordinates of these three pillars. Find out what is the smallest area that the arena could have.", "input_spec": "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.", "output_spec": "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.", "sample_inputs": ["0.000000 0.000000\n1.000000 1.000000\n0.000000 1.000000"], "sample_outputs": ["1.00000000"], "notes": null}, "positive_code": [{"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\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*\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": "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\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": "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 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 *\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": "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": "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 *\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": "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": "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": "__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": "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": "#!/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": "#!/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\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": "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 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\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": "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": "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": "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": "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, 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\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": "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\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": "# 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": "#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) 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": "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\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\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": "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\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\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": "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"}, {"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 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": "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"}, {"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)"}, {"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": "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, 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": "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\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 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)"}, {"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 *\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": "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": "from math import hypot,acos,pi,sin,fmod\n\ndef gcd(a,b):\n if b 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": "#!/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": "\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": "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": "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": "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= 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\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 *\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": "\"\"\"\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": "#!/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\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 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": "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 *\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 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": "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": "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": "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": "#!/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 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# 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\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": "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 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": "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": "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": "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\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 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 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": "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\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": "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*\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": "#!/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": "#!/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": "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": "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 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": "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 hypot,acos,pi,sin,fmod\n\ndef gcd(a,b):\n if b= 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= 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 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: # potentially find the N\n if abs((smallest * i/180) - round (smallest*i/180)) 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 a100:\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 # : \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 # \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"} {"nl": {"description": "Kavi has $$$2n$$$ points lying on the $$$OX$$$ axis, $$$i$$$-th of which is located at $$$x = i$$$.Kavi considers all ways to split these $$$2n$$$ points into $$$n$$$ pairs. Among those, he is interested in good pairings, which are defined as follows:Consider $$$n$$$ segments with ends at the points in correspondent pairs. The pairing is called good, if for every $$$2$$$ different segments $$$A$$$ and $$$B$$$ among those, at least one of the following holds: One of the segments $$$A$$$ and $$$B$$$ lies completely inside the other. $$$A$$$ and $$$B$$$ have the same length. Consider the following example: $$$A$$$ is a good pairing since the red segment lies completely inside the blue segment.$$$B$$$ is a good pairing since the red and the blue segment have the same length.$$$C$$$ is not a good pairing since none of the red or blue segments lies inside the other, neither do they have the same size.Kavi is interested in the number of good pairings, so he wants you to find it for him. As the result can be large, find this number modulo $$$998244353$$$.Two pairings are called different, if some two points are in one pair in some pairing and in different pairs in another.", "input_spec": "The single line of the input contains a single integer $$$n$$$ $$$(1\\le n \\le 10^6)$$$.", "output_spec": "Print the number of good pairings modulo $$$998244353$$$.", "sample_inputs": ["1", "2", "3", "100"], "sample_outputs": ["1", "3", "6", "688750769"], "notes": "NoteThe good pairings for the second example are: In the third example, the good pairings are: "}, "positive_code": [{"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": "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": "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\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": "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": "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 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 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 (l20)\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": "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": "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": "\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": "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": "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 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": "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\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,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": "#########################################################################################################\\\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": "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": "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": "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": "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": "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": "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": "#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\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": "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\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": "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,a,b,i=int(input())+1,0,0,1\r\nd=[0]*n\r\nwhile i 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 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": "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": "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": "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": "\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": "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 base1: continue \n base = i\n power = 1\n while basex:\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": "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": "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": "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": "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\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": "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": "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": "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": "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": "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": "# 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\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": "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": "# 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": "# 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": "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": "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] 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 = 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": "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": "# 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": "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": "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": "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": "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 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 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": "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>= 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": "\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\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": "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] 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=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": "#!/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": "n,a,b,i=int(input())+1,0,0,1;d=[0]*n\r\nwhile i 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": "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": "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\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": "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": "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": "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": "# 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 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": "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"}], "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 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 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 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= 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"} {"nl": {"description": "Vasily has a number a, which he wants to turn into a number b. For this purpose, he can do two types of operations: multiply the current number by 2 (that is, replace the number x by 2\u00b7x); append the digit 1 to the right of current number (that is, replace the number x by 10\u00b7x\u2009+\u20091). You need to help Vasily to transform the number a into the number b using only the operations described above, or find that it is impossible.Note that in this task you are not required to minimize the number of operations. It suffices to find any way to transform a into b.", "input_spec": "The first line contains two positive integers a and b (1\u2009\u2264\u2009a\u2009<\u2009b\u2009\u2264\u2009109)\u00a0\u2014 the number which Vasily has and the number he wants to have.", "output_spec": "If there is no way to get b from a, print \"NO\" (without quotes). Otherwise print three lines. On the first line print \"YES\" (without quotes). The second line should contain single integer k\u00a0\u2014 the length of the transformation sequence. On the third line print the sequence of transformations x1,\u2009x2,\u2009...,\u2009xk, where: x1 should be equal to a, xk should be equal to b, xi should be obtained from xi\u2009-\u20091 using any of two described operations (1\u2009<\u2009i\u2009\u2264\u2009k). If there are multiple answers, print any of them.", "sample_inputs": ["2 162", "4 42", "100 40021"], "sample_outputs": ["YES\n5\n2 4 8 81 162", "NO", "YES\n5\n100 200 2001 4002 40021"], "notes": null}, "positive_code": [{"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": "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": "\"\"\"\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 = 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": "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": "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": "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": "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, 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": "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 bn:\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 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": "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 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())\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": "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": "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": "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": "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, 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())\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": "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())\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": "##############--->>>>> 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": "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": "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": "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": "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": "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 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": "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": "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": "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": "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": "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)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": "# 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": "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())\nl=[b]\nwhile(a 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": "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": "# 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": "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": "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": "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": "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 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": "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= 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": "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": "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": "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": "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": "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": "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": "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=[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": "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": "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": "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=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": "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": "# -*- 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": "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": "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, 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": "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": "# 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(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": "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())\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": "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": "a,b=map(int,input().split())\nl=[b]\nwhile(a 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": "#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": "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 = 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": "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": "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": "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": "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 = 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())\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,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": "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": "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": "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": "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=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": "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 ba:\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 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": "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": "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 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 ka:\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 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 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 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 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 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 ka:\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(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 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 x10: 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 (num0 for i in x)\nprint(r*c-s(a)*s(zip(*a)))"}, {"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": "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": "\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": "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": "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,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": "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": "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": "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": "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": "#!/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": "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": "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": "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 j0:\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": "\"\"\"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": "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": "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": "#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": "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": "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)"}, {"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": "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": "#!/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": "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": "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().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": "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())\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=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": "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": "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": "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": "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": "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": "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().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": "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": "\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": "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": "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": "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": "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# 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": "#-------------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": "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": "\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": "\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": "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": "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": "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": "\"\"\"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": "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": "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": "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": "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": "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": "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": "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": "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": "'''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": "\"\"\"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": "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, 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": "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": "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())\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": "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": "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": "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 j0):\n print ans\nelse:\n print '0'\n"}, {"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": "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=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,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": "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": "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": "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": "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": "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": "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 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": "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=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": "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, 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": "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 = 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)"}], "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 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(istolb 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"} {"nl": {"description": "Let's introduce the designation , where x is a string, n is a positive integer and operation \"\u2009+\u2009\" is the string concatenation operation. For example, [abc,\u20092]\u2009=\u2009abcabc.We'll say that string s can be obtained from string t, if we can remove some characters from string t and obtain string s. For example, strings ab and a\u0441ba can be obtained from string xacbac, and strings bx and aaa cannot be obtained from it.Sereja has two strings, w\u2009=\u2009[a,\u2009b] and q\u2009=\u2009[c,\u2009d]. He wants to find such maximum integer p (p\u2009>\u20090), that [q,\u2009p] can be obtained from string w.", "input_spec": "The first line contains two integers b, d (1\u2009\u2264\u2009b,\u2009d\u2009\u2264\u2009107). The second line contains string a. The third line contains string c. The given strings are not empty and consist of lowercase English letters. Their lengths do not exceed 100.", "output_spec": "In a single line print an integer \u2014 the largest number p. If the required value of p doesn't exist, print 0.", "sample_inputs": ["10 3\nabab\nbab"], "sample_outputs": ["3"], "notes": null}, "positive_code": [{"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"}, {"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\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": "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": "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"}], "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"} {"nl": {"description": "n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends.Your task is to write a program that will find the minimum and the maximum number of pairs of friends that could have formed by the end of the competition.", "input_spec": "The only line of input contains two integers n and m, separated by a single space (1\u2009\u2264\u2009m\u2009\u2264\u2009n\u2009\u2264\u2009109) \u2014 the number of participants and the number of teams respectively. ", "output_spec": "The only line of the output should contain two integers kmin and kmax \u2014 the minimum possible number of pairs of friends and the maximum possible number of pairs of friends respectively.", "sample_inputs": ["5 1", "3 2", "6 3"], "sample_outputs": ["10 10", "1 1", "3 6"], "notes": "NoteIn the first sample all the participants get into one team, so there will be exactly ten pairs of friends.In the second sample at any possible arrangement one team will always have two participants and the other team will always have one participant. Thus, the number of pairs of friends will always be equal to one.In the third sample minimum number of newly formed friendships can be achieved if participants were split on teams consisting of 2 people, maximum number can be achieved if participants were split on teams of 1, 1 and 4 people."}, "positive_code": [{"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": "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": "# 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": "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": "(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": "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": "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,raw_input().split())\na=n/m\nprint m*a*(a-1)/2+a*(n%m),(n-m)*(n-m+1)/2\n"}, {"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": "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": "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": "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": "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 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": "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": "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": "\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": "\"\"\"\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,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": "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": "# -*- 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": "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,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": "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": "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": "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": "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": "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": "\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": "# 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": "# 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 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": "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": "# 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, 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"}, {"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": "\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 = [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": "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": "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,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,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": "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": "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": "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\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": "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": "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": "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": "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": "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": "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": "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": "#!/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,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,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": "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": "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": "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": "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": "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": "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": "###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": "\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": "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": "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": "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": "\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": "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": "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,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"}, {"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": "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": "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": "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": "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": "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": "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": "(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": "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": "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": "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": "\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": "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": "# 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": "'''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": "# 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": "\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": "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": "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"}], "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 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 qround(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 qteamsize/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 nm:\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 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"} {"nl": {"description": "Fafa owns a company that works on huge projects. There are n employees in Fafa's company. Whenever the company has a new project to start working on, Fafa has to divide the tasks of this project among all the employees.Fafa finds doing this every time is very tiring for him. So, he decided to choose the best l employees in his company as team leaders. Whenever there is a new project, Fafa will divide the tasks among only the team leaders and each team leader will be responsible of some positive number of employees to give them the tasks. To make this process fair for the team leaders, each one of them should be responsible for the same number of employees. Moreover, every employee, who is not a team leader, has to be under the responsibility of exactly one team leader, and no team leader is responsible for another team leader.Given the number of employees n, find in how many ways Fafa could choose the number of team leaders l in such a way that it is possible to divide employees between them evenly.", "input_spec": "The input consists of a single line containing a positive integer n (2\u2009\u2264\u2009n\u2009\u2264\u2009105) \u2014 the number of employees in Fafa's company.", "output_spec": "Print a single integer representing the answer to the problem.", "sample_inputs": ["2", "10"], "sample_outputs": ["1", "3"], "notes": "NoteIn the second sample Fafa has 3 ways: choose only 1 employee as a team leader with 9 employees under his responsibility. choose 2 employees as team leaders with 4 employees under the responsibility of each of them. choose 5 employees as team leaders with 1 employee under the responsibility of each of them. "}, "positive_code": [{"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())\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": "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": "# 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())\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": "n = input()\ns = 1\nfor i in xrange(2,n):\n if n%i == 0:\n s+=1\nprint s"}, {"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": "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):\n\trem = n-i;\n\tif(rem%i == 0):\n\t\tans += 1;\nprint ans;"}, {"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()\nprint len([i for i in xrange(1,n/2+1) if n%i==0])\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": "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": "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": "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(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())\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": "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": "#!/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(input())\nx=0\nfor i in range(1,n):\n if n%i==0:\n x+=1\nprint(x)\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": "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": "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(input())\ns = 0 \nfor A in range(1,n//2 +1): \n if (n-A) % A == 0: \n s+=1\nprint(s) "}, {"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())\ncnt = 0\nfor i in range(1,(n//2)+1):\n if (n-i)%i == 0:\n cnt += 1\nprint(cnt)\n "}, {"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(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": "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": "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())\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": "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())\nl = 0\ncount=0\nfor i in range(1,n):\n if(n%i==0):\n count+=1\nprint(count)\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": "\nn,i,c=int(input()),2,1\nwhile i*i0:\n count+=1\n return count\nif __name__ == \"__main__\":\n n = int(raw_input())\n fhc = FafaHisCompany()\n print fhc.solve(n)"}, {"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": "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": "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": "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": "\"\"\"\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": "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": "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 sum(n%i==0 for i in range(1, n))"}, {"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())\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())\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())\n\nprint(sum(n % d == 0 for d in range(2, n + 1)))\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 = 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=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(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": "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": "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": "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": "n = int(input())\n\nprint(sum(n % d == 0 for d in range(2, n + 1)))\n"}, {"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(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": "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(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))"}, {"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": "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": "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(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(input())\ncount=0\nfor i in range(1,n):\n\tif(n%i==0):\n\t\tcount=count+1\nprint(count)"}, {"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())\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": "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": "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())\ncount = 0\n\nfor i in xrange(1, n):\n if (n-i) % i == 0:\n count += 1\n\nprint count\n"}, {"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())\ncount = 0\nfor i in range(1, n):\n if not n % i:\n count += 1\nprint(count)"}, {"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": "count = 0\nn = int(input())\nfor i in range(1, n):\n if(n % (i+1) == 0):\n count += 1\nprint(count)"}, {"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": "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())\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": "# 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(input())\nans = 0\nfor i in range(1,n):\n\tif n % i == 0:\n\t\tans += 1\nprint(ans)\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": "answer = 0\nn = int(input())\nfor i in range(2, n+1):\n if n % i == 0:\n answer += 1\nprint(answer)"}, {"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=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 i2:\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=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=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"} {"nl": {"description": "Consider a linear function f(x)\u2009=\u2009Ax\u2009+\u2009B. Let's define g(0)(x)\u2009=\u2009x and g(n)(x)\u2009=\u2009f(g(n\u2009-\u20091)(x)) for n\u2009>\u20090. For the given integer values A, B, n and x find the value of g(n)(x) modulo 109\u2009+\u20097.", "input_spec": "The only line contains four integers A, B, n and x (1\u2009\u2264\u2009A,\u2009B,\u2009x\u2009\u2264\u2009109,\u20091\u2009\u2264\u2009n\u2009\u2264\u20091018) \u2014 the parameters from the problem statement. Note that the given value n can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.", "output_spec": "Print the only integer s \u2014 the value g(n)(x) modulo 109\u2009+\u20097.", "sample_inputs": ["3 4 1 1", "3 4 2 1", "3 4 3 1"], "sample_outputs": ["7", "25", "79"], "notes": null}, "positive_code": [{"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": "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": "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": "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=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": "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": "#!/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())\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": "#!/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": "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": "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": "(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": "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": "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": "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\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": "# 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": "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": "#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": "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": "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": "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": "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": "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, 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": "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": "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": "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": "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\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, 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": "#!/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 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, 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\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": "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": "#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": "#!/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": "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, 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": "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,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": "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": "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": "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": "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": "#!/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": "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": "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": "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": "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, 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": "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": "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": "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": "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,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": "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": "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": "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": "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": "# 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": "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": "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": "\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": "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": "\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": "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"}, {"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": "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": "#!/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": "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": "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": "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 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": "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": "\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": "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,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())\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": "\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,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": "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": "# 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": "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": "#!/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": "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": "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": "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": "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": "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=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": "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": "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": "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": "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": "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": "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"}], "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"} {"nl": {"description": "While swimming at the beach, Mike has accidentally dropped his cellphone into the water. There was no worry as he bought a cheap replacement phone with an old-fashioned keyboard. The keyboard has only ten digital equal-sized keys, located in the following way: Together with his old phone, he lost all his contacts and now he can only remember the way his fingers moved when he put some number in. One can formally consider finger movements as a sequence of vectors connecting centers of keys pressed consecutively to put in a number. For example, the finger movements for number \"586\" are the same as finger movements for number \"253\": Mike has already put in a number by his \"finger memory\" and started calling it, so he is now worrying, can he be sure that he is calling the correct number? In other words, is there any other number, that has the same finger movements?", "input_spec": "The first line of the input contains the only integer n (1\u2009\u2264\u2009n\u2009\u2264\u20099)\u00a0\u2014 the number of digits in the phone number that Mike put in. The second line contains the string consisting of n digits (characters from '0' to '9') representing the number that Mike put in.", "output_spec": "If there is no other phone number with the same finger movements and Mike can be sure he is calling the correct number, print \"YES\" (without quotes) in the only line. Otherwise print \"NO\" (without quotes) in the first line.", "sample_inputs": ["3\n586", "2\n09", "9\n123456789", "3\n911"], "sample_outputs": ["NO", "NO", "YES", "YES"], "notes": "NoteYou can find the picture clarifying the first sample case in the statement above."}, "positive_code": [{"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": "# -*- 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": "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": "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": "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": "# 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": "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": "#!/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": "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": "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": "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": "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": "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": "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": "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": "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(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": "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": "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": "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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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())\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": "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": "_, s = input(), set(input())\nprint(('NO', 'YES')[all(set(t) & s for t in '0147 0369 079 123'.split())])"}, {"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": "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(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": "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": "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": "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": "#!/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": "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": "# -*- 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 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": "#! /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()\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 = 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": "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": "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": "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 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": "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": "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": "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 = 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": "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": "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": "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": "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"}, {"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": "#! /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": "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"}, {"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": "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": "#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": "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": "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": "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": "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": "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": "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())\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": "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": "# -*- 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(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": "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=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": "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": "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())\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(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": "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": "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": "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": "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": "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, s = input(), set(input())\nprint(('NO', 'YES')[all(set(t) & s for t in '0147 0369 079 123'.split())])\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=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": "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": "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": "_, s = input(), set(input())\nprint(('NO', 'YES')[all(set(t) & s for t in '0147 0369 079 123'.split())])"}, {"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": "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(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": "#!/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(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"}], "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)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)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)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"} {"nl": {"description": "You are given an integer number $$$n$$$. The following algorithm is applied to it: if $$$n = 0$$$, then end algorithm; find the smallest prime divisor $$$d$$$ of $$$n$$$; subtract $$$d$$$ from $$$n$$$ and go to step $$$1$$$. Determine the number of subtrations the algorithm will make.", "input_spec": "The only line contains a single integer $$$n$$$ ($$$2 \\le n \\le 10^{10}$$$).", "output_spec": "Print a single integer \u2014 the number of subtractions the algorithm will make.", "sample_inputs": ["5", "4"], "sample_outputs": ["1", "2"], "notes": "NoteIn the first example $$$5$$$ is the smallest prime divisor, thus it gets subtracted right away to make a $$$0$$$.In the second example $$$2$$$ is the smallest prime divisor at both steps."}, "positive_code": [{"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())\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": "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": "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": "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": "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": "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": "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": "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": "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": "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 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": "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": "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())\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": "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": "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": "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": "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": "# 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": "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": "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": "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": "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())\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": "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": "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())\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": "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": "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())\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())\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 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": "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"}, {"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": "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": "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": "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": "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": "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": "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*in:i=n\nprint(1+(n-i)//2)"}, {"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())\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 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": "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": "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": "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: , 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": "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": "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 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": "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": "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())\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": "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": "n=input()\ni=2\nwhile i*in]"}, {"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": "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": "#!/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": "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": "#!/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": "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": "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": "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())\ni=2\nwhile i*in:i=n\nprint(1+(n-i)//2)"}, {"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": "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": "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())\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": "\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 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": "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": "\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": "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": "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\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": "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\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": "# 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": "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": "#!/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 \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 __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: , 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": "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": "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": "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 = 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": "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": "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": "'''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": "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: , 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": "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": "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": "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())\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 % 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=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": "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": "#!/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": "#!/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": "#!/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))"}], "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*i0 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] 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"} {"nl": {"description": "Alice and Bob decided to eat some fruit. In the kitchen they found a large bag of oranges and apples. Alice immediately took an orange for herself, Bob took an apple. To make the process of sharing the remaining fruit more fun, the friends decided to play a game. They put multiple cards and on each one they wrote a letter, either 'A', or the letter 'B'. Then they began to remove the cards one by one from left to right, every time they removed a card with the letter 'A', Alice gave Bob all the fruits she had at that moment and took out of the bag as many apples and as many oranges as she had before. Thus the number of oranges and apples Alice had, did not change. If the card had written letter 'B', then Bob did the same, that is, he gave Alice all the fruit that he had, and took from the bag the same set of fruit. After the last card way removed, all the fruit in the bag were over.You know how many oranges and apples was in the bag at first. Your task is to find any sequence of cards that Alice and Bob could have played with.", "input_spec": "The first line of the input contains two integers, x,\u2009y (1\u2009\u2264\u2009x,\u2009y\u2009\u2264\u20091018,\u2009xy\u2009>\u20091) \u2014 the number of oranges and apples that were initially in the bag.", "output_spec": "Print any sequence of cards that would meet the problem conditions as a compressed string of characters 'A' and 'B. That means that you need to replace the segments of identical consecutive characters by the number of repetitions of the characters and the actual character. For example, string AAABAABBB should be replaced by string 3A1B2A3B, but cannot be replaced by 2A1A1B2A3B or by 3AB2A3B. See the samples for clarifications of the output format. The string that you print should consist of at most 106 characters. It is guaranteed that if the answer exists, its compressed representation exists, consisting of at most 106 characters. If there are several possible answers, you are allowed to print any of them. If the sequence of cards that meet the problem statement does not not exist, print a single word Impossible.", "sample_inputs": ["1 4", "2 2", "3 2"], "sample_outputs": ["3B", "Impossible", "1A1B"], "notes": "NoteIn the first sample, if the row contained three cards with letter 'B', then Bob should give one apple to Alice three times. So, in the end of the game Alice has one orange and three apples, and Bob has one apple, in total it is one orange and four apples.In second sample, there is no answer since one card is not enough for game to finish, and two cards will produce at least three apples or three oranges.In the third sample, cards contain letters 'AB', so after removing the first card Bob has one orange and one apple, and after removal of second card Alice has two oranges and one apple. So, in total it is three oranges and two apples."}, "positive_code": [{"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": "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 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] 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": "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"}, {"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": "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": "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<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< ', 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"}, {"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": "# -*- 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": "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 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": "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": "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 0y:\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 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"}], "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"} {"nl": {"description": "Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from $$$1$$$ to $$$9$$$). In this problem, we use one digit and one lowercase letter, which is the first character of the suit, to represent a suited tile. All possible suited tiles are represented as 1m, 2m, $$$\\ldots$$$, 9m, 1p, 2p, $$$\\ldots$$$, 9p, 1s, 2s, $$$\\ldots$$$, 9s.In order to win the game, she must have at least one mentsu (described below) in her hand, so sometimes she should draw extra suited tiles. After drawing a tile, the number of her tiles increases by one. She can draw any tiles she wants, including those already in her hand.Do you know the minimum number of extra suited tiles she needs to draw so that she can win?Here are some useful definitions in this game: A mentsu, also known as meld, is formed by a koutsu or a shuntsu; A koutsu, also known as triplet, is made of three identical tiles, such as [1m, 1m, 1m], however, [1m, 1p, 1s] or [1m, 4m, 7m] is NOT a koutsu; A shuntsu, also known as sequence, is made of three sequential numbered tiles in the same suit, such as [1m, 2m, 3m] and [5s, 7s, 6s], however, [9m, 1m, 2m] or [1m, 2p, 3s] is NOT a shuntsu. Some examples: [2m, 3p, 2s, 4m, 1s, 2s, 4s] \u2014 it contains no koutsu or shuntsu, so it includes no mentsu; [4s, 3m, 3p, 4s, 5p, 4s, 5p] \u2014 it contains a koutsu, [4s, 4s, 4s], but no shuntsu, so it includes a mentsu; [5p, 5s, 9m, 4p, 1s, 7p, 7m, 6p] \u2014 it contains no koutsu but a shuntsu, [5p, 4p, 6p] or [5p, 7p, 6p], so it includes a mentsu. Note that the order of tiles is unnecessary and you can assume the number of each type of suited tiles she can draw is infinite.", "input_spec": "The only line contains three strings\u00a0\u2014 the tiles in Tokitsukaze's hand. For each string, the first character is a digit ranged from $$$1$$$ to $$$9$$$ and the second character is m, p or s.", "output_spec": "Print a single integer\u00a0\u2014 the minimum number of extra suited tiles she needs to draw.", "sample_inputs": ["1s 2s 3s", "9m 9m 9m", "3p 9m 2p"], "sample_outputs": ["0", "0", "1"], "notes": "NoteIn the first example, Tokitsukaze already has a shuntsu.In the second example, Tokitsukaze already has a koutsu.In the third example, Tokitsukaze can get a shuntsu by drawing one suited tile\u00a0\u2014 1p or 4p. The resulting tiles will be [3p, 9m, 2p, 1p] or [3p, 9m, 2p, 4p]."}, "positive_code": [{"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": "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": "\"\"\"\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 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": "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": "\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": "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=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": "\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": "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": "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": "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]= 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=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 = 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": "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": "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": "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": "#include\n#include //per fare input output con scanf and printf\n#include //per fare qsort e bsearch\n#include // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n \n#using namespace std;\n \n#define ld long double\n#define ll long long int\n#define vi vector \n#define pi pair \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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "# ========= /\\ /| |====/|\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": "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": "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": "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": "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=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": "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": "#include\n#include //per fare input output con scanf and printf\n#include //per fare qsort e bsearch\n#include // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n \n#using namespace std;\n \n#define ld long double\n#define ll long long int\n#define vi vector \n#define pi pair \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": "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": "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": "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 = 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "\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": "#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": "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": "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": "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": "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": "\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": "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": "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": "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))"}, {"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": "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": "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": "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": "\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": "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] 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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, 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": "# 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": "'''\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": "#include\n#include //per fare input output con scanf and printf\n#include //per fare qsort e bsearch\n#include // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n \n#using namespace std;\n \n#define ld long double\n#define ll long long int\n#define vi vector \n#define pi pair \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": "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": "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": "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"}], "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(y3):\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(xx):\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 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"} {"nl": {"description": "This is an easier version of the problem. In this version, $$$n \\le 500$$$.Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a string consisting of opening and closing brackets only. Petya believes, that the beauty of the bracket string is a number of its cyclical shifts, which form a correct bracket sequence.To digress from his problems, Vasya decided to select two positions of the string (not necessarily distinct) and swap characters located at this positions with each other. Vasya will apply this operation exactly once. He is curious what is the maximum possible beauty he can achieve this way. Please help him.We remind that bracket sequence $$$s$$$ is called correct if: $$$s$$$ is empty; $$$s$$$ is equal to \"($$$t$$$)\", where $$$t$$$ is correct bracket sequence; $$$s$$$ is equal to $$$t_1 t_2$$$, i.e. concatenation of $$$t_1$$$ and $$$t_2$$$, where $$$t_1$$$ and $$$t_2$$$ are correct bracket sequences. For example, \"(()())\", \"()\" are correct, while \")(\" and \"())\" are not.The cyclical shift of the string $$$s$$$ of length $$$n$$$ by $$$k$$$ ($$$0 \\leq k < n$$$) is a string formed by a concatenation of the last $$$k$$$ symbols of the string $$$s$$$ with the first $$$n - k$$$ symbols of string $$$s$$$. For example, the cyclical shift of string \"(())()\" by $$$2$$$ equals \"()(())\".Cyclical shifts $$$i$$$ and $$$j$$$ are considered different, if $$$i \\ne j$$$.", "input_spec": "The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 500$$$), the length of the string. The second line contains a string, consisting of exactly $$$n$$$ characters, where each of the characters is either \"(\" or \")\".", "output_spec": "The first line should contain a single integer\u00a0\u2014 the largest beauty of the string, which can be achieved by swapping some two characters. The second line should contain integers $$$l$$$ and $$$r$$$ ($$$1 \\leq l, r \\leq n$$$)\u00a0\u2014 the indices of two characters, which should be swapped in order to maximize the string's beauty. In case there are several possible swaps, print any of them.", "sample_inputs": ["10\n()()())(()", "12\n)(()(()())()", "6\n)))(()"], "sample_outputs": ["5\n8 7", "4\n5 10", "0\n1 1"], "notes": "NoteIn the first example, we can swap $$$7$$$-th and $$$8$$$-th character, obtaining a string \"()()()()()\". The cyclical shifts by $$$0, 2, 4, 6, 8$$$ of this string form a correct bracket sequence.In the second example, after swapping $$$5$$$-th and $$$10$$$-th character, we obtain a string \")(())()()(()\". The cyclical shifts by $$$11, 7, 5, 3$$$ of this string form a correct bracket sequence.In the third example, swap of any two brackets results in $$$0$$$ cyclical shifts being correct bracket sequences. "}, "positive_code": [{"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())\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": "def do(i):\n if i == \"(\":\n return 1\n else:\n return -1\ndef find(i,idx):\n if 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=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"}, {"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 smans:\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(tempmaxn):\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(ggmaxi):\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 smans:\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=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())\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"}, {"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 chtf:\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": "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]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"}], "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 i0:\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 l0:\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]=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(tempmaxn):\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(ggmaxi):\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=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=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=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]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]=maxdiv and a>0:\n a-=v*k\n b-=maxdiv\n boxes+=1\nif a>0:\n if b0:\n a-=v\n boxes+=1\nprint boxes\n"}, {"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": "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": "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": "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": "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": "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": "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": "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": "#!/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": "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": "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())\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, 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": "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": "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": "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());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(' '))\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": "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": "#!/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": "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": "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,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": "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": "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": "#!/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": "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 , 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": "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 0:\n d = min(b, k - 1)\n a -= (d + 1) * v\n b -= d\n val += 1\nprint(val)"}, {"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": "#!/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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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, 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": "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": "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": "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": "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": "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": "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": "\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": "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, 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": "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": "#!/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": "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": "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,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, 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": "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": "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": "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": "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": "#!/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())\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())\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": "#!/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": "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": "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=maxdiv and a>0:\n a-=v*k\n b-=maxdiv\n boxes+=1\nif a>0:\n if b0:\n a-=v\n boxes+=1\nprint boxes\n"}, {"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": "\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": "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": "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())\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": "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": "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+10 and b>0):\n\t if v*(b+1)>a and bk:\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 b0):\n c+=math.ceil(a/v)\n print(c)\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())\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 b0:\n a-=v\n boxes+=1\nprint boxes\n"}, {"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": "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"}, {"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, 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())\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())\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": "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 i0):\n d-=i\n break\nprint(res)"}, {"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=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: \n#-------------------------------------------------------------------------------\n\ndef main():\n pass\n\nif __name__ == '__main__':\n main()\nk,a,b,v=map(int, input().split())\nn=0\nif(b0):\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": "# 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": "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=(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,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": "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": "#!/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": "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)"}], "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+10 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(ba):\n print(1)\nelse:\n if b+10):\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+10):\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+10 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(b0):\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 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= 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"} {"nl": {"description": "Amr doesn't like Maths as he finds it really boring, so he usually sleeps in Maths lectures. But one day the teacher suspected that Amr is sleeping and asked him a question to make sure he wasn't.First he gave Amr two positive integers n and k. Then he asked Amr, how many integer numbers x\u2009>\u20090 exist such that: Decimal representation of x (without leading zeroes) consists of exactly n digits; There exists some integer y\u2009>\u20090 such that: ; decimal representation of y is a suffix of decimal representation of x. As the answer to this question may be pretty huge the teacher asked Amr to output only its remainder modulo a number m.Can you help Amr escape this embarrassing situation?", "input_spec": "Input consists of three integers n,\u2009k,\u2009m (1\u2009\u2264\u2009n\u2009\u2264\u20091000, 1\u2009\u2264\u2009k\u2009\u2264\u2009100, 1\u2009\u2264\u2009m\u2009\u2264\u2009109).", "output_spec": "Print the required number modulo m.", "sample_inputs": ["1 2 1000", "2 2 1000", "5 3 1103"], "sample_outputs": ["4", "45", "590"], "notes": "NoteA suffix of a string S is a non-empty string that can be obtained by removing some number (possibly, zero) of first characters from S."}, "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": "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": "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": "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 d0 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"}, {"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)"}], "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 d0 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 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"} {"nl": {"description": "Do you remember a kind cartoon \"Beauty and the Beast\"? No, no, there was no firing from machine guns or radiation mutants time-travels!There was a beauty named Belle. Once she had violated the Beast's order and visited the West Wing. After that she was banished from the castle... Everybody was upset. The beautiful Belle was upset, so was the Beast, so was Lumiere the candlestick. But the worst thing was that Cogsworth was upset. Cogsworth is not a human, but is the mantel clock, which was often used as an alarm clock.Due to Cogsworth's frustration all the inhabitants of the castle were in trouble: now they could not determine when it was time to drink morning tea, and when it was time for an evening stroll. Fortunately, deep in the basement are lying digital clock showing the time in the format HH:MM. Now the residents of the castle face a difficult task. They should turn Cogsworth's hour and minute mustache hands in such a way, that Cogsworth began to show the correct time. Moreover they need to find turn angles in degrees for each mustache hands. The initial time showed by Cogsworth is 12:00.You can only rotate the hands forward, that is, as is shown in the picture: As since there are many ways too select such angles because of full rotations, choose the smallest angles in the right (non-negative) direction.Note that Cogsworth's hour and minute mustache hands move evenly and continuously. Hands are moving independently, so when turning one hand the other hand remains standing still.", "input_spec": "The only line of input contains current time according to the digital clock, formatted as HH:MM (00\u2009\u2264\u2009HH\u2009\u2264\u200923, 00\u2009\u2264\u2009MM\u2009\u2264\u200959). The mantel clock initially shows 12:00. Pretests contain times of the beginning of some morning TV programs of the Channel One Russia.", "output_spec": "Print two numbers x and y \u2014 the angles of turning the hour and minute hands, respectively (0\u2009\u2264\u2009x,\u2009y\u2009<\u2009360). The absolute or relative error in the answer should not exceed 10\u2009-\u20099.", "sample_inputs": ["12:00", "04:30", "08:17"], "sample_outputs": ["0 0", "135 180", "248.5 102"], "notes": "NoteA note to the second example: the hour hand will be positioned exactly in the middle, between 4 and 5."}, "positive_code": [{"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": "#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": "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": "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": "h,m = map(int, raw_input().split(\":\"))\nprint (h%12)*30+0.5*m, 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": "s=input()\nh=int(s[:2])\nm=int(s[3:])\nprint(h%12*30+m/2,m*6)"}, {"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": "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": "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": "s=input()\nh=int(s[:2])\nm=int(s[3:])\nprint(h%12*30+m/2,m*6)"}, {"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 = 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "h, m = map(int, raw_input().split(\":\"))\nh = h % 12\nprint h * 30 + m / 2.0, m * 6 \n"}, {"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": "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": "a, b = map(int, input().split(':'))\nprint(30*(a-12*(a>11)+b/60), 6*b)"}, {"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": "\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": "h,m = map(int, input().split(':'))\nif h >=12:\n h-=12\nprint(float(30*h+m/2), m*6)\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": "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": "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": "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": "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": "h,m=map(int,raw_input().split(\":\"));print h%12*30+m/2.,m*6"}, {"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": "# 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": "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": "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": "s = input()\nh = (int(s[:2]))%12\nm = int(s[3:])\nh += m/60\nprint(h*5*6, m*6)"}, {"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": "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": "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": "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": "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": "a, b = map(int, input().split(':'))\nprint(30 * (a % 12) + b / 2, 6 * b) "}, {"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": "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": "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": "a, b = map(int, input().split(':'))\nprint(30 * (a % 12) + b / 2, 6 * b) "}, {"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": "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": "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": "h, m = map(int, raw_input().split(':'))\nprint (h * 30 + m * 0.5) % 360, m * 6"}, {"source_code": "HH, MM = map(int, input().split(':'))\n\nprint(30*(HH%12)+MM/2, 6*MM)"}, {"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": "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"}, {"source_code": "s=input()\nh=int(s[:2])\nm=int(s[3:])\nprint(h%12*30+m/2,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": "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(\":\"))\nh = h % 12\nprint h * 30 + m / 2.0, m * 6 \n"}, {"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": "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": "s=input()\nh=int(s[:2])\nm=int(s[3:])\nprint(h%12*30+m/2,m*6)"}, {"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\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": "'''\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": "h, m = map(int, raw_input().split(\":\"))\nh = h % 12\nprint h * 30 + m / 2.0, m * 6 \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": "hh, mm = map(int, input().split(\":\"))\n\nprint((hh%12)*30 + mm/2, mm*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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "a, b = map(int, input().split(':'))\nprint(30*(a-12*(a>11)+b/60), 6*b)"}, {"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": "hh,mm=map(int,raw_input().split(':'))\nhh%=12\nhd=hh*30+mm*.5\nmd=mm*6\nprint hd,md\n"}, {"source_code": "h, m = map(int, raw_input().split(\":\"))\nprint h % 12 * 30 + m / 2., m * 6 \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": "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": "#!/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": "s = input()\nh = (int(s[:2]))%12\nm = int(s[3:])\nh += m/60\nprint(h*5*6, 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": "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": "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": "h,m=map(int,raw_input().split(\":\"));print h%12*30+m/2.,m*6"}, {"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])\nm=int(s[3:])\nprint(h%12*30+m/2,m*6)"}, {"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": "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": "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])\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))"}], "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"} {"nl": {"description": "On a chessboard with a width of $$$n$$$ and a height of $$$n$$$, rows are numbered from bottom to top from $$$1$$$ to $$$n$$$, columns are numbered from left to right from $$$1$$$ to $$$n$$$. Therefore, for each cell of the chessboard, you can assign the coordinates $$$(r,c)$$$, where $$$r$$$ is the number of the row, and $$$c$$$ is the number of the column.The white king has been sitting in a cell with $$$(1,1)$$$ coordinates for a thousand years, while the black king has been sitting in a cell with $$$(n,n)$$$ coordinates. They would have sat like that further, but suddenly a beautiful coin fell on the cell with coordinates $$$(x,y)$$$...Each of the monarchs wanted to get it, so they decided to arrange a race according to slightly changed chess rules:As in chess, the white king makes the first move, the black king makes the second one, the white king makes the third one, and so on. However, in this problem, kings can stand in adjacent cells or even in the same cell at the same time.The player who reaches the coin first will win, that is to say, the player who reaches the cell with the coordinates $$$(x,y)$$$ first will win.Let's recall that the king is such a chess piece that can move one cell in all directions, that is, if the king is in the $$$(a,b)$$$ cell, then in one move he can move from $$$(a,b)$$$ to the cells $$$(a + 1,b)$$$, $$$(a - 1,b)$$$, $$$(a,b + 1)$$$, $$$(a,b - 1)$$$, $$$(a + 1,b - 1)$$$, $$$(a + 1,b + 1)$$$, $$$(a - 1,b - 1)$$$, or $$$(a - 1,b + 1)$$$. Going outside of the field is prohibited.Determine the color of the king, who will reach the cell with the coordinates $$$(x,y)$$$ first, if the white king moves first.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$2 \\le n \\le 10^{18}$$$)\u00a0\u2014 the length of the side of the chess field. The second line contains two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x,y \\le n$$$)\u00a0\u2014 coordinates of the cell, where the coin fell.", "output_spec": "In a single line print the answer \"White\" (without quotes), if the white king will win, or \"Black\" (without quotes), if the black king will win. You can print each letter in any case (upper or lower).", "sample_inputs": ["4\n2 3", "5\n3 5", "2\n2 2"], "sample_outputs": ["White", "Black", "Black"], "notes": "NoteAn example of the race from the first sample where both the white king and the black king move optimally: The white king moves from the cell $$$(1,1)$$$ into the cell $$$(2,2)$$$. The black king moves form the cell $$$(4,4)$$$ into the cell $$$(3,3)$$$. The white king moves from the cell $$$(2,2)$$$ into the cell $$$(2,3)$$$. This is cell containing the coin, so the white king wins. An example of the race from the second sample where both the white king and the black king move optimally: The white king moves from the cell $$$(1,1)$$$ into the cell $$$(2,2)$$$. The black king moves form the cell $$$(5,5)$$$ into the cell $$$(4,4)$$$. The white king moves from the cell $$$(2,2)$$$ into the cell $$$(3,3)$$$. The black king moves from the cell $$$(4,4)$$$ into the cell $$$(3,5)$$$. This is the cell, where the coin fell, so the black king wins. In the third example, the coin fell in the starting cell of the black king, so the black king immediately wins. "}, "positive_code": [{"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())\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=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 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": "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 = 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())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\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 = (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())\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": "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().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())\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 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": "\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": " #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(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())\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())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\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(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(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())\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())\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\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=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())\na,b = map(int,input().split())\nprint(\"White\"if (a+b) <=(n+1) else \"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": "#!/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": "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())\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": "# 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": "\"\"\"\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": "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": "#----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())\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 = 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 (x-1 + y-1) <= (n-x + n-y):\n print('White')\nelse:\n print('Black')"}, {"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": "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 = 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 = int(input())\nx,y = map(int,input().split())\nk = x+y-2\nh= 2*n-x-y\nif h==k or k 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())\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(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": "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(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())\n\nif abs(x - 1) + abs(y - 1) - 1 < abs(x - n) + abs(y - n):\n\tprint('White')\nelse:\n\tprint('Black')"}, {"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=map(int,input().split())\nif (x+y-2)<=(2*n-x-y):\n\tprint('White')\nelse:\n\tprint('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(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": "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( )"}, {"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())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\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=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 #! /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 = 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-whiterowy-whitecolumn:\n whiteturn+=y-whitecolumn;\n whiteturn+=(x-whiterow)-(y-whitecolumn);\nelif x-whiterow==y-whitecolumn:\n whiteturn+=x-whiterow;\n \nif blackrow-xblackcolumn-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": "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())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\n print(\"White\")\nelse:\n print(\"Black\")\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 else print('Black')"}, {"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": "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": "n = int(input())\na,b = map(int,input().split())\nprint(\"White\"if (a+b) <=(n+1) else \"Black\")"}, {"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 = 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=[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())\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())\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=b 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": "#!/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": "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": "# 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": "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": " #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 = 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=int(input())\na,b=input().split()\nif (int(a)+int(b))-1<=n:\n print(\"White\")\nelse:\n print(\"Black\")\n"}, {"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 = 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": "print([\"Black\",\"White\"][int(input())+1>=sum(map(int,input().split()))])\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 = [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 = 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 = 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())\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": "# 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": "a = input()\nb,c = sorted(map(int,raw_input().split()))\nif b-1<=a-c:\n print 'White'\nelse:\n print 'Black'\n"}], "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 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 z1k:\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 z1k:\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 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 z1kx:\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 tk:\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 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 z1kx:\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 z1kx:\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+xk:\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 z1kx:\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 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"} {"nl": {"description": "You found a mysterious function f. The function takes two strings s1 and s2. These strings must consist only of lowercase English letters, and must be the same length.The output of the function f is another string of the same length. The i-th character of the output is equal to the minimum of the i-th character of s1 and the i-th character of s2.For example, f(\"ab\", \"ba\") = \"aa\", and f(\"nzwzl\", \"zizez\") = \"niwel\".You found two strings x and y of the same length and consisting of only lowercase English letters. Find any string z such that f(x,\u2009z)\u2009=\u2009y, or print -1 if no such string z exists.", "input_spec": "The first line of input contains the string x. The second line of input contains the string y. Both x and y consist only of lowercase English letters, x and y have same length and this length is between 1 and 100.", "output_spec": "If there is no string z such that f(x,\u2009z)\u2009=\u2009y, print -1. Otherwise, print a string z such that f(x,\u2009z)\u2009=\u2009y. If there are multiple possible answers, print any of them. The string z should be the same length as x and y and consist only of lowercase English letters.", "sample_inputs": ["ab\naa", "nzwzl\nniwel", "ab\nba"], "sample_outputs": ["ba", "xiyez", "-1"], "notes": "NoteThe first case is from the statement.Another solution for the second case is \"zizez\"There is no solution for the third case. That is, there is no z such that f(\"ab\", z)\u2009=\u2009 \"ba\"."}, "positive_code": [{"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": "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": "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()\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": "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": "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": "# -*- 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 = 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": "x = input()\ny = input()\nz = []\nflag=0\nfor i in range(len(x)):\n if x[i] 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": "str1=str(raw_input())\nstr2=str(raw_input())\n\nstr3=[]\nfoo1=False\nfoo2=False\nfor i in range(len(str1)):\n if str1[i]x[i]:\n z = -1\n break\n else:\n z += y[i]\nprint z"}, {"source_code": "x=input()\nz=input()\ny=''\nfor i in range (len(z)):\n if z[i]>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 z+=y[i]\n else:\n z+=x[i]\n pr(z)\n \nfor _ in range(1):\n solve()\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": "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": "\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)"}, {"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": "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": "\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]) 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": "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": "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(xi):\n\t\tprint -1\n\t\texit()\n\ty += chr(min(ord(xi),ord(zi)))\n\ti += 1\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": "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": "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": "a,b=raw_input(),raw_input()\nfor x,y in zip(a,b):\n if xx[i] for i in range(len(x))) else y)"}, {"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]) x[i]:\n print -1\n sys.exit()\n z.append(y[i])\n\nprint ''.join(z)\n\n\n"}, {"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": "s=input()\nl=input()\nprint(-1 if any(s[i]x for x,y in zip(a,b))])"}, {"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]x[i]:\n print(-1);exit(0)\n else:\n b.append(y[i])\nprint(''.join(b))"}, {"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": "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": "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": "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": "s1=input()\ns2=input()\nfor i in range(len(s1)):\n\tif ord(s1[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": "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": "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 = 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": "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": "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": "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": "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": "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": "def check(a,b):\n\tw=''\n\tfor i in range(len(a)):\n\t\tif a[i] alf.find(y[i]):\n\t\tz += y[i]\n\nelse:\n\tprint(z)"}, {"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()\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,y = raw_input(), raw_input()\nprint all(a>=b for a,b in zip(x,y)) * y or \"-1\""}, {"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": "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": "x, y = input(), input()\nprint(-1 if any(ch1 < ch2 for ch1, ch2 in zip(x, y)) else y)"}, {"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]0:\n\tprint(k)\n"}, {"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] 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": "x,y=input(),input()\nprint('-1' if any(y[i]>x[i] for i in range(len(x))) else y)"}, {"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()\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 = 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()); y = list(input())\nprint(-1 if any(b>a for a, b in zip(x,y)) else ''.join(y))"}, {"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": "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": "str1=str(raw_input())\nstr2=str(raw_input())\n\nstr3=[]\nfoo1=False\nfoo2=False\nfor i in range(len(str1)):\n if str1[i]0:\n\tprint(k)\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 = 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": "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": "s1 = str(input())\ns2 = str(input())\nans = ''\ni =0\nwhile is1[i]:\n ans = -1\n break\n i = i + 1\nif ans!=-1:\n ans = s2\nprint(ans)"}, {"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": "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": "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": "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 = 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": "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": "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 = input()\ny = input()\nprint( -1 if any( ord( x[ i ] ) < ord( y[ i ] ) for i in range( len( x ) ) ) else y )\n"}, {"source_code": "s=input()\nl=input()\nfor i in range(len(s)):\n if(s[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": "# 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)"}], "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 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 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])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])= 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]) 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(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]) 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])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 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] 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] 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]) 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])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 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"} {"nl": {"description": "On her way to programming school tiger Dasha faced her first test \u2014 a huge staircase! The steps were numbered from one to infinity. As we know, tigers are very fond of all striped things, it is possible that it has something to do with their color. So on some interval of her way she calculated two values \u2014 the number of steps with even and odd numbers. You need to check whether there is an interval of steps from the l-th to the r-th (1\u2009\u2264\u2009l\u2009\u2264\u2009r), for which values that Dasha has found are correct.", "input_spec": "In the only line you are given two integers a, b (0\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009100) \u2014 the number of even and odd steps, accordingly.", "output_spec": "In the only line print \"YES\", if the interval of steps described above exists, and \"NO\" otherwise.", "sample_inputs": ["2 3", "3 1"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first example one of suitable intervals is from 1 to 5. The interval contains two even steps\u00a0\u2014 2 and 4, and three odd: 1, 3 and 5."}, "positive_code": [{"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().split())\nprint 'YES' if a + b > 0 and abs(a - b) <= 1 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": "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 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": "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": "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": "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())\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, raw_input().split())\nprint 'YES' if a + b > 0 and abs(a - b) <= 1 else 'NO'"}, {"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": "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": "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": "\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": "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, raw_input().split())\nprint 'YES' if abs(a-b) <= 1 and (a > 0 or b > 0) else '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": "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": "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')"}, {"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": "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": "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 = 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": "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());print(\"YES\" if abs(a-b)<2 and a+b!=0 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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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 = map(int, raw_input().split())\n\nprint 'YES' if abs(a - b) < 2 and a + b > 0 else '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": "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": "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": "# -*- 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": "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 0<=abs(a-b)<=1 and (a!=0 or b!=0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a, b = map(int, raw_input().split())\nprint ['NO', 'YES'][(a or b) and abs(a-b) < 2]"}, {"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": "\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==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())\nif max(a, b) > 0 and abs(b-a) < 2: print 'YES'\nelse: print 'NO'\n"}, {"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": "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": "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": "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": "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": "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());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=map(int,input().split())\nprint('YES' if (a-b in [1,-1,0]) and ((a!=0) or (b!=0) ) else '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": "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": "a, b = map(int, input().split())\nprint([\"NO\", \"YES\"][abs(a-b)<2 and a+b>0])"}, {"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": "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 abs(a-b)>1 :\n print(\"NO\")\nelif a==0 and b==0:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"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": "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,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": "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": "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": "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": "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": "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": "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": "a, b = map(int, input().split())\nprint([\"NO\", \"YES\"][abs(a-b)<2 and a+b>0])"}, {"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 = [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": "\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=(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": "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,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": "a,b=map(int,input().split())\nif abs(a-b)<=1 and a+b!=0:\n print(\"YES\")\nelse:\n print(\"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==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())\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 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": "# 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": "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": "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": "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": "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": "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": "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": "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": "# -*- 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())\nprint('YES' if abs(a - b) < 2 and (a, b) != (0, 0) else '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": "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 = 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"}], "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 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=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"} {"nl": {"description": "User ainta is making a web site. This time he is going to make a navigation of the pages. In his site, there are n pages numbered by integers from 1 to n. Assume that somebody is on the p-th page now. The navigation will look like this: << p\u2009-\u2009k p\u2009-\u2009k\u2009+\u20091 ... p\u2009-\u20091 (p) p\u2009+\u20091 ... p\u2009+\u2009k\u2009-\u20091 p\u2009+\u2009k >> When someone clicks the button \"<<\" he is redirected to page 1, and when someone clicks the button \">>\" he is redirected to page n. Of course if someone clicks on a number, he is redirected to the corresponding page.There are some conditions in the navigation: If page 1 is in the navigation, the button \"<<\" must not be printed. If page n is in the navigation, the button \">>\" must not be printed. If the page number is smaller than 1 or greater than n, it must not be printed. \u00a0You can see some examples of the navigations. Make a program that prints the navigation.", "input_spec": "The first and the only line contains three integers n, p, k (3\u2009\u2264\u2009n\u2009\u2264\u2009100; 1\u2009\u2264\u2009p\u2009\u2264\u2009n; 1\u2009\u2264\u2009k\u2009\u2264\u2009n)", "output_spec": "Print the proper navigation. Follow the format of the output from the test samples.", "sample_inputs": ["17 5 2", "6 5 2", "6 1 2", "6 2 2", "9 6 3", "10 6 3", "8 5 4"], "sample_outputs": ["<< 3 4 (5) 6 7 >>", "<< 3 4 (5) 6", "(1) 2 3 >>", "1 (2) 3 4 >>", "<< 3 4 5 (6) 7 8 9", "<< 3 4 5 (6) 7 8 9 >>", "1 2 3 4 (5) 6 7 8"], "notes": null}, "positive_code": [{"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]>\")"}, {"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": "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": "_ = 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": "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])>\")\nprint(\" \".join(ls))"}, {"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": "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": "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": "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] = [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] = [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())\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": "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": "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\t\t\n\telif (p-k)<=1 :\n\t\t#print(1,end=' ')\n\t\tif(p+k)>')\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=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>',end='')"}, {"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>']\nprint ' '.join(a)\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,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>\",end = \" \")"}, {"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": "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": "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>\")\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": "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": "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": "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\nprint(' '.join(res).strip())"}, {"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": "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>')\nprint(' '.join(nav))\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) and ('('+str(n)+')') not in s):\n s=s+'>>'\nprint(s)\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>\")\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": "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": "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": "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": "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>',end='')"}, {"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": "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>']\nprint ' '.join(s)\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": "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\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": "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": "# # 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 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": "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": "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": "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 = 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": "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": "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,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": "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"}, {"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": "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": "# 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>\""}, {"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": "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": "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, 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": "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())\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": "(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)>'\nprint s"}, {"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 >= 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": "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)>\")"}, {"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())\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": "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>')\nif p-k<=1 and 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 = [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": "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": "# 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": "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>')\nelse:\n for i in range(p,n):\n output.append(str(i+1))\n\nprint(' '.join(output))\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 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": "#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": "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": "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": "#! /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": "_ = 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": "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": "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())\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": "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": "'''\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": "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>\",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, 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": "_ = 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": "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,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=[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": "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": "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": "# 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, 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 = 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": "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>')\nprint(' '.join(nav))\n"}, {"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 = 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": "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": "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]>\")"}, {"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": "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 = 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": "# -*- 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)"}], "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=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=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=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>\",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>')\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+k1:\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>\"\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>\",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\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 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)>',\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\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>\",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>\"\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>\",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 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>\")"}, {"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>')\nif p-k<=1 and 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>\")"}, {"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>\")\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 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>\")"}, {"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>')\nif p-k<=1 and 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\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>')"}, {"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"} {"nl": {"description": "InputThe input contains two integers $$$N$$$, $$$M$$$ ($$$1 \\le N \\le 1024, 2 \\le M \\le 16$$$), separated by a single space.OutputOutput \"YES\" or \"NO\".ExamplesInput\n2 3\nOutput\nYES\nInput\n3 2\nOutput\nNO\nInput\n33 16\nOutput\nYES\nInput\n26 5\nOutput\nNO\n", "input_spec": "The input contains two integers $$$N$$$, $$$M$$$ ($$$1 \\le N \\le 1024, 2 \\le M \\le 16$$$), separated by a single space.", "output_spec": "Output \"YES\" or \"NO\".", "sample_inputs": ["2 3", "3 2", "33 16", "26 5"], "sample_outputs": ["YES", "NO", "YES", "NO"], "notes": null}, "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################################ ###########################################\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###########################################################################################\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 = [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)]) "}, {"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}) 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)) 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)) 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"} {"nl": {"description": "Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like game there are $$$p$$$ players doing penalty shoot-outs. Winner is the one who scores the most. In case of ties, one of the top-scorers will be declared as the winner randomly with equal probability.They have just finished the game and now are waiting for the result. But there's a tiny problem! The judges have lost the paper of scores! Fortunately they have calculated sum of the scores before they get lost and also for some of the players they have remembered a lower bound on how much they scored. However, the information about the bounds is private, so Hasan only got to know his bound.According to the available data, he knows that his score is at least $$$r$$$ and sum of the scores is $$$s$$$.Thus the final state of the game can be represented in form of sequence of $$$p$$$ integers $$$a_1, a_2, \\dots, a_p$$$ ($$$0 \\le a_i$$$) \u2014 player's scores. Hasan is player number $$$1$$$, so $$$a_1 \\ge r$$$. Also $$$a_1 + a_2 + \\dots + a_p = s$$$. Two states are considered different if there exists some position $$$i$$$ such that the value of $$$a_i$$$ differs in these states. Once again, Hasan doesn't know the exact scores (he doesn't know his exact score as well). So he considers each of the final states to be equally probable to achieve.Help Hasan find the probability of him winning.It can be shown that it is in the form of $$$\\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are non-negative integers and $$$Q \\ne 0$$$, $$$P \\le Q$$$. Report the value of $$$P \\cdot Q^{-1} \\pmod {998244353}$$$.", "input_spec": "The only line contains three integers $$$p$$$, $$$s$$$ and $$$r$$$ ($$$1 \\le p \\le 100$$$, $$$0 \\le r \\le s \\le 5000$$$) \u2014 the number of players, the sum of scores of all players and Hasan's score, respectively.", "output_spec": "Print a single integer \u2014 the probability of Hasan winning. It can be shown that it is in the form of $$$\\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are non-negative integers and $$$Q \\ne 0$$$, $$$P \\le Q$$$. Report the value of $$$P \\cdot Q^{-1} \\pmod {998244353}$$$.", "sample_inputs": ["2 6 3", "5 20 11", "10 30 10"], "sample_outputs": ["124780545", "1", "85932500"], "notes": "NoteIn the first example Hasan can score $$$3$$$, $$$4$$$, $$$5$$$ or $$$6$$$ goals. If he scores $$$4$$$ goals or more than he scores strictly more than his only opponent. If he scores $$$3$$$ then his opponent also scores $$$3$$$ and Hasan has a probability of $$$\\frac 1 2$$$ to win the game. Thus, overall he has the probability of $$$\\frac 7 8$$$ to win.In the second example even Hasan's lower bound on goal implies him scoring more than any of his opponents. Thus, the resulting probability is $$$1$$$."}, "positive_code": [{"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"}, {"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"} {"nl": {"description": "A string $$$s$$$ of length $$$n$$$ can be encrypted by the following algorithm: iterate over all divisors of $$$n$$$ in decreasing order (i.e. from $$$n$$$ to $$$1$$$), for each divisor $$$d$$$, reverse the substring $$$s[1 \\dots d]$$$ (i.e. the substring which starts at position $$$1$$$ and ends at position $$$d$$$). For example, the above algorithm applied to the string $$$s$$$=\"codeforces\" leads to the following changes: \"codeforces\" $$$\\to$$$ \"secrofedoc\" $$$\\to$$$ \"orcesfedoc\" $$$\\to$$$ \"rocesfedoc\" $$$\\to$$$ \"rocesfedoc\" (obviously, the last reverse operation doesn't change the string because $$$d=1$$$).You are given the encrypted string $$$t$$$. Your task is to decrypt this string, i.e., to find a string $$$s$$$ such that the above algorithm results in string $$$t$$$. It can be proven that this string $$$s$$$ always exists and is unique.", "input_spec": "The first line of input consists of a single integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 the length of the string $$$t$$$. The second line of input consists of the string $$$t$$$. The length of $$$t$$$ is $$$n$$$, and it consists only of lowercase Latin letters.", "output_spec": "Print a string $$$s$$$ such that the above algorithm results in $$$t$$$.", "sample_inputs": ["10\nrocesfedoc", "16\nplmaetwoxesisiht", "1\nz"], "sample_outputs": ["codeforces", "thisisexampletwo", "z"], "notes": "NoteThe first example is described in the problem statement."}, "positive_code": [{"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=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 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": "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": "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 = 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": "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(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": "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": "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": "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": "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 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": "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())\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": "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": "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": "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": "# -*- 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": "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": "#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())\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": "# -*- 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": "# 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": "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": "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=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# 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())\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 = 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": "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": "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": "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": "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(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())\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": "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 = 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": "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": "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": "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(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": "#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": "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": "# 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 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()\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": "a=int(input());b=input();i=1\nwhile(i= 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": "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": "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": "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": "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": "#!/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 = 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": "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": "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": "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": "#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": "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": "#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=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": "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=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": "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(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": "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()"}, {"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": "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())\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": "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": "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 = 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": "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": "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())\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\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": "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": "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 = ''.join(reversed(s[0:i])) + s[i:] \nprint(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": "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": "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": "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": "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": "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()\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 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 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(i1:\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"} {"nl": {"description": "Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divide cards between them in some manner, it's possible that they have different number of cards. Then they play a \"war\"-like card game. The rules are following. On each turn a fight happens. Each of them picks card from the top of his stack and puts on the table. The one whose card value is bigger wins this fight and takes both cards from the table to the bottom of his stack. More precisely, he first takes his opponent's card and puts to the bottom of his stack, and then he puts his card to the bottom of his stack. If after some turn one of the player's stack becomes empty, he loses and the other one wins. You have to calculate how many fights will happen and who will win the game, or state that game won't end.", "input_spec": "First line contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u200910), the number of cards. Second line contains integer k1 (1\u2009\u2264\u2009k1\u2009\u2264\u2009n\u2009-\u20091), the number of the first soldier's cards. Then follow k1 integers that are the values on the first soldier's cards, from top to bottom of his stack. Third line contains integer k2 (k1\u2009+\u2009k2\u2009=\u2009n), the number of the second soldier's cards. Then follow k2 integers that are the values on the second soldier's cards, from top to bottom of his stack. All card values are different.", "output_spec": "If somebody wins in this game, print 2 integers where the first one stands for the number of fights before end of game and the second one is 1 or 2 showing which player has won. If the game won't end and will continue forever output \u2009-\u20091.", "sample_inputs": ["4\n2 1 3\n2 4 2", "3\n1 2\n2 1 3"], "sample_outputs": ["6 2", "-1"], "notes": "NoteFirst sample: Second sample: "}, "positive_code": [{"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] 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=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": "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())\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": "##############--->>>>> 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": "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=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": "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 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": "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": "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": "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": "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())\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": "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=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": "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": "##############--->>>>> 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\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": "# 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": "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": "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": "\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": "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": "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": "#!/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": "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": "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": "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": "#*+++++++++++++++++++++\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(aq:\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(input())\na = list(map(int,input().split()))[1:]\nb = list(map(int,input().split()))[1:]\n\ni=0\ng=1000000\nwhile i0 and len(b)>0:\n if a[0] 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": "\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": "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": "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())\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=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] 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(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": "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": "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": "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 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": "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\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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(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": "__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": "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": "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": "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": "'''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())\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": "'''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=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": "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 \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": "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": "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])soldado2:\n soldado1.ganar(soldado2)\n soldado2.perder()\n t+=1\n\n elif soldado1500:\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": "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": "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": "#!/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": "\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": "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": "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": "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": "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": "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": "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": "\"\"\"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": "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": "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": "## 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": "\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": "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": "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": "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": "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": "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 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(x200):\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": "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": "\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": "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()\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"}, {"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": "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"}], "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 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]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 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 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]soldado2:\n soldado1.ganar(soldado2)\n soldado2.perder()\n t+=1\n\n elif soldado150:\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< 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 val10 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]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 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]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 val1b:\n a+=[b.pop(0),a.pop(0)]\n elif a 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"} {"nl": {"description": "One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem.Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight.", "input_spec": "The first (and the only) input line contains integer number w (1\u2009\u2264\u2009w\u2009\u2264\u2009100) \u2014 the weight of the watermelon bought by the boys.", "output_spec": "Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case.", "sample_inputs": ["8"], "sample_outputs": ["YES"], "notes": "NoteFor example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant \u2014 two parts of 4 and 4 kilos)."}, "positive_code": [{"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": "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": "n = int(raw_input())\n \nif n <= 2:\n print \"NO\"\nelif n % 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": "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": "w = int(input())\nif(w<=2):\n print(\"NO\")\nelif((w-2)%2==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "inp = int(raw_input())\nif inp > 2:\n print ['YES','NO'][inp%2]\nelse:\n print 'NO'"}, {"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": "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):\n print(\"NO\")\nelif w % 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": "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": "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": "x = float(input())\nif x<=2:\n print(\"NO\")\nelif x%2 == 0:\n print(\"YES\")\nelse:\n print(\"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": "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= input()\nif (w % 2 == 1) or (w == 2):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"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": "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": "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 >= 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": "w = int(input())\nif w == 2:\n print (\"NO\")\nelif w % 2 == 0:\n print (\"YES\")\nelse:\n print (\"NO\")"}, {"source_code": "w = int(input())\nif (w%2 == 1 or w < 3):\n print(\"NO\")\nelse :\n print(\"YES\")\n"}, {"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": "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": "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": "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 <= 2:\n print(\"No\")\nelif w%2 == 0:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"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": "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": "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": "w = int(raw_input())\nif (w==2):\n print (\"NO\")\nelif (w % 2 == 0):\n print (\"YES\")\nelse:\n print (\"NO\")"}, {"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": "input = input() \nif(input == 2 or input == 0):\n print(\"NO\")\nelif(input % 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": "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": "w=int(input())\nif w%2 == 0 and w > 2:\n\tprint(\"YES\")\nelse:\n\tprint(\"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 = 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": "# 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 2 and n % 2 == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n# -------------------------------------------------------Main Code------------------------------------------------------\nsolve()"}, {"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": "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": "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": "w = int(input())\nif w % 2 == 0 and w != 2:\n print('YES')\nelse:\n print('NO')"}, {"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": "\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": "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": "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": "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": "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": "melon_weight = input()\nif melon_weight >= 4 and melon_weight % 2 == 0:\n\tprint \"YES\"\nelse: print \"NO\""}, {"source_code": "num = int(input())\nif num % 2 == 0 and num > 2:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"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": "a = input()\nif a/2 == a/2.0 and a > 2:\n print \"YES\"\nelse:\n print \"NO\"\n#1\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": "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": "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": "w=int(input(\"\"))\nif(w%2==0 and w!=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=input()\nif a%2==1 or a==2:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n\t\n\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": "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": "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(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": "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\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": "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 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": "# 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 and w % 2 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"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": "\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": "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": "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": "r=int(raw_input())\nif(r%2==0 and r!=2):\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\t"}, {"source_code": "number1 = int(input(''))\n\nif(((number1%2)!=0) or (number1<3)):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"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": "a = int(input())\nif a % 2 == 0 and a != 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": "input = int(raw_input())\n\nif input%2 == 0 and input > 2:\n print 'YES'\nelse:\n print 'NO'"}, {"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": "#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\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": "n = int(raw_input())\n \nif n <= 2:\n print \"NO\"\nelif n % 2 == 0:\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": "input_arg=int(input())\nresult= input_arg%2\nif input_arg>2 and result==0:\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": "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": "\nw = int(input())\n\n\n\nif w % 2==0 and w != 2:\n print(\"YES\")\n\n\nelse:\n print(\"NO\")"}, {"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": "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": "a = int(input())\nif a==2 or a%2==1 :\n print ('NO')\nelse: print('YES')\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": "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))"}], "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=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"} {"nl": {"description": "This task will exclusively concentrate only on the arrays where all elements equal 1 and/or 2.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.For example, any array is n-periodic, where n is the array length. Array [2,\u20091,\u20092,\u20091,\u20092,\u20091] is at the same time 2-periodic and 6-periodic and array [1,\u20092,\u20091,\u20091,\u20092,\u20091,\u20091,\u20092,\u20091] is at the same time 3-periodic and 9-periodic.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.", "input_spec": "The first line of the input contains a pair of integers n, k (1\u2009\u2264\u2009k\u2009\u2264\u2009n\u2009\u2264\u2009100), 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,\u2009a2,\u2009...,\u2009an (1\u2009\u2264\u2009ai\u2009\u2264\u20092), ai is the i-th element of the array.", "output_spec": "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.", "sample_inputs": ["6 2\n2 1 2 2 2 1", "8 4\n1 1 2 1 1 1 2 1", "9 3\n2 1 1 1 2 1 1 1 2"], "sample_outputs": ["1", "0", "3"], "notes": "NoteIn the first sample it is enough to change the fourth element from 2 to 1, then the array changes to [2,\u20091,\u20092,\u20091,\u20092,\u20091].In the second sample, the given array already is 4-periodic.In the third sample it is enough to replace each occurrence of number two by number one. In this case the array will look as [1,\u20091,\u20091,\u20091,\u20091,\u20091,\u20091,\u20091,\u20091] \u2014 this array is simultaneously 1-, 3- and 9-periodic."}, "positive_code": [{"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": "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=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": "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": "[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": "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 = 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": "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": "#!/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": "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": "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": "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": "\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": "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": "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, 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": "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": "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": "# 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": "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 = [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(\" \"))\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": "[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": "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": "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": "# 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": "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": "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": "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": "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())\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"}, {"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": "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": "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": "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": "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": "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 = 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": "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": "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": "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": "# -*- 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 = 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": "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": "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": "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": "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\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": "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": "[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": "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": "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 = [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,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": "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": "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": "\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())\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,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": "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": "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": "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": "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": "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": "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": "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": "## 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=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 = 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": "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": "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": "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 = 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())\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": "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().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": "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": "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,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": "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": "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().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": "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": "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": "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": "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 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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"}], "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(j0):\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(j0):\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(j0):\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(j0):\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(j0):\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[1]):\n print ans\n sys.exit()\n \n while (h=y[1]):\n print count\n sys.exit()\n while (hy[1]):\n print count\n sys.exit()\n while (h=y[1]):\n print count\n sys.exit()\n while (hy[1]):\n print count\n sys.exit()\n while (h 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"} {"nl": {"description": "Anadi has a set of dominoes. Every domino has two parts, and each part contains some dots. For every $$$a$$$ and $$$b$$$ such that $$$1 \\leq a \\leq b \\leq 6$$$, there is exactly one domino with $$$a$$$ dots on one half and $$$b$$$ dots on the other half. The set contains exactly $$$21$$$ dominoes. Here is an exact illustration of his set: Also, Anadi has an undirected graph without self-loops and multiple edges. He wants to choose some dominoes and place them on the edges of this graph. He can use at most one domino of each type. Each edge can fit at most one domino. It's not necessary to place a domino on each edge of the graph.When placing a domino on an edge, he also chooses its direction. In other words, one half of any placed domino must be directed toward one of the endpoints of the edge and the other half must be directed toward the other endpoint. There's a catch: if there are multiple halves of dominoes directed toward the same vertex, each of these halves must contain the same number of dots.How many dominoes at most can Anadi place on the edges of his graph?", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \\leq n \\leq 7$$$, $$$0 \\leq m \\leq \\frac{n\\cdot(n-1)}{2}$$$) \u2014 the number of vertices and the number of edges in the graph. The next $$$m$$$ lines contain two integers each. Integers in the $$$i$$$-th line are $$$a_i$$$ and $$$b_i$$$ ($$$1 \\leq a, b \\leq n$$$, $$$a \\neq b$$$) and denote that there is an edge which connects vertices $$$a_i$$$ and $$$b_i$$$. The graph might be disconnected. It's however guaranteed that the graph doesn't contain any self-loops, and that there is at most one edge between any pair of vertices.", "output_spec": "Output one integer which denotes the maximum number of dominoes which Anadi can place on the edges of the graph.", "sample_inputs": ["4 4\n1 2\n2 3\n3 4\n4 1", "7 0", "3 1\n1 3", "7 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"], "sample_outputs": ["4", "0", "1", "16"], "notes": "NoteHere is an illustration of Anadi's graph from the first sample test: And here is one of the ways to place a domino on each of its edges: Note that each vertex is faced by the halves of dominoes with the same number of dots. For instance, all halves directed toward vertex $$$1$$$ have three dots."}, "positive_code": [{"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": "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)x:\n\t mi = x\n\tprint(m - mi)"}, {"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 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": "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 = 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 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": "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) 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: 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": "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": "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": "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=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 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": "'''\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 = 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": "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": "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": "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": "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": "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": "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 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": "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": "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"}], "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 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"} {"nl": {"description": "Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose decimal representation (without leading zeroes) contain only the lucky digits x and y. For example, if x\u2009=\u20094, and y\u2009=\u20097, then numbers 47, 744, 4 are lucky.Let's call a positive integer a undoubtedly lucky, if there are such digits x and y (0\u2009\u2264\u2009x,\u2009y\u2009\u2264\u20099), that the decimal representation of number a (without leading zeroes) contains only digits x and y.Polycarpus has integer n. He wants to know how many positive integers that do not exceed n, are undoubtedly lucky. Help him, count this number.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009109) \u2014 Polycarpus's number.", "output_spec": "Print a single integer that says, how many positive integers that do not exceed n are undoubtedly lucky.", "sample_inputs": ["10", "123"], "sample_outputs": ["10", "113"], "notes": "NoteIn the first test sample all numbers that do not exceed 10 are undoubtedly lucky.In the second sample numbers 102, 103, 104, 105, 106, 107, 108, 109, 120, 123 are not undoubtedly lucky."}, "positive_code": [{"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": "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": "#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 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": "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": "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": "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": "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": "#!/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": "# ~*~ 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 00:\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 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 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< 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": "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 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": "def p(k):\n\tif 00 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": "# -*- 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()"}, {"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": "def p(k):\n\tif 00 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 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": "def p(k):\n\tif 0 n:\n print i-1\n break\n"}, {"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"}, {"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": "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": "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 00):\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)"}], "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< 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"} {"nl": {"description": "Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale:\"Once upon a time, there lived an emperor. He was very rich and had much grain. One day he ordered to build a huge barn to put there all his grain. Best builders were building that barn for three days and three nights. But they overlooked and there remained a little hole in the barn, from which every day sparrows came through. Here flew a sparrow, took a grain and flew away...\"More formally, the following takes place in the fairy tale. At the beginning of the first day the barn with the capacity of n grains was full. Then, every day (starting with the first day) the following happens: m grains are brought to the barn. If m grains doesn't fit to the barn, the barn becomes full and the grains that doesn't fit are brought back (in this problem we can assume that the grains that doesn't fit to the barn are not taken into account). Sparrows come and eat grain. In the i-th day i sparrows come, that is on the first day one sparrow come, on the second day two sparrows come and so on. Every sparrow eats one grain. If the barn is empty, a sparrow eats nothing. Anton is tired of listening how Danik describes every sparrow that eats grain from the barn. Anton doesn't know when the fairy tale ends, so he asked you to determine, by the end of which day the barn will become empty for the first time. Help Anton and write a program that will determine the number of that day!", "input_spec": "The only line of the input contains two integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091018)\u00a0\u2014 the capacity of the barn and the number of grains that are brought every day.", "output_spec": "Output one integer\u00a0\u2014 the number of the day when the barn will become empty for the first time. Days are numbered starting with one.", "sample_inputs": ["5 2", "8 1"], "sample_outputs": ["4", "5"], "notes": "NoteIn the first sample the capacity of the barn is five grains and two grains are brought every day. The following happens: At the beginning of the first day grain is brought to the barn. It's full, so nothing happens. At the end of the first day one sparrow comes and eats one grain, so 5\u2009-\u20091\u2009=\u20094 grains remain. At the beginning of the second day two grains are brought. The barn becomes full and one grain doesn't fit to it. At the end of the second day two sparrows come. 5\u2009-\u20092\u2009=\u20093 grains remain. At the beginning of the third day two grains are brought. The barn becomes full again. At the end of the third day three sparrows come and eat grain. 5\u2009-\u20093\u2009=\u20092 grains remain. At the beginning of the fourth day grain is brought again. 2\u2009+\u20092\u2009=\u20094 grains remain. At the end of the fourth day four sparrows come and eat grain. 4\u2009-\u20094\u2009=\u20090 grains remain. The barn is empty. So the answer is 4, because by the end of the fourth day the barn becomes empty."}, "positive_code": [{"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 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": "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 = [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": "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": "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+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": "# 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": "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 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"}, {"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+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": "n,m=map(int,input().split())\nif n=2*n:\n r=mid\n else:\n l=mid+1\n print(m+l)\n"}, {"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": "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 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": "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": "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": "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": "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": "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": "#!/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": "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": "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": "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": "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 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": "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": "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": "def get(n):\n return (1+n)*n/2\nn,m=map(int,raw_input().split())\n\nl,r=m+1,n\nwhile l=n):\n r=md\n else:\n l=md+1\nif (n<=m):\n print n\nelse:\n print l\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 decimal.getcontext().prec=100;\n print(((decimal.Decimal(1+8*(n-m)).sqrt()-1)/2+m).to_integral_exact())"}, {"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 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": "\"\"\" 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": "n,m=map(int,input().split())\nif n=2*n:\n r=mid\n else:\n l=mid+1\n print(m+l)\n"}, {"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"}, {"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": "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": "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 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": "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": "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": "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": "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": "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": "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 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 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": "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": "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": "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": "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": "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 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": "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 = 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": "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()]\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": "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": "\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": "# 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] = 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": "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": "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": "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\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": "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": "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": "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": "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": "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 = [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 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": "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": "\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": "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 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": "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 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": "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": "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": "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 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": "def bs(v):\n\tl, h = 0, int(3e9)\n\twhile l=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 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": "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": "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": "#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": "#!/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": "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:\n finished=True\n elif triangle(newNum)=target and triangle(newNum-1)\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": "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 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": "n, m = map(int, raw_input().split(\" \"))\nif n<=m:\n print n\nelse:\n l = m\n r = int(1e19)\n while l= n:\n r = mid\n else:\n l = mid+1\n print l\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-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 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": "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": "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": "\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": "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)=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=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:\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= 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 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= 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 =n: print(n)\nelse:\n amount=n-m\n ans=m\n l=0\n r=min(2000000000,n)\n while l+1=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= 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= (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 nm+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= (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=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=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 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= 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)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 = raw_input().split()\n\nif a == b: print a\nelse: print '1'"}, {"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\""}, {"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": "'''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": "import fractions\n\na, b = map(int, raw_input().split())\nif a == b:\n print a\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": "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": "a, b = map(int,raw_input().split())\nprint a if (a==b) else 1"}, {"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": "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": "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)"}, {"source_code": "a,b=map(int,raw_input().split())\nprint a if a==b else 1 if ab :\n return gcd(a%b,b);\n elif a= 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 = map(int,input().split())\n\nif a == b :\n print(a)\n\nelse:\n print(1)\n"}, {"source_code": "x, y = raw_input().split()\nif x == y:\n\tprint x\nelse:\n\tprint 1"}, {"source_code": "a,b = map(int,input().split())\n\nif abs(a-b)>0:\n print(1)\nelse:\n print(a)\n "}, {"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": "[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": "a, b = map(int, raw_input().split())\nprint a == b and a or 1\n"}, {"source_code": "a, b = list(map(int, input().split()))\nif a == b: print(a)\nelse: 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": "a, b=map(int, input().rstrip().split())\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)\n\nelse:\n print(1)\n"}, {"source_code": "a=raw_input().split()\nif a[0]==a[1]:\n\tprint a[0]\nelse:\n\tprint 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": "# -*- coding:utf-8 -*-\nimport fractions\na,b=map(int,raw_input().split(' '))\nprint 1 if a!=b else b"}, {"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": "num1, num2 = raw_input().split()\nif num1 == num2:\n print num1\nelse:\n print 1"}, {"source_code": "a, b = raw_input().split()\n\nif a == b: print a\nelse: 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": "a,b=map(int,raw_input().split())\nprint [1,a][a==b]\n"}, {"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": "m,n = map(int, raw_input().split())\nif m==n:\n print m\nelse:\n print 1"}, {"source_code": "a, b = [i for i in input().split()]\n\nif a==b:\n print(a)\nelse:\n print(1)"}, {"source_code": "# -*- coding:utf-8 -*-\nimport fractions\na,b=map(int,raw_input().split(' '))\nprint 1 if a!=b else b"}, {"source_code": "a, b = map(int, raw_input().split())\n\nif a != b: print 1\nelse: print a\n"}, {"source_code": "\na,b=input().split()\nif a==b:\n print(a)\nelse:\n print(1);"}, {"source_code": "a, b = map(int, raw_input().split())\nif a != b:\n\tprint 1\nelse:\n\tprint a\n\t#rs"}, {"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 = map(int, raw_input().split())\nif a == b: print a\nelse: print 1"}, {"source_code": "a, b = input().split()\n\nif a == b:\n print(a)\nelse:\n print(1)\n"}, {"source_code": "a, b = input().split()\nprint(1 if a != b else a)"}, {"source_code": "a, b = map(int, raw_input().split())\n\nif a != b: print 1\nelse: print a\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": "a, b = map(int, input().split())\n\nif a == b:\n print(\"{}\".format(a))\nelse:\n print(\"{}\".format(1))\n"}, {"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": "from fractions import gcd\na,b = map(int,raw_input().split(' '))\nif a == b:\n print a\nelse:\n print 1"}, {"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": "hello = raw_input().split()\nfirst = int(hello[0])\nsecond = int(hello[1])\nif first == second:\n\tprint first\nelse:\n\tprint 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": "a,b=map(int,input().split())\nif a==b:\n print(a)\nelse:\n print(1)"}, {"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": "# 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": "a, b = list(map(str, input().split()))\n\nif a == b:\n print(a)\nelse:\n print(1)"}, {"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": "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": "a, b = list(map(str, 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=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=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 = [int(x) for x in 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": "a, b = map(int, raw_input().split())\nif a != b:\n\tprint 1\nelse:\n\tprint a\n\t#rs"}, {"source_code": "\na,b=[int(i) for i in input().split()]\nif a==b:print(a)\nelse:print(1)\n"}, {"source_code": "x, y = map(int,input().split(' ')); \nif (x==y):print(x) \nelse: 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 ab: 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(a1:\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"} {"nl": {"description": "Not long ago Billy came across such a problem, where there were given three natural numbers A, B and C from the range [1,\u2009N], and it was asked to check whether the equation AB\u2009=\u2009C is correct. Recently Billy studied the concept of a digital root of a number. We should remind you that a digital root d(x) of the number x is the sum s(x) of all the digits of this number, if s(x)\u2009\u2264\u20099, otherwise it is d(s(x)). For example, a digital root of the number 6543 is calculated as follows: d(6543)\u2009=\u2009d(6\u2009+\u20095\u2009+\u20094\u2009+\u20093)\u2009=\u2009d(18)\u2009=\u20099. Billy has counted that the digital root of a product of numbers is equal to the digital root of the product of the factors' digital roots, i.e. d(xy)\u2009=\u2009d(d(x)d(y)). And the following solution to the problem came to his mind: to calculate the digital roots and check if this condition is met. However, Billy has doubts that this condition is sufficient. That's why he asks you to find out the amount of test examples for the given problem such that the algorithm proposed by Billy makes mistakes.", "input_spec": "The first line contains the only number N (1\u2009\u2264\u2009N\u2009\u2264\u2009106).", "output_spec": "Output one number \u2014 the amount of required A, B and C from the range [1,\u2009N].", "sample_inputs": ["4", "5"], "sample_outputs": ["2", "6"], "notes": "NoteFor the first sample the required triples are (3,\u20094,\u20093) and (4,\u20093,\u20093)."}, "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, 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"}, {"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"} {"nl": {"description": "Your task is to calculate the number of arrays such that: each array contains $$$n$$$ elements; each element is an integer from $$$1$$$ to $$$m$$$; for each array, there is exactly one pair of equal elements; for each array $$$a$$$, there exists an index $$$i$$$ such that the array is strictly ascending before the $$$i$$$-th element and strictly descending after it (formally, it means that $$$a_j < a_{j + 1}$$$, if $$$j < i$$$, and $$$a_j > a_{j + 1}$$$, if $$$j \\ge i$$$). ", "input_spec": "The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le m \\le 2 \\cdot 10^5$$$).", "output_spec": "Print one integer \u2014 the number of arrays that meet all of the aforementioned conditions, taken modulo $$$998244353$$$.", "sample_inputs": ["3 4", "3 5", "42 1337", "100000 200000"], "sample_outputs": ["6", "10", "806066790", "707899035"], "notes": "NoteThe arrays in the first example are: $$$[1, 2, 1]$$$; $$$[1, 3, 1]$$$; $$$[1, 4, 1]$$$; $$$[2, 3, 2]$$$; $$$[2, 4, 2]$$$; $$$[3, 4, 3]$$$. "}, "positive_code": [{"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": "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": "\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": "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": "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": "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": "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": "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": "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": "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": "# 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": "#!/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": "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": "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": "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": "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": "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": "#!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": "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 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": "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": "#!/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 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)"}, {"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": "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 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 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": "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": "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": "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": "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": "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": "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": "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\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= 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": "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": "\"\"\"\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": "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": "# -*- 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": "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": "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": "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": "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": "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": "\"\"\"\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() 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": "\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": "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": "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": "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": "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": "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": "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": "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= 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": "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": "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": "# ------------------- 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": "# 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": "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": "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": "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": "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": "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": "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": "# -*- 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": "\"\"\"\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() 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": "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": "# 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": "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": "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": "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": "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": "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": "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": "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()"}], "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"} {"nl": {"description": "Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will follow knockout rules from the very first game. That means, that if someone loses a game he leaves the tournament immediately.Organizers are still arranging tournament grid (i.e. the order games will happen and who is going to play with whom) but they have already fixed one rule: two players can play against each other only if the number of games one of them has already played differs by no more than one from the number of games the other one has already played. Of course, both players had to win all their games in order to continue participating in the tournament.Tournament hasn't started yet so the audience is a bit bored. Ostap decided to find out what is the maximum number of games the winner of the tournament can take part in (assuming the rule above is used). However, it is unlikely he can deal with this problem without your help.", "input_spec": "The only line of the input contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20091018)\u00a0\u2014 the number of players to participate in the tournament.", "output_spec": "Print the maximum number of games in which the winner of the tournament can take part.", "sample_inputs": ["2", "3", "4", "10"], "sample_outputs": ["1", "2", "2", "4"], "notes": "NoteIn all samples we consider that player number 1 is the winner.In the first sample, there would be only one game so the answer is 1.In the second sample, player 1 can consequently beat players 2 and 3. In the third sample, player 1 can't play with each other player as after he plays with players 2 and 3 he can't play against player 4, as he has 0 games played, while player 1 already played 2. Thus, the answer is 2 and to achieve we make pairs (1,\u20092) and (3,\u20094) and then clash the winners."}, "positive_code": [{"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": "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())\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(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"}, {"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": "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": "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())\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": "#!/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,1\nc=0\nwhile a<=n:\n a,b=a+b,a\n c+=1\nprint(c)"}, {"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": "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": "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": "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]<=an:\n break\n i+=1\n x=y\n y=s\n print(i)\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": "\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": "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": "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())\na,b = 2,3\nc = 0\nwhile n >= a:\n a,b = b,a+b\n c+=1\nprint(c)"}, {"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": "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())\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())\nb = 2\na = 1\nd = 0\nwhile b <= n:\n a, b = b, a + b\n d += 1\nprint(d)"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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())\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": "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": "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": "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": "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": "# 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": "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())\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": "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": "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": "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(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(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=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": "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": "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": "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 = 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 = 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": "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(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())\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": "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())\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": "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": "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 = 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())\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())\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": "#!/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": "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, 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())\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": "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())\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 = 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": "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())\na,b=2,1\nans=0\nwhile a<=n:\n a,b=a+b,a\n ans+=1\nprint(ans)"}, {"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(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 = 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": "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())\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())\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": "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())\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": "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": "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": "\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 = 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": "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())\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": "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(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": "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": "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": "__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, a, b, v = int(input()), 1, 1, -1\nwhile b <= n:\n a, b, v = b, a + b, v + 1\nprint(v)"}, {"source_code": "def go():\n\tn = input()\n\tgames=0\n\tp1=1\n\tp2=2\n\twhile gamesn:\n\t\t\treturn games\n\t\t\n\t\n\t\n\t\nprint go()\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)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 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)= 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 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\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 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"} {"nl": {"description": "Throughout Igor K.'s life he has had many situations worthy of attention. We remember the story with the virus, the story of his mathematical career and of course, his famous programming achievements. However, one does not always adopt new hobbies, one can quit something as well.This time Igor K. got disappointed in one of his hobbies: editing and voicing videos. Moreover, he got disappointed in it so much, that he decided to destroy his secret archive for good. Igor K. use Pindows XR operation system which represents files and folders by small icons. At that, m icons can fit in a horizontal row in any window.Igor K.'s computer contains n folders in the D: disk's root catalog. The folders are numbered from 1 to n in the order from the left to the right and from top to bottom (see the images). At that the folders with secret videos have numbers from a to b inclusive. Igor K. wants to delete them forever, at that making as few frame selections as possible, and then pressing Shift+Delete exactly once. What is the minimum number of times Igor K. will have to select the folder in order to select folders from a to b and only them? Let us note that if some selected folder is selected repeatedly, then it is deselected. Each selection possesses the shape of some rectangle with sides parallel to the screen's borders.", "input_spec": "The only line contains four integers n, m, a, b (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009109, 1\u2009\u2264\u2009a\u2009\u2264\u2009b\u2009\u2264\u2009n). They are the number of folders in Igor K.'s computer, the width of a window and the numbers of the first and the last folders that need to be deleted.", "output_spec": "Print a single number: the least possible number of times Igor K. will have to select the folders using frames to select only the folders with numbers from a to b.", "sample_inputs": ["11 4 3 9", "20 5 2 20"], "sample_outputs": ["3", "2"], "notes": "NoteThe images below illustrate statement tests.The first test:In this test we can select folders 3 and 4 with out first selection, folders 5, 6, 7, 8 with our second selection and folder 9 with our third, last selection.The second test:In this test we can first select all folders in the first row (2, 3, 4, 5), then \u2014 all other ones."}, "positive_code": [{"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": "#!/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": "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())\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(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": "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= 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 ib0 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": "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": "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": "#!/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": "\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= 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"}, {"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": "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"}, {"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": "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\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": "(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 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": "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": "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": "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": "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": "#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": "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": "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))"}], "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 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 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"} {"nl": {"description": "This version of the problem differs from the next one only in the constraint on $$$n$$$.Note that the memory limit in this problem is lower than in others.You have a vertical strip with $$$n$$$ cells, numbered consecutively from $$$1$$$ to $$$n$$$ from top to bottom.You also have a token that is initially placed in cell $$$n$$$. You will move the token up until it arrives at cell $$$1$$$.Let the token be in cell $$$x > 1$$$ at some moment. One shift of the token can have either of the following kinds: Subtraction: you choose an integer $$$y$$$ between $$$1$$$ and $$$x-1$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$x - y$$$. Floored division: you choose an integer $$$z$$$ between $$$2$$$ and $$$x$$$, inclusive, and move the token from cell $$$x$$$ to cell $$$\\lfloor \\frac{x}{z} \\rfloor$$$ ($$$x$$$ divided by $$$z$$$ rounded down). Find the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$ using one or more shifts, and print it modulo $$$m$$$. Note that if there are several ways to move the token from one cell to another in one shift, all these ways are considered distinct (check example explanation for a better understanding).", "input_spec": "The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\le n \\le 2 \\cdot 10^5$$$; $$$10^8 < m < 10^9$$$; $$$m$$$ is a prime number)\u00a0\u2014 the length of the strip and the modulo.", "output_spec": "Print the number of ways to move the token from cell $$$n$$$ to cell $$$1$$$, modulo $$$m$$$.", "sample_inputs": ["3 998244353", "5 998244353", "42 998244353"], "sample_outputs": ["5", "25", "793019428"], "notes": "NoteIn the first test, there are three ways to move the token from cell $$$3$$$ to cell $$$1$$$ in one shift: using subtraction of $$$y = 2$$$, or using division by $$$z = 2$$$ or $$$z = 3$$$.There are also two ways to move the token from cell $$$3$$$ to cell $$$1$$$ via cell $$$2$$$: first subtract $$$y = 1$$$, and then either subtract $$$y = 1$$$ again or divide by $$$z = 2$$$.Therefore, there are five ways in total."}, "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 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################################ ###########################################\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###########################################################################################\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\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": "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"}, {"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] 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): #jq2:\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 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 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################################ ###########################################\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###########################################################################################\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): #ja1 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"} {"nl": {"description": "The Fair Nut lives in $$$n$$$ story house. $$$a_i$$$ people live on the $$$i$$$-th floor of the house. Every person uses elevator twice a day: to get from the floor where he/she lives to the ground (first) floor and to get from the first floor to the floor where he/she lives, when he/she comes back home in the evening. It was decided that elevator, when it is not used, will stay on the $$$x$$$-th floor, but $$$x$$$ hasn't been chosen yet. When a person needs to get from floor $$$a$$$ to floor $$$b$$$, elevator follows the simple algorithm: Moves from the $$$x$$$-th floor (initially it stays on the $$$x$$$-th floor) to the $$$a$$$-th and takes the passenger. Moves from the $$$a$$$-th floor to the $$$b$$$-th floor and lets out the passenger (if $$$a$$$ equals $$$b$$$, elevator just opens and closes the doors, but still comes to the floor from the $$$x$$$-th floor). Moves from the $$$b$$$-th floor back to the $$$x$$$-th. The elevator never transposes more than one person and always goes back to the floor $$$x$$$ before transposing a next passenger. The elevator spends one unit of electricity to move between neighboring floors. So moving from the $$$a$$$-th floor to the $$$b$$$-th floor requires $$$|a - b|$$$ units of electricity.Your task is to help Nut to find the minimum number of electricity units, that it would be enough for one day, by choosing an optimal the $$$x$$$-th floor. Don't forget than elevator initially stays on the $$$x$$$-th floor. ", "input_spec": "The first line contains one integer $$$n$$$ ($$$1 \\leq n \\leq 100$$$)\u00a0\u2014 the number of floors. The second line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$0 \\leq a_i \\leq 100$$$)\u00a0\u2014 the number of people on each floor.", "output_spec": "In a single line, print the answer to the problem\u00a0\u2014 the minimum number of electricity units.", "sample_inputs": ["3\n0 2 1", "2\n1 1"], "sample_outputs": ["16", "4"], "notes": "NoteIn the first example, the answer can be achieved by choosing the second floor as the $$$x$$$-th floor. Each person from the second floor (there are two of them) would spend $$$4$$$ units of electricity per day ($$$2$$$ to get down and $$$2$$$ to get up), and one person from the third would spend $$$8$$$ units of electricity per day ($$$4$$$ to get down and $$$4$$$ to get up). $$$4 \\cdot 2 + 8 \\cdot 1 = 16$$$.In the second example, the answer can be achieved by choosing the first floor as the $$$x$$$-th floor."}, "positive_code": [{"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": "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())\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\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": "\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": "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())\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": "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": "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": "#!/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())\nmin = 0\nres = input().split()\nfor i in range(n):\n min += i*int(res[i])\nprint(4*min)"}, {"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": "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": "\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 ====================================================================================\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\"\"\""}, {"source_code": "raw_input()\nprint sum(list(map(lambda (i, x): 4*i*x, list(enumerate(map(int, raw_input().split(' ')))))))"}, {"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": "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())\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": "# 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 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": "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": "\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": "'''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": "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())\nx = list(map(int, input().split(\" \")))\nsum=0\nfor i in range(n):\n sum+=i*4*x[i]\nprint(sum)"}, {"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": "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": "#_________________ 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": "''' 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": "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 = [int(w) for w in input().split()]\n\nprint(4*sum(a[i]*i for i in range(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())\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": "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": "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": "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())\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 = 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": "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())\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": "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": "\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": "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()))\nc=0\nfor i in range(n):\n c+=i*l[i]*4\nprint(c)\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": "raw_input()\nprint sum(list(map(lambda (i, x): 4*i*x, list(enumerate(map(int, raw_input().split(' ')))))))"}, {"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": "raw_input()\nprint sum(list(map(lambda (i, x): 4*i*x, list(enumerate(map(int, raw_input().split(' ')))))))"}, {"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 sum:\n best = sum\n\nprint(best)\n\n\n"}, {"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())\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": "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 = 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": "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": "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": "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": "#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": "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())\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": "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": "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": "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": "__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": "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 nowx:\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": "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": "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": "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": "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": "input()\n\nprint(4 * sum(i*a for i,a in enumerate(map(int, input().split()))))"}, {"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": "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": "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": "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, 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": "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": "\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 = 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": "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": "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": "\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": "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": "#!/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": "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": "\"\"\"\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": "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": "\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"}], "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 tanss):\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"} {"nl": {"description": "There are $$$n + 2$$$ towns located on a coordinate line, numbered from $$$0$$$ to $$$n + 1$$$. The $$$i$$$-th town is located at the point $$$i$$$.You build a radio tower in each of the towns $$$1, 2, \\dots, n$$$ with probability $$$\\frac{1}{2}$$$ (these events are independent). After that, you want to set the signal power on each tower to some integer from $$$1$$$ to $$$n$$$ (signal powers are not necessarily the same, but also not necessarily different). The signal from a tower located in a town $$$i$$$ with signal power $$$p$$$ reaches every city $$$c$$$ such that $$$|c - i| < p$$$.After building the towers, you want to choose signal powers in such a way that: towns $$$0$$$ and $$$n + 1$$$ don't get any signal from the radio towers; towns $$$1, 2, \\dots, n$$$ get signal from exactly one radio tower each. For example, if $$$n = 5$$$, and you have built the towers in towns $$$2$$$, $$$4$$$ and $$$5$$$, you may set the signal power of the tower in town $$$2$$$ to $$$2$$$, and the signal power of the towers in towns $$$4$$$ and $$$5$$$ to $$$1$$$. That way, towns $$$0$$$ and $$$n + 1$$$ don't get the signal from any tower, towns $$$1$$$, $$$2$$$ and $$$3$$$ get the signal from the tower in town $$$2$$$, town $$$4$$$ gets the signal from the tower in town $$$4$$$, and town $$$5$$$ gets the signal from the tower in town $$$5$$$.Calculate the probability that, after building the towers, you will have a way to set signal powers to meet all constraints.", "input_spec": "The first (and only) line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 2 \\cdot 10^5$$$).", "output_spec": "Print one integer \u2014 the probability that there will be a way to set signal powers so that all constraints are met, taken modulo $$$998244353$$$. Formally, the probability can be expressed as an irreducible fraction $$$\\frac{x}{y}$$$. You have to print the value of $$$x \\cdot y^{-1} \\bmod 998244353$$$, where $$$y^{-1}$$$ is an integer such that $$$y \\cdot y^{-1} \\bmod 998244353 = 1$$$.", "sample_inputs": ["2", "3", "5", "200000"], "sample_outputs": ["748683265", "748683265", "842268673", "202370013"], "notes": "NoteThe real answer for the first example is $$$\\frac{1}{4}$$$: with probability $$$\\frac{1}{4}$$$, the towers are built in both towns $$$1$$$ and $$$2$$$, so we can set their signal powers to $$$1$$$. The real answer for the second example is $$$\\frac{1}{4}$$$: with probability $$$\\frac{1}{8}$$$, the towers are built in towns $$$1$$$, $$$2$$$ and $$$3$$$, so we can set their signal powers to $$$1$$$; with probability $$$\\frac{1}{8}$$$, only one tower in town $$$2$$$ is built, and we can set its signal power to $$$2$$$. The real answer for the third example is $$$\\frac{5}{32}$$$. Note that even though the previous explanations used equal signal powers for all towers, it is not necessarily so. For example, if $$$n = 5$$$ and the towers are built in towns $$$2$$$, $$$4$$$ and $$$5$$$, you may set the signal power of the tower in town $$$2$$$ to $$$2$$$, and the signal power of the towers in towns $$$4$$$ and $$$5$$$ to $$$1$$$."}, "positive_code": [{"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": "from sys import stdin\nmod = 998244353\na = [1,1,1]\nn = int(stdin.readline())\nwhile len(a)=mod:\n a[-1]-=mod\nden = pow(2,mod-2,mod)\nden = pow(den,n,mod)\nprint (a[n]*den)%mod"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "\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=1,1\nfor i in range(n-1):a,b=b,a+b\nprint(a*pow(1< 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": "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": "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": "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"}, {"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": "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())\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": "##################################### \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": "\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=mod:\n a[-1]-=mod\nden = pow(2,mod-2,mod)\nden = pow(den,n,mod)\nprint (a[n]*den)%mod"}, {"source_code": "from sys import stdin\nmod = 998244353\na = [1,1,1]\nn = int(stdin.readline())\nwhile len(a)=mod:\n a[-1]-=mod\nden = pow(2,mod-2,mod)\nden = pow(den,n,mod)\nprint (a[n]*den)%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": "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": "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": "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": "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": "# 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\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": "#!/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": "\"\"\"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\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())\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\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": "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": "'''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": "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": "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": "##################################### \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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "\nM = 998244353 \nn=int(input())\na,b=1,1\nfor i in range(n-1):a,b=b,a+b\nprint(a*pow(1<> 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": "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": "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": "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": "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": "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": "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<> 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": "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": "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": "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 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": "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())\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": "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": "\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": "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": "# 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 \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": "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": "\nM = 998244353 \nn=int(input())\na,b=1,1\nfor i in range(n-1):a,b=b,a+b\nprint(a*pow(1< 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": "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": "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": "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)"}, {"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": "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": "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": "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": "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": "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())\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": "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"}], "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"} {"nl": {"description": "Let's consider one interesting word game. In this game you should transform one word into another through special operations. Let's say we have word w, let's split this word into two non-empty parts x and y so, that w\u2009=\u2009xy. A split operation is transforming word w\u2009=\u2009xy into word u\u2009=\u2009yx. For example, a split operation can transform word \"wordcut\" into word \"cutword\".You are given two words start and end. Count in how many ways we can transform word start into word end, if we apply exactly k split operations consecutively to word start. Two ways are considered different if the sequences of applied operations differ. Two operation sequences are different if exists such number i (1\u2009\u2264\u2009i\u2009\u2264\u2009k), that in the i-th operation of the first sequence the word splits into parts x and y, in the i-th operation of the second sequence the word splits into parts a and b, and additionally x\u2009\u2260\u2009a holds.", "input_spec": "The first line contains a non-empty word start, the second line contains a non-empty word end. The words consist of lowercase Latin letters. The number of letters in word start equals the number of letters in word end and is at least 2 and doesn't exceed 1000 letters. The third line contains integer k (0\u2009\u2264\u2009k\u2009\u2264\u2009105) \u2014 the required number of operations.", "output_spec": "Print a single number \u2014 the answer to the problem. As this number can be rather large, print it modulo 1000000007 (109\u2009+\u20097).", "sample_inputs": ["ab\nab\n2", "ababab\nababab\n1", "ab\nba\n2"], "sample_outputs": ["1", "2", "0"], "notes": "NoteThe sought way in the first sample is:ab \u2009\u2192\u2009 a|b \u2009\u2192\u2009 ba \u2009\u2192\u2009 b|a \u2009\u2192\u2009 abIn the second sample the two sought ways are: ababab \u2009\u2192\u2009 abab|ab \u2009\u2192\u2009 ababab ababab \u2009\u2192\u2009 ab|abab \u2009\u2192\u2009 ababab"}, "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": "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": "\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"} {"nl": {"description": "Little Petya loves playing with squares. Mum bought him a square 2n\u2009\u00d7\u20092n in size. Petya marked a cell inside the square and now he is solving the following task.The task is to draw a broken line that would go along the grid lines and that would cut the square into two equal parts. The cutting line should not have any common points with the marked cell and the resulting two parts should be equal up to rotation.Petya wants to determine whether it is possible to cut the square in the required manner given the sizes of the square side and the coordinates of the marked cell. Help him.", "input_spec": "The first line contains three space-separated integers 2n, x and y (2\u2009\u2264\u20092n\u2009\u2264\u2009100,\u20091\u2009\u2264\u2009x,\u2009y\u2009\u2264\u20092n), representing the length of a square's side and the coordinates of the marked cell. It is guaranteed that 2n is even. The coordinates of the marked cell are represented by a pair of numbers x y, where x represents the number of the row and y represents the number of the column. The rows and columns are numbered by consecutive integers from 1 to 2n. The rows are numbered from top to bottom and the columns are numbered from the left to the right.", "output_spec": "If the square is possible to cut, print \"YES\", otherwise print \"NO\" (without the quotes).", "sample_inputs": ["4 1 1", "2 2 2"], "sample_outputs": ["YES", "NO"], "notes": "NoteA sample test from the statement and one of the possible ways of cutting the square are shown in the picture: "}, "positive_code": [{"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())\nf = lambda x : x in (n / 2, n / 2 + 1)\nprint 'NO' if f(x) and f(y) else 'YES'"}, {"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(\"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\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())\nprint ['YES', 'NO'][{x, y} <= {n / 2, n / 2 + 1}]"}, {"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": "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\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": "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": "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())\nprint(['YES',\"NO\"][(x==n/2 or x==n/2+1) and (y==n/2 or y==n/2+1)])"}, {"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=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": "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=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": "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": "#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,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": "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, raw_input().split())\nn/=2\ns=[n,n+1]\nprint \"YNEOS\"[x in s and y in s::2]"}, {"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": "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())\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": "(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": "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": "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": "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": "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())\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": "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": "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\""}, {"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=[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": "#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": "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": "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": "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": "_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": "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": "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\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": "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())\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": "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": "_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": "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": "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": "\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": "_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": "#-*- 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": "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": "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": "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=[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, 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": "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": "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=(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, 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().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": "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": "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\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": "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, raw_input().split())\nprint \"NO\" if n/2 <= x <= n/2+1 and n/2 <= y <= n/2+1 else \"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": "#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,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=[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, 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())\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": "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": "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\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": "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": "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": "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 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())\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().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())\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": "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": "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": "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": "#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, 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": "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, input().split())\nn //= 2\nprint('NO' if n <= x <= n + 1 and n <= y <= n + 1 else 'YES')\n"}, {"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": "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": "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\""}, {"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,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": "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": "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": "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": "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": "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 = 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"}], "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 y2:\n if y>1 and y1 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"} {"nl": {"description": "Furik loves math lessons very much, so he doesn't attend them, unlike Rubik. But now Furik wants to get a good mark for math. For that Ms. Ivanova, his math teacher, gave him a new task. Furik solved the task immediately. Can you?You are given a system of equations: You should count, how many there are pairs of integers (a,\u2009b) (0\u2009\u2264\u2009a,\u2009b) which satisfy the system.", "input_spec": "A single line contains two integers n,\u2009m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20091000) \u2014 the parameters of the system. The numbers on the line are separated by a space.", "output_spec": "On a single line print the answer to the problem.", "sample_inputs": ["9 3", "14 28", "4 20"], "sample_outputs": ["1", "1", "0"], "notes": "NoteIn the first sample the suitable pair is integers (3,\u20090). In the second sample the suitable pair is integers (3,\u20095). In the third sample there is no suitable pair."}, "positive_code": [{"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())\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,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,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": "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": "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": "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,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": "\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=[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": "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": "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": "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, 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": "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": "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": "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": "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": "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": "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,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": "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": "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": "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# (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,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": "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": "\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": "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": "__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": "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": "# 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": "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())\nprint sum([i==n-(m-i*i)**2 for i in range(n+1) if m>=i*i])"}, {"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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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 = [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=(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": "#!/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,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": "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": "#!/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 = 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": "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": "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": "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": "#!/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": "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": "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 = 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": "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": "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)])"}, {"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": "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": "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, 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, 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": "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": "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": "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": "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": "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())\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": "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": "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": "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())\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": "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": "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": "###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())\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": "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": "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": "#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, 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": "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": "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": "\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": "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,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": "#!/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 = 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": "#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": "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": "(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": "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": "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": "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": "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": "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)"}], "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 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"} {"nl": {"description": "One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump. Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability. The picture corresponds to the first example. The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.", "input_spec": "The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100. ", "output_spec": "Print single integer a\u00a0\u2014 the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.", "sample_inputs": ["ABABBBACFEYUKOTT", "AAA"], "sample_outputs": ["4", "1"], "notes": null}, "positive_code": [{"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": "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": "import re\nprint(max(map(len,re.split(\"[AEIOUY]\",input())))+1)\n"}, {"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": "#!/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": "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": "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 = '0'+input()+'1'\nl = 'AEIOUY1'\ni, k, mx, p, ls = 0, 0, 0, 0, 0\nwhile i0:\n while i m:\n m = d\nprint m\n"}, {"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": "#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 = '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": "#! /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": "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": "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": "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": "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": "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()\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 f1m:\n m=c\n c=0\nprint(m)"}, {"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": "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": "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": "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": "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": "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": "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 = 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": "#!/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": "#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": "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": "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": "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": "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": "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": "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": "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": "# 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": "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": "import re\nprint(len(max(re.split('[AEIOUY]', input()), key=len))+1)"}, {"source_code": "import re\nprint(max(map(len,re.split(\"[AEIOUY]\",input())))+1)\n"}, {"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": "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": "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": "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": "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": "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": "# #\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": "import re\nprint(len(max(re.split('[AEIOUY]', input()), key=len))+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": "#!/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": "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": "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": "\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"}, {"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": "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": "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": "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": "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": "\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": "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": "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": "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": "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": "x=raw_input()\n\nr=[]\nc=1\ni=0\nm=0\nwhile i m:\n m = d\nif m == 0:\n m = len(w)\nprint m\n"}, {"source_code": "import re\ns = raw_input()\nprint max(map(len, re.split(r\"[AEIOUY]\", s)))+1"}, {"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": "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 = 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"}, {"source_code": "\nstring = raw_input().strip()\nvow = 'AEIOUY'\nans = 1\nll = len(string)\np = 0\n\nwhile p max1:\n max1 = cnt\n cnt = 0\ncnt = cnt + 1\nif cnt > max1:\n max1 = cnt\nprint(max1)"}, {"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": "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": "\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": "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": "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": "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": "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": "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": "'''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": "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": "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()\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": "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": "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()\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": "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": "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": "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)) "}], "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 imazx:\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 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 jmax:\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 i0:\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"} {"nl": {"description": "The last stage of Football World Cup is played using the play-off system.There are n teams left in this stage, they are enumerated from 1 to n. Several rounds are held, in each round the remaining teams are sorted in the order of their ids, then the first in this order plays with the second, the third\u00a0\u2014 with the fourth, the fifth\u00a0\u2014 with the sixth, and so on. It is guaranteed that in each round there is even number of teams. The winner of each game advances to the next round, the loser is eliminated from the tournament, there are no draws. In the last round there is the only game with two remaining teams: the round is called the Final, the winner is called the champion, and the tournament is over.Arkady wants his two favorite teams to play in the Final. Unfortunately, the team ids are already determined, and it may happen that it is impossible for teams to meet in the Final, because they are to meet in some earlier stage, if they are strong enough. Determine, in which round the teams with ids a and b can meet.", "input_spec": "The only line contains three integers n, a and b (2\u2009\u2264\u2009n\u2009\u2264\u2009256, 1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009n)\u00a0\u2014 the total number of teams, and the ids of the teams that Arkady is interested in. It is guaranteed that n is such that in each round an even number of team advance, and that a and b are not equal.", "output_spec": "In the only line print \"Final!\" (without quotes), if teams a and b can meet in the Final. Otherwise, print a single integer\u00a0\u2014 the number of the round in which teams a and b can meet. The round are enumerated from 1.", "sample_inputs": ["4 1 2", "8 2 6", "8 7 5"], "sample_outputs": ["1", "Final!", "2"], "notes": "NoteIn the first example teams 1 and 2 meet in the first round.In the second example teams 2 and 6 can only meet in the third round, which is the Final, if they win all their opponents in earlier rounds.In the third example the teams with ids 7 and 5 can meet in the second round, if they win their opponents in the first round."}, "positive_code": [{"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": "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())\na,b,r=a-1,b-1,0\nwhile a!=b:\n a//=2\n b//=2\n r+=1\nprint(r if 2**r2):\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 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": "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": "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": "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": "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())\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": "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": "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": "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": "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": "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": "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 a0:\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,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": "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 (an 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": "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": "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": "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": "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 (an 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": "# 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": "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": "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": "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": "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 (an 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": "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())\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/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": "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**r1:\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": "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": "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": "# -*- 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": "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**r2):\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=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**rn/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, 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": "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": "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": "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": "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())\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": "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": "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": "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": "'''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": "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": "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 %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": "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": "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())\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": "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": "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": "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": "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": "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": "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=[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=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>= 1\n b >>= 1\n result += 1\nif n == 1 << result:\n print(\"Final!\")\nelse:\n print(result)\n"}, {"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": "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())\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": "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<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": "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# * *\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) = 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": "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": "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 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())\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": "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, 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": "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": "# ========= /\\ /| |====/|\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": "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": "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": "__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!\")"}, {"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": "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\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": "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": "# -*- 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 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": "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!\")"}], "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 bv/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]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]=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)= 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= 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 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//22):\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)> 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=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"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": "ka=int(input())\nif(ka&(ka-1)>0):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "n=input()\nprint 'YNEOS'[n&(n-1)>0::2]"}, {"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": "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=input()\nprint 'YNEOS'[n&(n-1)>0::2]"}, {"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": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\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": "#!/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": "\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(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()\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[\"YES\",\"NO\"][n&(n-1)>0]"}, {"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": "n = int(input())\n\nprint('NO' if n & n-1 else 'YES')"}, {"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": "\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=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "n=input()\nprint 'YNEOS'[n&(n-1)>0::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": "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": "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": "n=input();print[\"NO\",\"YES\"][n&n-1==0]"}, {"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": "n=input();print[\"YES\",\"NO\"][n&(n-1)>0]"}, {"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": "x = int( input() )\nprint( \"NO\" if x & x-1 > 0 else \"YES\" )"}, {"source_code": "n=input();print[\"NO\",\"YES\"][n&(n-1)==0]"}, {"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()\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": "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": "#!/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": "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": "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": "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": "\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": "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": "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": "print('NYOE S'[input() in {'1', '2', '4', '8', '16', '32', '64', '128', '256', '512'} :: 2])"}, {"source_code": "n=input();print[\"YES\",\"NO\"][n&n-1>0]"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\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": "n=input();print[\"NO\",\"YES\"][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()\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();print[\"YES\",\"NO\"][n&n-1>0]"}, {"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": "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())\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": "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": "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"}, {"source_code": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "n = int(input())\n\nprint('NO' if n & n-1 else 'YES')"}, {"source_code": "n=input();print[\"NO\",\"YES\"][not(n&(n-1))]\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": "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=input()\nprint 'YNEOS'[n&(n-1)>0::2]"}, {"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(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=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())\nprint('NO'if n&n-1 else 'YES')"}, {"source_code": "n=input();print[\"NO\",\"YES\"][not(n&(n-1))]\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 = 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=int(input())\nprint(\"NO\" if n&(n-1) else \"YES\")\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": "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": "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(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": "print ['NO','YES'][input()in[1,2,4,8,16,32,64,128,256,512]]"}, {"source_code": "n = input()\nprint ['NO', 'YES'][len(set(i * (i + 1) / 2 % n for i in range(n * 2))) == n]"}, {"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": "n=input();print[\"YES\",\"NO\"][n&n-1>0]"}, {"source_code": "n=input();print[\"NO\",\"YES\"][not(n&(n-1))]\n"}, {"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": "# 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": "n=input();print\"YNEOS\"[n&n-1>0::2]\n"}, {"source_code": "n=input()\nprint 'YNEOS'[n&(n-1)>0::2]"}, {"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": "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": "#\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 = 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": "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=input();print\"YNEOS\"[n&n-1>0::2]\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": "print('NYOE S'[int(raw_input()) in {1, 2, 4, 8, 16, 32, 64, 128, 256, 512} :: 2])"}, {"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": "x = int( input() )\nprint( \"NO\" if x & x-1 > 0 else \"YES\" )\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 = input()\nprint ['YES', 'NO'][n & (n - 1) > 0]"}, {"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\")"}], "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"} {"nl": {"description": "Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's index is divisible by b. So the tile with the number divisible by a and b can be either painted Red or Blue.After her painting is done, she will get p chocolates for each tile that is painted Red and q chocolates for each tile that is painted Blue.Note that she can paint tiles in any order she wants.Given the required information, find the maximum\u00a0number of chocolates Joty can get.", "input_spec": "The only line contains five integers n, a, b, p and q (1\u2009\u2264\u2009n,\u2009a,\u2009b,\u2009p,\u2009q\u2009\u2264\u2009109).", "output_spec": "Print the only integer s \u2014 the maximum number of chocolates Joty can get. Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.", "sample_inputs": ["5 2 3 12 15", "20 2 3 3 5"], "sample_outputs": ["39", "51"], "notes": null}, "positive_code": [{"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": "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": "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": "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, 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": "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": "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": "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": "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": "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 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": "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": "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": "'''#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 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": "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 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": "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())\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": "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": "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": "# 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": "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 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 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": "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": "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": "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": "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": "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 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 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\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": "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": "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": "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": "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": "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\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": "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": "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": "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": "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": "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": "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": "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": "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": "n,a,b,p,q=map(int,input().split())\nif 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": "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": "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 .\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": "n,a,b,p,q=map(int,input().split())\nif p 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": "__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": "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": "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": "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": "# -*- 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 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\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=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 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": "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 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": "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": "'''#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 pq:\n\tans=x*p+(y-z)*q\nelse:\n\tans=y*q+(x-z)*p\nprint ans"}, {"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\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": "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": "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": "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": "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": "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 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": "n,a,b,p,q=map(int,input().split())\nif pq:\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": "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": "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": "\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": "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": "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": "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": "# 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": "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)"}], "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 ab:\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 aq :\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 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"} {"nl": {"description": "After passing a test, Vasya got himself a box of $$$n$$$ candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.This means the process of eating candies is the following: in the beginning Vasya chooses a single integer $$$k$$$, same for all days. After that, in the morning he eats $$$k$$$ candies from the box (if there are less than $$$k$$$ candies in the box, he eats them all), then in the evening Petya eats $$$10\\%$$$ of the candies remaining in the box. If there are still candies left in the box, the process repeats\u00a0\u2014 next day Vasya eats $$$k$$$ candies again, and Petya\u00a0\u2014 $$$10\\%$$$ of the candies left in a box, and so on.If the amount of candies in the box is not divisible by $$$10$$$, Petya rounds the amount he takes from the box down. For example, if there were $$$97$$$ candies in the box, Petya would eat only $$$9$$$ of them. In particular, if there are less than $$$10$$$ candies in a box, Petya won't eat any at all.Your task is to find out the minimal amount of $$$k$$$ that can be chosen by Vasya so that he would eat at least half of the $$$n$$$ candies he initially got. Note that the number $$$k$$$ must be integer.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\leq n \\leq 10^{18}$$$)\u00a0\u2014 the initial amount of candies in the box.", "output_spec": "Output a single integer\u00a0\u2014 the minimal amount of $$$k$$$ that would allow Vasya to eat at least half of candies he got.", "sample_inputs": ["68"], "sample_outputs": ["3"], "notes": "NoteIn the sample, the amount of candies, with $$$k=3$$$, would change in the following way (Vasya eats first):$$$68 \\to 65 \\to 59 \\to 56 \\to 51 \\to 48 \\to 44 \\to 41 \\\\ \\to 37 \\to 34 \\to 31 \\to 28 \\to 26 \\to 23 \\to 21 \\to 18 \\to 17 \\to 14 \\\\ \\to 13 \\to 10 \\to 9 \\to 6 \\to 6 \\to 3 \\to 3 \\to 0$$$.In total, Vasya would eat $$$39$$$ candies, while Petya\u00a0\u2014 $$$29$$$."}, "positive_code": [{"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": "n=input()\nl,h=1,n\nwhile l 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": "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": "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": "# -*- 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": "\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": "# 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 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= 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": "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#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": "# -*- 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": "n = int(input())\n\ndef can(x):\n v = 0\n t = n\n while t>0:\n if t= ((n+1)//2))\n\nlo = 1\nhi = n\nwhile lo>1);\n if can(mid):\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": "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": "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": "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 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": "# 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+10:\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 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": "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 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": "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": "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": "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": "#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": "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 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": "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": "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 = 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": "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())\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#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": "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": "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": "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=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": "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())\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())\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": "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)"}, {"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": "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": "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": "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 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": "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": "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": "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\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": "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*x0):\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": "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 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": "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 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": "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": "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": "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": "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": "\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": "# -*- 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": "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 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": "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": "# -*- 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": "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": "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 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)"}, {"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(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": "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": "n = int(input())\n\nans = 1\n\nl = 0\nr = n\nwhile l9:\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": "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())\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": "#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": "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": "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": "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": "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 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": "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())\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": "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": "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": "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": "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": "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": "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": "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": "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=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": "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": "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 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 = 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"}], "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 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 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=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 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=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 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=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 (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 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 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 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 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 l0:\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 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 k9:\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 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+10):\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 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": "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": "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": "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": "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] 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(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 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": "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": "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#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": "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": "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": "# 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": "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": "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": "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": "# 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 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": "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": "'''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": "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": "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 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": "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 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": "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": "'''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": "#!/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": "\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])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": "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:\n ans = min(ans, mem[i][1])\n\nprint(ans)\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(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": "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=(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 numx:\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 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": "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": "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\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": "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": "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": "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": "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": "# 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": "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=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": "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": "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": "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 = [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": "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 = 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\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": "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": "#!/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": "#!/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": "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,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()\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": "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": "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": "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])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) 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\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, 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(su0):\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": "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": "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": "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": "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": "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": "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": "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": "'''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": "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())\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"}, {"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": "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) 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": "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"}, {"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": "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 ans=min(ans,moves[i])\nprint(ans)\n \n\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": "\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": "# ------------------- 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\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": "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": "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 = 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": "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": "\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": "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": "#!/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=n:\n results[k] = sum(sorted_res[0:n])\n print(min(results.values()))\n\nif __name__ == \"__main__\":\n main()\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": "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"}], "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 fr0:\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]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]=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 numx:\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 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 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:\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]\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< 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 jcand):\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] 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]\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]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)0:\n x//=2\n ch+=1\n if sol[x][0]=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:\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]) [(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=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< 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 jcand):\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 numx:\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 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<=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 jcand):\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"} {"nl": {"description": "Recently you have received two positive integer numbers $$$x$$$ and $$$y$$$. You forgot them, but you remembered a shuffled list containing all divisors of $$$x$$$ (including $$$1$$$ and $$$x$$$) and all divisors of $$$y$$$ (including $$$1$$$ and $$$y$$$). If $$$d$$$ is a divisor of both numbers $$$x$$$ and $$$y$$$ at the same time, there are two occurrences of $$$d$$$ in the list.For example, if $$$x=4$$$ and $$$y=6$$$ then the given list can be any permutation of the list $$$[1, 2, 4, 1, 2, 3, 6]$$$. Some of the possible lists are: $$$[1, 1, 2, 4, 6, 3, 2]$$$, $$$[4, 6, 1, 1, 2, 3, 2]$$$ or $$$[1, 6, 3, 2, 4, 1, 2]$$$.Your problem is to restore suitable positive integer numbers $$$x$$$ and $$$y$$$ that would yield the same list of divisors (possibly in different order).It is guaranteed that the answer exists, i.e. the given list of divisors corresponds to some positive integers $$$x$$$ and $$$y$$$.", "input_spec": "The first line contains one integer $$$n$$$ ($$$2 \\le n \\le 128$$$) \u2014 the number of divisors of $$$x$$$ and $$$y$$$. The second line of the input contains $$$n$$$ integers $$$d_1, d_2, \\dots, d_n$$$ ($$$1 \\le d_i \\le 10^4$$$), where $$$d_i$$$ is either divisor of $$$x$$$ or divisor of $$$y$$$. If a number is divisor of both numbers $$$x$$$ and $$$y$$$ then there are two copies of this number in the list.", "output_spec": "Print two positive integer numbers $$$x$$$ and $$$y$$$ \u2014 such numbers that merged list of their divisors is the permutation of the given list of integers. It is guaranteed that the answer exists.", "sample_inputs": ["10\n10 2 8 1 2 4 1 20 4 5"], "sample_outputs": ["20 8"], "notes": null}, "positive_code": [{"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 i1) and i>k:\n k=i\nprint(m,k)"}, {"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": "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 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())\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": "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": "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": "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": "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": "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": "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": "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())\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#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 = 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": "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"}, {"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=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": "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 = 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": "#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": "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": "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": "__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": "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": "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())\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": "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())\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))"}, {"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": "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": "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=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": "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": "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=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": "\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 = 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": "'''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": "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": "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": "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": "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": "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": "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 = 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": "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": "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 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": "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())\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": "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": "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": "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())\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": "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(input())\nlista = [int(x) for x in input().split()]\nmaxi = 0\nid = 0\nfor i in range (0, len(lista)):\n if maxi1):\n div.append(i)\n\nprint(str(mx)+\" \"+str(max(div)))"}, {"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": "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": "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(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=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": "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(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": "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()\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 = 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())\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": "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": "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": "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": "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": "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": "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()\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": "\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": "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": "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": "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": "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": "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": "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())\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": "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=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 = 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": "\"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 = 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": "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()))\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": "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": "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": "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": "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": "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"}], "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 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 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 min3:\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"} {"nl": {"description": "Numbers k-bonacci (k is integer, k\u2009>\u20091) are a generalization of Fibonacci numbers and are determined as follows: F(k,\u2009n)\u2009=\u20090, for integer n, 1\u2009\u2264\u2009n\u2009<\u2009k; F(k,\u2009k)\u2009=\u20091; F(k,\u2009n)\u2009=\u2009F(k,\u2009n\u2009-\u20091)\u2009+\u2009F(k,\u2009n\u2009-\u20092)\u2009+\u2009...\u2009+\u2009F(k,\u2009n\u2009-\u2009k), for integer n, n\u2009>\u2009k. Note that we determine the k-bonacci numbers, F(k,\u2009n), only for integer values of n and k.You've got a number s, represent it as a sum of several (at least two) distinct k-bonacci numbers. ", "input_spec": "The first line contains two integers s and k (1\u2009\u2264\u2009s,\u2009k\u2009\u2264\u2009109;\u00a0k\u2009>\u20091).", "output_spec": "In the first line print an integer m (m\u2009\u2265\u20092) that shows how many numbers are in the found representation. In the second line print m distinct integers a1,\u2009a2,\u2009...,\u2009am. Each printed integer should be a k-bonacci number. The sum of printed integers must equal s. It is guaranteed that the answer exists. If there are several possible answers, print any of them.", "sample_inputs": ["5 2", "21 5"], "sample_outputs": ["3\n0 2 3", "3\n4 1 16"], "notes": null}, "positive_code": [{"source_code": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]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": "#!/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\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": "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": "\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=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": "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]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=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]= 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\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=[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": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1] 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]= 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] 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 = [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": "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]=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": "s,k=map(int,raw_input().split())\na,b=[0,1],[]\nwhile a[-1]= 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": "\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": "#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 s0:\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] 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] 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]= 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,"}, {"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 i0:\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]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=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=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] 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))"}], "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]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 n0:\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=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=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 n0 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= 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 n0 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 n0:\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]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= 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 i0:\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=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=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=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]= 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] 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"} {"nl": {"description": "A boy Valera registered on site Codeforces as Valera, and wrote his first Codeforces Round #300. He boasted to a friend Arkady about winning as much as x points for his first contest. But Arkady did not believe his friend's words and decided to check whether Valera could have shown such a result.He knows that the contest number 300 was unusual because there were only two problems. The contest lasted for t minutes, the minutes are numbered starting from zero. The first problem had the initial cost of a points, and every minute its cost reduced by da points. The second problem had the initial cost of b points, and every minute this cost reduced by db points. Thus, as soon as the zero minute of the contest is over, the first problem will cost a\u2009-\u2009da points, and the second problem will cost b\u2009-\u2009db points. It is guaranteed that at any moment of the contest each problem has a non-negative cost.Arkady asks you to find out whether Valera could have got exactly x points for this contest. You should assume that Valera could have solved any number of the offered problems. You should also assume that for each problem Valera made no more than one attempt, besides, he could have submitted both problems at the same minute of the contest, starting with minute 0 and ending with minute number t\u2009-\u20091. Please note that Valera can't submit a solution exactly t minutes after the start of the contest or later.", "input_spec": "The single line of the input contains six integers x,\u2009t,\u2009a,\u2009b,\u2009da,\u2009db (0\u2009\u2264\u2009x\u2009\u2264\u2009600;\u00a01\u2009\u2264\u2009t,\u2009a,\u2009b,\u2009da,\u2009db\u2009\u2264\u2009300) \u2014 Valera's result, the contest's duration, the initial cost of the first problem, the initial cost of the second problem, the number of points that the first and the second problem lose per minute, correspondingly. It is guaranteed that at each minute of the contest each problem has a non-negative cost, that is, a\u2009-\u2009i\u00b7da\u2009\u2265\u20090 and b\u2009-\u2009i\u00b7db\u2009\u2265\u20090 for all 0\u2009\u2264\u2009i\u2009\u2264\u2009t\u2009-\u20091.", "output_spec": "If Valera could have earned exactly x points at a contest, print \"YES\", otherwise print \"NO\" (without the quotes).", "sample_inputs": ["30 5 20 20 3 5", "10 4 100 5 5 1"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample Valera could have acted like this: he could have submitted the first problem at minute 0 and the second problem \u2014 at minute 2. Then the first problem brings him 20 points and the second problem brings him 10 points, that in total gives the required 30 points."}, "positive_code": [{"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": "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": "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=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, 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": "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": "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())\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,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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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"}, {"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(' '))\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, 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,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": "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 = 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 = 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": "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": "#!/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": "# 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, 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": "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": "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": "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": "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": "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,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,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": "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": "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": "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": "#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())\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": "#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": "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": "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 = [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, 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": "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": "#!/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": "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 = 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 = 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": "# 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/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())\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": "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 = (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": "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(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, 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 = 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": "#!/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,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(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": "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": "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": "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": "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": "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": "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": "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": "#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": "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\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": "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 = 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": "[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": "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": "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": "#!/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, 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, 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": "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/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": "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,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": "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": "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,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": "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())\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, 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": "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": "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": "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"}, {"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\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": "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())\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')"}], "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"} {"nl": {"description": "Mishka started participating in a programming contest. There are $$$n$$$ problems in the contest. Mishka's problem-solving skill is equal to $$$k$$$.Mishka arranges all problems from the contest into a list. Because of his weird principles, Mishka only solves problems from one of the ends of the list. Every time, he chooses which end (left or right) he will solve the next problem from. Thus, each problem Mishka solves is either the leftmost or the rightmost problem in the list.Mishka cannot solve a problem with difficulty greater than $$$k$$$. When Mishka solves the problem, it disappears from the list, so the length of the list decreases by $$$1$$$. Mishka stops when he is unable to solve any problem from any end of the list.How many problems can Mishka solve?", "input_spec": "The first line of input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\le n, k \\le 100$$$) \u2014 the number of problems in the contest and Mishka's problem-solving skill. The second line of input contains $$$n$$$ integers $$$a_1, a_2, \\dots, a_n$$$ ($$$1 \\le a_i \\le 100$$$), where $$$a_i$$$ is the difficulty of the $$$i$$$-th problem. The problems are given in order from the leftmost to the rightmost in the list.", "output_spec": "Print one integer \u2014 the maximum number of problems Mishka can solve.", "sample_inputs": ["8 4\n4 2 3 1 5 1 6 4", "5 2\n3 1 2 1 3", "5 100\n12 34 55 43 21"], "sample_outputs": ["5", "0", "5"], "notes": "NoteIn the first example, Mishka can solve problems in the following order: $$$[4, 2, 3, 1, 5, 1, 6, 4] \\rightarrow [2, 3, 1, 5, 1, 6, 4] \\rightarrow [2, 3, 1, 5, 1, 6] \\rightarrow [3, 1, 5, 1, 6] \\rightarrow [1, 5, 1, 6] \\rightarrow [5, 1, 6]$$$, so the number of solved problems will be equal to $$$5$$$.In the second example, Mishka can't solve any problem because the difficulties of problems from both ends are greater than $$$k$$$.In the third example, Mishka's solving skill is so amazing that he can solve all the problems."}, "positive_code": [{"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()))\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\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": "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": "# 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 leftk):\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": "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())\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": "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": "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=0 and jk 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": "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())\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": "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())\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": "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())\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": "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": "# -*- 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=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,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()))\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())\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": "# 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 leftk):\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())\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": "(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())\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": "\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": "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": "# 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": "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": "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,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=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())\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": "###\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\"\"\"\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": "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": "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": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\ni=0\nj=0\nl=0\nwhile(lk):\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": "# 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": "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": "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": "\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": "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": "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": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\ni=0\nj=0\nl=0\nwhile(l0:\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": "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": "# -*- 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": "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": "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": "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"}, {"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=0 and jk 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": "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": "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()))\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": "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": "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, 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": "#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": "__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": "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": "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": "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": "n,k=map(int,input().split())\nb=list(map(int,input().split()))\nj=0\nq=0\nr=0\nwhile(jk:\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": "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": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\ni=0\nj=0\nl=0\nwhile(ln):\n print(n)\nelse:\n print(count1)"}, {"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=[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": "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": "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": "#!/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 = 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=map(int,input().split())\nl=list(map(int,input().split()))\ni=0\nh=1\nc=0\np=0\ns=1\nwhile ik:\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=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": "# -*- 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": "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=0:\n if a[i]<=k:\n p=p+1\n else:\n break\n i-=1\n print(p)\n"}, {"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=list(map(int,input().split()))\nz=list(map(int,input().split()))\n\ncount=0\n\nstep=0\n\nwhile stepw:\n c+=1\n else:\n break\nprint(c)"}, {"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": "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": "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 (leftleft)):\n right+=1\n cout+=1\nprint(cout) \n\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())\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 ik 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, 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": "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": "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": "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 = 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())\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)"}], "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 ib:\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 ii:\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 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 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 ia[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 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 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 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=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 im:\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=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)=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"} {"nl": {"description": "There is a card game called \"Durak\", which means \"Fool\" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly \u2014 you can find them later yourselves if you want.To play durak you need a pack of 36 cards. Each card has a suit (\"S\", \"H\", \"D\" and \"C\") and a rank (in the increasing order \"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" and \"A\"). At the beginning of the game one suit is arbitrarily chosen as trump. The players move like that: one player puts one or several of his cards on the table and the other one should beat each of them with his cards.A card beats another one if both cards have similar suits and the first card has a higher rank then the second one. Besides, a trump card can beat any non-trump card whatever the cards\u2019 ranks are. In all other cases you can not beat the second card with the first one.You are given the trump suit and two different cards. Determine whether the first one beats the second one or not.", "input_spec": "The first line contains the tramp suit. It is \"S\", \"H\", \"D\" or \"C\". The second line contains the description of the two different cards. Each card is described by one word consisting of two symbols. The first symbol stands for the rank (\"6\", \"7\", \"8\", \"9\", \"T\", \"J\", \"Q\", \"K\" and \"A\"), and the second one stands for the suit (\"S\", \"H\", \"D\" and \"C\").", "output_spec": "Print \"YES\" (without the quotes) if the first cards beats the second one. Otherwise, print \"NO\" (also without the quotes).", "sample_inputs": ["H\nQH 9S", "S\n8D 6D", "C\n7H AS"], "sample_outputs": ["YES", "YES", "NO"], "notes": null}, "positive_code": [{"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": "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": "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": "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": "#!/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": "'''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": "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": "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 = 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": "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": "#!/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": "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'\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": "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": "######################################################################\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "# -*- 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": "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": "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": "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": "\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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=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": "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": "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": "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": "# -*- 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": "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": "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": "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": "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 = 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": "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": "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": "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": "\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()\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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "\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": "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": "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": "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": "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": "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": "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": "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": "# -*- 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": "'''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": "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": "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": "##############--->>>>> 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\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": "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": "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": "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": "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": "\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": "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"}, {"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]) 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": "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": "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": "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": "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"}], "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)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[3])):\n print 'YES'\nelif (l[1]==l[4] and int(l[0]) 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]] 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]) 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('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[3])):\n print 'YES'\nelif (l[1]==l[4] and int(l[0])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)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]] 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"} {"nl": {"description": "You are given a string $$$s$$$ consisting of lowercase Latin letters. Let the length of $$$s$$$ be $$$|s|$$$. You may perform several operations on this string.In one operation, you can choose some index $$$i$$$ and remove the $$$i$$$-th character of $$$s$$$ ($$$s_i$$$) if at least one of its adjacent characters is the previous letter in the Latin alphabet for $$$s_i$$$. For example, the previous letter for b is a, the previous letter for s is r, the letter a has no previous letters. Note that after each removal the length of the string decreases by one. So, the index $$$i$$$ should satisfy the condition $$$1 \\le i \\le |s|$$$ during each operation.For the character $$$s_i$$$ adjacent characters are $$$s_{i-1}$$$ and $$$s_{i+1}$$$. The first and the last characters of $$$s$$$ both have only one adjacent character (unless $$$|s| = 1$$$).Consider the following example. Let $$$s=$$$ bacabcab. During the first move, you can remove the first character $$$s_1=$$$ b because $$$s_2=$$$ a. Then the string becomes $$$s=$$$ acabcab. During the second move, you can remove the fifth character $$$s_5=$$$ c because $$$s_4=$$$ b. Then the string becomes $$$s=$$$ acabab. During the third move, you can remove the sixth character $$$s_6=$$$'b' because $$$s_5=$$$ a. Then the string becomes $$$s=$$$ acaba. During the fourth move, the only character you can remove is $$$s_4=$$$ b, because $$$s_3=$$$ a (or $$$s_5=$$$ a). The string becomes $$$s=$$$ acaa and you cannot do anything with it. Your task is to find the maximum possible number of characters you can remove if you choose the sequence of operations optimally.", "input_spec": "The only line of the input contains one integer $$$|s|$$$ ($$$1 \\le |s| \\le 100$$$) \u2014 the length of $$$s$$$. The second line of the input contains one string $$$s$$$ consisting of $$$|s|$$$ lowercase Latin letters.", "output_spec": "Print one integer \u2014 the maximum possible number of characters you can remove if you choose the sequence of moves optimally.", "sample_inputs": ["8\nbacabcab", "4\nbcda", "6\nabbbbb"], "sample_outputs": ["4", "3", "5"], "notes": "NoteThe first example is described in the problem statement. Note that the sequence of moves provided in the statement is not the only, but it can be shown that the maximum possible answer to this test is $$$4$$$.In the second example, you can remove all but one character of $$$s$$$. The only possible answer follows. During the first move, remove the third character $$$s_3=$$$ d, $$$s$$$ becomes bca. During the second move, remove the second character $$$s_2=$$$ c, $$$s$$$ becomes ba. And during the third move, remove the first character $$$s_1=$$$ b, $$$s$$$ becomes a. "}, "positive_code": [{"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 k0 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": "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 = j0 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": "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": "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 i0 and s[i]==c and s[i-1] == chr(ord(c)-1)) or (i1:\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 imx: 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()\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": "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": "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())\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": "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())\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": "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": "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 \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(j0 and (a[j-1]==chr(ord(y)-1) or a[j-1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n elif(j= 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 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": "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(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": "def is_right_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": "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+1ord(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": "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())\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": "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())\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": "# 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": "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 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 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": "#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=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=0 and s[x]!=-1 and s[x]==chr(ord(s[j])-1)) or (y=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 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 = 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": "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": "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": "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+1m:\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=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())\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": "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=0 and ord(s[i])-ord(s[i-1])==1:\n if mx==-1:\n mx=i\n elif s[mx] 0 and s[idx-1] == prev:\n s.pop(idx)\n updated = True\n\nprint( n - len(s))\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 \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(j0 and (a[j-1]==chr(ord(y)-1) or a[j-1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n elif(j= 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": "# 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 j0 and j=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=0 and ord(v[i-1][0]) == ord(v[i][0])-1:\n v[i][1] +=1\n if i+1=0 and ord(v[mi-1][0])-1 == ord(v[mi][0])):\n v[mi-1][1]-=1\n if(mi+1=0 and ord(v[mi][0])-1 == ord(v[mi-1][0])):\n v[mi][1]+=1\n if(mi=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": "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\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]1):\n for char in range(ord('z'),ord('a')-1,-1):\n i=0\n while(len(s)>0 and i 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": "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 im:\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": "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, 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": "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": "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]= 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": "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": "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+1ord(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": "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\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= 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": "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())\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 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": "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))"}, {"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 j0 and j1:\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": "#------------------------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 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": "\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": "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": "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)"}, {"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]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": "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 (j0 and j=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": "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=0 and ord(v[mi-1][0])-1 == ord(v[mi][0])):\n v[mi-1][1]-=1\n if(mi+1=0 and ord(v[mi][0])-1 == ord(v[mi-1][0])):\n v[mi][1]+=1\n if(mi=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(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": "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": "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": "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=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 (j0):\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 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 j0:\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 -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 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= 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 i1:\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 i1:\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 k1:\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 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 j0:\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 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 imx: 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 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 imx: 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 (j0 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 (i0:\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 j0:\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=0:\n if ord(s[k])-ord(s[k-1])==1:\n prev=1\n if k+1=0:\n leftNumber,leftString = dp[start][k-1][0],dp[start][k-1][1]\n if k+1dp[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+1maxyet):\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= 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 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'0 and (a[j-1]==chr(ord(y)-1) or a[j-1]==\"*\")):\n a[j]=\"*\"\n ans+=1\n elif(j= 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 jle-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 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 = 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 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] 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 (j0 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 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"} {"nl": {"description": "Salve, mi amice.Et tu quidem de lapis philosophorum. Barba non facit philosophum. Labor omnia vincit. Non potest creatio ex nihilo. Necesse est partibus.Rp:\u00a0\u00a0\u00a0\u00a0I Aqua Fortis\u00a0\u00a0\u00a0\u00a0I Aqua Regia\u00a0\u00a0\u00a0\u00a0II Amalgama\u00a0\u00a0\u00a0\u00a0VII Minium\u00a0\u00a0\u00a0\u00a0IV VitriolMisce in vitro et \u00e6stus, et nil admirari. Festina lente, et nulla tenaci invia est via.Fac et spera,Vale,Nicolas Flamel", "input_spec": "The first line of input contains several space-separated integers ai (0\u2009\u2264\u2009ai\u2009\u2264\u2009100).", "output_spec": "Print a single integer.", "sample_inputs": ["2 4 6 8 10"], "sample_outputs": ["1"], "notes": null}, "positive_code": [{"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\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, b, c, d, e = map(int, input().split())\nprint(min(a, b, c // 2, d // 7, e // 4))"}, {"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": "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 = [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=[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, b, c, d, e = map(int, raw_input().split())\nprint min(a, b, c / 2, d / 7, e / 4)"}, {"source_code": "a, b, c, d, e = map(int, input().split())\nprint(min(a, b, c >> 1, d // 7, e >> 2))\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": "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": "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": "#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=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": "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, 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, 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": "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": "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": "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())\nprint( min( a , b , c // 2 , d // 7 , e // 4 ) )\n"}, {"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())\nprint min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)\n"}, {"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": "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": "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=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": "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\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": "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,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": "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())\nprint min(a, b, c / 2, d / 7, e / 4)\n"}, {"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": "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, b, c, d, e = map(int, input().split())\nprint(min(a//1, b//1, c//2, d//7, e//4))\n"}, {"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())\nprint min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)"}, {"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": "\"\"\"\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": "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"}, {"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": "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": "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": "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": "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": "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= 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(map(lambda a, b: a/b, a, [1,1,2,7,4]))"}, {"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": "a1, a2, a3, a4, a5 = map(int, input().split())\nprint(min(a1, a2, a3 // 2, a4 // 7, a5 // 4))"}, {"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": "# 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": "a=map(int,raw_input().split())\nprint min(a[0],a[1],a[2]/2,a[3]/7,a[4]/4)"}, {"source_code": "a,b,c,d,e=map(int,input().split())\nprint(min(a,b,c//2,d//7,e//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": "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": "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": "a1, a2, a3, a4, a5 = map(int, input().split())\nprint(min(a1, a2, a3 // 2, a4 // 7, a5 // 4))"}, {"source_code": "a, b, c, d, e = map(int, raw_input().split())\nprint min(a, b, c/2, d/7, e/4)"}, {"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": "a , b , c , d , e = map( int , input().split())\nprint( min( a , b , c // 2 , d // 7 , e // 4 ) )\n"}, {"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 = 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": "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": "print min(map(lambda x,y:(int(x)/y),raw_input().split(),[1,1,2,7,4]))"}, {"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": "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": "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": "# 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": "# 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": "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,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,b,c,d,lmh=map(int,input().split());print(min(a,b,c//2,d//7,lmh//4))"}, {"source_code": "a, b, c, d, e = map(int, raw_input().split())\nprint min(a, b, c/2, d/7, e/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(ans)"}, {"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": "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": "a , b , c , d , e = map( int , input().split())\nprint( min( a , b , c // 2 , d // 7 , e // 4 ) )\n"}, {"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))\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"} {"nl": {"description": "Vasya has n burles. One bottle of Ber-Cola costs a burles and one Bars bar costs b burles. He can buy any non-negative integer number of bottles of Ber-Cola and any non-negative integer number of Bars bars.Find out if it's possible to buy some amount of bottles of Ber-Cola and Bars bars and spend exactly n burles.In 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.", "input_spec": "First line contains single integer n (1\u2009\u2264\u2009n\u2009\u2264\u200910\u2009000\u2009000)\u00a0\u2014 amount of money, that Vasya has. Second line contains single integer a (1\u2009\u2264\u2009a\u2009\u2264\u200910\u2009000\u2009000)\u00a0\u2014 cost of one bottle of Ber-Cola. Third line contains single integer b (1\u2009\u2264\u2009b\u2009\u2264\u200910\u2009000\u2009000)\u00a0\u2014 cost of one Bars bar.", "output_spec": "If Vasya can't buy Bars and Ber-Cola in such a way to spend exactly n burles print \u00abNO\u00bb (without quotes). Otherwise in first line print \u00abYES\u00bb (without quotes). In second line print two non-negative integers x and y\u00a0\u2014 number of bottles of Ber-Cola and number of Bars bars Vasya should buy in order to spend exactly n burles, i.e. x\u00b7a\u2009+\u2009y\u00b7b\u2009=\u2009n. If there are multiple answers print any of them. Any of numbers x and y can be equal 0.", "sample_inputs": ["7\n2\n3", "100\n25\n10", "15\n4\n8", "9960594\n2551\n2557"], "sample_outputs": ["YES\n2 1", "YES\n0 10", "NO", "YES\n1951 1949"], "notes": "NoteIn first example Vasya can buy two bottles of Ber-Cola and one Bars bar. He will spend exactly 2\u00b72\u2009+\u20091\u00b73\u2009=\u20097 burles.In second example Vasya can spend exactly n burles multiple ways: buy two bottles of Ber-Cola and five Bars bars; buy four bottles of Ber-Cola and don't buy Bars bars; don't buy Ber-Cola and buy 10 Bars bars. In third example it's impossible to but Ber-Cola and Bars bars in order to spend exactly n burles."}, "positive_code": [{"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(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": "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": "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\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": "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": "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": "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": "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": "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": "'''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 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": "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": "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": "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": "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 = 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": "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(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": "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())\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\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())\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": "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": "import sys\nfrom fractions import gcd\nn=input()\nx=input()\ny=input()\nflag=False\nif(x= 0:\n print(\"YES\")\n print(i, (n - a * i) // b)\n break\nelse:\n print(\"NO\")\n \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())\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": "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": "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": "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": "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": "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": "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": "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": "'''\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\")"}, {"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": "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": "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": "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())\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": "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": "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": "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": "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": "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": "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": "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=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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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())\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 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": "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())\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": "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": "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": "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": "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": "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())\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": "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": "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": "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": "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": "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 az 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": "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": "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": "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\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": "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": "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": "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": "'''\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": "import sys\nfrom fractions import gcd\nn=input()\nx=input()\ny=input()\nflag=False\nif(x 0 and x > 0):\n\t\tx -= y\n\t\tcola += 1\n\t\ttoolong -= y\nprint(\"YES\")\nprint(cola, bar)"}, {"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 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": "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": "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": "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": "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=[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())\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": "# cook your dish here\nn=int(input())\na=int(input())\nb=int(input())\nf=0\nif a0:\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')"}], "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 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=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\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 ((xz 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 in//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while in//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//ab:\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= 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 in//a:\n print('NO')\n else:\n print('YES')\n print(i,end=' ')\n print((n-a*i)//b)\n else:\n while in//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= 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):\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 ab:\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"} {"nl": {"description": "Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. A palindrome is a string that reads the same backward as forward, for example strings \"z\", \"aaa\", \"aba\", \"abccba\" are palindromes, but strings \"codeforces\", \"reality\", \"ab\" are not.", "input_spec": "The first and single line contains string s (1\u2009\u2264\u2009|s|\u2009\u2264\u200915).", "output_spec": "Print \"YES\" (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or \"NO\" (without quotes) otherwise. ", "sample_inputs": ["abccaa", "abbcca", "abcda"], "sample_outputs": ["YES", "NO", "YES"], "notes": null}, "positive_code": [{"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": "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, 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": "#!/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": "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": "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=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": "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()\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": "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": "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": "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": "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": "# -*- 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": "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": "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": "'''\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": "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": "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()\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": "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": "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": "##############--->>>>> 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": "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": "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": "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": "s = input()\ncnt = 0\nn = len(s)-1\ni = 0\nwhile i1:\n print(\"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": "#!/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": "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": "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": "\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": "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": "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": "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": "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().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 = 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": "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 = 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": "\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": "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": "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": "str=input();\nls=len(str);\ni,j,ans=0,ls-1,0;\nwhile(i1 or (ans==0 and ls&1==0)): print(\"NO\");\nelse: print(\"YES\");"}, {"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 = 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": "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": "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": "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": "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": "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": "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": "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": "# 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": "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": "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": "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": "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": "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": "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()"}, {"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": "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": "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 = 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": "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": "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": "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": "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": "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 = 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": "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\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": "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": "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()\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": "#https://codeforces.com/problemset/problem/798/A\ns=input()\nc=0\ni=0\nflag=True\nwhile(i1):\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)\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": "##############--->>>>> 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": "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": "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": "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().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": "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": "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": "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": "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": "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')"}], "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(i1):\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 j1 :\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 i1:\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(i1:\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 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 i1:\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"} {"nl": {"description": "Today is Wednesday, the third day of the week. What's more interesting is that tomorrow is the last day of the year 2015.Limak is a little polar bear. He enjoyed this year a lot. Now, he is so eager to the coming year 2016.Limak wants to prove how responsible a bear he is. He is going to regularly save candies for the entire year 2016! He considers various saving plans. He can save one candy either on some fixed day of the week or on some fixed day of the month.Limak chose one particular plan. He isn't sure how many candies he will save in the 2016 with his plan. Please, calculate it and tell him.", "input_spec": "The only line of the input is in one of the following two formats: \"x of week\" where x (1\u2009\u2264\u2009x\u2009\u2264\u20097) denotes the day of the week. The 1-st day is Monday and the 7-th one is Sunday. \"x of month\" where x (1\u2009\u2264\u2009x\u2009\u2264\u200931) denotes the day of the month. ", "output_spec": "Print one integer\u00a0\u2014 the number of candies Limak will save in the year 2016.", "sample_inputs": ["4 of week", "30 of month"], "sample_outputs": ["52", "11"], "notes": "NotePolar bears use the Gregorian calendar. It is the most common calendar and you likely use it too. You can read about it on Wikipedia if you want to \u2013 https://en.wikipedia.org/wiki/Gregorian_calendar. The week starts with Monday.In the first sample Limak wants to save one candy on each Thursday (the 4-th day of the week). There are 52 Thursdays in the 2016. Thus, he will save 52 candies in total.In the second sample Limak wants to save one candy on the 30-th day of each month. There is the 30-th day in exactly 11 months in the 2016\u00a0\u2014 all months but February. It means that Limak will save 11 candies in total."}, "positive_code": [{"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 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": "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": "\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": "#-------------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 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"}, {"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": "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": "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": "\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": "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()\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": "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": "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": "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": "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": "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)"}, {"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": "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": "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 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": "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": "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": "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": "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": "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": "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": "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": "# 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": "\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": "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": "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 = 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": "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": "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": "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": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2016 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": "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": "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": "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": "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": "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": "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": "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": "# -*- 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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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": "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, 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": "\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": "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": "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": "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 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": "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": "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": "#\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": "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": "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": "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": "\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": "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": "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": "# 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": "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=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": "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": "'''\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": "\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": "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": "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": "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": "# 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": "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": "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": "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 = 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": "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": "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": "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=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": "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": "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": "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,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": "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": "#!/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": "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": "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\""}], "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# 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# 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# 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"} {"nl": {"description": "When Valera was playing football on a stadium, it suddenly began to rain. Valera hid in the corridor under the grandstand not to get wet. However, the desire to play was so great that he decided to train his hitting the ball right in this corridor. Valera went back far enough, put the ball and hit it. The ball bounced off the walls, the ceiling and the floor corridor and finally hit the exit door. As the ball was wet, it left a spot on the door. Now Valera wants to know the coordinates for this spot.Let's describe the event more formally. The ball will be considered a point in space. The door of the corridor will be considered a rectangle located on plane xOz, such that the lower left corner of the door is located at point (0,\u20090,\u20090), and the upper right corner is located at point (a,\u20090,\u2009b) . The corridor will be considered as a rectangular parallelepiped, infinite in the direction of increasing coordinates of y. In this corridor the floor will be considered as plane xOy, and the ceiling as plane, parallel to xOy and passing through point (a,\u20090,\u2009b). We will also assume that one of the walls is plane yOz, and the other wall is plane, parallel to yOz and passing through point (a,\u20090,\u2009b).We'll say that the ball hit the door when its coordinate y was equal to 0. Thus the coordinates of the spot are point (x0,\u20090,\u2009z0), where 0\u2009\u2264\u2009x0\u2009\u2264\u2009a,\u20090\u2009\u2264\u2009z0\u2009\u2264\u2009b. To hit the ball, Valera steps away from the door at distance m and puts the ball in the center of the corridor at point . After the hit the ball flies at speed (vx,\u2009vy,\u2009vz). This means that if the ball has coordinates (x,\u2009y,\u2009z), then after one second it will have coordinates (x\u2009+\u2009vx,\u2009y\u2009+\u2009vy,\u2009z\u2009+\u2009vz).See image in notes for clarification.When the ball collides with the ceiling, the floor or a wall of the corridor, it bounces off in accordance with the laws of reflection (the angle of incidence equals the angle of reflection). In the problem we consider the ideal physical model, so we can assume that there is no air resistance, friction force, or any loss of energy.", "input_spec": "The first line contains three space-separated integers a,\u2009b,\u2009m (1\u2009\u2264\u2009a,\u2009b,\u2009m\u2009\u2264\u2009100). The first two integers specify point (a,\u20090,\u2009b), through which the ceiling and one of the corridor walls pass. The third integer is the distance at which Valera went away from the door. The second line has three space-separated integers vx,\u2009vy,\u2009vz (|vx|,\u2009|vy|,\u2009|vz|\u2009\u2264\u2009100,\u2009vy\u2009<\u20090,\u2009vz\u2009\u2265\u20090) \u2014 the speed of the ball after the hit. It is guaranteed that the ball hits the door.", "output_spec": "Print two real numbers x0,\u2009z0 \u2014 the x and z coordinates of point (x0,\u20090,\u2009z0), at which the ball hits the exit door. The answer will be considered correct, if its absolute or relative error does not exceed 10\u2009\u2009-\u20096.", "sample_inputs": ["7 2 11\n3 -11 2", "7 2 11\n4 -3 3"], "sample_outputs": ["6.5000000000 2.0000000000", "4.1666666667 1.0000000000"], "notes": "Note"}, "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 tempotime:\n position=[position[i]+vitesse[i]*min(time,necessary) for i in range(3)]\n if time 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\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) 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"} {"nl": {"description": "Polycarp loves ciphers. He has invented his own cipher called repeating.Repeating cipher is used for strings. To encrypt the string $$$s=s_{1}s_{2} \\dots s_{m}$$$ ($$$1 \\le m \\le 10$$$), Polycarp uses the following algorithm: he writes down $$$s_1$$$ ones, he writes down $$$s_2$$$ twice, he writes down $$$s_3$$$ three times, ... he writes down $$$s_m$$$ $$$m$$$ times. For example, if $$$s$$$=\"bab\" the process is: \"b\" $$$\\to$$$ \"baa\" $$$\\to$$$ \"baabbb\". So the encrypted $$$s$$$=\"bab\" is \"baabbb\".Given string $$$t$$$ \u2014 the result of encryption of some string $$$s$$$. Your task is to decrypt it, i.\u2009e. find the string $$$s$$$.", "input_spec": "The first line contains integer $$$n$$$ ($$$1 \\le n \\le 55$$$) \u2014 the length of the encrypted string. The second line of the input contains $$$t$$$ \u2014 the result of encryption of some string $$$s$$$. It contains only lowercase Latin letters. The length of $$$t$$$ is exactly $$$n$$$. It is guaranteed that the answer to the test exists.", "output_spec": "Print such string $$$s$$$ that after encryption it equals $$$t$$$.", "sample_inputs": ["6\nbaabbb", "10\nooopppssss", "1\nz"], "sample_outputs": ["bab", "oops", "z"], "notes": null}, "positive_code": [{"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=1\na=''\nwhile s!=\"\":\n a+=s[0]\n s=s[i:]\n i+=1\n \nprint(a)\n "}, {"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": "t=int(input())\nif t==1:\n print(input())\nelse:\n g=input()\n count=1\n pos=0\n t-=1\n while posn:\n print r\n exit(0)"}, {"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": "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": "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": "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": "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 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": "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": "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": "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(j0:\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()\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": "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": "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": "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": "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": "## 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": "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())\ns=input()\na=0 \ni=0\nemp=''\n\nwhile(an:\n print r\n exit(0)"}, {"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": "#!/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 \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=input();txt=raw_input();i=0;ans=''\nwhile i 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())\ns=input()\nt=1\nt1=1\na=[]\ni=0\nt=1\nwhile(i= n:\n break\n ans.append(s[cnt])\n cnt += (i+1)\nprint(\"\".join(ans))\n\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": "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": "\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": "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()\nt = []\ninc = int(0)\nif 1<=n and n<=55 and len(s)==n:\n i = 0\n while i=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": "n=int(input())\na=input()\ni=1\nsum=0\nwhile sum= 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())\nst = input()\ns = \"\"\nc = 0\nj = 1\nwhile c=n:\n break\n t+=s[i]\n i+=j+1\nprint t"}, {"source_code": "n = int(input())\ns = input()\na = ''\ni = 0\nj=1\nwhile(i n-1:\n\t\tbreak\n\telse:\n\t\tans += s[z+i]\n\t\tz += i\nprint ans"}, {"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 = 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": "j, n, a = 0, int(input()), input()\nfor i in range(n):\n j+=i\n if j0:\n ans = ans + st[i]\n i = i+z\n z+=1\n\nprint(ans)\n"}, {"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": "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": "\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": "a = input()\nb = input()\nz = 1\nx = b[0]\ni = 0\nwhile i (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())\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 0:\n ans.append(s[-1])\n for j in xrange(i):\n s.pop()\n i += 1\nprint ''.join(ans)"}, {"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": "n=int(input())\ns=input()\nans,i,k='',0,1\nwhile i\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 \n fflush(stdout);\n or\n #import \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": "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)"}, {"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": "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()\nres_s = s[0]\ni = 1\ncount = 1\nwhile i= len(s):\n break\n #print(i)\n decrypt[i-1] = s[pointer]\n pointer += 1\nprint(''.join(decrypt).strip())\n"}, {"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)"}], "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)//20:\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= 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(j0:\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 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 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=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\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+11:\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 ks):\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 i0:\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 len(a):\n break\n"}, {"source_code": "nbr =int(input()) \ns = input() \nres=\"\" \nres =res+s[0]\ni=1 \ncpt =0 \nwhile(i 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": "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": "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 b1b1:\n\tif b1b1)*(1+(r-b1)//c))\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": "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 >= 0:\n\t\treturn a % b\n\treturn - ((-a)%b)\ndef extended_gcd(a, b):\n\ttmp1 = a\n\ttmp2 = b\n\txx = 0\n\ty = 0\n\tyy = 1\n\tx = 1\n\twhile b != 0:\n\t\tq = a//b\n\t\tt = b\n\t\tb = mod(a,b)\n\t\ta = t\n\t\ttt = xx\n\t\txx = x-q*xx\n\t\tx = t\n\t\tt = yy\n\t\tyy = y-q*yy\n\t\ty = t;\n\tassert(a == tmp1*x+tmp2*y)\n\treturn (a,x,y)\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\t#print((R-b1-a1*x) /( a1*c1) ,(R-b2-a2*y)/ (a2*c2))\n\t#print((L-b1-a1*x)/(c1*a1) ,(L-b2-a2*y)/(c2*a2))\n\t#print(-x/c1,-y/c2)\n\t#print(bajo1,tope1)\n\t\n\t#print(bajo2,tope2)\n\t#print(bajo3)\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 math import gcd\ndef exd_gcd(a, b):\n # always return as POSITIVE presentation\n if a % b == 0:\n return 0, (1 if b > 0 else -1)\n x, y = exd_gcd(b, a % b)\n return y, x - a // b * y\ndef interval_intersect(a, b, c, d):\n if b <= a or d <= c:\n return 0\n if c < a:\n a, b, c, d = c, d, a, b\n if c < b:\n return min(b, d) - c\n else:\n return 0\ndef ceil(a, b):\n return (a + b - 1) // b\n\na1, b1, a2, b2, L, R = map(int, input().split())\ng = gcd(a1, a2)\nif (b1 - b2) % g != 0:\n print(0)\n exit(0)\nk, l = exd_gcd(a1, a2)\nl = -l\nk *= (b2 - b1) // g\nl *= (b2 - b1) // g\nd1 = a2 // g\nd2 = a1 // g\nassert(k * a1 + b1 == l * a2 + b2)\narb = 3238\nassert((k + arb * d1) * a1 + b1 == (l + arb * d2) * a2 + b2)\nL1, R1 = ceil(max(0, ceil(L - b1, a1)) - k, d1), ((R - b1) // a1 - k) // d1\nL2, R2 = ceil(max(0, ceil(L - b2, a2)) - l, d2), ((R - b2) // a2 - l) // d2\nprint(interval_intersect(L1, R1 + 1, L2, R2 + 1))\n"}, {"source_code": "#!/usr/bin/env\tpython\n#-*-coding:utf-8 -*-\nimport math\na1,b1,a2,b2,l,r=map(int,input().split())\nif b1b1:\n\tif b1b1)*(1+(r-b1)//c))"}, {"source_code": "def exgcd(i, j):\n if j == 0:\n return 1, 0, i\n u, v, d = exgcd(j, i % j)\n return v, u - v * (i // j), d\nma, ra, mb, rb, L, R = map(int, input().split(' '))\nL = max(L, ra, rb)\nif L > R:\n print(0)\n exit(0)\nif ra > rb:\n ma, ra, mb, rb = mb, rb, ma, ra\n_, _, md = exgcd(ma, mb)\nif md != 1:\n if (rb - ra) % md != 0:\n print(0)\n exit(0)\n m = ma * mb // md\n rev, _, _ = exgcd(ma // md, mb // md)\n rev = (rev % (mb // md) + mb // md) % (mb // md)\n r = ma * (rb - ra) // md * rev + ra\n r = (r % m + m) % m\nelse:\n m = ma * mb\n bv, av, _ = exgcd(ma, mb)\n r = ra * mb * av + rb * ma * bv\n r = (r % m + m) % m\ndef calc(i):\n return (i - r) // m\nprint(calc(R) - calc(L - 1))\n"}, {"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\n a1, a2=a2, a1\n b1, b2=b2, b1\n\nL=max(b1, b2, L) #accounts for >=0 restriction\n\nif L>R: #checking this once again\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 #solution for x is x=q (mod p), follows from a1coeff in gcd linear combination thing\n print (R-q)/p - (L-q-1)/p\n else:\n print 0\n\n\n \n"}, {"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\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"}, {"source_code": "import sys\nfrom sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (int(a),int(1),int(0))\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return int(g),int(x),int(y)\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = int(a1)\nB = int(a2)\nC = int(b2 - b1)\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print(0)\n sys.exit(0)\n\nX = int(X*C/G)\nY = int(Y*C/G)\n\nK = int(max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] ))\n\n# print(\"A\",A,\"B\",B)\n# print(\"G\",G)\n# print(\"X\",X,\"Y\",Y)\n# print(\"K\",K)\n\n# print(\"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 ))\n# print(\"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 ))\n# print(\"S\", a1 * (X + B*K/G) + b1, \"T\", a2 * (-Y + A*K/G) + b2)\n\nK = max( [ K, int(math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) )) ] )\n\nU = math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) + 0.00001 )\n\n# print(K,U)\n\nwhile a1 * (X + B*K/G) + b1 < L:\n K = K + 1\n\n# print(K, a1 * (X + B*K/G) + b1)\n\nif K > U or a1 * (X + B*K/G) + b1 > R:\n ANS = 0;\nelse:\n ANS = U - K + 1\n\nprint(max( [ 0, int(ANS) ] ))\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\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>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 (k1:\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\na1,b1,a2,b2,l,r=map(int,raw_input().split())\n\nif b1b1:\n if b1b1):\n print (1+(r-b1)/var)\nelse:\n print \"0\"\n\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 b2ls: print(0)\n else: print(ls-li+1)\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": "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": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n #print(gg, X, Y, y, a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n if X >= 0:\n X -= (X//dd) * dd\n else:\n g = X//dd\n if g * dd > X:\n g += 1\n X -= g * dd\n \n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n \n if X > k:\n return 0\n return (k-X)//dd + 1\n\n\na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L-b1)//a1\nif d1 < 0:\n d1 = 0\nd1 *= a1\nd1 += b1\nd2 = (L-b2)//a2\nif d2 < 0:\n d2 = 0\nd2 *= a2\nd2 += b2\n\nwhile d1 < L:\n d1 += a1\nwhile d2 < L:\n d2 += a2\n\n#print(d1, d2, L, R)\n\nif R < max(d1, d2):\n print(0)\nelse:\n \n if d1 > d2 or (d1 == d2 and a1 < a2):\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))"}, {"source_code": "from fractions import gcd\na1,b1,a2,b2,l,r=map(int,input().split())\n\nif b1b1:\n if b1b1):\n print (int(1+(r-b1)//var))\nelse:\n print (\"0\")\n\n\n\n"}, {"source_code": "import sys, collections\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 // gcd(a, b) * b\n\ndef extgcd(a, b):\n if b == 0: return 1, 0\n x, y = extgcd(b, a % b)\n return y, x - a // b * y\n\ndef prime_factor(n):\n res = collections.defaultdict(int)\n\n i = 2\n while i * i <= n:\n cnt = 0\n while n % i == 0:\n n //= i\n cnt += 1\n if cnt > 0: res[i] = cnt\n i += 1\n if n != 1: res[n] = 1\n\n return res\n\ndef modinv(a, mod):\n if a == 0: return -1\n if gcd(a, mod) != 1: return -1\n return extgcd(a, mod)[0] % mod\n\ndef normalize(a1, a2):\n p1 = prime_factor(a1)\n p2 = prime_factor(a2)\n\n keys = list(set(p1.keys()) | set(p2.keys()))\n\n r1 = 1\n r2 = 1\n for k in keys:\n if p1[k] >= p2[k]:\n r1 *= k ** p1[k]\n else:\n r2 *= k ** p2[k]\n return r1, r2\n\ndef solve(a1, b1, a2, b2):\n g = gcd(a1, a2)\n if (b1 - b2) % g != 0: return -1\n\n a1, a2 = normalize(a1, a2)\n u = b1 % a1\n inv = modinv(a1, a2)\n v = (b2 - u) * inv % a2\n return u + v * a1\n\ndef f(x0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if x0 + 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)\nx0 = solve(a1, b1, a2, b2)\n\nif x0 == -1:\n print(0)\n sys.exit()\n\nx0 -= T * 10 ** 36\n\nok = 10 ** 60\nng = -1\n\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\nx0 += ok * T\n\n# L <= x0 + kT < R + 1\nans = f(x0, T, R + 1) - f(x0, T, L)\n\nprint(ans)"}, {"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": "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": "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"}], "negative_code": [{"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 (b2 - b1) % 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": "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, l - coeff, r - coeff\nod, x1, y1 = nod(a1, -a2)\nif b2 % od != 0:\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 # 2x - 3y = 3\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\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 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 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": "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)\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": "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\nprint(max(0, ri - le + 1))\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, ri + 1) :\n X = x0 + B * k // g\n if X >= 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": "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 if u >= 0 :\n if u % v != 0 :\n return int(u // v + 1)\n else :\n return int(u // v)\n else :\n return int(-((-u) // v))\n\ndef my_floor(u, v) :\n if v < 0 :\n u *= -1\n v *= -1\n if u >= 0 :\n return int(u // v)\n else :\n if (-u) % v != 0 :\n return int(-((-u) // v) - 1)\n else :\n return int(-((-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 my_ceil(R - b1 - a1 * x0, a1 * B / g),\n my_ceil(y0 * a2 + b2 - R, a2 * A / g)\n ])\n\nri = min([\n my_floor(L - b1 - a1 * x0, a1 * B / g),\n my_floor(y0 * a2 + b2 - L, a2 * A / g),\n my_floor(-x0, B / g),\n my_floor(y0, A / g)\n ])\n\nprint(max(int(0), ri - le + 1))\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 if x > R:\n print (0)\n return\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+med*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": "def 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\nif c%g != 0 :\n print (0)\n exit (0)\ni = -(a*(x*c)+aa)\nstep = a*b//g\nf = max (0,(l-i)//step)\ns = (r-i)//step\nprint (abs (s-f)+1)"}, {"source_code": "def 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\nif c%g != 0 :\n print (0)\n exit (0)\ni = a*(x*c)+aa\nstep = a*b//g\n\n# shift i to la,lb\nif i >= max(aa,bb) :\n i -= (i-max(aa,bb))//step * step\nelse :\n i += ((max(aa,bb)-i)//step + 1) * step\n\nf = (l-i)//step\nif (l-i) % step != 0 : f+=1\ns = (r-i)//step\n#print(i,step,f,s)\nprint (max(0,s-f+1))"}, {"source_code": "def 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\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\nif i >= max(aa,bb) :\n i -= (i-max(aa,bb))//step * step\nelif i <= max(aa,bb) :\n i += ((max(aa,bb)-i)//step + 1) * 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 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 i -= ((i-max(aa,bb))//step + (1 if (i-max(aa,bb))%step!=0 else 0)) * 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": "def 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\nif c%g != 0 :\n print (0)\n exit (0)\ni = a*(x*c)+aa\nstep = a*b//g\n\n# shift i to la,lb\nif i >= max(aa,bb) :\n i -= (i-max(aa,bb))//step * step\nelif i <= max(aa,bb) :\n i += ((max(aa,bb)-i)//step + 1) * 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": "def 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\nif i >= max(aa,bb) :\n i -= (i-max(aa,bb))//step * step\nelif i <= max(aa,bb) :\n i += ((max(aa,bb)-i)//step + 1) * 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 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 i -= int(math.ceil(i-max(aa,bb))/step) * step\nelif i < max(aa,bb) :\n i += int(math.ceil(max(aa,bb)-i)/step) * 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": "def 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\nif c%g != 0 :\n print (0)\n exit (0)\ni = a*(x*c)+aa\nstep = a*b//g\n\n# shift i to la,lb\nif i >= max(aa,bb) :\n i -= (i-max(aa,bb))//step * step\nelse :\n i += ((max(aa,bb)-i)//step + 1) * step\n\nf = max (0,(l-i)//step)\ns = (r-i)//step\n#print(i,step,f,s)\nprint (max(0,s-f+1))"}, {"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 i -= ((i-max(aa,bb))//step + (1 if (i-max(aa,bb))%step!=0 else 0)) * 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\nprint(i,step,f,s)\nprint (max(0,s-f+1))"}, {"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 print(max(0, (R - X) // LCM + 1))"}, {"source_code": "from collections import defaultdict\nimport sys\n\ndef gcd(a1, a2):\n if a2 == 0:\n return a1\n else:\n return gcd(a2, a1 % a2)\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n a1, b1, a2, b2, L, R = map(int, input().split())\n LCM = a1 * a2 // gcd(a1, a2)\n if abs(b1 - b2) % gcd(a1, a2) != 0:\n print(0)\n sys.exit(0)\n for i in range(max([b1, b2, L]), R + 1):\n if (i - b1) % a1 == 0 and (i - b2) % a2 == 0:\n print((R - i) // LCM + 1)\n break\n "}, {"source_code": "from collections import defaultdict\nimport sys\n\ndef gcd(a1, a2):\n if a2 == 0:\n return a1\n else:\n return gcd(a2, a1 % a2)\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n a1, b1, a2, b2, L, R = map(int, input().split())\n LCM = a1 * a2 // gcd(a1, a2)\n for i in range(L, R + 1):\n if (i - b1) % a1 == 0 and (i - b2) % a2 == 0:\n print((R - i) // LCM + 1)\n sys.exit(0)\n print(0)"}, {"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 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 = egcd(a1, a2)[0]\n g += LCM * math.ceil((L - egcd(a1, a2)[0]) / LCM)\n print(max(0, (R - g) // LCM + 1))"}, {"source_code": "from math import gcd\ndef exd_gcd(a, b):\n # always return as POSITIVE presentation\n if a % b == 0:\n return 0, (1 if b > 0 else -1)\n x, y = exd_gcd(b, a % b)\n return y, x - a // b * y\ndef interval_intersect(a, b, c, d):\n if b <= a or d <= c:\n return 0\n if c < a:\n a, b, c, d = c, d, a, b\n if c < b:\n return min(b, d) - c\n else:\n return 0\ndef ceil(a, b):\n return (a + b - 1) // b\n\na1, b1, a2, b2, L, R = map(int, input().split())\ng = gcd(a1, a2)\nif (b1 - b2) % g != 0:\n print(0)\n exit(0)\nk, l = exd_gcd(a1, a2)\nl = -l\nk *= (b2 - b1) // g\nl *= (b2 - b1) // g\nd1 = a2 // g\nd2 = a1 // g\nassert(k * a1 + b1 == l * a2 + b2)\narb = 3238\nassert((k + arb * d1) * a1 + b1 == (l + arb * d2) * a2 + b2)\nL1, R1 = ceil(max(0, ceil(L - b1, a1)) - k, d1), ((R - b1) // a1 - k) // d1\nL2, R2 = ceil(max(0, ceil(L - b2, a2)) - k, d2), ((R - b2) // a2 - k) // d2\nprint(interval_intersect(L1, R1 + 1, L2, R2 + 1))\n"}, {"source_code": "from math import gcd\ndef exd_gcd(a, b):\n # always return as POSITIVE presentation\n if a % b == 0:\n return 0, (1 if b > 0 else -1)\n x, y = exd_gcd(b, a % b)\n return y, x - a // b * y\ndef interval_intersect(a, b, c, d):\n if b <= a or d <= c:\n return 0\n if c < a:\n a, b, c, d = c, d, a, b\n if c < b:\n return min(b, d) - c\n else:\n return 0\ndef ceil(a, b):\n return (a + b - 1) // b\n\na1, b1, a2, b2, L, R = map(int, input().split())\ng = gcd(a1, a2)\nif (b1 - b2) % g != 0:\n print(0)\n exit(0)\nk, l = exd_gcd(a1, a2)\nl = -l\nk *= (b2 - b1) // g\nl *= (b2 - b1) // g\nd1 = a2 // g\nd2 = a1 // g\nassert(k * a1 + b1 == l * a2 + b2)\narb = 3238\nassert((k + arb * d1) * a1 + b1 == (l + arb * d2) * a2 + b2)\nL1, R1 = ceil(max(0, ceil(L - b1, a1)) - k, d1), ((R - b1) // a1 - k) // d1\nL2, R2 = ceil(max(0, ceil(L - b2, a2)) - l, d2), ((R - b2) // a2 - l) // d2\nprint(L1 * d1 + k, R1 * d1 + k)\nprint(L2 * d2 + k, R2 * d2 + k)\nprint(interval_intersect(L1, R1 + 1, L2, R2 + 1))\n"}, {"source_code": "def exgcd(i, j):\n if j == 0:\n return 1, 0, i\n u, v, d = exgcd(j, i % j)\n return v, u - v * i // j, d\n\nma, ra, mb, rb, L, R = map(int, input().split(' '))\nL = max(L, ra, rb)\n\nif L > R:\n print(0)\n exit(0)\n\nra %= ma\nrb %= mb\n\nif ra > rb:\n ma, ra, mb, rb = mb, rb, ma, ra\n\n_, _, md = exgcd(ma, mb)\n\nif md != 1:\n if (rb - ra) % md != 0:\n print(0)\n exit(0)\n m = ma * mb // md\n rev, _, _ = exgcd(ma // md, mb // md)\n rev = (rev % (mb // md) + mb // md) % (mb // md)\n r = ma * (rb - ra) // md * rev + ra\n r = (r % m + m) % m\nelse:\n m = ma * mb\n bv, av, _ = exgcd(ma, mb)\n r = ra * mb * av + rb * ma * bv\n r = (r % m + m) % m\n\ndef calc(i):\n return (i - r) // m\n\nprint(calc(R) - calc(L - 1))\n"}, {"source_code": "def exgcd(i, j):\n if j == 0:\n return 1, 0, i\n u, v, d = exgcd(j, i % j)\n return v, u - v * i // j, d\n\nma, ra, mb, rb, L, R = map(int, input().split(' '))\n\nra %= ma\nrb %= mb\n\nif ra > rb:\n ma, ra, mb, rb = mb, rb, ma, ra\n\n_, _, md = exgcd(ma, mb)\n\nif md != 1:\n if (rb - ra) % md != 0:\n print(0)\n exit(0)\n m = ma * mb // md\n rev, _, _ = exgcd(ma // md, mb // md)\n rev = (rev % (mb // md) + mb // md) % (mb // md)\n r = ma * (rb - ra) // md * rev + ra\n r = (r % m + m) % m\nelse:\n m = ma * mb\n bv, av, _ = exgcd(ma, mb)\n r = ra * mb * av + rb * ma * bv\n r = (r % m + m) % m\n\ndef calc(i):\n return (i - r) // m\n\nprint(calc(R) - calc(L - 1))\n"}, {"source_code": "def euc(a, b): #requires a>=b\n if a%b==0:\n return [b, 0, 1]\n else:\n return [euc(b, a%b)[0], euc(b, a%b)[2], euc(b, a%b)[1]-euc(b, a%b)[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\n a1, a2=a2, a1\n b1, b2=b2, b1\n\nL=max(b1, b2, L) #accounts for >=0 restriction\n\nif 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"}, {"source_code": "import sys\nfrom sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (a,1,0)\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return g,x,y\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = a1\nB = a2\nC = b2 - b1\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print 0\n sys.exit(0)\n\nX = X*C/G\nY = Y*C/G\n\nK = max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] )\n\n#print int(K)\n\n#print \"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 )\n#print \"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 )\n#print \"S\", a1 * (X + B*K/G) + b1, \"T\", a2 * (-Y + A*K/G) + b2\n\nK = max( [ K, math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) ) ] )\n\nANS = math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) ) - K + 1\n\nprint max( [ 0, int(ANS) ] )\n"}, {"source_code": "from sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (a,1,0)\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return g,x,y\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = a1\nB = a2\nC = b2 - b1\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print 0\n sys.exit(0)\n\nX = X*C/G\nY = Y*C/G\n\nK = max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] )\n\nprint int(K)\n\nprint \"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 )\nprint \"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 )\nprint \"S\", a1 * (X + B*K/G) + b1, \"T\", a2 * (-Y + A*K/G) + b2\n\nK = max( [ K, math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) ) ] )\n\nANS = math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) ) - K + 1\n\nprint max( [ 0, int(ANS) ] )\n"}, {"source_code": "import sys\nfrom sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (a,1,0)\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return g,x,y\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = a1\nB = a2\nC = b2 - b1\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print 0\n sys.exit(0)\n\nX = X*C/G\nY = Y*C/G\n\nK = int(max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] ))\n\n# print \"A\",A,\"B\",B\n# print \"G\",G\n# print \"X\",X,\"Y\",Y\n# print \"K\",int(K)\n\n# print \"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 )\n# print \"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 )\n# print \"S\", a1 * (X + B*int(K)/G) + b1, \"T\", a2 * (-Y + A*int(K)/G) + b2\n\nK = int(max( [ K, math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) ) ] ))\n\nU = int(math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) ))\n\nwhile a1 * (X + B*int(K)/G) + b1 < L:\n K = K + 1\n\nif K > U or a1 * (X + B*int(K)/G) + b1 > R:\n ANS = 0;\nelse:\n ANS = U - K + 1\n\nprint max( [ 0, int(ANS) ] )\n"}, {"source_code": "import sys\nfrom sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (a,1,0)\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return g,x,y\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = a1\nB = a2\nC = b2 - b1\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print 0\n sys.exit(0)\n\nX = X*C/G\nY = Y*C/G\n\nK = int(max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] ))\n\n# print \"A\",A,\"B\",B\n# print \"G\",G\n# print \"X\",X,\"Y\",Y\n# print \"K\",int(K)\n\n# print \"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 )\n# print \"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 )\n# print \"S\", a1 * (X + B*int(K)/G) + b1, \"T\", a2 * (-Y + A*int(K)/G) + b2\n\nK = int(max( [ K, math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) ) ] ))\n\nU = int(math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) ))\n\nwhile a1 * (X + B*int(K)/G) + b1 < L:\n K = K + 1\n\nif K > U:\n ANS = 0;\nelse:\n ANS = U - K + 1\n\nprint max( [ 0, int(ANS) ] )\n"}, {"source_code": "from sys import stdin,stdout\nimport math\n\ndef gcd_ext(a, b):\n if b == 0:\n return (a,1,0)\n else:\n g,x,y = gcd_ext(b, a%b)\n t = x;\n x = y;\n y = t - a/b*y\n return g,x,y\n\na1,b1,a2,b2,L,R = [ int(x) for x in stdin.readline().rstrip().split() ]\n\nA = a1\nB = a2\nC = b2 - b1\n\nG,X,Y = gcd_ext( A, B )\n\nif C % G != 0:\n print 0\n sys.exit(0)\n\nX = X*C/G\nY = Y*C/G\n\nK = max( [ math.ceil( -X*G/float(B) ), math.ceil( Y*G/float(A) ) ] )\n\n# print int(K)\n\n# print \"LOWER\", (L - b1 - a1 * X) * G / float( B * a1 ), (L - b2 + a2 * Y) * G / float( A * a2 )\n# print \"UPPER\", (R - b1 - a1 * X) * G / float( B * a1 ), (R - b2 + a2 * Y) * G / float( A * a2 )\n# print \"S\", a1 * (X + B*K/G) + b1, \"T\", a2 * (-Y + A*K/G) + b2\n\nK = max( [ K, math.ceil( (L - b1 - a1 * X) * G / float( B * a1 ) ) ] )\n\nANS = math.floor( (R - b1 - a1 * X) * G / float( B * a1 ) ) - K + 1\n\nprint int(ANS)\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>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 (k1:\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\nx = (b1%(a1/g) +(a1/g))%(a1/g) # modulo a1/g\ny = (b2%a2 + a2)%a2 # modulo a2\n\nP = [x,y]\nQ = [a1/g,a2]\nrem = crt(Q,P)\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": "a1,b1,a2,b2,l,r=map(int,raw_input().split())\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\n\nlst1=[]\nlst2=[]\nfor i in range(ks1,ke1+2):\n if(a1*i+b1>=l and a1*i+b1<=r):\n lst1.append(a1*i+b1)\nfor i in range(ks2,ke2+2):\n if(a2*i+b2>=l and a2*i+b2<=r):\n lst2.append(a2*i+b2)\n \nset1=set(lst1)\nset2=set(lst2)\n\nl=len(set1.intersection(set2))\nprint l\n \n"}, {"source_code": "a1,b1,a2,b2,l,r=map(int,raw_input().split())\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\n\nlst1=[]\nlst2=[]\nfor i in range(ks1-1,ke1+2):\n if(a1*i+b1>=l or a1*i+b1<=r):\n lst1.append(a1*i+b1)\nfor i in range(ks2-1,ke2+2):\n if(a2*i+b2>=l or a2*i+b2<=r):\n lst2.append(a2*i+b2)\n \nset1=set(lst1)\nset2=set(lst2)\nl=len(set1.intersection(set2))\nprint l\n \n"}, {"source_code": "a1,b1,a2,b2,l,r=map(int,raw_input().split())\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\n\nlst1=[]\nlst2=[]\nfor i in range(ks1,ke1+1):\n lst1.append(a1*i+b1)\nfor i in range(ks2,ke2+1):\n lst2.append(a2*i+b2)\n \nset1=set(lst1)\nset2=set(lst2)\nl=len(set1.intersection(set2))\nprint l"}, {"source_code": "from fractions import gcd\na1,b1,a2,b2,l,r=map(int,raw_input().split())\nks1=(l-b1)/a1\nke1=(r-b1)/a1\nks2=(l-b2)/a2\nke2=(r-b2)/a2\nb1=(b1-l)%a1+l\nb2=(b2-l)%a2+l\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 b1b1):\n print (1+(r-b1)/var)\nelse:\n print \"0\"\n\n \n"}, {"source_code": "\nimport 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 range(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 if x1%t or 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))\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 # b1,b2=0 leads here\n ans=1\n if b1!=l and (l-b1)%a1!=0: ans=0\n if b2!=l and (l-b2)%a2!=0: ans=0\n print(ans)\nelif gcd(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": "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 lly = sign(L - b2 + a2 - 1) * abs(L - b2 + a2 - 1) / a2\n rry = sign(R - b2) * abs(R - b2) / a2\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 base\n #print (rr * a2 + b2 - base) / lcm , (ll * a2 + b2 - 1 - base) / lcm\n return (rr * a2 + b2 - base) / lcm - (ll * a2 + b2 - 1 - base) / lcm\n\nassert solve(2, 4, 3, 0, 6, 17) == 2\nassert solve(2, 0, 3, 3, 5, 21) == 3\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": "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 llx = max(llx, 0)\n rrx = max(rrx, 0)\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 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 base\n #print (rr * a2 + b2 - base) / lcm , (ll * a2 + b2 - 1 - base) / lcm\n return (rr * a2 + b2 - base) / lcm - (ll * a2 + b2 - 1 - base) / lcm\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)\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": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n X -= (X//dd) * dd\n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n \n if X > k:\n return 0\n \n return (k-X)//dd + 1\n \n \na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L-b1+a1-1)//a1\nd1 *= a1\nd1 -= b1\nd2 = (L-b2+a2-1)//a2\nd2 *= a2\nd2 -= b2\n\nif R < max(d1, d2):\n print(0)\nelse:\n if d1 > d2:\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))"}, {"source_code": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n X -= (X//dd) * dd\n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n \n if X > k:\n return 0\n \n return (k-X)//dd + 1\n \n \na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L-b1)//a1\nif d1 < 0:\n d1 = 0\nd1 *= a1\nd1 -= b1\nd2 = (L-b2)//a2\nif d2 < 0:\n d2 = 0\nd2 *= a2\nd2 -= b2\n\nwhile d1 < L:\n d1 += a1\nwhile d2 < L:\n d2 += a2\n\n#print(d1, d2, L, R)\nif R < max(d1, d2):\n print(0)\nelse:\n if d1 > d2 or (d1 == d2 and a1 < a2):\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))"}, {"source_code": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n if X >= 0:\n X -= (X//dd) * dd\n else:\n g = X//dd\n if g * dd > X:\n g += 1\n X -= g * dd\n \n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n \n if X > k:\n return 0\n return (k-X)//dd + 1\n\n\na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L-b1)//a1\nif d1 < 0:\n d1 = 0\nd1 *= a1\nd1 += b1\nd2 = (L-b2)//a2\nif d2 < 0:\n d2 = 0\nd2 *= a2\nd2 += b2\n\nwhile d1 < L:\n d1 += a1\nwhile d2 < L:\n d2 += a2\n\n#print(d1, d2, L, R)\n\nif R < max(d1, d2):\n print(0)\nelse:\n if a1 < a2:\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))\n"}, {"source_code": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n if X >= 0:\n X -= (X//dd) * dd\n else:\n g = X//dd\n if g * dd > X:\n g += 1\n X -= g * dd\n \n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n \n if X > k:\n return 0\n return (k-X)//dd + 1\n\n\na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L-b1)//a1\nif d1 < 0:\n d1 = 0\nd1 *= a1\nd1 += b1\nd2 = (L-b2)//a2\nif d2 < 0:\n d2 = 0\nd2 *= a2\nd2 += b2\n\nwhile d1 < L:\n d1 += a1\nwhile d2 < L:\n d2 += a2\n\n#print(d1, d2, L, R)\n\nif R < max(d1, d2):\n print(0)\nelse:\n if d1 > d2 or (d1 == d2 and a1 < a2):\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))\n"}, {"source_code": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n X -= (X//dd) * dd\n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n if X > k:\n return 0\n return (k-X)//dd + 1\n \n \na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L+b1+a1-1)//a1\nd1 *= a1\nd1 += b1\nd2 = (L+b2+a2-1)//a2\nd2 *= a2\nd2 += b2\n\nif R < max(d1, d2):\n print(0)\nelse:\n if d1 > d2:\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))"}, {"source_code": "def gcd(a, b):\n if a==0:\n return (b, 0, 1)\n g, x1, y1 = gcd(b%a, a)\n x = y1 - (b // a) * x1\n y = x1\n return (g, x, y)\n\t\ndef solve(a, b, x, y, r):\n k = (r-x)//a\n y = (-y) % b\n y = (y-x) % b\n \n gg, X, Y = gcd(a, b)\n if y % gg != 0:\n return 0\n X *= y // gg\n dd = b//gg\n X -= (X//dd) * dd\n if X < 0:\n X += dd\n elif X >= dd:\n X -= dd\n \n if X > k:\n return 0\n \n return (k-X)//dd + 1\n \n \na1, b1, a2, b2, L, R = map(int, input().split())\nd1 = (L-b1)//a1\nif d1 < 0:\n d1 = 0\nd1 *= a1\nd1 -= b1\nd2 = (L-b2)//a2\nif d2 < 0:\n d2 = 0\nd2 *= a2\nd2 -= b2\n\n\n\nif R < max(d1, d2):\n print(0)\nelse:\n if d1 > d2:\n print(solve(a1, a2, d1, d2, R))\n else:\n print(solve(a2, a1, d2, d1, R))"}, {"source_code": "from fractions import gcd\na1,b1,a2,b2,l,r=map(int,input().split())\n\nif b1b1:\n if b1b1):\n print (1+(r-b1)//var)\nelse:\n print (\"0\")\n\n\n\n"}, {"source_code": "from fractions import gcd\na1,b1,a2,b2,l,r=map(int,input().split())\n\nif b1b1:\n if b1b1):\n print (1+(r-b1)/var)\nelse:\n print (\"0\")\n\n\n\n"}, {"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 // gcd(a, b) * b\n\ndef extgcd(a, b):\n if b == 0: return 1, 0\n x, y = extgcd(b, a % b)\n return y, x - a // b * y\n\ndef modinv(a, mod):\n if a == 0: return -1\n if gcd(a, mod) != 1: return -1\n return extgcd(a, mod)[0] % mod\n\ndef solve(a1, b1, a2, b2):\n g = gcd(a1, a2)\n a1 //= g\n a2 *= g\n if a1 == a2:\n if b1 % a1 == b2 % a2: return b1\n return -1\n u = b1 % a1\n inv = modinv(a1, a2)\n if inv == -1: return -1\n v = (b2 - u) * inv % a2\n return u + v * a1\n\ndef f(x0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if x0 + 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)\nx0 = solve(a1, b1, a2, b2)\n\nif x0 == -1:\n print(0)\n sys.exit()\n\nx0 -= T * 10 ** 36\n\nok = 10 ** 60\nng = -1\n\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\nx0 += ok * T\n\n# L <= x0 + kT < R + 1\nans = f(x0, T, R + 1) - f(x0, T, L)\n\nprint(ans)"}, {"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 // gcd(a, b) * b\n\ndef extgcd(a, b):\n if b == 0: return 1, 0\n x, y = extgcd(b, a % b)\n return y, x - a // b * y\n\ndef modinv(a, mod):\n if a == 0: return -1\n if gcd(a, mod) != 1: return -1\n return extgcd(a, mod)[0] % mod\n\ndef solve(a1, b1, a2, b2):\n if a1 == a2:\n if b1 % a1 == b2 % a2: return b1\n return -1\n u = b1 % a1\n inv = modinv(a1, a2)\n if inv == -1: return -1\n v = (b2 - u) * inv % a2\n return u + v * a1\n\ndef f(x0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if x0 + 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)\nx0 = solve(a1, b1, a2, b2)\n\nif x0 == -1:\n print(0)\n sys.exit()\n\nx0 -= T * 10 ** 36\n\nok = 10 ** 60\nng = -1\n\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\nx0 += ok * T\n\n# L <= x0 + kT < R + 1\nans = f(x0, T, R + 1) - f(x0, T, L)\n\nprint(ans)"}, {"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 // gcd(a, b) * b\n\ndef extgcd(a, b):\n if b == 0: return 1, 0\n x, y = extgcd(b, a % b)\n return y, x - a // b * y\n\ndef modinv(a, mod):\n if a == 0: return -1\n if gcd(a, mod) != 1: return -1\n return extgcd(a, mod)[0] % mod\n\ndef solve(a1, b1, a2, b2):\n u = b1 % a1\n inv = modinv(a1, a2)\n if inv == -1: return -1\n v = (b2 - u) * inv % a2\n return u + v * a1\n\ndef f(x0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if x0 + 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)\nx0 = solve(a1, b1, a2, b2)\n\nif x0 == -1:\n print(0)\n sys.exit()\n\nx0 -= T * 10 ** 18\n\nok = 10 ** 36\nng = -1\n\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\nx0 += ok * T\n\n# L <= x0 + kT < R + 1\nans = f(x0, T, R + 1) - f(x0, T, L)\n\nprint(ans)"}, {"source_code": "\ndef gcd(a, b):\n if b == 0: return a\n return gcd(b, a % b)\n\ndef lcm(a, b):\n return a // gcd(a, b) * b\n\ndef extgcd(a, b):\n if b == 0: return 1, 0\n x, y = extgcd(b, a % b)\n return y, x - a // b * y\n\ndef modinv(a, mod):\n if a == 0: return -1\n if gcd(a, mod) != 1: return -1\n return extgcd(a, mod)[0] % mod\n\ndef solve(a1, b1, a2, b2):\n u = b1 % a1\n inv = modinv(a1, a2)\n if inv == -1: return -1\n v = (b2 - b1) * inv % a2\n return u + v * a1\n\ndef f(x0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if x0 + 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)\nx0 = solve(a1, b1, a2, b2)\nx0 -= T * 10 ** 18\n\nok = 10 ** 36\nng = -1\n\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\nx0 += ok * T\n\n# L <= x0 + kT < R + 1\nans = f(x0, T, R + 1) - f(x0, T, L)\n\nprint(ans)"}, {"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 // gcd(a, b) * b\n\ndef extgcd(a, b):\n if b == 0: return 1, 0\n x, y = extgcd(b, a % b)\n return y, x - a // b * y\n\ndef modinv(a, mod):\n if a == 0: return -1\n if gcd(a, mod) != 1: return -1\n return extgcd(a, mod)[0] % mod\n\ndef solve(a1, b1, a2, b2):\n u = b1 % a1\n inv = modinv(a1, a2)\n if inv == -1: return -1\n v = (b2 - b1) * inv % a2\n return u + v * a1\n\ndef f(x0, T, v):\n ok = 10 ** 36\n ng = -1\n\n while ok - ng > 1:\n mid = (ok + ng) // 2\n\n if x0 + 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)\nx0 = solve(a1, b1, a2, b2)\n\nif x0 == -1:\n print(0)\n sys.exit()\n\nx0 -= T * 10 ** 18\n\nok = 10 ** 36\nng = -1\n\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n\n val = x0 + T * mid\n k = (val - b1) // a1\n l = (val - b2) // a2\n if k >= 0 and l >= 0:\n ok = mid\n else:\n ng = mid\n\nx0 += ok * T\n\n# L <= x0 + kT < R + 1\nans = f(x0, T, R + 1) - f(x0, T, L)\n\nprint(ans)"}, {"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;\nprint(R//rmod - (L-1)//rmod - 1)\n\n"}], "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4"} {"nl": {"description": "A chessboard n\u2009\u00d7\u2009m in size is given. During the zero minute we repaint all the black squares to the 0 color. During the i-th minute we repaint to the i color the initially black squares that have exactly four corner-adjacent squares painted i\u2009-\u20091 (all such squares are repainted simultaneously). This process continues ad infinitum. You have to figure out how many squares we repainted exactly x times.The upper left square of the board has to be assumed to be always black. Two squares are called corner-adjacent, if they have exactly one common point.", "input_spec": "The first line contains integers n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u20095000). The second line contains integer x (1\u2009\u2264\u2009x\u2009\u2264\u2009109).", "output_spec": "Print how many squares will be painted exactly x times.", "sample_inputs": ["3 3\n1", "3 3\n2", "1 1\n1"], "sample_outputs": ["4", "1", "1"], "notes": null}, "positive_code": [{"source_code": "n, m = map(int, input().split())\nx, v = int(input()), 0\nx1, y1, x2, y2 = x - 1, x - 1, n - x, m - x\nif x1 > x2 or y1 > y2:\n print(0)\n exit()\nfor i in range(x1, x2 + 1):\n if i == x1 or i == x2:\n v += (y2 - y1 + 1) // 2 + ((i + y1) % 2 == 0 and (i + y2) % 2 == 0)\n else:\n v += ((i + y1) % 2 == 0) + ((i + y2) % 2 == 0)\nprint(v)"}, {"source_code": "n, m = map(int, input().split())\nx = int(input())\na = max(0, n - 2 * (x - 1))\nb = max(0, m - 2 * (x - 1))\nsize = a * b - max(0, a - 2) * max(0, b - 2)\nresult = (size + 1) // 2\nprint(result)\n"}, {"source_code": "import itertools\nimport math\n\nn, m = [int(k) for k in input().split()]\nx = int(input())\nif n-2*(x-1) < 1 or m-2*(x-1) < 1:\n print(0)\nelif n-2*(x-1) == 1 or m-2*(x-1) == 1:\n print((n+m-4*(x-1))//2)\nelse: print(n+m-2 - 4*(x-1))\n\n\n\n\n"}, {"source_code": "n,m=map(int,input().split())\nx=int(input())\nw,h=n-(2*x-1),m-(2*x-1)\nif w<0 or h<0:\n print(0)\nelse:\n print(max(w+h,1))\n"}, {"source_code": "import math\na=list(map(int,input().split()))\nx=int(input())\nbt=math.ceil((a[0]*a[1])/2)\nc=[]\nif a[0]>=2 and a[1]>=2:\n k=(math.ceil(a[0]/2)+math.floor(a[0]/2)+math.ceil((a[1]-2)/2)+math.floor((a[1]-2)/2))\nelse:\n k=math.ceil(max(a)/2)+math.floor(max(a)/2)\nwhile True:\n if a[0]<2 or a[1]<2:\n c.append(k)\n break\n c.append(k)\n a[0]-=2\n a[1]-=2\n if a[0]>=2 and a[1]>=2:\n k=(math.ceil(a[0]/2)+math.floor(a[0]/2)+math.ceil((a[1]-2)/2)+math.floor((a[1]-2)/2))\n else:\n k=math.ceil(max(a)/2)+math.floor(max(a)/2)\nif x-1>len(c):\n print('0')\nelse:\n print(c[x-1])"}, {"source_code": "import itertools\nimport math\n\nn, m = [int(k) for k in input().split()]\nx = int(input())\nif n-2*(x-1) < 1 or m-2*(x-1) < 1:\n print(0)\nelif n-2*(x-1) == 1 or m-2*(x-1) == 1:\n print((n+m-4*(x-1))//2)\nelse: print(n+m-2 - 4*(x-1))\n\n\n\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "#! /usr/bin/env python\nfrom sys import stdin, setrecursionlimit as depth\n\ndepth(10000)\n\ndef count_black(length,init):\n\tif length<0:\n\t\treturn 0\n\tif init: #black\n\t\tret=length/2\n\t\tif length%2:\n\t\t\tret+=1\n\telse:\n\t\tret=length/2\n\treturn ret\n\t\ndef paint(n,m,x,step):\n\t#print n,m,x,step\n\tif n<=0 or m<=0:\n\t\treturn 0\n\telif x==1:\n\t\tif n==1:\n\t\t\treturn count_black(m,True)\n\t\telif m==1:\n\t\t\treturn count_black(n,True)\n\t\telse:\n\t\t\ttop_row=count_black(m,True)\n\t\t\tbottom_row=count_black(m,((n-1)%2==0))\n\t\t\tleft_col=count_black(n-2,False)\n\t\t\tright_black=((n+m-1)%2)==0\n\t\t\tright_col=count_black(n-2,right_black)\n\t\t\t#print \">>> %d %d %d %d\"%(top_row,bottom_row,left_col,right_col)\n\t\t\treturn sum((top_row,bottom_row,left_col,right_col))\n\telse:\n\t\treturn paint(n-2,m-2,x-1,step+1)\n\t\t\t\n\nif __name__=='__main__':\n\tn,m=map(int,stdin.readline().split())\n\tx=int(stdin.readline())\n\tprint paint(n,m,x,0)\n"}, {"source_code": "n,m=map(int,raw_input().split())\nx=input()-1\nprint max(n+m-4*x-2,1) if min(n,m)>2*x else 0"}, {"source_code": "n, m = map(int, raw_input().split())\nx = input()\nb = lambda h, w: ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2) if h > 0 and w > 0 else 0\nh, w = n - x - x, m - x - x\nprint b(h + 2, w + 2) - b(h, w)"}, {"source_code": "n, m = map(int, raw_input().split())\nx = input()\ndef black(x1, y1, x2, y2):\n if x1 > x2 or y1 > y2:\n return 0\n h, w = x2 - x1 + 1, y2 - y1 + 1\n return ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2)\nif min(n, m) >= x + x - 1:\n print black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)\nelse:\n print 0"}, {"source_code": "n, m = map(int, raw_input().split())\nx = input()\ndef black(x1, y1, x2, y2):\n if x1 > x2 or y1 > y2:\n return 0\n h, w = x2 - x1 + 1, y2 - y1 + 1\n return ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2)\nprint black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)"}, {"source_code": "def sqr(x,y): return 0 if x<1 or y<1 else x*y\nx,y = map(int,raw_input().split())\ni = input()\nprint (sqr(x-2*(i-1), y-2*(i-1))-sqr(x-2*i, y-2*i)+1)/2"}, {"source_code": "n,m=map(int,raw_input().split());x=input()-1;print(min(n,m)>2*x)*(n+m-4*x-2or 1)"}, {"source_code": "n,m=map(int,raw_input().split())\nx=input()\nif n2*x else 0\n"}, {"source_code": "n,m = map(int,raw_input().split())\nx = input()\nn-=2*x-2\nm-=2*x-2\nif n<=0 or m<=0:\n\tprint 0\nelif n==1 and m==1:\n\tprint 1\nelse:\n\tprint n+m-2\n"}, {"source_code": "n,m=map(int,raw_input().split())\nx=input()-1\nprint max(n+m-4*x-2,1) if min(n,m)>2*x else 0"}, {"source_code": "n,m = map(int,raw_input().split())\nx = input()\n\nn = max(0,n-2*(x-1))\nm = max(0,m-2*(x-1))\nif n==0 or m==0: print 0\nelif n==1 and m==1: print 1\nelif n%2 and m%2: print max(0,2*(n%2+m%2+n/2+m/2 - 2))\nelif n%2 or m%2: print max(n/2 + m/2 + 1 + n/2 + m/2 - 2,0)\nelse: print max(0,(n/2 + m/2)*2-2) "}, {"source_code": "import math\n\nn, m = map(int, raw_input().split())\nx = int(raw_input()) - 1\n\na = n - (x*2)\nb = m - (x*2)\n\nif a > 0 and b > 0:\n if a == b == 1:\n print 1\n else:\n if a == 1:\n print int(math.ceil(b/2))\n elif b == 1:\n print int(math.ceil(a/2))\n else: print (2*a + 2*(b-2))/2\nelse:\n print 0\n"}, {"source_code": "import math\n\nn, m = map(int, raw_input().split())\nx = int(raw_input()) - 1\n\na = n - (x*2)\nb = m - (x*2)\n\nif a > 0 and b > 0:\n if a == b == 1:\n print 1\n else:\n if a == 1:\n print int(math.ceil(b/2))\n elif b == 1:\n print int(math.ceil(a/2))\n else: print (2*a + 2*(b-2))/2\nelse:\n print 0"}, {"source_code": "from itertools import *\n[n, m], x = map (int, raw_input ().split ()), input ()\nn -= (x - 1) * 2\nm -= (x - 1) * 2\nn, m = sorted ([n, m])\nif [n, m] == [1, 1]:\n p = 1\nelif n == 1:\n p = (m + 1) / 2\nelif n > 0 and m > 0:\n p = ((n + m) * 2 - 4) / 2\nelse:\n p = 0\nprint p \n\n"}, {"source_code": "buf = raw_input()\n\n[n,m] = [int(i) for i in buf.split()]\n\nx = int(raw_input()) - 1\n\nn2 = n - 2*x\nm2 = m - 2*x\n\nif n2 <= 0 or m2 <= 0:\n print 0\nelif n2 == 1:\n print (m2+1)/2\nelif m2 == 1:\n print (n2+1)/2\nelse:\n print m2 + n2 - 2\n\n"}, {"source_code": "# Codeforces Beta Round #40\n# Problem B -- Repaintings\nn, m = map(int, raw_input().split())\nx = input() - 1\nif min(n, m) > 2 * x:\n\tprint max(n + m - 4 * x - 2, 1)\nelse:\n\tprint 0\n"}, {"source_code": "n,m = map(int, raw_input().split())\nx = input()\n\nif min(n,m) < 2*x-1:\n print 0\nelse:\n n1 = n-2*(x-1)\n m1 = m-2*(x-1)\n ans = (n1*m1+1)/2\n if n1>=2 and m1>=2:\n ans -= ((n1-2)*(m1-2)+1)/2\n print ans"}, {"source_code": "import sys\n\ndef calc(n, m):\n return ((n+1)/2)*((m+1)/2)+(m/2)*(n/2)\n\nnn, mm = map(int, sys.stdin.readline().split())\nx = int(sys.stdin.readline())\n\nn = nn-2*(x-1)\nm = mm-2*(x-1)\n\nif n <= 0 or m <= 0:\n print 0\nelse:\n res = calc(n, m)\n if n-2 > 0 and m-2 > 0:\n res -= calc(n-2, m-2)\n print res\n"}, {"source_code": "n, m = map(int, input().split())\nx = int(input())\nk = 0\nfor i in range(n):\n for j in range(m):\n if not (i + j) % 2:\n if min(min(i, j) + 1, min(n - i, m - j)) == x:\n k += 1\nprint(k)\n"}], "negative_code": [{"source_code": "n, m = map(int, input().split())\nx, v = int(input()), 0\nx1, y1, x2, y2 = x - 1, x - 1, n - x, m - x\nfor i in range(x1, x2 + 1):\n if i == x1 or i == x2:\n v += (y2 - y1 + 1) // 2 + ((i + y1) % 2 == 0 and (i + y2) % 2 == 0)\n else:\n v += ((i + y1) % 2 == 0) + ((i + y2) % 2 == 0)\nprint(v)"}, {"source_code": "n, m = map(int, raw_input().split())\nx = input()\ndef black(x1, y1, x2, y2):\n h, w = x2 - x1 + 1, y2 - y1 + 1\n if x1 % 2 == y1 % 2:\n return (h + 1) / 2 * (w + 1) / 2 + h / 2 * w / 2\n return (h + 1) / 2 * w / 2 + h / 2 * (w + 1) / 2\nif min(n, m) >= x + x - 1:\n print black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)\nelse:\n print 0"}, {"source_code": "n, m = map(int, raw_input().split())\nx = input()\ndef black(x1, y1, x2, y2):\n h, w = x2 - x1 + 1, y2 - y1 + 1\n return ((h + 1) / 2) * ((w + 1) / 2) + (h / 2) * (w / 2)\nif min(n, m) >= x + x - 1:\n print black(x - 1, x - 1, n - x, m - x) - black(x, x, n - x - 1, m - x - 1)\nelse:\n print 0"}, {"source_code": "n,m=map(int,raw_input().split())\nx=input()\nif n 0:\n print res\nelse:\n print '0'\n"}, {"source_code": "buf = raw_input()\n\n[n2,m2] = [(int(i)+1)/2 for i in buf.split()]\n\nx = int(raw_input()) - 1\n\nres = (n2-x)*(m2-x)\n\nif res > 0:\n print res\nelse:\n print '0'\n"}, {"source_code": "# Codeforces Beta Round #40\n# Problem B -- Repaintings\nn, m = map(int, raw_input().split())\nx = input() - 1\nif min(n, m) > 2 * x:\n\tprint max(n + m - 4 * x, 1)\nelse:\n\tprint 0\n"}, {"source_code": "import sys\n\nn, m = map(int, sys.stdin.readline().split())\nx = int(sys.stdin.readline())\n\nif n % 2 == 0 and m % 2 == 0:\n if x > min(m, n):\n print \"0\"\n else:\n print (n-2*(x-1))*((m-2*(x-1))/2)\nelse:\n if n % 2 == 0:\n n -= 1\n if m % 2 == 0:\n m -= 1\n\n nn = (n+1)/2\n mm = (m+1)/2\n\n if x > min(nn, mm)/2+1:\n print \"0\"\n else:\n nn = (n+1)/2\n mm = (m+1)/2\n\n print (nn-x+1)*(mm-x+1)\n\n"}, {"source_code": "import sys\n\nnn, mm = map(int, sys.stdin.readline().split())\nx = int(sys.stdin.readline())\n\nn = nn-2*(x-1)\nm = mm-2*(x-1)\n\nif n == 1 and m == 1:\n print 1\nelif n <= 0 or m <= 0:\n print 0\nelse:\n print ((n+1)/2)*(m/2)+((m+1)/2)*(n/2)\n"}], "src_uid": "fa1ef5f9bceeb7266cc597ba8f2161cb"} {"nl": {"description": "Let quasi-palindromic number be such number that adding some leading zeros (possible none) to it produces a palindromic string. String t is called a palindrome, if it reads the same from left to right and from right to left.For example, numbers 131 and 2010200 are quasi-palindromic, they can be transformed to strings \"131\" and \"002010200\", respectively, which are palindromes.You are given some integer number x. Check if it's a quasi-palindromic number.", "input_spec": "The first line contains one integer number x (1\u2009\u2264\u2009x\u2009\u2264\u2009109). This number is given without any leading zeroes.", "output_spec": "Print \"YES\" if number x is quasi-palindromic. Otherwise, print \"NO\" (without quotes).", "sample_inputs": ["131", "320", "2010200"], "sample_outputs": ["YES", "NO", "YES"], "notes": null}, "positive_code": [{"source_code": "a = int(raw_input())\n\nwhile(a % 10 == 0):\n a /= 10\n\ns = str(a);\nif(s == s[::-1]):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "a = int(raw_input())\n\nwhile(a % 10 == 0):\n a /= 10\n\ns = str(a);\nif(s == s[::-1]):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n=input()\ni=len(n)-1\nwhile n[i]=='0':\n i-=1\ns=n[:i+1]\n#print(s)\nif s==s[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=raw_input()\nl=len(n)\ni=l-1\ns=n\nc1,c2=0,0\nwhile n[i]=='0':\n\tc1+=1\n\ti-=1\ni=0\nwhile n[i]=='0':\n\tc2+=1\n\ti+=1\nk=c1-c2\nfor i in range(k):\n\ts='0'+s\nflag=0\nfor i in range(len(s)/2):\n\tif s[i]==s[len(s)-i-1]:\n\t\tcontinue\n\telse:\n\t\tflag=1\n\t\tbreak\nif flag==1:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n"}, {"source_code": "a=[0]*10\nn=input()\nt=0\ns=len(n)-1\nwhile s>=0and n[s]=='0':t+=1;s-=1\nn='0'*t+n\nfor j in range(len(n)//2):\n if n[j]!=n[len(n)-1-j]:exit(print('NO'))\nprint('YES')\n\n\n"}, {"source_code": "s = raw_input().strip('0')\nprint ['NO', 'YES'][s == s[::-1]]\n"}, {"source_code": "n=raw_input()\nl=len(n)\ni=l-1\ns=n\nc1,c2=0,0\nwhile n[i]=='0':\n\tc1+=1\n\ti-=1\ni=0\nwhile n[i]=='0':\n\tc2+=1\n\ti+=1\nk=c1-c2\nfor i in range(k):\n\ts='0'+s\nflag=0\nfor i in range(len(s)/2):\n\tif s[i]==s[len(s)-i-1]:\n\t\tcontinue\n\telse:\n\t\tflag=1\n\t\tbreak\nif flag==1:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n"}, {"source_code": "x = raw_input()\nx = str(x)\n\nif x[::-1] == x:\n print \"YES\"\nelse:\n len_add = len(x[:-1])\n\n for i in range(0, len_add):\n x = \"0\" + x\n if x[::-1] == x:\n print \"YES\"\n no = False\n break\n else:\n no = True\n\n if no == True:\n print \"NO\"\n"}, {"source_code": "x=input().strip('0')\nprint('YES' if x==x[::-1] else 'NO')"}, {"source_code": "s = input().strip('0')\nprint(\"YES\") if s == s[::-1] else print(\"NO\")"}, {"source_code": "def is_palindrome(s):\n l, r = 0, len(s) - 1\n while l < r:\n if s[l] != s[r]:\n return False\n l += 1\n r -= 1\n return True\n\ns = input()\nr = len(s) - 1\nwhile s[r] == '0':\n r -= 1\nif is_palindrome(s[:r+1]):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a = int(raw_input())\n\nwhile(a % 10 == 0):\n a /= 10\n\ns = str(a);\nif(s == s[::-1]):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "x=input();n=x.replace('0','')\nif len(n)==0:exit(print('YES'))\nx=x.replace('0','',x.find(n[0]))[::-1]\nx=x.replace('0','',x.find(n[-1]))\nprint('YES' if x==x[::-1] else 'NO')"}, {"source_code": "s = raw_input().strip('0')\nprint 'YES' if s == s[::-1] else 'NO'"}, {"source_code": "p = input()\nif p == p[::-1] or len(p) == 1:\n print(\"YES\")\nelse:\n if p[0] != p[len(p) - 1] and '0' not in [p[0], p[len(p) - 1]]:\n print(\"NO\")\n else:\n cl, cr = '', ''\n for i in p:\n if i == '0':\n cl+='0'\n else:\n break\n for i in p[::-1]:\n if i == '0':\n cr+='0'\n else:\n break\n if cl == cr and p != p[::-1]:\n print(\"NO\")\n else:\n if len(cl) > len(cr):\n p += ('0' * (len(cl) - len(cr)))\n if p == p[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")\n else: \n p = ('0' * (len(cr) - len(cl))) + p\n if p == p[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "value = input()\n\ntrailingZero = len(value) - len(value.rstrip('0'))\npal = trailingZero*'0' + value\n\nif value == value[::-1]:\n print(\"YES\")\nelif pal == pal[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x = int(input())\nfor i in range(len(str(x))):\n y = x % 10\n if y != 0:\n break\n else:\n x = x // 10\n\n\nif len(str(x)) % 2 == 0:\n j = len(str(x)) // 2\n m = str(x)[j:]\n if str(x)[:j] == m[::-1]:\n print(\"YES\")\n else:\n print(\"NO\") \nelse:\n j = len(str(x)) // 2\n m = str(x)[(j + 1):]\n if str(x)[:j] == m[::-1]:\n print(\"YES\")\n else:\n print(\"NO\")\n\n \n"}, {"source_code": "x = input()\nx = x[::-1]\nx1 = str(int(x))\nx2 = x1[::-1]\ncheck = [False] *(len(x1))\nfor i in range(len(x1)):\n if x1[i] == x2[i]:\n check[i] = True\nif check.count(False) == 0:\n print('YES')\nelse:\n print('NO')\n \n "}, {"source_code": "ins = input()\nins = ins.strip(\"0\")\n\nprint([\"NO\", \"YES\"][ins == ins[::-1]])"}, {"source_code": "n=input()\nwhile n%10 == 0:\n\tn/=10\nd=str(n)\nif d == d[::-1]:\n\tprint \"YES\"\nelse: print \"NO\""}, {"source_code": "from sys import stdin\nans = 'NO'\nn = int(stdin.readline())\nwhile n%10==0:\n n/=10\na = str(n)\nif a==a[::-1]:\n ans = 'YES'\nprint ans"}, {"source_code": "n = raw_input()\nn = n[::-1]\nn = str(int(n))\nif n == n[::-1]:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "l=raw_input().strip('0')\nprint('YES'if l[::-1]==l else'NO')"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# File : 863a.py\n# Author : recurze\n# Date : 16:32 08.12.2018\n# Last Modified Date: 16:32 08.12.2018\n\ns = str(raw_input()).lstrip('0').rstrip('0')\nprint [\"NO\", \"YES\"][s == s[::-1]]\n"}, {"source_code": "s=raw_input()\nt=s[::-1].lstrip('0')\nif t==s.rstrip('0'):\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import math\n\n\na = str(input())\n\ndef palindrome(a):\n n = len(a)\n if n%2==0:\n for i in range(int(n/2)):\n if a[i]!=a[n-i-1]:\n return False\n return True\n else:\n for i in range(math.floor(n/2)):\n if a[i]!=a[n-i-1]:\n return False\n return True\n\ni=1\n \nwhile (i!=0):\n if palindrome(a):\n print(\"YES\")\n i=0\n else:\n if a[-1]== '0':\n a=a[:-1]\n else:\n i=0\n print(\"NO\")"}, {"source_code": "s = raw_input()\nt = s\nt = s.strip('0')\nif s.strip('0')[::-1] == t:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n\n"}, {"source_code": "t = input().rstrip('0')\n\nif t == t[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\nk = 0\nfor e in n[::-1]:\n if e == '0':\n k += 1\n else:\n break\nn = k*'0' + n\nif n == n[::-1]:\n ans = 'YES'\nelse:\n ans = 'NO'\nprint(ans)"}, {"source_code": "s = input().rstrip('0')\nprint(('NO', 'YES')[s == s[::-1]])\n"}, {"source_code": "\nfrom math import *\nfrom decimal import *\nfrom fractions import gcd\ngetcontext().prec = 20\nimport copy\ndef mp():\n return map(int,str(raw_input()).split())\n\ns=str(raw_input())\na=''\nflag=1\nfor i in range(len(s)-1,-1,-1):\n if flag==1 and s[i]=='0':\n pass\n else:\n flag=0\n a+=s[i]\n#print a\nif a==a[::-1]:\n print 'YES'\nelse:\n print \"NO\""}, {"source_code": "s = input()\n\nfor i in range(100):\n if s == s[::-1]:\n break\n s = '0' + s\nif s == s[::-1]:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def isPalindrome(s) :\n if len(s) <= 1 :\n return True\n else :\n if s[0] == s[len(s) - 1] :\n s2 = s[1 : len(s) - 1]\n return isPalindrome(s2)\n else :\n return False\n\ns = raw_input()\ni = len(s) - 1\nwhile(True) :\n if s[i] == '0' :\n i -= 1\n else :\n break\n\ns1 = s[0 : i + 1]\n\nif(isPalindrome(s1)) :\n print(\"YES\")\nelse :\n print('NO')"}, {"source_code": "INF = 999999999999999999L\ntry:\n inFile = open(\"A.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\n\ns = read()\nzero_cnt = 0\nfor i in reversed(range(len(s))):\n if s[i] == \"0\":\n zero_cnt += 1\n else:\n break \n \nfor i in range(len(s)):\n if s[i] == \"0\":\n zero_cnt -= 1\n else:\n break \n\ns = \"0\"*zero_cnt + s\nrev = s[::-1]\n#print s\n#print rev\nif s == rev:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def main():\n\tnum = input()\n\tflag = False\n\trev = num[::-1]\n\tif num == rev:\n\t\tflag = True\n\telse:\n\t\tlength = len(num)\n\t\twhile num[length-1] == '0':\n\t\t\tlength = length-1\n\t\tnum = num[0:length]\n\t\trev = num[::-1]\n\t\tif num == rev:\n\t\t\tflag = True\n\t\n\tif flag == True:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\t\t\n"}, {"source_code": "a = raw_input()\ns = 0\ne = len(a) - 1\n\nl = 0\nwhile a[s] == '0':\n s += 1\n l += 1\n\nr = 0\nwhile a[e] == '0':\n e -= 1\n r += 1\n\n#Check if pali\npali = False\nif a[s:e+1] == ''.join(list(reversed(a[s:e+1]))):\n pali = True\n\nif pali and l <= r:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "if __name__ == '__main__':\n s = input().strip('0')\n if s[::] == s[::-1]:\n print('YES')\n else:\n print('NO')"}, {"source_code": "s=raw_input()\nt=s[::-1].lstrip('0')\nif t==s.rstrip('0'):\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n = input()\n\ncheck1 = True\ncheck2 = True\n\n\nl = len(n)-1\ncount1, count2 = 0, 0\n\nfor _ in range(len(n)):\n if int(n[_]) == 0 and check1:\n count1 += 1\n else:\n check1 = False\n\n if int(n[l]) == 0 and check2:\n count2 += 1\n else:\n check2 = False\n\n l -= 1\n\n if not check1 and not check2: break\n\ncount = abs(count1 - count2)\n\ns = str(n)\nst = ''\n\nif count1 > count2:\n for _ in range(count):\n s += '0'\nelse:\n for _ in range(count):\n st += '0'\n s = st + s\n\nif str(s) == str(s)[::-1]: print(\"YES\")\nelse: print(\"NO\")\n"}, {"source_code": "l=input().strip('0')\nprint('YES'if l[::-1]==l else'NO')"}, {"source_code": "n = input()\n\ncheck1 = True\ncheck2 = True\n\n\nl = len(n)-1\ncount1, count2 = 0, 0\n\nfor _ in range(len(n)):\n if int(n[_]) == 0 and check1:\n count1 += 1\n else:\n check1 = False\n\n if int(n[l]) == 0 and check2:\n count2 += 1\n else:\n check2 = False\n\n l -= 1\n\n if not check1 and not check2: break\n\ncount = abs(count1 - count2)\n\ns = str(n)\nst = ''\n\nif count1 > count2:\n for _ in range(count):\n s += '0'\nelse:\n for _ in range(count):\n st += '0'\n s = st + s\n\nif str(s) == str(s)[::-1]: print(\"YES\")\nelse: print(\"NO\")\n"}, {"source_code": "s=input()\nfor i in range(14):\n s1='0'*i+s \n if s1==s1[::-1]:\n print('YES')\n exit()\nprint('NO')"}, {"source_code": "x = raw_input()\n\ndef is_palindrome(x):\n i = 0\n j = len(x) - 1\n while i < j:\n if x[i] != x[j]:\n return False\n i += 1\n j -= 1\n return True\n\ndef is_quasi(x):\n for i in range(len(x)+1):\n if is_palindrome('0'*i + x):\n return True\n return False\n\nprint 'YES' if is_quasi(x) else 'NO'\n"}, {"source_code": "n = map(str, raw_input())\n\n\ndef solve(a):\n k = len(a)\n for i in xrange(len(a) - 1, 0, -1):\n if n[i] == '0':\n k = k - 1\n else:\n break\n new_array = a[0:k]\n z = True\n for i in xrange(0, k/2):\n if new_array[i] != new_array[k - i - 1]:\n z = False\n break\n return z\n\nif solve(n):\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "s = list(input())\nwhile len(s) and s[0]==\"0\":\n s.remove(\"0\")\nwhile len(s) and s[-1]==\"0\":\n s.pop()\nt = s.copy()\nt.reverse()\nif t ==s:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "value = input()\n\ntrailingZero = len(value) - len(value.rstrip('0'))\npal = trailingZero*'0' + value\n\nif value == value[::-1]:\n print(\"YES\")\nelif pal == pal[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "w=raw_input()\np=\"NO\"\nfor z in range(10):\n\tpad=\"0\"*z\n\tw1=pad+w\n\tif w1==w1[::-1]:\n\t\tp=\"YES\"\nprint p"}, {"source_code": "n = input()\ndef ispolindrome(n):\n ans = 0\n if len(n) % 2 == 0:\n ans_len = len(n) // 2\n else:\n ans_len = (len(n) // 2) + 1\n for i in range(ans_len):\n if n[i] == n[len(n) - 1 - i]:\n ans += 1\n if len(n) % 2 and ans == (len(n) // 2) + 1:\n return True\n elif len(n) % 2 == 0 and ans == len(n) // 2:\n return True\n else:\n return False\nif ispolindrome(n):\n print(\"YES\")\nelse:\n n = list(n)\n ans_len = False\n for i in range(len(n)):\n if n[len(n) - 1 - i] == \"0\":\n ans_len = len(n) - 1 - i\n else:\n break\n if ans_len != False and ispolindrome(n[:ans_len]):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "def main():\n n = list(input())\n n = n[::-1]\n \n #print(n)\n while n[0] == '0':\n n.remove('0')\n #print (n)\n \n if n[:] == n[::-1]:\n print (\"YES\")\n else:\n print (\"NO\")\n\nmain()"}, {"source_code": "s=list(input())\nn=len(s)\nt,flag=1,1\nz=s[::-1]\nfor i in z:\n\tif i=='0':\n\t\tt+=1\n\telse:\n\t\tbreak\n# print(t)\t\t\t\t\nfor i in range(t):\n\tfor j in range(n):\n\t\tif s[j]==s[-(j+1)]:\n\t\t\tpass\n\t\telse:\n\t\t\tflag=0\n\t\t\tbreak\n\t\tflag=1\t\n\t# print(s)\n\ts.insert(0,'0')\n\tn+=1\nif flag==1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "\nf = lambda l: 'YES' if l==l[::-1] else 'NO'\n\nn = input().strip('0')\n\nprint(f(n))"}, {"source_code": "def main():\n\tnum = input()\n\tflag = False\n\trev = num[::-1]\n\tif num == rev:\n\t\tflag = True\n\telse:\n\t\tlength = len(num)\n\t\twhile num[length-1] == '0':\n\t\t\tlength = length-1\n\t\tnum = num[0:length]\n\t\trev = num[::-1]\n\t\tif num == rev:\n\t\t\tflag = True\n\t\n\tif flag == True:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\t\t\n"}, {"source_code": "#coding: utf-8\n\ndef CheckQuasiPalindrome(n):\n num = n.rstrip('0')\n return num == num[::-1]\n\nif __name__ == \"__main__\":\n n = raw_input()\n print \"Yes\" if CheckQuasiPalindrome(n) else \"No\""}, {"source_code": "s = input()\nwhile s != s[::-1]:\n s = '0' + s\n if len(s) > 40: break\nprint('YNEOS'[len(s) > 40::2])\n"}, {"source_code": "n=list(input())\nfor i in range(len(n)):\n\tif n[i]==\"0\":\n\t\tn.remove(n[i])\n\telse:\n\t\tbreak\nfor i in range(len(n)-1,-1,-1):\n\tif n[i]==\"0\":\n\t\tn.pop(i)\n\telse:\n\t\tbreak\nr=len(n)\nc=0\nfor i in range(r):\n\tif n[i]==n[-(i+1)]:\n\t\tc+=1\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak\nif r==c:\n\tprint(\"YES\")"}, {"source_code": "s = list(input())\ncount = 0\nfor i in range(len(s)-1,-1,-1):\n\tif s[i]==\"0\":\n\t\tcount += 1\n\telse:\n\t\tbreak\nfor k in range(count):\n\ts.pop()\nif s==s[::-1]:\n\tprint(\"YES\")\nelse:print(\"NO\")\t\t\t\t\t"}, {"source_code": "def ispalindrome(s):\n\tmid=len(s)//2\n\tif mid==1:\n\t\tif s[0]!=s[-1]:\n\t\t\treturn False\n\telse:\n\t\tfor i in range(mid):\n\t\t\tif s[i]!=s[-1-i]:\n\t\t\t\treturn False\n\treturn True\ndef main():\n\ts=input()\n\tcheck=\"\"\n\tfor i in range(-1, -len(s)-1, -1):\n\t\tif(s[i]!='0'):\n\t\t\tbreak\n\tfor j in range(len(s)):\n\t\tif(s[j]!='0'):\n\t\t\tbreak\n\tif i==-1:\n\t\tcheck=s\n\telse:\n\t\tcheck=s[j:i+1]\n\tif ispalindrome(check):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nmain()"}, {"source_code": "from sys import stdin\nans = 'NO'\nn = int(stdin.readline())\nwhile n%10==0:\n n/=10\na = str(n)\nif a==a[::-1]:\n ans = 'YES'\nprint ans"}, {"source_code": "s = input()\nfor i in range(len(s)):\n if s[-1] == '0':\n s = s[0:-1]\n else:\n break\nif s == s[::-1]:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s = input()\nind1 = 0\nwhile int(s[ind1]) == 0:\n ind1 += 1\nind2 = len(s) - 1\nwhile int(s[ind2]) == 0:\n ind2 -= 1\ns1 = s[ind1:ind2+1]\nif s1[::-1] == s1 and ind1 <= len(s) - ind2:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x = input().strip('0')\nprint('YES'if x[::-1] == x else'NO')\n\n# CodeForcesian\n# \u2665\n\n"}, {"source_code": "n = input()\nwhile (n % 10 == 0) :\n\tn /= 10\n\nn = str(n)\nit = 0;\nwhile it < len(n) : \n\tif n[ it ] != n[ len(n) - it - 1] :\n\t\tprint \"NO\"\n\t\texit()\n\tit += 1;\n\nprint \"YES\"\n"}, {"source_code": "def isPalindrome(s):\n n=len(s)\n i=0\n while i*2 0:\n v //= 10\n\ns = str(v)\n\nif s == s[::-1]: print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "import sys\nfrom itertools import *\nfrom cmath import *\n\ninput = sys.stdin.readline\nfrom math import *\n\n\n############ ---- Input Functions ---- ############\ndef inp():\n return int(input().strip())\n\n\ndef inlt():\n return list(map(int, input().split()))\n\n\ndef insr():\n s = input()\n return list(s[:len(s) - 1])\n\n\ndef invr():\n return map(int, input().split())\n\ndef iss(s):\n t=s[::-1]\n return t==s\n\ns=insr()\nwhile s[len(s)-1]=='0':\n s.pop()\n\nprint(\"YES\" if iss(s) else \"NO\")"}, {"source_code": "n=int (raw_input())\n\nfinalNum=n\ndiv10=True\nwhile div10==True:\n if finalNum%10==0:\n finalNum/=10\n else:\n div10=False\nfinalNum=str(finalNum)\ni=-len(finalNum)\nf=-1\ntoPrint='YES'\nwhile i <=f and toPrint=='YES' :\n if finalNum[i] != finalNum[f]:\n toPrint='NO' \n i+=1\n f-=1\nprint toPrint"}, {"source_code": "import sys\n\ns = sys.stdin.readline().strip()\nr = s[::-1]\n\ni = 0\nwhile r[i] == '0':\n i+=1\n\np = r[i:]\nif p == p[::-1]:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "def polindrom(s):\n st2 = ''\n for i in s:\n st2 = i + st2\n return st2;\na = input()\nk = 0\ntest = True\nwhile test:\n if (k>8 or a == polindrom(a)):\n if (a==polindrom(a)):\n test = True\n else:\n test = False\n break\n else:\n a = '0' + a\n k+=1\nif test:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\nwhile n%10==0:\n n=n/10\nsaven=n\nb=0\nwhile saven>0:\n b=10*b+saven%10\n saven=int(saven/10)\nif b==n:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x = input()\nfor i in range(10):\n if list(x) == list(x)[::-1]:\n print(\"YES\") \n break\n x = \"0\"+x\nelse: print(\"NO\")"}, {"source_code": "s=input()\ndef p(s): \n return s==s[::-1]\ns=s.rstrip('0')\nif p(s):\n print(\"YES\")\n \nelse:\n print(\"NO\")\n"}, {"source_code": "def isPalindrome(s):\n if s==s[::-1]:\n return True\n else:\n return False\nif isPalindrome(input().rstrip('0')):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x = raw_input().strip()\nfor i in range(len(x) - 1, -1, -1):\n if x[i] == '0':\n x = x[:-1]\n else:\n break\nf = 0\nl = len(x) - 1\nv = True\nwhile f <= l:\n if x[f] != x[l]:\n v = False\n break\n f += 1\n l -= 1\nif v == False:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# File : 863a.py\n# Author : recurze\n# Date : 16:32 08.12.2018\n# Last Modified Date: 16:32 08.12.2018\n\ns = str(raw_input()).lstrip('0').rstrip('0')\nprint [\"NO\", \"YES\"][s == s[::-1]]\n"}, {"source_code": "n = int(raw_input())\nwhile n%10 == 0:\n\tn /= 10\ns = str(n)\nret = True\nfor i in range(len(s)/2):\n\tif s[i] != s[-(1+i)]:\n\t\tret = False\n\t\tbreak\nprint \"YES\" if ret else \"NO\"\n"}, {"source_code": "\nf = lambda l: 'YES' if l==l[::-1] else 'NO'\n\nn = input().strip('0')\n\nprint(f(n))"}, {"source_code": "s=input().strip('0')\nif s==s[::-1]:\n print('yes')\nelse:\n print('no')"}, {"source_code": "a = raw_input()\ns = 0\ne = len(a) - 1\n\nl = 0\nwhile a[s] == '0':\n s += 1\n l += 1\n\nr = 0\nwhile a[e] == '0':\n e -= 1\n r += 1\n\n#Check if pali\npali = False\nif a[s:e+1] == ''.join(list(reversed(a[s:e+1]))):\n pali = True\n\nif pali and l <= r:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n = int(raw_input())\ns = str(n)\nl = len(s)\nfor i, c in enumerate(s):\n if c != '0':\n l = len(s)\n elif l > i-1:\n l = i\nprint \"YES\" if s[:l] == s[:l][::-1] else \"NO\""}, {"source_code": "n=raw_input()\nn=list(n)\nwhile n[-1]=='0':n.pop()\nif n==list(reversed(n)):print \"YES\"\nelse: print \"NO\"\n"}, {"source_code": "def checkQP(inputStr):\n\tinputStr = inputStr.strip(\"0\")\n\tif inputStr == inputStr[::-1]:\n\t\treturn \"YES\"\n\telse:\n\t\treturn \"NO\"\n\n\nif __name__ == '__main__':\n\twhile True:\n\t\ttry:\n\t\t\tinputStr = input()\n\t\t\tprint(checkQP(inputStr))\n\t\texcept EOFError:\n\t\t\tbreak"}, {"source_code": "\nR = lambda:map(int,input().split())\n\ns = input().strip('0')\nif s == s[::-1]:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=[int(q) for q in list(input())]\na=a[::-1]\nif a[0]==0 and len(a)==1:\n print('YES')\nelse:\n while(1):\n if a[0]==0:\n a.pop(0)\n else:\n break\n if a==a[::-1]:\n print('YES')\n else:\n print('NO')"}, {"source_code": "x = input()\nx = x[::-1]\nx1 = str(int(x))\nx2 = x1[::-1]\ncheck = [False] *(len(x1))\nfor i in range(len(x1)):\n if x1[i] == x2[i]:\n check[i] = True\nif check.count(False) == 0:\n print('YES')\nelse:\n print('NO')\n \n "}], "negative_code": [{"source_code": "\nx=raw_input()\nf=0\nz=x[::-1]\nif z==x:\n\tf=1\nfor i in range(0,len(x)):\n\ty='0'+x\n\tj=y[::-1]\n\tif y==j:\n\t\tf=1\n\t\tbreak\nif f==1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n=int(input())\nwhile n<1 and n>10**9:\n n=int(input())\nt=str(n)\nj=0\nfor i in t:\n if t.count(i)%2!=0:\n j+=1\n if j>=1and len(t)%2==0:\n print('no')\n break\nelse :\n print('yes')"}, {"source_code": "x = raw_input()\nwhile x != x[::-1] and len(x) < 18:\n x = \"0\" + x\nif x == x[::-1]:\n print \"YES\"\nelse :\n print \"NO\""}, {"source_code": "def pol(n):\n c=n\n length=len(n)\n count=0\n if n[len(n)-1]==\"0\":\n for i in range(len(n)-1,-1,-1):\n if n[i]==\"0\":\n count+=1\n else:\n break\n if count!=0:\n for i in range(count):\n n=\"0\"+n\n n=\"\".join(reversed(n))\n t=\"\".join(reversed(c))\n if n[:length]==t:\n return \"Yes\"\n else:\n return \"No\"\n else:\n if c==\"\".join(reversed(n)):\n return \"Yes\"\n else:\n return \"No\"\n\nprint(pol(input().strip()))"}, {"source_code": "import sys\n\nnum = sys.stdin.readline().strip(\"0\")\n\nmiddle = len(num) // 2 + 1\n\nfor i in range(middle):\n if num == \"\" or type(num) != str:\n print(\"NO\")\n break\n if num[i] != num[-i - 1]:\n print(\"NO\")\n break\n elif i == middle - 1:\n print(\"YES\")\n else:\n continue"}, {"source_code": "inp = input()\ninp = inp.strip('0')\nif inp == inp[::-1]:\n print('Yes')\nelse:\n print('No')\nprint(inp)\n"}, {"source_code": "string = input()\n\nodd_cnt = 0\n\nfor i in range(10):\n chn = str(i)\n\n if string.count(chn) % 2 == 1:\n odd_cnt += 1\n\nif odd_cnt <= 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "a=list(input())\nif a[-1]!='0':\n print('NO')\nelse:\n for i in range(len(a)-1,-1,-1):\n if a[i]=='0':\n a.pop(i)\n else:\n break\n p=len(a)\n p1=a[:]\n p2=p*[0]\n for i in range(p-1,-1,-1):\n p2[p-i-1]=a[i]\n if p1==p2:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "S=input()\nN=len(S)\nD=[]\nC=[]\nC1=[]\nfor i in range(0,N):\n D.append(S[i])\nfor i in range(0,N):\n if D[i] not in C:\n if((D.count(D[i]))%2==0):\n C.append(D[i])\n else:\n if D[i] not in C1:\n C1.append(D[i])\nif(len(C)0):\n dig=n%10\n rev=rev*10+dig\n n=n//10\nif(temp==rev):\n print(\"The number is a palindrome!\")\nelse:\n print(\"The number isn't a palindrome!\")"}, {"source_code": "a=raw_input()\nfor i in xrange(len(a)): \n if a[len(a)-i-1]!='0':\n a=a[:-i]\n break\nif a==a[::-1]:\n print 'YES'\nelse:\n print \"NO\""}, {"source_code": "a = input()\nif a == a[::-1]:\n print('YES')\nelse:\n b = int(a[::-1])\n if b == a[:len(str(b))]:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "l=input()\nprint('YES' if l.replace('0','')[::-1]==l.replace('0','') else 'NO')"}, {"source_code": "S = input().strip()\nprint([\"NO\", \"YES\"][S == S[::-1]])"}, {"source_code": "a=raw_input()\nwhile a and a[-1]=='0':a=a[:-1]\ndef palin(x):\n for i in range(len(x)/2):\n if x[i] != x[len(x)-1-i]:return False\n return True\nprint\"YES\"if palin(a)else\"NO\"\n"}, {"source_code": "from sys import stdin\nlines = stdin.readlines()\nx = str(lines[0])\nc = x[::-1]\nsumm = 0\nfor i in c:\n if i != \"0\":\n break\n elif i == \"0\":\n summ += 1\nx = \"0\"*summ+x\n\ndef pal(x):\n c = x[::-1]\n for i in range(len(x)/2):\n if x[i] != c[i]:\n return False\n return True\nif pal(x):\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "s = input()\nprint( \"YES\" if s == s[::-1] else \"NO\")"}, {"source_code": "n=str(input())\nd=n[::-1]\nf=0\nfor i in range(0,len(d)):\n if(d[i]!='0'):\n f=i\n break\nn=n[0:(len(n)-f)]\ne=0\nfor i in range(0,len(n)):\n if(n.count(n[i])%2!=0):\n e=e+1\nif(e==1):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "c = str(input())\nx= len(c)-len(c.rstrip('0'))\nc= x*'0'+c\n\nl=len(c)\n\nj= c[: l//2]\n\nk= c[l//2+1:]\nk=k[::-1]\nif j==k:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"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 pallindrom(s):\n for i in range(len(s)//2):\n if s[i] != s[~i]:\n return False\n return True\n\nstring = ''.join(input().split('0'))\nif pallindrom(string):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s = input()\nprint( \"YES\" if s == s[::-1] else \"NO\")"}, {"source_code": "def pol(n):\n c=n\n length=len(n)\n count1=0\n count2=0\n if n[len(n)-1]==\"0\":\n for i in range(len(n)-1,-1,-1):\n if n[i]==\"0\":\n count1+=1\n else:\n break\n if n[0]==\"0\":\n for i in range(len(n)):\n if n[i] == \"0\":\n count2 += 1\n else:\n break\n print(count1)\n print(count2)\n if count1-count2!=0:\n for i in range(count1-count2):\n n=\"0\"+n\n t=\"\".join(reversed(c))\n print(t)\n if n[:length]==t:\n return \"YES\"\n else:\n return \"NO\"\n else:\n if c==\"\".join(reversed(n)):\n return \"YES\"\n else:\n return \"NO\"\n\nprint(pol(input().strip()))"}, {"source_code": "\nx=raw_input()\nf=0\nz=x[::-1]\nif z==x:\n\tf=1\nfor i in range(0,len(x)):\n\ty='0'+x\n\tj=y[::-1]\n\tif y==j:\n\t\tf=1\n\t\tbreak\nif f==1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "def main():\n\ts=input()\n\tcheck=\"\"\n\tfor i in range(-1, -len(s)-1, -1):\n\t\tif(s[i]!='0'):\n\t\t\tbreak\n\tfor j in range(len(s)):\n\t\tif(s[j]!='0'):\n\t\t\tbreak\n\tif i==-1:\n\t\tcheck=s\n\telse:\n\t\tcheck=s[j:i+1]\n\tif ispalindrome(check):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\ndef ispalindrome(s):\n\tmid=len(s)//2\n\tif len(s)%2==0:\n\t\tfor i in range(mid):\n\t\t\tif s[i]!=s[-1-i]:\n\t\t\t\tbreak\n\t\telse:\n\t\t\treturn True\n\telse:\n\t\tfor i in range(mid-1):\n\t\t\tif s[i]!=s[-1-i]:\n\t\t\t\tbreak\n\t\telse:\n\t\t\treturn True\n\treturn False\nmain()"}, {"source_code": "x=str(input())\na=x.count(\"0\")\ns=\"\"\nif a>0:\n while a<=2*x.count(\"0\"):\n if x==x[::-1]:\n s=1\n break\n x=\"0\"+x\nif s==1:\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "import sys\n\nfor line in sys.stdin:\n for var in line.split():\n print(var)\n r=var[::-1]\n for b in r:\n if(b!=\"0\"):\n break\n if(var[0]!=b):\n var=var[:-1]\n r=var[::-1]\n print(var+\" \"+r)\n if(var==r):\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\n\n"}, {"source_code": "num1 = list(raw_input())\nnum2 = num1[::-1]\nif len(num1) == 1:\n print(\"YES\")\n\nind0= 0\ncount = 0\n\nwhile num2[ind0] == \"0\":\n count += 1\n ind0+= 1\n\nind0 = 0\nwhile num1[ind0] == \"0\":\n count -= 1\n ind0 += 1\n\nls = [\"0\"] * count\nnum = ls + num1\n\npal = True\nstart = 0\nend = len(num) -1\n\nwhile start < end:\n if num[start] != num[end]:\n pal = False\n break\n start += 1\n end -= 1\n\nif pal:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s=input()\nl=len(s)\nfor i in range(0,l):\n if s[i]!='0':\n s=s[i:]\n break\nl=len(s)\nfor i in range(1,l):\n if s[l-i]!='0':\n s=s[:l-i+1]\n break\nl=len(s)\nf=0\nfor i in range(0,int(l/2)):\n if(s[i]!=s[l-i-1]):\n f=1\n break\nif f==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "S = input().strip()\nprint([\"NO\", \"YES\"][S == S[::-1]])"}, {"source_code": "s = raw_input()\nprint 'YES' if s == s[::-1] else 'NO'"}, {"source_code": "a = input()\nst1 = ''\nst2 = ''\nfor i in a:\n if i != '0':\n st1 += i\nfor i in st1:\n st2 = i + st2\nif st1 == st2:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# Main maut ko takiya, aur kafan ko chadaar banakar audhta hoon!\n \ns=input()\n\ns.replace(\"0\",\"\")\n\nif s==s[::-1]:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n \n"}, {"source_code": "n=list(input())\nfor i in range(len(n)):\n\tif n[i]==\"0\":\n\t\tn.remove(n[i])\n\telse:\n\t\tbreak\nfor i in range(len(n)):\n\tif n[-i]==\"0\":\n\t\tn.remove(n[-i])\n\telse:\n\t\tbreak\nr=len(n)\nc=0\nfor i in range(r):\n\tif n[i]==n[-(i+1)]:\n\t\tc+=1\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak\nif r==c:\n\tprint(\"YES\")\n"}, {"source_code": "t = input()\ni = t.rfind('0')\nif i != -1: t = t[:i]\nk = len(t) // 2\nprint(['NO', 'YES'][t[:k] == t[-k:][::-1]])"}, {"source_code": "def main():\n s = input()\n ss = ''\n for i in range(len(s) - 1, -1, -1):\n if s[i] == '0':\n ss += '0'\n ss += s\n #print(ss)\n for i in range(0, len(ss) // 2 + 1):\n #print(ss[i], ss[len(ss) - 1 - i])\n if ss[i] != ss[len(ss) - 1 - i]:\n print('NO')\n return\n print('YES')\n\nmain()"}, {"source_code": "a=list(input())\nif a[-1]!='0':\n print('NO')\nelse:\n for i in range(len(a)-1,-1,-1):\n if a[i]=='0':\n a.pop(i)\n else:\n break\n p=len(a)\n p1=a[:]\n p2=p*[0]\n for i in range(p-1,-1,-1):\n p2[p-i-1]=a[i]\n if p1==p2:\n print('YES')\n else:\n print('NO')\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 pallindrom(s):\n for i in range(len(s)//2):\n if s[i] != s[~i]:\n return False\n return True\n\nstring = ''.join(input().split('0'))\nif pallindrom(string):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\n\nnum = sys.stdin.readline().strip(\"0\")\n\nmiddle = len(num) // 2 + 1\n\nfor i in range(middle):\n if num == \"\" or type(num) != str:\n print(\"NO\")\n break\n if num[i] != num[-i - 1]:\n print(\"NO\")\n break\n elif i == middle - 1:\n print(\"YES\")\n else:\n continue"}, {"source_code": "a=[0]*10\nn=input()\nfor i in n:\n a[int(i)]^=1\nif sum(a)<2:print('YES')\nelse:print('NO')\n\n\n"}, {"source_code": "{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 36,\n \"metadata\": {},\n \"outputs\": [\n {\n \"name\": \"stdout\",\n \"output_type\": \"stream\",\n \"text\": [\n \"2010200\\n\",\n \"YES\\n\"\n ]\n }\n ],\n \"source\": [\n \"import math\\n\",\n \"\\n\",\n \"\\n\",\n \"a = str(input())\\n\",\n \"\\n\",\n \"def palindrome(a):\\n\",\n \"\\tn = len(a)\\n\",\n \"\\tif n%2==0:\\n\",\n \"\\t\\tfor i in range(int(n/2)):\\n\",\n \"\\t\\t\\tif a[i]!=a[n-i-1]:\\n\",\n \"\\t\\t\\t\\treturn False\\n\",\n \"\\t\\treturn True\\n\",\n \"\\telse:\\n\",\n \"\\t\\tfor i in range(math.floor(n/2)):\\n\",\n \"\\t\\t\\tif a[i]!=a[n-i-1]:\\n\",\n \"\\t\\t\\t\\treturn False\\n\",\n \"\\t\\treturn True\\n\",\n \"\\n\",\n \"i=1\\n\",\n \"\\t \\n\",\n \"while (i!=0):\\n\",\n \"\\tif palindrome(a):\\n\",\n \"\\t\\tprint(\\\"YES\\\")\\n\",\n \"\\t\\ti=0\\n\",\n \"\\telse:\\n\",\n \"\\t\\tif a[-1]== '0':\\n\",\n \"\\t\\t\\ta=a[:-1]\\n\",\n \"\\t\\telse:\\n\",\n \"\\t\\t\\ti=0\\n\",\n \"\\n\",\n \"if i==1:\\n\",\n \"\\tprint(\\\"NO\\\")\"\n ]\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \"Python 3\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.6.0\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 2\n}\n"}, {"source_code": "n=int(input(\"Enter number:\"))\ntemp=n\nrev=0\nwhile(n>0):\n dig=n%10\n rev=rev*10+dig\n n=n//10\nif(temp==rev):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "from sys import stdin\nlines = stdin.readlines()\nx = str(lines[0])\nc = x[::-1]\nsumm = 0\nfor i in c:\n if i != \"0\":\n break\n elif i == \"0\":\n summ += 1\nx = \"0\"*summ+x\n\ndef pal(x):\n c = x[::-1]\n for i in range(len(x)/2):\n if x[i] != c[i]:\n return False\n return True\nif pal(x):\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "s = input()\n\nif s == s[::-1]:\n\tprint('YES')\nelse:\n\tfor i in range(1, len(s)//2):\n\t\tp = s[:-i]\n\t\tif p == p[::-1]:\n\t\t\tprint('YES')\n\t\t\tbreak\n\telse:\n\t\tprint('NO')"}, {"source_code": "x = list(input())\nwhile \"0\" in x: x.remove(\"0\")\nif x == x[::-1]: print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "n=list(input())\nfor i in range(len(n)):\n\tif n[i]==\"0\":\n\t\tn.remove(n[i])\n\telse:\n\t\tbreak\nfor i in range(len(n)):\n\tif n[-i]==\"0\":\n\t\tn.remove(n[-i])\n\telse:\n\t\tbreak\nr=len(n)\nc=0\nfor i in range(r):\n\tif n[i]==n[-(i+1)]:\n\t\tc+=1\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak\nif r==c:\n\tprint(\"YES\")\n"}, {"source_code": "a=[0]*10\nn=input()\nfor i in n:\n a[int(i)]^=1\nif sum(a)-a[0]<2:print('YES')\nelse:print('NO')\n\n\n"}, {"source_code": "x = raw_input()\nx = str(x)\n\nif x[::-1] == x:\n print \"YES\"\nelse:\n len_add = len(x[:-1])\n\n for i in range(0, len_add):\n x = \"0\" + x\n if x[::-1] == x:\n print \"YES\"\n break\n print \"NO\"\n"}, {"source_code": "x=int(input())\nch=str(x)\nd={}\nfor i in range(len(ch)):\n if ch[i] in d:\n d[ch[i]]+=1\n else:\n d[ch[i]]=1\nif len(ch)%2==0:\n test=True\n for i in range(len(ch)):\n if d[ch[i]]%2==1:\n test=False\n break\nelse :\n k=0\n test=True\n for i in range(len(ch)):\n if d[ch[i]]%2==1:\n k+=1\n if k>1 :\n test=False\nif test :\n print('Yes')\nelse :\n print('NO')\n \n \n"}, {"source_code": "a=[0]*10\nn=input()\nfor i in n:\n a[int(i)]^=1\nif sum(a)<2:print('YES')\nelse:print('NO')\n\n\n"}, {"source_code": "import sys\nfrom itertools import *\nfrom cmath import *\n\ninput = sys.stdin.readline\nfrom math import *\n\n\n############ ---- Input Functions ---- ############\ndef inp():\n return int(input().strip())\n\n\ndef inlt():\n return list(map(int, input().split()))\n\n\ndef insr():\n s = input()\n return list(s[:len(s) - 1])\n\n\ndef invr():\n return map(int, input().split())\n\ndef iss(s):\n t=s[::-1]\n return t==s\n\ns=insr()\nwhile '0' in s:\n s.remove('0')\n\nprint(\"YES\" if iss(s) else \"NO\")"}, {"source_code": "x=int(input())\nch=str(x)\nd={}\nfor i in range(len(ch)):\n if ch[i] in d:\n d[ch[i]]+=1\n else:\n d[ch[i]]=1\nif len(ch)%2==0:\n test=True\n for i in range(len(ch)):\n if d[ch[i]]%2==1:\n test=False\n break\nelse :\n k=0\n test=True\n for i in range(len(ch)):\n if d[ch[i]]%2==1:\n k+=1\n if k>1 :\n test=False\nif test :\n print('Yes')\nelse :\n print('NO')\n \n \n"}, {"source_code": "input = input()\ninput = input.rstrip()\nquasi = True\nfor i in range(len(input)):\n j = len(input) - 1 - i\n if input[i] != input[j]:\n quasi = False\n print(\"NO\")\n break\nif quasi:\n print(\"YES\")\n"}, {"source_code": "def check(s,n):\n for i in xrange(n/2):\n if s[i]!=s[n-i-1]:\n return False\n return True\n \ns=raw_input().strip('0')\nn=len(s)\nif check(s,n)== True:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "S=input()\nN=len(S)\nD=[]\nC=[]\nC1=[]\nfor i in range(0,N):\n D.append(S[i])\nfor i in range(0,N):\n if D[i] not in C:\n if((D.count(D[i]))%2==0):\n C.append(D[i])\n else:\n if D[i] not in C1:\n C1.append(D[i])\nif(len(C)10**9 and n<1:\n n=int(input())\nt=str(n)\nj=0\nfor i in t :\n if t.count(i)%2!=0:\n j+=1\n if j>1:\n print('no')\n break\n if j==1 and len(t)%2==0:\n print('no')\n break\nelse :\n print('yes')\n "}, {"source_code": "n = input()\n\ndef isp(s):\n ok = True\n for i in range(len(s)//2):\n ok &= s[i] == s[-i]\n return ok\n\nfor i in range(20):\n s = n.rjust(i, '0')\n if isp(s):\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "t = input()\ni = t.rfind('0')\nif i != -1: t = t[:i]\nk = len(t) // 2\nprint(['YES', 'NO'][t[:k] == t[-k:][::-1]])"}, {"source_code": "n=list(input())\nfor i in range(len(n)):\n\tif n[i]==\"0\":\n\t\tn.remove(n[i])\n\telse:\n\t\tbreak\nfor i in range(len(n)):\n\tif n[-i]==\"0\":\n\t\tn.remove(n[-i])\n\telse:\n\t\tbreak\nr=len(n)\nc=0\nfor i in range(r):\n\tif n[i]==n[-(i+1)]:\n\t\tc+=1\n\telse:\n\t\tprint(\"NO\")\nif r==c:\n\tprint(\"YES\")"}, {"source_code": "def main():\n\ts=input()\n\tcheck=\"\"\n\tfor i in range(-1, -len(s)-1, -1):\n\t\tif(s[i]!='0'):\n\t\t\tbreak\n\tfor j in range(len(s)):\n\t\tif(s[j]!='0'):\n\t\t\tbreak\n\tif i==-1:\n\t\tcheck=s\n\telse:\n\t\tcheck=s[j:i+1]\n\tif ispalindrome(check):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")"}, {"source_code": "n=input()\ns=str(n)\ns=s[::-1]\ncnt=0\nfor i in range(len(s)):\n if s[i]=='0':\n cnt+=1\ns=s[cnt:]\nif s==s[::-1]:\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "row = raw_input()\ni = 0\nj = len(row)\nrow = list(row)\nwhile i < j:\n if row[i] != '0':\n break\n else:\n del row[i]\n i +=1\ni = 0\nwhile i < j:\n if row[j-1] != '0':\n break\n else:\n del row[j-1]\n j -= 1\n i += 1\n#print row\ni,j = 0,len(row)\nflag = 1\nif len(row) % 2 == 0:\n #print i ,j\n while i < j-1:\n if row[i] != row[j-1]:\n flag = 0\n i += 1\n j -= 1\n#else:\n# while i < j:\n# if row[i] != row[j]-1:\n# flag = 0\n# i += 1\n# j -= 1\nif flag:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n=list(input())\nfor i in range(len(n)):\n\tif n[i]==\"0\":\n\t\tn.remove(n[i])\n\telse:\n\t\tbreak\nfor i in range(len(n)):\n\tif n[-i]==\"0\":\n\t\tn.remove(n[-i])\n\telse:\n\t\tbreak\nr=len(n)\nc=0\nfor i in range(r):\n\tif n[i]==n[-(i+1)]:\n\t\tc+=1\n\telse:\n\t\tprint(\"NO\")\n\t\tbreak\nif r==c:\n\tprint(\"YES\")\n"}, {"source_code": "def pol(n):\n c=n\n length=len(n)\n count1=0\n count2=0\n if n[len(n)-1]==\"0\":\n for i in range(len(n)-1,-1,-1):\n if n[i]==\"0\":\n count1+=1\n else:\n break\n if n[0]==\"0\":\n for i in range(len(n)):\n if n[i] == \"0\":\n count2 += 1\n else:\n break\n print(count1)\n print(count2)\n if count1-count2!=0:\n for i in range(count1-count2):\n n=\"0\"+n\n t=\"\".join(reversed(c))\n print(t)\n if n[:length]==t:\n return \"YES\"\n else:\n return \"NO\"\n else:\n if c==\"\".join(reversed(n)):\n return \"YES\"\n else:\n return \"NO\"\n\nprint(pol(input().strip()))"}, {"source_code": "num = list(input())\nnum = [x for x in num if x != '0']\ncopy = [y for y in num]\nnum.reverse()\nif copy == num:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "S=input()\nN=len(S)\nD=[]\nC=[]\nC1=[]\nfor i in range(0,N):\n D.append(S[i])\nfor i in range(0,N):\n if D[i] not in C:\n if D[i] not in C1:\n if((D.count(D[i]))%2==0):\n C.append(D[i])\n else:\n if(D[i]!='0'):\n C1.append(D[i])\n else:\n C.append(D[i])\nj=0\nif(S[0]!=S[N-1]):\n if(S[0]!='0' and S[N-1]!='0'):\n j=1\nif (len(C1)>1 or j==1):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "x = raw_input()\nx = str(x)\n\nif x[::-1] == x:\n print \"YES\"\nelse:\n len_add = len(x[:-1])\n\n for i in range(0, len_add):\n x = \"0\" + x\n if x[::-1] == x:\n print \"YES\"\n break\n print \"NO\"\n"}, {"source_code": "def main():\n\ts=input()\n\tfor i in range(-1, -len(s)-1, -1):\n\t\tif(s[i]!='0'):\n\t\t\tbreak\n\tfor j in range(len(s)):\n\t\tif(s[j]!='0'):\n\t\t\tbreak\n\tif ispalindrome(s[j:i+1]):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\ndef ispalindrome(s):\n\tmid=len(s)//2\n\tif len(s)%2==0:\n\t\tfor i in range(mid):\n\t\t\tif s[i]!=s[-1-i]:\n\t\t\t\tbreak\n\t\telse:\n\t\t\treturn True\n\telse:\n\t\tfor i in range(mid-1):\n\t\t\tif s[i]!=s[-1-i]:\n\t\t\t\tbreak\n\t\telse:\n\t\t\treturn True\n\treturn False\nmain()"}, {"source_code": "n = input()\nz_cnt = 0\nflag = 0\nif n[0] == '0':\n for x in n:\n if x == '0' and flag == 0:\n z_cnt += 1\n else:\n flag = 1\n n = z_cnt * '0' + n\nelse:\n n = n[::-1]\n for x in n:\n if x == '0' and flag == 0:\n z_cnt += 1\n else:\n flag = 1\n n = n + z_cnt * '0'\nprint(n)\ni = n[::-1]\nif i == n:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n = input()\nd = []\nfor i in n:\n if i != \"0\":\n d.append(i)\nk = len(d) // 2\nif len(d) == 0:\n print(\"YES\")\n\nelif len(d) % 2 == 0:\n a = d[k:]\n a = reversed(a)\n if d[:k] == list(a):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n\n a = d[k + 1:]\n a = reversed(a)\n if d[:k] == list(a):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import sys\n\nnum = sys.stdin.readlines()[0].strip(\"0\")\n\nif num[::-1] == num:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\nd = []\nfor i in n:\n if i != \"0\":\n d.append(i)\nif d == list(reversed(d)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = [int(i) for i in input() if int(i)!=0]\nl = [0]*9\n\nfor e in n:\n\tl[int(e)-1]+=1\nev = 0\nod = 0\nfor i in l:\n\tif i==0:\n\t\tpass\n\telif i%2==0:\n\t\tev+=1\n\telif i%2!=0:\n\t\tod+=1\nif len(n)%2==0:\n\tif od==0:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tif od==1:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")"}, {"source_code": "inputs = input()\nlength = len(inputs)\narr = list('1'*length)\nfor i in range(length):\n arr[i] = inputs[i]\ni = 0\nwhile i < length:\n if inputs[i] != '0':\n break\n i = i + 1\nstart = i\ni = length\nwhile i >= 0:\n i = i - 1\n if inputs[i] != '0':\n break\nend = i\nif start >= end:\n print(\"YES\")\nwhile start <= end:\n if inputs[start] != inputs[end]:\n print(\"NO\")\n quit()\n else:\n start = start + 1\n end = end - 1\n\nprint(\"YES\")"}, {"source_code": "import sys\n\nfor line in sys.stdin:\n for var in line.split():\n print(var)\n r=var[::-1]\n for b in r:\n if(b!=\"0\"):\n break\n if(var[0]!=b):\n var=var[:-1]\n r=var[::-1]\n print(var+\" \"+r)\n if(var==r):\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\n\n"}, {"source_code": "x = input()\nt = int(x)\nk = 0\ni = 0\nif t%10 == 0:\n\tfor i in range(len(x)):\n\t\tif t%10 == 0:\n\t\t\tt = int(t/10)\n\t\telse:\n\t\t\tbreak\nr = str(t)\nfor i in range(int(len(r)/2)):\n\tif r[i] == r[len(r)-i-1]:\n\t\tcontinue\n\telse:\n\t\tk = 1\n\t\tbreak\nif i == int(len(r)/2) - 1 and k == 0 or i == 0 and k == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "s = input()\n\nctl = 0\nctr = 0\nif s != s[::-1] :\n for x in s :\n if x == '0' :\n ctl += 1\n else :\n break\n for x in s[::-1] :\n if x == '0' :\n ctr += 1\n else :\n break\n sn = s[ctl : -1 * ctr]\n if sn == sn[::-1] : print('YES')\n else : print('NO')\n \nelse :\n print('YES')"}, {"source_code": "t = input()\nif(t == t[::-1]) :\n\tprint('YES')\nelse :\n\tt = '00' + t\n\tif(t == t[::-1]) :\n\t\tprint('YES')\n\telse : \n\t\tprint('NO')"}, {"source_code": "number = input()\n# number = \"12100\"\n# index = len(number) - 1\nif len(number) % 2 == 0:\n if number[-1] == \"0\":\n index = len(number) - 1\n while number[index] == \"0\":\n index -= 1\n number = number[0:index + 1]\n middle = len(number) // 2\n first = list(number[:middle])\n second = list(number[middle:])\n second = list(reversed(second))\n # print(index, number, middle, first, second)\n if first == second:\n print('YES')\n else:\n print('NO')\n else:\n middle = len(number) // 2\n first = list(number[:middle])\n second = list(number[middle:])\n second = list(reversed(second))\n # print(number, middle, first, second)\n if first == second:\n print('YES')\n else:\n print('NO')\nelse:\n if number[-1] == \"0\":\n index = len(number) - 1\n while number[index] == \"0\":\n index -= 1\n number = number[0:index + 1]\n middle = len(number) // 2\n first = list(number[:middle])\n second = list(number[middle + 1:])\n second = list(reversed(second))\n # print(index, number, middle, first, second)\n if first == second:\n print('YES')\n else:\n print('NO')\n else:\n middle = len(number) // 2\n first = list(number[:middle])\n second = list(number[middle + 1:])\n second = list(reversed(second))\n # print(number, middle, first, second)\n if first == second:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "a=list(input())\nif a[-1]!='0':\n print('NO')\nelse:\n for i in range(len(a)-1,-1,-1):\n if a[i]=='0':\n a.pop(i)\n else:\n break\n p=len(a)\n p1=a[:]\n p2=p*[0]\n for i in range(p-1,-1,-1):\n p2[p-i-1]=a[i]\n if p1==p2:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "n=str(input())\nd=n[::-1]\nf=0\nfor i in range(0,len(d)):\n if(d[i]!='0'):\n f=i\n break\nn=n[0:(len(n)-f)]\ne=0\nfor i in range(0,len(n)):\n if(n.count(n[i])%2!=0):\n e=e+1\nif(e==1):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "x=str(input())\na=x.count(\"0\")\ns=\"\"\nif a>0:\n while a<=2*x.count(\"0\"):\n if x==x[::-1]:\n s=1\n break\n x=\"0\"+x\nif s==1:\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "x = input()\nt = int(x)\nk = 0\ni = 0\nif t%10 == 0:\n\tfor i in range(len(x)):\n\t\tif t%10 == 0:\n\t\t\tt = int(t/10)\n\t\telse:\n\t\t\tbreak\nr = str(t)\nfor i in range(int(len(r)/2)):\n\tif r[i] == r[len(r)-i-1]:\n\t\tcontinue\n\telse:\n\t\tk = 1\n\t\tbreak\nif i == int(len(r)/2) - 1 and k == 0 or i == 0 and k == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "t = input()\ni = t.rfind('0')\nif i != -1: t = t[:i]\nk = len(t) // 2\nprint(['NO', 'YES'][t[:k] == t[-k:][::-1]])"}, {"source_code": "from sys import stdin\nlines = stdin.readlines()\nx = str(lines[0])\nc = x[::-1]\nsumm = 0\nfor i in c:\n if i != \"0\":\n break\n elif i == \"0\":\n summ += 1\nx = \"0\"*summ+x\n\ndef pal(x):\n c = x[::-1]\n for i in range(len(x)/2):\n if x[i] != c[i]:\n return False\n return True\nif pal(x):\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "import sys\n\nnum = sys.stdin.readlines()[0].strip(\"0\")\n\nmiddle = len(num) // 2 + 1\n\nfor i in range(middle):\n if num == \"\" or type(num) != str:\n print(\"NO\")\n break\n if num[i] != num[-i - 1]:\n print(\"NO\")\n break\n elif i == middle - 1:\n print(\"YES\")\n else:\n continue"}, {"source_code": "from sys import stdin\nlines = stdin.readlines()\nx = str(lines[0])\nc = x[::-1]\nsumm = 0\nfor i in c:\n if i != \"0\":\n break\n elif i == \"0\":\n summ += 1\nx = \"0\"*summ+x\n\ndef pal(x):\n c = x[::-1]\n for i in range(len(x)/2):\n if x[i] != c[i]:\n return False\n return True\nif pal(x):\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "n=int(input())\nwhile n<1 and n>10**9:\n n=int(input())\nt=str(n)\n\nfor i in t: \n if t.count(i)%2!=0:\n print('no')\n break\nelse :\n print('yes')\n \n"}, {"source_code": "text = input().replace('0', '')\nfl = 0\nrez = 1\nfor i in set(text):\n if text.count(i) % 2 == 1:\n if fl:\n rez = 0\n break\n else:\n fl += 1\nprint('YES' if rez else 'NO')"}, {"source_code": "string = input()\n\nodd_cnt = 0\n\nfor i in range(10):\n chn = str(i)\n\n if string.count(chn) % 2 == 1:\n odd_cnt += 1\n\nif odd_cnt <= 1:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n = input()\nd = []\nfor i in n:\n if i != \"0\":\n d.append(i)\nk = len(d) // 2\nif len(d) % 2 == 0:\n a = d[k:]\n a = reversed(a)\n if d[:k] == a:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n\n a = d[k + 1:]\n a = reversed(a)\n if d[:k] == list(a):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "from sys import stdin\nlines = stdin.readlines()\nx = str(lines[0])\nc = x[::-1]\nsumm = 0\nfor i in c:\n if i != \"0\":\n break\n elif i == \"0\":\n summ += 1\nx = \"0\"*summ+x\n\ndef pal(x):\n c = x[::-1]\n for i in range(len(x)/2):\n if x[i] != c[i]:\n return False\n return True\nif pal(x):\n print \"YES\"\nelse:\n print \"NO\"\n "}, {"source_code": "string=raw_input(\"Enter string:\")\nif(string==string[::-1]):\n print(\"The string is a palindrome\")\nelse:\n print(\"The string isn't a palindrome\")"}], "src_uid": "d82278932881e3aa997086c909f29051"} {"nl": {"description": "Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to . Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it.He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles.", "input_spec": "The first and the single line of the input contains 6 space-separated integers a1,\u2009a2,\u2009a3,\u2009a4,\u2009a5 and a6 (1\u2009\u2264\u2009ai\u2009\u2264\u20091000) \u2014 the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists.", "output_spec": "Print a single integer \u2014 the number of triangles with the sides of one 1 centimeter, into which the hexagon is split.", "sample_inputs": ["1 1 1 1 1 1", "1 2 1 2 1 2"], "sample_outputs": ["6", "13"], "notes": "NoteThis is what Gerald's hexagon looks like in the first sample:And that's what it looks like in the second sample:"}, "positive_code": [{"source_code": "#!/usr/bin/env python3\n\nimport itertools\nimport sys\n\nfor x in itertools.permutations(map(int, input().split())):\n a = x[0] + x[1] + x[2]\n b = x[2] + x[3] + x[4]\n c = x[4] + x[5] + x[0]\n if (a == b) and (b == c):\n print(a ** 2 - x[0] ** 2 - x[2] ** 2 - x[4] ** 2)\n sys.exit(0)\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split());print((a+b+c)**2-a**2-c**2-e**2)"}, {"source_code": "# see the tut\n\na1, a2, a3, a4, a5, a6 = map(int, input().split())\nprint( (a1+a2+a3)**2 - a1**2 - a3**2 - a5**2 )"}, {"source_code": "from sys import stdin\nl=map(int,stdin.readline().split())\nprint (((l[0]+l[1]+l[2])**2)-(l[0]**2+l[2]**2+l[4]**2))"}, {"source_code": "a=input().split()\nprint(((int(a[0])+int(a[1])+int(a[-1]))**2)-(int(a[1])**2+int(a[3])**2+int(a[5])**2))"}, {"source_code": "ls = map(int, raw_input().split())\n\nma = max(ls)\nix_ma = ls.index(ma)\nleft = ls[(ix_ma - 1) % len(ls)]\nright = ls[(ix_ma + 1) % len(ls)]\n# print left, ma, right\n\nL = left + ma + right\n# print \"L = %d\" % L\ntot = L * L\nfor i in xrange(0, 6, 2):\n z = ls[(i + ix_ma + 1) % len(ls)]\n # print \"minus %d\" % z\n tot -= z * z\n\nprint tot\n"}, {"source_code": "def input_ints():\n return list(map(int, input().split()))\n\ndef output_list(v):\n print(' '.join(str(x) for x in v))\n\ndef main():\n a = input_ints()\n ans = 0\n x = a[0]\n for i in range(a[1] + a[2]):\n d = 0\n d += (1 if i < a[1] else -1)\n d += (1 if i < a[5] else -1)\n d //= 2\n ans += 2 * x + d\n x += d\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a,b,c,d,e,f = map(int, raw_input().split())\nprint (a+b+c)**2 - a**2 - c**2 - e**2"}, {"source_code": "[s1, s2, s3, s4, s5, s6] = map(int, raw_input('').split(' '))\ncount = 0\nfor i in xrange(s1, s1 + min(s2, s6)):\n count += ((2 * i) + 1)\nfor height in xrange(max(s6, s2) - min(s6, s2)):\n count += (2 * (s1 + min(s2, s6)))\nfor i in xrange(s4, s4 + min(s3, s5)):\n count += ((2 * i) + 1)\nprint count\n"}, {"source_code": "s = list(map(int, input().split()))\nprint((s[0] + s[1] + s[2])**2 - s[0]**2 - s[2]**2 - s[4]**2)"}, {"source_code": "def mp(): return map(int,input().split())\ndef lt(): return list(map(int,input().split()))\ndef pt(x): print(x)\ndef ip(): return input()\ndef it(): return int(input())\ndef sl(x): return [t for t in x]\ndef spl(x): return x.split()\ndef aj(liste, item): liste.append(item)\ndef bin(x): return \"{0:b}\".format(x)\ndef listring(l): return ' '.join([str(x) for x in l])\ndef printlist(l): print(' '.join([str(x) for x in l]))\n \na = lt()\nsum = a[3]+a[4]+a[5]\nprint(sum*sum-a[1]**2-a[3]**2-a[5]**2)"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\nprint((a+b+c)**2-a*a-c*c-e*e)"}, {"source_code": "a = [int(i) for i in input().split()]\n\nprint((a[0]+a[4]+a[5])**2 - (a[0]**2 + a[2]**2 + a[4]**2))"}, {"source_code": "a1, a2, a3, a4, a5,a6 = map(int,input().split())\n#a1, a2, a3, a4, a5,a6 = map(int,'1 2 1 2 1 2'.split())\nnow = a1 * 2 + 1\nres = now\nfor i in range(1, a2 + a3):\n if i == a2:\n now += 1\n if i == a6:\n now += 1\n if a2 < a6:\n if i < a2:\n now += 2\n if i >= a6:\n now -= 2\n else:\n if i < a6:\n now += 2\n if i >= a2:\n now -= 2\n \n res += now\nprint(res)\n \n \n \n"}, {"source_code": "H = input().split()\nH = [ int(x) for x in H ]\n\nleftSum = 1\nrightSum = 1\n\nleftIndex = 1\nrightIndex = 3\n\nbaseNum = H[ 2 ]\n\nsum = 0\n\nwhile( leftIndex >= 0 and rightIndex <= 4 ):\n\t\n\tsum += ( baseNum * 2 ) - 1 + leftSum + rightSum\n\n\tif( leftSum == 1 and rightSum == 1 ):\n\t\tbaseNum += 1\n\t\n\tif( leftSum == 0 and rightSum == 0 ):\n\t\tbaseNum -= 1\n\n\tH[ leftIndex ] -= 1\n\tH[ rightIndex ] -= 1\n\n\tif( H[ leftIndex ] == 0 ):\n\t\tleftSum = 0\n\t\tleftIndex -= 1\n\n\tif( H[ rightIndex ] == 0 ):\n\t\trightSum = 0\n\t\trightIndex += 1\n\nprint( sum )"}, {"source_code": "l = list(map(int,input().split()))\nt1 = min(l[0],l[2])\nt2 = min(l[3],l[5])\ns1 = 0\nf1 = 2*l[1]+1\nfl = f1+2*(t1)\ns1 = s1+((f1+fl-2)*(t1))//2\nf11 = 2*l[4]+1\nf1l = f11+2*t2\ns1 = s1+((f11+f1l-2)*(t2))//2\nr = abs(l[2]-l[0])\ns1 = s1 + r*2*(l[1]+t1)\nprint(s1)\n"}, {"source_code": "def intSqrt(x):\n a = 1\n b = x\n while a < b:\n c = (a+b)//2\n if c*c > x:\n b = c\n elif abs(c*c-x) < 0.1:\n a = c\n break\n else:\n a = c+1\n return a\na = [int(x) for x in input().split()]\narea = sum([a[i]*a[i+1] for i in range(0,6,2)])\nsides = [(a[i]**2+a[i+1]**2+a[i]*a[i+1])**0.5 for i in range(0,6,2)]\nsemi = sum(sides)/2\nprint(area+int(intSqrt(16*semi*(semi-sides[0])*(semi-sides[1])*(semi-sides[2])/3)))\n"}, {"source_code": "sides = list(map(int, raw_input().split()))\n\nt1 = sides[0]\nt2 = sides[2]\nt3 = sides[4]\nft = sides[0]+sides[1]+sides[2]\n\nprint((ft*(ft)) - (t1*(t1)) - (t2*(t2)) - (t3*(t3)))\n"}, {"source_code": "sides = map(int, raw_input().split(\" \"));\n\ntotal = 0;\nsize = sides[0];\n\nedge1 = min(sides[1],sides[5]);\nedge2 = max(sides[1],sides[5]);\n\nfor i in range(edge1):\n total += 2 * size + 1;\n size += 1;\n\nfor i in range(edge2-edge1):\n total += 2 * size;\n\nfor i in range(min(sides[2],sides[4])):\n total += 2 * size - 1;\n size -= 1;\n\nprint total;"}, {"source_code": "l = list(map(int, input().split()))\nx = l[0]+l[1]+l[2]\nprint(x**2 - l[0]**2 - l[2]**2 - l[4]**2)\n"}, {"source_code": "a = map(int, raw_input().split())\nprint sum(a[:3])**2 - a[0]**2 - a[2]**2 - a[4]**2\n"}, {"source_code": "import sys\n\nh = [int(x) for x in raw_input().split()]\n\n#triangle area -> l * 3^0.5 / 2\n\narea = (h[0]+h[1]+h[2])**2 - h[0]**2 - h[2]**2 - h[4]**2\nprint area\n"}, {"source_code": "from sys import stdin\na = [int(item) for item in stdin.readline().split()]\nt = a[0]+a[1]+a[2]\nprint t**2-a[0]**2-a[2]**2-a[4]**2\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\ndef sp(l, d):\n return l**2+l*d*2\n\nimport time\n\nA = [int(i) for i in input().split()]\n\nstart = time.time()\nm = min(A)\nwhile(A[0] != m):\n A = A [1:]+[A[0]]\n\nans = sp(A[0], A[1]) + (A[2]-A[0])*(A[0]+A[1])*2+sp(A[3], A[4])\nprint(ans)\nfinish = time.time()\n#print(finish - start)\n"}, {"source_code": "from math import *\n\n\nl = list(map(int, input().split()))\np = [(0, 0)]\nangle = 0\nfor i in range(5):\n\tp.append((p[-1][0] + l[i] * sin(angle), p[-1][1] + l[i] * cos(angle)))\n\tangle += pi / 3\nans = 0\nfor i in range(1, 5):\n\tans += 0.5 * abs(p[i][0] * p[i+1][1] - p[i][1] * p[i+1][0])\nprint(round(ans * 4 / sqrt(3)))\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\n\nprint((a+b+c)*(a+b+c)-a*a-c*c-e*e)"}, {"source_code": "#f=open('pe.in','r')\nimport math\n\na=[int(x) for x in input().split()]\nb=[[0,0]]\nb.append([a[0]/2,a[0]*math.sqrt(3)/2])\nb.append([a[0]/2+a[1],a[0]*math.sqrt(3)/2])\nb.append([a[0]/2+a[1]+a[2]/2,(a[0]-a[2])*math.sqrt(3)/2])\nb.append([a[0]/2+a[1]+a[2]/2-a[3]/2,(a[0]-a[2]-a[3])*math.sqrt(3)/2])\nb.append([a[0]/2+a[1]+a[2]/2-a[3]/2-a[4],(a[0]-a[2]-a[3])*math.sqrt(3)/2])\ns=0\nfor i in range(6):\n\ts+=b[i][0]*b[(i+1)%6][1]\n\ts-=b[i][1]*b[(i+1)%6][0]\nprint(round(math.fabs(s)*2/math.sqrt(3)))"}, {"source_code": "a=input().split()\nb=int(a[0])\nc=int(a[1])\nd=int(a[2])\ne=int(a[3])\nf=int(a[4])\ng=int(a[5])\nsb=((b+c+g)**2)\nsk=(c**2)+(e**2)+(g**2)\njlh=sb-sk\nprint(jlh)"}, {"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()\na1,a2,a3,a4,a5,a6=listInput()\nprint (a1+a2+a3)**2-a1**2-a3**2-a5**2"}, {"source_code": "#!/usr/bin/env python3\n\nimport itertools\nimport sys\n\nfor x in itertools.permutations(map(int, input().split())):\n a = x[0] + x[1] + x[2]\n b = x[2] + x[3] + x[4]\n c = x[4] + x[5] + x[0]\n if (a == b) and (b == c):\n print(a ** 2 - x[0] ** 2 - x[2] ** 2 - x[4] ** 2)\n sys.exit(0)\n"}, {"source_code": "a = map(int, raw_input().split())\nprint (a[0] + a[1] + a[2]) * (a[0] + a[1] + a[2]) - a[0] * a[0] - a[2] * a[2] - a[4] * a[4]"}, {"source_code": "a = map(int, raw_input().split())\nprint (a[0] + a[1] + a[2]) * (a[0] + a[1] + a[2]) - a[0] * a[0] - a[2] * a[2] - a[4] * a[4]"}, {"source_code": "# your code goes here\na,b,c,d,e,f = map(int,raw_input().split(\" \"))\nv = (a+b+c)*(a+b+c)\nv -= (a*a + c*c + e*e)\nprint v\n# print int(4*v/math.sqrt(3))"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\nprint((a+b+c)**2-a**2-c**2-e**2)"}, {"source_code": "a = [int(i) for i in input().split()]\nn = a[2] + a[3] + a[4]\nprint(n * n - a[0] * a[0] - a[2] * a[2] - a[4] * a[4])"}, {"source_code": "def f3(a):\n return a * a\n\ns = raw_input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\n\nprint f3(s[0] + s[1] + s[2]) - f3(s[0]) - f3(s[2]) - f3(s[4])\n"}, {"source_code": "a = list(map(int, input().split()))\nprint((a[5] + a[4]) * (a[0] + a[1]) * 2 - a[4] ** 2 - a[1] ** 2)\n"}, {"source_code": "def read_list(t): return [t(x) for x in input().split()]\ndef read_line(t): return t(input())\ndef read_lines(t, N): return [t(input()) for _ in range(N)]\n\nH = read_list(int)\n\nprint((H[0] + H[1] + H[2]) ** 2 - H[0] ** 2 - H[2] ** 2 - H[4] ** 2)\n"}, {"source_code": "'''input\n1 1 1 1 1 1\n'''\na1, a2, a3, a4, a5, a6 = map(int, input().split())\ns = a1 + a2 + a3\nprint(s**2 - a1**2 - a3**2 - a5**2)"}, {"source_code": "sides = [int(x) for x in input().split()]\nbigtriangle = (sides[0] + sides[1] + sides[2]) ** 2\nans = bigtriangle - sides[0]**2 - sides[2]**2 - sides[4]**2\nprint(ans)\n"}, {"source_code": "'''\nCreated on Apr 28, 2016\nGmail: r.haque.249.rh@gmail.com\n@author: Md. Rezwanul Haque\n'''\nfrom math import sqrt\na,b,c,d,e,f = map(int,input().split())\n#if(a==b==c==d==e==f):\n# ans = (a)*6\n # print(ans)\n#else:\nans = (a+b+c)**2 - (a)**2 - (c)**2 - (e)**2\nprint(ans)"}, {"source_code": "a = list(map(int, input().split()))\nd = a[0]\np = 1 + 2 * (d - 1)\nx = (1 + p) * d // 2\n\nd = a[2]\np = 1 + 2 * (d - 1)\ny = (1 + p) * d // 2\n\nd = a[4]\np = 1 + 2 * (d - 1)\nz = (1 + p) * d // 2\n\nb = a[0] + a[5] + a[4]\np = 1 + 2 * (b - 1)\ns = (1 + p) * b // 2\nprint(s - x - y - z)\n"}, {"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\na = get_int_vector()\n\nprint((a[0]+a[1]+a[2])**2-a[0]**2-a[2]**2-a[4]**2)\n"}, {"source_code": "def triangles(a1, a2, a3, a4, a5, a6):\n b1 = min(a2, a6)\n b2 = abs(a2-a6)\n b3 = min(a3, a5)\n return ((a1 + a1 + b1) * b1) + (2 * (a1 + b1) * b2) + ((a4 + a4 + b3) * b3)\n\n\ndef main():\n a1, a2, a3, a4, a5, a6 = readinti()\n print(triangles(a1, a2, a3, a4, a5, a6))\n\n##########\n\nimport sys\nimport time\nimport traceback\nfrom contextlib import contextmanager\nfrom io import StringIO\n\ndef readint():\n return int(input())\n\n\ndef readinti():\n return map(int, input().split())\n\n\ndef readintl():\n return list(readinti())\n\n\ndef readintll(k):\n return [readintl() for _ in range(k)]\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}\"\n f\"Got ({int((t1-t0)*1000000)/1000:0.3f} ms):\\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 1 1 1 1 1\n\"\"\", \"\"\"\\\n6\n\"\"\"), (\"\"\"\\\n1 2 1 2 1 2\n\"\"\", \"\"\"\\\n13\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"}, {"source_code": "a1,a2,a3,a4,a5,a6 = map(int,raw_input().split())\nprint (a1 + a2 + a3)**2 - a1**2 - a3**2 - a5**2\n"}, {"source_code": "def sqr(x:int) -> int:\n return x*x\n\na,b,c,d,e,f = map(int, input().split())\n\nif a==b==c==d==e==f:\n print(sqr(a)*6)\nelse:\n print(sqr(a+b+c)-sqr(a)-sqr(c)-sqr(e))\n"}, {"source_code": "from math import *\n\n\na = [int(i) for i in input().split()]\n\nres = pow((a[0]+a[1]+a[2]),2)-pow(a[0],2)-pow(a[2],2)-pow(a[4],2)\n\nprint('%.0f'%res)\n"}, {"source_code": "u = input().split()\na = int(u[0])\nc = int(u[2])\nd = int(u[3])\ne = int(u[4])\nprint((c + d + e) * (c + d + e) - a * a - c * c - e * e)"}, {"source_code": "def S(a):\n if a == 1:\n return 1\n else:\n return a+a*(a-1) \n\na,b,c,d,e,f = map(int,raw_input().split())\n\nre = S(min(a,c)+b)-S(b)+S(min(d,f)+e)-S(e)+2*(min(a,c)+b)*(max(a,c)-min(a,c))\nprint re\n"}, {"source_code": "l = list(map(int,input().split()))\nt1 = min(l[0],l[2])\nt2 = min(l[3],l[5])\ns1 = 0\nf1 = 2*l[1]+1\nfl = f1+2*(t1)\ns1 = s1+((f1+fl-2)*(t1))//2\nf11 = 2*l[4]+1\nf1l = f11+2*t2\ns1 = s1+((f11+f1l-2)*(t2))//2\nr = abs(l[2]-l[0])\ns1 = s1 + r*2*(l[1]+t1)\nprint(s1)\n"}, {"source_code": "from math import sqrt\na=[0]+[int(i) for i in input().split()]\nS=sqrt(3)*(a[6]*a[5]+a[1]*a[2]+a[3]*a[4])/2 + (a[1]-a[4])*(a[1]-a[4])*sqrt(3)/4\nprint(int(S*4/sqrt(3)+0.5))"}, {"source_code": "def solve(a):\n length_of_side = sum(a[:3])\n return length_of_side ** 2 - (a[0] ** 2 + a[2] ** 2 + a[4] ** 2)\n\n\n# assert solve([1000, 1000, 1, 1000, 1000, 1]) == 2004000\n# assert solve([2, 4, 5, 3, 3, 6]) == 83\n# assert solve([45, 19, 48, 18, 46, 21]) == 6099\n# assert solve([1, 2, 1, 2, 1, 2]) == 13\n# assert solve([1, 1, 1, 1, 1, 1]) == 6\n# assert solve([7, 5, 4, 8, 4, 5]) == 175\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\nprint((a+b+c)**2-a*a-c*c-e*e)"}, {"source_code": "# hexagon}\na,b,c,d,e,f=map(int,input().split())\nS=a+b+c\nprint(S**2-a**2-c**2-e**2)"}, {"source_code": "def f3(a):\n return a * a\n\ns = raw_input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\n\nprint f3(s[0] + s[1] + s[2]) - f3(s[0]) - f3(s[2]) - f3(s[4])\n"}, {"source_code": "a, b, c, d, e, f = map(int, raw_input().split(\" \"))\nside = a + b + c\nf = lambda x: x ** 2\narea = side ** 2 - f(a) - f(c) - f(e)\nprint area\n"}, {"source_code": "a = map(int,raw_input().split(\" \"))\nans = 0\nside = a[0]\ninc = min(a[5],a[1])\neq = max(a[5],a[1]) - inc\ndec = min(a[2],a[4])\nfor i in range(inc):\n\tans += 2*side + 1\n\tside += 1\nfor i in range(eq):\n\tans += 2*side\nfor i in range(dec):\n\tans += 2*side - 1\n\tside -= 1\nprint ans"}, {"source_code": "a=list(map(int, input().split()))\nprint((a[0]+a[1]+a[2])**2-a[0]**2-a[2]**2-a[4]**2)"}, {"source_code": "a = list(map(int, input().split()))\nprv, v = a[0], 0\nwhile a[2]:\n nxt = prv - 1\n if a[1]:\n nxt += 1\n a[1] -= 1\n else:\n a[2] -= 1\n if a[5]:\n nxt += 1\n a[5] -= 1\n else:\n a[4] -= 1\n v += prv + nxt\n prv = nxt\nprint(v)"}, {"source_code": "a1, a2, a3, _, a5, _ = list(map(int, input().split()))\nprint((a1 + a2 + a3) ** 2 - a1 ** 2 - a3 ** 2 - a5 ** 2)"}, {"source_code": "def get(a, b):\n return a*b\n\n\na = [int(x) for x in input().split()]\nres = (a[0] + a[5]/2 + a[1]/2)*(a[5] + a[4])*2\nres = res - get(a[1]/2, a[1]) - get(a[2]/2, a[2]) - get(a[4]/2, a[4]) - get(a[5]/2, a[5])\nprint(round(res))"}, {"source_code": "a = list(map(int, input().split(' ')))\nprint((a[0]+a[1]+a[2])**2 - (a[0]**2 + a[2]**2 +a[4]**2))"}, {"source_code": "def main():\n d = list(map(int, input().split()))\n res = 0\n for i in range(min(d[0], d[2])):\n res += (i + d[1] - 1) * 2 + 3\n for i in range(min(d[3], d[5])):\n res += (i + d[4] - 1) * 2 + 3\n if d[0] != d[2]:\n res += abs(d[0] - d[2]) * 2 * ( min(d[0], d[2]) + d[1] )\n\n print(res)\n\n\nmain()\n"}, {"source_code": "sides = list(map(int, input().split()))\nc0 = (0,0)\nc1 = (sides[0], 0)\nc2 = (c1[0] + sides[1]/2, 0.5*(3**0.5)*sides[1])\nc3 = (c2[0] - sides[2]/2, c2[1] + sides[2]*0.5*(3**0.5))\nc4 = (c3[0]-sides[3], c3[1])\nc5 = (c4[0]-sides[4]*0.5, c4[1]-sides[4]*0.5*(3**0.5))\nc6 = (c5[0]+sides[5]*0.5, c5[1]-sides[5]*0.5*(3**0.5))\n#print(c3)\n#print(c6)\n\narea1 = (c0[0]*c1[1]+c1[0]*c2[1]+c2[0]*c3[1]+c3[0]*c4[1]+c4[0]*c5[1]+c5[0]*c0[1])\narea2 = (c0[1]*c1[0]+c1[1]*c2[0]+c2[1]*c3[0]+c3[1]*c4[0]+c4[1]*c5[0]+c5[1]*c0[0])\n\nprint(int(round((area1-area2)/2/(3**0.5)*4)))\n\n\n"}, {"source_code": "import sys\n \na = map (int, sys.stdin.readline().split())\nprint ((a[0] + a[5]) * (a[1] + a[2]) * 2 - a[5] ** 2 - a[2] ** 2)"}, {"source_code": "a,b,c,d,e,f=map(int,raw_input().split());print (a+b+c)**2-a**2-c**2-e**2"}, {"source_code": "a1, a2, a3, a4, a5, a6 = map(int, raw_input().split())\nprint (a1+a2+a3)**2-a1**2-a3**2-a5**2"}, {"source_code": "a = [int(x) for x in input().split()]\nans = 0\nwhile max(a) > 1:\n\ti = 0\n\twhile a[i] == 1:\n\t\ti += 1\n\ta[i] -= 1\n\tif a[(i + 3) % 6] != 1:\n\t\tans += (a[(i + 1) % 6] + a[(i + 2) % 6]) * 2\n\t\ta[(i + 3) % 6] -= 1\n\t\tcontinue\n\tif a[(i + 2) % 6] != 1:\n\t\tans += a[(i + 1) % 6] * 2 + 1\n\t\ta[(i + 1) % 6] += 1\n\t\ta[(i + 2) % 6] -= 1\n\t\tcontinue\n\tans += a[(i - 1) % 6] * 2 + 1\n\ta[(i - 1) % 6] += 1\n\ta[(i - 2) % 6] -= 1\nprint(ans + 6)\n"}, {"source_code": "\nimport sys\nimport math\nimport itertools\nfrom collections import defaultdict\n\nsides = map(int, sys.stdin.readline().rstrip().split())\n\n\ncos30 = 0.8660254037844386467637231\nsin30 = 0.5\ntan30 = 0.5773502691896257645091487\nh = cos30*(sides[1] + sides[2])\n\ndef getupw(height):\n\tif height - 0.00001 < cos30*sides[1]:\n\t\tr = sides[0] + height*tan30\n\telse:\n\t\theightleft = height - cos30*sides[1]\n\t\tr = sides[0] + sin30*sides[1] - heightleft*tan30\n\tif height - 0.00001 < cos30*sides[-1]:\n\t\tl = -height*tan30\n\telse:\n\t\theightleft = height - cos30*sides[-1]\n\t\tl = -(sin30*sides[-1] - heightleft*tan30)\n\t#print r-l, r, l, \"rallalllaa\"\n\treturn int(round(r - l))\n\n#print getupw(5*cos30)\n#print \"\\n\\n\"\n\ntot = 0\ni = 0\nwhile i*cos30 < h - 0.00001:\n\tcurh = i*cos30\n\tfirst = getupw(curh)\n\tsec = getupw(curh+cos30)\n\t#print first, sec\n\ttot += first + sec\n\ti += 1\n\n\nprint tot\n\n"}, {"source_code": "from math import sqrt\na=map(float,raw_input().split());\nprint(int((a[1]+a[2])*(a[1]+a[5]+2*a[0])-(a[1]*a[1]+a[2]*a[2]+a[4]*a[4]+a[5]*a[5])/2.))"}, {"source_code": "sides = [int(x) for x in input().split()]\nbigtriangle = (sides[0] + sides[1] + sides[2]) ** 2\nans = bigtriangle - sides[0]**2 - sides[2]**2 - sides[4]**2\nprint(ans)\n"}, {"source_code": "s = list(map(int, input().split()))\nprint((s[0] + s[1] + s[2])**2 - s[0]**2 - s[2]**2 - s[4]**2)"}, {"source_code": "sides=map(int, raw_input().split(\" \"))\n\nprint (sides[1]+sides[0]+sides[2])*(sides[1]+sides[0]+sides[2])-sides[0]*sides[0]-sides[2]*sides[2]-sides[4]*sides[4]\n"}, {"source_code": "import sys\n\nan = list(map(int, sys.stdin.readline().split()))\nans = (an[0] + an[1] + an[2])*(an[0] + an[1] + an[2]) - an[0]*an[0] - an[2]*an[2] - an[4] * an[4]\nprint(ans)\n"}, {"source_code": "from math import sqrt\n\nth = lambda x, y: x*x + y*y + x*y\narea = lambda x, y, z: sqrt(4*x*y - (x + y - z)**2)\n\na, b, c, d, e, f = map(float, raw_input().split())\nab = th(a, b)\ncd = th(c, d)\nef = th(e, f)\na, b, c, d, e, f = [i*i for i in (a, b, c, d, e, f)]\nprint int(round((area(a, b, ab) + area(c, d, cd) + area(e, f, ef) + area(ab, cd, ef))/sqrt(3)))\n"}, {"source_code": "a = list(map(int, input().split()))\nprint((a[5] + a[4]) * (a[0] + a[1]) * 2 - a[4] ** 2 - a[1] ** 2)\n"}, {"source_code": "import math\nl=input().split()\n\nfor i in range(6):\n l[i]=int(l[i])\ns=(3**.5)/4\nb=(l[0]**2+l[1]**2+l[0]*l[1])**.5\nc=(l[2]**2+l[3]**2+l[2]*l[3])**.5\nd=(l[4]**2+l[5]**2+l[4]*l[5])**.5\n\ndef ar(b,c,d):\n s=b+c+d\n s/=2\n return (s*(s-b)*(s-c)*(s-d))**.5\n\nA=(ar(l[0],l[1],b)+ar(l[2],l[3],c)+ar(l[4],l[5],d)+ar(c,d,b))/(s)\n\nif(int(A)==int(A+.5)):\n print(int(A))\nelse:\n print(int(A+.5))\n"}, {"source_code": "from math import sqrt\na=map(float,raw_input().split());\nprint(int((a[1]+a[2])*(a[1]+a[5]+2*a[0])-(a[1]*a[1]+a[2]*a[2]+a[4]*a[4]+a[5]*a[5])/2.))"}, {"source_code": "a=list(map(int, input().split()))\nprint((a[0]+a[1]+a[2])**2 - a[0]**2 - a[2]**2 - a[4]**2)\n"}, {"source_code": "a = map(int, raw_input().split())\nprint sum(a[:3])**2-sum([i**2 for i in a[::2]])\n\n"}, {"source_code": "a = map (int, raw_input().split())\nprint (a[0] + a[1] + a[2]) ** 2 - a[0] ** 2 - a[2] ** 2 - a[4] ** 2\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\nprint((a+b+c)**2-a*a-c*c-e*e)"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n a = list(map(int,input().split()))\n ans = sum(a[:3])**2 - sum([a[i]*a[i] for i in range(0,6,2)])\n print(ans)\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "a1, a2, a3, _, a5, _ = list(map(int, input().split()))\nprint((a1 + a2 + a3) ** 2 - a1 ** 2 - a3 ** 2 - a5 ** 2)"}, {"source_code": "a,b,c,d,e,f=map(int,raw_input().split())\nprint (a+b+c)**2-a*a-c*c-e*e\n"}, {"source_code": "import sys\n\n(a1, a2, a3, a4, a5, a6) = map(int, input().split())\n\ndef calc(h):\n\tres = 0\n\tcur = 1\n\twhile cur <= h:\n\t\tres += cur + cur - 1\n\t\tcur += 1\n\treturn res\n\nax1 = a4\nax2 = a6\nans = calc(ax1 + ax2 + a5) - calc(ax1) - calc(ax2) - calc(a2)\nprint(ans)"}, {"source_code": "from sys import stdin\n\nsides = list(map(int, input().split()))\nside = sides[0]+sides[1]+sides[2]\nbig = ((2*side - 1)//2 + 1)**2\ns1 = sides[0]**2\ns2 = sides[2]**2\ns3 = sides[4]**2\nprint(big-s1-s2-s3)\n"}, {"source_code": "a = raw_input()\na = map(int,a.split(\" \"))\n\nprint (a[0]+a[1]+a[2])*(a[0]+a[1]+a[2])-a[0]*a[0]-a[2]*a[2]-a[4]*a[4]"}, {"source_code": "a = list(map(int, input().split()))\nprint((a[0] + a[1] + a[2]) ** 2 - a[0] ** 2 - a[2] ** 2 - a[4] ** 2)"}, {"source_code": "def f(x):\n ans = 0\n for i in range(1, x + 1):\n ans += 2 * i - 1\n\n return ans\n\na = list(map(int, input().split()))\nprint((a[0] + a[1]) * 2 * (a[1] + a[2]) - f(a[1]) - f(a[4]))"}, {"source_code": "s= input().split()\na=s[0]\nb=s[1]\nc=s[2]\nd=s[3]\ne=s[4]\nf=s[5]\nhasil = (((int(a)+int(b)+int(f))**2)-(int(b)**2+int(d)**2+int(f)**2))\nprint(hasil)"}, {"source_code": "def main():\n a1, a2, a3, a4, a5, a6 = map(int, input().split())\n print((a1 + a6) * (a5 + a6) * 2 - a6 * a6 - a3 * a3)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a = map(int,raw_input().split())\n# int(raw_input())\n# raw_input()\nl=a[0]+a[1]+a[2]\nprint l**2-a[0]**2-a[2]**2-a[4]**2\n"}, {"source_code": "l = list(map(int, input().split()))\nx = l[0]+l[1]+l[2]\nprint(x**2 - l[0]**2 - l[2]**2 - l[4]**2)\n"}, {"source_code": "arr = list(map(int, input().split()))\n\ndef Foo(element):\n\treturn element ** 2\t\n\nprint(Foo(arr[0] + arr[1] + arr[2]) - Foo(arr[0]) - Foo(arr[2]) - Foo(arr[4]));\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\n\nprint((a+b+c)**2-a*a-c*c-e*e)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "'''input\n1 1 1 1 1 1\n'''\na1, a2, a3, a4, a5, a6 = map(int, input().split())\ns = a1 + a2 + a3\nprint(s**2 - a1**2 - a3**2 - a5**2)"}, {"source_code": "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n a = list(map(int,input().split()))\n ans = sum(a[:3])**2 - sum([a[i]*a[i] for i in range(0,6,2)])\n print(ans)\n return\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "A = [int(x) for x in input().split()]\nprint((A[0] + A[1] + A[2])**2 - A[0]**2 - A[2]**2 - A[4]**2)\n"}, {"source_code": "l=[int(n) for n in input().split()]\nprint((l[0]+l[1]+l[2])**2 -l[4]**2-l[0]**2-l[2]**2)\n"}], "negative_code": [{"source_code": "def solve(a):\n r = 0\n while len(list(filter(lambda x: x > 0, a))) > 3:\n r += sum(2 * x - 1 for x in a)\n a = [x - 1 for x in a if x > 1]\n\n return r + (a[0] ** 2 if a else 0)\n\n\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "l=list(map(int,input().split()))\np=(max(l)+2)**2\nprint(p-l[0]**2-l[2]**2-l[4]**2)\n"}, {"source_code": "a_1, a_2, a_3, a_4, a_5, a_6 = map(int, input().split())\nprint((a_1 + a_2 + a_3) ** 2 - a_1 ** 2 - a_2 ** 2 - a_5 ** 2)"}, {"source_code": "def solve(a):\n total_sum = 0\n while True:\n current_sum = 0\n zero_count = 0\n one_count = 0\n for i in range(6):\n if a[i] == 0:\n zero_count += 1\n continue\n if a[i] == 1:\n one_count += 1\n current_sum += a[i] * 2 - 1\n current_sum -= (zero_count * 2)\n\n if zero_count >= 3 or (zero_count == 2 and one_count == 2):\n break\n b = []\n for i in range(6):\n if a[i] == 0:\n b.append(0)\n continue\n b.append(a[i] - 1)\n if a[i - 1] == 0:\n b[-1] = max(0, b[-1] - 1)\n if a[(i + 1) % 6] == 0:\n b[-1] = max(0, b[-1] - 1)\n a = b\n total_sum += current_sum\n\n zero_count = len(list(filter(lambda x: x == 0, a)))\n\n if zero_count == 3:\n return total_sum + (sum(a) // 3) ** 2\n elif zero_count == 2:\n return total_sum + sum(sorted(a, reverse=True)[:2])\n return total_sum\n\n\n# assert solve([2, 4, 5, 3, 3, 6]) == 83\n# assert solve([45, 19, 48, 18, 46, 21]) == 6099\n# assert solve([1, 2, 1, 2, 1, 2]) == 13\n# assert solve([1, 1, 1, 1, 1, 1]) == 6\n# assert solve([7, 5, 4, 8, 4, 5]) == 175\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "r = raw_input()\nl = r.split(' ')\na = int(l[0])\nb = int(l[1])\nc = int(l[2])\nd = int(l[3])\nmul1 = 0\nmul2 = 0\nfor x in range(0,b):\n\tmul1 = mul1+x\nfor y in range(0,c):\n\tmul2 = mul2+y\nprint b+(2*mul1)+(2*b*a)+c+(2*mul2)+(2*d*c)"}, {"source_code": "sides = list(map(int, input().split()))\nc0 = (0,0)\nc1 = (sides[0], 0)\nc2 = (c1[0] + sides[1]/2, 0.5*(3**0.5)*sides[1])\nc3 = (c2[0] - sides[2]/2, c2[1] + sides[2]*0.5*(3**0.5))\nc4 = (c3[0]-sides[3], c3[1])\nc5 = (c4[0]-sides[4]*0.5, c4[1]-sides[4]*0.5*(3**0.5))\nc6 = (c5[0]+sides[5]*0.5, c5[1]-sides[5]*0.5*(3**0.5))\n#print(c3)\n#print(c6)\n\narea1 = (c0[0]*c1[1]+c1[0]*c2[1]+c2[0]*c3[1]+c3[0]*c4[1]+c4[0]*c5[1]+c5[0]*c0[1])\narea2 = (c0[1]*c1[0]+c1[1]*c2[0]+c2[1]*c3[0]+c3[1]*c4[0]+c4[1]*c5[0]+c5[1]*c0[0])\n\nprint(int((area1-area2)/2/(3**0.5)*4))\n\n\n"}, {"source_code": "def sqr(a, b, c):\n return a * a + 2 * b * c\n\n\nif __name__ == '__main__':\n data = list(map(int, input().split()))\n print(sqr(data[0], data[1], data[2]) + sqr(data[3], data[4], data[5]))"}, {"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\n\ndef tringles(n):\n return 3+(n-1)*2\n\n\nsides=array()\n\na,l1,r1=sides[0],sides[5],sides[1]\nb,l2,r2=sides[3],sides[2],sides[4]\n\nans=0\n\n#print(l1,a,r1)\n#print(l2,b,r2)\n\nfor i in range(min(l1,r1)):\n ans+=tringles(a+i)\n\n\nfor i in range(min(l2,r2)):\n ans+=tringles(b+i)\n\nlayers=abs(l1-r1)\nans+=layers* tringles(a+min(l1,r1))\n\nprint(ans)\n\n\n \n\n\n\n\n\n"}, {"source_code": "a, b, c, d, e, f = (int(x) for x in input().split())\nans = (a * b + c * d + e * f) * 2 + (abs(a - b) * abs(c - d) if e - f else 0)\nprint(ans)\n"}, {"source_code": "ar=map(int,raw_input().split())\na=ar[0]\nb=ar[1]\nprint ((b+2*a)**2-(3*(a*a)))\n"}, {"source_code": "def solve(a):\n r = 0\n while len(list(filter(lambda x: x > 0, a))) > 3:\n r += sum(2 * x - 1 for x in a)\n a = [x - 1 for x in a if x > 1]\n\n return r + (a[0] ** 2 if a else 0)\n\n\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "a = list(map(int, input().split()))\n\ncnt = 0\n\nl = a[0]\nfor i in range(a[1]):\n cnt += (l + i) * 2 + 1\n\nl = a[0] + a[1]\nfor i in range(l, a[3], -1):\n cnt += i * 2 - 1\n\nprint(cnt)\n"}, {"source_code": "sides = list(map(int, input().split()))\nc0 = (0,0)\nc1 = (sides[0], 0)\nc2 = (c1[0] + sides[1]/2, 0.5*(3**0.5)*sides[1])\nc3 = (c2[0] - sides[2]/2, c2[1] + sides[2]*0.5*(3**0.5))\nc4 = (c3[0]-sides[3], c3[1])\nc5 = (c4[0]-sides[4]*0.5, c4[1]-sides[4]*0.5*(3**0.5))\nc6 = (c5[0]+sides[5]*0.5, c5[1]-sides[5]*0.5*(3**0.5))\n#print(c3)\n#print(c6)\n\narea1 = (c0[0]*c1[1]+c1[0]*c2[1]+c2[0]*c3[1]+c3[0]*c4[1]+c4[0]*c5[1]+c5[0]*c0[1])\narea2 = (c0[1]*c1[0]+c1[1]*c2[0]+c2[1]*c3[0]+c3[1]*c4[0]+c4[1]*c5[0]+c5[1]*c0[0])\n\nprint(int((area1-area2)/2/(3**0.5)*4))\n\n\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split())\nprint((a+b+c)*(a+b+c)-a*a-b*b-c*c)"}, {"source_code": "sm = 0\n\na = map(int, raw_input().split())\ni = 0\nwhile any(a):\n if sum(a) == 3:\n sm += 1\n break\n\n for i in range(6):\n\n if a[i]:\n sm += a[i] * 2 - 1\n a[i] /= 2\n\nprint sm"}, {"source_code": "def f3(a):\n if a == 0:\n return 0\n elif a == 1:\n return 1\n else:\n return f3(a - 1) + (a - 1) * 2 + 1\n\ns = raw_input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\n\nif s[0] == s[3]:\n print f3(s[0] + s[1] + s[2]) - f3(s[0]) - f3(s[1]) - f3(s[2])\nelse:\n print f3(s[0] + s[1] + s[2]) - 3 * f3(min(s[:2]))"}, {"source_code": "a = map(int,raw_input().split())\ns1 = min(a[1],a[5])\ns2 = max(a[1],a[5])-s1\ns3 = min(a[2],a[4])\nans = 0\nfor i in xrange(a[0],a[0]+s1):\n\tans+=(i*2)+1\nans+= s2 * ((s1+1)*2+1)\nfor i in xrange(a[3],a[3]+s3):\n\tans+=(i*2)+1\n\t\nprint ans"}, {"source_code": "a=[int(x) for x in input().split()]\n\na1=(a[0]+a[3])*(a[1]+a[2])\nprint(a1)\na2=(a[1]*a[2])\na3=(a[4]*a[5])\nprint(a2+a3)\nprint(a1+a2+a3)"}, {"source_code": "a=[int(x) for x in input().split()]\n\na1=(a[0]+a[3])*(a[1]+a[2])\nprint(a1)\na2=(a[1]*a[2])\na3=(a[4]*a[5])\nprint(a2+a3)\nprint(a1+a2+a3)"}, {"source_code": "#(2*mx+1)*2 + 2*(mx-1) + 1\n\na, b, c, d, e, f = [int(i) for i in input().split()]\n\nA = [a,b,c,d,e,f]\n\nA.sort()\n\nmx = max(A)\n\ns = 0\n\ntmp = min(A)\nmx = max(A)\n\nwhile tmp>0:\n tmp-=1\n s += 2*mx+1\n mx-=1\n\ndeficit = max(A) - min(A)\nans = 0\ntmp = max(A) - min(A)\ni=1\nwhile tmp>0:\n tmp-=1\n ans += (2*i + 1)\n i+=1\n\nprint(s*2 + ans)\n"}, {"source_code": "\ndef main():\n d = list(map(int, input().split()))\n res = 0\n for i in range(d[0]):\n res += (i+d[1]-1)*2+3\n for i in range(d[3]):\n res += (i+d[4]-1)*2+3\n print(res)\n\n\nmain()\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\ndef sp(l, d):\n return l**2+l*d*2\n\nimport time\n\nA = [int(i) for i in input().split()]\n\nstart = time.time()\n\nans = sp(A[0], A[1]) + sp(A[5], A[4])\nprint(ans)\nfinish = time.time()\n#print(finish - start)\n"}, {"source_code": "arr = list(map(int, input().split()))\n\ndef foo(arr):\n\tanswer = 0\n\tflag= False\n\ts = 0\n\tb = [ a // 2 for a in arr]\n\tfor element in arr:\n\t\tanswer += element * 2 - 1\n\t\telement //= 2\n\t\ts += element\n\t\tflag |= (element == 0)\n\n\tif flag:\n\t\tnum = s // 3\n\t\treturn answer + num ** 2\n\telse:\n\t\treturn answer + foo(b)\n\nprint(foo(arr))\n\t\t\t\n"}, {"source_code": "ar=map(int,raw_input().split())\na=ar[0]\nb=ar[1]\nprint ((b+2*a)**2-(3*(a*a)))\n"}, {"source_code": "a,b,c,d,e,f=map(int,input().split());print(b*(a+b+c)+2*a*c-e*e)"}, {"source_code": "\nimport sys\nimport math\nimport itertools\nfrom collections import defaultdict\n\nsides = map(int, sys.stdin.readline().rstrip().split())\n\n\ncos30 = 0.8660254037844386467637231\nsin30 = 0.5\nh = cos30*(sides[1] + sides[2])\nw = sides[0] + sin30*(sides[1] + sides[-1])\n\n\n\ndef getupw(height):\n\tif height - 0.00001 < cos30*sides[1]:\n\t\tr = sides[0] + sin30*height\n\telse:\n\t\theightleft = height - cos30*sides[1]\n\t\tr = sides[0] + sin30*sides[1] - heightleft*sin30\n\tif height - 0.00001 < cos30*sides[-1]:\n\t\tl = -sin30*height\n\telse:\n\t\theightleft = height - cos30*sides[1]\n\t\tl = -(sin30*sides[-1] - heightleft*sin30)\n\treturn int(round(r - l))\n\ntot = 0\ni = 0\nwhile i < h - 0.00001:\n\tfirst = getupw(i)\n\tsec = getupw(i+1)\n\ttot += first + sec\n\ti += 1\n\n\nprint tot\n"}, {"source_code": "'''\nCreated on Apr 28, 2016\nGmail: r.haque.249.rh@gmail.com\n@author: Md. Rezwanul Haque\n'''\nfrom math import sqrt\na,b,c,d,e,f = map(int,input().split())\nif(a==b==c==d==e==f):\n ans = (a)*6\n print(ans)\nelse:\n ans = (a+b+c)**2 - (a)**2 - (c)**2 - (e)**2\n print(ans)"}, {"source_code": "a = list(map(int, input().split()))\n\ncnt = 0\n\nl = a[0]\nfor i in range(a[1]):\n cnt += (l + i) * 2 + 1\n\nl = a[0] + a[1]\nfor i in range(l, a[3], -1):\n cnt += i * 2 - 1\n\nprint(cnt)\n"}, {"source_code": "from math import sqrt\ndef g(s):\n return sqrt((s * 3 / 2) * ((s * 3 / 2 - s) ** 3))\na = [float(i) for i in input().split()]\nf = g(a[0] + a[1] + a[2])\nprint(round(f - g(a[0]) - g(a[2]) - g(a[4])) / g(1))"}, {"source_code": "from math import sqrt\na=[0]+[int(i) for i in input().split()]\nS=sqrt(3)*(a[6]*a[5]+a[1]*a[2]+a[3]*a[4])/2 + (a[1]-a[4])*(a[1]-a[4])*sqrt(3)/4\nprint(int(S*4/sqrt(3)))"}, {"source_code": "def f3(a):\n if a == 0:\n return 0\n elif a == 1:\n return 1\n else:\n return f3(a - 1) + (a - 1) * 2 + 1\n\ns = raw_input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\n\nif s[0] == s[3]:\n print f3(s[0] + s[1] + s[2]) - f3(s[0]) - f3(s[1]) - f3(s[2])\nelse:\n print f3(s[0] + s[1] + s[2]) - 3 * f3(min(s[:2]))"}, {"source_code": "def main():\n d = list(map(int, input().split()))\n res = 0\n for i in range(min(d[0], d[2])):\n res += (i + d[1] - 1) * 2 + 3\n for i in range(min(d[3], d[5])):\n res += (i + d[4] - 1) * 2 + 3\n if d[0] != d[2]:\n res += abs(d[0] - d[2]) * 2 * ( min(d[0], d[2]) * 2 + d[1] )\n\n print(res)\n\n\nmain()\n"}, {"source_code": "from math import sqrt\na=[0]+[int(i) for i in input().split()]\nS=sqrt(3)*(a[6]*a[5]+a[1]*a[2]+a[3]*a[4])/2 + (a[1]-a[4])*(a[1]-a[4])*sqrt(3)/4\nprint(int(S*4/sqrt(3)))"}, {"source_code": "from math import sqrt\na=[0]+[int(i) for i in input().split()]\nS=sqrt(3)*(a[6]*a[5]+a[1]*a[2]+a[3]*a[4])/2 + (a[1]-a[4])*(a[1]-a[4])*sqrt(3)/4\nprint(int(S*4/sqrt(3)))"}, {"source_code": "def main():\n d = list(map(int, input().split()))\n res = 0\n for i in range(min(d[0], d[2])):\n res += (i + d[1] - 1) * 2 + 3\n for i in range(min(d[3], d[5])):\n res += (i + d[4] - 1) * 2 + 3\n if d[0] != d[2]:\n res += abs(d[0] - d[2]) * 2 * (( min(d[0], d[2]) * 2 + d[1] + 1) // 2)\n\n print(res)\n\n\nmain()\n"}, {"source_code": "a = list(map(int, input().split()))\nans = 3 + ((a[0] - 1) * 2)\n\nfor i in range(1, a[1]):\n ans += ans + 2\n\ntem = 3 + ((a[3] - 1) * 2) - 2\nans += 3 + ((a[3] - 1) * 2)\n\nfor i in range(1, a[2]):\n ans += tem\nprint(ans)\n"}, {"source_code": "def solve(a):\n total_sum = 0\n while len(list(filter(lambda x: x > 0, a))) > 3:\n current_sum = 0\n zero_count = 0\n for i in range(6):\n if a[i] == 0:\n zero_count += 1\n continue\n current_sum += a[i] * 2 - 1\n current_sum -= (zero_count * 2)\n for i in range(6):\n if a[i] > 0:\n a[i] -= 1\n total_sum += current_sum\n return total_sum + (1 if a == [1, 0, 1, 0, 1, 0] or a == [0, 1, 0, 1, 0, 1] else 0)\n\n\n# assert solve([2, 4, 5, 3, 3, 6]) == 83\n# assert solve([1, 2, 1, 2, 1, 2]) == 13\n# assert solve([1, 1, 1, 1, 1, 1]) == 6\n\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\nprint((a + b + c) ** 2 - (a ** 2 - c ** 2 - e ** 2))"}, {"source_code": "A = list(map(int, input().split()))\n\nans = A[1] * A[2] * 2\nans += A[1] ** 2\n\nans += A[4] * A[5] * 2\nans += A[4] ** 2\n\nprint(ans)\n"}, {"source_code": "a, b, c, d, e, f = (int(x) for x in input().split())\nans = (a * b + c * d + e * f) * 2 + (abs(a - b) * abs(c - d) if e - f else 0)\nprint(ans)\n"}, {"source_code": "l = list(map(int,input().split()))\ns1 = 0\nfor i in range(2*l[1]+1,2*l[1]+2*l[0]+1,2):\n s1 = s1 + i\nfor j in range(2*l[4]+1,2*l[4]+2*l[5]+1,2):\n s1 = s1 + j\nprint(s1)"}, {"source_code": "a1,a2,a3,a4,a5,a6=map(int,input().split())\ns=a1+2\nans=s\nfor i in range(1,a2):\n s+=2\n ans+=s\nans+=s\nfor i in range(1,a3):\n s-=2\n ans+=s\nprint(ans)"}, {"source_code": "sides = list(map(int, input().split()))\n\ndef triangle(pos):\n peak = sides[pos]\n side = sides[pos+1]\n base = peak + side\n return side * (base + peak)\n\ntop = triangle(0)\nbottom = triangle(3)\nprint(top + bottom)\n"}, {"source_code": "a=sorted(map(int,raw_input().split()))\ns=a[0]*2+a[-1]\nprint s*s-3*a[0]*a[0]\n"}, {"source_code": "a = [int(x) for x in input().split()]\narea = sum([a[i]*a[i+1] for i in range(0,6,2)])\nsides = [(a[i]**2+a[i+1]**2+a[i]*a[i+1])**0.5 for i in range(0,6,2)]\nsemi = sum(sides)/2\nprint(int(area+(16/3*semi*(semi-sides[0])*(semi-sides[1])*(semi-sides[2]))**0.5))\n"}, {"source_code": "def solve(a):\n r = 0\n while len(list(filter(lambda x: x > 0, a))) > 3:\n r += sum(2 * x - 1 for x in a)\n a = [x - 1 for x in a if x > 1]\n\n return r + (a[0] ** 2 if a else 0)\n\n\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "a = list(map(int, input().split()))\nprint((a[5] + a[2]) * (a[0] + a[1]) * 2 - a[2] ** 2 - a[1] ** 2)\n"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\nmxn = max(a, b, c, d, e, f)\nmin = min(a, b, c, d, e, f)\nprint((mxn + min + min) ** 2 - (min ** 2) * 3)\n"}, {"source_code": "a = [int(x) for x in input().split()]\narea = sum([a[i]*a[i+1] for i in range(0,6,2)])\nsides = [(a[i]**2+a[i+1]**2+a[i]*a[i+1])**0.5 for i in range(0,6,2)]\nsemi = sum(sides)/2\nprint(int(area+(16/3*semi*(semi-sides[0])*(semi-sides[1])*(semi-sides[2]))**0.5))\n"}, {"source_code": "a, b, c, d, e, f = (int(x) for x in input().split())\nans = (a * b + c * d + e * f) * 2 + (abs(a - b) * abs(c - d) if e - f else 0)\nprint(ans)\n"}, {"source_code": "a1,a2,a3,a4,a5,a6=map(int,input().split())\ns=a1+2\nans=s\nfor i in range(1,a2):\n s+=2\n ans+=s\nans+=s\nfor i in range(1,a3):\n s-=2\n ans+=s\nprint(ans)"}, {"source_code": "\ndef main():\n d = list(map(int, input().split()))\n res = 0\n for i in range(d[0]):\n res += (i+d[1]-1)*2+3\n for i in range(d[3]):\n res += (i+d[4]-1)*2+3\n print(res)\n\n\nmain()\n"}, {"source_code": "a=sorted(map(int,raw_input().split()))\ns=a[0]*2+a[-1]\nprint s*s-3*a[0]*a[0]\n"}, {"source_code": "import math\ndef solve(sides):\n\ttotal = 0\n\tbase1 = sides[1] + sides[0]\n\ttrap1Area = ((base1 + sides[0]) * (sides[1] * (0.5 * math.sqrt(3)))) / 2.0\n\ttotal += int(trap1Area / (0.25 * math.sqrt(3)))\n\n\tbase2 = sides[2] + sides[3]\n\ttrap2Area = ((base2 + sides[3]) * (sides[2] * (0.5 * math.sqrt(3)))) / 2.0\n\ttotal += int(trap2Area / (0.25 * math.sqrt(3)))\n\n\treturn total\n\n\nsides = map(int, raw_input().split())\nprint solve(sides)"}, {"source_code": "def solve(a):\n r = 0\n while len(list(filter(lambda x: x > 0, a))) > 3:\n r += sum(2 * x - 1 for x in a)\n a = [x - 1 for x in a if x > 1]\n\n return r + (a[0] ** 2 if a else 0)\n\n\na = list(map(int, input().split()))\n\nr = solve(a)\nprint(r)\n"}, {"source_code": "import math\n\n\ndef solve():\n a = [int(i) for i in input().split()]\n sum_t = 0\n\n for i in a:\n sum_t += i\n\n print(sum_t + math.trunc(sum_t / 2))\n\nif __name__ == \"__main__\":\n solve()\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\n\ndef tringles(n):\n return 3+(n-1)*2\n\n\nsides=array()\n\na,l1,r1=sides[0],sides[5],sides[1]\nb,l2,r2=sides[3],sides[2],sides[4]\n\nans=0\n\n#print(l1,a,r1)\n#print(l2,b,r2)\n\nfor i in range(min(l1,r1)):\n ans+=tringles(a+i)\n\n\nfor i in range(min(l2,r2)):\n ans+=tringles(b+i)\n\nlayers=abs(l1-r1)\nans+=layers* tringles(a+min(l1,r1))\n\nprint(ans)\n\n\n \n\n\n\n\n\n"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\nmxn = max(a, b, c, d, e, f)\nmin = min(a, b, c, d, e, f)\nprint((mxn + min + min) ** 2 - (min ** 2) * 3)\n"}, {"source_code": "sides = list(map(int, input().split()))\nc0 = (0,0)\nc1 = (sides[0], 0)\nc2 = (c1[0] + sides[1]/2, 0.5*(3**0.5)*sides[1])\nc3 = (c2[0] - sides[2]/2, c2[1] + sides[2]*0.5*(3**0.5))\nc4 = (c3[0]-sides[3], c3[1])\nc5 = (c4[0]-sides[4]*0.5, c4[1]-sides[4]*0.5*(3**0.5))\nc6 = (c5[0]+sides[5]*0.5, c5[1]-sides[5]*0.5*(3**0.5))\n#print(c3)\n#print(c6)\n\narea1 = (c0[0]*c1[1]+c1[0]*c2[1]+c2[0]*c3[1]+c3[0]*c4[1]+c4[0]*c5[1]+c5[0]*c0[1])\narea2 = (c0[1]*c1[0]+c1[1]*c2[0]+c2[1]*c3[0]+c3[1]*c4[0]+c4[1]*c5[0]+c5[1]*c0[0])\n\nprint(int((area1-area2)/2/(3**0.5)*4))\n\n\n"}, {"source_code": "a,b,c,d,e,f = map(int, input().split())\nprint(((a + b + c + d + e + f) // 2) ** 2 - a**2 - c**2 - e**2)"}, {"source_code": "def f3(a):\n if a == 0:\n return 0\n elif a == 1:\n return 1\n else:\n return f3(a - 1) + (a - 1) * 2 + 1\n \ndef f4(a, b):\n if a == 1:\n return 2 * b\n elif b == 1:\n return 2 * a\n else:\n return f4(a - 1, b - 1) * 3\n\ns = raw_input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\nres = 0 \nif s[0] == s[3]:\n # 4 or 0\n s = s[:3]\n s.sort()\n while s[0] > 0:\n res = res + 2 * (s[0] * 2 - 1 + s[1] * 2 - 1 + s[2] * 2 - 1)\n s[0] = s[0] - 1\n s[1] = s[1] - 1\n s[2] = s[2] - 1\n if s[0] == s[1] == s[2]:\n print res\n else:\n print res + f4(s[1], s[2])\nelse:\n s = s[:2]\n s.sort()\n while s[0] > 0:\n res = res + 3 * (s[0] * 2 - 1 + s[1] * 2 - 1)\n s[0] = s[0] - 1\n s[1] = s[1] - 1\n print res + f3(s[1])"}, {"source_code": "def triang(n):\n a = 0\n i = 1\n while i <= n:\n a += (2 * i - 1)\n i += 1\n return a\n\na = input().split()\nfor i in range(len(a)):\n a[i] = int(a[i])\nc = a[0] + a[1] + a[5]\nprint(c)\nprint(triang(c) - triang(a[1]) - triang(a[3]) - triang(a[5]))"}, {"source_code": "a, b, c, d, e, f = map(int, input().split())\nprint((a + c + e) **2 - b**2 - c**2 - d**2)"}, {"source_code": "import sys\nimport string\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom functools import lru_cache\nfrom collections import Counter\nfrom fractions import Fraction\n\ndef mi(s):\n return map(int, s.strip().split())\n\ndef lmi(s):\n return list(mi(s))\n\ndef tmi(s):\n return tuple(mi(s))\n\ndef mf(f, s):\n return map(f, s)\n\ndef lmf(f, s):\n return list(mf(f, s))\n\ndef js(lst):\n return \" \".join(str(d) for d in lst)\n\ndef jsns(lst):\n return \"\".join(str(d) for d in lst)\n\ndef line():\n return sys.stdin.readline().strip()\n\ndef linesp():\n return line().split()\n\ndef iline():\n return int(line())\n\ndef mat(n):\n matr = []\n for _ in range(n):\n matr.append(linesp())\n return matr\n\ndef matns(n):\n mat = []\n for _ in range(n):\n mat.append([c for c in line()])\n return mat\n\ndef mati(n):\n mat = []\n for _ in range(n):\n mat.append(lmi(line())) \n return mat\n\ndef pmat(mat):\n for row in mat:\n print(js(row))\n\ndef calc(a, b, c):\n d = a * math.cos(math.pi / 3) / 2\n e = c * math.cos(math.pi / 3) / 2\n h = a * math.sin(math.pi / 3)\n return h * b + h * e + h * d\n\ndef main():\n k = 0.433013\n a, b, c, d, e, f = lmi(line())\n print(int(round((calc(a, b, c) + calc(d, e, f)) / k, 2)))\n\nmain()\n"}, {"source_code": "a = list(map(int, input().split()))\nans = 3 + ((a[0] - 1) * 2)\n\nfor i in range(1, a[1]):\n ans += ans + 2\n\ntem = 3 + ((a[3] - 1) * 2) - 2\nans += 3 + ((a[3] - 1) * 2)\n\nfor i in range(1, a[2]):\n ans += tem\nprint(ans)\n"}, {"source_code": "l = [int(s) for s in raw_input().split()]\nn1 = min(l[1],l[5])\nn2 = min(l[4],l[2])\n#print n1,n2\n#print max(l[1],l[5])-n1, max(l[2],l[4])-n2\nprint 2*l[0]*n1 + n1*n1 + 2*(max(l[1],l[5])-n1) + 2*l[3]*n2 + n2*n2\n"}, {"source_code": "# mukulchandel\na1,a2,a3,a4,a5,a6=map(int,input().split())\na=a1\nb=a2\ns=(a+b)\nans=0\nfor i in range(a):\n ans=ans+2*s-1\n s=s-1\ns=(a+b)\nfor i in range(b):\n ans=ans+2*s-1\n s=s-1\nprint(ans)\n"}, {"source_code": "l = list(map(int,input().split()))\nk1 = min(l[1]+l[1]+1,l[-2]+l[-2]+1)\nk2 = max(l[1]+l[1]+1,l[-2]+l[-2]+1)\ns1 = 0\nfor i in range(k1,k1+2*l[0],2):\n s1 = s1 + i\nfor j in range(k2,k2+2*l[5],2):\n s1 = s1 + j\nprint(s1)"}, {"source_code": "a=sum(map(int,raw_input().split())[:3])\nprint a*a-3\n"}, {"source_code": "sm = 0\n\na = map(int, raw_input().split())\ni = 0\nwhile any(a):\n if sum(a) == 3:\n sm += 1\n break\n\n for i in range(6):\n\n if a[i]:\n sm += a[i] * 2 - 1\n a[i] /= 2\n\nprint sm"}, {"source_code": "a=[int(x) for x in input().split()]\nans=0\nans+=(2*a[0]+min(a[1],a[5]))*min(a[1],a[5])\nans+=(2*a[0]-1+2*min(a[1],a[5]))*(max(a[1],a[5])-min(a[1],a[5]))\nans+=(a[0]+min(a[1],a[5])+a[3])*(min(a[2],a[4]))\nprint(ans)\n"}, {"source_code": "a = sorted(list(map(int, input().split())))\nif a[2] != a[3]:\n print(a[0] ** 2 + 4 * a[0] * a[-1] + a[-1] ** 2)\nelif a[1] != a[2]:\n print(4 * a[0] * a[-1] + 2 * a[-1] ** 2)\nelse:\n print(4 * a[0] * a[-1] + 2 * a[0] ** 2)"}, {"source_code": "a=sorted(map(int,raw_input().split()))\ns=a[0]*2+a[-1]\nprint s*s-3*a[0]*a[0]\n"}, {"source_code": "a = list(set(map(int, input().split(' '))))\nif len(a) == 1:\n x = y = a[0]\nelse:\n x = a[0]\n y = a[1]\nprint(x**2 + y**2 + 4*x*y)"}, {"source_code": "a = list(map(int, input().split()))\nans = 3 + ((a[0] - 1) * 2)\n\nfor i in range(1, a[1]):\n ans += ans + 2\n\ntem = 3 + ((a[3] - 1) * 2) - 2\nans += 3 + ((a[3] - 1) * 2)\n\nfor i in range(1, a[2]):\n ans += tem\nprint(ans)\n"}, {"source_code": "def answer(a1,a2,a3,a4,a5,a6):\n \n count=0\n for i in range(1,a2+1):\n count+=2*(i+a1)-1\n \n for i in range(1,a3+1):\n count+=2*(i+a4)-1\n \n return count\n \n \n \n \na1,a2,a3,a4,a5,a6=map(int,input().split())\nprint(answer(a1,a2,a3,a4,a5,a6)) "}, {"source_code": "r = raw_input()\nl = r.split(' ')\na = int(l[0])\nb = int(l[1])\nc = int(l[2])\nd = int(l[3])\nmul1 = 0\nmul2 = 0\nfor x in range(0,b):\n\tmul1 = mul1+x\nfor y in range(0,c):\n\tmul2 = mul2+y\nprint b+(2*mul1)+(2*b*a)+c+(2*mul2)+(2*d*c)"}, {"source_code": "inp=input()\ninp=inp.split()\ninp=[int(i) for i in inp]\ns=inp[0]+inp[1]+inp[2]\ns*=s\ns-=(inp[0]*inp[0]+inp[1]*inp[1]+inp[2]*inp[2])\nprint(s)"}, {"source_code": "a=map(int,raw_input().split())\ns=sum(a[:3])\nm=min(a)\nprint s*s-3*m*m\n"}, {"source_code": "a = list(map(int, input().split()))\nprint((sum(a[:3]) ** 2) - (sum(a[0::2])))\n"}, {"source_code": "def triang(n):\n a = 0\n i = 1\n while i <= n:\n a += (2 * i - 1)\n i += 1\n return a\n\na = input().split()\nfor i in range(len(a)):\n a[i] = int(a[i])\nc = a[0] + a[1] + a[5]\nprint(c)\nprint(triang(c) - triang(a[1]) - triang(a[3]) - triang(a[5]))"}, {"source_code": "a = map(int,raw_input().split())\ns1 = min(a[1],a[5])\ns2 = max(a[1],a[5])-s1\ns3 = min(a[2],a[4])\nans = 0\nfor i in xrange(a[0],a[0]+s1):\n\tans+=(i*2)+1\nans+= s2 * ((a[0]+s1)*2+1)\nfor i in xrange(a[3],a[3]+s3):\n\tans+=(i*2)+1\n\t\nprint ans"}, {"source_code": "a = [int(i) for i in input().split()]\ntriangles = min(a[1],a[3])*(2*a[2] + min(a[1], a[3])) + abs(a[3] - a[1])*(a[2] + 2*min(a[1],a[3])) + min(a[0], a[4])*(2*a[5] + min(a[0], a[4]))\nprint(triangles)\n"}, {"source_code": "__author__ = 'trunghieu11'\n\n\ndef solve(hexagon):\n answer = hexagon[0] + hexagon[1] + hexagon[2]\n answer = answer * answer - hexagon[0] * hexagon[0] * 3\n return answer\n\n\nif __name__ == '__main__':\n hexagon = list(map(int, raw_input().split(\" \")))\n print solve(hexagon)"}, {"source_code": "import math\n\na, b, c, d, e, f = map(int, input().split(\" \"))\nx = b + a + c\ny = d + c + e\nz = f + e + a\ns = x*x - a - c - e\nprint(int(s)) "}, {"source_code": "__author__ = 'trunghieu11'\n\n\ndef solve(hexagon):\n answer = hexagon[0] + hexagon[1] + hexagon[2]\n answer = answer * answer - hexagon[0] * hexagon[0] * 3\n return answer\n\n\nif __name__ == '__main__':\n hexagon = list(map(int, raw_input().split(\" \")))\n print solve(hexagon)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\n\ndef solve(a, b) -> bool:\n m = min([a, b])\n l = max([a, b])\n left = 3 * m * (m + 1) - m - 5 if m > 1 else 0\n right = 3 * l * (l + 1) - (5 * l) - 1 if l > 1 else 0\n return 6 + left + right\n\n\ndef getinput():\n def getints_line():\n return list(map(int, input().split(' ')))\n [a, b] = getints_line()[:2]\n return a, b\n\n\ndef test():\n art = Assert()\n art.equal(solve(1, 1), 6)\n art.equal(solve(1, 2), 13)\n art.equal(solve(2, 1), 13)\n art.equal(solve(2, 2), 24)\n art.equal(solve(2, 3), 37)\n art.equal(solve(3, 3), 54)\n\n\ndef main():\n # test()\n print(solve(*getinput()))\n # print('\\n'.join(map(str, solve(*getinput()))))\n\n\nimport unittest\nclass Assert(unittest.TestCase):\n def equal(self, a, b):\n self.assertEqual(a, b)\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "import math\ndef sqr(x):\n return x * x\n\n\ndef side_(a,b):\n cos_120 = -0.5\n return abs((sqr(a) * sqr(b) - (2 * a * b * cos_120)) ** 0.5)\n\ndef triangle_area(a,b,c):\n p = (a + b + c) / 2\n return abs((p * (p-a) * (p-b) * (p-c)) ** 0.5)\n\n\n\na1,a2,a3,a4,a5,a6 = map(int,input().split())\nsin_120 = (-1) * ((3 ** 0.5) / 2)\narea1 = abs((a1 * a2) / 2 * sin_120)\narea2 = abs((a3 * a4) / 2 * sin_120)\narea3 = abs((a5 * a6) / 2 * sin_120)\nside1 = side_(a1,a2)\nside2 = side_(a3,a4)\nside3 = side_(a5,a6)\ns = triangle_area(side1,side2,side3)\nall_area = area1 + area2 + area3 + s\nprint(round((all_area / ((3 ** 0.5) / 4))+1))"}, {"source_code": "import math as m\na = list(map(int, input().split()))\n\ndef area_tr(l):\n h = m.sqrt(l**2 + (l/2)**2)\n a = l*h/2\n\n a1 = 0.5 * m.sqrt(1 + 0.5**2)\n return int(a / a1)\n\nsol = 0\nif a[0] == a[1] and a[1] == a[2]:\n sol = 6 * area_tr(a[0])\nelif a[0] != a[1] and a[1] != a[2] and a[2] != a[3]:\n min_l = min(a)\n max_l = max(a)\n\n sol = area_tr(min_l) + 3\n sol += max_l * 3 + (max_l-1) * 3\nelse:\n min_l = min(a)\n max_l = max(a)\n\n sol = area_tr(min_l + max_l) * 2\n sol -= area_tr(min_l) * 2\n\nprint(sol)\n"}, {"source_code": "r = raw_input()\nl = r.split(' ')\na = int(l[0])\nb = int(l[1])\nc = int(l[2])\nd = int(l[3])\nmul1 = 0\nmul2 = 0\nfor x in range(0,b):\n\tmul1 = mul1+x\nfor y in range(0,c):\n\tmul2 = mul2+y\nprint b+(2*mul1)+(2*b*a)+c+(2*mul2)+(2*d*c)"}, {"source_code": "a=map(int,raw_input().split())\ns=sum(a[:3])\nm=min(a)\nprint s*s-3*m*m\n"}, {"source_code": "import sys\nimport string\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom functools import lru_cache\nfrom collections import Counter\nfrom fractions import Fraction\n\ndef mi(s):\n return map(int, s.strip().split())\n\ndef lmi(s):\n return list(mi(s))\n\ndef tmi(s):\n return tuple(mi(s))\n\ndef mf(f, s):\n return map(f, s)\n\ndef lmf(f, s):\n return list(mf(f, s))\n\ndef js(lst):\n return \" \".join(str(d) for d in lst)\n\ndef jsns(lst):\n return \"\".join(str(d) for d in lst)\n\ndef line():\n return sys.stdin.readline().strip()\n\ndef linesp():\n return line().split()\n\ndef iline():\n return int(line())\n\ndef mat(n):\n matr = []\n for _ in range(n):\n matr.append(linesp())\n return matr\n\ndef matns(n):\n mat = []\n for _ in range(n):\n mat.append([c for c in line()])\n return mat\n\ndef mati(n):\n mat = []\n for _ in range(n):\n mat.append(lmi(line())) \n return mat\n\ndef pmat(mat):\n for row in mat:\n print(js(row))\n\ndef main():\n k = 0.433013\n a, b, c, d, e, f = lmi(line())\n a1 = (a + b + c)**2\n a2 = (a**2 + c**2 + e**2)\n ans = round(3**0.5 * (a1 - a2) / (4 * k), 2)\n print(int(ans))\nmain()\n"}, {"source_code": "import sys\nimport string\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom functools import lru_cache\nfrom collections import Counter\nfrom fractions import Fraction\n\ndef mi(s):\n return map(int, s.strip().split())\n\ndef lmi(s):\n return list(mi(s))\n\ndef tmi(s):\n return tuple(mi(s))\n\ndef mf(f, s):\n return map(f, s)\n\ndef lmf(f, s):\n return list(mf(f, s))\n\ndef js(lst):\n return \" \".join(str(d) for d in lst)\n\ndef jsns(lst):\n return \"\".join(str(d) for d in lst)\n\ndef line():\n return sys.stdin.readline().strip()\n\ndef linesp():\n return line().split()\n\ndef iline():\n return int(line())\n\ndef mat(n):\n matr = []\n for _ in range(n):\n matr.append(linesp())\n return matr\n\ndef matns(n):\n mat = []\n for _ in range(n):\n mat.append([c for c in line()])\n return mat\n\ndef mati(n):\n mat = []\n for _ in range(n):\n mat.append(lmi(line())) \n return mat\n\ndef pmat(mat):\n for row in mat:\n print(js(row))\n\ndef main():\n k = 0.433013\n a, b, c, d, e, f = lmi(line())\n\n asin = a * math.sin(math.pi / 3)\n acos = a * math.cos(math.pi / 3)\n dsin = d * math.sin(math.pi / 3)\n dcos = d * math.cos(math.pi / 3)\n\n first = asin * acos + b * asin\n second = dsin * dcos + e * dsin\n middle = abs(c - a) * (b + 2 * acos) * math.sin(math.pi / 3)\n print(int(round((first + second + middle) / k, 2)))\nmain()\n"}, {"source_code": "from math import sqrt\ndef g(s):\n return sqrt((s * 3 / 2) * ((s * 3 / 2 - s) ** 3))\na = [float(i) for i in input().split()]\nf = g(a[0] + a[1] + a[2])\nprint(round(f - g(a[0]) - g(a[2]) - g(a[4])) / g(1))"}, {"source_code": "import math\nimport sys\n\ndef main():\n seq = map(int, raw_input().split())\n seq_set = set(seq)\n if len(seq_set) == 1:\n return seq[0]**2*6\n if seq[0] == seq[2] == seq[4] and seq[1] == seq[3] == seq[5]:\n min_side = min(seq_set)\n max_side = max(seq_set)\n return (2*min_side + max_side)**2 - 3*min_side**2\n else:\n min_side = min(seq_set)\n max_side = max(seq_set)\n return (max_side + min_side*2)**2 - max_side**2 - 2*min_side\n\nif __name__ == '__main__':\n print main()\n"}, {"source_code": "import math\n\n\ndef solve():\n a = [int(i) for i in input().split()]\n sum_t = 0\n\n for i in a:\n sum_t += i\n\n print(sum_t + math.trunc(sum_t / 2))\n\nif __name__ == \"__main__\":\n solve()\n"}, {"source_code": "def sqr(a, b, c):\n return a * a + 2 * b * c\n\n\nif __name__ == '__main__':\n data = list(map(int, input().split()))\n print(sqr(data[0], data[1], data[2]) + sqr(data[3], data[4], data[5]))"}, {"source_code": "def read_list(t): return [t(x) for x in input().split()]\ndef read_line(t): return t(input())\ndef read_lines(t, N): return [t(input()) for _ in range(N)]\n\nH = read_list(int)\n\nprint((H[0] + H[1] + H[2]) ** 2 - H[0] ** 2 + H[2] ** 2 + H[4] ** 2)\n"}, {"source_code": "ar=map(int,raw_input().split())\na=ar[0]\nb=ar[1]\nprint ((b+2*a)**2-(3*(a*a)))\n"}, {"source_code": "l = list(map(int,input().split()))\nt1 = min(l[0],l[2])\nt2 = min(l[3],l[5])\ns1 = 0\nf1 = 2*l[1]+1\nfl = f1+2*(t1)\ns1 = s1+((f1+fl-2)*(t1))//2\nprint(s1)\nf11 = 2*l[4]+1\nf1l = f11+2*t2\ns1 = s1+((f11+f1l-2)*(t2))//2\nr = abs(l[2]-l[0])\ns1 = s1 + r*2*(l[1]+t1)\nprint(s1)\n"}], "src_uid": "382475475427f0e76c6b4ac6e7a02e21"} {"nl": {"description": "Baby Ehab was toying around with arrays. He has an array $$$a$$$ of length $$$n$$$. He defines an array to be good if there's no way to partition it into $$$2$$$ subsequences such that the sum of the elements in the first is equal to the sum of the elements in the second. Now he wants to remove the minimum number of elements in $$$a$$$ so that it becomes a good array. Can you help him?A sequence $$$b$$$ is a subsequence of an array $$$a$$$ if $$$b$$$ can be obtained from $$$a$$$ by deleting some (possibly zero or all) elements. A partitioning of an array is a way to divide it into $$$2$$$ subsequences such that every element belongs to exactly one subsequence, so you must use all the elements, and you can't share any elements.", "input_spec": "The first line contains an integer $$$n$$$ ($$$2 \\le n \\le 100$$$)\u00a0\u2014 the length of the array $$$a$$$. The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\\ldots$$$, $$$a_{n}$$$ ($$$1 \\le a_i \\le 2000$$$)\u00a0\u2014 the elements of the array $$$a$$$.", "output_spec": "The first line should contain the minimum number of elements you need to remove. The second line should contain the indices of the elements you're removing, separated by spaces. We can show that an answer always exists. If there are multiple solutions, you can print any.", "sample_inputs": ["4\n6 3 9 12", "2\n1 2"], "sample_outputs": ["1\n2", "0"], "notes": "NoteIn the first example, you can partition the array into $$$[6,9]$$$ and $$$[3,12]$$$, so you must remove at least $$$1$$$ element. Removing $$$3$$$ is sufficient.In the second example, the array is already good, so you don't need to remove any elements."}, "positive_code": [{"source_code": "# from sys import stdin,stdout\r\n# input=stdin.readline\r\nimport math\r\nimport sys\r\n# t=int(input())\r\nfrom collections import Counter,defaultdict\r\nimport bisect\r\ndef func(n,set):\r\n s = sum(set)\r\n if s%2:\r\n return False\r\n s = s//2\r\n subset =([[False for i in range(s + 1)]\r\n for i in range(n + 1)])\r\n\r\n for i in range(n + 1):\r\n subset[i][0] = True\r\n\r\n for i in range(1, s + 1):\r\n subset[0][i]= False\r\n\r\n for i in range(1, n + 1):\r\n for j in range(1, s + 1):\r\n if j= set[i-1]:\r\n subset[i][j] = (subset[i-1][j] or\r\n subset[i - 1][j-set[i-1]])\r\n\r\n\r\n return subset[n][s]\r\ndef check(a,flag = 0):\r\n for i in a:\r\n if i%2:\r\n if not flag:\r\n return False\r\n else:\r\n return a.index(i)\r\n return True\r\nn = int(input())\r\na = list(map(int,input().split(' ')))\r\naTemp = [i for i in a]\r\nif not func(n,a):\r\n print(0)\r\nelse:\r\n while (check(aTemp)):\r\n aTemp = [i//2 for i in aTemp]\r\n print(1)\r\n print(check(aTemp,1)+1)\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\nn = int(input())\r\narray = [int(x) for x in input().split()]\r\nif sum(array) % 2 == 0:\r\n s = 1\r\n for i in array:\r\n s |= s << i\r\n\r\n if s & (1 << (sum(array)//2)):\r\n b = [x & -x for x in array]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i+1}\")\r\n sys.exit()\r\nprint(0)\r\n"}, {"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\nn = int(input())\r\nl = list(map(int, input().split()))\r\nsum1 = sum(l)\r\nif sum1%2 == 1:\r\n print(0)\r\nelse:\r\n prev_dict = {}\r\n prev_dict[0] = True\r\n new_dict = prev_dict.copy()\r\n for i in range(n):\r\n for val in prev_dict:\r\n if val + l[i] not in new_dict:\r\n new_dict[val + l[i]] = True\r\n prev_dict = new_dict.copy()\r\n if sum1//2 not in new_dict:\r\n print(0)\r\n else:\r\n found = -1\r\n for i in range(n):\r\n if l[i]%2 == 1:\r\n save = i + 1\r\n found = 1\r\n break\r\n if found == 1:\r\n print(1)\r\n print(save)\r\n else:\r\n check = 4\r\n save = -1\r\n while True:\r\n for i in range(n):\r\n if l[i]%check != 0:\r\n save = i + 1\r\n break\r\n if save > -1:\r\n break\r\n else:\r\n check *= 2\r\n print(1)\r\n print(save)"}, {"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\nn = int(input())\r\nl = list(map(int, input().split()))\r\nsum1 = sum(l)\r\nif sum1%2 == 1:\r\n print(0)\r\nelse:\r\n prev_dict = {}\r\n prev_dict[0] = True\r\n new_dict = prev_dict.copy()\r\n for i in range(n):\r\n for val in prev_dict:\r\n if val + l[i] not in new_dict:\r\n new_dict[val + l[i]] = True\r\n prev_dict = new_dict.copy()\r\n if sum1//2 not in new_dict:\r\n print(0)\r\n else:\r\n found = -1\r\n for i in range(n):\r\n if l[i]%2 == 1:\r\n save = i + 1\r\n found = 1\r\n break\r\n if found == 1:\r\n print(1)\r\n print(save)\r\n else:\r\n check = 4\r\n save = -1\r\n while True:\r\n for i in range(n):\r\n if l[i]%check != 0:\r\n save = i + 1\r\n break\r\n if save > -1:\r\n break\r\n else:\r\n check *= 2\r\n print(1)\r\n print(save)"}, {"source_code": "n = int(input())\r\narr = list(map(int, input().split()))\r\n\r\nif sum(arr) & 1:\r\n print(0)\r\nelse:\r\n even, odd = 0, 0\r\n for i in arr:\r\n if i & 1:\r\n odd += 1\r\n else:\r\n even += 1\r\n target = sum(arr) // 2\r\n n = len(arr)\r\n dp = [[False for i in range(target + 1)] for j in range(n + 1)]\r\n for i in range(n + 1):\r\n dp[i][0] = True\r\n for i in range(1, n + 1):\r\n for j in range(1, target + 1):\r\n if arr[i - 1] > j:\r\n dp[i][j] = dp[i - 1][j]\r\n else:\r\n dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]\r\n if dp[n][target]:\r\n if odd:\r\n for i in range(len(arr)):\r\n if arr[i] & 1:\r\n print(1)\r\n print(i + 1)\r\n exit()\r\n else:\r\n min_index = 10 ** 9\r\n ans = -1\r\n for i in range(len(arr)):\r\n for j in range(32):\r\n if arr[i] & (1 << j):\r\n if j < min_index:\r\n min_index = min(min_index, j)\r\n ans = i + 1\r\n break\r\n print(1)\r\n print(ans)\r\n else:\r\n print(0)\r\n"}, {"source_code": "def ii(): return int(input())\r\ndef si(): return input()\r\ndef mi(): return map(int,input().strip().split(\" \"))\r\ndef msi(): return map(str,input().strip().split(\" \"))\r\ndef li(): return list(mi())\r\n\r\n\r\n\r\nn = ii()\r\nl = li()\r\n\r\ns = sum(l)\r\nif(s%2):\r\n print(0)\r\nelse:\r\n dp = []\r\n ss = s\r\n s = s//2\r\n for i in range(n+1):\r\n dp.append([0]*(s+1))\r\n for i in range(n+1):\r\n dp[i][0] = 1\r\n\r\n for i in range(1,n+1):\r\n for j in range(1,s+1):\r\n if(l[i-1]<=j):\r\n dp[i][j] = dp[i-1][j-l[i-1]] or dp[i-1][j]\r\n\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n if(dp[n][s]==0):\r\n \tprint(0)\r\n else:\r\n\t for i in range(n):\r\n\t if(l[i]%2==0 and dp[n][(ss-l[i])//2] == 0):\r\n\t print(1)\r\n\t print(i+1)\r\n\t \r\n\t break\r\n\t elif(l[i]%2):\r\n\t \tprint(1)\r\n\t \tprint(i+1)\r\n\t \r\n\t \tbreak\r\n "}, {"source_code": "import math\ndef check(n,l):\n s = sum(l)\n if s%2!=0:\n return True\n dp = [[False]*n for i in range(s//2+1)]\n for i in range(n):\n for j in range(s//2+1):\n if i==0:\n if j==0 or j==l[0]:\n dp[j][i]=True\n continue\n if j==0:\n dp[j][i]=True\n continue\n if j>=l[i]:\n dp[j][i] = dp[j][i-1] or dp[j-l[i]][i-1]\n else:\n dp[j][i] = dp[j][i-1]\n return not dp[-1][-1]\n\nn = int(input())\nl = [int(i) for i in input().split()]\nl1 = [math.log2(i&-i) for i in l]\nv = l1.index(min(l1))\nfor i in range(n):\n l[i] = int(l[i]/2**l1[v]) \nif check(n,l)==True:\n print(0)\nelse:\n print(1)\n print(v+1)"}, {"source_code": "import math\r\nt = int(input())\r\na = list(map(int, input().split()))\r\nd = math.gcd(a[0], a[1])\r\nfor i in range(2, len(a)):\r\n d = math.gcd(d, a[i])\r\nfor i in range(len(a)):\r\n a[i] = a[i]//d\r\ntotal = sum(a)\r\nif total % 2 == 1:\r\n print(0)\r\nelse:\r\n target = total//2\r\n dp = [False] * (target+1)\r\n dp[0] = True\r\n for v in a:\r\n for i in range(target, v - 1, -1):\r\n dp[i] = dp[i] or dp[i - v]\r\n if dp[target]:\r\n j = 0\r\n while a[j] % 2 == 0:\r\n j += 1\r\n print(1)\r\n print(j + 1)\r\n else:\r\n print(0)"}, {"source_code": "from sys import stdin\n\n\ndef read_int():\n return int(stdin.readline())\n\n\ndef read_ints():\n return map(int, stdin.readline().split(' '))\n\n\nn = read_int()\na = list(read_ints())\ns = sum(a)\nif s % 2 == 1:\n print(0)\n exit(0)\n\ndp = [False] * (s // 2 + 1)\ndp[0] = True\nfor ai in a:\n for j in range(s // 2, ai - 1, -1):\n dp[j] = dp[j] or dp[j - ai]\nif not dp[s // 2]:\n print(0)\n exit(0)\n\nwhile True:\n if sum(a) % 2 == 1:\n print(0)\n exit(0)\n else:\n odd = -1\n for i in range(n):\n if a[i] % 2 == 1:\n print(1)\n print(i + 1)\n exit(0)\n a = [x // 2 for x in a]\n"}, {"source_code": "import functools, math, sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef knapsack(capacity, utility, weight):\r\n backpack = [[0 for i in range(capacity + 1)] for j in range(2)]\r\n for i in range(len(weight)):\r\n if i % 2 == 0:\r\n for j in range(capacity + 1):\r\n if weight[i] <= j:\r\n backpack[1][j] = max(utility[i] + backpack[0][j - weight[i]], backpack[0][j])\r\n else:\r\n backpack[1][j] = backpack[0][j]\r\n else:\r\n for j in range(capacity + 1):\r\n if weight[i] <= j:\r\n backpack[0][j] = max(utility[i] + backpack[1][j - weight[i]], backpack[1][j])\r\n else:\r\n backpack[0][j] = backpack[1][j]\r\n if not len(weight) % 2:\r\n return backpack[0][capacity]\r\n else:\r\n return backpack[1][capacity]\r\n\r\nn, values = int(input()), [int(i) for i in input().split()]\r\ntot, tar = sum(values), sum(values) // 2\r\nif tot % 2 or knapsack(tar, values, values) != tar:\r\n print(0)\r\n sys.exit()\r\ngcd = functools.reduce(math.gcd, values)\r\nvalues = [values[i] // gcd for i in range(n)]\r\nfor i in range(n): # remove\r\n if values[i] % 2:\r\n print(1)\r\n print(i + 1)\r\n sys.exit()\r\n"}, {"source_code": "import math\r\ndef fun(a,n):\r\n d=[{} for i in range(n)]\r\n d[0][0]=True\r\n d[0][a[0]]=True\r\n\r\n d[-1][sum(a)//2]=False\r\n \r\n for i in range(n-1):\r\n for j in d[i]:\r\n d[i+1][j+a[i+1]]=True\r\n d[i+1][j]=True\r\n #print(d)\r\n return d[-1][sum(a)//2] \r\n \r\n\r\nn=int(input())\r\na=[int(x) for x in input().split()]\r\n\r\nif sum(a)%2==1:\r\n print(0)\r\n\r\nelse:\r\n if fun(a,n):\r\n print(1)\r\n mn=int(math.log(a[0],2))\r\n ans=0\r\n for i in range(n):\r\n t=0\r\n while a[i]%2==0:\r\n a[i]=a[i]//2\r\n t+=1\r\n if t=1:\n\n\t\tc = a%10\n\n\t\ta = int(a/10)\n\n\n\t\tb.append(c)\n\n\treturn list(reversed(b))\n\ndef str_list_to_int_list(a):\n\n\n\ta = list(map(int,a))\n\n\treturn a\n\ndef make_1d_array(n,inti= 0):\n\n\ta = [inti for _ in range(n)]\n\n\treturn a\n\ndef make_2d_array(n,m,inti= 0):\n\n\ta = [[inti for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef make_3d_array(n,m,k,inti= 0):\n\n\ta = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef gcd(a,b):\n\n\tif(b==0): \n\t\treturn a\n\n\telse:\n\t\treturn gcd(b,a%b);\n\n\n\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\nS = lambda : list(map(str,input()))\n\n\n# def solve(sum1,dp):\n\n# \tprev = [[] for i in range(sum1+1)]\n\n# \tfor i in range(n):\n\n# \t\tdp = [prev[j] for j in range(sum1+1)]\n\n# \t\tfor j in range(sum1+1):\n\n\n'''\n\n\n#########################\n#\tOptimizations\n#\n#\t1)\tloop from backwards thus only one loop required\n#\t2)\tmemeroization of only required index of ans\n#\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\n\nif sum1%2==0:\n\n\n\tsum1 = sum1//2\n\n\tdp = [False]*(sum1+1)\n\tdp[0] = True\n\t# ans = [[] for j in range(sum1+1)]\n\tfrom collections import defaultdict\n\tans = defaultdict(list)\n\tfor i in range(n):\n\t\tfor j in range(sum1,-1,-1):\n\t\t\tif j-a[i]>=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n\t\t\t\tif prev[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans1[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans1[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n\t\tprev = dp.copy()\n\t\tans = ans1.copy()\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(prev_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n# \t\tprev_a = [dp_a[j] for j in range(len(dp_a))]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif dp[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(dp_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif prev[j-a[i]][0]:\n# \t\t\t\t\tif dp[j][0]:\n# \t\t\t\t\t\tif (prev[j-a[i]][1]+1)prev[i][1]:\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,prev[i][1])\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = True\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tans1 = [ans[j] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n \n\n# 1)\tless loop while copying\n# 2)\talways intilize with -1\n# 3) \n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tprev1 = [0 for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = (True,0)\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tdp1 = prev1.copy()\n# \t\tans1 = [ans[j][:] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n"}, {"source_code": "import os,sys,math \r\nfrom io import BytesIO, IOBase\r\nfrom collections import defaultdict,deque,OrderedDict\r\nimport bisect as bi\r\ndef yes():print('YES')\r\ndef no():print('NO')\r\ndef I():return (int(input()))\r\ndef In():return(map(int,input().split()))\r\ndef ln():return list(map(int,input().split()))\r\ndef Sn():return input().strip()\r\nfrom array import array\r\nBUFSIZE = 8192\r\n#complete the main function with number of test cases to complete greater than x\r\ndef find_gt(a, x):\r\n i = bi.bisect_left(a, x)\r\n if i != len(a):\r\n return i\r\n else: \r\n return len(a)\r\ndef CountTrailingZeros(n):\r\n \r\n bit = bin(n)[2:]\r\n bit = bit[::-1]\r\n zero = 0;\r\n for i in range(len(bit)):\r\n if (bit[i] == '0'):\r\n zero += 1\r\n else:\r\n break\r\n \r\n return zero\r\ndef solve():\r\n Max=2000*100\r\n n=I()\r\n dp=array('b')\r\n dp=[False]*Max\r\n dp[0]=True\r\n l=list(In())\r\n total=0\r\n for x in l:\r\n total+=x\r\n for j in range(len(dp)-x-1,-1,-1):\r\n if not dp[j]:continue\r\n dp[j+x]=True\r\n\r\n if (not dp[total//2]) or (total%2!=0):\r\n print(0)\r\n return\r\n trail=31\r\n for x in l:\r\n trail=min(trail,CountTrailingZeros(x))\r\n ans=-2\r\n for i in range(n):\r\n if l[i]%(1<>1\r\n\r\ndef subsetSum(l, i, target_sum, memo=dict()):\r\n\tkey = i, target_sum\r\n\tif key in memo:\r\n\t\treturn memo[key]\r\n\r\n\tif target_sum == 0:\r\n\t\treturn True\r\n\tif i == len(l):\r\n\t\treturn False\r\n\r\n\tto_return = subsetSum(l, i+1, target_sum, memo) or subsetSum(l, i+1, target_sum-l[i], memo)\r\n\tmemo[key] = to_return\r\n\treturn to_return\r\n\r\n\r\n\r\ndef make_good(l):\r\n\tfor i in range(len(l)):\r\n\t\tif l[i] & 1:\t# odd\r\n\t\t\treturn i+1\t# 1-based index\r\n\r\n\t# all items are even\r\n\treturn(make_good(list(map(y, l))))\r\n\r\n\r\nif __name__ == '__main__':\r\n\tn = int(input())\r\n\tl = list(map(int, input().split()))\r\n\r\n\tif sum(l) & 1==1 or not subsetSum(l, 0, sum(l)//2):\t\r\n\t\tprint(0)\r\n\r\n\telse:\r\n\r\n\t\tres = make_good(l)\r\n\t\tprint(1)\r\n\t\tprint(res)\r\n\r\n"}, {"source_code": "def zip_sorted(a,b):\n\n\t# sorted by a\n\ta,b = zip(*sorted(zip(a,b)))\n\t# sorted by b\n\tsorted(zip(a, b), key=lambda x: x[1])\n\n\treturn a,b\n\ndef number_to_list(a):\n\n\tb = []\n\n\twhile a>=1:\n\n\t\tc = a%10\n\n\t\ta = int(a/10)\n\n\n\t\tb.append(c)\n\n\treturn list(reversed(b))\n\ndef str_list_to_int_list(a):\n\n\n\ta = list(map(int,a))\n\n\treturn a\n\ndef make_1d_array(n,inti= 0):\n\n\ta = [inti for _ in range(n)]\n\n\treturn a\n\ndef make_2d_array(n,m,inti= 0):\n\n\ta = [[inti for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef make_3d_array(n,m,k,inti= 0):\n\n\ta = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef gcd(a,b):\n\n\tif(b==0): \n\t\treturn a\n\n\telse:\n\t\treturn gcd(b,a%b);\n\n\n\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\nS = lambda : list(map(str,input()))\n\n\n# def solve(sum1,dp):\n\n# \tprev = [[] for i in range(sum1+1)]\n\n# \tfor i in range(n):\n\n# \t\tdp = [prev[j] for j in range(sum1+1)]\n\n# \t\tfor j in range(sum1+1):\n\n\n'''\n\n\n#########################\n#\tOptimizations\n#\n#\t1)\tloop from backwards thus only one loop required\n#\t2)\tmemeroization of only required index of ans\n#\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\n\nif sum1%2==0:\n\n\n\tsum1 = sum1//2\n\n\tdp = [False]*(sum1+1)\n\tdp[0] = True\n\t# ans = [[] for j in range(sum1+1)]\n\tfrom collections import defaultdict\n\tans = defaultdict(list)\n\tfor i in range(n):\n\t\tfor j in range(sum1,-1,-1):\n\t\t\tif j-a[i]>=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n# \t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in ans:\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(prev_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n# \t\tprev_a = [dp_a[j] for j in range(len(dp_a))]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(dp_a[j])>(len(dp_a[j-a[i]])+1):\n\t\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in range(sum1+1):\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(dp_a[i])=a[i-1]:\r\n dp[i][j]=dp[i-1][j] or dp[i-1][j-a[i-1]]\r\n else:\r\n dp[i][j]=dp[i-1][j]\r\n if not dp[n][s]:\r\n print(0)\r\n else:\r\n f=0\r\n for i in range(len(a)):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n f=1\r\n break\r\n if f==0:\r\n f=1\r\n while(f):\r\n for i in range(len(a)):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n f=0\r\n break\r\n a[i]=a[i]//2\r\n \r\n"}, {"source_code": "# import sys\r\n# sys.stdin=open('input.txt','r')\r\n# sys.stdout=open('output.txt','w')\r\nimport sys\r\nimport math\r\ndef input(): return sys.stdin.readline().strip(\"\\n\")\r\ndef I(): return (input())\r\ndef II(): return (int(input()))\r\ndef MI(): return (map(int,input().split()))\r\ndef LI(): return (list(map(int,input().split())))\r\ndef findPartition(arr, n,s):\r\n\tif s % 2 == 1:\r\n\t\treturn False\r\n\t# print(s)\r\n\tfor i in range(0, n + 1):\r\n\t\tpart[0][i] = True\r\n\tfor i in range(1, s // 2 + 1):\r\n\t\tpart[i][0] = False\r\n\tfor i in range(1, s // 2 + 1):\r\n\t\tfor j in range(1, n + 1):\r\n\t\t\tpart[i][j] = part[i][j - 1]\r\n\t\t\tif i >= arr[j - 1]:\r\n\t\t\t\tpart[i][j] = (part[i][j] or part[i - arr[j - 1]][j - 1])\r\n\treturn part[s // 2][n]\r\n\r\nn = II()\r\na = LI()\r\ns = 0\r\ni, j = 0, 0\r\nfor i in range(n):\r\n\ts += a[i]\r\n# print(s)\r\npart = [[True for i in range(n + 1)]for j in range(s // 2 + 1)]\r\nif findPartition(a,n,s) == False:\r\n\tprint(0)\r\nelse:\r\n\tswitch = 0\r\n\twhile True:\r\n\t\tfor i in range(n):\r\n\t\t\tif a[i] % 2 == 1:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\tswitch = 1 \r\n\t\t\t\tbreak;\r\n\t\t\ta[i] = a[i] // 2\r\n\t\tif switch == 1:\r\n\t\t\tbreak;\r\n\r\n"}, {"source_code": "from sys import stdin\n\n\ndef read_int():\n return int(stdin.readline())\n\n\ndef read_ints():\n return map(int, stdin.readline().split(' '))\n\n\nn = read_int()\na = list(read_ints())\nwhile True:\n s = sum(a)\n if s % 2 == 1:\n print(0)\n exit(0)\n h = 0\n dp = [False] * (s // 2 + 1)\n dp[0] = True\n for ai in a:\n for j in range(s // 2, ai - 1, -1):\n dp[j] = dp[j] or dp[j - ai]\n if not dp[s // 2]:\n print(0)\n exit(0)\n else:\n odd = -1\n for i in range(n):\n if a[i] % 2 == 1:\n print(1)\n print(i + 1)\n exit(0)\n a = [x // 2 for x in a]\n"}, {"source_code": "def zip_sorted(a,b):\n\n\t# sorted by a\n\ta,b = zip(*sorted(zip(a,b)))\n\t# sorted by b\n\tsorted(zip(a, b), key=lambda x: x[1])\n\n\treturn a,b\n\ndef number_to_list(a):\n\n\tb = []\n\n\twhile a>=1:\n\n\t\tc = a%10\n\n\t\ta = int(a/10)\n\n\n\t\tb.append(c)\n\n\treturn list(reversed(b))\n\ndef str_list_to_int_list(a):\n\n\n\ta = list(map(int,a))\n\n\treturn a\n\ndef make_1d_array(n,inti= 0):\n\n\ta = [inti for _ in range(n)]\n\n\treturn a\n\ndef make_2d_array(n,m,inti= 0):\n\n\ta = [[inti for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef make_3d_array(n,m,k,inti= 0):\n\n\ta = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef gcd(a,b):\n\n\tif(b==0): \n\t\treturn a\n\n\telse:\n\t\treturn gcd(b,a%b);\n\n\n\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\nS = lambda : list(map(str,input()))\n\n\n# def solve(sum1,dp):\n\n# \tprev = [[] for i in range(sum1+1)]\n\n# \tfor i in range(n):\n\n# \t\tdp = [prev[j] for j in range(sum1+1)]\n\n# \t\tfor j in range(sum1+1):\n\n\n'''\n\n\n#########################\n#\tOptimizations\n#\n#\t1)\tloop from backwards thus only one loop required\n#\t2)\tmemeroization of only required index of ans\n#\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\n\nif sum1%2==0:\n\n\n\tsum1 = sum1//2\n\n\tdp = [False]*(sum1+1)\n\tdp[0] = True\n\t# ans = [[] for j in range(sum1+1)]\n\tfrom collections import defaultdict\n\tans = defaultdict(list)\n\tfor i in range(n):\n\t\tfor j in range(sum1,-1,-1):\n\t\t\tif j-a[i]>=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n\t\t\t\tif prev[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans1[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans1[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n\t\tprev = dp.copy()\n\t\tans = ans1.copy()\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(prev_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n# \t\tprev_a = [dp_a[j] for j in range(len(dp_a))]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif dp[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(dp_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif prev[j-a[i]][0]:\n# \t\t\t\t\tif dp[j][0]:\n# \t\t\t\t\t\tif (prev[j-a[i]][1]+1)prev[i][1]:\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,prev[i][1])\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = True\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tans1 = [ans[j] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n \n\n# 1)\tless loop while copying\n# 2)\talways intilize with -1\n# 3) \n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tprev1 = [0 for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = (True,0)\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tdp1 = prev1.copy()\n# \t\tans1 = [ans[j][:] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n"}, {"source_code": "\"\"\"\r\n// Author : snape_here - Susanta Mukherjee\r\n \r\n \"\"\"\r\n\r\nfrom __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\ndef ii(): return int(input())\r\ndef fi(): return float(input())\r\ndef si(): return input()\r\ndef msi(): return map(str,input().split())\r\ndef mi(): return map(int,input().split())\r\ndef li(): return list(mi())\r\ndef lsi(): return list(msi())\r\n \r\n \r\ndef read():\r\n sys.stdin = open('input.txt', 'r') \r\n sys.stdout = open('output.txt', 'w') \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\ndef lcm(x, y):\r\n return (x*y)//(gcd(x,y))\r\n\r\nmod=1000000007\r\n\r\ndef modInverse(b,m): \r\n g = gcd(b, m) \r\n if (g != 1): \r\n return -1\r\n else: \r\n return pow(b, m - 2, m) \r\n\r\ndef ceil2(x,y):\r\n if x%y==0:\r\n return x//y\r\n else:\r\n return x//y+1\r\n\r\ndef modu(a,b,m): \r\n\r\n a = a % m \r\n inv = modInverse(b,m) \r\n if(inv == -1): \r\n return -999999999\r\n else: \r\n return (inv*a)%m\r\n\r\nfrom math import log,factorial,cos,tan,sin,radians,floor,sqrt,ceil\r\n\r\nabc=\"abcdefghijklmnopqrstuvwxyz\"\r\n\r\npi=3.141592653589793238\r\n\r\ndef gcd1(a):\r\n\r\n if len(a) == 1:\r\n return a[0]\r\n\r\n ans = a[0]\r\n for i in range(1,len(a)):\r\n ans = gcd(ans,a[i])\r\n\r\n return ans\r\n\r\ndef mykey(x):\r\n return x[1],-x[0]\r\n\r\ndef main():\r\n\r\n for _ in range(1):\r\n n=ii()\r\n a=li()\r\n a.insert(0,0)\r\n if sum(a)%2:\r\n print(0)\r\n exit()\r\n\r\n s = sum(a)\r\n\r\n dp = []\r\n for i in range(n+1):\r\n c = [0]*(200005)\r\n dp.append(c)\r\n\r\n dp[0][0] = 1\r\n for i in range(n):\r\n for j in range(200005):\r\n if dp[i][j]:\r\n dp[i+1][j] = 1\r\n dp[i+1][j+a[i+1]] = 1\r\n\r\n y = -1 \r\n for i in range(n, 0, -1):\r\n if a[i]%2:\r\n y = i \r\n break\r\n\r\n if y==-1:\r\n l=[]\r\n for i in range(1,n+1):\r\n c = 0\r\n while a[i]%2==0:\r\n a[i] //= 2\r\n c += 1\r\n l.append(c)\r\n m = min(l)\r\n\r\n for i in range(n):\r\n if l[i]==m:\r\n y = i+1\r\n break\r\n\r\n x = s//2\r\n f = 0\r\n ans = 0\r\n for i in range(1,n+1):\r\n if dp[i][x]:\r\n f = 1\r\n ans = y \r\n break\r\n\r\n if f:\r\n print(1)\r\n print(ans)\r\n else:\r\n print(0)\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\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()"}, {"source_code": "from os import path\r\nimport sys,time\r\nmod = int(1e9 + 7)\r\n# import re\r\nfrom math import ceil, floor,gcd,log,log2 ,factorial,sqrt\r\nfrom collections import defaultdict ,Counter , OrderedDict , deque\r\nfrom itertools import combinations ,accumulate\r\n# from string import ascii_lowercase ,ascii_uppercase\r\nfrom bisect import *\r\nfrom functools import reduce\r\nfrom operator import mul\r\nstar = lambda x: print(' '.join(map(str, x)))\r\ngrid = lambda r :[lint() for i in range(r)]\r\nstpr = lambda x : sys.stdout.write(f'{x}' + '\\n')\r\nINF = float('inf')\r\nif (path.exists('input.txt')):\r\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\r\nimport sys\r\nfrom sys import stdin, stdout\r\nfrom collections import *\r\nfrom math import gcd, floor, ceil\r\ndef st(): return list(stdin.readline().strip())\r\ndef inp():\r\n return int(stdin.readline())\r\ndef inlt():\r\n return list(map(int, stdin.readline().split()))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return map(int, stdin.readline().split())\r\ndef pr(n): return stdout.write(str(n)+\"\\n\")\r\nfrom copy import deepcopy\r\ndef subset_sum(a,n,target):\r\n dp = [[False for _ in range(target+1)]for _ in range(n+1)]\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if i==0:\r\n dp[i][j] = False\r\n if j==0:\r\n dp[i][j] = True\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if a[i-1]<=j:\r\n dp[i][j] = dp[i-1][j] or dp[i-1][j-a[i-1]]\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n return dp[n][target]\r\ndef solve():\r\n n = inp()\r\n a = inlt()\r\n if sum(a)%2:\r\n print(0)\r\n else:\r\n odd = False\r\n ind = 0\r\n if subset_sum(a,n,sum(a)//2):\r\n for i in range(n):\r\n if a[i]%2:\r\n ind = i\r\n odd = True\r\n break\r\n if odd:\r\n print(1)\r\n print(ind+1)\r\n else:\r\n \r\n for j in range(13):\r\n for i in range(n):\r\n if a[i]%2:\r\n print(1)\r\n print(i+1)\r\n return\r\n else:\r\n a[i]//=2\r\n else:\r\n print(0)\r\n \r\nt = 1\r\n#t = inp()\r\nfor _ in range(t):\r\n solve()\r\n\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\ndef main():\r\n n = int(input())\r\n A = list(map(int, input().split()))\r\n\r\n M = sum(A)\r\n if M%2 == 1:\r\n print(0)\r\n exit()\r\n\r\n dp = [False]*(M+1)\r\n dp[0] = True\r\n for a in A:\r\n for j in reversed(range(M+1)):\r\n if not dp[j]:\r\n continue\r\n dp[j+a] = True\r\n\r\n if not dp[M//2]:\r\n print(0)\r\n exit()\r\n while True:\r\n B = []\r\n S = sum(A)\r\n for i, a in enumerate(A):\r\n if S%2 == 0:\r\n if a%2 == 1:\r\n print(1)\r\n print(i+1)\r\n exit()\r\n else:\r\n B.append(a//2)\r\n else:\r\n if a%2 == 0:\r\n print(1)\r\n print(i+1)\r\n exit()\r\n else:\r\n A = B\r\n\r\nif __name__ == '__main__':\r\n main()\r\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\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: 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\ndef check(a,k):\r\n s=set([0])\r\n for i in range (len(a)):\r\n s1=set()\r\n for j in s:\r\n s1.add(a[i]+j)\r\n s=s.union(s1)\r\n if k in s:\r\n return True\r\n return False\r\n\r\nfor _ in range (1):\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n s=sum(a)\r\n d=defaultdict(int)\r\n for i in a:\r\n d[i]+=1\r\n mnd,mxd=min(d.values()),max(d.values())\r\n occ=0\r\n if s%2:\r\n print(0)\r\n continue\r\n if check(a,s//2)==False:\r\n print(0)\r\n continue\r\n mn,mx=min(a),max(a)\r\n m,o=0,0\r\n i1,i2,i3,i4=[0]*4\r\n for i in range (n):\r\n if a[i]%2:\r\n o=i+1\r\n elif (a[i]//2)%2:\r\n m=i+1\r\n if a[i]==mn:\r\n i1=i+1\r\n if a[i]==mx:\r\n i2=i+1\r\n if a[i]==mnd:\r\n i3=i+1\r\n if a[i]==mxd:\r\n i4=i+1\r\n print(1)\r\n if o:\r\n print(o)\r\n elif m:\r\n print(m)\r\n else:\r\n if check(list(a[:i1-1]+a[i1:]),(s-mn)//2)==False:\r\n print(i1)\r\n elif check(list(a[:i2-1]+a[i2:]),(s-mx)//2)==False:\r\n print(i2)\r\n elif check(list(a[:i3-1]+a[i3:]),(s-mnd)//2)==False:\r\n print(i3)\r\n elif check(list(a[:i4-1]+a[i4:]),(s-mxd)//2)==False:\r\n print(i4)\r\n "}, {"source_code": "\"\"\"**************************************************************\\\r\n BISMILLAHIR RAHMANIR RAHIM\r\n****************************************************************\r\n AUTHOR NAME: MD. TAHURUZZOHA TUHIN\r\n\\**************************************************************\"\"\"\r\n\r\n\r\n\r\n\r\n\r\n#!/usr/bin/env python\r\nfrom __future__ import division, print_function\r\n\r\nimport os\r\nimport sys\r\nfrom math import gcd\r\nfrom io import BytesIO, IOBase\r\nfrom heapq import heappush,heappop,heapify\r\nfrom collections import defaultdict, Counter, deque\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\n\r\n# Start FASTIO\r\nBUFSIZE = 8192\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 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\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\ndef check_freq(x):\r\n freq = {}\r\n for c in set(x):\r\n freq[c] = x.count(c)\r\n return freq\r\n \r\n\r\ndef ii(): return int(input())\r\ndef si(): return input()\r\ndef mi(): return map(int, input().strip().split(\" \"))\r\ndef li(): return list(mi())\r\nMAXX = 100000000\r\n\r\n\r\n'''**************Solution is Here***********'''\r\ndef equalPartition(sm,N, arr):\r\n # code here\r\n s=sm\r\n #s has to be even for halves to exist\r\n # if s%2==1:\r\n # return 0\r\n mat=[]\r\n # p=s//2\r\n p=sm\r\n \r\n #initialization of DP table\r\n for i in range(N+1):\r\n row=[]\r\n for j in range(p+1):\r\n if j==0:\r\n row.append(1)\r\n elif i==0:\r\n row.append(0)\r\n else:\r\n row.append(2)\r\n mat.append(row)\r\n # print(mat)\r\n \r\n # DP table\r\n for i in range(1,N+1):\r\n for j in range(1,p+1):\r\n if arr[i-1]>j:\r\n mat[i][j]=mat[i-1][j]\r\n \r\n else:\r\n mat[i][j]=max(mat[i-1][j],mat[i-1][j-arr[i-1]])\r\n return mat[-1][-1]\r\n\r\n\r\ndef solve(arr,n):\r\n sm = sum(arr)\r\n if sm%2==1:\r\n return False\r\n return 1\r\n\r\ndef main():\r\n T = 1\r\n for _ in range(T):\r\n n = ii()\r\n A = li()\r\n # if (solve(a, n)) == True:\r\n # ans = -1\r\n # for i in range(n):\r\n # b = [0]*n\r\n # k = 0\r\n # for j in range(n):\r\n # if i==j:\r\n # continue\r\n # b[k] = a[j]\r\n # k += 1\r\n # if (solve(b,k) == False):\r\n # ans = i\r\n # break\r\n # # if (solve(b,k) == True):\r\n # # ans = i+1\r\n # # break\r\n # print(1)\r\n # print(ans+1)\r\n # n = int(input())\r\n # A = list(map(int,input().split()))\r\n s = sum(A)\r\n M = 2*10**5+1\r\n dp = [0]*(M+5)\r\n dp[0] = 1\r\n g = A[0]\r\n ind = 0\r\n for a in A:\r\n g = gcd(a,g)\r\n for j in range(M)[::-1]:\r\n if j+a <= M:\r\n dp[j+a] |= dp[j]\r\n if s%2 or dp[s//2] == 0:\r\n print(0)\r\n exit()\r\n for i,a in enumerate(A,1):\r\n if (a//g)%2:\r\n print(1)\r\n print(i)\r\n exit()\r\n \r\n\r\n else:\r\n print(0)\r\n\r\n\r\n\r\n\r\n\r\n\r\n# End FASTIO\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "def solve(arr):\r\n s = sum(arr)\r\n if s & 1:\r\n print(0)\r\n return\r\n half = s // 2\r\n dp = [False] * (half + 1)\r\n dp[0] = True\r\n for a in arr:\r\n if a > half:\r\n print(0)\r\n return\r\n for j in range(half, a - 1, -1):\r\n dp[j] = dp[j] or dp[j - a]\r\n if not dp[-1]:\r\n print(0)\r\n return\r\n\r\n found = [None] * 13\r\n for idx, a in enumerate(arr):\r\n for i in range(13):\r\n if not found[i] and (a >> i) & 1:\r\n found[i] = idx + 1\r\n for i in range(13):\r\n if found[i] is not None:\r\n print(1)\r\n print(found[i])\r\n return\r\n\r\n\r\n# t = int(input())\r\n# for _ in range(t):\r\n # n, k = [int(x) for x in input().split()]\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\nsolve(arr)\r\n"}, {"source_code": "import math\r\nimport sys\r\nimport collections\r\nimport bisect\r\nimport time\r\nimport random\r\nfrom itertools import permutations\r\ndef get_ints():return map(int, sys.stdin.readline().strip().split())\r\ndef get_list():return list(map(int, sys.stdin.readline().strip().split()))\r\ndef get_string():return sys.stdin.readline().strip()\r\n\r\n\r\ndef findPartition(arr, n):\r\n\tSum = 0\r\n\tfor i in range(n):\r\n\t\tSum += arr[i]\r\n\tif (Sum % 2 != 0):\r\n\t\treturn 0\r\n\tpart = [0] * ((Sum // 2) + 1)\r\n\tfor i in range((Sum // 2) + 1):\r\n\t\tpart[i] = 0\r\n\tfor i in range(n):\r\n\t\tfor j in range(Sum // 2, arr[i] - 1, -1):\r\n\t\t\tif (part[j - arr[i]] == 1 or j == arr[i]):\r\n\t\t\t\tpart[j] = 1\r\n\treturn part[Sum // 2]\r\nfor t in range(1):\r\n\tn=int(input())\r\n\tarr=get_list()\r\n\tif findPartition(arr, n) == False:\r\n\t\tprint(0)\r\n\t\tcontinue\r\n\tp=0\r\n\tfor i in range(n):\r\n\t\tif arr[i]%2==1:\r\n\t\t\tprint(1)\r\n\t\t\tprint(i+1)\r\n\t\t\tp+=1\r\n\t\t\tbreak\r\n\tif p>0:\r\n\t\tcontinue\r\n\tfor i in range(n):\r\n\t\ttemp=arr[:i]+arr[i+1:]\r\n\t\tif findPartition(temp, n-1) == False:\r\n\t\t\tprint(1)\r\n\t\t\tprint(i+1)\r\n\t\t\tbreak"}, {"source_code": "from sys import stdin, stdout\r\n\r\nget_string = lambda: stdin.readline().strip(' ')\r\nget_intmap = lambda: map( int, get_string().split(' ') )\r\n\r\n\r\ndef testcase():\r\n n = int(input())\r\n l = list(get_intmap())\r\n suml = sum(l)\r\n if suml % 2 == 1:# odd sum array cant be bipartitioned\r\n print(0); return\r\n #try to partition the even sum array by\r\n #doing a knapsack on half the sum as weight of sack\r\n dp = [0] * (suml + 5)\r\n dp[0] = 1\r\n for item in l:\r\n for ind in range(len(dp)-1,-1,-1):\r\n if dp[ind] == 1:\r\n dp[ind + item] = 1\r\n if dp[suml//2]:#knapsack success/ partition possible\r\n print(1)\r\n #find odd number or number with smallest possible Least significant bit\r\n min_lsb_pos = 32\r\n min_ind = -1\r\n for ind, i in enumerate(l):\r\n lsb_pos = 0\r\n while i & (1 << lsb_pos) == 0:\r\n lsb_pos += 1\r\n if min_lsb_pos > lsb_pos:\r\n min_lsb_pos = lsb_pos\r\n min_ind = ind\r\n print(min_ind + 1)\r\n else:\r\n print(0)\r\n \r\n\r\ntestcase();quit()\r\nfor t in range(int(input())):\r\n testcase()\r\n"}, {"source_code": "n = int(input())\r\na = [int(i) for i in input().split()]\r\nsm = sum(a)\r\n#print(sorted(a))\r\n#print(sm)\r\nif sm % 2==1:\r\n print(0)\r\nelse:\r\n target = sm // 2\r\n dp =[[0 for j in range(target + 1)] for i in range(n+1)]\r\n dp[0][0] = 1\r\n x =[]\r\n c ={0:[]}\r\n boo = True\r\n for i in range(1,n+1):\r\n for j in range(target):\r\n if dp[i-1][j]:\r\n dp[i][j] = 1\r\n if(j+a[i-1] <= target):\r\n dp[i][j+a[i-1]] = 1\r\n \r\n #x = dp[-1][-1][-1]\r\n if(not dp[-1][-1]):\r\n print(0)\r\n exit()\r\n \r\n while(boo):\r\n for i in range(n):\r\n if a[i]%2:\r\n print(1)\r\n print(i+1)\r\n exit()\r\n a[i]/=2\r\n \r\n \r\n \r\n \r\n \r\n"}, {"source_code": "def zip_sorted(a,b):\n\n\t# sorted by a\n\ta,b = zip(*sorted(zip(a,b)))\n\t# sorted by b\n\tsorted(zip(a, b), key=lambda x: x[1])\n\n\treturn a,b\n\ndef number_to_list(a):\n\n\tb = []\n\n\twhile a>=1:\n\n\t\tc = a%10\n\n\t\ta = int(a/10)\n\n\n\t\tb.append(c)\n\n\treturn list(reversed(b))\n\ndef str_list_to_int_list(a):\n\n\n\ta = list(map(int,a))\n\n\treturn a\n\ndef make_1d_array(n,inti= 0):\n\n\ta = [inti for _ in range(n)]\n\n\treturn a\n\ndef make_2d_array(n,m,inti= 0):\n\n\ta = [[inti for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef make_3d_array(n,m,k,inti= 0):\n\n\ta = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef gcd(a,b):\n\n\tif(b==0): \n\t\treturn a\n\n\telse:\n\t\treturn gcd(b,a%b);\n\n\n\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\nS = lambda : list(map(str,input()))\n\n\n# def solve(sum1,dp):\n\n# \tprev = [[] for i in range(sum1+1)]\n\n# \tfor i in range(n):\n\n# \t\tdp = [prev[j] for j in range(sum1+1)]\n\n# \t\tfor j in range(sum1+1):\n\n\n'''\n\n\n#########################\n#\tOptimizations\n#\n#\t1)\tloop from backwards thus only one loop required\n#\t2)\tmemeroization of only required index of ans\n#\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\n\nif sum1%2==0:\n\n\n\tsum1 = sum1//2\n\n\tdp = [False]*(sum1+1)\n\tdp[0] = True\n\t# ans = [[] for j in range(sum1+1)]\n\tfrom collections import defaultdict\n\tans = defaultdict(list)\n\tfor i in range(n):\n\t\tfor j in range(sum1,-1,-1):\n\t\t\tif j-a[i]>=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n# \t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in ans:\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(prev_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n# \t\tprev_a = [dp_a[j] for j in range(len(dp_a))]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif dp[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(dp_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif prev[j-a[i]][0]:\n# \t\t\t\t\tif dp[j][0]:\n# \t\t\t\t\t\tif (prev[j-a[i]][1]+1)prev[i][1]:\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,prev[i][1])\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = True\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tans1 = [ans[j] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n \n\n# 1)\tless loop while copying\n# 2)\talways intilize with -1\n# 3) \n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\nif sum1%2==0:\n\tsum1 = sum1//2\n\tprev = [False for i in range(sum1+1)]\n\tprev1 = [0 for i in range(sum1+1)]\n\tans = [[] for i in range(sum1+1)]\n\tprev[0] = (True,0)\n\tfor i in range(n):\n\t\tdp = prev.copy()\n\t\tdp1 = prev1.copy()\n\t\tans1 = [ans[j][:] for j in range(sum1+1)]\n\t\tfor j in range(sum1+1):\n\t\t\tif (j-a[i])>=0:\n\t\t\t\tif prev[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n\t\t\t\t\tidx = i\n\t\t\t\tmin1 = min(min1,len(ans[i]))\n\t\tprint(len(ans[idx]))\n\t\tprint(*ans[idx])\n\telse:\n\t\tprint(0)\nelse:\n\tprint(0)\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef solve():\n n = int(input())\n arr = list(map(int, input().split()))\n S = sum(arr)\n if S % 2:\n print(0)\n return\n\n dp = [False for _ in range(S + 1)]\n dp[arr[-1]] = True\n dp[0] = True\n\n for i in range(n - 2, -1, -1):\n for s in range(S + 1, 0, -1):\n if s - arr[i] >= 0 and dp[s - arr[i]]:\n dp[s] = dp[s-arr[i]]\n\n if not dp[S // 2]:\n print(0)\n else:\n cnt = float(\"inf\")\n ans = 0\n for i in range(n):\n tmp = 0\n num = arr[i]\n while num and num % 2 == 0:\n num //= 2\n tmp += 1\n if tmp < cnt:\n cnt = tmp\n ans = i\n print(1)\n print(ans+1)\n return\n\n\nsolve()\n"}, {"source_code": "def helper2(a,tar):\r\n pool = [0] * 200005\r\n pool[0] = 1\r\n for i in range(len(a)):\r\n child = []\r\n for j in range(tar):\r\n if pool[j] == 1:\r\n child.append(j+a[i])\r\n for c in child:\r\n pool[c]= 1\r\n\r\n return pool[tar] == 1\r\n\r\ndef helper(a):\r\n \r\n if sum(a) % 2 == 1:\r\n return -1\r\n \r\n if helper2(a,sum(a)//2):\r\n while True:\r\n for i in range(len(a)):\r\n if a[i] % 2 == 1:\r\n return i\r\n a[i] = a[i] // 2\r\n else:\r\n return -1\r\n\r\n#t = int(input())\r\n#for i in range(t):\r\nn = int(input())\r\na = list(map(int,input().split(\" \")))\r\n#print(len(a))\r\nres = helper(a)\r\nif res == -1:\r\n print(0)\r\n print()\r\nelse:\r\n print(1)\r\n print(res+1)\r\n"}, {"source_code": "def partition(arr,n):\r\n s=sum(arr)//2\r\n if sum(arr)%2 !=0:\r\n return False\r\n else:\r\n dp=[[False for j in range(s+1)] for i in range(n+1)]\r\n for i in range(n+1):\r\n for j in range(s+1):\r\n if i==0:\r\n dp[i][j]=False\r\n if j==0:\r\n dp[i][j]=True\r\n elif j>=arr[i-1]:\r\n dp[i][j]=dp[i-1][j-arr[i-1]] or dp[i-1][j]\r\n else:\r\n dp[i][j]=dp[i-1][j]\r\n return dp[n][s]\r\ndef solve(arr,n):\r\n count=0\r\n for i in range(n):\r\n if arr[i]%2:\r\n count+=1\r\n print(count)\r\n print(i+1)\r\n return\r\n\r\n # print(count)\r\n f=0\r\n while f!=1:\r\n\r\n for k in range(n):\r\n arr[k]=arr[k]//2\r\n\r\n if arr[k]%2:\r\n print(1)\r\n print(k+1)\r\n f=1\r\n return\r\n\r\n\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\nres=(partition(arr,n))\r\ncount=0\r\nif res==False:\r\n print(0)\r\nelse:\r\n (solve(arr,n))\r\n\r\n"}, {"source_code": "# &&&&&&&&YPP#&&&&&&&&&&&&&&&&##&&&&&B5B@@@@@@@@@@&!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&G^#@@@@@@#5&&&&P&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@&J&&&&##&&&&&&&&GB&&&G&&&&&&&&\r\n# &&&&&&&B5Y##&&&&&&&&&&&&&&&&B5##&&&&#?!B&&@&&&&&&&B7&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&5!&@@@@@@@P&&&&P&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#J&&&##&&&&&&&&&&P&&&&&&&&\r\n# &&&&&&&G?G#&&&&&&&&&&&&&&&&PJ#&&&&&5. .:~7JPBB#G7&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&Y5@@@@@@@@B#&&&P@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&@&@@#&@@PJ&&&##&&&&&&&&5B&&P#&&&&&&&\r\n# &&&&&&&55#&&&&&&&&&&&&&&&&5J##&&&5: ..~#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#Y#@@@@@@@@&G&&&P#&#&&&&&&&&@@@@@@@@@@@@@@@@@@@&&&&&###BB5#&&7Y&&##&&&&&&&&#G&&GB&&&&&&&\r\n# &&&&&&#YB#&&&&&&&&&&&&&&&5P&&&&Y^. ~#&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP@@@@@@@@@&Y&&#P&&&&&&&@@&&&&&BBG5JJ7!~~^:::.......... ... P&&##&&&&&&&&Y#&GP&&&&&&&\r\n# &&&&&&B5#&&&&&&&&&&&&&&#YG&&&G~ .:. . ~7P&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&P#@@@@@@@@@@J#&BP@@@@@&&&BPY?~:. G&#B#&&&&&&&5P&#P&&&&&&&\r\n# &&&&&&JP&&&&&&&&&&&&&&BY#&&P: . ^: ... .#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP&@@@@@@@@@@YB@G5@@@@@GPY?!~. . G&BB&&&&&&&&5&&&&&&&\r\n# &&&&&&7#&&&&&&&&&&&&&GY&&5^ .^::.....^55!:..~B&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&PB@@@@@@@@@@@GG@PP@@@@@&&&#GPP?!!?JYG#&#^ ::.^:.:. . ..:.. :7G&G#&&&&&&&J#&Y#&&&&&&\r\n# &&&&&BY&&&&&&&&&&&&&PP#5?YJJ?!75J7?!JJ#&B5JP&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP&@@@@@@@@@@@GG&YB@@@@@@@@&#B###&@@@@@@@Y.:::~!!!!^:. . .^....:. . :P&G#&&&&&&GG&5B&&&&&&\r\n# &&&&&GP&&&&&&&&&&&&?YGP#&&&&&&#B#B#B####GYB&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#P#@@@@@@@@@@@@BP&P&@@@@@@@@&&@@@@@@@@@@@@@77??Y5YJJPY~~^:.. .~~!!~^.:^. ^?PBB&&&&&&PG&&&&&&\r\n# &&&&&G#&&&&&&&&&&#~7?PGP&@@@@@@@@@@@@@@BG&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&PP@@@@@@@@@@@@@#BBG@@@@@@@@@@@@@@@@@@@@@@@@@&&@&BGBBGGP5PYYJ7!!^!#GY?!~^^7^ 5@YYP#&&&&&&5BG5&&&&&&\r\n# &&&&&P&&&&&&&&&&5^!YP~::^!JG##&@&&@@@BG#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP&@@@@@@@@@@@@@BGPB@@@@@@@@@@@@@@@@@@@@@@@@@@^:?#&&&&&&&####PPPPBBBGBP5P57: !@@@P7Y&#&&&&GPGY&&&&&&\r\n# &&&&#B&&&&&&&&#JYY!JPB#&&&&&Y5&@&B&#G#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BY#@@@@@@@@@@@@@@PYY&@@@@@@@@@@@@@@@@@@@@@&&#G5GP. ^?P#@@@@@@@@@@@&&&&&&#BP?. 5@@@@B..P&&&&BY&&&&&&\r\n# &&&&##&&&&&&&G?&@@@@@@@@@@@@&@@@&BB#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#PB@@@@@@@@@@@@@@@PYP@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@P&BPYYP&&&&&@@@@@@@&#BP?^. !7Y5J!^~~:G&&&&&PGJ#&&&&&\r\n# &&&&&&&&&&&&55@@@@@@@@@@@@@@@@&BB&&&&&&&&&&#&&&&&&&&&&&&&&&&&&&&&&#GB@@@@@@@@@@@@@@@#?Y&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@#G#@@@&GJ?YP5YYYJ?!.7Y55J?PJB&&&&BP?B&&&&&\r\n# &&&&&&&&&#@@@@@@@@@@@@@@@BPB&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#PG@@@@@@@@@@@@@@@@G7B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@#G&@@@@@@@#J#@@@@@@5P&&&&G7B&&&&&\r\n\r\nimport sys\r\nfrom collections import *\r\n\r\ndef re(data=str): return data(sys.stdin.readline().rstrip())\r\ndef mp(data=str): return map(data, sys.stdin.readline().split())\r\n\r\ndef solve():\r\n n = re(int)\r\n a = list(mp(int))\r\n sm = sum(a)\r\n MX = 200003\r\n dp = [0] * MX\r\n dp[0] = 1\r\n for i in range(n):\r\n for j in range(MX - 1, -1, -1):\r\n if j - a[i] >= 0:\r\n if dp[j - a[i]]:\r\n dp[j] = 1\r\n \r\n if sm & 1 or not dp[sm // 2]:\r\n print(0)\r\n else:\r\n while True:\r\n for i in range(n):\r\n if a[i] & 1:\r\n print(1)\r\n print(i + 1)\r\n return\r\n else:\r\n a[i] //= 2\r\n \r\n \r\n \r\n\r\n \r\n\r\n\r\n return None\r\n\r\ndef main():\r\n tests = 1\r\n # tests = re(int)\r\n for tc in range(tests):\r\n solve()\r\n print()\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "from functools import lru_cache\n\t\ndef gcd(a,b):\n\tif b==0:\n\t\treturn(a)\n\treturn(gcd(b,a%b))\n\n@lru_cache(None)\ndef subsetSum(curSum,totalSum,idx,array):\n\n\tif idx>=len(array):\n\t\treturn(False)\n\n\tif totalSum==2*curSum:\n\t\treturn(True)\n\n\tif 2*curSum>totalSum:\n\t\treturn(False)\n\twithVal=subsetSum(curSum+array[idx],totalSum,idx+1,array)\n\tif withVal:\n\t\treturn(True)\t\n\twithOutVal=subsetSum(curSum,totalSum,idx+1,array)\n\n\treturn(withOutVal)\n\n\nn=int(input())\narray=tuple(map(int,input().split()))\ntotalSum=sum(array)\n\nif totalSum%2!=0 or not subsetSum(0,totalSum,0,array):\n\tprint(0)\n\nelse:\n\tfor idx,val in enumerate(array):\n\t\tif val%2!=0:\n\t\t\tprint(1)\n\t\t\tprint(idx+1)\n\t\t\tbreak\n\telse:\n\t\tansIdx=0\n\t\tansCount=float('inf')\n\t\tfor idx,val in enumerate(array):\n\t\t\tcount=0\n\t\t\twhile val%2==0:\n\t\t\t\tcount+=1\n\t\t\t\tval=val/2\n\t\t\tif count 2:\r\n count += 1\r\n return count\r\n\r\n\r\n# #MAXN = int(1e7 + 1)\r\n# # spf = [0 for i in range(MAXN)]\r\n#\r\n#\r\n# def sieve():\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#\r\n# for i in range(3, mt.ceil(mt.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#\r\n#\r\n# def getFactorization(x):\r\n# ret = 0\r\n# while (x != 1):\r\n# k = spf[x]\r\n# ret += 1\r\n# # ret.add(spf[x])\r\n# while x % k == 0:\r\n# x //= k\r\n#\r\n# return ret\r\n\r\n\r\n# Driver code\r\n\r\n# precalculating Smallest Prime Factor\r\n# sieve()\r\n\r\ndef main():\r\n n = int(input())\r\n arr = list(map(int, input().split()))\r\n k = sum(arr)\r\n if k % 2:\r\n print(0)\r\n else:\r\n Sum = k\r\n part = [0 for i in range((Sum // 2) + 1)]\r\n for i in range(n):\r\n for j in range(Sum // 2, arr[i] - 1, -1):\r\n if part[j - arr[i]] == 1 or j == arr[i]:\r\n part[j] = 1\r\n #print(part)\r\n if part[Sum // 2] != 1:\r\n print(0)\r\n else:\r\n for i in range(n):\r\n if arr[i]%2==1 or part[Sum//2-(arr[i]//2)]==0:\r\n f = i + 1\r\n break\r\n print(1)\r\n print(f)\r\n\r\n return\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n"}, {"source_code": "n = int(input())\r\narr = list(map(int,input().split()))\r\n\r\ndp = [[0 for _ in range(200001)] for __ in range(n + 1)]\r\ndp[0][0] = 1\r\npref = [0 for i in range(n)]\r\npref[0] = arr[0]\r\nfor i in range(1,n):\r\n pref[i] = pref[i - 1] + arr[i]\r\nfor i in range(1,n + 1):\r\n for j in range(1,200001):\r\n if j > pref[i - 1]:\r\n break\r\n if j - arr[i - 1] >= 0:\r\n dp[i][j] = dp[i - 1][j - arr[i - 1]]|dp[i - 1][j]\r\n\r\ns = sum(arr)\r\nif s % 2 or not dp[n][s//2]:\r\n print(0)\r\nelse:\r\n for index,i in enumerate(arr):\r\n if i % 2:\r\n print(1)\r\n print(index + 1)\r\n exit()\r\n while True:\r\n for i in range(n):\r\n arr[i] = arr[i]//2\r\n if arr[i]%2:\r\n print(1)\r\n print(i + 1)\r\n exit()\r\n"}, {"source_code": "import math, sys\r\nfrom collections import defaultdict, Counter, deque \r\nfrom heapq import heapify, heappush, heappop\r\n\r\nMOD = int(1e9) + 7\r\n\r\n\r\ndef main():\r\n\tn = int(input())\r\n\tarr = list(map(int, input().split()))\r\n\r\n\ttotal = sum(arr)\r\n\tif total % 2 != 0:\r\n\t\tprint(0)\r\n\t\treturn\r\n\r\n\tdp = [[0 for i in range(n + 1)] for j in range(total // 2 + 1)]\r\n\r\n\tfor i in range(n):\r\n\t\tdp[0][i] = 1\r\n\r\n\tfor i in range(1, total // 2 + 1):\r\n\t\tfor j in range(1, n + 1):\r\n\t\t\tdp[i][j] = dp[i][j - 1]\r\n\t\t\tif i >= arr[j - 1]:\r\n\t\t\t\tdp[i][j] = dp[i][j] | dp[i - arr[j - 1]][j - 1]\r\n\r\n\tif dp[total // 2][n]:\r\n\t\ti = 0\r\n\t\twhile True:\r\n\t\t\tif arr[i] % 2 == 1:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i + 1)\r\n\t\t\t\treturn\r\n\r\n\t\t\tarr[i] //= 2\r\n\t\t\ti += 1\r\n\t\t\tif i == n: i = 0\r\n\telse:\r\n\t\tprint(0)\r\n\r\n\r\nt = 1\r\n# t = int(input())\r\nfor _ in range(t):\r\n\tmain()\r\n"}, {"source_code": "def zip_sorted(a,b):\n\n\t# sorted by a\n\ta,b = zip(*sorted(zip(a,b)))\n\t# sorted by b\n\tsorted(zip(a, b), key=lambda x: x[1])\n\n\treturn a,b\n\ndef number_to_list(a):\n\n\tb = []\n\n\twhile a>=1:\n\n\t\tc = a%10\n\n\t\ta = int(a/10)\n\n\n\t\tb.append(c)\n\n\treturn list(reversed(b))\n\ndef str_list_to_int_list(a):\n\n\n\ta = list(map(int,a))\n\n\treturn a\n\ndef make_1d_array(n,inti= 0):\n\n\ta = [inti for _ in range(n)]\n\n\treturn a\n\ndef make_2d_array(n,m,inti= 0):\n\n\ta = [[inti for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef make_3d_array(n,m,k,inti= 0):\n\n\ta = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef gcd(a,b):\n\n\tif(b==0): \n\t\treturn a\n\n\telse:\n\t\treturn gcd(b,a%b);\n\n\n\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\nS = lambda : list(map(str,input()))\n\n\n# def solve(sum1,dp):\n\n# \tprev = [[] for i in range(sum1+1)]\n\n# \tfor i in range(n):\n\n# \t\tdp = [prev[j] for j in range(sum1+1)]\n\n# \t\tfor j in range(sum1+1):\n\n\n'''\n\n\n#########################\n#\tOptimizations\n#\n#\t1)\tloop from backwards thus only one loop required\n#\t2)\tmemeroization of only required index of ans\n#\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\n\nif sum1%2==0:\n\n\n\tsum1 = sum1//2\n\n\tdp = [False]*(sum1+1)\n\tdp[0] = True\n\t# ans = [[] for j in range(sum1+1)]\n\tfrom collections import defaultdict\n\tans = defaultdict(list)\n\tfor i in range(n):\n\t\tfor j in range(sum1,-1,-1):\n\t\t\tif j-a[i]>=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n\t\t\t\tif prev[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans1[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans1[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n\t\tprev = dp.copy()\n\t\tans = ans1.copy()\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(prev_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n# \t\tprev_a = [dp_a[j] for j in range(len(dp_a))]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif dp[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(dp_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif prev[j-a[i]][0]:\n# \t\t\t\t\tif dp[j][0]:\n# \t\t\t\t\t\tif (prev[j-a[i]][1]+1)prev[i][1]:\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,prev[i][1])\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = True\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tans1 = [ans[j] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n \n\n# 1)\tless loop while copying\n# 2)\talways intilize with -1\n# 3) \n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tprev1 = [0 for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = (True,0)\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tdp1 = prev1.copy()\n# \t\tans1 = [ans[j][:] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n"}, {"source_code": "n = int(input())\r\nl = list(map(int, input().split()))\r\nsum1 = sum(l)\r\nif sum1%2 == 1:\r\n print(0)\r\nelse:\r\n prev_dict = {}\r\n prev_dict[0] = True\r\n new_dict = prev_dict.copy()\r\n for i in range(n):\r\n for val in prev_dict:\r\n if val + l[i] not in new_dict:\r\n new_dict[val + l[i]] = True\r\n prev_dict = new_dict.copy()\r\n if sum1//2 not in new_dict:\r\n print(0)\r\n else:\r\n found = -1\r\n for i in range(n):\r\n if l[i]%2 == 1:\r\n save = i + 1\r\n found = 1\r\n break\r\n if found == 1:\r\n print(1)\r\n print(save)\r\n else:\r\n check = 4\r\n save = -1\r\n while True:\r\n for i in range(n):\r\n if l[i]%check != 0:\r\n save = i + 1\r\n break\r\n if save > -1:\r\n break\r\n else:\r\n check *= 2\r\n print(1)\r\n print(save)"}, {"source_code": "import functools, math, sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef knapsack(capacity, utility, weight):\r\n backpack = [[0 for i in range(capacity + 1)] for j in range(2)]\r\n for i in range(len(weight)):\r\n if i % 2 == 0:\r\n for j in range(capacity + 1):\r\n if weight[i] <= j:\r\n backpack[1][j] = max(utility[i] + backpack[0][j - weight[i]], backpack[0][j])\r\n else:\r\n backpack[1][j] = backpack[0][j]\r\n else:\r\n for j in range(capacity + 1):\r\n if weight[i] <= j:\r\n backpack[0][j] = max(utility[i] + backpack[1][j - weight[i]], backpack[1][j])\r\n else:\r\n backpack[0][j] = backpack[1][j]\r\n return backpack[len(weight) % 2][capacity]\r\n\r\nn, values = int(input()), [int(i) for i in input().split()]\r\ntot, tar = sum(values), sum(values) // 2\r\nif tot % 2 or knapsack(tar, values, values) != tar:\r\n print(0)\r\n sys.exit()\r\ngcd = functools.reduce(math.gcd, values)\r\nvalues = [values[i] // gcd for i in range(n)]\r\nfor i in range(n): # remove the odd one out\r\n if values[i] % 2:\r\n print(1)\r\n print(i + 1)\r\n sys.exit()\r\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nS = sum(a)\ndp = [False] * (S + 1)\ndp[0] = True\n\nfor x in a:\n for y in range(S - x, -1, -1):\n dp[x + y] = dp[x + y] or dp[y]\n\nif S % 2 == 1 or not dp[S // 2]:\n print(0)\n exit()\n\nelse:\n norm = 30\n res = -1\n for i, x in enumerate(a):\n cnt = 0\n while x & 1 == 0:\n cnt += 1\n x >>= 1\n if cnt < norm:\n norm = cnt\n res = i\n\n print(1)\n print(res + 1)\n"}, {"source_code": "def fp(arr, n) :\r\n Sum = 0\r\n for i in range(n) :\r\n Sum += arr[i]\r\n if (Sum % 2 != 0) :\r\n return 0\r\n part = [0] * ((Sum // 2) + 1)\r\n for i in range((Sum // 2) + 1) :\r\n part[i] = 0\r\n for i in range(n) :\r\n for j in range(Sum // 2, arr[i] - 1, -1) :\r\n if (part[j - arr[i]] == 1 or j == arr[i]) :\r\n part[j] = 1\r\n return part[Sum // 2]\r\n \r\nn = int(input())\r\narr = list(map(int,input().split()))\r\nb = arr.copy()\r\nflag = 0\r\nif fp(arr,n)==True:\r\n while True:\r\n for i in range(n):\r\n if arr[i]&1:\r\n print(1)\r\n print(i+1)\r\n flag = 1\r\n break\r\n arr[i] //= 2\r\n if flag==1:\r\n break\r\nelse:\r\n print(0)"}, {"source_code": "n = int(input())\r\narr = list(map(int, input().split()))\r\n\r\nif sum(arr) & 1:\r\n print(0)\r\nelse:\r\n even, odd = 0, 0\r\n for i in arr:\r\n if i & 1:\r\n odd += 1\r\n else:\r\n even += 1\r\n target = sum(arr) // 2\r\n n = len(arr)\r\n dp = [[False for i in range(target + 1)] for j in range(n + 1)]\r\n for i in range(n + 1):\r\n dp[i][0] = True\r\n for i in range(1, n + 1):\r\n for j in range(1, target + 1):\r\n if arr[i - 1] > j:\r\n dp[i][j] = dp[i - 1][j]\r\n else:\r\n dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]\r\n if dp[n][target]:\r\n if odd:\r\n for i in range(len(arr)):\r\n if arr[i] & 1:\r\n print(1)\r\n print(i + 1)\r\n exit()\r\n else:\r\n min_index = 10 ** 9\r\n ans = -1\r\n for i in range(len(arr)):\r\n for j in range(32):\r\n if arr[i] & (1 << j):\r\n if j < min_index:\r\n min_index = min(min_index, j)\r\n ans = i + 1\r\n break\r\n print(1)\r\n print(ans)\r\n else:\r\n print(0)\r\n"}, {"source_code": "def solve(arr):\r\n s = sum(arr)\r\n if s & 1:\r\n print(0)\r\n return\r\n half = s // 2\r\n dp = [False] * (half + 1)\r\n dp[0] = True\r\n for a in arr:\r\n if a > half:\r\n print(0)\r\n return\r\n for j in range(half, a - 1, -1):\r\n dp[j] = dp[j] or dp[j - a]\r\n if not dp[-1]:\r\n print(0)\r\n return\r\n\r\n found = [None] * 13\r\n for idx, a in enumerate(arr):\r\n for i in range(13):\r\n if not found[i] and (a >> i) & 1:\r\n found[i] = idx + 1\r\n for i in range(13):\r\n if found[i] is not None:\r\n print(1)\r\n print(found[i])\r\n return\r\n\r\n\r\n# t = int(input())\r\n# for _ in range(t):\r\n # n, k = [int(x) for x in input().split()]\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\nsolve(arr)\r\n"}, {"source_code": "#!/usr/bin/env python\r\n#from __future__ import division, print_function\r\nimport math\r\nimport os\r\nimport sys\r\n#from fractions import *\r\nfrom sys import *\r\nfrom decimal import *\r\nfrom io import BytesIO, IOBase\r\nfrom itertools import accumulate,combinations,permutations,combinations_with_replacement,product\r\nfrom collections import *\r\n#import timeit,time\r\n#sys.setrecursionlimit(10**5)\r\nM = 10 ** 9 + 7\r\nimport heapq\r\n\r\n# print(math.factorial(5))\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# sys.setrecursionlimit(10**6)\r\n# region fastio\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\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\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\r\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\r\n\r\n\r\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\r\n\r\n\r\ndef lis(): return list(map(int, inp().split()))\r\n\r\n\r\ndef stringlis(): return list(map(str, inp().split()))\r\n\r\n\r\ndef sep(): return map(int, inp().split())\r\n\r\n\r\ndef strsep(): return map(str, inp().split())\r\n\r\n\r\ndef fsep(): return map(float, inp().split())\r\n\r\n\r\ndef inpu(): return int(inp())\r\n\r\n\r\n# -----------------------------------------------------------------\r\n\r\ndef regularbracket(t):\r\n p = 0\r\n for i in t:\r\n if i == \"(\":\r\n p += 1\r\n else:\r\n p -= 1\r\n if p < 0:\r\n return False\r\n else:\r\n if p > 0:\r\n return False\r\n else:\r\n return True\r\n# -------------------------------------------------\r\ndef binarySearchcount(arr, n, key):\r\n left = 0\r\n right = n - 1\r\n count = 0\r\n while (left <= right):\r\n mid = int((right + left) / 2)\r\n # Check if middle element is\r\n # less than or equal to key\r\n if (arr[mid] <= key):\r\n count = mid + 1\r\n left = mid + 1\r\n # If key is smaller, ignore right half\r\n else:\r\n right = mid - 1\r\n return count\r\n\r\n#--------------------------------------------------binery search\r\ndef binarySearch(arr, n, key):\r\n left = 0\r\n right = n - 1\r\n while (left <= right):\r\n mid = ((right + left) // 2)\r\n if arr[mid]==key:\r\n return mid\r\n if (arr[mid] <= key):\r\n left = mid + 1\r\n # If key is smaller, ignore right half\r\n else:\r\n right = mid - 1\r\n return -1\r\n#-------------------------------------------------ternary search\r\ndef ternarysearch(arr,n,key):\r\n l,r=0,n-1\r\n while(l<=r):\r\n mid = (-l+r)//3 + l\r\n mid2 = mid + (-l+r)//3\r\n if arr[mid]==key:\r\n return mid\r\n if arr[mid2]==key:\r\n return mid2\r\n if arr[mid]>key:\r\n r=mid-1\r\n elif arr[mid2] 15999:\r\n return\r\n value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]\r\n symbol = [\"F\", \"MF\", \"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"]\r\n roman = \"\"\r\n i = 0\r\n while x > 0:\r\n div = x // value[i]\r\n x = x % value[i]\r\n while div:\r\n roman += symbol[i]\r\n div -= 1\r\n i += 1\r\n return roman\r\n\r\n\r\ndef soretd(s):\r\n for i in range(1, len(s)):\r\n if s[i - 1] > s[i]:\r\n return False\r\n return True\r\n\r\n\r\n# print(soretd(\"1\"))\r\n# ---------------------------\r\ndef countRhombi(h, w):\r\n ct = 0\r\n for i in range(2, h + 1, 2):\r\n for j in range(2, w + 1, 2):\r\n ct += (h - i + 1) * (w - j + 1)\r\n return ct\r\n\r\n\r\ndef countrhombi2(h, w):\r\n return ((h * h) // 4) * ((w * w) // 4)\r\n\r\n\r\n# ---------------------------------\r\ndef binpow(a, b):\r\n if b == 0:\r\n return 1\r\n else:\r\n res = binpow(a, b // 2)\r\n if b % 2 != 0:\r\n return res * res * a\r\n else:\r\n return res * res\r\n\r\n\r\n# -------------------------------------------------------\r\ndef binpowmodulus(a, b, M):\r\n if b==1:\r\n return a%M\r\n if b==0:\r\n return 1\r\n if b%2==0:\r\n ans=binpowmodulus(a,b//2,M)\r\n return (ans*ans)%(M)\r\n else:\r\n ans=binpowmodulus(a,(b-1)//2,M)\r\n return ((ans*a)%M * ans)%M\r\n# -------------------------------------------------------------\r\ndef coprime_to_n(n):\r\n result = n\r\n i = 2\r\n while (i * i <= n):\r\n if (n % i == 0):\r\n while (n % i == 0):\r\n n //= i\r\n result -= result // i\r\n i += 1\r\n if (n > 1):\r\n result -= result // n\r\n return result\r\n\r\n\r\ndef luckynumwithequalnumberoffourandseven(x,n,a):\r\n if x >= n and str(x).count(\"4\") == str(x).count(\"7\"):\r\n a.append(x)\r\n else:\r\n if x < 1e12:\r\n luckynumwithequalnumberoffourandseven(x * 10 + 4,n,a)\r\n luckynumwithequalnumberoffourandseven(x * 10 + 7,n,a)\r\n return a\r\n#----------------------\r\ndef luckynum(x,l,r,a):\r\n if x>=l and x<=r:\r\n a.append(x)\r\n if x>r:\r\n a.append(x)\r\n return a\r\n if x < 1e10:\r\n luckynum(x * 10 + 4, l,r,a)\r\n luckynum(x * 10 + 7, l,r,a)\r\n return a\r\n\r\ndef luckynuber(x, n, a):\r\n p = set(str(x))\r\n if len(p) <= 2:\r\n a.append(x)\r\n if x < n:\r\n luckynuber(x + 1, n, a)\r\n return a\r\n\r\n\r\n# ------------------------------------------------------interactive problems\r\n\r\ndef interact(type, x):\r\n if type == \"r\":\r\n inp = input()\r\n return inp.strip()\r\n else:\r\n print(x, flush=True)\r\n\r\n\r\n# ------------------------------------------------------------------zero at end of factorial of a number\r\ndef findTrailingZeros(n):\r\n # Initialize result\r\n count = 0\r\n\r\n # Keep dividing n by\r\n # 5 & update Count\r\n while (n >= 5):\r\n n //= 5\r\n count += n\r\n\r\n return count\r\n\r\n\r\n# -----------------------------------------------merge sort\r\n# Python program for implementation of MergeSort\r\ndef mergeSort(arr):\r\n if len(arr) > 1:\r\n\r\n # Finding the mid of the array\r\n mid = len(arr) // 2\r\n\r\n # Dividing the array elements\r\n L = arr[:mid]\r\n\r\n # into 2 halves\r\n R = arr[mid:]\r\n\r\n # Sorting the first half\r\n mergeSort(L)\r\n\r\n # Sorting the second half\r\n mergeSort(R)\r\n\r\n i = j = k = 0\r\n\r\n # Copy data to temp arrays L[] and R[]\r\n while i < len(L) and j < len(R):\r\n if L[i] < R[j]:\r\n arr[k] = L[i]\r\n i += 1\r\n else:\r\n arr[k] = R[j]\r\n j += 1\r\n k += 1\r\n\r\n # Checking if any element was left\r\n while i < len(L):\r\n arr[k] = L[i]\r\n i += 1\r\n k += 1\r\n\r\n while j < len(R):\r\n arr[k] = R[j]\r\n j += 1\r\n k += 1\r\n\r\n\r\n# -----------------------------------------------lucky number with two lucky any digits\r\nres = set()\r\ndef solven(p, l, a, b, n): # given number\r\n if p > n or l > 10:\r\n return\r\n if p > 0:\r\n res.add(p)\r\n solven(p * 10 + a, l + 1, a, b, n)\r\n solven(p * 10 + b, l + 1, a, b, n)\r\n\r\n\r\n# problem\r\n\"\"\"\r\nn = int(input())\r\nfor a in range(0, 10):\r\n for b in range(0, a):\r\n solve(0, 0)\r\nprint(len(res))\r\n\"\"\"\r\n\r\n# In the array A at every step we have two\r\n# choices for each element either we can\r\n# ignore the element or we can include the\r\n# element in our subset\r\ndef subsetsUtil(A, subset, index, d):\r\n print(*subset)\r\n s = sum(subset)\r\n d.append(s)\r\n for i in range(index, len(A)):\r\n # include the A[i] in subset.\r\n subset.append(A[i])\r\n\r\n # move onto the next element.\r\n subsetsUtil(A, subset, i + 1, d)\r\n\r\n # exclude the A[i] from subset and\r\n # triggers backtracking.\r\n subset.pop(-1)\r\n return d\r\n\r\n\r\ndef subsetSums(arr, l, r, d, sum=0):\r\n if l > r:\r\n d.append(sum)\r\n return\r\n subsetSums(arr, l + 1, r, d, sum + arr[l])\r\n\r\n # Subset excluding arr[l]\r\n subsetSums(arr, l + 1, r, d, sum)\r\n return d\r\n\r\n\r\ndef print_factors(x):\r\n factors = []\r\n for i in range(1, x + 1):\r\n if x % i == 0:\r\n factors.append(i)\r\n return (factors)\r\n\r\n\r\n# -----------------------------------------------\r\ndef calc(X, d, ans, D):\r\n # print(X,d)\r\n if len(X) == 0:\r\n return\r\n\r\n i = X.index(max(X))\r\n ans[D[max(X)]] = d\r\n\r\n Y = X[:i]\r\n Z = X[i + 1:]\r\n\r\n calc(Y, d + 1, ans, D)\r\n calc(Z, d + 1, ans, D)\r\n\r\n\r\n# ---------------------------------------\r\n\r\ndef factorization(n, l):\r\n c = n\r\n if prime(n) == True:\r\n l.append(n)\r\n return l\r\n for i in range(2, c):\r\n if n == 1:\r\n break\r\n while n % i == 0:\r\n l.append(i)\r\n n = n // i\r\n return l\r\n\r\n\r\n# endregion------------------------------\r\ndef good(b):\r\n l = []\r\n i = 0\r\n while (len(b) != 0):\r\n if b[i] < b[len(b) - 1 - i]:\r\n l.append(b[i])\r\n b.remove(b[i])\r\n else:\r\n l.append(b[len(b) - 1 - i])\r\n b.remove(b[len(b) - 1 - i])\r\n if l == sorted(l):\r\n # print(l)\r\n return True\r\n return False\r\n\r\n\r\n# arr=[]\r\n# print(good(arr))\r\ndef generate(st, s):\r\n if len(s) == 0:\r\n return\r\n\r\n # If current string is not already present.\r\n if s not in st:\r\n st.add(s)\r\n\r\n # Traverse current string, one by one\r\n # remove every character and recur.\r\n for i in range(len(s)):\r\n t = list(s).copy()\r\n t.remove(s[i])\r\n t = ''.join(t)\r\n generate(st, t)\r\n return\r\n#=--------------------------------------------longest increasing subsequence\r\n\r\ndef largestincreasingsubsequence(A):\r\n l = [1]*len(A)\r\n sub=[]\r\n for i in range(1,len(l)):\r\n for k in range(i):\r\n if A[k] number\r\n ans = ans - increment\r\n increment = increment / 10\r\n return ans\r\n\r\ndef countRectangles(l, w):\r\n squareSide = math.gcd(l, w)\r\n return int((l * w) / (squareSide * squareSide))\r\n\r\n# Function that count the\r\n# total numbersProgram between L\r\n# and R which have all the\r\n# digit same\r\ndef count_same_digit(L, R):\r\n tmp = 0\r\n ans = 0\r\n n = int(math.log10(R) + 1)\r\n for i in range(0, n):\r\n # tmp has all digits as 1\r\n tmp = tmp * 10 + 1\r\n for j in range(1, 10):\r\n\r\n if (L <= (tmp * j) and (tmp * j) <= R):\r\n #print(tmp*j)\r\n # Increment the required count\r\n ans += 1\r\n return ans\r\n#----------------------------------print k closest number of a number in an array\r\ndef findCrossOver(arr, low, high, x):\r\n # Base cases\r\n if (arr[high] <= x): # x is greater than all\r\n return high\r\n if (arr[low] > x): # x is smaller than all\r\n return low\r\n # Find the middle point\r\n mid = (low + high) // 2\r\n if (arr[mid] <= x and arr[mid + 1] > x):\r\n return mid\r\n if (arr[mid] < x):\r\n return findCrossOver(arr, mid + 1, high, x)\r\n return findCrossOver(arr, low, mid - 1, x)\r\ndef Kclosest(arr, x, k, n,ans):\r\n # Find the crossover point\r\n l = findCrossOver(arr, 0, n - 1, x)\r\n r = l + 1\r\n count = 0\r\n if (arr[l] == x):\r\n l -= 1\r\n #print(l)\r\n while (l >= 0 and r < n and count < k):\r\n if (x - arr[l] < arr[r] - x):\r\n ans.append(arr[l])\r\n l -= 1\r\n else:\r\n ans.append(arr[r])\r\n r += 1\r\n count += 1\r\n while (count < k and l >= 0):\r\n ans.append(arr[l])\r\n l -= 1\r\n count += 1\r\n while (count < k and r < n):\r\n ans.append(arr[r])\r\n r += 1\r\n count += 1\r\n return ans\r\n#---------------------------------------------------------------\r\n\r\ndef calcSum(arr, n, k):\r\n # Initialize sum = 0\r\n l=[]\r\n sum=0\r\n # Consider first subarray of size k\r\n # Store the sum of elements\r\n for i in range(k):\r\n sum += arr[i]\r\n\r\n # Print the current sum\r\n l.append(sum)\r\n\r\n # Consider every subarray of size k\r\n # Remove first element and add current\r\n # element to the window\r\n for i in range(k, n):\r\n # Add the element which enters\r\n # into the window and substract\r\n # the element which pops out from\r\n # the window of the size K\r\n sum = (sum - arr[i - k]) + arr[i]\r\n\r\n # Print the sum of subarray\r\n l.append(sum)\r\n\r\n return l\r\n\r\n\"\"\"\r\ndef dfs(root,nodeVal,nodeConnection,visited):\r\n leftVal = nodeVal[root][0]\r\n rightVal = nodeVal[root][1]\r\n solution = []\r\n if nodeConnection[root]:\r\n visited.add(root)\r\n for i in nodeConnection[root]:\r\n if i not in visited:\r\n solution.append(dfs(i,nodeVal,nodeConnection,visited))\r\n # print(\"solution\",solution)\r\n leftMax = 0\r\n rightMax = 0\r\n for i in solution:\r\n l, r = i\r\n leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])\r\n rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])\r\n # print(root,\"return->\",(leftVal,leftMax),(rightVal,rightMax))\r\n return ((leftVal, leftMax), (rightVal, rightMax))\r\n else:\r\n # ((left,maxVal),(right,maxVal))\r\n return ((leftVal, 0), (rightVal, 0))\r\n\"\"\"\r\n\"\"\"\r\ndef luckynumber(x,n,a):\r\n if x >0:\r\n a.append(x)\r\n if x>10**9:\r\n return a\r\n else:\r\n if x < 1e12:\r\n luckynumber(x * 10 + 4,n,a)\r\n luckynumber(x * 10 + 7,n,a)\r\ndef lcm(a,b):\r\n return (a*b)//math.gcd(a,b)\r\n\r\ndef query1(l, r):\r\n if l >= r:\r\n return -1\r\n print('?', l + 1, r + 1)\r\n sys.stdout.flush()\r\n return int(input()) - 1\r\ndef answer(p):\r\n print('!', p + 1)\r\n sys.stdout.flush()\r\n exit()\r\n\r\n#---------------------count number of primes\r\n\"\"\"\r\nimport math\r\nMAX = 10**5\r\nprefix = [0] * (MAX + 1)\r\ndef buildPrefix():\r\n prime = [1] * (MAX + 1)\r\n p = 2\r\n while (p * p <= MAX):\r\n if (prime[p] == 1):\r\n i = p * 2\r\n while (i <= MAX):\r\n prime[i] = 0\r\n i += p\r\n p += 1\r\n for p in range(2, MAX + 1):\r\n prefix[p] = prefix[p - 1]\r\n if (prime[p] == 1):\r\n prefix[p] += 1\r\ndef query(L, R):\r\n return prefix[R] - prefix[L - 1]\r\nbuildPrefix()\r\n\r\ndef maxSubArraySum(a, size):\r\n max_so_far = a[0]\r\n curr_max = a[0]\r\n for i in range(1, size):\r\n curr_max = max(a[i], curr_max + a[i])\r\n max_so_far = max(max_so_far, curr_max)\r\n return max_so_far\r\n\r\ndef solve(n,k):\r\n if n==1 and k==1:\r\n return 0\r\n mid=(2**(n-1))//2\r\n if k<=mid:\r\n return solve(n-1,k)\r\n else:\r\n return solve(n-1,k-(mid))==0\r\n\r\n#------------------print subset of strings\r\ndef solvr(s,p):\r\n if len(s)==0:\r\n print(p,end=\" \")\r\n return\r\n op1=p\r\n op2=p+s[0]\r\n s=s[1:]\r\n solvr(s,op1)\r\n solvr(s,op2)\r\n return\r\n#-------------------------------------balanced paranthesis\r\ndef paranthesis(n,m,ans,l):\r\n if n==0 and m==0:\r\n print(ans)\r\n return\r\n if n!=0:\r\n op1=ans+\"(\"\r\n paranthesis(n-1,m,op1,l)\r\n if m>n:\r\n op2=ans+\")\"\r\n paranthesis(n,m-1,op2,l)\r\n\"\"\"\r\nclass node:\r\n def __init__(self,data):\r\n self.data=data\r\n self.next=None\r\nclass linkedlis:\r\n def __init__(self):\r\n self.head=None\r\n def printlis(self):\r\n temp=self.head\r\n while(temp):\r\n print(temp.data,end=\" \")\r\n temp=temp.next\r\n def pushfirst(self,new_data):\r\n new_node=node(new_data)\r\n new_node.next=self.head\r\n self.head=new_node\r\n def pushmid(self,previous_node,new_data):\r\n new_node=node(new_data)\r\n if previous_node==None:\r\n print(\"call pushfirst function if it is the the start otherwise raise an error.\")\r\n new_node.next=previous_node.next\r\n previous_node.next=new_node\r\n def pushlast(self,new_data):\r\n new_node=node(new_data)\r\n if self.head==None:\r\n self.head=new_node\r\n return\r\n last=self.head\r\n while(last.next!=None):\r\n last=last.next\r\n last.next=new_node\r\n def delete_node(self,key):\r\n pass\r\nif __name__ == '__main__':\r\n l=linkedlis()\r\n l.head= node(1)\r\n p = node(2)\r\n pp = node(4)\r\n l.head.next = p\r\n p.next = pp\r\n #print(l.head)\r\n l.pushmid(p, 3)\r\n l.pushlast(5)\r\n l.pushfirst(0)\r\n #l.printlis()\r\n #print(l.head.data)\r\n\"\"\"\r\n\"\"\"\r\ndef main():\r\n n=1000\r\n l=[12]*1000\r\n sum=12*100\r\n dp=[[False]*(sum+1) for i in range(n+1)]\r\n for i in range(n+1):\r\n dp[i][0]=True\r\n for i in range(1,n+1):\r\n for j in range(1,sum+1):\r\n if j=arr[i]:\r\n stack.pop()\r\n else:\r\n break\r\n if len(stack)==0:\r\n ans.append(n)\r\n else:\r\n ans.append(stack[-1][1])\r\n stack.append([arr[i],i])\r\n ans.reverse()\r\n return ans\r\ndef lse(arr,n):\r\n stack=[]\r\n ans=[]\r\n for i in range(n):\r\n if len(stack)==0:\r\n ans.append(-1)\r\n else:\r\n while(len(stack)!=0):\r\n if stack[-1][0]>=arr[i]:\r\n stack.pop()\r\n else:\r\n break\r\n if len(stack)==0:\r\n ans.append(-1)\r\n else:\r\n ans.append(stack[-1][1])\r\n stack.append([arr[i],i])\r\n return ans\r\n\"\"\"\r\n\"\"\"\r\ndef lcs(s,r):\r\n rr=len(r)\r\n ss=len(s)\r\n l=[[0]*(rr+1) for i in range(ss+1)]\r\n for i in range(ss+1):\r\n for j in range(rr+1):\r\n if i==0 and j==0:\r\n l[i][j]=0\r\n elif s[i-1]==r[j-1]:\r\n l[i][j]=l[i-1][j-1]+1\r\n else:\r\n l[i][j] =max(l[i-1][j],l[i][j-1])\r\n return l[ss][rr]\r\n\"\"\"\r\ndef subsetsum(arr,sum,len):\r\n dp=[[False]*(sum+1) for i in range(len+1)]\r\n for i in range(len+1):\r\n dp[i][0]=True\r\n for i in range(1,len+1):\r\n for j in range(1,sum+1):\r\n if j==0:\r\n dp[i][j]=True\r\n elif arr[i-1]>j:\r\n dp[i][j]=dp[i-1][j]\r\n else:\r\n dp[i][j]=dp[i-1][j] or dp[i-1][j-arr[i-1]]\r\n #print(dp)\r\n return dp[len][sum]\r\n#print(subsetsum([3,9,12],12,3))\r\ndef main():\r\n t=1\r\n #t=inpu()\r\n for _ in range(t):\r\n n=inpu()\r\n arr=lis()\r\n arr=[0]+arr\r\n if sum(arr)%2!=0:\r\n print(0)\r\n continue\r\n else:\r\n ans=[]\r\n if subsetsum(arr,sum(arr)//2,len(arr))==True:\r\n print(1)\r\n pows = [-1] * 11\r\n for i in range(1,n+1):\r\n for j in range(10, -1, -1):\r\n if arr[i] % (1 << j) == 0:\r\n pows[j] = i\r\n break\r\n for i in range(11):\r\n if pows[i] != -1:\r\n print(pows[i])\r\n break\r\n else:\r\n print(0)\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "#######################################################################################################################\r\n# Author: BlackFyre\r\n# Language: PyPy 3.7\r\n#######################################################################################################################\r\n \r\nfrom sys import stdin, stdout, setrecursionlimit\r\nfrom math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2\r\nfrom random import seed, randint\r\nfrom datetime import datetime\r\nfrom collections import defaultdict as dd, deque\r\nfrom heapq import merge, heapify, heappop, heappush, nsmallest\r\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\r\nfrom collections import defaultdict as dd\r\nmod = pow(10, 9) + 7\r\nmod2 = 998244353\r\n# setrecursionlimit(3000)\r\n \r\ndef inp(): return stdin.readline().strip()\r\ndef iinp(): return int(inp())\r\ndef out(var, end=\"\\n\"): stdout.write(str(var) + \"\\n\")\r\ndef outa(*var, end=\"\\n\"): stdout.write(' '.join(map(str, var)) + end)\r\ndef lmp(): return list(mp())\r\ndef mp(): return map(int, inp().split())\r\ndef smp(): return map(str, inp().split())\r\ndef l1d(n, val=0): return [val for i in range(n)]\r\ndef l2d(n, m, val=0): return [l1d(m, val) for j in range(n)]\r\ndef remadd(x, y): return 1 if x % y else 0\r\ndef ceil(a, b): return (a + b - 1) // b\r\ndef def_value(): return 0\r\ndef def_inf(): return inf\r\ndef atoi(s): return ord(s)-ord('a')\r\ndef inc(s, n=1): return chr((ord(s)-ord('a')+n)%26+ord('a'))\r\n\r\nclass XY:\r\n def __init__(self, x, y):\r\n self.x = x\r\n self.y = y\r\n \r\ndef rotate(a,b,c):\r\n ang = (b.y-a.y)*(c.x-b.x) - (b.x-a.x)*(c.y-b.y)\r\n if ang == 0: return 0 #0coll, +-clock, --aclock\r\n else: return ang/abs(ang)\r\n \r\nn = iinp()\r\nb = lmp()\r\na = b.copy()\r\n \r\ns = sum(a)\r\nif s%2!=0:\r\n print(0)\r\nelse:\r\n s//=2\r\n dp = l1d(s+1, False)\r\n dp[0] = True\r\n for i in range(n):\r\n for j in range(s, -1, -1):\r\n if j-a[i]>=0:\r\n dp[j] = dp[j-a[i]] or dp[j]\r\n \r\n if not dp[s]: print(0)\r\n else:\r\n flg = False\r\n for i in range(n):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n flg = True\r\n break\r\n if not flg:\r\n print(1)\r\n gd = 0\r\n for i in range(n):\r\n gd = gcd(a[i],gd)\r\n for i in range(n):\r\n if (a[i]/gd)%2==1:\r\n print(i+1)\r\n break"}, {"source_code": "def isSubsetSum(set, n, sum):\r\n subset = ([[False for i in range(sum + 1)]for i in range(n + 1)])\r\n for i in range(n + 1):\r\n subset[i][0] = True\r\n for i in range(1, sum + 1):\r\n subset[0][i] = False\r\n for i in range(1, n + 1):\r\n for j in range(1, sum + 1):\r\n if j < set[i - 1]:\r\n subset[i][j] = subset[i - 1][j]\r\n if j >= set[i - 1]:\r\n subset[i][j] = (subset[i - 1][j] or subset[i - 1][j - set[i - 1]])\r\n return subset[n][sum]\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ntot=sum(a)\r\nif tot&1==1:\r\n print(0)\r\nelse:\r\n sm=tot//2\r\n if isSubsetSum(a,n,sm):\r\n print(1)\r\n ver=False\r\n for i in range(n):\r\n if a[i]&1==1:\r\n print(i+1)\r\n ver=True\r\n break\r\n if ver==False:\r\n while True:\r\n for i in range(n):\r\n a[i]//=2\r\n if a[i]&1==1:\r\n print(i+1)\r\n ver=True\r\n break\r\n if ver:\r\n break\r\n else:\r\n print(0)"}, {"source_code": "def check(arr):\r\n n=sum(arr)//2\r\n dp=[0 for i in range(sum(arr)+4)]\r\n dp[0]=1 # it check whether the given array\r\n for i in arr:\r\n for j in range(len(dp)-1,-1,-1):\r\n if dp[j]==1:\r\n dp[i+j]=1\r\n if i+j==n:\r\n return True\r\n if dp[n]==1:\r\n return True\r\n return False\r\n\r\n\r\ndef answer(arr):\r\n if sum(arr)%2!=0:\r\n print(0)\r\n else:# array is already good so it cannot be divided into two subsequence\r\n import math\r\n n=sum(arr)//2\r\n dp=[0 for i in range(n+1)]\r\n if check(arr)==True:\r\n d = math.gcd(arr[0], arr[1])\r\n for i in range(2, len(arr)):\r\n d = math.gcd(d, arr[i])\r\n\r\n for i in range(len(arr)):\r\n arr[i] //= d\r\n j=0\r\n while j=len(array):\n\t\treturn(False)\n\n\tif totalSum==2*curSum:\n\t\treturn(True)\n\n\tif 2*curSum>totalSum:\n\t\treturn(False)\n\twithVal=subsetSum(curSum+array[idx],totalSum,idx+1,array)\n\tif withVal:\n\t\treturn(True)\t\n\twithOutVal=subsetSum(curSum,totalSum,idx+1,array)\n\n\treturn(withOutVal)\n\n\nn=int(input())\narray=tuple(map(int,input().split()))\ntotalSum=sum(array)\n\nif totalSum%2!=0 or not subsetSum(0,totalSum,0,array):\n\tprint(0)\n\nelse:\n\tfor idx,val in enumerate(array):\n\t\tif val%2!=0:\n\t\t\tprint(1)\n\t\t\tprint(idx+1)\n\t\t\tbreak\n\telse:\n\t\tansIdx=0\n\t\tansCount=float('inf')\n\t\tfor idx,val in enumerate(array):\n\t\t\tcount=0\n\t\t\twhile val%2==0:\n\t\t\t\tcount+=1\n\t\t\t\tval=val/2\n\t\t\tif count=1:\n\n\t\tc = a%10\n\n\t\ta = int(a/10)\n\n\n\t\tb.append(c)\n\n\treturn list(reversed(b))\n\ndef str_list_to_int_list(a):\n\n\n\ta = list(map(int,a))\n\n\treturn a\n\ndef make_1d_array(n,inti= 0):\n\n\ta = [inti for _ in range(n)]\n\n\treturn a\n\ndef make_2d_array(n,m,inti= 0):\n\n\ta = [[inti for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef make_3d_array(n,m,k,inti= 0):\n\n\ta = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]\n\n\treturn a\n\ndef gcd(a,b):\n\n\tif(b==0): \n\t\treturn a\n\n\telse:\n\t\treturn gcd(b,a%b);\n\n\n\nimport sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\nS = lambda : list(map(str,input()))\n\n\n# def solve(sum1,dp):\n\n# \tprev = [[] for i in range(sum1+1)]\n\n# \tfor i in range(n):\n\n# \t\tdp = [prev[j] for j in range(sum1+1)]\n\n# \t\tfor j in range(sum1+1):\n\n\n'''\n\n\n#########################\n#\tOptimizations\n#\n#\t1)\tloop from backwards thus only one loop required\n#\t2)\tmemeroization of only required index of ans\n#\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\n\nif sum1%2==0:\n\n\n\tsum1 = sum1//2\n\n\tdp = [False]*(sum1+1)\n\tdp[0] = True\n\t# ans = [[] for j in range(sum1+1)]\n\tfrom collections import defaultdict\n\tans = defaultdict(list)\n\tfor i in range(n):\n\t\tfor j in range(sum1,-1,-1):\n\t\t\tif j-a[i]>=0:\n\t\t\t\tif dp[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n\t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\t\telse:\n\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n\t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n\t# print(ans)\n\n\tidx = -1\n\n\t# print(dp[sum1],ans[sum1])\n\n\tif dp[sum1]:\n\n\t\tmin1 = 10**10\n\n\t\tfor i in ans:\n\n\t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n\t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(ans[j])>(len(ans[j-a[i]])+1):\n# \t\t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tans[j] = ans[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in ans:\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(ans[i])=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(prev_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = prev_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or prev[j-a[i]]\n# \t\tprev = dp.copy()\n# \t\tprev_a = [dp_a[j] for j in range(len(dp_a))]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif dp[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif len(dp_a[j])>(len(dp_a[j-a[i]])+1):\n# \t\t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\t\telse:\n# \t\t\t\t\t\tdp_a[j] = dp_a[j-a[i]]+[i+1]\n# \t\t\t\tdp[j] = dp[j] or dp[j-a[i]]\n\n# \t# print(ans)\n\n# \tidx = -1\n\n# \t# print(dp[sum1],ans[sum1])\n\n# \tif dp[sum1]:\n\n# \t\tmin1 = 10**10\n\n# \t\tfor i in range(sum1+1):\n\n# \t\t\tif dp[i] and (i%2!=0 or dp[(2*sum1-i)//2]==False):\n\n# \t\t\t\tif len(dp_a[i])=0:\n# \t\t\t\tif prev[j-a[i]][0]:\n# \t\t\t\t\tif dp[j][0]:\n# \t\t\t\t\t\tif (prev[j-a[i]][1]+1)prev[i][1]:\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,prev[i][1])\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\n# n, = I()\n# a = I()\n# sum1 = sum(a)\n# if sum1%2==0:\n# \tsum1 = sum1//2\n# \tprev = [False for i in range(sum1+1)]\n# \tans = [[] for i in range(sum1+1)]\n# \tprev[0] = True\n# \tfor i in range(n):\n# \t\tdp = prev.copy()\n# \t\tans1 = [ans[j] for j in range(sum1+1)]\n# \t\tfor j in range(sum1+1):\n# \t\t\tif (j-a[i])>=0:\n# \t\t\t\tif prev[j-a[i]]:\n# \t\t\t\t\tif dp[j]:\n# \t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n# \t\t\t\t\tidx = i\n# \t\t\t\tmin1 = min(min1,len(ans[i]))\n# \t\tprint(len(ans[idx]))\n# \t\tprint(*ans[idx])\n# \telse:\n# \t\tprint(0)\n# else:\n# \tprint(0)\n \n\n# 1)\tless loop while copying\n# 2)\talways intilize with -1\n# 3) \n\n\n#########################\n#\n#\tWA of contest\n# pass\n\n#########################\n\nn, = I()\na = I()\nsum1 = sum(a)\nif sum1%2==0:\n\tsum1 = sum1//2\n\tprev = [False for i in range(sum1+1)]\n\tprev1 = [0 for i in range(sum1+1)]\n\tans = [[] for i in range(sum1+1)]\n\tprev[0] = (True,0)\n\tfor i in range(n):\n\t\tdp = prev.copy()\n\t\tdp1 = prev1.copy()\n\t\tans1 = [ans[j][:] for j in range(sum1+1)]\n\t\tfor j in range(sum1+1):\n\t\t\tif (j-a[i])>=0:\n\t\t\t\tif prev[j-a[i]]:\n\t\t\t\t\tif dp[j]:\n\t\t\t\t\t\tif (len(ans[j-a[i]])+1)len(ans[i]):\n\t\t\t\t\tidx = i\n\t\t\t\tmin1 = min(min1,len(ans[i]))\n\t\tprint(len(ans[idx]))\n\t\tprint(*ans[idx])\n\telse:\n\t\tprint(0)\nelse:\n\tprint(0)\n"}, {"source_code": "\"\"\"\r\n// Author : snape_here - Susanta Mukherjee\r\n \r\n \"\"\"\r\n\r\nfrom __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\ndef ii(): return int(input())\r\ndef fi(): return float(input())\r\ndef si(): return input()\r\ndef msi(): return map(str,input().split())\r\ndef mi(): return map(int,input().split())\r\ndef li(): return list(mi())\r\ndef lsi(): return list(msi())\r\n \r\n \r\ndef read():\r\n sys.stdin = open('input.txt', 'r') \r\n sys.stdout = open('output.txt', 'w') \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\ndef lcm(x, y):\r\n return (x*y)//(gcd(x,y))\r\n\r\nmod=1000000007\r\n\r\ndef modInverse(b,m): \r\n g = gcd(b, m) \r\n if (g != 1): \r\n return -1\r\n else: \r\n return pow(b, m - 2, m) \r\n\r\ndef ceil2(x,y):\r\n if x%y==0:\r\n return x//y\r\n else:\r\n return x//y+1\r\n\r\ndef modu(a,b,m): \r\n\r\n a = a % m \r\n inv = modInverse(b,m) \r\n if(inv == -1): \r\n return -999999999\r\n else: \r\n return (inv*a)%m\r\n\r\nfrom math import log,factorial,cos,tan,sin,radians,floor,sqrt,ceil\r\n\r\nabc=\"abcdefghijklmnopqrstuvwxyz\"\r\n\r\npi=3.141592653589793238\r\n\r\ndef gcd1(a):\r\n\r\n if len(a) == 1:\r\n return a[0]\r\n\r\n ans = a[0]\r\n for i in range(1,len(a)):\r\n ans = gcd(ans,a[i])\r\n\r\n return ans\r\n\r\ndef mykey(x):\r\n return x[1],-x[0]\r\n\r\ndef main():\r\n\r\n for _ in range(1):\r\n n=ii()\r\n a=li()\r\n a.insert(0,0)\r\n if sum(a)%2:\r\n print(0)\r\n exit()\r\n\r\n s = sum(a)\r\n\r\n dp = []\r\n for i in range(n+1):\r\n c = [0]*(200005)\r\n dp.append(c)\r\n\r\n dp[0][0] = 1\r\n for i in range(n):\r\n for j in range(200005):\r\n if dp[i][j]:\r\n dp[i+1][j] = 1\r\n dp[i+1][j+a[i+1]] = 1\r\n\r\n y = -1 \r\n for i in range(n, 0, -1):\r\n if a[i]%2:\r\n y = i \r\n break\r\n\r\n if y==-1:\r\n l=[]\r\n for i in range(1,n+1):\r\n c = 0\r\n while a[i]%2==0:\r\n a[i] //= 2\r\n c += 1\r\n l.append(c)\r\n m = min(l)\r\n\r\n for i in range(n):\r\n if l[i]==m:\r\n y = i+1\r\n break\r\n\r\n x = s//2\r\n f = 0\r\n ans = 0\r\n for i in range(1,n+1):\r\n if dp[i][x]:\r\n f = 1\r\n ans = y \r\n break\r\n\r\n if f:\r\n print(1)\r\n print(ans)\r\n else:\r\n print(0)\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\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()"}, {"source_code": "import sys\nimport math\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.rstrip()))\ndef invr():\n return(map(int,input().split()))\n\n\n\n\ndef solution(L):\n\n\tfor i in range(n):\n\t\tl=L[i]\n\t\tif l%2==1:\n\t\t\tprint(1)\n\t\t\tprint(i+1)\n\t\t\treturn 0\n\tsolution([l//2 for l in L])\n\nn=inp()\nL=inlt()\nS=sum(L)\ndef test():\n\tif S%2!=0:\n\t\tprint(0)\n\telse:\n\n\t\tP=set([0])\n\t\tfound=False\n\t\tfor l in L:\n\t\t\tif found:\n\t\t\t\tbreak\n\t\t\tA=[]\n\t\t\tfor p in P:\n\t\t\t\tif p+l==S//2:\n\t\t\t\t\tfound=True\n\t\t\t\t\tbreak\n\t\t\t\tif p+l <= S//2:\n\t\t\t\t\tA.append(p+l)\n\t\t\tfor a in A:\n\t\t\t\tP.add(a)\n\n\t\tif found:\n\t\t\tsolution(L)\n\t\telse:\n\t\t\tprint(0)\n\ntest()"}, {"source_code": "import sys\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nz = sum(a)\r\nif z % 2 == 0:\r\n s = 1\r\n for x in a:\r\n s |= s << x\r\n if s & (1 << (z // 2)):\r\n b = [x & -x for x in a]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i + 1}\")\r\n sys.exit()\r\nprint(0)"}, {"source_code": "from math import gcd\r\nfrom sys import stdin\r\ninput = stdin.buffer.readline\r\n\r\ndef check(arr):\r\n target = sum(arr) // 2\r\n dp = [[False for _ in range(target+1)] for __ in range(n+1)]\r\n\r\n for i in range(n+1):\r\n dp[i][0] = True\r\n\r\n for i in range(1, n+1):\r\n for j in range(1, target+1):\r\n if j - a[i-1] >= 0:\r\n dp[i][j] = dp[i-1][j - a[i-1]] or dp[i-1][j]\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n\r\n return dp[-1][-1]\r\n\r\n\r\ndef func():\r\n if sum(a) % 2 != 0 or not check(a):\r\n print(0)\r\n else:\r\n for i in range(n):\r\n if a[i] % 2 != 0:\r\n print(1, i+1, sep='\\n')\r\n return\r\n gc = 0\r\n\r\n for i in range(n):\r\n gc = gcd(gc, a[i])\r\n\r\n for i in range(n):\r\n a[i] = a[i] // gc\r\n\r\n for i in range(n):\r\n if a[i] % 2 != 0:\r\n print(1, i+1, sep='\\n')\r\n return\r\n\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nfunc()"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nfor _ in range(1):\r\n def canPartition(nums):\r\n a=sum(nums)\r\n n=len(nums)\r\n d={}\r\n def helper(curr,s):\r\n if curr==n:\r\n if s==a//2:\r\n return True\r\n return False\r\n if (curr,s) in d:\r\n return d[(curr,s)]\r\n ans=helper(curr+1,s+nums[curr]) or helper(curr+1,s)\r\n d[(curr,s)]=ans\r\n return ans \r\n if a%2:\r\n return False\r\n return helper(0,0)\r\n n=int(input())\r\n arr=[int(x) for x in input().split()]\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n continue\r\n if canPartition(arr)==False:\r\n print(0)\r\n continue\r\n else:\r\n odd=-1\r\n temp=[]\r\n for i in range(n):\r\n if arr[i]%2:\r\n odd=i\r\n if arr[i]%2==0 and (arr[i]//2)%2:\r\n temp.append(i)\r\n if odd>=0:\r\n print(1)\r\n print(odd+1)\r\n continue\r\n if temp:\r\n print(1)\r\n print(temp[0]+1)\r\n else:\r\n d={}\r\n for i in range(n):\r\n if arr[i] in d:\r\n d[arr[i]].append(i)\r\n else:\r\n d[arr[i]]=[i]\r\n #print(d)\r\n for i in sorted(d.keys()):\r\n if canPartition(arr[:d[i][0]]+arr[d[i][0]+1:])==False:\r\n print(1)\r\n print(d[i][0]+1)\r\n #print(1)\r\n #print(d[i][0])\r\n exit()"}, {"source_code": "from os import path\r\nimport sys,time\r\nmod = int(1e9 + 7)\r\n# import re\r\nfrom math import ceil, floor,gcd,log,log2 ,factorial,sqrt\r\nfrom collections import defaultdict ,Counter , OrderedDict , deque\r\nfrom itertools import combinations ,accumulate\r\n# from string import ascii_lowercase ,ascii_uppercase\r\nfrom bisect import *\r\nfrom functools import reduce\r\nfrom operator import mul\r\nstar = lambda x: print(' '.join(map(str, x)))\r\ngrid = lambda r :[lint() for i in range(r)]\r\nstpr = lambda x : sys.stdout.write(f'{x}' + '\\n')\r\nINF = float('inf')\r\nif (path.exists('input.txt')):\r\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\r\nimport sys\r\nfrom sys import stdin, stdout\r\nfrom collections import *\r\nfrom math import gcd, floor, ceil\r\ndef st(): return list(stdin.readline().strip())\r\ndef inp():\r\n return int(stdin.readline())\r\ndef inlt():\r\n return list(map(int, stdin.readline().split()))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return map(int, stdin.readline().split())\r\ndef pr(n): return stdout.write(str(n)+\"\\n\")\r\nfrom copy import deepcopy\r\ndef subset_sum(a,n,target):\r\n dp = [[False for _ in range(target+1)]for _ in range(n+1)]\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if i==0:\r\n dp[i][j] = False\r\n if j==0:\r\n dp[i][j] = True\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if a[i-1]<=j:\r\n dp[i][j] = dp[i-1][j] or dp[i-1][j-a[i-1]]\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n return dp[n][target]\r\ndef solve():\r\n n = inp()\r\n a = inlt()\r\n if sum(a)%2:\r\n print(0)\r\n else:\r\n odd = False\r\n ind = 0\r\n if subset_sum(a,n,sum(a)//2):\r\n for i in range(n):\r\n if a[i]%2:\r\n ind = i\r\n odd = True\r\n break\r\n if odd:\r\n print(1)\r\n print(ind+1)\r\n else:\r\n \r\n for j in range(13):\r\n for i in range(n):\r\n if a[i]%2:\r\n print(1)\r\n print(i+1)\r\n return\r\n else:\r\n a[i]//=2\r\n else:\r\n print(0)\r\n \r\nt = 1\r\n#t = inp()\r\nfor _ in range(t):\r\n solve()\r\n\r\n"}, {"source_code": "import sys \r\ninput = sys.stdin.readline \r\n\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\n\r\ns = sum(a)\r\nd = {0}\r\nfor i in a:\r\n b = set()\r\n for c in d:\r\n b.add(i + c)\r\n d |= b\r\n \r\nif(s % 2 == 1 or not (s // 2 in d)):\r\n print(0)\r\n exit()\r\n\r\nprint(1)\r\nfor i in range(33):\r\n for j in range(n):\r\n if(a[j] & (1 << i)):\r\n print(j + 1)\r\n exit()\r\n"}, {"source_code": "def possible(nums,target):\r\n reach = {0}\r\n for num in nums:\r\n reach |= {i+num for i in reach if i+num <= target}\r\n if target in reach:\r\n return True\r\n return False\r\nn = int(input())\r\narr = list(map(int,input().split()))\r\ns = sum(arr)\r\n\r\nif s%2==1 or not possible(arr,s//2):\r\n print(0)\r\nelse:\r\n print(1)\r\n mi = 100\r\n res = -1\r\n for i in range(n):\r\n A = arr[i] & (-arr[i])\r\n cnt = 0\r\n while A :\r\n cnt += 1\r\n A >>= 1\r\n if cnt < mi:\r\n mi = cnt\r\n res = i+1\r\n print(res)\r\n\r\n"}, {"source_code": "import math, sys\r\nfrom collections import defaultdict, Counter, deque \r\nfrom heapq import heapify, heappush, heappop\r\n\r\nMOD = int(1e9) + 7\r\n\r\n\r\ndef main():\r\n\tn = int(input())\r\n\tarr = list(map(int, input().split()))\r\n\r\n\ttotal = sum(arr)\r\n\tif total % 2 != 0:\r\n\t\tprint(0)\r\n\t\treturn\r\n\r\n\tdp = [[0 for i in range(n + 1)] for j in range(total // 2 + 1)]\r\n\r\n\tfor i in range(n):\r\n\t\tdp[0][i] = 1\r\n\r\n\tfor i in range(1, total // 2 + 1):\r\n\t\tfor j in range(1, n + 1):\r\n\t\t\tdp[i][j] = dp[i][j - 1]\r\n\t\t\tif i >= arr[j - 1]:\r\n\t\t\t\tdp[i][j] = dp[i][j] | dp[i - arr[j - 1]][j - 1]\r\n\r\n\tif dp[total // 2][n]:\r\n\t\ti = 0\r\n\t\twhile True:\r\n\t\t\tif arr[i] % 2 == 1:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i + 1)\r\n\t\t\t\treturn\r\n\r\n\t\t\tarr[i] //= 2\r\n\t\t\ti += 1\r\n\t\t\tif i == n: i = 0\r\n\telse:\r\n\t\tprint(0)\r\n\r\n\r\nt = 1\r\n# t = int(input())\r\nfor _ in range(t):\r\n\tmain()\r\n"}, {"source_code": "from sys import stdin, stdout\r\n\r\nget_string = lambda: stdin.readline().strip(' ')\r\nget_intmap = lambda: map( int, get_string().split(' ') )\r\n\r\n\r\ndef testcase():\r\n n = int(input())\r\n l = list(get_intmap())\r\n suml = sum(l)\r\n if suml % 2 == 1:# odd sum array cant be bipartitioned\r\n print(0); return\r\n #try to partition the even sum array by\r\n #doing a knapsack on half the sum as weight of sack\r\n dp = 1\r\n for i in l:\r\n dp |= (dp << i)\r\n if dp & (1 << (suml//2)):#knapsack success/ partition possible\r\n print(1)\r\n #find odd number or number with smallest possible Least significant bit\r\n min_lsb_pos = 32\r\n min_ind = -1\r\n for ind, i in enumerate(l):\r\n lsb_pos = 0\r\n while i & (1 << lsb_pos) == 0:\r\n lsb_pos += 1\r\n if min_lsb_pos > lsb_pos:\r\n min_lsb_pos = lsb_pos\r\n min_ind = ind\r\n print(min_ind + 1)\r\n else:\r\n print(0)\r\n \r\n\r\ntestcase();quit()\r\nfor t in range(int(input())):\r\n testcase()\r\n"}, {"source_code": "import math\r\ndef calc(arr):\r\n\tgc=arr[0]\r\n\tfor i in range(1,len(arr)):\r\n\t\tgc=math.gcd(gc,arr[i])\r\n\treturn gc\r\ndef check(arr):\r\n n=sum(arr)//2\r\n dp=[0 for i in range(sum(arr)+4)]\r\n dp[0]=1 # it check whether the given array\r\n for i in arr:\r\n for j in range(len(dp)-1,-1,-1):\r\n if dp[j]==1:\r\n dp[i+j]=1\r\n if i+j==n:\r\n return True\r\n if dp[n]==1:\r\n return True\r\n return False\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\ngc=calc(arr)\r\nif sum(arr)%2==0:\r\n\tif (check(arr) == False):\r\n\t\tprint(0)\r\n\telse:\r\n\t\tflag=0\r\n\t\tfor i in range(n):\r\n\t\t\tif arr[i]%2==1:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\tflag=1\r\n\t\t\t\tbreak\r\n\t\tif flag==0:\r\n\t\t\tfor i in range(n):\r\n\t\t\t\tif (arr[i]//gc)%2==1:\r\n\t\t\t\t\tprint(1)\r\n\t\t\t\t\tprint(i+1)\r\n\t\t\t\t\tbreak\r\nelse:\r\n\tprint(0)\r\n"}, {"source_code": "import time\r\n\r\n\r\ndef main():\r\n n = i_input()\r\n a = li_input()\r\n\r\n p = [0] * n\r\n s = 0\r\n for i, aa in enumerate(a):\r\n s += aa\r\n c = 0\r\n while not aa % 2:\r\n aa //= 2\r\n c += 1\r\n p[i] = c\r\n\r\n if s % 2:\r\n print(0)\r\n return\r\n\r\n a.sort()\r\n\r\n limit = s // 2\r\n l = [0]\r\n for aa in a:\r\n b = []\r\n p1 = p2 = 0\r\n while p1 < len(l):\r\n while p2 < len(l) and l[p1] + aa >= l[p2] and l[p2] <= limit:\r\n b.append(l[p2])\r\n p2 += 1\r\n\r\n if l[p1] + aa != b[-1] and l[p1] + aa <= limit:\r\n b.append(l[p1] + aa)\r\n p1 += 1\r\n l = b\r\n\r\n # print(l)\r\n\r\n if l[-1] != limit:\r\n print(0)\r\n return\r\n\r\n minp = (100, -1)\r\n for i in range(n):\r\n minp = min(minp, (p[i], i + 1))\r\n\r\n print(1)\r\n print(minp[1])\r\n\r\n\r\n############\r\n\r\ndef i_input():\r\n return int(input())\r\n\r\n\r\ndef l_input():\r\n return input().split()\r\n\r\n\r\ndef li_input():\r\n return list(map(int, l_input()))\r\n\r\n\r\n# endregion\r\n\r\nif __name__ == \"__main__\":\r\n TT = time.time()\r\n main()\r\n # print(\"\\n\", time.time() - TT)\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\ndef canPartition(a,i,target):\r\n dp = [[False for i in range(target+1)]for j in range(len(a))]\r\n for i in range(n):\r\n dp[i][0] = True\r\n for i in range(1,n):\r\n for j in range(1,target+1):\r\n dp[i][j] = dp[i-1][j]\r\n if a[i-1]<=j:\r\n dp[i][j] = dp[i][j] or dp[i-1][j-a[i-1]]\r\n return dp[-1][target] \r\nn = int(input())\r\na = list(map(int,input().split()))\r\ns = sum(a)\r\nif s%2==1:\r\n print(0)\r\nelse:\r\n final = float(\"inf\")\r\n memo = {}\r\n d = {i:v for v,i in enumerate(a)}\r\n if not canPartition(a,0,s//2):\r\n print(0)\r\n exit()\r\n for i in range(n):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n flag = False\r\n while True:\r\n for i in range(n):\r\n a[i]//=2\r\n for i in range(n):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n flag = True\r\n break\r\n if flag:\r\n break"}, {"source_code": "import sys\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nz = sum(a)\r\nif z % 2 == 0:\r\n s = 1\r\n for x in a:\r\n s |= s << x\r\n if s & (1 << (z // 2)):\r\n b = [x & -x for x in a]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i + 1}\")\r\n sys.exit()\r\nprint(0)"}, {"source_code": "# from typing import List, Set, Dict, Tuple, Text, Optional\nfrom collections import deque\nfrom types import GeneratorType\nimport os\nimport sys\nimport math\nimport heapq\nfrom atexit import register\nfrom io import BytesIO\nimport __pypy__ # type: ignore\n\n#########\n# INPUT #\n#########\n\n\nclass Input(object):\n def __init__(self):\n if 'CPH' not in os.environ:\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 def rawInput(self):\n # type: () -> str\n return sys.stdin.readline().rstrip('\\r\\n')\n\n def readInt(self):\n return int(self.rawInput())\n\n##########\n# OUTPUT #\n##########\n\n\nclass Output(object):\n def __init__(self):\n self.out = __pypy__.builders.StringBuilder()\n\n def write(self, text):\n # type: (str) -> None\n self.out.append(str(text))\n\n def writeLine(self, text):\n # type: (str) -> None\n self.write(str(text) + '\\n')\n\n def finalize(self):\n if sys.version_info[0] < 3:\n os.write(1, self.out.build())\n else:\n os.write(1, self.out.build().encode())\n\n###########\n# LIBRARY #\n###########\n\n\ndef bootstrap(f, stack=[]):\n # Deep Recursion helper.\n # From: https://github.com/cheran-senthil/PyRival/blob/c1972da95d102d95b9fea7c5c8e0474d61a54378/docs/bootstrap.rst\n # Usage:\n\n # @bootstrap\n # def recur(n):\n # if n == 0:\n # yield 1\n # yield (yield recur(n-1)) * n\n def wrappedfunc(*args, **kwargs):\n if stack:\n return f(*args, **kwargs)\n else:\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n else:\n stack.pop()\n if not stack:\n break\n to = stack[-1].send(to)\n return to\n\n return wrappedfunc\n\n\ndef KnapsackNoReplacementFind(items, target_sum):\n # type: (List[int], int) -> List[int]\n '''\n >>> KnapsackNoReplacementFind([1, 2, 3, 4], 5) in [[1, 2], [0, 3]]\n True\n >>> KnapsackNoReplacementFind([1, 2, 4, 8, 16], 19)\n [0, 1, 4]\n >>> KnapsackNoReplacementFind([2, 3, 4], 10) is None\n True\n '''\n mult = target_sum+1\n dp_table = [-2] * (mult * (len(items)+1))\n\n dp_table[0] = -1\n for i in range(len(items)):\n base = i*mult\n nex = (i+1)*mult\n for j in range(target_sum+1):\n dp_table[nex+j] = dp_table[base+j]\n for j in range(target_sum+1):\n if j+items[i] > target_sum:\n continue\n next_coord = nex + j + items[i]\n if dp_table[base+j] >= -1 and dp_table[next_coord] == -2:\n dp_table[next_coord] = i\n\n if dp_table[len(items) * mult + target_sum] == -2:\n return None\n\n used = []\n cursum = target_sum\n pos = len(items)\n while True:\n used_item = dp_table[pos*mult + cursum]\n\n if used_item == -1:\n break\n\n used.append(used_item)\n cursum -= items[used_item]\n pos = used_item\n\n used.reverse()\n\n return used\n\n\n#########\n# LOGIC #\n#########\n\n\ndef main(inp, out):\n # type: (Input, Output) -> any\n n = inp.readInt()\n nums = map(int, inp.rawInput().split())\n sum_all = sum(nums)\n if (sum_all % 2 == 1 or KnapsackNoReplacementFind(nums, sum_all//2) is None):\n out.writeLine(0)\n else:\n out.writeLine(1)\n\n while True:\n odds = filter(lambda x: nums[x] % 2, range(n))\n if len(odds):\n out.writeLine(odds[0]+1)\n break\n\n nums = map(lambda x: x / 2, nums)\n\n###############\n# BOILERPLATE #\n###############\n\n\noutput_obj = Output()\nmain(Input(), output_obj)\noutput_obj.finalize()\n"}, {"source_code": "import sys\r\nimport math\r\nfrom collections import defaultdict,Counter,deque\r\n\r\n# input=sys.stdin.readline\r\n# def print(x):\r\n# sys.stdout.write(str(x)+\"\\n\")\r\n\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\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\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# sys.stdout=open(\"CP3/output.txt\",'w')\r\n# sys.stdin=open(\"CP3/input.txt\",'r')\r\n\r\n# mod=pow(10,9)+7\r\n# t=int(input())\r\n# for i in range(t):\r\n# \tn,q=map(int,input().split())\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ns=0\r\nfor j in a:\r\n\ts+=j\r\nif s&1:\r\n\tprint(0)\r\n\tsys.exit()\r\ns//=2\r\ndp=[[0]*(s+1) for j in range(2)]\r\ndp[0][0]=dp[1][0]=1\r\nfor j in range(1,n+1):\r\n\tfor k in range(1,s+1):\r\n\t\tdp[j%2][k]=dp[1^(j%2)][k]\r\n\t\tif a[j-1]<=k:\r\n\t\t\tdp[j%2][k]|=dp[1^(j%2)][k-a[j-1]]\r\n\r\n\tif dp[j%2][s]==1:\r\n\t\tbreak\r\nelse:\r\n\tprint(0)\r\n\tsys.exit()\r\n\r\nprint(1)\r\ng=0\r\nfor j in range(n):\r\n\tg=math.gcd(g,a[j])\r\n\r\nfor j in range(n):\r\n\ta[j]//=g\r\n\tif a[j]&1:\r\n\t\tprint(j+1)\r\n\t\tbreak\r\n"}, {"source_code": "def exists(n,L):\n s=sum(L)\n\n dp=[(1+s//2)*[0] for i in range(n)]\n \n for x in range(s//2 +1):\n if x!=L[0]:\n dp[0][x]=False\n else:\n dp[0][x]=True\n for i in range(n-1):\n for x in range(s//2+1):\n if x>=L[i+1]:\n dp[i+1][x]=dp[i][x-L[i+1]] or dp[i][x]\n else:\n dp[i+1][x]=dp[i][x]\n l=False\n for i in range(n):\n l=l or dp[i][s//2]\n return l\n\ndef mini(n,L):\n s=sum(L)\n if s%2==1:\n return (0)\n if not exists(n,L):\n return(0)\n while True:\n for i in range(n):\n if L[i]%2==1:\n return(1,i+1)\n else:\n L[i]=L[i]//2\n \nn=int(input())\n\nL=[int(x) for x in input().split()]\n\n\nx=mini(n,L)\nif x==0:\n print(0)\nelse:\n print(x[0])\n print(x[1])"}, {"source_code": "import sys\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nz = sum(a)\r\nif z % 2 == 0:\r\n s = 1\r\n for x in a:\r\n s |= s << x\r\n if s & (1 << (z // 2)):\r\n b = [x & -x for x in a]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i + 1}\")\r\n sys.exit()\r\nprint(0)"}, {"source_code": "n = int(input())\r\narr = list(map(int, input().split()))\r\n\r\nif sum(arr) & 1:\r\n print(0)\r\nelse:\r\n even, odd = 0, 0\r\n for i in arr:\r\n if i & 1:\r\n odd += 1\r\n else:\r\n even += 1\r\n target = sum(arr) // 2\r\n n = len(arr)\r\n dp = [[False for i in range(target + 1)] for j in range(n + 1)]\r\n for i in range(n + 1):\r\n dp[i][0] = True\r\n for i in range(1, n + 1):\r\n for j in range(1, target + 1):\r\n if arr[i - 1] > j:\r\n dp[i][j] = dp[i - 1][j]\r\n else:\r\n dp[i][j] = dp[i - 1][j] or dp[i - 1][j - arr[i - 1]]\r\n if dp[n][target]:\r\n if odd:\r\n for i in range(len(arr)):\r\n if arr[i] & 1:\r\n print(1)\r\n print(i + 1)\r\n exit()\r\n else:\r\n min_index = 10 ** 9\r\n ans = -1\r\n for i in range(len(arr)):\r\n for j in range(32):\r\n if arr[i] & (1 << j):\r\n if j < min_index:\r\n min_index = min(min_index, j)\r\n ans = i + 1\r\n break\r\n print(1)\r\n print(ans)\r\n else:\r\n print(0)\r\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\ndef solve():\n n = int(input())\n arr = list(map(int, input().split()))\n S = sum(arr)\n if S % 2:\n print(0)\n return\n\n dp = [[False, 0, []] for _ in range(S+1)]\n dp[arr[-1]] = [True, 1, [n-1]]\n dp[0][0] = True\n\n for i in range(n-2, -1, -1):\n for s in range(S+1, 0, -1):\n if s - arr[i] >= 0 and dp[s-arr[i]][0]:\n if 1 + dp[s-arr[i]][1] > dp[s][1]:\n dp[s] = [True, 1 + dp[s-arr[i]][1], list(dp[s-arr[i]][2]) + [i]]\n if not dp[S//2][0]:\n print(0)\n else:\n ans = 0\n ansS = -1\n for s in range(1, S+1):\n if s % 2:\n if ans < dp[s][1]:\n ansS = s\n ans = dp[s][1]\n elif not dp[s // 2][0]:\n if ans < dp[s][1]:\n ansS = s\n ans = dp[s][1]\n\n print(n - ans)\n res = []\n bag = set(dp[ansS][2])\n for i in range(n):\n if i not in bag:\n res.append(i+1)\n print(*res)\n return\n\n\nsolve()\n"}, {"source_code": "import sys\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nz = sum(a)\r\nif z % 2 == 0:\r\n s = 1\r\n for x in a:\r\n s |= s << x\r\n if s & (1 << (z // 2)):\r\n b = [x & -x for x in a]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i + 1}\")\r\n sys.exit()\r\nprint(0)"}, {"source_code": "import sys\r\nimport sys\r\n \r\n# Returns the minimum value of the\r\n# difference of the two sets.\r\ndef findMin(S,n):\r\n \r\n # Find the sum of all elements\r\n total = sum(S)\r\n \r\n # Create a boolean table to store solutions to subproblems\r\n T = [[False] * (total + 1) for _ in range(len(S) + 1)]\r\n \r\n # Fill the lookup table in a bottom-up manner\r\n for i in range(len(S) + 1):\r\n \r\n # elements with zero-sum are always true\r\n T[i][0] = True\r\n \r\n j = 1\r\n while i > 0 and j <= total:\r\n \r\n # exclude the i'th element\r\n T[i][j] = T[i - 1][j]\r\n \r\n # include the i'th element\r\n if S[i - 1] <= j:\r\n T[i][j] |= T[i - 1][j - S[i - 1]]\r\n \r\n j = j + 1\r\n \r\n # Find the maximum value of `j` between 0 and `sum/2` for which the\r\n # last row is true\r\n j = total // 2\r\n while j >= 0 and not T[len(S)][j]:\r\n j = j - 1\r\n \r\n return total - 2*j\r\n \r\nn=int(input())\r\na = list(map(int,input().split()))\r\ncou=1\r\nc=a[0]\r\nfor i in range(1,n):\r\n if(a[i]==c):\r\n cou+=1\r\nif(sum(a)%2 !=0):\r\n print(0)\r\nelif(cou==n):\r\n if(cou%2 ==0):\r\n print(1)\r\n print(1)\r\n else:\r\n print(0)\r\nelse:\r\n if(findMin(a,n)>0):\r\n print(0)\r\n else:\r\n min=10000\r\n ans=-1\r\n \r\n for i in range(n):\r\n num=a[i]\r\n count=0\r\n while(num%2 ==0):\r\n num=num//2\r\n count+=1\r\n if(count < min):\r\n min=count\r\n ans=i\r\n print(1)\r\n print(ans+1)\r\n \r\n \r\n \r\n \r\n\r\n \r\n "}, {"source_code": "import sys\r\nimport math\r\nfrom collections import defaultdict,Counter,deque\r\n\r\n# input=sys.stdin.readline\r\n# def print(x):\r\n# sys.stdout.write(str(x)+\"\\n\")\r\n\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\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\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# sys.stdout=open(\"CP3/output.txt\",'w')\r\n# sys.stdin=open(\"CP3/input.txt\",'r')\r\n\r\n# mod=pow(10,9)+7\r\n# t=int(input())\r\n# for i in range(t):\r\n# \tn,q=map(int,input().split())\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ns=0\r\nfor j in a:\r\n\ts+=j\r\nif s&1:\r\n\tprint(0)\r\n\tsys.exit()\r\ns//=2\r\ndp=[0]*(s+1)\r\ndp[0]=1\r\nfor j in range(n):\r\n\tfor k in range(s,0,-1):\r\n\t\tif a[j]<=k:\r\n\t\t\tdp[k]|=dp[k-a[j]]\r\n\r\n\tif dp[s]==1:\r\n\t\tbreak\r\nelse:\r\n\tprint(0)\r\n\tsys.exit()\r\n\r\nprint(1)\r\ng=0\r\nfor j in range(n):\r\n\tg=math.gcd(g,a[j])\r\n\r\nfor j in range(n):\r\n\ta[j]//=g\r\n\tif a[j]&1:\r\n\t\tprint(j+1)\r\n\t\tbreak\r\n"}, {"source_code": "from functools import lru_cache\n\t\ndef gcd(a,b):\n\tif b==0:\n\t\treturn(a)\n\treturn(gcd(b,a%b))\n\n@lru_cache(None)\ndef subsetSum(curSum,totalSum,idx,array):\n\n\tif idx>=len(array):\n\t\treturn(False)\n\n\tif totalSum==2*curSum:\n\t\treturn(True)\n\n\tif 2*curSum>totalSum:\n\t\treturn(False)\n\twithVal=subsetSum(curSum+array[idx],totalSum,idx+1,array)\n\tif withVal:\n\t\treturn(True)\t\n\twithOutVal=subsetSum(curSum,totalSum,idx+1,array)\n\n\treturn(withOutVal)\n\n\nn=int(input())\narray=tuple(map(int,input().split()))\ntotalSum=sum(array)\n\nif totalSum%2!=0 or not subsetSum(0,totalSum,0,array):\n\tprint(0)\n\nelse:\n\tfor idx,val in enumerate(array):\n\t\tif val%2!=0:\n\t\t\tprint(1)\n\t\t\tprint(idx+1)\n\t\t\tbreak\n\telse:\n\t\tansIdx=0\n\t\tansCount=float('inf')\n\t\tfor idx,val in enumerate(array):\n\t\t\tcount=0\n\t\t\twhile val%2==0:\n\t\t\t\tcount+=1\n\t\t\t\tval=val/2\n\t\t\tif count= set[i-1]:\r\n subset[i][j] = (subset[i-1][j] or\r\n subset[i - 1][j-set[i-1]])\r\n\r\n\r\n return subset[n][s]\r\ndef check(a,flag = 0):\r\n for i in a:\r\n if i%2:\r\n if not flag:\r\n return False\r\n else:\r\n return a.index(i)\r\n return True\r\nn = int(input())\r\na = list(map(int,input().split(' ')))\r\naTemp = [i for i in a]\r\nif not func(n,a):\r\n print(0)\r\nelse:\r\n while (check(aTemp)):\r\n aTemp = [i//2 for i in aTemp]\r\n print(1)\r\n print(check(aTemp,1)+1)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\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\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: 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\ndef check(a,k):\r\n s=set([0])\r\n for i in range (len(a)):\r\n s1=set()\r\n for j in s:\r\n s1.add(a[i]+j)\r\n s=s.union(s1)\r\n if k in s:\r\n return True\r\n return False\r\n\r\nfor _ in range (1):\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n s=sum(a)\r\n d=defaultdict(int)\r\n for i in a:\r\n d[i]+=1\r\n mnd,mxd=min(d.values()),max(d.values())\r\n occ=0\r\n if s%2:\r\n print(0)\r\n continue\r\n if check(a,s//2)==False:\r\n print(0)\r\n continue\r\n mn,mx=min(a),max(a)\r\n m,o=0,0\r\n i1,i2,i3,i4=[0]*4\r\n for i in range (n):\r\n if a[i]%2:\r\n o=i+1\r\n elif (a[i]//2)%2:\r\n m=i+1\r\n if a[i]==mn:\r\n i1=i+1\r\n if a[i]==mx:\r\n i2=i+1\r\n if a[i]==mnd:\r\n i3=i+1\r\n if a[i]==mxd:\r\n i4=i+1\r\n print(1)\r\n if o:\r\n print(o)\r\n elif m:\r\n print(m)\r\n else:\r\n if check(list(a[:i1-1]+a[i1:]),(s-mn)//2)==False:\r\n print(i1)\r\n elif check(list(a[:i2-1]+a[i2:]),(s-mx)//2)==False:\r\n print(i2)\r\n elif check(list(a[:i3-1]+a[i3:]),(s-mnd)//2)==False:\r\n print(i3)\r\n elif check(list(a[:i4-1]+a[i4:]),(s-mxd)//2)==False:\r\n print(i4)\r\n "}, {"source_code": "import os,sys,math \r\nfrom io import BytesIO, IOBase\r\nfrom collections import defaultdict,deque,OrderedDict\r\nimport bisect as bi\r\ndef yes():print('YES')\r\ndef no():print('NO')\r\ndef I():return (int(input()))\r\ndef In():return(map(int,input().split()))\r\ndef ln():return list(map(int,input().split()))\r\ndef Sn():return input().strip()\r\nBUFSIZE = 8192\r\n#complete the main function with number of test cases to complete greater than x\r\ndef find_gt(a, x):\r\n i = bi.bisect_left(a, x)\r\n if i != len(a):\r\n return i\r\n else: \r\n return len(a)\r\ndef CountTrailingZeros(n):\r\n \r\n bit = bin(n)[2:]\r\n bit = bit[::-1]\r\n zero = 0;\r\n for i in range(len(bit)):\r\n if (bit[i] == '0'):\r\n zero += 1\r\n else:\r\n break\r\n \r\n return zero\r\ndef solve():\r\n Max=2000*100\r\n dp=[False]*(Max+1)\r\n n=I()\r\n dp[0]=True\r\n l=list(In())\r\n total=0\r\n for x in l:\r\n total+=x\r\n for j in range(len(dp)-x-1,-1,-1):\r\n if not dp[j]:continue\r\n dp[j+x]=True\r\n\r\n if (not dp[total//2]) or (total%2!=0):\r\n print(0)\r\n return\r\n trail=31\r\n for x in l:\r\n trail=min(trail,CountTrailingZeros(x))\r\n ans=-2\r\n for i in range(n):\r\n if l[i]%(1< pref[i - 1]:\r\n break\r\n if j - arr[i - 1] >= 0:\r\n dp[i][j] = dp[i - 1][j - arr[i - 1]]|dp[i - 1][j]\r\n\r\ns = sum(arr)\r\nif s % 2 or not dp[n][s//2]:\r\n print(0)\r\nelse:\r\n for index,i in enumerate(arr):\r\n if i % 2:\r\n print(1)\r\n print(index + 1)\r\n exit()\r\n while True:\r\n for i in range(n):\r\n arr[i] = arr[i]//2\r\n if arr[i]%2:\r\n print(1)\r\n print(i + 1)\r\n exit()\r\n"}, {"source_code": "import sys,math,bisect\n\ninf = float('inf')\nmod = (10**9)+7\n\n\"==========================\"\ndef lcm(a,b):\n return int((a/math.gcd(a,b))*b)\ndef gcd(a,b):\n return int(math.gcd(a,b))\ndef tobinary(n):\n return bin(n)[2:]\ndef binarySearch(a,x):\n i = bisect.bisect_left(a,x)\n if i!=len(a) and a[i]==x:\n return i\n else:\n return -1\ndef lowerBound(a, x):\n i = bisect.bisect_left(a, x)\n if i:\n return (i-1)\n else:\n return -1\ndef upperBound(a,x):\n i = bisect.bisect_right(a,x)\n if i!= len(a)+1 and a[i-1]==x:\n return (i-1)\n else:\n return -1\ndef primesInRange(n):\n ans = []\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 for p in range(2, n+1):\n if prime[p]:\n ans.append(p)\n return ans\ndef primeFactors(n):\n factors = []\n while n % 2 == 0:\n factors.append(2)\n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2):\n while n % i== 0:\n factors.append(i)\n n = n // i\n if n > 2:\n factors.append(n)\n return factors\n\"============================\"\n\"\"\"\nn = int(input())\nn,k = map(int,input().split())\narr = list(map(int,input().split()))\n\"\"\"\nfrom collections import deque,defaultdict,Counter\nimport heapq\n\ndef isSubsetSum(set, n, sum):\n subset =([[False for i in range(sum + 1)]\n for i in range(n + 1)])\n for i in range(n + 1):\n subset[i][0] = True\n for i in range(1, sum + 1):\n subset[0][i]= False\n for i in range(1, n + 1):\n for j in range(1, sum + 1):\n if j= set[i-1]:\n subset[i][j] = (subset[i-1][j] or\n subset[i - 1][j-set[i-1]])\n return subset[n][sum]\n\nfor _ in range(1):\n n = int(input())\n arr = list(map(int,input().split()))\n x= sum(arr)//2\n if sum(arr)%2==1 or not isSubsetSum(arr,n,x):\n print(0)\n else:\n flag=True\n for i in range(n):\n if arr[i]%2==1:\n print(1)\n print(i+1)\n flag=False\n break\n while flag:\n for i in range(n):\n arr[i]=arr[i]//2\n if arr[i]%2==1:\n print(1)\n print(i+1)\n flag=False\n break\n"}, {"source_code": "#Don't stalk me, don't stop me, from making submissions at high speed. If you don't trust me,\r\nimport sys\r\n#then trust me, don't waste your time not trusting me. I don't plagiarise, don't fantasize,\r\nimport os\r\n#just let my hard work synthesize my rating. Don't be sad, just try again, everyone fails\r\nfrom io import BytesIO, IOBase\r\nBUFSIZE = 8192\r\n#every now and then. Just keep coding, just keep working and you'll keep progressing at speed-\r\n# -forcing.\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\n#code by _Frust(CF)/Frust(AtCoder)\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\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 input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nimport math\r\nimport heapq as hq\r\n\r\n\r\ndef checker(dp, nums):\r\n for i in range(n):\r\n for j in range(r, -1, -1):\r\n if dp[j]==1 and j+l1[i]<=r:\r\n dp[j+l1[i]]=1\r\n\r\n if dp[r]==1:\r\n return True\r\n else:\r\n return False\r\n\r\n\r\n\r\nn=int(input())\r\nl1=[int(i) for i in input().split()]\r\n\r\ns=sum(l1)\r\nif s&1:\r\n print(0)\r\nelse:\r\n r=s//2\r\n dp=[0 for i in range(r + 1)]\r\n dp[0]=1\r\n # print(r)\r\n\r\n if not checker(dp, l1):\r\n print(0)\r\n else:\r\n found=0\r\n for i in range(n):\r\n if l1[i]&1:\r\n found=1\r\n print(1)\r\n print(i+1)\r\n break\r\n if found==0:\r\n d1={}\r\n for i in l1:\r\n d1[i]=d1.get(i, 0)+1\r\n rnum=-1\r\n for i in range(r, -1, -1):\r\n if dp[i]==0 and 2*(r-i) in d1:\r\n rnum=2*(r-i)\r\n break\r\n # print(dp)\r\n\r\n for i in range(n):\r\n if l1[i]==rnum:\r\n print(1)\r\n print(i+1)\r\n break\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "n = int(input())\r\na = [int(i) for i in input().split()]\r\nsm = sum(a)\r\n#print(sorted(a))\r\n#print(sm)\r\nif sm % 2==1:\r\n print(0)\r\nelse:\r\n target = sm // 2\r\n dp =[[0 for j in range(target + 1)] for i in range(n+1)]\r\n dp[0][0] = 1\r\n x =[]\r\n c ={0:[]}\r\n boo = True\r\n for i in range(1,n+1):\r\n for j in range(target):\r\n if dp[i-1][j]:\r\n dp[i][j] = 1\r\n if(j+a[i-1] <= target):\r\n dp[i][j+a[i-1]] = 1\r\n if(j+a[i-1] == target):\r\n k, l = i , j+a[i-1]\r\n temp = []\r\n while(l > 0 and k > 0):\r\n if(dp[k][l]):\r\n temp += [k-1]\r\n l -= a[k-1]\r\n k -= 1\r\n \r\n else:\r\n k -= 1\r\n x += [temp]\r\n break\r\n if(x):\r\n break\r\n \r\n #x = dp[-1][-1][-1]\r\n if(len(x)==0):\r\n print(0)\r\n exit()\r\n temp = []\r\n #print(x)\r\n for i in range(n):\r\n if i not in x[0]:\r\n temp += [i]\r\n x += [temp]\r\n exp = 0\r\n while(boo):\r\n for i in range(2):\r\n for j in range(len(x[i])):\r\n if a[x[i][j]]%2:\r\n print(1)\r\n print(x[i][j]+1)\r\n boo = False\r\n break\r\n a[x[i][j]] /= 2\r\n if not boo:\r\n break\r\n exp += 1\r\n \r\n \r\n \r\n \r\n \r\n"}, {"source_code": "def partition(arr,n):\r\n s=sum(arr)//2\r\n if sum(arr)%2 !=0:\r\n return False\r\n else:\r\n dp=[[False for j in range(s+1)] for i in range(n+1)]\r\n for i in range(n+1):\r\n for j in range(s+1):\r\n if i==0:\r\n dp[i][j]=False\r\n if j==0:\r\n dp[i][j]=True\r\n elif j>=arr[i-1]:\r\n dp[i][j]=dp[i-1][j-arr[i-1]] or dp[i-1][j]\r\n else:\r\n dp[i][j]=dp[i-1][j]\r\n return dp[n][s]\r\ndef solve(arr,n):\r\n count=0\r\n for i in range(n):\r\n if arr[i]%2:\r\n count+=1\r\n print(count)\r\n print(i+1)\r\n return\r\n\r\n # print(count)\r\n f=0\r\n while f!=1:\r\n\r\n for k in range(n):\r\n arr[k]=arr[k]//2\r\n\r\n if arr[k]%2:\r\n print(1)\r\n print(k+1)\r\n f=1\r\n return\r\n\r\n\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\nres=(partition(arr,n))\r\ncount=0\r\nif res==False:\r\n print(0)\r\nelse:\r\n (solve(arr,n))\r\n\r\n"}, {"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\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\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\ndef prod(a, mod=10**9+7):\r\n\tans = 1\r\n\tfor each in a:\r\n\t\tans = (ans * each) % mod\r\n\treturn ans\r\n\r\ndef gcd(x, y):\r\n\twhile y:\r\n\t\tx, y = y, x % y\r\n\treturn x\r\n\r\ndef lcm(a, b): return a * b // gcd(a, b)\r\n\r\ndef binary(x, length=16):\r\n\ty = bin(x)[2:]\r\n\treturn y if len(y) >= length else \"0\" * (length - len(y)) + y\r\n\r\nfor _ in range(int(input()) if not True else 1):\r\n\tn = int(input())\r\n\t#n, k = map(int, input().split())\r\n\t#a, b = map(int, input().split())\r\n\t#c, d = map(int, input().split())\r\n\ta = list(map(int, input().split()))\r\n\t#b = list(map(int, input().split()))\r\n\t#s = input()\r\n\tdef f(n, a):\r\n\t\ttotal = sum(a)\r\n\t\tif total % 2:\r\n\t\t\tprint(0)\r\n\t\t\tquit()\r\n\t\t\t\r\n\t\t\r\n\t\tdp = [[0]*(2*10**5 + 1) for ___ in range(101)]\r\n\t\tfor i in range(n+1):\r\n\t\t\tdp[i][0] = 1\r\n\r\n\t\tfor i in range(1,n+1):\r\n\t\t\tfor j in range(1, total+1):\r\n\t\t\t\tdp[i][j] = dp[i-1][j]\r\n\t\t\t\tif a[i-1] <= j:\r\n\t\t\t\t\tdp[i][j] = max(dp[i][j], dp[i-1][j-a[i-1]])\r\n\r\n\t\tx = 0\r\n\t\tfor k in range(total//2, -1, -1):\r\n\t\t\tif dp[n][k]:\r\n\t\t\t\tx = total - 2*k\r\n\t\t\t\tbreak\r\n\t\tif x:\r\n\t\t\tprint(0)\r\n\t\t\tquit()\r\n\t\tfor i in range(n):\r\n\t\t\tif a[i] % 2 or not dp[n][(total - a[i]) // 2]:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\tquit()\r\n\tf(n, a)\r\n\r\n\r\n"}, {"source_code": "'''Author- Akshit Monga'''\r\nfrom sys import stdin, stdout\r\ninput = stdin.readline\r\n\r\ndef findPartiion(arr, n):\r\n Sum = 0\r\n for i in range(n):\r\n Sum += arr[i]\r\n if (Sum % 2 != 0):\r\n return 0\r\n part = [0] * ((Sum // 2) + 1)\r\n for i in range((Sum // 2) + 1):\r\n part[i] = 0\r\n for i in range(n):\r\n for j in range(Sum // 2, arr[i] - 1, -1):\r\n if (part[j - arr[i]] == 1 or j == arr[i]):\r\n part[j] = 1\r\n\r\n return part[Sum // 2]\r\n\r\nt = 1\r\nfor _ in range(t):\r\n n=int(input())\r\n a=[int(x) for x in input().split()]\r\n if sum(a)%2:\r\n print(0)\r\n continue\r\n if not findPartiion(a,n):\r\n print(0)\r\n continue\r\n l=0\r\n r=n-1\r\n while l<=r:\r\n vals = a[::]\r\n i=l\r\n del vals[i]\r\n if not findPartiion(vals, n - 1):\r\n print(1)\r\n print(i + 1)\r\n break\r\n vals = a[::]\r\n i=r\r\n del vals[i]\r\n if not findPartiion(vals, n - 1):\r\n print(1)\r\n print(i + 1)\r\n break\r\n l+=1\r\n r-=1\r\n else:\r\n assert 1==2"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\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\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\ninp = lambda dtype: dtype(input().strip())\r\ninp_d = lambda dtype: [dtype(x) for x in input().split()]\r\ninp_2d = lambda dtype, n: [inp(dtype) for _ in range(n)]\r\ninp_2ds = lambda dtype, n: [inp_d(dtype) for _ in range(n)]\r\ninp_enu = lambda dtype: [(i, x) for i, x in enumerate(inp_d(dtype))]\r\ninp_enus = lambda dtype, n: [[i, inp_d(dtype)] for i in range(n)]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nlsone = lambda x: x & (-x)\r\n\r\nn, a = inp(int), inp_d(int)\r\nmem, su = [False] * (10 ** 5 + 1), sum(a)\r\nmem[0] = True\r\n\r\nfor i in range(n):\r\n for j in range(10 ** 5 - a[i], -1, -1):\r\n mem[a[i] + j] |= mem[j]\r\n mem[a[i]] = True\r\n \r\nif su & 1 or not mem[su >> 1]:\r\n print(0)\r\nelse:\r\n print(1, a.index(min(a, key=lambda x: lsone(x))) + 1, sep='\\n')\r\n"}, {"source_code": "import math\r\nimport sys\r\nimport collections\r\nimport bisect\r\nimport time\r\nimport random\r\nfrom itertools import permutations\r\ndef get_ints():return map(int, sys.stdin.readline().strip().split())\r\ndef get_list():return list(map(int, sys.stdin.readline().strip().split()))\r\ndef get_string():return sys.stdin.readline().strip()\r\n\r\n\r\ndef findPartition(arr, n):\r\n\tSum = 0\r\n\tfor i in range(n):\r\n\t\tSum += arr[i]\r\n\tif (Sum % 2 != 0):\r\n\t\treturn 0\r\n\tpart = [0] * ((Sum // 2) + 1)\r\n\tfor i in range((Sum // 2) + 1):\r\n\t\tpart[i] = 0\r\n\tfor i in range(n):\r\n\t\tfor j in range(Sum // 2, arr[i] - 1, -1):\r\n\t\t\tif (part[j - arr[i]] == 1 or j == arr[i]):\r\n\t\t\t\tpart[j] = 1\r\n\treturn part[Sum // 2]\r\nfor t in range(1):\r\n\tn=int(input())\r\n\tarr=get_list()\r\n\tif findPartition(arr, n) == False:\r\n\t\tprint(0)\r\n\t\tcontinue\r\n\tp=0\r\n\tfor i in range(n):\r\n\t\tif arr[i]%2==1:\r\n\t\t\tprint(1)\r\n\t\t\tprint(i+1)\r\n\t\t\tp+=1\r\n\t\t\tbreak\r\n\tif p>0:\r\n\t\tcontinue\r\n\tfor i in range(n):\r\n\t\ttemp=arr[:i]+arr[i+1:]\r\n\t\tif findPartition(temp, n-1) == False:\r\n\t\t\tprint(1)\r\n\t\t\tprint(i+1)\r\n\t\t\tbreak"}, {"source_code": "n=input()\r\na=map(int,raw_input().split())\r\nsm=sum(a)\r\nif sm%2==1:\r\n print 0\r\nelse:\r\n dp=[0 for i in range(sm/2+1)]\r\n dp[0]=1\r\n op=sm/2\r\n for i in range(n):\r\n store=[]\r\n for j in range(op+1):\r\n if dp[j]==1:\r\n if j+a[i]<=op:\r\n if dp[j+a[i]]==0:\r\n store.append(j+a[i])\r\n for j in store:\r\n dp[j]=1\r\n if dp[-1]==0:\r\n print 0\r\n else:\r\n mx=1000\r\n ind=-1\r\n g=1\r\n for i in a:\r\n k=i\r\n cnt=0\r\n while k%2==0:\r\n cnt+=1\r\n k/=2\r\n if cnt= 0 and dp[s-arr[i]][0]:\n if 1 + dp[s-arr[i]][1] > dp[s][1]:\n dp[s] = [True, 1 + dp[s-arr[i]][1], list(dp[s-arr[i]][2]) + [i]]\n if not dp[S//2][0]:\n print(0)\n else:\n ans = 0\n ansS = -1\n for s in range(1, S+1):\n if s % 2:\n if ans < dp[s][1]:\n ansS = s\n ans = dp[s][1]\n elif not dp[s // 2][0]:\n if ans < dp[s][1]:\n ansS = s\n ans = dp[s][1]\n\n print(n - ans)\n res = []\n bag = set(dp[ansS][2])\n for i in range(n):\n if i not in bag:\n res.append(i+1)\n print(*res)\n return\n\n\nsolve()\n"}, {"source_code": "def possible(nums,target):\r\n reach = {0}\r\n for num in nums:\r\n reach |= {i+num for i in reach if i+num <= target}\r\n if target in reach:\r\n return True\r\n return False\r\nn = int(input())\r\narr = list(map(int,input().split()))\r\ns = sum(arr)\r\n\r\nif s%2==1 or not possible(arr,s//2):\r\n print(0)\r\nelse:\r\n print(1)\r\n mi = 100\r\n res = -1\r\n for i in range(n):\r\n A = arr[i] & (-arr[i])\r\n cnt = 0\r\n while A :\r\n cnt += 1\r\n A >>= 1\r\n if cnt < mi:\r\n mi = cnt\r\n res = i+1\r\n print(res)\r\n\r\n"}, {"source_code": "n=int(input())\r\n # n,k=map(int,input().split())\r\nl=list(map(int,input().split()))\r\nf=0\r\nif sum(l)%2!=0:\r\n print(0)\r\n f=1\r\n # continue\r\nif f==0:\r\n s=sum(l)//2 \r\n dp=[[False for _ in range(s+1)] for _ in range(n+1)]\r\n for i in range(n+1):\r\n dp[i][0]=True\r\n for i in range(1,n+1):\r\n for j in range(1,s+1):\r\n if l[i-1]<=j:\r\n dp[i][j]=dp[i-1][j] | dp[i-1][j-l[i-1]]\r\n else:\r\n dp[i][j]=dp[i-1][j] \r\n f=0\r\n if dp[n][s]==True:\r\n for i in range(12): \r\n for i in range(n):\r\n if l[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n f=1\r\n break\r\n l[i]//=2\r\n if f==1:\r\n break \r\n \r\n # if f==0:\r\n # for i in range(n):\r\n # if l[i]%4==1:\r\n # print(1)\r\n # print(i+1)\r\n # f=1\r\n # break\r\n\r\n else:\r\n print(\"0\") "}, {"source_code": "def findsubarr(s,n,e):\r\n if(n==1):\r\n return {0,e}\r\n else:\r\n p=list(findsubarr(s,n-1,a[n-2]))\r\n q=set()\r\n for x in range(len(p)):\r\n sum1=p[x]+0\r\n sum2=p[x]+e\r\n if(sum1<=s):\r\n q.add(sum1)\r\n if(sum2<=s):\r\n q.add(sum2)\r\n return q\r\n\r\n\r\nn=int(input())\r\na=list(map(int,input().split()))\r\nq=min(a)\r\ns=sum(a)\r\np=1\r\n\r\nif(s%2==0):\r\n if(s/2 in findsubarr(int(s/2),n,a[n-1]))==False:\r\n print(0)\r\n exit()\r\n\r\nwhile(True):\r\n t=pow(2,p)\r\n if(s%t!=0):\r\n print(0)\r\n exit()\r\n else:\r\n for x in range(n):\r\n if(a[x]%t!=0):\r\n print(1)\r\n print(x+1)\r\n exit()\r\n p=p+1\r\n"}, {"source_code": "import math\r\ndef calc(arr):\r\n\tgc=arr[0]\r\n\tfor i in range(1,len(arr)):\r\n\t\tgc=math.gcd(gc,arr[i])\r\n\treturn gc\r\ndef check(arr):\r\n n=sum(arr)//2\r\n dp=[0 for i in range(sum(arr)+4)]\r\n dp[0]=1 # it check whether the given array\r\n for i in arr:\r\n for j in range(len(dp)-1,-1,-1):\r\n if dp[j]==1:\r\n dp[i+j]=1\r\n if i+j==n:\r\n return True\r\n if dp[n]==1:\r\n return True\r\n return False\r\nn=int(input())\r\narr=list(map(int,input().split()))\r\ngc=calc(arr)\r\nif sum(arr)%2==0:\r\n\tif (check(arr) == False):\r\n\t\tprint(0)\r\n\telse:\r\n\t\tflag=0\r\n\t\tfor i in range(n):\r\n\t\t\tif arr[i]%2==1:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\tflag=1\r\n\t\t\t\tbreak\r\n\t\tif flag==0:\r\n\t\t\tfor i in range(n):\r\n\t\t\t\tif (arr[i]//gc)%2==1:\r\n\t\t\t\t\tprint(1)\r\n\t\t\t\t\tprint(i+1)\r\n\t\t\t\t\tbreak\r\nelse:\r\n\tprint(0)\r\n"}, {"source_code": "n = int(input())\r\na = list(map(int, input().split()))\r\ns = sum(a)\r\n\r\nif s & 1:\r\n print(0)\r\n exit()\r\n\r\nh = s//2\r\nk = [False]*(s+1)\r\nk[0] = True\r\nfor i in a:\r\n for j in range(s, -1, -1):\r\n if k[j]:\r\n k[j+i] = True\r\n\r\nif k[h]:\r\n res = None\r\n m = float(\"inf\")\r\n for i in range(n):\r\n if a[i] & 1:\r\n res = i+1\r\n break\r\n else:\r\n temp = 0\r\n while a[i] % 2 == 0:\r\n a[i] //= 2\r\n temp += 1\r\n if temp < m:\r\n m = temp\r\n res = i+1\r\n print(1)\r\n print(res)\r\n\r\nelse:\r\n print(0)\r\n"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\ndef subset_sum(a, n, k):\r\n k += 1\r\n dp = [[True]*k for i in range(n)]\r\n for y in range(n):\r\n for x in range(1, k):\r\n if y == 0:\r\n dp[y][x] = x == a[y]\r\n elif x - a[y] < 0:\r\n dp[y][x] = dp[y-1][x]\r\n elif dp[y-1][x] == True:\r\n dp[y][x] = True\r\n else:\r\n dp[y][x] = dp[y-1][x-a[y]]\r\n return dp[-1][-1]\r\n\r\ndef solve(n, a):\r\n s = sum(a)\r\n if s % 2 > 0:\r\n print(0)\r\n return\r\n if not(subset_sum(a, n, s // 2)):\r\n print(0)\r\n return\r\n for i in range(n):\r\n if a[i] % 2 > 0:\r\n print(1)\r\n print(i+1)\r\n return\r\n m = float(\"inf\")\r\n for i in range(n):\r\n j = 0\r\n while a[i] >> j & 1 == 0:\r\n j += 1\r\n if j < m:\r\n m = j\r\n ans = i+1\r\n print(1)\r\n print(ans)\r\n\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nsolve(n, a)"}, {"source_code": "import sys\r\nn = int(input())\r\na = [int(x) for x in input().split()]\r\nz = sum(a)\r\nif z % 2 == 0:\r\n s = 1\r\n for x in a:\r\n s |= s << x\r\n if s & (1 << (z // 2)):\r\n b = [x & -x for x in a]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i + 1}\")\r\n sys.exit()\r\nprint(0)"}, {"source_code": "import sys\r\nsys.setrecursionlimit(int(1e4))\r\ndef alreadygood(ind, sm):\r\n dp = [[False for i in range(300001)] for j in range(n + 1)]\r\n for i in range(300001):\r\n if i == s - i:\r\n dp[n - 1][i] = True\r\n for ind in range(n - 2, -1, -1):\r\n for sm in range(s - 1, -1, -1):\r\n dp[ind][sm] = dp[ind + 1][sm] | dp[ind + 1][sm + lis[ind]]\r\n return dp[0][0]\r\n\r\nimport sys, math ; input = lambda :sys.stdin.readline().rstrip()\r\nI=lambda:[*map(int,input().split())]\r\nn, = I()\r\nlis = I()\r\ndp = dict()\r\ns = sum(lis)\r\nif sum(lis) & 1:\r\n print(0)\r\n exit()\r\nelse:\r\n a = alreadygood(0, 0)\r\n if not a:\r\n print(0)\r\n exit()\r\n odd = False\r\n for i, j in enumerate(lis):\r\n if j & 1:\r\n print(1)\r\n print(i + 1)\r\n odd = True\r\n exit()\r\n if odd == False:\r\n if not a:\r\n print(0)\r\n else:\r\n mn = 1 << 69 ; ind = None\r\n for i in range(n):\r\n val = math.log2(lis[i]&-lis[i])+1\r\n if val < mn:\r\n mn = val ; ind = i\r\n print(1)\r\n print(ind + 1)"}], "negative_code": [{"source_code": "import sys, threading\r\nimport math\r\nfrom os import path\r\nfrom collections import defaultdict, Counter, deque\r\nfrom bisect import *\r\nfrom string import ascii_lowercase\r\nfrom functools import cmp_to_key\r\nimport heapq\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\nMAXN = 1123456\r\nMOD = 10**9 + 7\r\n\r\n\r\nclass mydict:\r\n def __init__(self, func):\r\n self.random = randint(0, 1 << 32)\r\n self.default = func\r\n self.dict = {}\r\n \r\n def __getitem__(self, key):\r\n mykey = self.random ^ key\r\n if mykey not in self.dict:\r\n self.dict[mykey] = self.default()\r\n return self.dict[mykey]\r\n \r\n def get(self, key, default):\r\n mykey = self.random ^ key\r\n if mykey not in self.dict:\r\n return default\r\n return self.dict[mykey]\r\n \r\n def __setitem__(self, key, item):\r\n mykey = self.random ^ key\r\n self.dict[mykey] = item\r\n \r\n def getkeys(self):\r\n return [self.random ^ i for i in self.dict]\r\n \r\n def __str__(self):\r\n return f'{[(self.random ^ i, self.dict[i]) for i in self.dict]}'\r\n\r\n \r\ndef lcm(a, b):\r\n return (a*b)//(math.gcd(a,b))\r\n \r\n \r\ndef mod(n):\r\n return n%MOD\r\n\r\n\r\ndef fls():\r\n sys.stdout.flush()\r\n\r\n\r\ndp = []\r\ndef helper(ar, ind, cur):\r\n\r\n global dp\r\n # print(ind, sm-cur)\r\n if cur == 0:\r\n dp[cur] = True\r\n return True\r\n\r\n if ind >= len(ar):\r\n return False\r\n\r\n if cur < 0:\r\n return False\r\n\r\n if not dp[cur] is None:\r\n return dp[cur]\r\n\r\n b1 = b2 = False\r\n b1 = helper(ar, ind+1, cur)\r\n b2 = helper(ar, ind+1, cur-ar[ind])\r\n dp[cur] = b1 or b2\r\n return dp[cur]\r\n\r\n\r\ndef solve(t):\r\n # print(f'Case #{t}: ', end = '')\r\n n = readInts()\r\n ar = readList()\r\n sm = sum(ar)\r\n if sm&1:\r\n print(0)\r\n return\r\n\r\n global dp\r\n dp = [None for _ in range(sm+1)]\r\n helper(ar, 0, sm//2)\r\n if not dp[sm//2]:\r\n print(0)\r\n return\r\n \r\n for i in range(n):\r\n if ar[i]&1:\r\n print(1)\r\n print(i+1)\r\n return\r\n\r\n\r\n for i in range(n):\r\n nar = ar[:i] + ar[i+1:]\r\n dp = [None for _ in range(sm+1)]\r\n if not helper(nar, 0, sum(nar)//2):\r\n print(1)\r\n print(i+1)\r\n return\r\n\r\n print(n-1)\r\n\r\n\r\n\r\n\r\ndef main():\r\n t = 1\r\n if path.exists(\"F:/Comp Programming/input.txt\"):\r\n sys.stdin = open(\"F:/Comp Programming/input.txt\", 'r')\r\n sys.stdout = open(\"F:/Comp Programming/output1.txt\", 'w')\r\n # sys.setrecursionlimit(10**5)\r\n # t = readInts()\r\n for i in range(t):\r\n solve(i+1)\r\n \r\n \r\nif __name__ == '__main__':\r\n main() "}, {"source_code": "n = int(input())\r\na = list(map(int, input().split()))\r\ns = sum(a)\r\n\r\nif s & 1:\r\n print(0)\r\n exit()\r\n\r\nh = s//2\r\nk = [False]*(s+1)\r\nk[0] = True\r\nfor i in a:\r\n for j in range(s, -1, -1):\r\n if k[j]:\r\n k[j+i] = True\r\n\r\nif k[h]:\r\n res = None\r\n m = float(\"inf\")\r\n for i in range(n):\r\n if a[i] & 1:\r\n res = i+1\r\n break\r\n else:\r\n temp = 0\r\n while a[i] % 2 == 0:\r\n a[i] //= 2\r\n temp += 1\r\n if temp < m:\r\n m = temp\r\n res = i\r\n print(1)\r\n print(res)\r\n\r\nelse:\r\n print(0)\r\n"}, {"source_code": "n = int(input())\r\na = [int(i) for i in input().split()]\r\nsm = sum(a)\r\nif sm % 2==1:\r\n print(0)\r\nelse:\r\n target = sm // 2\r\n dp =[[[0,[]] for j in range(target + 1)] for i in range(n+1)]\r\n dp[0][0] = [1,[]]\r\n x =[]\r\n for i in range(1,n+1):\r\n for j in range(target):\r\n if dp[i-1][j][0]:\r\n dp[i][j] = dp[i-1][j]\r\n if(j+a[i-1] < target):\r\n dp[i][j+a[i-1]] = [1,dp[i-1][j][1] + [a[i-1]]]\r\n if(j+a[i-1] == target):\r\n x += [dp[i-1][j][1] + [a[i-1]]]\r\n #x = dp[-1][-1][-1]\r\n print(1)\r\n print(a.index(x[0][0])+1)\r\n"}, {"source_code": "\"\"\"**************************************************************\\\r\n BISMILLAHIR RAHMANIR RAHIM\r\n****************************************************************\r\n AUTHOR NAME: MD. TAHURUZZOHA TUHIN\r\n\\**************************************************************\"\"\"\r\n\r\n\r\n\r\n\r\n\r\n#!/usr/bin/env python\r\nfrom __future__ import division, print_function\r\n\r\nimport os\r\nimport sys\r\nimport math\r\nfrom io import BytesIO, IOBase\r\nfrom heapq import heappush,heappop,heapify\r\nfrom collections import defaultdict, Counter, deque\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\n\r\n# Start FASTIO\r\nBUFSIZE = 8192\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 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\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\ndef check_freq(x):\r\n freq = {}\r\n for c in set(x):\r\n freq[c] = x.count(c)\r\n return freq\r\n \r\n\r\ndef ii(): return int(input())\r\ndef si(): return input()\r\ndef mi(): return map(int, input().strip().split(\" \"))\r\ndef li(): return list(mi())\r\nMAXX = 100000000\r\n\r\n\r\n'''**************Solution is Here***********'''\r\ndef equalPartition(self,N, arr):\r\n # code here\r\n s=sum(arr)\r\n #s has to be even for halves to exist\r\n if s%2==1:\r\n return 0\r\n mat=[]\r\n p=s//2\r\n \r\n #initialization of DP table\r\n for i in range(N+1):\r\n row=[]\r\n for j in range(p+1):\r\n if j==0:\r\n row.append(1)\r\n elif i==0:\r\n row.append(0)\r\n else:\r\n row.append(2)\r\n mat.append(row)\r\n # print(mat)\r\n \r\n # DP table\r\n for i in range(1,N+1):\r\n for j in range(1,p+1):\r\n if arr[i-1]>j:\r\n mat[i][j]=mat[i-1][j]\r\n \r\n else:\r\n mat[i][j]=max(mat[i-1][j],mat[i-1][j-arr[i-1]])\r\n return mat[-1][-1]\r\n\r\n\r\ndef solve(arr,n):\r\n sm = sum(arr)\r\n if sm%2==1:\r\n return False\r\n return equalPartition(sm//2, n, arr)\r\n\r\ndef main():\r\n T = 1\r\n for _ in range(T):\r\n n = ii()\r\n a = li()\r\n if (solve(a, n)) == True:\r\n ans = -1\r\n for i in range(n):\r\n b = [0]*n\r\n k = 0\r\n for j in range(n):\r\n if i==j:\r\n continue\r\n b[k] = a[j]\r\n k += 1\r\n if (solve(b,k) == False):\r\n ans = i\r\n break\r\n if (solve(b,k) == True):\r\n ans = i+1\r\n break\r\n print(1)\r\n print(ans+1)\r\n \r\n\r\n else:\r\n print(0)\r\n\r\n\r\n\r\n\r\n\r\n\r\n# End FASTIO\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "import sys\nimport math\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.rstrip()))\ndef invr():\n return(map(int,input().split()))\nn=inp()\ndef solution(L):\n\tS=sum(L)\n\tif S==0:\n\t\tprint(n-1)\n\t\tprint(' '.join([str(i) for i in range(1, n)]))\n\t\treturn 0\n\tif S%2!=0:\n\t\tprint(0)\n\t\treturn 0\n\telse:\n\t\tfor i in range(len(L)):\n\t\t\tl=L[i]\n\t\t\tif l%2==1:\n\t\t\t\tprint(1)\n\t\t\t\tprint(i+1)\n\t\t\t\treturn 0\n\tsolution([l//2 for l in L])\n\nL=inlt()\nsolution(L)"}, {"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\n\r\ndef findPartiion(a,n):\r\n s = 0\r\n for i in range(n):\r\n s += a[i]\r\n if s % 2:\r\n return 0\r\n part = [0] * (s // 2 + 1)\r\n for i in range(s // 2 + 1):\r\n part[i] = 0\r\n for i in range(n):\r\n for j in range(s // 2, a[i] - 1, -1):\r\n if (part[j - a[i]] == 1 or j == a[i]):\r\n part[j] = 1\r\n return part[s // 2]\r\n\r\ndef main():\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n if not findPartiion(a,len(a)):\r\n print(0)\r\n else:\r\n o = 0\r\n for i in a:\r\n if i % 2:\r\n o += 1\r\n if o % 2:\r\n print(0)\r\n else:\r\n print(1)\r\n for i in range(n):\r\n if a[i] % 2:\r\n print(i + 1)\r\n return\r\n for i in range(n):\r\n f=1\r\n for j in range(n):\r\n if i!=j:\r\n for k in range(n):\r\n if j!=k:\r\n if a[i]==2*(a[j]-a[k]):\r\n f=0\r\n if f:\r\n print(i+1)\r\n return\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\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\nimport math\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.rstrip()))\ndef invr():\n return(map(int,input().split()))\n\n\n\n\ndef solution(L):\n\n\tfor i in range(n):\n\t\tl=L[i]\n\t\tif l%2==1:\n\t\t\tprint(1)\n\t\t\tprint(i+1)\n\t\t\treturn 0\n\tsolution([l//2 for l in L])\n\nn=inp()\nL=inlt()\nS=sum(L)\ndef test():\n\tif S%2!=0:\n\t\tprint(0)\n\telse:\n\n\t\tP=set([0])\n\t\tfound=False\n\t\tfor l in L:\n\t\t\tA=[]\n\t\t\tfor p in P:\n\t\t\t\tif p+l==S//2:\n\t\t\t\t\tprint(0)\n\t\t\t\t\treturn\n\t\t\t\tif p+l <= S//2:\n\t\t\t\t\tA.append(p+l)\n\t\t\tfor a in A:\n\t\t\t\tP.add(a)\n\n\n\n\t\tsolution(L)\n\ntest()"}, {"source_code": "from math import gcd\r\nfrom sys import stdin\r\ninput = stdin.buffer.readline\r\n\r\ndef check(arr):\r\n target = sum(arr) // 2\r\n dp = [[False for _ in range(target+1)] for __ in range(n+1)]\r\n\r\n for i in range(n+1):\r\n dp[i][0] = True\r\n\r\n for i in range(1, n+1):\r\n for j in range(1, target+1):\r\n if j - a[i-1] >= 0:\r\n dp[i][j] = dp[i][j - a[i-1]] or dp[i-1][j]\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n\r\n return dp[-1][-1]\r\n\r\n\r\ndef func():\r\n if sum(a) % 2 != 0 or not check(a):\r\n print(0)\r\n else:\r\n for i in range(n):\r\n if a[i] % 2 != 0:\r\n print(1, i+1, sep='\\n')\r\n return\r\n gc = 0\r\n\r\n for i in range(n):\r\n gc = gcd(gc, a[i])\r\n\r\n for i in range(n):\r\n a[i] = a[i] // gc\r\n\r\n for i in range(n):\r\n if a[i] % 2 != 0:\r\n print(1, i+1, sep='\\n')\r\n return\r\n\r\n\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nfunc()\r\n"}, {"source_code": "n=int(input())\r\na=list(map(int,input().split()))\r\nsums=sum(a)\r\nif sums%2==1:\r\n print(0)\r\nelse:\r\n flag=True\r\n while flag:\r\n for i in range(n):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n flag=False\r\n break\r\n else:\r\n a[i] = a[i] // 2\r\n if flag:\r\n sums =sums//2\r\n if sums%2==1:\r\n print(0)\r\n break\r\n \r\n \r\n"}, {"source_code": "n=int(input())\r\nm=[int(i) for i in input().split()]\r\ns=sum(m)\r\nfor i in range(len(m)):\r\n m[i]=[m[i],i]\r\n\r\nif s%2!=0:\r\n print(0)\r\na=0\r\nb=0\r\nm.sort(key=lambda x: x[0], reverse=True)\r\nprint(m)\r\nc=1\r\nans=[]\r\nwhile True:\r\n a=0\r\n b=0\r\n for i in range(len(m)):\r\n if a<=b and a+m[i][0]<=s//2:\r\n a+=m[i][0]\r\n else:\r\n b+=m[i][0]\r\n t=None\r\n for i in range(len(m)):\r\n if m[i][0] % 2 != 0:\r\n t=m[i][1]\r\n if t is not None:\r\n ans=[t]\r\n break\r\n else:\r\n for i in range(len(m)):\r\n m[i][0]//=2\r\nprint(c,*ans,sep='\\n')"}, {"source_code": "n=int(input())\r\nm=[int(i) for i in input().split()]\r\ns=sum(m)\r\nfor i in range(len(m)):\r\n m[i]=[m[i],i]\r\n\r\nif s%2!=0:\r\n print(0)\r\n exit()\r\na=0\r\nb=0\r\nm.sort(key=lambda x: x[0], reverse=True)\r\nc=1\r\nans=[]\r\nwhile True:\r\n a=0\r\n b=0\r\n for i in range(len(m)):\r\n if len(m)%2!=0 and i==len(m)-1:\r\n break\r\n if a<=b and a+m[i][0]<=s//2:\r\n a+=m[i][0]\r\n else:\r\n b+=m[i][0]\r\n if b!=a:\r\n break\r\n t=None\r\n mm=m[0][0]\r\n for i in range(len(m)):\r\n if m[i][0] < mm:\r\n j=i\r\n t=m[i][1]\r\n mm=m[i][0]\r\n m.pop(j)\r\n ans.append(t+1)\r\nprint(len(ans))\r\nprint(*ans)"}, {"source_code": "from os import path\r\nimport sys,time\r\nmod = int(1e9 + 7)\r\n# import re\r\nfrom math import ceil, floor,gcd,log,log2 ,factorial,sqrt\r\nfrom collections import defaultdict ,Counter , OrderedDict , deque\r\nfrom itertools import combinations ,accumulate\r\n# from string import ascii_lowercase ,ascii_uppercase\r\nfrom bisect import *\r\nfrom functools import reduce\r\nfrom operator import mul\r\nstar = lambda x: print(' '.join(map(str, x)))\r\ngrid = lambda r :[lint() for i in range(r)]\r\nstpr = lambda x : sys.stdout.write(f'{x}' + '\\n')\r\nINF = float('inf')\r\nif (path.exists('input.txt')):\r\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\r\nimport sys\r\nfrom sys import stdin, stdout\r\nfrom collections import *\r\nfrom math import gcd, floor, ceil\r\ndef st(): return list(stdin.readline().strip())\r\ndef inp():\r\n return int(stdin.readline())\r\ndef inlt():\r\n return list(map(int, stdin.readline().split()))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return map(int, stdin.readline().split())\r\ndef pr(n): return stdout.write(str(n)+\"\\n\")\r\nfrom copy import deepcopy\r\ndef subset_sum(a,n,target):\r\n dp = [[False for _ in range(target+1)]for _ in range(n+1)]\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if i==0:\r\n dp[i][j] = False\r\n if j==0:\r\n dp[i][j] = True\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if a[i-1]<=j:\r\n dp[i][j] = dp[i-1][j] or dp[i-1][j-a[i-1]]\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n return dp[n][target]\r\ndef solve():\r\n n = inp()\r\n a = inlt()\r\n if sum(a)%2:\r\n print(0)\r\n else:\r\n odd = False\r\n ind = 0\r\n if subset_sum(a,n,sum(a)//2):\r\n for i in range(n):\r\n if a[i]%2:\r\n ind = i\r\n odd = True\r\n break\r\n if odd:\r\n print(1)\r\n print(ind+1)\r\n else:\r\n for i in range(1,11):\r\n for j in range(n):\r\n if a[i]%2:\r\n print(1)\r\n print(i+1)\r\n else:\r\n a[i]//=2\r\n else:\r\n print(0)\r\n \r\nt = 1\r\n#t = inp()\r\nfor _ in range(t):\r\n solve()\r\n\r\n"}, {"source_code": "import sys\r\nreader = (s.rstrip() for s in sys.stdin)\r\ninput = reader.__next__\r\n\r\n\r\nn = int(input())\r\nlst = list(map(int,input().split()))\r\n\r\n\r\nsumN = sum(lst)\r\n\r\nif sumN%2:\r\n print(0)\r\nelse:\r\n ans = 0\r\n dude = 0\r\n for ele in lst:\r\n dude ^= ele\r\n if dude!=0:\r\n print(0)\r\n else:\r\n for idx,ele in enumerate(lst):\r\n if ele%2:\r\n ans = idx + 1\r\n break\r\n\r\n if ans:\r\n print(1)\r\n print(ans)\r\n elif sumN//2%2:\r\n print(0)\r\n else:\r\n for idx,ele in enumerate(lst):\r\n if ((sumN-ele)//2)%2:\r\n ans = idx + 1\r\n break\r\n print(1)\r\n print(ans)\r\n\r\n#\"{} {} {}\".format(maxele,minele,minele)\r\n\r\n# yield \" \".join([str(x) for x in ans])\r\n# 2 4 4 2\r\n\r\n# 2*10\r\n"}, {"source_code": "#!/usr/bin/env python3\r\n \r\nimport sys\r\nimport math\r\nfrom bisect import bisect_right as br\r\nfrom bisect import bisect_left as bl\r\nfrom heapq import heappush, heappop,heappushpop\r\nfrom collections import defaultdict\r\nfrom itertools import accumulate\r\nfrom collections import Counter\r\nfrom collections import deque\r\nfrom operator import itemgetter\r\nfrom itertools import permutations\r\nmod = 10**9 + 7\r\ninf = float('inf')\r\ndef I(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int,sys.stdin.readline().split()))\r\n\r\nn = I()\r\na = LI()\r\nm = max(a)\r\ndp = [[False] * (n * m + 1) for _ in range(n + 1)]\r\ndp[0][0] = True\r\ns = 0\r\nans = set()\r\nfor i in range(n):\r\n ai = a[i]\r\n for j in range(n * m + 1):\r\n dp[i+1][j] = dp[i][j]\r\n if (s + ai) % 2 == 0 and dp[i+1][(s + ai) // 2]:\r\n ans.add(i+1)\r\n continue\r\n s += ai\r\n for j in range(n * m + 1 - ai):\r\n if dp[i][j] and not dp[i+1][j + ai]:\r\n dp[i+1][j + ai] = True\r\nans = list(ans)\r\nprint(len(ans))\r\nprint(*ans)"}, {"source_code": "#Fast I/O\r\nimport sys,os\r\nimport math\r\n# To enable the file I/O i the below 2 lines are uncommented.\r\n# read from in.txt if uncommented\r\nif os.path.exists('in.txt'): sys.stdin=open('in.txt','r')\r\n# will print on Console if file I/O is not activated\r\n#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')\r\n\r\n# inputs template\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\ndef main():\r\n n=int(input())\r\n arr=list(MI())\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n return\r\n t=s//2\r\n mat=[[0 for i in range(t+1)] for j in range(n+1)]\r\n mat[0][0]=1\r\n for i in range(1,n+1):\r\n mat[i][0]=1\r\n for j in range(1,t+1):\r\n if arr[i-1]<=j:\r\n mat[i][j]=mat[i-1][j]|mat[i-1][j-arr[i-1]]\r\n else:\r\n mat[i][j]=mat[i-1][j]\r\n if mat[n][t]:\r\n found=False\r\n for i in range(1,32):\r\n if found:\r\n break\r\n for j in range(n):\r\n if arr[j]&(1<= n:\n return False\n \n bad = False\n bad = bad | call(i + 1, cursum)\n bad = bad | call(i + 1, cursum + a[i])\n dp[i][cursum] = bad\n return dp[i][cursum]\n\nif not call(0, 0):\n print(0)\n exit(0)\n\nfor i in range(n):\n if a[i] % 2 != 0:\n print(1) \n print(i + 1)\n exit(0)\n \nid = -1\nwhile id == -1:\n for i in range(n):\n if c[i] % 2 == 1:\n id = i\n break\n\n c[i] = c[i] // 2\n\nprint(1)\nprint(id + 1)\n"}, {"source_code": "#!/usr/bin/env python3\r\n \r\nimport sys\r\nimport math\r\nfrom bisect import bisect_right as br\r\nfrom bisect import bisect_left as bl\r\nfrom heapq import heappush, heappop,heappushpop\r\nfrom collections import defaultdict\r\nfrom itertools import accumulate\r\nfrom collections import Counter\r\nfrom collections import deque\r\nfrom operator import itemgetter\r\nfrom itertools import permutations\r\nmod = 10**9 + 7\r\ninf = float('inf')\r\ndef I(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int,sys.stdin.readline().split()))\r\n\r\nn = I()\r\na = LI()\r\nm = max(a)\r\na = [[a[i], i] for i in range(n)]\r\na.sort(reverse=True)\r\ndp = [[False] * (n * m + 1) for _ in range(n + 1)]\r\ndp[0][0] = True\r\ns = 0\r\nans = set()\r\nfor i in range(n):\r\n ai = a[i][0]\r\n idx = a[i][1]\r\n for j in range(n * m + 1):\r\n dp[i+1][j] = dp[i][j]\r\n if (s + ai) % 2 == 0 and dp[i+1][(s + ai) // 2]:\r\n ans.add(idx+1)\r\n continue\r\n s += ai\r\n for j in range(n * m + 1 - ai):\r\n if dp[i][j] and not dp[i+1][j + ai]:\r\n dp[i+1][j + ai] = True\r\nans = list(ans)\r\nprint(len(ans))\r\nprint(*ans)"}, {"source_code": "def helper2(a,tar):\r\n pool = [0] * 200005\r\n pool[0] = 1\r\n for i in range(len(a)):\r\n for j in range(tar):\r\n if pool[j] == 1:\r\n pool[j+a[i]] = 1\r\n \r\n if pool[tar] == 1:\r\n return True\r\n \r\n return False\r\n\r\ndef helper(a):\r\n \r\n if sum(a) % 2 == 1:\r\n return -1\r\n \r\n if helper2(a,sum(a)//2):\r\n while True:\r\n for i in range(len(a)):\r\n if a[i] % 2 == 1:\r\n return i\r\n a[i] = a[i] // 2\r\n else:\r\n return -1\r\n\r\n#t = int(input())\r\n#for i in range(t):\r\nn = int(input())\r\na = list(map(int,input().split(\" \")))\r\nres = helper(a)\r\nif res == -1:\r\n print(0)\r\nelse:\r\n print(1)\r\n print(res+1)\r\n"}, {"source_code": "def con(n):\r\n t=bin(int(n))\r\n return t[::-1]\r\n\r\nn=int(input())\r\nl=list(map(con,input().split()))\r\nc=float('inf')\r\nfor i in range(n):\r\n c=min(len(l[i]),c)\r\n\r\nf=0\r\nfor i in range(c):\r\n for j in range(n):\r\n if l[j][i]=='1':\r\n print(1)\r\n print(j+1)\r\n f=1\r\n break\r\n if f==1:\r\n break\r\n\r\n"}, {"source_code": "def inp():\r\n return [int(a) for a in input().split()]\r\ndef gcd(x, y):\r\n if y:\r\n return gcd(y, x % y)\r\n else:\r\n return x\r\ndef bad(array):\r\n st = set()\r\n st.add(0)\r\n for i in array:\r\n st1 = set()\r\n for j in st:\r\n st1.add(i + j)\r\n st = st.union(st1)\r\n if sum(array) // 2 in st:\r\n return True\r\n return False\r\nind = []\r\nn = int(input())\r\na = inp()\r\nprev = a[0]\r\nfor i in range(1, n):\r\n g = gcd(prev, a[i])\r\n prev = a[i]\r\nfor i in range(n):\r\n a[i] //= g\r\nif sum(a) % 2 == 1:\r\n print(0)\r\nelse:\r\n if bad(a):\r\n for i in range(n):\r\n if a[i] % 2:\r\n print(1)\r\n print(i + 1)\r\n break\r\n else:\r\n print(0)\r\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\nfrom math import gcd\r\ndef partion(a):\r\n su=sum(a)\r\n if su%2:\r\n return 0\r\n dp=[1]+[0]*su\r\n for i in a:\r\n for j in range(su,i-1,-1):\r\n dp[j]+=dp[j-i]\r\n return dp[su//2]\r\ndef gcd_Array(a):\r\n g=0\r\n for i in a:\r\n g=gcd(g,i)\r\n return g\r\ndef main():\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n if partion(a):\r\n g=gcd_Array(a)\r\n for i in range(n):\r\n a[i]=a[i]//g\r\n o,ind=0,0\r\n for i,v in enumerate(a):\r\n if v&1:\r\n o+=1\r\n ind=i+1\r\n if o&1:\r\n print(0)\r\n else:\r\n print(1)\r\n print(ind+1)\r\n else:\r\n print(0)\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\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": "# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math\nfrom heapq import heappop, heappush, heapify, heapreplace\nfrom collections import defaultdict, deque\nfrom bisect import bisect_left, bisect_right\n#from functools import lru_cache\nimport re\nmod = 1000000007\nmod1 = 998244353\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n# ------------------------------------------- Algos --------------------------------------------------------\ndef primeFactors(n):\n arr = []\n while n % 2 == 0:\n arr.append(2)\n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2):\n while n % i== 0:\n arr.append(i)\n n = n // i\n if n > 2:\n arr.append(n)\n return arr\ndef primeFactorsSet(n):\n s = set()\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)\n return s\ndef sieve(n):\n res=[0 for i in range(n+1)]\n #prime=set([])\n prime=[]\n for i in range(2,n+1):\n if not res[i]:\n #prime.add(i)\n prime.append(i)\n for j in range(1,n//i+1):\n res[i*j]=1\n return prime\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\ndef countPrimesLessThanN(n):\n seen, ans = [0] * n, 0\n for num in range(2, n):\n if seen[num]: continue\n ans += 1\n seen[num*num:n:num] = [1] * ((n - 1) // num - num + 1)\n return ans\ndef gcd(x, y):\n return math.gcd(x, y)\ndef lcm(a,b):\n return (a // gcd(a,b))* b\ndef isBitSet(n,k):\n # returns the count of numbers up to N having K-th bit set.\n res = (n >> (k + 1)) << k\n if ((n >> k) & 1):\n res += n & ((1 << k) - 1)\n return res\ndef modular_exponentiation(x, y, p): #returns (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\ndef nCr(n, r, p): # returns nCr % 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\ndef smallestDivisor(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 += 2\n return 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 return False\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 return True\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# -------------------------------------------------- code -------------------------------------------------\ndef subsetSum(elements, target):\n dp = [False]*(target+1)\n dp[0] = True\n for ele in elements:\n for j in range(target, ele - 1, -1):\n if dp[j - ele]:\n dp[j] = True\n return dp[target]\n\ndef main():\n n = int(input())\n arr = list(map(int, input().split()))\n\n if not subsetSum(arr, sum(arr)//2):\n print(0)\n return\n\n g = 0\n odd = -1\n for i in range(n):\n g = gcd(g, arr[i])\n if arr[i]%2 == 1:\n odd = i+1\n break\n\n if odd != -1:\n print(1)\n print(odd)\n return\n\n ans = -1\n for i in range(n):\n if arr[i]//g % 2 == 1:\n ans = i+1\n break\n\n print(1)\n print(ans)\n\n\n# ---------------------------------------------- region fastio ---------------------------------------------\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# -------------------------------------------------- end region ---------------------------------------------\n\nif __name__ == \"__main__\":\n #read()\n main()"}, {"source_code": "def solve(arr):\r\n s = sum(arr)\r\n if s & 1:\r\n print(0)\r\n return\r\n half = s // 2\r\n dp = [False] * (half + 1)\r\n dp[0] = True\r\n for a in arr:\r\n if a > half:\r\n print(0)\r\n return\r\n for j in range(half, a - 1, -1):\r\n dp[j] = dp[j] or dp[j - a]\r\n if not dp[-1]:\r\n print(0)\r\n return\r\n\r\n found = [None] * 13\r\n for a in arr:\r\n for i in range(13):\r\n if not found[i] and (a >> i) & 1:\r\n found[i] = a\r\n for i in range(13):\r\n if found[i]:\r\n print(1)\r\n print(found[i])\r\n return\r\n\r\n\r\n# t = int(input())\r\n# for _ in range(t):\r\n # n, k = [int(x) for x in input().split()]\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\nsolve(arr)\r\n"}, {"source_code": "# template taken from https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nimport math\nfrom heapq import heappop, heappush, heapify, heapreplace\nfrom collections import defaultdict, deque\nfrom bisect import bisect_left, bisect_right\n#from functools import lru_cache\nimport re\nmod = 1000000007\nmod1 = 998244353\n\ndef read():\n sys.stdin = open('input.txt', 'r') \n sys.stdout = open('output.txt', 'w') \n\n# ------------------------------------------- Algos --------------------------------------------------------\ndef primeFactors(n):\n arr = []\n while n % 2 == 0:\n arr.append(2)\n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2):\n while n % i== 0:\n arr.append(i)\n n = n // i\n if n > 2:\n arr.append(n)\n return arr\ndef primeFactorsSet(n):\n s = set()\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)\n return s\ndef sieve(n):\n res=[0 for i in range(n+1)]\n #prime=set([])\n prime=[]\n for i in range(2,n+1):\n if not res[i]:\n #prime.add(i)\n prime.append(i)\n for j in range(1,n//i+1):\n res[i*j]=1\n return prime\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\ndef countPrimesLessThanN(n):\n seen, ans = [0] * n, 0\n for num in range(2, n):\n if seen[num]: continue\n ans += 1\n seen[num*num:n:num] = [1] * ((n - 1) // num - num + 1)\n return ans\ndef gcd(x, y):\n return math.gcd(x, y)\ndef lcm(a,b):\n return (a // gcd(a,b))* b\ndef isBitSet(n,k):\n # returns the count of numbers up to N having K-th bit set.\n res = (n >> (k + 1)) << k\n if ((n >> k) & 1):\n res += n & ((1 << k) - 1)\n return res\ndef modular_exponentiation(x, y, p): #returns (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\ndef nCr(n, r, p): # returns nCr % 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\ndef smallestDivisor(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 += 2\n return 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 return False\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 return True\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# -------------------------------------------------- code -------------------------------------------------\ndef subsetSum(elements, target):\n dp = [False]*(target+1)\n dp[0] = True\n for ele in elements:\n for j in range(target, ele - 1, -1):\n if dp[j - ele]:\n dp[j] = True\n return dp[target]\n\ndef main():\n n = int(input())\n arr = list(map(int, input().split()))\n s = sum(arr)\n if s%2 == 1:\n print(0)\n return\n\n if subsetSum(arr, s//2):\n g = 0\n odd = -1\n for i in range(n):\n if arr[i]%2 == 1:\n odd = i+1\n break\n else:\n g = gcd(g, arr[i])\n if odd != -1:\n print(1)\n print(odd)\n else:\n z = -1\n for i in range(n):\n arr[i] = arr[i]//g\n if arr[i]//4 != 0:\n z = i+1\n break\n if z != -1:\n print(1)\n print(z)\n return\n\n de = deque(arr)\n a = -1\n for i in range(n):\n x = de.popleft()\n\n if not subsetSum(de, (s-x)//2):\n a = i+1\n break\n\n else:\n de.append(x)\n print(1)\n print(a)\n\n else:\n print(0)\n\n# ---------------------------------------------- region fastio ---------------------------------------------\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# -------------------------------------------------- end region ---------------------------------------------\n\nif __name__ == \"__main__\":\n #read()\n main()"}, {"source_code": "import sys\r\nsys.setrecursionlimit(int(1e4))\r\ndef alreadygood(ind, sm):\r\n dp = [[False for i in range(200001)] for j in range(n + 1)]\r\n for i in range(200001):\r\n if i == s - i:\r\n dp[n - 1][i] = True\r\n for ind in range(n - 2, -1, -1):\r\n for sm in range(s - 1, -1, -1):\r\n dp[ind][sm] = dp[ind + 1][sm] | dp[ind + 1][sm + lis[ind]]\r\n return dp[0][0]\r\n\r\nimport sys, math ; input = lambda :sys.stdin.readline().rstrip()\r\nI=lambda:[*map(int,input().split())]\r\nn, = I()\r\nlis = I()\r\ndp = dict()\r\ns = sum(lis)\r\nif sum(lis) & 1:\r\n print(0)\r\n exit()\r\nelse:\r\n odd = False\r\n for i, j in enumerate(lis):\r\n if j & 1:\r\n print(1)\r\n print(i + 1)\r\n odd = True\r\n exit()\r\n if odd == False:\r\n if not alreadygood(0, 0):\r\n print(0)\r\n else:\r\n mn = 1 << 69 ; ind = None\r\n for i in range(n):\r\n val = math.log2(lis[i]&-lis[i])+1\r\n if val < mn:\r\n mn = val ; ind = i\r\n print(1)\r\n print(ind + 1)"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\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\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\ninp = lambda dtype: dtype(input().strip())\r\ninp_d = lambda dtype: [dtype(x) for x in input().split()]\r\ninp_2d = lambda dtype, n: [inp(dtype) for _ in range(n)]\r\ninp_2ds = lambda dtype, n: [inp_d(dtype) for _ in range(n)]\r\ninp_enu = lambda dtype: [(i, x) for i, x in enumerate(inp_d(dtype))]\r\ninp_enus = lambda dtype, n: [[i, inp_d(dtype)] for i in range(n)]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\nlsone = lambda x: x & (-x)\r\n\r\nn, a = inp(int), inp_d(int)\r\nmem, su = [False] * (10 ** 5 + 1), sum(a)\r\n\r\nfor i in range(n):\r\n for j in range(10 ** 5 - a[i] + 1):\r\n mem[a[i] + j] = True\r\n\r\nif su & 1 or not mem[su >> 1]:\r\n print(0)\r\nelse:\r\n print(1, a.index(min(a, key=lambda x: lsone(x))) + 1, sep='\\n')\r\n"}, {"source_code": "import sys\r\nsys.setrecursionlimit(int(1e4))\r\ndef alreadygood(ind, sm):\r\n dp = [[False for i in range(20001)] for j in range(n + 1)]\r\n for i in range(20001):\r\n if i == s - i:\r\n dp[n - 1][i] = True\r\n for ind in range(n - 2, -1, -1):\r\n for sm in range(s - 1, -1, -1):\r\n dp[ind][sm] = dp[ind + 1][sm] | dp[ind + 1][sm + lis[ind]]\r\n return dp[0][0]\r\n\r\nimport sys, math ; input = lambda :sys.stdin.readline().rstrip()\r\nI=lambda:[*map(int,input().split())]\r\nn, = I()\r\nlis = I()\r\ndp = dict()\r\ns = sum(lis)\r\nif sum(lis) & 1:\r\n print(0)\r\n exit()\r\nelse:\r\n odd = False\r\n for i, j in enumerate(lis):\r\n if j & 1:\r\n print(1)\r\n print(i + 1)\r\n odd = True\r\n exit()\r\n if odd == False:\r\n if not alreadygood(0, 0):\r\n print(0)\r\n else:\r\n print(1)\r\n print(lis.index(min(lis)) + 1)"}, {"source_code": "# Author : nitish420 --------------------------------------------------------------------\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\n\r\ndef knapsack(n,wt,w,dp):\r\n\r\n for i in range(n+1):\r\n dp[i][0]=1\r\n\r\n for r in range(1,n+1):\r\n for c in range(1,w+1):\r\n if wt[r-1]<=w:\r\n dp[r][c]=dp[r-1][c] or dp[r-1][c-wt[r-1]]\r\n else:\r\n dp[r][c]=0\r\n\r\n return dp[n][w]\r\n\r\n\r\ndef main():\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n s=sum(a)\r\n\r\n if s%2==0:\r\n\r\n dp=[[0 for _ in range(s//2+1)]for _ in range(n+1)]\r\n\r\n \r\n if knapsack(n,a,s//2,dp):\r\n\r\n # for item in dp:\r\n # print(*item)\r\n\r\n for i,item in enumerate(a):\r\n if item%2:\r\n print(1)\r\n print(i+1)\r\n break\r\n elif dp[n][((s-item)//2)]==0:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n print(0)\r\n else:\r\n print(0)\r\n\r\n# 6\r\n# 2 4 6 8 10 10\r\n\r\n\r\n#----------------------------------------------------------------------------------------\r\ndef nouse0():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse1():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse2():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\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\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\n\r\n\r\ndef nouse3():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse4():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse5():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\r\n\r\n# endregion\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n \r\n# mandatory imports\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import log2, ceil, sqrt, gcd, log\r\n\r\n# optional imports\r\n# from itertools import permutations\r\n# from functools import cmp_to_key # for adding custom comparator\r\n# from fractions import Fraction\r\nfrom collections import *\r\nfrom bisect import *\r\n# from __future__ import print_function # for PyPy2\r\nfrom heapq import *\r\nBUFSIZE = 8192\r\n\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\ng = lambda : input().strip()\r\ngl = lambda : g().split()\r\ngil = lambda : [int(var) for var in gl()]\r\ngfl = lambda : [float(var) for var in gl()]\r\ngcl = lambda : list(g())\r\ngbs = lambda : [int(var) for var in g()]\r\nrr = lambda x : reversed(range(x)) \r\nmod = int(1e9)+7\r\ninf = float(\"inf\")\r\n\r\nn, = gil()\r\na = gil()\r\nif sum(a)&1:\r\n print(0)\r\n exit()\r\nidx = 0\r\np = int(log2(a[0]))\r\n\r\nfor i in range(1, n):\r\n pi = int(log2(a[i]))\r\n if pi < p:\r\n idx = i\r\n p = pi\r\n\r\nprint(1)\r\nprint(idx+1)"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\n_print = print\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 inp():\r\n return sys.stdin.readline().rstrip()\r\n\r\n\r\ndef mpint():\r\n return map(int, inp().split(' '))\r\n\r\n\r\ndef itg():\r\n return int(inp())\r\n\r\n\r\n# ############################## import\r\ndef sum_partition(iterable):\r\n iterable = tuple(iterable)\r\n s = sum(iterable)\r\n half = s >> 1\r\n dp = [0] * (half + 1)\r\n for i in range(len(iterable)):\r\n for h in range(half, iterable[i] - 1, -1):\r\n dp[h] = max(dp[h], dp[h - iterable[i]] + iterable[i])\r\n return dp[half] == s - dp[half]\r\n\r\n\r\n# ############################## main\r\ndef main():\r\n n = itg()\r\n arr = tuple(mpint())\r\n if not sum_partition(arr):\r\n print(0)\r\n return\r\n\r\n print(1)\r\n d = {}\r\n for i, a in enumerate(arr):\r\n d[a] = i + 1\r\n\r\n while True:\r\n for k in tuple(d):\r\n if k & 1:\r\n print(d[k])\r\n return\r\n else:\r\n d[k >> 1] = d[k]\r\n del d[k]\r\n\r\n\r\nDEBUG = 0\r\nURL = 'https://codeforces.com/contest/1516/problem/C'\r\n\r\nif __name__ == '__main__':\r\n # 0: normal, 1: runner, 2: debug, 3: interactive\r\n if DEBUG == 1:\r\n import requests\r\n from ACgenerator.Y_Test_Case_Runner import TestCaseRunner\r\n\r\n runner = TestCaseRunner(main, URL)\r\n inp = runner.input_stream\r\n print = runner.output_stream\r\n runner.checking()\r\n else:\r\n if DEBUG != 2:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n if DEBUG:\r\n def print(*args, **kwargs):\r\n _print(*args, **kwargs)\r\n sys.stdout.flush()\r\n main()\r\n# Please check!\r\n"}, {"source_code": "def helper2(a,tar):\r\n pool = [0] * 200005\r\n pool[0] = 1\r\n for i in range(len(a)):\r\n for j in range(tar):\r\n if pool[j] == 1:\r\n pool[j+a[i]] = 1\r\n #print(pool[tar])\r\n return pool[tar] == 1\r\n\r\ndef helper(a):\r\n \r\n if sum(a) % 2 == 1:\r\n return -1\r\n \r\n if helper2(a,sum(a)//2):\r\n while True:\r\n for i in range(len(a)):\r\n if a[i] % 2 == 1:\r\n return i\r\n a[i] = a[i] // 2\r\n else:\r\n return -1\r\n\r\n#t = int(input())\r\n#for i in range(t):\r\nn = int(input())\r\na = list(map(int,input().split(\" \")))\r\n#print(len(a))\r\nres = helper(a)\r\nif res == -1:\r\n print(0)\r\n print()\r\nelse:\r\n print(1)\r\n print(res+1)\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\ndef canPartition(a,i,target,num):\r\n global final\r\n if target==0:\r\n final = min(final,num)\r\n return True\r\n if i>=len(a) or target<0:\r\n return False\r\n if (i,target) in memo:\r\n return memo[i,target]\r\n memo[i,target] = canPartition(a,i+1,target,num) or canPartition(a,i+1,target-a[i],min(num,a[i]))\r\n return memo[i,target]\r\nn = int(input())\r\na = list(map(int,input().split()))\r\ns = sum(a)\r\nif s%2==1:\r\n print(0)\r\nelse:\r\n final = float(\"inf\")\r\n memo = {}\r\n d = {i:v for v,i in enumerate(a)}\r\n for i in range(n):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n flag = False\r\n while True:\r\n for i in range(n):\r\n a[i]//=2\r\n for i in range(n):\r\n if a[i]%2==1:\r\n print(1)\r\n print(i+1)\r\n flag = True\r\n break\r\n if flag:\r\n break"}, {"source_code": "from os import path\r\nimport sys,time\r\nmod = int(1e9 + 7)\r\n# import re\r\nfrom math import ceil, floor,gcd,log,log2 ,factorial,sqrt\r\nfrom collections import defaultdict ,Counter , OrderedDict , deque\r\nfrom itertools import combinations ,accumulate\r\n# from string import ascii_lowercase ,ascii_uppercase\r\nfrom bisect import *\r\nfrom functools import reduce\r\nfrom operator import mul\r\nstar = lambda x: print(' '.join(map(str, x)))\r\ngrid = lambda r :[lint() for i in range(r)]\r\nstpr = lambda x : sys.stdout.write(f'{x}' + '\\n')\r\nINF = float('inf')\r\nif (path.exists('input.txt')):\r\n sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w');\r\nimport sys\r\nfrom sys import stdin, stdout\r\nfrom collections import *\r\nfrom math import gcd, floor, ceil\r\ndef st(): return list(stdin.readline().strip())\r\ndef inp():\r\n return int(stdin.readline())\r\ndef inlt():\r\n return list(map(int, stdin.readline().split()))\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\ndef invr():\r\n return map(int, stdin.readline().split())\r\ndef pr(n): return stdout.write(str(n)+\"\\n\")\r\nfrom copy import deepcopy\r\ndef subset_sum(a,n,target):\r\n dp = [[False for _ in range(target+1)]for _ in range(n+1)]\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if i==0:\r\n dp[i][j] = False\r\n if j==0:\r\n dp[i][j] = True\r\n for i in range(n+1):\r\n for j in range(target+1):\r\n if a[i-1]<=j:\r\n dp[i][j] = dp[i-1][j] or dp[i-1][j-a[i-1]]\r\n else:\r\n dp[i][j] = dp[i-1][j]\r\n return dp[n][target]\r\ndef solve():\r\n n = inp()\r\n a = inlt()\r\n if sum(a)%2:\r\n print(0)\r\n else:\r\n odd = False\r\n ind = 0\r\n if subset_sum(a,n,sum(a)//2):\r\n for i in range(n):\r\n if a[i]%2:\r\n ind = i\r\n odd = True\r\n break\r\n if odd:\r\n print(1)\r\n print(ind+1)\r\n else:\r\n for i in range(1,11):\r\n for j in range(n):\r\n if a[i]%2:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n a[i]//=2\r\n else:\r\n print(0)\r\n \r\nt = 1\r\n#t = inp()\r\nfor _ in range(t):\r\n solve()\r\n\r\n"}, {"source_code": "from __future__ import division, print_function\r\n\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nsys.setrecursionlimit(10**5)\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\n \r\ndef main():\r\n pass\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\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\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\n# import sys\r\n# sys.stdin = open(\"input.txt\", \"r\")\r\n# sys.stdout = open(\"output.txt\", \"w\")\r\n\r\n \r\ndef solution():\r\n\tn=int(input())\r\n\tarr=list(map(int,input().split()))\r\n\tsm=sum(arr)\r\n\t\r\n\tif sm%2!=0:\r\n\t\tprint(0)\r\n\t\treturn\r\n\telse:\r\n\t\ttarget=sm//2\r\n\t\tdp=[[False for i in range(target+1)] for j in range(n+1)]\r\n \r\n\t\tfor i in range(n+1):\r\n\t\t\tdp[i][0]=True\r\n\t\t\t\r\n\t\tfor i in range(1,n+1):\r\n\t\t\tfor j in range(1, target+1):\r\n\t\t\t\tif arr[i-1]<=j:\r\n\t\t\t\t\tdp[i][j]=dp[i-1][j-arr[i-1]] or dp[i-1][j]\r\n\t\t\t\telse:\r\n\t\t\t\t\tdp[i][j]=dp[i-1][j] \r\n\t\t\r\n\t\tif not dp[-1][-1]:\r\n\t\t\tprint(0)\r\n\t\t\treturn\r\n\t\tfor i in range(n):\t\t\t\r\n\t\t\tif arr[i]%2!=0:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\treturn\r\n \r\n\t\tfor i in range(n):\r\n\t\t\ttemp=sm-arr[i]\r\n\t\t\ttemp=temp//2\r\n\t\t\tif temp%2!=0:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n \r\n \r\n\treturn\r\n \r\n \r\n# t=int(input())\r\n# while t:\r\n# \tt-=1\r\nsolution()\r\n\t"}, {"source_code": "n=int(input())\r\npow=[2,4,8,16,32,64,128,256,512,1024]\r\ns=[int(i) for i in input().split()]\r\nfl=True\r\nfor i in range(len(s)):\r\n if s[i]!=2000:\r\n fl=False\r\n s[i]=[s[i],i]\r\nif fl:\r\n print(1,1,sep='\\n')\r\n exit()\r\nn=len(s)\r\nk=0\r\nfor i in range(len(s)):\r\n k+=s[i][0]\r\nif k%2!=0:\r\n print(0)\r\n exit()\r\nans=[]\r\nstate = True\r\nwhile state:\r\n n = len(s)\r\n k=0\r\n for i in range(len(s)):\r\n k += s[i][0]\r\n p=[[False for i in range(n+2)] for i in range((k//2)+2)]\r\n for i in range(1,n+2):\r\n if i<=k//2+1:\r\n p[i][0]=True\r\n p[0][i]=True\r\n for i in range(1,k//2+1):\r\n for j in range(1,n+1):\r\n if (i-s[j-1][0])>=0:\r\n p[i][j]=p[i][j-1] or p[i-s[j-1][0]][j-1]\r\n else:\r\n p[i][j]=p[i][j-1]\r\n state = p[-1][-1]\r\n if len(s)>0:\r\n m=s[0][0]\r\n t=0\r\n else:\r\n break\r\n j=0\r\n mj=11\r\n for i in range(len(s)):\r\n if s[i][0]%2!=0:\r\n t=s[i][1]\r\n tmp=i\r\n break\r\n for j in range(len(pow)):\r\n if s[i][0]%pow[j]!=0:\r\n if mj>j:\r\n mj=j\r\n t=s[i][1]\r\n tmp=i\r\n s.pop(tmp)\r\n ans.append(t+1)\r\nprint(len(ans))\r\nprint(*ans)\r\n"}, {"source_code": "#!/usr/bin/env python3\r\n \r\nimport sys\r\nimport math\r\nfrom bisect import bisect_right as br\r\nfrom bisect import bisect_left as bl\r\nfrom heapq import heappush, heappop,heappushpop\r\nfrom collections import defaultdict\r\nfrom itertools import accumulate\r\nfrom collections import Counter\r\nfrom collections import deque\r\nfrom operator import itemgetter\r\nfrom itertools import permutations\r\nmod = 10**9 + 7\r\ninf = float('inf')\r\ndef I(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int,sys.stdin.readline().split()))\r\n\r\nn = I()\r\na = LI()\r\ns = sum(a)\r\nm = max(a)\r\nif s % 2:\r\n print(0)\r\nelse:\r\n dp = [[False] * (n * m + 1) for _ in range(n + 1)]\r\n dp[0][0] = True\r\n for i in range(n):\r\n ai = a[i]\r\n for j in range(n * m + 1):\r\n dp[i+1][j] = dp[i][j]\r\n for j in range(n * m + 1 - ai):\r\n if dp[i][j] and not dp[i+1][j + ai]:\r\n dp[i+1][j + ai] = True\r\n if dp[n][s//2]:\r\n print(1)\r\n print(a.index(min(a)) + 1)\r\n else:\r\n print(0)"}, {"source_code": "n = int(input())\r\na = list(map(int, input().split()))\r\ns = sum(a)\r\nif s % 2 == 1:\r\n print(0)\r\n exit()\r\ndp = [[False] * (s // 2+10) for _ in range(n + 1)]\r\ndp[0][0] = True\r\nfor i in range(n):\r\n for j in range(s // 2+10):\r\n if j < a[i]:\r\n dp[i + 1][j] = dp[i][j]\r\n else:\r\n dp[i + 1][j] |= dp[i][j - a[i]]\r\nif not dp[n][s//2]:\r\n print(0)\r\nelse:\r\n l = []\r\n for i in a:\r\n cnt = 0\r\n while i % 2 == 0:\r\n i //= 2\r\n cnt += 1\r\n l.append(cnt)\r\n print(1)\r\n print(l.index(min(l))+1)\r\n"}, {"source_code": "\ndef find(a):\n t = sum(a)\n if t%2 == 1:\n return -1\n else:\n tar = t//2\n s = set()\n s.add(0)\n count = 0\n for i in a[:-1]:\n count += i\n t = count%tar\n if t in s and i!=0:\n return 0\n s.add(t)\n return -1\ndef process(a):\n\n num = float('inf')\n ind = 0\n for i in range(len(a)):\n count = 0\n while a[i]&1 == 0:\n a[i] = a[i] >> 1\n count+=1\n if (count < num):\n num = count\n ind = i+1\n print(1)\n print(ind)\n\n\n\n\nilg = int(input())\na = list(map(int, input().split()))\nr = find(a)\nif (r==-1 or len(a) <=1):\n print(0)\nelse:\n process(a)"}, {"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef solve():\r\n n = int(input())\r\n a = list(map(int,input().split()))\r\n vis = [False]*(2000*100)+[False]\r\n vis[0]=True\r\n for i in range(n):\r\n for j in range(len(vis)-a[i]-1,-1,-1):\r\n if not vis[j]:continue\r\n vis[a[i]+j]=True\r\n sm = sum(a)\r\n if (not vis[sm//2] or sm%2!=0):\r\n print(0)\r\n return\r\n idx= -1\r\n\r\n log =32\r\n div= float('inf')\r\n for pw in range(log,-1,-1):\r\n for i in range(n):\r\n if a[i]//(2**pw)>0:\r\n div = min(div,a[i]//(2**pw))\r\n\r\n for i in range(n):\r\n a[i]/=div\r\n if a[i]%2!=0:\r\n idx =i\r\n break\r\n print(1)\r\n print(idx+1)\r\n return\r\n\r\nt= 1#int(input())\r\nfor _ in range(t):\r\n solve()\r\n"}, {"source_code": "x=int(input())\r\nar=list(map(int,input().split()))[:x]\r\ns=sum(ar)\r\nb=[]\r\nfor j in range(x):\r\n if(ar[j]%2==1):\r\n b.append(j)\r\nif(s%2):\r\n print(0)\r\nelse:\r\n if(s%3==0):\r\n for k in b:\r\n if ar[k]%6:\r\n print(1)\r\n print(k+1)\r\n break\r\n else:\r\n print(1)\r\n print(b[0]+1)\r\n "}, {"source_code": "#!/usr/bin/env python3.9\nfrom pprint import pprint\nn = int(input())\na = list(map(int, input().split(' ')))\n# print(a)\nsa = sum(a)\nif sa % 2 != 0:\n # array already good\n # print('sum is odd')\n print(0)\nelse:\n target = sa // 2\n # print(target)\n # pack knapsack\n # i items, j target capacity\n d = [[0 for _ in range(target+1)] for _ in range(n)]\n d[0][0] = 1\n for i in range(1, n):\n wi = a[i-1]\n for j in range(1, target+1):\n using_wi = d[i-1][j-wi] if j-wi >= 0 else 0\n d[i][j] = d[i-1][j] or using_wi\n # [print(*row) for row in d]\n if d[-1][-1] == False:\n # array is good\n print(0)\n else:\n # drop odd number\n drop_idx = -1\n for i in range(n):\n if a[i] % 2 == 1:\n drop_idx = i\n break\n if drop_idx == -1:\n # full array of even numbers\n for i in range(n):\n if a[i] % 4 == 2:\n drop_idx = i\n break\n if drop_idx == -1:\n drop_idx = a.index(max(a))\n\n print(1)\n print(drop_idx + 1)\n # print(a[drop_idx])\n"}, {"source_code": "#!/usr/bin/env python\r\n#from __future__ import division, print_function\r\nimport math\r\nimport os\r\nimport sys\r\n#from fractions import *\r\nfrom sys import *\r\nfrom decimal import *\r\nfrom io import BytesIO, IOBase\r\nfrom itertools import accumulate,combinations,permutations,combinations_with_replacement,product\r\nfrom collections import *\r\n#import timeit,time\r\n#sys.setrecursionlimit(10**5)\r\nM = 10 ** 9 + 7\r\nimport heapq\r\n\r\n# print(math.factorial(5))\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# sys.setrecursionlimit(10**6)\r\n# region fastio\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\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\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\r\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\r\n\r\n\r\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\r\n\r\n\r\ndef lis(): return list(map(int, inp().split()))\r\n\r\n\r\ndef stringlis(): return list(map(str, inp().split()))\r\n\r\n\r\ndef sep(): return map(int, inp().split())\r\n\r\n\r\ndef strsep(): return map(str, inp().split())\r\n\r\n\r\ndef fsep(): return map(float, inp().split())\r\n\r\n\r\ndef inpu(): return int(inp())\r\n\r\n\r\n# -----------------------------------------------------------------\r\n\r\ndef regularbracket(t):\r\n p = 0\r\n for i in t:\r\n if i == \"(\":\r\n p += 1\r\n else:\r\n p -= 1\r\n if p < 0:\r\n return False\r\n else:\r\n if p > 0:\r\n return False\r\n else:\r\n return True\r\n# -------------------------------------------------\r\ndef binarySearchcount(arr, n, key):\r\n left = 0\r\n right = n - 1\r\n count = 0\r\n while (left <= right):\r\n mid = int((right + left) / 2)\r\n # Check if middle element is\r\n # less than or equal to key\r\n if (arr[mid] <= key):\r\n count = mid + 1\r\n left = mid + 1\r\n # If key is smaller, ignore right half\r\n else:\r\n right = mid - 1\r\n return count\r\n\r\n#--------------------------------------------------binery search\r\ndef binarySearch(arr, n, key):\r\n left = 0\r\n right = n - 1\r\n while (left <= right):\r\n mid = ((right + left) // 2)\r\n if arr[mid]==key:\r\n return mid\r\n if (arr[mid] <= key):\r\n left = mid + 1\r\n # If key is smaller, ignore right half\r\n else:\r\n right = mid - 1\r\n return -1\r\n#-------------------------------------------------ternary search\r\ndef ternarysearch(arr,n,key):\r\n l,r=0,n-1\r\n while(l<=r):\r\n mid = (-l+r)//3 + l\r\n mid2 = mid + (-l+r)//3\r\n if arr[mid]==key:\r\n return mid\r\n if arr[mid2]==key:\r\n return mid2\r\n if arr[mid]>key:\r\n r=mid-1\r\n elif arr[mid2] 15999:\r\n return\r\n value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]\r\n symbol = [\"F\", \"MF\", \"M\", \"CM\", \"D\", \"CD\", \"C\", \"XC\", \"L\", \"XL\", \"X\", \"IX\", \"V\", \"IV\", \"I\"]\r\n roman = \"\"\r\n i = 0\r\n while x > 0:\r\n div = x // value[i]\r\n x = x % value[i]\r\n while div:\r\n roman += symbol[i]\r\n div -= 1\r\n i += 1\r\n return roman\r\n\r\n\r\ndef soretd(s):\r\n for i in range(1, len(s)):\r\n if s[i - 1] > s[i]:\r\n return False\r\n return True\r\n\r\n\r\n# print(soretd(\"1\"))\r\n# ---------------------------\r\ndef countRhombi(h, w):\r\n ct = 0\r\n for i in range(2, h + 1, 2):\r\n for j in range(2, w + 1, 2):\r\n ct += (h - i + 1) * (w - j + 1)\r\n return ct\r\n\r\n\r\ndef countrhombi2(h, w):\r\n return ((h * h) // 4) * ((w * w) // 4)\r\n\r\n\r\n# ---------------------------------\r\ndef binpow(a, b):\r\n if b == 0:\r\n return 1\r\n else:\r\n res = binpow(a, b // 2)\r\n if b % 2 != 0:\r\n return res * res * a\r\n else:\r\n return res * res\r\n\r\n\r\n# -------------------------------------------------------\r\ndef binpowmodulus(a, b, M):\r\n if b==1:\r\n return a%M\r\n if b==0:\r\n return 1\r\n if b%2==0:\r\n ans=binpowmodulus(a,b//2,M)\r\n return (ans*ans)%(M)\r\n else:\r\n ans=binpowmodulus(a,(b-1)//2,M)\r\n return ((ans*a)%M * ans)%M\r\n# -------------------------------------------------------------\r\ndef coprime_to_n(n):\r\n result = n\r\n i = 2\r\n while (i * i <= n):\r\n if (n % i == 0):\r\n while (n % i == 0):\r\n n //= i\r\n result -= result // i\r\n i += 1\r\n if (n > 1):\r\n result -= result // n\r\n return result\r\n\r\n\r\ndef luckynumwithequalnumberoffourandseven(x,n,a):\r\n if x >= n and str(x).count(\"4\") == str(x).count(\"7\"):\r\n a.append(x)\r\n else:\r\n if x < 1e12:\r\n luckynumwithequalnumberoffourandseven(x * 10 + 4,n,a)\r\n luckynumwithequalnumberoffourandseven(x * 10 + 7,n,a)\r\n return a\r\n#----------------------\r\ndef luckynum(x,l,r,a):\r\n if x>=l and x<=r:\r\n a.append(x)\r\n if x>r:\r\n a.append(x)\r\n return a\r\n if x < 1e10:\r\n luckynum(x * 10 + 4, l,r,a)\r\n luckynum(x * 10 + 7, l,r,a)\r\n return a\r\n\r\ndef luckynuber(x, n, a):\r\n p = set(str(x))\r\n if len(p) <= 2:\r\n a.append(x)\r\n if x < n:\r\n luckynuber(x + 1, n, a)\r\n return a\r\n\r\n\r\n# ------------------------------------------------------interactive problems\r\n\r\ndef interact(type, x):\r\n if type == \"r\":\r\n inp = input()\r\n return inp.strip()\r\n else:\r\n print(x, flush=True)\r\n\r\n\r\n# ------------------------------------------------------------------zero at end of factorial of a number\r\ndef findTrailingZeros(n):\r\n # Initialize result\r\n count = 0\r\n\r\n # Keep dividing n by\r\n # 5 & update Count\r\n while (n >= 5):\r\n n //= 5\r\n count += n\r\n\r\n return count\r\n\r\n\r\n# -----------------------------------------------merge sort\r\n# Python program for implementation of MergeSort\r\ndef mergeSort(arr):\r\n if len(arr) > 1:\r\n\r\n # Finding the mid of the array\r\n mid = len(arr) // 2\r\n\r\n # Dividing the array elements\r\n L = arr[:mid]\r\n\r\n # into 2 halves\r\n R = arr[mid:]\r\n\r\n # Sorting the first half\r\n mergeSort(L)\r\n\r\n # Sorting the second half\r\n mergeSort(R)\r\n\r\n i = j = k = 0\r\n\r\n # Copy data to temp arrays L[] and R[]\r\n while i < len(L) and j < len(R):\r\n if L[i] < R[j]:\r\n arr[k] = L[i]\r\n i += 1\r\n else:\r\n arr[k] = R[j]\r\n j += 1\r\n k += 1\r\n\r\n # Checking if any element was left\r\n while i < len(L):\r\n arr[k] = L[i]\r\n i += 1\r\n k += 1\r\n\r\n while j < len(R):\r\n arr[k] = R[j]\r\n j += 1\r\n k += 1\r\n\r\n\r\n# -----------------------------------------------lucky number with two lucky any digits\r\nres = set()\r\ndef solven(p, l, a, b, n): # given number\r\n if p > n or l > 10:\r\n return\r\n if p > 0:\r\n res.add(p)\r\n solven(p * 10 + a, l + 1, a, b, n)\r\n solven(p * 10 + b, l + 1, a, b, n)\r\n\r\n\r\n# problem\r\n\"\"\"\r\nn = int(input())\r\nfor a in range(0, 10):\r\n for b in range(0, a):\r\n solve(0, 0)\r\nprint(len(res))\r\n\"\"\"\r\n\r\n# In the array A at every step we have two\r\n# choices for each element either we can\r\n# ignore the element or we can include the\r\n# element in our subset\r\ndef subsetsUtil(A, subset, index, d):\r\n print(*subset)\r\n s = sum(subset)\r\n d.append(s)\r\n for i in range(index, len(A)):\r\n # include the A[i] in subset.\r\n subset.append(A[i])\r\n\r\n # move onto the next element.\r\n subsetsUtil(A, subset, i + 1, d)\r\n\r\n # exclude the A[i] from subset and\r\n # triggers backtracking.\r\n subset.pop(-1)\r\n return d\r\n\r\n\r\ndef subsetSums(arr, l, r, d, sum=0):\r\n if l > r:\r\n d.append(sum)\r\n return\r\n subsetSums(arr, l + 1, r, d, sum + arr[l])\r\n\r\n # Subset excluding arr[l]\r\n subsetSums(arr, l + 1, r, d, sum)\r\n return d\r\n\r\n\r\ndef print_factors(x):\r\n factors = []\r\n for i in range(1, x + 1):\r\n if x % i == 0:\r\n factors.append(i)\r\n return (factors)\r\n\r\n\r\n# -----------------------------------------------\r\ndef calc(X, d, ans, D):\r\n # print(X,d)\r\n if len(X) == 0:\r\n return\r\n\r\n i = X.index(max(X))\r\n ans[D[max(X)]] = d\r\n\r\n Y = X[:i]\r\n Z = X[i + 1:]\r\n\r\n calc(Y, d + 1, ans, D)\r\n calc(Z, d + 1, ans, D)\r\n\r\n\r\n# ---------------------------------------\r\n\r\ndef factorization(n, l):\r\n c = n\r\n if prime(n) == True:\r\n l.append(n)\r\n return l\r\n for i in range(2, c):\r\n if n == 1:\r\n break\r\n while n % i == 0:\r\n l.append(i)\r\n n = n // i\r\n return l\r\n\r\n\r\n# endregion------------------------------\r\ndef good(b):\r\n l = []\r\n i = 0\r\n while (len(b) != 0):\r\n if b[i] < b[len(b) - 1 - i]:\r\n l.append(b[i])\r\n b.remove(b[i])\r\n else:\r\n l.append(b[len(b) - 1 - i])\r\n b.remove(b[len(b) - 1 - i])\r\n if l == sorted(l):\r\n # print(l)\r\n return True\r\n return False\r\n\r\n\r\n# arr=[]\r\n# print(good(arr))\r\ndef generate(st, s):\r\n if len(s) == 0:\r\n return\r\n\r\n # If current string is not already present.\r\n if s not in st:\r\n st.add(s)\r\n\r\n # Traverse current string, one by one\r\n # remove every character and recur.\r\n for i in range(len(s)):\r\n t = list(s).copy()\r\n t.remove(s[i])\r\n t = ''.join(t)\r\n generate(st, t)\r\n return\r\n#=--------------------------------------------longest increasing subsequence\r\n\r\ndef largestincreasingsubsequence(A):\r\n l = [1]*len(A)\r\n sub=[]\r\n for i in range(1,len(l)):\r\n for k in range(i):\r\n if A[k] number\r\n ans = ans - increment\r\n increment = increment / 10\r\n return ans\r\n\r\ndef countRectangles(l, w):\r\n squareSide = math.gcd(l, w)\r\n return int((l * w) / (squareSide * squareSide))\r\n\r\n# Function that count the\r\n# total numbersProgram between L\r\n# and R which have all the\r\n# digit same\r\ndef count_same_digit(L, R):\r\n tmp = 0\r\n ans = 0\r\n n = int(math.log10(R) + 1)\r\n for i in range(0, n):\r\n # tmp has all digits as 1\r\n tmp = tmp * 10 + 1\r\n for j in range(1, 10):\r\n\r\n if (L <= (tmp * j) and (tmp * j) <= R):\r\n #print(tmp*j)\r\n # Increment the required count\r\n ans += 1\r\n return ans\r\n#----------------------------------print k closest number of a number in an array\r\ndef findCrossOver(arr, low, high, x):\r\n # Base cases\r\n if (arr[high] <= x): # x is greater than all\r\n return high\r\n if (arr[low] > x): # x is smaller than all\r\n return low\r\n # Find the middle point\r\n mid = (low + high) // 2\r\n if (arr[mid] <= x and arr[mid + 1] > x):\r\n return mid\r\n if (arr[mid] < x):\r\n return findCrossOver(arr, mid + 1, high, x)\r\n return findCrossOver(arr, low, mid - 1, x)\r\ndef Kclosest(arr, x, k, n,ans):\r\n # Find the crossover point\r\n l = findCrossOver(arr, 0, n - 1, x)\r\n r = l + 1\r\n count = 0\r\n if (arr[l] == x):\r\n l -= 1\r\n #print(l)\r\n while (l >= 0 and r < n and count < k):\r\n if (x - arr[l] < arr[r] - x):\r\n ans.append(arr[l])\r\n l -= 1\r\n else:\r\n ans.append(arr[r])\r\n r += 1\r\n count += 1\r\n while (count < k and l >= 0):\r\n ans.append(arr[l])\r\n l -= 1\r\n count += 1\r\n while (count < k and r < n):\r\n ans.append(arr[r])\r\n r += 1\r\n count += 1\r\n return ans\r\n#---------------------------------------------------------------\r\n\r\ndef calcSum(arr, n, k):\r\n # Initialize sum = 0\r\n l=[]\r\n sum=0\r\n # Consider first subarray of size k\r\n # Store the sum of elements\r\n for i in range(k):\r\n sum += arr[i]\r\n\r\n # Print the current sum\r\n l.append(sum)\r\n\r\n # Consider every subarray of size k\r\n # Remove first element and add current\r\n # element to the window\r\n for i in range(k, n):\r\n # Add the element which enters\r\n # into the window and substract\r\n # the element which pops out from\r\n # the window of the size K\r\n sum = (sum - arr[i - k]) + arr[i]\r\n\r\n # Print the sum of subarray\r\n l.append(sum)\r\n\r\n return l\r\n\r\n\"\"\"\r\ndef dfs(root,nodeVal,nodeConnection,visited):\r\n leftVal = nodeVal[root][0]\r\n rightVal = nodeVal[root][1]\r\n solution = []\r\n if nodeConnection[root]:\r\n visited.add(root)\r\n for i in nodeConnection[root]:\r\n if i not in visited:\r\n solution.append(dfs(i,nodeVal,nodeConnection,visited))\r\n # print(\"solution\",solution)\r\n leftMax = 0\r\n rightMax = 0\r\n for i in solution:\r\n l, r = i\r\n leftMax += max(abs(leftVal - l[0]) + l[1], abs(leftVal - r[0]) + r[1])\r\n rightMax += max(abs(rightVal - l[0]) + l[1], abs(rightVal - r[0]) + r[1])\r\n # print(root,\"return->\",(leftVal,leftMax),(rightVal,rightMax))\r\n return ((leftVal, leftMax), (rightVal, rightMax))\r\n else:\r\n # ((left,maxVal),(right,maxVal))\r\n return ((leftVal, 0), (rightVal, 0))\r\n\"\"\"\r\n\"\"\"\r\ndef luckynumber(x,n,a):\r\n if x >0:\r\n a.append(x)\r\n if x>10**9:\r\n return a\r\n else:\r\n if x < 1e12:\r\n luckynumber(x * 10 + 4,n,a)\r\n luckynumber(x * 10 + 7,n,a)\r\ndef lcm(a,b):\r\n return (a*b)//math.gcd(a,b)\r\n\r\ndef query1(l, r):\r\n if l >= r:\r\n return -1\r\n print('?', l + 1, r + 1)\r\n sys.stdout.flush()\r\n return int(input()) - 1\r\ndef answer(p):\r\n print('!', p + 1)\r\n sys.stdout.flush()\r\n exit()\r\n\r\n#---------------------count number of primes\r\n\"\"\"\r\nimport math\r\nMAX = 10**5\r\nprefix = [0] * (MAX + 1)\r\ndef buildPrefix():\r\n prime = [1] * (MAX + 1)\r\n p = 2\r\n while (p * p <= MAX):\r\n if (prime[p] == 1):\r\n i = p * 2\r\n while (i <= MAX):\r\n prime[i] = 0\r\n i += p\r\n p += 1\r\n for p in range(2, MAX + 1):\r\n prefix[p] = prefix[p - 1]\r\n if (prime[p] == 1):\r\n prefix[p] += 1\r\ndef query(L, R):\r\n return prefix[R] - prefix[L - 1]\r\n#buildPrefix()\r\n\r\ndef maxSubArraySum(a, size):\r\n max_so_far = a[0]\r\n curr_max = a[0]\r\n for i in range(1, size):\r\n curr_max = max(a[i], curr_max + a[i])\r\n max_so_far = max(max_so_far, curr_max)\r\n return max_so_far\r\n\r\ndef solve(n,k):\r\n if n==1 and k==1:\r\n return 0\r\n mid=(2**(n-1))//2\r\n if k<=mid:\r\n return solve(n-1,k)\r\n else:\r\n return solve(n-1,k-(mid))==0\r\n\r\n#------------------print subset of strings\r\ndef solvr(s,p):\r\n if len(s)==0:\r\n print(p,end=\" \")\r\n return\r\n op1=p\r\n op2=p+s[0]\r\n s=s[1:]\r\n solvr(s,op1)\r\n solvr(s,op2)\r\n return\r\n#-------------------------------------balanced paranthesis\r\ndef paranthesis(n,m,ans,l):\r\n if n==0 and m==0:\r\n print(ans)\r\n return\r\n if n!=0:\r\n op1=ans+\"(\"\r\n paranthesis(n-1,m,op1,l)\r\n if m>n:\r\n op2=ans+\")\"\r\n paranthesis(n,m-1,op2,l)\r\n\"\"\"\r\nclass node:\r\n def __init__(self,data):\r\n self.data=data\r\n self.next=None\r\nclass linkedlis:\r\n def __init__(self):\r\n self.head=None\r\n def printlis(self):\r\n temp=self.head\r\n while(temp):\r\n print(temp.data,end=\" \")\r\n temp=temp.next\r\n def pushfirst(self,new_data):\r\n new_node=node(new_data)\r\n new_node.next=self.head\r\n self.head=new_node\r\n def pushmid(self,previous_node,new_data):\r\n new_node=node(new_data)\r\n if previous_node==None:\r\n print(\"call pushfirst function if it is the the start otherwise raise an error.\")\r\n new_node.next=previous_node.next\r\n previous_node.next=new_node\r\n def pushlast(self,new_data):\r\n new_node=node(new_data)\r\n if self.head==None:\r\n self.head=new_node\r\n return\r\n last=self.head\r\n while(last.next!=None):\r\n last=last.next\r\n last.next=new_node\r\n def delete_node(self,key):\r\n pass\r\nif __name__ == '__main__':\r\n l=linkedlis()\r\n l.head= node(1)\r\n p = node(2)\r\n pp = node(4)\r\n l.head.next = p\r\n p.next = pp\r\n #print(l.head)\r\n l.pushmid(p, 3)\r\n l.pushlast(5)\r\n l.pushfirst(0)\r\n #l.printlis()\r\n #print(l.head.data)\r\n\"\"\"\r\n\"\"\"\r\ndef main():\r\n n=1000\r\n l=[12]*1000\r\n sum=12*100\r\n dp=[[False]*(sum+1) for i in range(n+1)]\r\n for i in range(n+1):\r\n dp[i][0]=True\r\n for i in range(1,n+1):\r\n for j in range(1,sum+1):\r\n if j=arr[i]:\r\n stack.pop()\r\n else:\r\n break\r\n if len(stack)==0:\r\n ans.append(n)\r\n else:\r\n ans.append(stack[-1][1])\r\n stack.append([arr[i],i])\r\n ans.reverse()\r\n return ans\r\ndef lse(arr,n):\r\n stack=[]\r\n ans=[]\r\n for i in range(n):\r\n if len(stack)==0:\r\n ans.append(-1)\r\n else:\r\n while(len(stack)!=0):\r\n if stack[-1][0]>=arr[i]:\r\n stack.pop()\r\n else:\r\n break\r\n if len(stack)==0:\r\n ans.append(-1)\r\n else:\r\n ans.append(stack[-1][1])\r\n stack.append([arr[i],i])\r\n return ans\r\n\"\"\"\r\n\"\"\"\r\ndef lcs(s,r):\r\n rr=len(r)\r\n ss=len(s)\r\n l=[[0]*(rr+1) for i in range(ss+1)]\r\n for i in range(ss+1):\r\n for j in range(rr+1):\r\n if i==0 and j==0:\r\n l[i][j]=0\r\n elif s[i-1]==r[j-1]:\r\n l[i][j]=l[i-1][j-1]+1\r\n else:\r\n l[i][j] =max(l[i-1][j],l[i][j-1])\r\n return l[ss][rr]\r\n\"\"\"\r\ndef subsetsum(arr,sum,len):\r\n dp=[[False]*(sum+1) for i in range(len+1)]\r\n for i in range(len+1):\r\n dp[i][0]=True\r\n for i in range(1,len+1):\r\n for j in range(1,sum+1):\r\n if j==0:\r\n dp[i][j]=True\r\n elif arr[i-1]>j:\r\n dp[i][j]=dp[i-1][j]\r\n else:\r\n dp[i][j]=dp[i-1][j] or dp[i-1][j-arr[i-1]]\r\n #print(dp)\r\n return dp[len][sum]\r\n#print(subsetsum([3,9,12],12,3))\r\ndef main():\r\n t=1\r\n #t=inpu()\r\n for _ in range(t):\r\n n=inpu()\r\n arr=lis()\r\n arr=arr\r\n if sum(arr)%2!=0:\r\n print(0)\r\n continue\r\n else:\r\n if subsetsum(arr,sum(arr)//2,len(arr))==True:\r\n print(1)\r\n pows = [-1] * 11\r\n for i in range(n):\r\n if arr[i]%2!=0:\r\n print(i+1)\r\n break\r\n else:\r\n print(0)\r\n else:\r\n print(0)\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "def inp():\r\n return [int(a) for a in input().split()]\r\ndef gcd(x, y):\r\n if y:\r\n return gcd(y, x % y)\r\n else:\r\n return x\r\ndef bad(array):\r\n st = set()\r\n st.add(0)\r\n for i in array:\r\n st1 = set()\r\n for j in st:\r\n st1.add(i + j)\r\n st = st.union(st1)\r\n if sum(array) // 2 in st:\r\n return True\r\n return False\r\nind = []\r\nn = int(input())\r\na = inp()\r\nif sum(a) % 2 == 1:\r\n print(0)\r\nelse:\r\n prev = a[0]\r\n for i in range(1, n):\r\n g = gcd(prev, a[i])\r\n prev = a[i]\r\n for i in range(n):\r\n a[i] //= g\r\n if bad(a):\r\n for i in range(n):\r\n if a[i] % 2:\r\n print(1)\r\n print(i + 1)\r\n break\r\n else:\r\n print(0)\r\n"}, {"source_code": "#!/bin/python3\r\n\r\nimport math\r\nimport os\r\nimport random\r\nimport re\r\nimport sys\r\n\r\n#\r\n# Complete the 'timeConversion' function below.\r\n#\r\n# The function is expected to return a STRING.\r\n# The function accepts STRING s as parameter.\r\n#\r\nif __name__ == '__main__':\r\n n=int(input())\r\n a = list(map(int,(input().split(' '))))\r\n temp = [[0]*(2000*n+1)]*2\r\n temp[1][0] = 1\r\n temp1 = 0\r\n for i in range(0,n):\r\n temp1+=a[i]\r\n for j in range(0,2000*n+1):\r\n if j>=a[i]:\r\n temp[(i%2)][j]|=temp[(i%2)^1][j-a[i]]\r\n temp[(i%2)][j]|=temp[(i%2)^1][j]\r\n pos = 0\r\n if ((temp1%2==1) or (temp1%2==0 and temp[(n%2)^1][int(temp1/2)]==0)):\r\n print(0)\r\n else:\r\n print(1)\r\n temp=0\r\n ind = 0\r\n for i in range(0,n):\r\n temp1=0\r\n while(a[i]%2):\r\n a[i]/=2\r\n temp1+=1\r\n if temp1>temp:\r\n temp=temp1\r\n ind=i\r\n print(ind+1)\r\n \r\n \r\n"}, {"source_code": "\r\nfrom bisect import bisect,bisect_left\r\n\r\nfrom collections import *\r\nfrom math import gcd,ceil,sqrt,floor,inf\r\nfrom heapq import *\r\nfrom itertools import *\r\nfrom operator import add,mul,sub,xor,truediv,floordiv\r\nfrom functools import *\r\n\r\n#------------------------------------------------------------------------\r\nimport os\r\nimport sys\r\n\r\nfrom io import BytesIO, IOBase\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\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 RL(): return map(int, sys.stdin.readline().split())\r\ndef RLL(): return list(map(int, sys.stdin.readline().split()))\r\ndef N(): return int(input())\r\ndef A(n):return [0]*n\r\ndef AI(n,x): return [x]*n\r\ndef A2(n,m): return [[0]*m for i in range(n)]\r\ndef G(n): return [[] for i in range(n)]\r\ndef GP(it): return [[ch,len(list(g))] for ch,g in groupby(it)]\r\n#------------------------------------------------------------------------\r\n\r\n\r\nfrom types import GeneratorType\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 \r\n return wrappedfunc\r\n\r\nmod=10**9+7\r\nfarr=[1]\r\nifa=[]\r\n \r\ndef fact(x,mod=0):\r\n if mod:\r\n while x>=len(farr):\r\n farr.append(farr[-1]*len(farr)%mod)\r\n else:\r\n while x>=len(farr):\r\n farr.append(farr[-1]*len(farr))\r\n return farr[x]\r\n \r\ndef ifact(x,mod):\r\n global ifa\r\n fact(x,mod)\r\n ifa.append(pow(farr[-1],mod-2,mod))\r\n for i in range(x,0,-1):\r\n ifa.append(ifa[-1]*i%mod)\r\n ifa.reverse()\r\n \r\ndef per(i,j,mod=0):\r\n if i=c or b>=c: return floorsum(a%c,b%c,c,n)+b//c*(n+1)+a//c*n*(n+1)//2\r\n m=(a*n+b)//c\r\n return n*m-floorsum(c,c-b-1,a,m-1)\r\n\r\ndef inverse(a,m):\r\n a%=m\r\n if a<=1: return a\r\n return ((1-inverse(m,a)*m)//a)%m\r\n \r\ndef lowbit(n):\r\n return n&-n\r\n \r\nclass BIT:\r\n def __init__(self,arr):\r\n self.arr=arr\r\n self.n=len(arr)-1\r\n \r\n def update(self,x,v):\r\n while x<=self.n:\r\n self.arr[x]+=v\r\n x+=x&-x\r\n \r\n def query(self,x):\r\n ans=0\r\n while x:\r\n ans+=self.arr[x]\r\n x&=x-1\r\n return ans\r\n\r\nclass ST:\r\n def __init__(self,arr):#n!=0\r\n n=len(arr)\r\n mx=n.bit_length()#\u53d6\u4e0d\u5230\r\n self.st=[[0]*mx for i in range(n)]\r\n for i in range(n):\r\n self.st[i][0]=arr[i]\r\n for j in range(1,mx):\r\n for i in range(n-(1<r:return -inf\r\n s=(r+1-l).bit_length()-1\r\n return max(self.st[l][s],self.st[r-(1<self.c[v]:\r\n u,v=v,u\r\n self.c[u]+=self.c[v]\r\n self.c[v]=u\r\n return True\r\n \r\n def size(self,x): return -self.c[self.find(x)]\r\n \r\nclass UFS:#\u79e9+\u8def\u5f84\r\n def __init__(self,n):\r\n self.parent=[i for i in range(n)]\r\n self.ranks=[0]*n\r\n \r\n def find(self,x):\r\n if x!=self.parent[x]:\r\n self.parent[x]=self.find(self.parent[x])\r\n return self.parent[x]\r\n \r\n def union(self,u,v):\r\n pu,pv=self.find(u),self.find(v)\r\n if pu==pv:\r\n return False\r\n if self.ranks[pu]>=self.ranks[pv]:\r\n self.parent[pv]=pu\r\n if self.ranks[pv]==self.ranks[pu]:\r\n self.ranks[pu]+=1\r\n else:\r\n self.parent[pu]=pv\r\n \r\ndef Prime(n):\r\n c=0\r\n prime=[]\r\n flag=[0]*(n+1) \r\n for i in range(2,n+1):\r\n if not flag[i]:\r\n prime.append(i)\r\n c+=1\r\n for j in range(c):\r\n if i*prime[j]>n: break\r\n flag[i*prime[j]]=prime[j]\r\n if i%prime[j]==0: break\r\n return flag\r\n \r\ndef dij(s,graph):\r\n d={}\r\n d[s]=0\r\n heap=[(0,s)]\r\n seen=set()\r\n while heap:\r\n dis,u=heappop(heap)\r\n if u in seen:\r\n continue\r\n seen.add(u)\r\n for v,w in graph[u]:\r\n if v not in d or d[v]>d[u]+w:\r\n d[v]=d[u]+w\r\n heappush(heap,(d[v],v))\r\n return d\r\n\r\ndef bell(s,g):#bellman-Ford\r\n dis=AI(n,inf)\r\n dis[s]=0\r\n for i in range(n-1):\r\n for u,v,w in edge:\r\n if dis[v]>dis[u]+w:\r\n dis[v]=dis[u]+w\r\n change=A(n)\r\n for i in range(n):\r\n for u,v,w in edge:\r\n if dis[v]>dis[u]+w:\r\n dis[v]=dis[u]+w\r\n change[v]=1\r\n return dis\r\n\r\ndef lcm(a,b): return a*b//gcd(a,b)\r\ndef lis(nums):\r\n res=[]\r\n for k in nums:\r\n i=bisect.bisect_left(res,k)\r\n if i==len(res):\r\n res.append(k)\r\n else:\r\n res[i]=k\r\n return len(res)\r\n\r\ndef RP(nums):#\u9006\u5e8f\u5bf9\r\n n = len(nums)\r\n s=set(nums)\r\n d={}\r\n for i,k in enumerate(sorted(s),1):\r\n d[k]=i\r\n bi=BIT([0]*(len(s)+1))\r\n ans=0\r\n for i in range(n-1,-1,-1):\r\n ans+=bi.query(d[nums[i]]-1)\r\n bi.update(d[nums[i]],1)\r\n return ans\r\n \r\nclass DLN:\r\n def __init__(self,val):\r\n self.val=val\r\n self.pre=None\r\n self.next=None\r\n\r\ndef nb(i,j,n,m):\r\n for ni,nj in [[i+1,j],[i-1,j],[i,j-1],[i,j+1]]:\r\n if 0<=ni>(s//2):\r\n print(0)\r\n exit()\r\n print(1)\r\n g=G(12)\r\n for i,x in enumerate(a,1):\r\n c=0\r\n while not x&1:\r\n x//=2\r\n c+=1\r\n g[c].append(i)\r\n for i in range(12):\r\n if g[i]:\r\n print(g[i][0])\r\n exit()\r\n #print(ans)\r\n\r\n\r\n\r\n \r\n''' \r\nsys.setrecursionlimit(200000)\r\nimport threading\r\nthreading.stack_size(10**8)\r\nt=threading.Thr\r\nead(target=main)\r\nt.start()\r\nt.join()\r\n'''\r\n\r\n"}, {"source_code": "def canPartition(nums):\r\n target, n = sum(nums), len(nums)\r\n if target & 1:\r\n return False\r\n target >>= 1\r\n dp = [True] + [False]*target\r\n for x in nums:\r\n dp = [dp[s] or (s >= x and dp[s-x]) for s in range(target+1)]\r\n if dp[target]:\r\n return True\r\n return False\r\n\r\n\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\nres = []\r\n\r\nwhile canPartition(arr):\r\n tmp = []\r\n tarr = arr\r\n print(tarr)\r\n for i in range(n):\r\n t = arr[:i] + arr[i+1:]\r\n if not canPartition(t):\r\n tmp.append(i)\r\n\r\n arr = arr[:min(tmp)] + arr[min(tmp)+1:]\r\n res.append(min(tmp))\r\n\r\nif len(res) > 0:\r\n print(len(res))\r\n print(\" \".join(str(x+1) for x in res))\r\nelse:\r\n print('0')\r\n"}, {"source_code": "import sys\r\nimport math\r\nfrom collections import defaultdict,Counter,deque\r\n\r\n# input=sys.stdin.readline\r\n# def print(x):\r\n# sys.stdout.write(str(x)+\"\\n\")\r\n\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\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\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# sys.stdout=open(\"CP3/output.txt\",'w')\r\n# sys.stdin=open(\"CP3/input.txt\",'r')\r\n\r\n# mod=pow(10,9)+7\r\n# t=int(input())\r\n# for i in range(t):\r\n# \tn,q=map(int,input().split())\r\nn=int(input())\r\na=list(map(int,input().split()))\r\ns=0\r\nfor j in a:\r\n\ts+=j\r\nif s&1:\r\n\tprint(0)\r\n\tsys.exit()\r\ns//=2\r\ndp=[0]*(s+1)\r\ndp[0]=1\r\nfor j in range(n):\r\n\tfor k in range(1,s+1):\r\n\t\tif a[j]<=k:\r\n\t\t\tdp[k]|=dp[k-a[j]]\r\n\r\n\tif dp[s]==1:\r\n\t\tbreak\r\nelse:\r\n\tprint(0)\r\n\tsys.exit()\r\n\r\nprint(1)\r\ng=0\r\nfor j in range(n):\r\n\tg=math.gcd(g,a[j])\r\n\r\nfor j in range(n):\r\n\ta[j]//=g\r\n\tif a[j]&1:\r\n\t\tprint(j+1)\r\n\t\tbreak\r\n"}, {"source_code": "# Author : nitish420 --------------------------------------------------------------------\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\n\r\ndef knapsack(n,wt,w,dp):\r\n\r\n for i in range(n+1):\r\n dp[i][0]=1\r\n\r\n for r in range(1,n+1):\r\n for c in range(1,w+1):\r\n if wt[r-1]<=w:\r\n dp[r][c]=dp[r-1][c] or dp[r-1][c-wt[r-1]]\r\n else:\r\n dp[r][c]=0\r\n\r\n return dp[n][w]\r\n\r\n\r\ndef main():\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n s=sum(a)\r\n\r\n if s%2==0:\r\n\r\n dp=[[0 for _ in range(s//2+1)]for _ in range(n+1)]\r\n\r\n \r\n if knapsack(n,a,s//2,dp):\r\n\r\n # for item in dp:\r\n # print(*item)\r\n\r\n for i,item in enumerate(a):\r\n if item%2:\r\n print(1)\r\n print(i+1)\r\n break\r\n elif dp[n][((s-item)//2)]==0 or ((s-item)//2)%2:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n print(s)\r\n else:\r\n print(0)\r\n else:\r\n print(0)\r\n\r\n# 6\r\n# 2 4 6 8 10 10\r\n\r\n\r\n#----------------------------------------------------------------------------------------\r\ndef nouse0():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse1():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse2():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\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\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\n\r\n\r\ndef nouse3():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse4():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse5():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\r\n\r\n# endregion\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom functools import reduce\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 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\ndef extended_gcd(a, b):\n \"\"\"returns gcd(a, b), s, r s.t. a * s + b * r == gcd(a, b)\"\"\"\n s, old_s = 0, 1\n r, old_r = b, a\n while r:\n q = old_r // r\n old_r, r = r, old_r - q * r\n old_s, s = s, old_s - q * s\n return old_r, old_s, (old_r - old_s * a) // b if b else 0\n\n\ngcdm = lambda *args: reduce(gcd, args, 0)\n\nlcm = lambda a, b: a * b // gcd(a, b)\n\nlcmm = lambda *args: reduce(lcm, args, 1)\n\n\ndef main():\n n = int(input())\n a = [int(ai) for ai in input().split()]\n g = gcdm(*a)\n a = [ai // g for ai in a]\n\n odd_idx = 0\n for i in range(n):\n if a[i] % 2:\n odd_idx = i\n break\n\n s = sum(a)\n if s % 2:\n print(0)\n return\n\n needed = s // 2\n\n dp = [0] * (needed + 1)\n dp[0] = 1\n for i in range(n):\n for j in range(needed + 1):\n dp[j] = dp[j] or (dp[j - a[i]] if j - a[i] > - 1 else 0)\n\n if dp[-1]:\n print(1)\n print(odd_idx + 1)\n else:\n print(0)\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": "# ------------------- 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\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\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\ndef prod(a, mod=10**9+7):\r\n\tans = 1\r\n\tfor each in a:\r\n\t\tans = (ans * each) % mod\r\n\treturn ans\r\n\r\ndef gcd(x, y):\r\n\twhile y:\r\n\t\tx, y = y, x % y\r\n\treturn x\r\n\r\ndef lcm(a, b): return a * b // gcd(a, b)\r\n\r\ndef binary(x, length=16):\r\n\ty = bin(x)[2:]\r\n\treturn y if len(y) >= length else \"0\" * (length - len(y)) + y\r\n\r\nfor _ in range(int(input()) if not True else 1):\r\n\tn = int(input())\r\n\t#n, k = map(int, input().split())\r\n\t#a, b = map(int, input().split())\r\n\t#c, d = map(int, input().split())\r\n\ta = list(map(int, input().split()))\r\n\t#b = list(map(int, input().split()))\r\n\t#s = input()\r\n\tdef f(n, a):\r\n\t\ttotal = sum(a)\r\n\t\tif total % 2:\r\n\t\t\tprint(0)\r\n\t\t\tquit()\r\n\t\tmod4 = (total // 2) % 4\r\n\t\tdp = [-1]*(total // 2 + 1)\r\n\t\tdp[0] = 0\r\n\t\tfor i in range(n):\r\n\t\t\tfor j in range(0, total//2 + 1):\r\n\t\t\t\tif dp[j] != i+1 and dp[j] != -1 and a[i] + j <= total//2:\r\n\t\t\t\t\tdp[a[i] + j] = i+1\r\n\t\tif dp[total//2] == -1:\r\n\t\t\tprint(0)\r\n\t\t\tquit()\r\n\t\tfor i in range(n):\r\n\t\t\tif a[i] % 2:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\tquit()\r\n\r\n\t\tif mod4 == 1 or mod4 == 3:\r\n\t\t\tprint(0)\r\n\t\t\tquit()\r\n\r\n\t\t# all elements divisible by 2\r\n\t\tfor i in range(n):\r\n\t\t\tif a[i] % 4 == 2:\r\n\t\t\t\tprint(1)\r\n\t\t\t\tprint(i+1)\r\n\t\t\t\tquit()\r\n\t\ta = [a[i]//4 for i in range(n)]\r\n\t\tf(n, a)\r\n\tf(n, a)\r\n\r\n\r\n"}, {"source_code": "from sys import stdin,stdout\r\nstdin.readline\r\ndef mp(): return list(map(int, stdin.readline().strip().split()))\r\ndef it():return int(stdin.readline().strip())\r\nfrom collections import defaultdict as dd,Counter as C,deque\r\nfrom math import ceil,gcd,sqrt,factorial,log2,floor\r\n\r\nn = it()\r\nl=mp()\r\n\r\nsu=sum(l)\r\n\r\nif su&1:\r\n\tprint(0)\r\nelse:\r\n\tt=[[False for i in range(su//2+1)] for _ in range(n+1)]\r\n\r\n\tfor i in range(n+1):\r\n\t\tfor j in range(su//2+1):\r\n\t\t\tif j==0:\r\n\t\t\t\tt[i][j]=True\r\n\r\n\tfor i in range(1,n+1):\r\n\t\tfor j in range(1,su//2+1):\r\n\r\n\t\t\tif j >= l[i-1]:\r\n\t\t\t\tt[i][j]=(t[i-1][j-l[i-1]] or t[i-1][j])\r\n\r\n\t\t\telse:\r\n\t\t\t\tt[i][j]=t[i-1][j]\r\n\t# print((t[n][su//2]))\r\n\tif (t[n][su//2]):\r\n\t\tind = -1\r\n\t\tfor i in range(n):\r\n\t\t\tif l[i]&1:\r\n\t\t\t\tind = i\r\n\t\t\t\tbreak\r\n\t\tif ind != -1:\r\n\t\t\tprint(1)\r\n\t\t\tprint(ind+1)\r\n\t\telse:\r\n\t\t\twhile 1:\r\n\t\t\t\tflag =0\r\n\t\t\t\tflag=0\r\n\t\t\t\tind = -1\r\n\t\t\t\tfor i in range(n):\r\n\t\t\t\t\tif l[i]&1:\r\n\t\t\t\t\t\tind = i\r\n\t\t\t\t\t\tflag =1\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\telse:\r\n\t\t\t\t\t\tl[i]//=2\r\n\t\t\t\tif flag:\r\n\t\t\t\t\tbreak\r\n\t\t\tprint(1)\r\n\t\t\tprint(ind+1)\r\n\r\n"}, {"source_code": " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n \r\n# mandatory imports\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import log2, ceil, sqrt, gcd, log\r\n\r\n# optional imports\r\n# from itertools import permutations\r\n# from functools import cmp_to_key # for adding custom comparator\r\n# from fractions import Fraction\r\nfrom collections import *\r\nfrom bisect import *\r\n# from __future__ import print_function # for PyPy2\r\nfrom heapq import *\r\nBUFSIZE = 8192\r\n\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\ng = lambda : input().strip()\r\ngl = lambda : g().split()\r\ngil = lambda : [int(var) for var in gl()]\r\ngfl = lambda : [float(var) for var in gl()]\r\ngcl = lambda : list(g())\r\ngbs = lambda : [int(var) for var in g()]\r\nrr = lambda x : reversed(range(x)) \r\nmod = int(1e9)+7\r\ninf = float(\"inf\")\r\n\r\nn, = gil()\r\na = gil()\r\nsm = sum(a)\r\n\r\ndef iszero(a, n):\r\n dp = [n]*((sm//2) + 1)\r\n dp[0] = -1\r\n for i in range(len(dp)):\r\n for j in range(dp[i]+1, n):\r\n if i + a[j] < len(dp) and dp[i+a[j]] > j:\r\n dp[i+a[j]] = j\r\n\r\n # print(*dp)\r\n return dp[-1] == n\r\n\r\nif sm&1 or iszero(a, n):\r\n print(0)\r\n exit()\r\nidx = 0\r\np = int(log2(a[0]))\r\n\r\nfor i in range(1, n):\r\n pi = int(log2(a[i]))\r\n if pi < p:\r\n idx = i\r\n p = pi\r\n\r\nprint(1)\r\nprint(idx+1)"}, {"source_code": "n=int(input())\r\nm=[int(i) for i in input().split()]\r\ns=sum(m)\r\nfor i in range(len(m)):\r\n m[i]=[m[i],i]\r\n\r\nif s%2!=0:\r\n print(0)\r\n exit()\r\na=0\r\nb=0\r\nm.sort(key=lambda x: x[0], reverse=True)\r\nc=1\r\nans=[]\r\nwhile True:\r\n a=0\r\n b=0\r\n for i in range(len(m)):\r\n if a<=b and a+m[i][0]<=s//2:\r\n a+=m[i][0]\r\n else:\r\n b+=m[i][0]\r\n if b!=a:\r\n break\r\n t=None\r\n mm=m[0][0]\r\n for i in range(len(m)):\r\n if m[i][0] < mm:\r\n j=i\r\n t=m[i][1]\r\n mm=m[i][0]\r\n m.pop(j)\r\n ans.append(t)\r\nprint(len(ans),*ans,sep='\\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\n\r\ndef findPartiion(a,n):\r\n s = sum(a)\r\n if s % 2:\r\n return 0\r\n part = [0] * (s // 2 + 1)\r\n part[0]=1\r\n for i in range(n):\r\n for j in range(s // 2, a[i] - 1, -1):\r\n part[j]|=part[j-a[i]]\r\n return part[s//2]\r\n\r\ndef main():\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n if sum(a)%2:\r\n print(0)\r\n elif not findPartiion(a,len(a)):\r\n print(0)\r\n else:\r\n o = 0\r\n for i in a:\r\n if i % 2:\r\n o += 1\r\n if o % 2:\r\n print(0)\r\n else:\r\n print(1)\r\n for i in range(n):\r\n if a[i] % 2:\r\n print(i + 1)\r\n return\r\n for i in range(n):\r\n f=1\r\n for j in range(n):\r\n if i!=j:\r\n for k in range(n):\r\n if j!=k:\r\n if a[i]==2*(a[j]-a[k]):\r\n f=0\r\n if f:\r\n print(i+1)\r\n return\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\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\r\ninput = sys.stdin.readline\r\nfor _ in range(1):\r\n def canPartition(nums):\r\n a=sum(nums)\r\n n=len(nums)\r\n d={}\r\n def helper(curr,s):\r\n if curr==n:\r\n if s==a//2:\r\n return True\r\n return False\r\n if (curr,s) in d:\r\n return d[(curr,s)]\r\n ans=helper(curr+1,s+nums[curr]) or helper(curr+1,s)\r\n d[(curr,s)]=ans\r\n return ans \r\n if a%2:\r\n return False\r\n return helper(0,0)\r\n n=int(input())\r\n arr=[int(x) for x in input().split()]\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n continue\r\n if canPartition(arr)==False:\r\n print(0)\r\n continue\r\n else:\r\n odd=-1\r\n temp=[]\r\n for i in range(n):\r\n if arr[i]%2:\r\n odd=i\r\n if arr[i]%2==0 and (arr[i]//2)%2:\r\n temp.append(i)\r\n if odd>=0:\r\n print(1)\r\n print(odd+1)\r\n continue\r\n if temp:\r\n print(1)\r\n print(temp[0]+1)\r\n else:\r\n d={}\r\n for i in range(n):\r\n if arr[i] in d:\r\n d[arr[i]].append(i+1)\r\n else:\r\n d[arr[i]]=[i+1]\r\n for i in sorted(d.keys()):\r\n if len(d[i])%2==0:\r\n print(1)\r\n print(d[i][0])\r\n exit()"}, {"source_code": "def lol(s,a,n,d):\r\n if (s,n) in d:\r\n return d[(s,n)]\r\n \r\n if s==0:\r\n d[(s,n)]=True\r\n return True\r\n if n==0 and s!=0:\r\n d[(s,n)]=False\r\n return False\r\n if a[n-1]>s:\r\n return lol(s,a,n-1,d)\r\n z=lol(s,a,n-1,d)\r\n y=lol(s-a[n-1],a,n-1,d)\r\n d[(s,n)]=z or y\r\n return z or y \r\nn=int(input())\r\na=list(map(int,input().split()))\r\ns=0\r\nf=0\r\nd={}\r\nfor i in a:\r\n s+=i\r\nif s%2==1:\r\n print(0)\r\nelse:\r\n if lol(s//2,a,n,d):\r\n f=1\r\n else:\r\n print(0)\r\nif f==1:\r\n ans=1\r\n for i in range(len(a)):\r\n if a[i]%2==1:\r\n print(ans)\r\n print(i+1)\r\n f=0\r\n break\r\n if f==1:\r\n d={}\r\n for i in range(len(a)):\r\n ele=a.pop(i)\r\n if not lol(s//2,a,n-1,d):\r\n print(ans)\r\n print(i+1)\r\n break\r\n else:\r\n a.insert(i,ele)\r\n \r\n"}, {"source_code": "def inp():\r\n return [int(a) for a in input().split()]\r\ndef gcd(x, y):\r\n if y:\r\n return gcd(y, x % y)\r\n else:\r\n return x\r\nind = []\r\nn = int(input())\r\na = inp()\r\nif sum(a) % 2 == 1:\r\n print(0)\r\nelse:\r\n prev = a[0]\r\n for i in range(1, n):\r\n g = gcd(prev, a[i])\r\n prev = a[i]\r\n for i in range(n):\r\n a[i] /= g\r\n while sum(a) % 2 == 0:\r\n for i in range(n):\r\n if a[i] % 2:\r\n ind.append(i + 1)\r\n del a[i]\r\n n -= 1\r\n break\r\n print(len(ind))\r\n print(*ind)\r\n"}, {"source_code": "import sys\r\nreader = (s.rstrip() for s in sys.stdin)\r\ninput = reader.__next__\r\n\r\n\r\nn = int(input())\r\nlst = list(map(int,input().split()))\r\n\r\n\r\nsumN = sum(lst)\r\n\r\nif sumN%2:\r\n print(0)\r\nelse:\r\n ans = 0\r\n for idx,ele in enumerate(lst):\r\n if ele%2:\r\n ans = idx + 1\r\n break\r\n\r\n if ans:\r\n print(1)\r\n print(ans)\r\n elif sumN//2%2:\r\n print(0)\r\n else:\r\n for idx,ele in enumerate(lst):\r\n if ((sumN-ele)//2)%2:\r\n ans = idx + 1\r\n break\r\n print(1)\r\n print(ans)\r\n\r\n#\"{} {} {}\".format(maxele,minele,minele)\r\n\r\n# yield \" \".join([str(x) for x in ans])\r\n# 2 4 4 2\r\n\r\n# 2*10\r\n"}, {"source_code": "import math\r\ndef fun(a,n):\r\n d=[{} for i in range(n)]\r\n d[0][0]=True\r\n d[0][a[0]]=True\r\n\r\n d[-1][sum(a)//2]=False\r\n \r\n for i in range(n-1):\r\n for j in d[i]:\r\n d[i+1][j+a[i+1]]=True\r\n d[i+1][j]=True\r\n #print(d)\r\n return d[-1][sum(a)//2] \r\n \r\n\r\nn=int(input())\r\na=[int(x) for x in input().split()]\r\n\r\nif sum(a)%2==1:\r\n print(0)\r\n\r\nelse:\r\n if fun(a,n):\r\n print(1)\r\n mn=int(math.log(a[0],2))\r\n ans=0\r\n for i in range(n):\r\n if int(math.log(a[i],2))=0:\n\t\t\t\tif prev[j-a[i]][0]:\n\t\t\t\t\tdp[j][0] = True\n\t\t\t\t\tif (prev[j-a[i]][1]+1)prev[i][1]:\n\t\t\t\t\tidx = i\n\t\t\t\tmin1 = min(min1,prev[i][1])\n\t\tprint(len(ans[idx]))\n\t\tprint(*ans[idx])\n\telse:\n\t\tprint(0)\nelse:\n\tprint(0)\n\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nimport heapq\r\nhpush = heapq.heappush\r\nhpop = heapq.heappop\r\nn = int(input())\r\na = list(map(int, input().split()))\r\nsm = sum(a)\r\nif sm % 2:\r\n print(0)\r\n exit(0)\r\ndp = [0] * (sm // 2 + 1)\r\ndp[0] = 1\r\nodd = 0\r\nfor i in range(n):\r\n x = a[i]\r\n if x % 2: odd = i + 1\r\n for i in range(sm, -1, -1):\r\n if i + x <= sm // 2:\r\n dp[i + x] |= dp[i]\r\nif dp[sm // 2] == 0:\r\n print(0)\r\n exit(0)\r\nif odd:\r\n print(1)\r\n print(odd)\r\n exit(0)\r\n\r\nh = [(-a[i], i) for i in range(n)]\r\nheapq.heapify(h)\r\nres = set()\r\nwhile len(h):\r\n x, i = hpop(h)\r\n x = -x\r\n res.add(i + 1)\r\n sm -= x\r\n if dp[sm // 2] == 0: break\r\n dp = [0] * (sm // 2 + 1)\r\n dp[0] = 1\r\n for i in range(n):\r\n x = a[i]\r\n if i + 1 in res: continue\r\n for i in range(sm, -1, -1):\r\n if i + x <= sm // 2:\r\n dp[i + x] |= dp[i]\r\n if dp[sm // 2] == 0: break\r\n #print(sm, res, dp, h)\r\nprint(len(res))\r\nres = sorted(res)\r\nfor r in res: print(r)"}, {"source_code": " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n \r\n# mandatory imports\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import log2, ceil, sqrt, gcd, log\r\n\r\n# optional imports\r\n# from itertools import permutations\r\n# from functools import cmp_to_key # for adding custom comparator\r\n# from fractions import Fraction\r\nfrom collections import *\r\nfrom bisect import *\r\n# from __future__ import print_function # for PyPy2\r\nfrom heapq import *\r\nBUFSIZE = 8192\r\n\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\ng = lambda : input().strip()\r\ngl = lambda : g().split()\r\ngil = lambda : [int(var) for var in gl()]\r\ngfl = lambda : [float(var) for var in gl()]\r\ngcl = lambda : list(g())\r\ngbs = lambda : [int(var) for var in g()]\r\nrr = lambda x : reversed(range(x)) \r\nmod = int(1e9)+7\r\ninf = float(\"inf\")\r\n\r\nn, = gil()\r\na = gil()\r\nsm = sum(a)\r\n\r\ndef iszero(a, n):\r\n dp = [n]*((sm//2) + 1)\r\n dp[0] = 0\r\n for i in range(len(dp)):\r\n for j in range(dp[i], n):\r\n if i + a[j] < len(dp) and dp[i+a[j]] > j+1:\r\n dp[i+a[j]] = j+1\r\n\r\n # print(*dp)\r\n return dp[-1] == n\r\n\r\nif sm&1 or iszero(a, n):\r\n print(0)\r\n exit()\r\nidx = 0\r\np = int(log2(a[0]))\r\n\r\nfor i in range(1, n):\r\n pi = int(log2(a[i]))\r\n if pi < p:\r\n idx = i\r\n p = pi\r\n\r\nprint(1)\r\nprint(idx+1)"}, {"source_code": "# 2022-09-04 12:35:14.236880\n# https://codeforces.com/problemset/problem/1516/C\nimport sys\n\n_DEBUG = True\nif not _DEBUG:\n input = sys.stdin.readline\n # print = sys.stdout.write\n\n\ndef proc(n, a):\n sa = sum(a)\n if sa % 2:\n return 0\n\n t = set()\n for e in a:\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if sa // 2 not in t:\n return None\n return a.index(min(a)) + 1\n\n\nn = int(input())\na = list(map(int, input().split()))\nans = proc(n, a)\nif not ans:\n print(0)\nelse:\n print(1)\n print(ans)\n"}, {"source_code": " \r\nfrom bisect import bisect,bisect_left\r\n \r\nfrom collections import *\r\nfrom math import gcd,ceil,sqrt,floor,inf\r\nfrom heapq import *\r\nfrom itertools import *\r\nfrom operator import add,mul,sub,xor,truediv,floordiv\r\nfrom functools import *\r\n \r\n#------------------------------------------------------------------------\r\nimport os\r\nimport sys\r\n \r\nfrom io import BytesIO, IOBase\r\n# region fastio\r\n \r\nBUFSIZE = 8192\r\n \r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\n \r\n#------------------------------------------------------------------------\r\ndef RL(): return map(int, sys.stdin.readline().split())\r\ndef RLL(): return list(map(int, sys.stdin.readline().split()))\r\ndef N(): return int(input())\r\ndef A(n):return [0]*n\r\ndef AI(n,x): return [x]*n\r\ndef A2(n,m): return [[0]*m for i in range(n)]\r\ndef G(n): return [[] for i in range(n)]\r\ndef GP(it): return [[ch,len(list(g))] for ch,g in groupby(it)]\r\n#------------------------------------------------------------------------\r\n \r\n \r\nfrom types import GeneratorType\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 \r\n return wrappedfunc\r\n \r\nmod=10**9+7\r\nfarr=[1]\r\nifa=[]\r\n \r\ndef fact(x,mod=0):\r\n if mod:\r\n while x>=len(farr):\r\n farr.append(farr[-1]*len(farr)%mod)\r\n else:\r\n while x>=len(farr):\r\n farr.append(farr[-1]*len(farr))\r\n return farr[x]\r\n \r\ndef ifact(x,mod):\r\n global ifa\r\n fact(x,mod)\r\n ifa.append(pow(farr[-1],mod-2,mod))\r\n for i in range(x,0,-1):\r\n ifa.append(ifa[-1]*i%mod)\r\n ifa.reverse()\r\n \r\ndef per(i,j,mod=0):\r\n if i=c or b>=c: return floorsum(a%c,b%c,c,n)+b//c*(n+1)+a//c*n*(n+1)//2\r\n m=(a*n+b)//c\r\n return n*m-floorsum(c,c-b-1,a,m-1)\r\n \r\ndef inverse(a,m):\r\n a%=m\r\n if a<=1: return a\r\n return ((1-inverse(m,a)*m)//a)%m\r\n \r\ndef lowbit(n):\r\n return n&-n\r\n \r\nclass BIT:\r\n def __init__(self,arr):\r\n self.arr=arr\r\n self.n=len(arr)-1\r\n \r\n def update(self,x,v):\r\n while x<=self.n:\r\n self.arr[x]+=v\r\n x+=x&-x\r\n \r\n def query(self,x):\r\n ans=0\r\n while x:\r\n ans+=self.arr[x]\r\n x&=x-1\r\n return ans\r\n \r\nclass ST:\r\n def __init__(self,arr):#n!=0\r\n n=len(arr)\r\n mx=n.bit_length()#\u53d6\u4e0d\u5230\r\n self.st=[[0]*mx for i in range(n)]\r\n for i in range(n):\r\n self.st[i][0]=arr[i]\r\n for j in range(1,mx):\r\n for i in range(n-(1<r:return -inf\r\n s=(r+1-l).bit_length()-1\r\n return max(self.st[l][s],self.st[r-(1<self.c[v]:\r\n u,v=v,u\r\n self.c[u]+=self.c[v]\r\n self.c[v]=u\r\n return True\r\n \r\n def size(self,x): return -self.c[self.find(x)]\r\n \r\nclass UFS:#\u79e9+\u8def\u5f84\r\n def __init__(self,n):\r\n self.parent=[i for i in range(n)]\r\n self.ranks=[0]*n\r\n \r\n def find(self,x):\r\n if x!=self.parent[x]:\r\n self.parent[x]=self.find(self.parent[x])\r\n return self.parent[x]\r\n \r\n def union(self,u,v):\r\n pu,pv=self.find(u),self.find(v)\r\n if pu==pv:\r\n return False\r\n if self.ranks[pu]>=self.ranks[pv]:\r\n self.parent[pv]=pu\r\n if self.ranks[pv]==self.ranks[pu]:\r\n self.ranks[pu]+=1\r\n else:\r\n self.parent[pu]=pv\r\n \r\ndef Prime(n):\r\n c=0\r\n prime=[]\r\n flag=[0]*(n+1) \r\n for i in range(2,n+1):\r\n if not flag[i]:\r\n prime.append(i)\r\n c+=1\r\n for j in range(c):\r\n if i*prime[j]>n: break\r\n flag[i*prime[j]]=prime[j]\r\n if i%prime[j]==0: break\r\n return flag\r\n \r\ndef dij(s,graph):\r\n d={}\r\n d[s]=0\r\n heap=[(0,s)]\r\n seen=set()\r\n while heap:\r\n dis,u=heappop(heap)\r\n if u in seen:\r\n continue\r\n seen.add(u)\r\n for v,w in graph[u]:\r\n if v not in d or d[v]>d[u]+w:\r\n d[v]=d[u]+w\r\n heappush(heap,(d[v],v))\r\n return d\r\n \r\ndef bell(s,g):#bellman-Ford\r\n dis=AI(n,inf)\r\n dis[s]=0\r\n for i in range(n-1):\r\n for u,v,w in edge:\r\n if dis[v]>dis[u]+w:\r\n dis[v]=dis[u]+w\r\n change=A(n)\r\n for i in range(n):\r\n for u,v,w in edge:\r\n if dis[v]>dis[u]+w:\r\n dis[v]=dis[u]+w\r\n change[v]=1\r\n return dis\r\n \r\ndef lcm(a,b): return a*b//gcd(a,b)\r\ndef lis(nums):\r\n res=[]\r\n for k in nums:\r\n i=bisect.bisect_left(res,k)\r\n if i==len(res):\r\n res.append(k)\r\n else:\r\n res[i]=k\r\n return len(res)\r\n \r\ndef RP(nums):#\u9006\u5e8f\u5bf9\r\n n = len(nums)\r\n s=set(nums)\r\n d={}\r\n for i,k in enumerate(sorted(s),1):\r\n d[k]=i\r\n bi=BIT([0]*(len(s)+1))\r\n ans=0\r\n for i in range(n-1,-1,-1):\r\n ans+=bi.query(d[nums[i]]-1)\r\n bi.update(d[nums[i]],1)\r\n return ans\r\n \r\nclass DLN:\r\n def __init__(self,val):\r\n self.val=val\r\n self.pre=None\r\n self.next=None\r\n \r\ndef nb(i,j,n,m):\r\n for ni,nj in [[i+1,j],[i-1,j],[i,j-1],[i,j+1]]:\r\n if 0<=ni>(s//2)&1:\r\n print(\"JISHU\")\r\n print(0)\r\n exit()\r\n print(1)\r\n g=G(12)\r\n for i,x in enumerate(a,1):\r\n c=0\r\n while not x&1:\r\n x//=2\r\n c+=1\r\n g[c].append(i)\r\n for i in range(12):\r\n if g[i]:\r\n print(g[i][0])\r\n exit()\r\n #print(ans)\r\n \r\n \r\n \r\n \r\n"}, {"source_code": "#Fast I/O\r\nimport sys,os\r\nimport math\r\n# To enable the file I/O i the below 2 lines are uncommented.\r\n# read from in.txt if uncommented\r\nif os.path.exists('in.txt'): sys.stdin=open('in.txt','r')\r\n# will print on Console if file I/O is not activated\r\n#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')\r\n\r\n# inputs template\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\ndef main():\r\n n=int(input())\r\n arr=list(MI())\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n return\r\n t=s//2\r\n mat=[[0 for i in range(t+1)] for j in range(n+1)]\r\n mat[0][0]=1\r\n for i in range(1,n+1):\r\n mat[i][0]=1\r\n for j in range(1,t+1):\r\n if arr[i-1]<=j:\r\n mat[i][j]=mat[i-1][j]|mat[i-1][j-arr[i-1]]\r\n else:\r\n mat[i][j]=mat[i-1][j]\r\n if mat[n][t]:\r\n found=False\r\n for i in range(1,32):\r\n if found:\r\n break\r\n for j in range(n):\r\n if arr[j]&(1<= 0:\r\n if dp[i - 1][j - a[i - 1]]:\r\n dp[i][j] = 1\r\n \r\n if sm & 1 or not dp[-1][sm // 2]:\r\n print(0)\r\n else:\r\n for i in range(n):\r\n if a[i] & 1:\r\n print(1)\r\n print(i + 1)\r\n return\r\n \r\n for i in range(n):\r\n if (sm - a[i]) // 2 & 1:\r\n print(1)\r\n print(i + 1)\r\n return\r\n \r\n \r\n \r\n\r\n \r\n\r\n\r\n return None\r\n\r\ndef main():\r\n tests = 1\r\n # tests = re(int)\r\n for tc in range(tests):\r\n solve()\r\n print()\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"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\ndef main():\r\n n = int(input())\r\n A = list(map(int, input().split()))\r\n\r\n M = sum(A)\r\n dp = [False]*(M+1)\r\n dp[0] = True\r\n for a in A:\r\n for j in reversed(range(M+1)):\r\n if not dp[j]:\r\n continue\r\n dp[j+a] = True\r\n\r\n flag = False\r\n for i in range(M+1):\r\n if M-i == i:\r\n flag = True\r\n break\r\n if not flag:\r\n print(0)\r\n exit()\r\n B = []\r\n for i, a in enumerate(A):\r\n B.append((a, i))\r\n for a, i in B:\r\n if a%2 == 1:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n B.sort(key=lambda x: x[0])\r\n print(1)\r\n print(B[0][1]+1)\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "# 2022-09-04 12:35:14.236880\n# https://codeforces.com/problemset/problem/1516/C\nimport sys\nfrom collections import Counter\n\n_DEBUG = True\nif not _DEBUG:\n input = sys.stdin.readline\n # print = sys.stdout.write\n\n\ndef proc(n, a):\n def possible(idx):\n new_sa = sa - a[idx]\n new_half = new_sa // 2\n\n t = set()\n for i in range(n):\n if i == idx:\n continue\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if new_half in t:\n return False\n return True\n\n sa = sum(a)\n\n t = set()\n for e in a:\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if sa % 2 == 1 or (sa // 2) not in t:\n return None\n\n for i in range(n):\n if possible(i):\n return i + 1\n return None\n\n\nn = int(input())\na = list(map(int, input().split()))\nans = proc(n, a)\nif not ans:\n print(0)\nelse:\n print(1)\n print(ans)\n"}, {"source_code": "import os\r\nimport sys\r\nfrom io import BytesIO, IOBase\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\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\ninp = lambda dtype: dtype(input().strip())\r\ninp_d = lambda dtype: [dtype(x) for x in input().split()]\r\ninp_2d = lambda dtype, n: [inp(dtype) for _ in range(n)]\r\ninp_2ds = lambda dtype, n: [inp_d(dtype) for _ in range(n)]\r\ninp_enu = lambda dtype: [(i, x) for i, x in enumerate(inp_d(dtype))]\r\ninp_enus = lambda dtype, n: [[i, inp_d(dtype)] for i in range(n)]\r\nceil1 = lambda a, b: (a + b - 1) // b\r\n\r\nn, a = inp(int), inp_d(int)\r\nsums, su = {0, a[0]}, sum(a)\r\n\r\nfor i in range(1, n):\r\n sums.update([a[i] + j for j in sums if a[i] + j <= su >> 1])\r\n\r\nif su & 1 or su >> 1 not in sums:\r\n print(0)\r\nelse:\r\n for i in range(n):\r\n if a[i] & 1:\r\n exit(print(1, i + 1, sep='\\n'))\r\n else:\r\n print(1, a.index(min(a)) + 1, sep='\\n')\r\n"}, {"source_code": "\ndef find(a):\n t = sum(a)\n if t%2 == 1:\n return -1\n else:\n tar = t//2\n s = set()\n s.add(0)\n count = 0\n for i in a[:-1]:\n count += i\n t = count%tar\n if t in s and i!=0:\n return 0\n s.add(t)\n return -1\ndef process(a):\n\n num = float('inf')\n ind = 0\n for i in range(len(a)):\n count = 0\n while a[i]&1 == 0:\n a[i] = a[i] >> 1\n count+=1\n if (count < num):\n num = count\n ind = i+1\n print(1)\n print(ind)\n\n\n\n\nilg = int(input())\na = list(map(int, input().split()))\nr = find(a)\nif (r==-1 or len(a) <=1):\n print(0)\nelse:\n process(a)"}, {"source_code": "n = int(input())\na = [int(_) for _ in input().split()]\nc = a.copy()\nfor i in range(n):\n a[i] = a[i] % 2 + 2\n\nsum = 0\nfor x in a:\n sum += x \n \nif sum % 2 != 0: \n print(0)\n exit(0) \n\ndp = [[-1 for _ in range((5 * n) + 1)] for _ in range(n + 1)]\ndef call(i, cursum):\n if dp[i][cursum] != -1:\n return dp[i][cursum]\n\n if cursum * 2 == sum:\n return True\n\n if i >= n:\n return False\n \n bad = False\n bad = bad | call(i + 1, cursum)\n bad = bad | call(i + 1, cursum + a[i])\n dp[i][cursum] = bad\n return dp[i][cursum]\n\nif not call(0, 0):\n print(0)\n exit(0)\n\nfor i in range(n):\n if a[i] % 2 != 0:\n print(1) \n print(i + 1)\n exit(0)\n \nid = -1\nwhile id == -1:\n for i in range(n):\n if c[i] % 2 == 1:\n id = i\n break\n\n c[i] = c[i] // 2\n\nprint(1)\nprint(id + 1)\n"}, {"source_code": "# 2022-09-04 12:35:14.236880\n# https://codeforces.com/problemset/problem/1516/C\nimport sys\nfrom collections import Counter\n\n_DEBUG = True\nif not _DEBUG:\n input = sys.stdin.readline\n # print = sys.stdout.write\n\n\ndef proc(n, a):\n sa = sum(a)\n\n t = set()\n for e in a:\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if sa % 2 == 1 or (sa // 2) not in t:\n return None\n\n for i, e in enumerate(a):\n if e % 2:\n return i + 1\n return 1\n\n\nn = int(input())\na = list(map(int, input().split()))\nans = proc(n, a)\nif not ans:\n print(0)\nelse:\n print(1)\n print(ans)\n"}, {"source_code": "import random\r\nimport collections\r\nimport string\r\nimport math\r\nimport copy\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\n\r\n\r\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\n# n = 0\r\n# m = 0\r\n\r\n# n = int(input())\r\n\r\n# li = [int(i) for i in input().split()]\r\n\r\n# s = sorted(li)\r\n\"\"\"\r\nfrom dataclasses import dataclass\r\n\r\n@dataclass\r\nclass point:\r\n x: float\r\n y: float\r\n \r\n \r\n@dataclass\r\nclass line:\r\n A: float\r\n B: float\r\n C: float\r\n \r\n def gety(self, x):\r\n return (self.A*x+self.C)/-self.B\r\n \r\n def getx(self, y):\r\n return (self.B*y+self.C)/-self.A\r\n \r\n def k(self):\r\n return -self.A/self.B\r\n \r\n def b(self):\r\n return -self.C/self.B\r\n \r\n def dist(self, p: point):\r\n return abs((self.A*p.x+self.B*p.y+self.C)/(self.A**2+self.B**2)**0.5)\r\n \r\n \r\ndef calc_line(u: point, v: point):\r\n return line(A=u.y-v.y, B=v.x-u.x, C=u.y*(u.x-v.x)-u.x*(u.y-v.y))\r\n \r\n \r\ndef is_parallel(u: line, v: line) -> bool:\r\n f1 = False\r\n f2 = False\r\n try:\r\n k1 = u.k()\r\n except:\r\n f1 = True\r\n try:\r\n k2 = v.k()\r\n except:\r\n f2 = True\r\n if f1 != f2:\r\n return False\r\n return f1 or k1 == k2\r\n \r\n \r\ndef seg_len(_from: point, _to: point):\r\n return ((_from.x - _to.x)**2 + (_from.y - _to.y)**2) ** 0.5\r\n \r\ndef in_range(_from: point, _to: point, _point: point) -> bool:\r\n if _from.x < _to.x:\r\n if _from.y < _to.y:\r\n return _from.x <= _point.x <= _to.x and _from.y <= _point.y <= _to.y\r\n else:\r\n return _from.x <= _point.x <= _to.x and _from.y >= _point.y >= _to.y\r\n else:\r\n if _from.y < _to.y:\r\n return _from.x >= _point.x >= _to.x and _from.y <= _point.y <= _to.y\r\n else:\r\n return _from.x >= _point.x >= _to.x and _from.y >= _point.y >= _to.y\r\n \r\ndef intersect(u: line, v: line) -> point:\r\n tx = (u.B*v.C-v.B*u.C)/(v.B*u.A-u.B*v.A)\r\n if u.B!=0.0:\r\n ty = -u.A*tx/u.B - u.C/u.B\r\n else:\r\n ty = -v.A*tx/v.B - v.C/v.B\r\n return point(x=tx, y=ty)\r\n \r\ndef in_direction(_from: point, _to: point, _point: point) -> bool:\r\n if _from.x < _to.x:\r\n if _from.y < _to.y:\r\n return _to.x < _point.x and _to.y < _point.y\r\n else:\r\n return _to.x < _point.x and _point.y <= _to.y\r\n else:\r\n if _from.y < _to.y:\r\n return _to.x >= _point.x and _to.y < _point.y\r\n else:\r\n return _to.x >= _point.x and _point.y <= _to.y\r\n\r\n\r\n\"\"\"\r\n# mo = int(1e9+7)\r\nmo = 998244353\r\n\r\n\r\ndef exgcd(a, b):\r\n if not b:\r\n return 1, 0\r\n y, x = exgcd(b, a % b)\r\n y -= a//b * x\r\n return x, y\r\n\r\n\r\ndef getinv(a, m):\r\n x, y = exgcd(a, m)\r\n return -1 if x == 1 else x % m\r\n\r\n\r\ndef comb(n, b):\r\n res = 1\r\n b = min(b, n-b)\r\n for i in range(b):\r\n res = res*(n-i)*getinv(i+1, mo) % mo\r\n # res %= mo\r\n return res % mo\r\n\r\n\r\ndef quickpower(a, n):\r\n res = 1\r\n while n:\r\n if n & 1:\r\n res = res * a % mo\r\n n >>= 1\r\n a = a*a % mo\r\n return res\r\n\r\n\r\ndef dis(a, b):\r\n return abs(a[0]-b[0]) + abs(a[1]-b[1])\r\n\r\n\r\ndef getpref(x):\r\n if x > 1:\r\n return (x)*(x-1) >> 1\r\n else:\r\n return 0\r\n\r\n\r\ndef orafli(upp):\r\n primes = []\r\n marked = [False for i in range(upp+3)]\r\n prvs = [i for i in range(upp+3)]\r\n for i in range(2, upp):\r\n if not marked[i]:\r\n primes.append(i)\r\n for j in primes:\r\n if i*j >= upp:\r\n break\r\n marked[i*j] = True\r\n prvs[i*j] = j\r\n if i % j == 0:\r\n break\r\n return primes, prvs\r\n\r\n\r\ndef lower_ord(c: str) -> int:\r\n return ord(c)-97\r\n\r\n\r\ndef upper_ord(c: str) -> int:\r\n return ord(c) - 65\r\n\r\n\r\ndef read_list():\r\n return [int(i) for i in input().split()]\r\n\r\n\r\ndef read_int():\r\n s = input().split()\r\n if len(s) == 1:\r\n return int(s[0])\r\n else:\r\n return map(int, s)\r\n\r\n\r\ndef ask(s):\r\n print(f\"? {s}\", flush=True)\r\n\r\n\r\ndef answer(s):\r\n print(f\"{s}\", flush=True)\r\n\r\nimport functools\r\n\r\n# primes, prvs = orafli(100010)\r\n\r\ndef solve():\r\n n = read_int()\r\n\r\n bl = [1]\r\n for i in range(11):\r\n bl.append(bl[-1]<<1)\r\n\r\n l = read_list()\r\n if sum(l)&1:\r\n print(0)\r\n return\r\n\r\n blm = [0 for i in range(12)]\r\n for i in l:\r\n tl = []\r\n for p,j in enumerate(bl):\r\n blm[p]+=1 if j&i else 0\r\n sel = -1\r\n for k, v in enumerate(blm):\r\n if v&1:\r\n print(0)\r\n return\r\n if v and sel == -1:\r\n sel = k\r\n vv = 1< 2:\n arr.append(n)\n return arr\ndef primeFactorsSet(n):\n s = set()\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)\n return s\ndef sieve(n):\n res=[0 for i in range(n+1)]\n #prime=set([])\n prime=[]\n for i in range(2,n+1):\n if not res[i]:\n #prime.add(i)\n prime.append(i)\n for j in range(1,n//i+1):\n res[i*j]=1\n return prime\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\ndef countPrimesLessThanN(n):\n seen, ans = [0] * n, 0\n for num in range(2, n):\n if seen[num]: continue\n ans += 1\n seen[num*num:n:num] = [1] * ((n - 1) // num - num + 1)\n return ans\ndef gcd(x, y):\n return math.gcd(x, y)\ndef lcm(a,b):\n return (a // gcd(a,b))* b\ndef isBitSet(n,k):\n # returns the count of numbers up to N having K-th bit set.\n res = (n >> (k + 1)) << k\n if ((n >> k) & 1):\n res += n & ((1 << k) - 1)\n return res\ndef modular_exponentiation(x, y, p): #returns (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\ndef nCr(n, r, p): # returns nCr % 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\ndef smallestDivisor(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 += 2\n return 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 return False\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 return True\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# -------------------------------------------------- code -------------------------------------------------\ndef subsetSum(elements, target):\n dp = [False]*(target+1)\n dp[0] = True\n for ele in elements:\n for j in range(target, ele - 1, -1):\n if dp[j - ele]:\n dp[j] = True\n return dp[target]\n\ndef main():\n n = int(input())\n arr = list(map(int, input().split()))\n s = sum(arr)\n if s%2 == 1:\n print(0)\n return\n\n if subsetSum(arr, s//2):\n g = 0\n odd = -1\n for i in range(n):\n if arr[i]%2 == 1:\n odd = i+1\n break\n else:\n g = gcd(g, arr[i])\n if odd != -1:\n print(1)\n print(odd)\n else:\n for i in range(n):\n arr[i] = arr[i]//g\n\n de = deque(arr)\n a = -1\n for i in range(n):\n x = de.popleft()\n\n if not subsetSum(de, (s-x)//2):\n a = i+1\n break\n\n else:\n de.append(x)\n print(1)\n print(a)\n\n else:\n print(0)\n\n# ---------------------------------------------- region fastio ---------------------------------------------\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# -------------------------------------------------- end region ---------------------------------------------\n\nif __name__ == \"__main__\":\n #read()\n main()"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nfor _ in range(1):\r\n def canPartition(nums):\r\n a=sum(nums)\r\n n=len(nums)\r\n d={}\r\n def helper(curr,s):\r\n if curr==n:\r\n if s==a//2:\r\n return True\r\n return False\r\n if (curr,s) in d:\r\n return d[(curr,s)]\r\n ans=helper(curr+1,s+nums[curr]) or helper(curr+1,s)\r\n d[(curr,s)]=ans\r\n return ans \r\n if a%2:\r\n return False\r\n return helper(0,0)\r\n n=int(input())\r\n arr=[int(x) for x in input().split()]\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n continue\r\n if canPartition(arr)==False:\r\n print(0)\r\n continue\r\n else:\r\n odd=-1\r\n temp=[]\r\n for i in range(n):\r\n if arr[i]%2:\r\n odd=i\r\n if arr[i]%2==0 and (arr[i]//2)%2:\r\n temp.append(i)\r\n if odd>=0:\r\n print(1)\r\n print(odd+1)\r\n continue\r\n if temp:\r\n print(1)\r\n print(temp[0]+1)\r\n else:\r\n d={}\r\n for i in range(n):\r\n if arr[i] in d:\r\n d[arr[i]].append(i+1)\r\n else:\r\n d[arr[i]]=[i+1]\r\n #print(d)\r\n for i in sorted(d.keys()):\r\n if canPartition(arr[:d[i][0]]+arr[d[i][0]+1:])==False:\r\n print(1)\r\n print(d[i][0])\r\n #print(1)\r\n #print(d[i][0])\r\n exit()"}, {"source_code": "def inp():\r\n return [int(a) for a in input().split()]\r\ndef gcd(x, y):\r\n if y:\r\n return gcd(y, x % y)\r\n else:\r\n return x\r\nind = []\r\nn = int(input())\r\na = inp()\r\nif sum(a) % 2 == 1:\r\n print(0)\r\nelse:\r\n prev = a[0]\r\n for i in range(1, n):\r\n g = gcd(prev, a[i])\r\n prev = a[i]\r\n for i in range(n):\r\n a[i] /= g\r\n while sum(a) % 2 == 0:\r\n for i in range(n):\r\n if a[i] % 2:\r\n ind.append(i + 1)\r\n del a[i]\r\n n -= 1\r\n break\r\n print(len(ind))\r\n print(*ind)\r\n"}, {"source_code": "# Author : nitish420 --------------------------------------------------------------------\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\n\r\ndef knapsack(n,wt,w,dp):\r\n\r\n for i in range(n+1):\r\n dp[i][0]=1\r\n\r\n for r in range(1,n+1):\r\n for c in range(1,w+1):\r\n if wt[r-1]<=w:\r\n dp[r][c]=dp[r-1][c] or dp[r-1][c-wt[r-1]]\r\n else:\r\n dp[r][c]=dp[r-1][c]\r\n\r\n return dp[n][w]\r\n\r\n\r\ndef main():\r\n n=int(input())\r\n a=list(map(int,input().split()))\r\n s=sum(a)\r\n if s%2==0:\r\n\r\n dp=[[0 for _ in range(s//2+1)]for _ in range(n+1)]\r\n\r\n if knapsack(n,a,s//2,dp):\r\n\r\n for i,item in enumerate(a):\r\n if item%2:\r\n print(1)\r\n print(i+1)\r\n break\r\n elif ((s-item)//2)%2:\r\n print(1)\r\n print(i+1)\r\n break\r\n else:\r\n print(2)\r\n print(n-1,n)\r\n else:\r\n print(0)\r\n else:\r\n print(0)\r\n\r\n# 6\r\n# 2 4 6 8 10 10\r\n\r\n\r\n#----------------------------------------------------------------------------------------\r\ndef nouse0():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse1():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse2():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\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\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\n\r\n\r\ndef nouse3():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse4():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse5():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\r\n\r\n# endregion\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "# 2022-09-04 12:35:14.236880\n# https://codeforces.com/problemset/problem/1516/C\nimport sys\nfrom collections import Counter\n\n_DEBUG = True\nif not _DEBUG:\n input = sys.stdin.readline\n # print = sys.stdout.write\n\n\ndef proc(n, a):\n def possible(idx):\n new_sa = sa - a[idx]\n new_half = new_sa // 2\n\n t = set()\n for i, e in enumerate(a):\n if i == idx:\n continue\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if new_half in t:\n return False\n return True\n\n sa = sum(a)\n\n t = set()\n for e in a:\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if sa % 2 == 1 or (sa // 2) not in t:\n return None\n\n for i in range(n):\n if possible(i):\n return i + 1\n return None\n\n\nn = int(input())\na = list(map(int, input().split()))\nans = proc(n, a)\nif not ans:\n print(0)\nelse:\n print(1)\n print(ans)\n"}, {"source_code": "#Don't stalk me, don't stop me, from making submissions at high speed. If you don't trust me,\r\nimport sys\r\n#then trust me, don't waste your time not trusting me. I don't plagiarise, don't fantasize,\r\nimport os\r\n#just let my hard work synthesize my rating. Don't be sad, just try again, everyone fails\r\nfrom io import BytesIO, IOBase\r\nBUFSIZE = 8192\r\n#every now and then. Just keep coding, just keep working and you'll keep progressing at speed-\r\n# -forcing.\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\n#code by _Frust(CF)/Frust(AtCoder)\r\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\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 input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nimport math\r\nimport heapq as hq\r\n\r\n\r\ndef checker(dp, nums):\r\n for i in range(n):\r\n for j in range(r, -1, -1):\r\n if dp[j]==1 and j+l1[i]<=r:\r\n dp[j+l1[i]]=1\r\n\r\n if dp[r]==True:\r\n return True\r\n return False\r\n\r\n\r\n\r\nn=int(input())\r\nl1=[int(i) for i in input().split()]\r\n\r\ns=sum(l1)\r\nif s&1:\r\n print(0)\r\nelse:\r\n r=s//2\r\n dp=[0 for i in range(r + 1)]\r\n dp[0]=1\r\n\r\n if not checker(dp, l1):\r\n print(0)\r\n else:\r\n print(1)\r\n k=min(l1)\r\n for i in range(n):\r\n if l1[i]==k:\r\n print(i+1)\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "n = int(input()) \r\na = list(map(int,input().split())) \r\nodd = 0 \r\nfor i in a:\r\n if (i%2==1):\r\n odd+=1 \r\nif (odd%2==1):\r\n print(0) \r\nelse:\r\n if (odd>0):\r\n print(1) \r\n for i in range(n):\r\n if (a[i]%2==1):\r\n print(i+1)\r\n break \r\n else:\r\n print(1) \r\n mini = 10**9 \r\n x = 0 \r\n for i in range(n):\r\n ans=0 \r\n while(a[i]%2==0):\r\n a[i] = a[i]//2 \r\n ans+=1 \r\n if (mini>ans):\r\n x = i+1 \r\n print(x)"}, {"source_code": "import sys\nimport math\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.rstrip()))\ndef invr():\n return(map(int,input().split()))\nn=inp()\ndef solution(L):\n\tS=sum(L)\n\tif S==0:\n\t\tprint(n-1)\n\t\tprint(' '.join([str(i) for i in range(1, n)]))\n\t\treturn 0\n\tif S%2!=0:\n\t\tprint(0)\n\t\treturn 0\n\telse:\n\t\tfor i in range(len(L)):\n\t\t\tl=L[i]\n\t\t\tif l%2==1:\n\t\t\t\tprint(1)\n\t\t\t\tprint(i+1)\n\t\t\t\treturn 0\n\tsolution([l//2 for l in L])\n\nL=inlt()\nsolution(L)"}, {"source_code": "#Fast I/O\r\nimport sys,os\r\nimport math\r\n# To enable the file I/O i the below 2 lines are uncommented.\r\n# read from in.txt if uncommented\r\nif os.path.exists('in.txt'): sys.stdin=open('in.txt','r')\r\n# will print on Console if file I/O is not activated\r\n#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')\r\n\r\n# inputs template\r\nfrom io import BytesIO, IOBase\r\n\r\n\r\ndef main():\r\n n=int(input())\r\n arr=list(MI())\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n return\r\n t=s//2\r\n mat=[[0 for i in range(t+1)] for j in range(n+1)]\r\n mat[0][0]=1\r\n for i in range(1,n+1):\r\n mat[i][0]=1\r\n for j in range(1,t+1):\r\n if arr[i-1]<=j:\r\n mat[i][j]=mat[i-1][j]|mat[i-1][j-arr[i-1]]\r\n else:\r\n mat[i][j]=mat[i-1][j]\r\n if mat[n][t]:\r\n found=False\r\n for i in range(1,32):\r\n if found:\r\n break\r\n for j in range(n):\r\n if arr[j]&(1< 2:\n factors.append(n)\n return factors\n\"============================\"\n\"\"\"\nn = int(input())\nn,k = map(int,input().split())\narr = list(map(int,input().split()))\n\"\"\"\nfrom collections import deque,defaultdict,Counter\nimport heapq\n\nfor _ in range(1):\n n=int(input())\n arr=list(map(int,input().split()))\n flag=True\n if sum(arr)%2==1:\n print(0)\n elif sum(arr)%2==0 and n%2==1:\n print(0)\n else:\n flag=True\n for i in range(n):\n if arr[i]%2==1:\n print(1)\n print(i+1)\n flag=False\n break\n while flag:\n for i in range(n):\n arr[i]=arr[i]/2\n if arr[i]%2==1:\n print(1)\n print(i+1)\n flag=False\n break\n"}, {"source_code": "import time\r\n\r\n#start_time = time.time()\r\n#def 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 = 10**9 + 7\r\n\r\n\"\"\"\r\nIf the sum of elements is odd, return\r\n\r\nSubset sums of 14 with min element 2\r\n\r\nMust not be able to have subset sums 13\r\n\r\nRemove the number which is the smallest power of 2\r\n\"\"\"\r\n\r\nfrom copy import deepcopy\r\n\r\ndef solve():\r\n N = getInt()\r\n A = getInts()\r\n S = sum(A)\r\n if S % 2:\r\n print(0)\r\n return\r\n sums = set([0])\r\n for a in A:\r\n new_sums = deepcopy(sums)\r\n for s in sums:\r\n new_sums.add(a+s)\r\n sums = deepcopy(new_sums)\r\n if s//2 not in sums:\r\n print(0)\r\n return\r\n two_min = 65\r\n two_min_idx = -1\r\n for i,a in enumerate(A):\r\n num = 0\r\n x = a\r\n while x % 2 == 0:\r\n x //= 2\r\n num += 1\r\n if num < two_min:\r\n two_min = num\r\n two_min_idx = i\r\n print(1)\r\n print(two_min_idx+1)\r\n return\r\n \r\n#for _ in range(getInt()):\r\n#print(solve())\r\nsolve()\r\n\r\n#TIME_()"}, {"source_code": "n = int(input())\r\na = list(map(int, input().split()))\r\ns = sum(a)\r\nif s % 2 == 1:\r\n print(0)\r\n exit()\r\ndp = [[False] * (s // 2+1) for _ in range(n + 1)]\r\ndp[0][0] = True\r\nfor i in range(n):\r\n for j in range(s // 2+1):\r\n if j < a[i]:\r\n dp[i + 1][j] = dp[i][j]\r\n else:\r\n dp[i + 1][j] |= dp[i][j - a[i]]\r\nif not dp[-1][-1]:\r\n print(0)\r\nelse:\r\n l = []\r\n for i in a:\r\n cnt = 0\r\n while i % 2 == 0:\r\n i //= 2\r\n cnt += 1\r\n l.append(cnt)\r\n print(1)\r\n print(l.index(min(l))+1)\r\n"}, {"source_code": "import math\r\nimport sys\r\ninput = sys.stdin.readline\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\n\r\ndef part(l,s):\r\n if s%2!=0:\r\n return 0\r\n s=s//2\r\n dp=[0 for _ in range(s+1)]\r\n dp[0]=1\r\n for i in range(1,n):\r\n for j in range(s,-1,-1):\r\n if j-l[i-1]>=0:\r\n dp[j]= dp[j - l[i-1]] or dp[j]\r\n return dp[s]\r\nn=inp()\r\nl=inlt()\r\ns=sum(l)\r\nif part(l,s):\r\n if s%2:\r\n print(0)\r\n else:\r\n indx=-1\r\n for i in range(n):\r\n if l[i]%2==1:\r\n indx=i\r\n break\r\n if indx!=-1:\r\n print(1)\r\n print(indx+1)\r\n else:\r\n vals=[]\r\n cnt=0\r\n while(part(l,s)):\r\n z=[each & -each for each in l]\r\n cnt+=1\r\n temp=l[z.index(min(z))]\r\n s-=temp\r\n vals.append(temp)\r\n l.remove(temp)\r\n print(cnt)\r\n for each in vals:\r\n print(each)\r\nelse:\r\n print(0)\r\n"}, {"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\n\r\ndef solve():\r\n n = int(input())\r\n a = list(map(int,input().split()))\r\n vis = [False]*(2000*100)+[False]\r\n vis[0]=True\r\n for i in range(n):\r\n for j in range(len(vis)-a[i]-1,-1,-1):\r\n if not vis[j]:continue\r\n vis[a[i]+j]=True\r\n sm = sum(a)\r\n if (not vis[sm//2] or sm%2!=0):\r\n print(0)\r\n return\r\n idx= -1\r\n\r\n log =32\r\n div= float('inf')\r\n for pw in range(log,-1,-1):\r\n for i in range(n):\r\n if a[i]//(2**pw)>0:\r\n div = min(div,a[i]//(2**pw))\r\n\r\n for i in range(n):\r\n if a[i]%2:\r\n idx=i\r\n break\r\n a[i]/=(2**div)\r\n if a[i]%2:\r\n idx =i\r\n print(1)\r\n print(idx+1)\r\n return\r\n\r\nt= 1#int(input())\r\nfor _ in range(t):\r\n solve()\r\n"}, {"source_code": " ###### ### ####### ####### ## # ##### ### ##### \r\n # # # # # # # # # # # # # ### \r\n # # # # # # # # # # # # # ### \r\n ###### ######### # # # # # # ######### # \r\n ###### ######### # # # # # # ######### # \r\n # # # # # # # # # # #### # # # \r\n # # # # # # # ## # # # # # \r\n ###### # # ####### ####### # # ##### # # # # \r\n \r\n# mandatory imports\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nfrom math import log2, ceil, sqrt, gcd, log\r\n\r\n# optional imports\r\n# from itertools import permutations\r\n# from functools import cmp_to_key # for adding custom comparator\r\n# from fractions import Fraction\r\nfrom collections import *\r\nfrom bisect import *\r\n# from __future__ import print_function # for PyPy2\r\nfrom heapq import *\r\nBUFSIZE = 8192\r\n\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\ng = lambda : input().strip()\r\ngl = lambda : g().split()\r\ngil = lambda : [int(var) for var in gl()]\r\ngfl = lambda : [float(var) for var in gl()]\r\ngcl = lambda : list(g())\r\ngbs = lambda : [int(var) for var in g()]\r\nrr = lambda x : reversed(range(x)) \r\nmod = int(1e9)+7\r\ninf = float(\"inf\")\r\n\r\nn, = gil()\r\na = gil()\r\nif sum(a)&1:\r\n print(0)\r\n exit()\r\nidx = 0\r\np = int(log2(a[0]))\r\n\r\nfor i in range(1, n):\r\n pi = int(log2(a[i]))\r\n if pi < p:\r\n idx = i\r\n p = pi\r\n\r\nprint(1)\r\nprint(idx+1)"}, {"source_code": "\"\"\"\r\n\r\nAuthor : Preet Modh \r\n\r\n\"\"\"\r\nimport sys,os\r\nfrom difflib import SequenceMatcher\r\nfrom collections import Counter\r\nfrom bisect import bisect_left as bl,bisect_right as br\r\nfrom io import BytesIO, IOBase\r\nfrom itertools import accumulate\r\nimport math\r\n\r\n\"\"\" \r\n\r\n**All function calls:**\r\n\r\nLCSubstr(a,b): for Longest Common Substring\r\ngcd(x, y): greatest common divisor of x and y\r\nprime_factors(n): Number of prime factor of n\r\ndistinct_factors(n): list of distinct factors of n\r\nall_factors(n): list of all factors of n\r\nis_prime(n): checks if n is prime\r\nprime_list(n): all primes less than number of\r\nmodinv(a, m): modular inverse of a w.r.t. to m, works when a and m are coprime\r\nmake_nCr_mod()(n,r) value of ncr%mod\r\nbinarySearch(arr, l, r, x): binary search \r\nPrefixSum(arr): prefix sum array\r\nmemodict(f): Memoization decorator for a function taking a single argument\r\nmemoize(f): Memoization decorator for a function taking one or more arguments\r\n\r\n\"\"\"\r\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\n\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 memoize(f):\r\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\r\n class memodict(dict):\r\n def __getitem__(self, *key):\r\n return dict.__getitem__(self, key)\r\n\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\nLCSubstr = lambda a, b:SequenceMatcher(None, a, b).find_longest_match(0, len(a), 0, len(b))\r\n\"\"\" THIS IS FOR for Longest Common Substring \"\"\"\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 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@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\ndef is_prime(n):\r\n \"\"\"returns True if n is prime else False\"\"\"\r\n if n < 5 or n & 1 == 0 or n % 3 == 0:\r\n return 2 <= n <= 3\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 p = (p * p) % n\r\n if p == n - 1:\r\n break\r\n else:\r\n return False\r\n return True\r\n\r\ndef prime_sieve(n):\r\n \"\"\"returns a sieve of primes >= 5 and < n\"\"\"\r\n flag = n % 6 == 2\r\n sieve = bytearray((n // 3 + flag >> 3) + 1)\r\n for i in range(1, int(n**0.5) // 3 + 1):\r\n if not (sieve[i >> 3] >> (i & 7)) & 1:\r\n k = (3 * i + 1) | 1\r\n for j in range(k * k // 3, n // 3 + flag, 2 * k):\r\n sieve[j >> 3] |= 1 << (j & 7)\r\n for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):\r\n sieve[j >> 3] |= 1 << (j & 7)\r\n return sieve\r\n\r\n\r\ndef prime_list(n):\r\n \"\"\"returns a list of primes <= n\"\"\"\r\n res = []\r\n if n > 1:\r\n res.append(2)\r\n if n > 2:\r\n res.append(3)\r\n if n > 4:\r\n sieve = prime_sieve(n + 1)\r\n res.extend(3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not (sieve[i >> 3] >> (i & 7)) & 1)\r\n return res\r\n \r\n\r\n\r\n\r\ndef extended_gcd(a, b):\r\n \"\"\"returns gcd(a, b), s, r s.t. a * s + b * r == gcd(a, b)\"\"\"\r\n s, old_s = 0, 1\r\n r, old_r = b, a\r\n while r:\r\n q = old_r // r\r\n old_r, r = r, old_r - q * r\r\n old_s, s = s, old_s - q * s\r\n return old_r, old_s, (old_r - old_s * a) // b if b else 0\r\n\r\n\r\ndef modinv(a, m):\r\n \"\"\"returns the modular inverse of a w.r.t. to m, works when a and m are coprime\"\"\"\r\n g, x, _ = extended_gcd(a % m, m)\r\n return x % m if g == 1 else None\r\n\r\n\r\ndef make_nCr_mod(max_n=2 * 10**5, mod=10**9 + 7):\r\n max_n = min(max_n, mod - 1)\r\n\r\n fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)\r\n fact[0] = 1\r\n for i in range(max_n):\r\n fact[i + 1] = fact[i] * (i + 1) % mod\r\n\r\n inv_fact[-1] = pow(fact[-1], mod - 2, mod)\r\n for i in reversed(range(max_n)):\r\n inv_fact[i] = inv_fact[i + 1] * (i + 1) % mod\r\n\r\n def nCr_mod(n, r):\r\n res = 1\r\n while n or r:\r\n a, b = n % mod, r % mod\r\n if a < b:\r\n return 0\r\n res = res * fact[a] % mod * inv_fact[b] % mod * inv_fact[a - b] % mod\r\n n //= mod\r\n r //= mod\r\n return res\r\n\r\n return nCr_mod\r\n \"\"\" \r\n To use:\r\n x=make_nCr_mod()\r\n print(x(n,r))\r\n \"\"\"\r\n\r\ndef binarySearch(arr, l, r, x):\r\n \r\n while l <= r:\r\n mid = l + (r - l) // 2\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 r = mid - 1\r\n \r\n return -1\r\n\r\n\r\n \r\ndef PrefixSum(arr):\r\n return list(accumulate(arr))\r\n \r\n \r\nclass inputs:\r\n #To handle different inputs\r\n def single(self):\r\n return int(input())\r\n def mul(self):\r\n return map(int,input().split())\r\n def list(self):\r\n return list(map(int,input().split()))\r\n\r\ninp=inputs()\r\n########################################################\r\n\r\n\r\ndef isSubsetSum(set, n, sum):\r\n \r\n # The value of subset[i][j] will be\r\n # true if there is a\r\n # subset of set[0..j-1] with sum equal to i\r\n subset =([[False for i in range(sum + 1)]\r\n for i in range(n + 1)])\r\n \r\n # If sum is 0, then answer is true\r\n for i in range(n + 1):\r\n subset[i][0] = True\r\n \r\n # If sum is not 0 and set is empty,\r\n # then answer is false\r\n for i in range(1, sum + 1):\r\n subset[0][i]= False\r\n \r\n # Fill the subset table in botton up manner\r\n for i in range(1, n + 1):\r\n for j in range(1, sum + 1):\r\n if j= set[i-1]:\r\n subset[i][j] = (subset[i-1][j] or\r\n subset[i - 1][j-set[i-1]])\r\n \r\n # uncomment this code to print table\r\n # for i in range(n + 1):\r\n # for j in range(sum + 1):\r\n # print (subset[i][j], end =\" \")\r\n # print()\r\n return subset[n][sum]\r\n\r\n\r\ndef main():\r\n n=inp.single()\r\n a=inp.list()\r\n s=sum(a)\r\n if sum(a)%2==1:\r\n print(\"0\")\r\n return\r\n else:\r\n for i in range(len(a)):\r\n if a[i]%2!=0:\r\n print(1)\r\n print(i+1)\r\n return \r\n\r\n if (not isSubsetSum(a,len(a),s//2)):\r\n print(0)\r\n return\r\n \r\n while(True):\r\n for i in range(len(a)):\r\n a[i]=a[i]//2\r\n if(a[i]%2==1):\r\n print(1)\r\n print(i+1)\r\n return\r\n \r\n\r\n\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "def exists(n,L):\n s=sum(L)\n\n dp=[(1+s//2)*[0] for i in range(n)]\n \n for x in range(s//2 +1):\n dp[0][x]=True\n for i in range(n-1):\n for x in range(s//2+1):\n if x>=L[i+1]:\n dp[i+1][x]=dp[i][x-L[i+1]] or dp[i][x]\n else:\n dp[i+1][x]=dp[i][x]\n l=False\n for i in range(n):\n l=l or dp[i][s//2]\n return l\n\ndef mini(n,L):\n s=sum(L)\n if s%2==1:\n return (0)\n if not exists(n,L):\n return(0)\n while True:\n for i in range(n):\n if L[i]%2==1:\n return(1,i+1)\n else:\n L[i]=L[i]//2\n \nn=int(input())\n\nL=[int(x) for x in input().split()]\n\n\nx=mini(n,L)\nif x==0:\n print(0)\nelse:\n print(x[0])\n print(x[1])"}, {"source_code": "def canPartition(nums):\r\n target, n = sum(nums), len(nums)\r\n if target & 1:\r\n return False\r\n target >>= 1\r\n dp = [True] + [False]*target\r\n for x in nums:\r\n dp = [dp[s] or (s >= x and dp[s-x]) for s in range(target+1)]\r\n if dp[target]:\r\n return True\r\n return False\r\n\r\n\r\nn = int(input())\r\narr = [int(x) for x in input().split()]\r\nres = []\r\n\r\nwhile canPartition(arr):\r\n tmp = []\r\n tarr = arr\r\n print(tarr)\r\n for i in range(n):\r\n t = arr[:i] + arr[i+1:]\r\n if not canPartition(t):\r\n tmp.append(i)\r\n\r\n arr = arr[:min(tmp)] + arr[min(tmp)+1:]\r\n res.append(min(tmp))\r\n\r\nif len(res) > 0:\r\n print(len(res))\r\n print(\" \".join(str(x+1) for x in res))\r\nelse:\r\n print('0')\r\n"}, {"source_code": "import os,sys,math \r\nfrom io import BytesIO, IOBase\r\nfrom collections import defaultdict,deque,OrderedDict\r\nimport bisect as bi\r\ndef yes():print('YES')\r\ndef no():print('NO')\r\ndef I():return (int(input()))\r\ndef In():return(map(int,input().split()))\r\ndef ln():return list(map(int,input().split()))\r\ndef Sn():return input().strip()\r\nBUFSIZE = 8192\r\n#complete the main function with number of test cases to complete greater than x\r\ndef find_gt(a, x):\r\n i = bi.bisect_left(a, x)\r\n if i != len(a):\r\n return i\r\n else: \r\n return len(a)\r\ndef CountTrailingZeros(n):\r\n \r\n bit = bin(n)[2:]\r\n bit = bit[::-1]\r\n zero = 0;\r\n for i in range(len(bit)):\r\n if (bit[i] == '0'):\r\n zero += 1\r\n else:\r\n break\r\n \r\n return zero\r\ndef solve():\r\n Max=2000*100\r\n dp=[True]*(Max+1)\r\n n=I()\r\n l=list(In())\r\n total=0\r\n for x in l:\r\n total+=x\r\n for j in range(len(dp)-x-1,-1,-1):\r\n if not dp[j]:continue\r\n dp[j+x]=True\r\n\r\n if (not dp[total//2]) or (total%2!=0):\r\n print(0)\r\n return\r\n trail=31\r\n for x in l:\r\n trail=min(trail,CountTrailingZeros(x))\r\n ans=-2\r\n for i in range(n):\r\n if l[i]%(1<0:\r\n div = min(div,a[i]//(2**pw))\r\n\r\n for i in range(n):\r\n a[i]/=(2**div)\r\n if a[i]%2!=0:\r\n idx =i\r\n break\r\n print(1)\r\n print(idx+1)\r\n return\r\n\r\nt= 1#int(input())\r\nfor _ in range(t):\r\n solve()\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nfor _ in range(1):\r\n def canPartition(nums):\r\n a=sum(nums)\r\n n=len(nums)\r\n d={}\r\n def helper(curr,s):\r\n if curr==n:\r\n if s==a//2:\r\n return True\r\n return False\r\n if (curr,s) in d:\r\n return d[(curr,s)]\r\n ans=helper(curr+1,s+nums[curr]) or helper(curr+1,s)\r\n d[(curr,s)]=ans\r\n return ans \r\n if a%2:\r\n return False\r\n return helper(0,0)\r\n n=int(input())\r\n arr=[int(x) for x in input().split()]\r\n s=sum(arr)\r\n if s%2:\r\n print(0)\r\n continue\r\n if canPartition(arr)==False:\r\n print(0)\r\n continue\r\n else:\r\n odd=-1\r\n temp=[]\r\n for i in range(n):\r\n if arr[i]%2:\r\n odd=i\r\n if arr[i]%2==0 and (arr[i]//2)%2:\r\n temp.append(i)\r\n if odd>=0:\r\n print(1)\r\n print(odd)\r\n continue\r\n if temp:\r\n print(1)\r\n print(i+1)\r\n else:\r\n print(1)\r\n print(arr.index(min(arr))+1)"}, {"source_code": "# 2022-09-04 12:35:14.236880\n# https://codeforces.com/problemset/problem/1516/C\nimport sys\nfrom collections import Counter\n\n_DEBUG = True\nif not _DEBUG:\n input = sys.stdin.readline\n # print = sys.stdout.write\n\n\ndef proc(n, a):\n def possible(idx):\n new_sa = sa - a[idx]\n new_half = new_sa // 2\n\n t = set()\n for i, e in enumerate(a):\n if i == idx:\n continue\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if new_half in t:\n return False\n return True\n\n sa = sum(a)\n\n t = set()\n for e in a:\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if sa % 2 == 1 or (sa // 2) not in t:\n return None\n\n for i in range(n):\n if possible(i):\n return i + 1\n return None\n\n\nn = int(input())\na = list(map(int, input().split()))\nans = proc(n, a)\nif not ans:\n print(0)\nelse:\n print(1)\n print(ans)\n"}, {"source_code": "\"\"\"**************************************************************\\\r\n BISMILLAHIR RAHMANIR RAHIM\r\n****************************************************************\r\n AUTHOR NAME: MD. TAHURUZZOHA TUHIN\r\n\\**************************************************************\"\"\"\r\n\r\n\r\n\r\n\r\n\r\n#!/usr/bin/env python\r\nfrom __future__ import division, print_function\r\n\r\nimport os\r\nimport sys\r\nimport math\r\nfrom io import BytesIO, IOBase\r\nfrom heapq import heappush,heappop,heapify\r\nfrom collections import defaultdict, Counter, deque\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\n\r\n# Start FASTIO\r\nBUFSIZE = 8192\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 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\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\ndef check_freq(x):\r\n freq = {}\r\n for c in set(x):\r\n freq[c] = x.count(c)\r\n return freq\r\n \r\n\r\ndef ii(): return int(input())\r\ndef si(): return input()\r\ndef mi(): return map(int, input().strip().split(\" \"))\r\ndef li(): return list(mi())\r\nMAXX = 100000000\r\n\r\n\r\n'''**************Solution is Here***********'''\r\ndef equalPartition(self,N, arr):\r\n # code here\r\n s=sum(arr)\r\n #s has to be even for halves to exist\r\n if s%2==1:\r\n return 0\r\n mat=[]\r\n p=s//2\r\n \r\n #initialization of DP table\r\n for i in range(N+1):\r\n row=[]\r\n for j in range(p+1):\r\n if j==0:\r\n row.append(1)\r\n elif i==0:\r\n row.append(0)\r\n else:\r\n row.append(2)\r\n mat.append(row)\r\n # print(mat)\r\n \r\n # DP table\r\n for i in range(1,N+1):\r\n for j in range(1,p+1):\r\n if arr[i-1]>j:\r\n mat[i][j]=mat[i-1][j]\r\n \r\n else:\r\n mat[i][j]=max(mat[i-1][j],mat[i-1][j-arr[i-1]])\r\n return mat[-1][-1]\r\n\r\n\r\ndef solve(arr,n):\r\n sm = sum(arr)\r\n if sm%2==1:\r\n return False\r\n return equalPartition(sm//2, n, arr)\r\n\r\ndef main():\r\n T = 1\r\n for _ in range(T):\r\n n = ii()\r\n a = li()\r\n if (solve(a, n)) == True:\r\n ans = -1\r\n for i in range(n):\r\n b = [0]*n\r\n k = 0\r\n for j in range(n):\r\n if i==j:\r\n continue\r\n b[k] = a[j]\r\n k += 1\r\n if (solve(b,k) == False):\r\n ans = i\r\n break\r\n if (solve(b,k) == True):\r\n ans = i+1\r\n break\r\n print(1)\r\n print(ans+1)\r\n \r\n\r\n else:\r\n print(0)\r\n\r\n\r\n\r\n\r\n\r\n\r\n# End FASTIO\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "def isSubsetSum(arr, n, sum):\r\n if sum == 0:\r\n return True\r\n if n == 0 and sum != 0:\r\n return False\r\n\r\n if arr[n - 1] > sum:\r\n return isSubsetSum(arr, n - 1, sum)\r\n\r\n return isSubsetSum(arr, n - 1, sum) or isSubsetSum(arr, n - 1, sum - arr[n - 1])\r\n\r\n\r\ndef findPartion(arr, n):\r\n sum = 0\r\n for i in range(0, n):\r\n sum += arr[i]\r\n if sum % 2 != 0:\r\n return False\r\n\r\n return isSubsetSum(arr, n, sum // 2)\r\n\r\n\r\narr = [6, 3, 9, 12]\r\nn = len(arr)\r\n\r\n# Function call\r\nif findPartion(arr, n):\r\n b = [x & -x for x in arr]\r\n i = b.index(min(b))\r\n print(f\"1\\n{i + 1}\")\r\nelse:\r\n print(0)"}, {"source_code": "# 2022-09-04 12:35:14.236880\n# https://codeforces.com/problemset/problem/1516/C\nimport sys\nfrom collections import Counter\n\n_DEBUG = True\nif not _DEBUG:\n input = sys.stdin.readline\n # print = sys.stdout.write\n\n\ndef proc(n, a):\n sa = sum(a)\n\n t = set()\n for e in a:\n for v in list(t):\n t.add(v + e)\n t.add(e)\n\n if sa % 2 == 1 or (sa // 2) not in t:\n return None\n\n for i, e in enumerate(a):\n if e % 2:\n return i + 1\n return 1\n\n\nn = int(input())\na = list(map(int, input().split()))\nans = proc(n, a)\nif not ans:\n print(0)\nelse:\n print(1)\n print(ans)\n"}], "src_uid": "29063ad54712b4911c6bf871969ee147"} {"nl": {"description": "You are given an integer $$$n$$$ from $$$1$$$ to $$$10^{18}$$$ without leading zeroes.In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.What is the minimum number of moves you have to make to obtain a number that is divisible by $$$25$$$? Print -1 if it is impossible to obtain a number that is divisible by $$$25$$$.", "input_spec": "The first line contains an integer $$$n$$$ ($$$1 \\le n \\le 10^{18}$$$). It is guaranteed that the first (left) digit of the number $$$n$$$ is not a zero.", "output_spec": "If it is impossible to obtain a number that is divisible by $$$25$$$, print -1. Otherwise print the minimum number of moves required to obtain such number. Note that you can swap only adjacent digits in the given number.", "sample_inputs": ["5071", "705", "1241367"], "sample_outputs": ["4", "1", "-1"], "notes": "NoteIn the first example one of the possible sequences of moves is 5071 $$$\\rightarrow$$$ 5701 $$$\\rightarrow$$$ 7501 $$$\\rightarrow$$$ 7510 $$$\\rightarrow$$$ 7150."}, "positive_code": [{"source_code": "def swap(ar,ind1,ind2):\n if ind2 > ind1:\n for i in range(ind1,ind2):\n temp = ar[i]\n ar[i] = ar[i+1]\n ar[i+1] = temp\n else:\n for i in range(ind1,ind2,-1):\n temp = ar[i]\n ar[i] = ar[i-1]\n ar[i-1] = temp\n \nn = list(input())\nn2 = len(n)\nans = 100\nfor i in range(n2):\n for j in range(n2):\n nc = [0]*n2\n for i2 in range(n2):\n nc[i2] = n[i2]\n swap(nc,i,n2-1)\n swap(nc,j,n2-2)\n num = 0\n for z in range(n2):\n if nc[z] != \"0\":\n num = z\n break\n swap(nc,0,num)\n if int(\"\".join(nc)) % 25 == 0:\n ans = min(ans,abs(n2-2-j)+abs(n2-1-i)+num)\n \nif ans == 100:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "\ndef finder(n,ind):\n i=ind-1\n while(i>=0):\n if(n[i]==\"0\"):\n break\n else:\n i=i-1\n \n return(i)\n\ndef zeros(n):\n count=0\n pol=1\n while(pol=2):\n c01=l-n.rfind(\"0\")-2\n c02=l-finder(n,n.rfind(\"0\"))-1\n \n ans.append(c01+c02)\n\nif(int(n)%25==0):\n print(0)\nelif(len(ans)==0):\n print(-1)\nelse:\n print(min(ans))\n"}, {"source_code": "INF = 1000\n\n\ndef compute_pair(s, pair):\n n = len(s)\n try:\n l2 = s.rindex(pair[1])\n l1 = s.rindex(pair[0])\n if pair[0] == '0':\n l1 = s[:l2].rindex(pair[1])\n except:\n return INF\n\n steps = abs((n - 2) - l1) + abs((n - 1) - l2)\n if l1 > l2 and l1 != n - 1:\n steps += 1\n\n if l1 == n - 1:\n steps -= 1\n\n l1, l2 = min(l1, l2), max(l1, l2)\n new_s = s[:l1] + s[l1+1:l2] + s[l2+1:]\n if new_s.startswith('0'):\n for i, q in enumerate(new_s):\n if q != '0':\n steps += i\n break\n\n return steps\n\n\ndef main():\n s = input()\n best = INF\n if int(s) < 10:\n print(-1)\n return\n\n for pair in ['00', '25', '50', '75']:\n l = compute_pair(s, pair)\n if l < best:\n best = l\n\n if best == INF:\n best = -1\n\n print(best)\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "s=input()[::-1]\nm=I=41\nf=s.find('5')+1\ni=s.find('0')+1\nt=len(s)\nif i:\n j=min(s.find('0',i)+1or I,f or I)\n if j 1:\n first = s.rfind('0')\n second = s[:first].rfind('0')\n d = n - 1 - first + n - 2 - second\n m = min(m, d)\n elif x != '00' and x[0] in s and x[1] in s:\n first = s.rfind(x[0])\n second = s.rfind(x[1])\n d = n - 1 - second + n - 2 - first\n if second == 0:\n i = 1\n while s[i] == '0':\n i += 1\n d += 1\n if second < first:\n d += 1\n m = min(m, d)\n if float('inf') == m:\n return -1\n return m\n\n\nprint(go())\n"}, {"source_code": "def go(n, c1, c2):\n l = len(n)\n pos2 = n.rfind(c2)\n pos1 = n.rfind(c1)\n if c1 == c2:\n pos1 = n[:pos2].rfind(c1)\n if pos1 == -1 or pos2 == -1:\n return 10 ** 10\n #print(pos1, pos2)\n nxt = 0\n if min(pos1, pos2) == 0:\n nxt = 1\n if max(pos1, pos2) == 1:\n nxt = 2\n ans = 0\n if nxt != l:\n while nxt < l and n[nxt] == '0':\n ans += 1\n nxt += 1\n if nxt == l:\n return 10 ** 10\n ans += l - pos2 - 1\n if pos1 > pos2:\n pos1 -= 1\n ans += (l - pos1 - 2)\n return ans\n\nn = input()\nans = min([go(n, '2', '5'), go(n, '0', '0'), go(n, '7', '5'), go(n, '5', '0')])\nif ans == 10 ** 10:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "s = input();n=len(s)\ndef i(c,o=0): \n try: return s[::-1].index(str(c),o)\n except: return -1\noo=0\nwhile oo=0 else -1\nr=100\nif o01>=0 and o02>=0: r=min(r,o01+o02-1)\nif o01>=0 and o5>=0: r=min(r,o01+o5-int(o01=0 and o2>=0: r=min(r,o5+o2-int(o5=0 and o7>=0: r=min(r,o5+o7-int(o5=0 else -1\nr=100\nif o01>=0 and o02>=0: r=min(r,o01+o02-1)\nif o01>=0 and o5>=0: r=min(r,o01+o5-int(o01=0 and o2>=0: r=min(r,o5+o2-int(o5=0 and o7>=0: r=min(r,o5+o7-int(o5= 2):\n\tres = -1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '0'):\n\t\t\tif(res == -1): res = n-1-i\n\t\t\telse:\n\t\t\t\tres += n-2-i\n\t\t\t\tbreak\n\tans = min(ans,res)\nif(c['0'] and c['5']):\n\tres = 0\n\tf = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '0'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '5'):\n\t\t\tf = 1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-2-i+f\n\t\t\tbreak\n\tans = min(ans,res)\nif(c['2'] and c['5']):\n\tres = 0\n\tf = 0\n\tflag = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '2'):\n\t\t\tf = 1\n\tif(i == 0 and s[1] == '0'):\n\t\tfor i in range(1,n):\n\t\t\tif(s[i] != '0'):\n\t\t\t\tbreak\n\t\tflag = i-1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '2'):\n\t\t\tres += n-2-i+f\n\t\t\tbreak\n\tans = min(ans,res+flag)\nif(c['7'] and c['5']):\n\tres = 0\n\tf = 0\n\tflag = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '7'):\n\t\t\tf = 1\n\tif(i == 0 and s[1] == '0'):\n\t\tfor i in range(1,n):\n\t\t\tif(s[i] != '0'):\n\t\t\t\tbreak\n\t\tflag = i-1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '7'):\n\t\t\tres += n-2-i+f\n\t\t\tbreak\n\tans = min(ans,res+flag)\nif(ans == 1e18):\n\tans = -1\nprint(ans)"}, {"source_code": "s = input()\n\nglobans = 10 ** 9\n\nfor i_ in range(len(s)):\n for j_ in range(len(s)):\n i = i_\n j = j_\n\n if j == i:\n continue\n\n if i == len(s) - 1:\n ans = abs(len(s) - j - 1)\n else:\n ans = abs(len(s) - i - 2) + abs(len(s) - j - 1) + int(j < i)\n\n if i > j:\n i, j = j, i\n\n nw = s[:i] + s[i + 1:j] + s[j + 1:] + s[i_] + s[j_]\n\n for x in range(len(s)):\n if nw[x] == \"0\":\n continue\n ans += x\n nw = nw[x] + nw[:x] + nw[x + 1:]\n break\n\n if int(nw) % 25 == 0:\n globans = min(globans, ans)\n\nif globans == 10 ** 9:\n print(-1)\nelse:\n print(globans)\n"}, {"source_code": "z=input()\nn=len(z)\nmaxa=10**18\ny=int(z)\nif(y%25==0):\n print(0)\n quit()\nif(n==1):\n print(-1)\n quit()\nfor i in range(n):\n for j in range(n):\n if(i==j):\n continue\n copy=list(z)\n swaps=0\n for k in range(i,n-1):\n copy[k],copy[k+1]=copy[k+1],copy[k]\n swaps+=1\n if(j>i):\n j-=1\n for k in range(j,n-2):\n copy[k],copy[k+1]=copy[k+1],copy[k]\n swaps+=1\n if((10*(ord(copy[n-2])-48)+(ord(copy[n-1])-48))%25):\n continue\n if(copy[0]=='0'):\n done=0\n for yo in range(n-2):\n if(copy[yo]!='0'):\n done=1\n swaps+=(yo)\n break\n if(done):\n maxa=min(maxa,swaps)\n else:\n continue\n maxa=min(maxa,swaps)\nif(maxa==10**18):\n print(-1)\nelse:\n print(maxa)\n"}, {"source_code": "s=input()[::-1]\nm=I=41\nf=s.find('5')+1\ni=s.find('0')+1\nt=len(s)\nif i:\n j=min(s.find('0',i)+1or I,f or I)\n if j1:\n g.append(permut(l,'0','0'))\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if (k.rfind('5') > k.rfind('0')):\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('2') > k.rfind('5')):\n temp += 1\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('7') > k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp= INFINITY:\n res = -1\n \n return res\n\n\ndef calc(n, last_digits):\n if not last_digits:\n return 0\n \n idx = n.rfind(last_digits[-1])\n if idx == -1:\n return INFINITY\n \n res = len(n) - idx - 1\n n = n[:idx] + n[(idx+1):]\n last_digits = last_digits[:-1]\n \n extra = 0\n if n and n[0] == '0':\n idx = len(n)\n for digit in \"123456789\":\n if n.find(digit) != -1:\n idx = min(idx, n.find(digit))\n \n if idx == len(n):\n return idx\n \n n = swap(n, 0, idx)\n extra = idx\n \n return res + calc(n, last_digits) + extra\n\n\ndef brute(n):\n q = queue.Queue()\n dis = dict()\n \n q.put(str(n))\n dis[str(n)] = 0\n \n while not q.empty():\n s = q.get()\n if int(s) % 25 == 0:\n return dis[s]\n \n for i in range(1, len(s)):\n j = i - 1\n t = swap(s, i, j)\n \n if t not in dis and t[0] != '0':\n dis[t] = dis[s] + 1\n q.put(t)\n \n return -1\n\n\ndef swap(s, i, j):\n chars = list(s)\n chars[i], chars[j] = chars[j], chars[i]\n return \"\".join(char for char in chars)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def digits(n):\n\treturn len(str(n))\n\ndef digit(n, i):\n\tif i < digits(n):\n\t\treturn int(str(n)[digits(n) - i - 1])\n\n\treturn 0\n\ndef swap_digits(n, i, j):\n\treturn n + digit(n, i) * (10**j - 10**i) + digit(n, j) * (10**i - 10**j)\n\nn = int(input())\n\nif n % 25 == 0:\n\tprint(0)\n\texit()\n\nans = []\n\nfor i in range(digits(n)):\n\tfor j in range(digits(n)):\n\t\tif i == j:\n\t\t\tcontinue\n\n\t\tx, y, cur, cur_ans = i, j, n, 0\n\n\t\tif y > x:\n\t\t\tx += 1\n\n\t\twhile y > 0:\n\t\t\tcur = swap_digits(cur, y, y - 1)\n\t\t\ty -= 1\n\t\t\tcur_ans += 1\n\n\t\twhile x > 1:\n\t\t\tcur = swap_digits(cur, x, x - 1)\n\t\t\tx -= 1\n\t\t\tcur_ans += 1\n\n\t\tfor k in range(digits(n), -1, -1):\n\t\t\tif digit(cur, k) != 0:\n\t\t\t\tcur_ans += (digits(n) - 1) - k\n\t\t\t\tbreak\n\n\t\tif cur % 25 == 0:\n\t\t\tans.append(cur_ans)\n\nprint(min(ans) if len(ans) != 0 else -1)"}, {"source_code": "s=input()\narr=[]\nfor i in s:\n\tarr.append(i)\nans=100000000000\nfor i in range(len(s)):\n\tfor j in range(len(s)):\n\t\tif i==j:\n\t\t\tcontinue\n\t\tt=arr[:] \n\t\t# print('t ori',''.join(t))\n\t\tcurr=0\n\t\tfor k in range(i,len(s)-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t\",''.join(t))\n\t\ttey=0\n\t\tif j>i:\n\t\t\ttey+=1\n\t\tfor k in range(j-tey,len(s)-2,1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t1\",''.join(t))\n\t\tpos=-1\n\t\tfor k in range(len(s)):\n\t\t\tif t[k]!='0':\n\t\t\t\tpos=k \n\t\t\t\tbreak\n\t\tfor k in range(pos,0,-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k-1]\n\t\t\tt[k-1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t2\",''.join(t))\n\t\tif int(''.join(t))%25==0:\n\t\t\tans=min(ans,curr)\nif ans==100000000000:\n\tans=-1\nprint(ans)\n"}, {"source_code": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if (k.rfind('5') > k.rfind('0')):\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('2') > k.rfind('5')):\n temp += 1\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('7') > k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp -1])\n if (cnt == 0 and len(pos0) < 2):\n return -1\n\n res = tam * 2\n if (len(pos0) > 1): #00\n res = min(res, calcSwaps(num, pos0[-2], pos0[-1], tam))\n\n if (pos[0] > -1 and pos[1] > -1): #25\n res = min(res, calcSwaps(num, pos[0], pos[1], tam))\n\n if (pos[1] > -1 and len(pos0) > 0): #50\n res = min(res, calcSwaps(num, pos[1], pos0[-1], tam))\n \n if (pos[2] > -1 and pos[1] > -1): #75\n res = min(res, calcSwaps(num, pos[2], pos[1], tam))\n\n if res == tam *2:\n res = -1\n\n return res\n\ndef main():\n lines = stdin.readlines()\n for line in lines: \n res = solve(line.strip())\n \n stdout.write(str(res))\n stdout.write(\"\\n\")\n\nmain()"}, {"source_code": "s = input()\n\nif int(s)%25 == 0:\n print(0)\nelse:\n sols = []\n d = {}\n n = list(s)\n nr = s[::-1]\n for c in ('0', '2', '5', '7'):\n p = nr.find(c)\n d[c] = p\n \n for c1, c2 in (('2', '5'),('5', '0') , ('7', '5')):\n if c1 not in n or c2 not in n:\n continue\n \n dc1 = d[c1]\n dc2 = d[c2]\n sol = 0\n \n if dc1 == len(n) - 1 and len(n)>1 and n[1] == '0':\n i = 1\n while i len(n) -i -1:\n dc2 -= 1\n \n if dc2 == len(n) - 1 and len(n)>1 and n[1] == '0':\n \n i = 1\n while i len(n) -i -1:\n dc1 -= 1 \n \n \n if dc1 == 0:\n sols.append(dc2 + sol)\n continue\n \n if dc1 < dc2:\n sols.append(dc2 + dc1 + sol)\n \n else:\n sols.append(dc2 + dc1 - 1 + sol)\n\n z1 = nr.find('0')\n if z1!=-1:\n z2 = nr.find('0', z1+1)\n if z2 != -1:\n sols.append(z1 + z2 - 1)\n if len(sols) == 0:\n print(-1)\n else:\n print(min(sols))\n "}, {"source_code": "n=input()\n#25\nif('2' not in n or '5' not in n):a=10**18\nelse:\n a=0\n i=len(n)-1\n while n[i]!='5':\n i-=1\n a+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='2':\n i-=1\n a+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n a+=i \n#75\nif('7' not in n or '5' not in n):b=10**18\nelse:\n b=0\n i=len(n)-1\n while n[i]!='5':\n i-=1\n b+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='7':\n i-=1\n b+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n b+=i \n#50\nif('5' not in n or '0' not in n):c=10**18\nelse:\n c=0\n i=len(n)-1\n while n[i]!='0':\n i-=1\n c+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='5':\n i-=1\n c+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n c+=i \n#00\nif(n.count('0')<2):d=10**18\nelse:\n d=0\n i=len(n)-1\n while n[i]!='0':\n i-=1\n d+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='0':\n i-=1\n d+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n d+=i \nans=min(a,b,c,d)\nif(ans==10**18):print(-1)\nelse:print(ans)"}, {"source_code": "k = input()\nzeroes = [-1, -1]\nfive = -1\ntwo = -1\nseven = -1\nfor i in range(len(k)):\n if k[i] == '0':\n zeroes[zeroes.index(min(zeroes))] = i\n elif k[i] == '2':\n two = i\n elif k[i] == '5':\n five = i\n elif k[i] == '7':\n seven = i\nif len(k) == 3 and k[:2] == '50' and k[-1] != '5' and k[-1] != '0':\n print(2)\nelif k == '5020' or k == '5070':\n print(1)\nelif k[-2:] == '25' or k[-2:] == '00' or k[-2:] == '50' or k[-2:] == '75':\n print(0)\nelif k[-2:] == '52' or k[-2:] == '05' or k[-2:] == '57':\n print(1)\nelif k == '505':\n print(1)\nelif k == '500':\n print(0)\nelif len(k) != 4 and ((k[:3] == '502' and two == 2) or (k[:3] == '507' and seven == 2)):\n print((len(k)))\nelif (len(k) == 4) and (k[:3] == '502' or k[:3] == '507'):\n print(4)\nelif k[:2] == '50' and five == 0 and min(zeroes) == -1 and (seven != -1 or two != -1):\n print(2 * len(k) - max(two, seven) - 1)\nelif k[:2] == '50' and five == 0 and min(zeroes) != -1 and (seven != -1 or two != -1):\n cnt0 = 0\n for u in range(1, len(k)):\n if k[u] == '0':\n cnt0 += 1\n print(min((len(k) * 2 - zeroes[0] - zeroes[1] - 3), (cnt0 - 1 + len(k))))\nelse:\n ch = []\n fl = 0\n if min(zeroes) > -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nx = int(input())\n\nxs = str(x)\nif xs.count('0')<2 and \\\n (xs.count('2') + xs.count('5')) < 2 and \\\n (xs.count('5') + xs.count('0')) < 2 and \\\n (xs.count('7') + xs.count('5')) < 2:\n print '-1'\n sys.exit()\n\ndef f(x,d):\n sx = str(x)\n n = len(sx)\n if sx[-2:] in ('00','25','50','75'):\n return 0\n \n if d<0: return 100\n\n besta = 100\n for i in range(len(sx)-1):\n if sx[i] in '0257':\n if sx[i] in '50':\n inter = [n-2,n-1]\n else:\n inter = [n-2]\n for j in inter:\n if i>=j:continue\n if (i!=0 or sx[i+1]!='0'):\n besta = min(besta, j-i + f(int(''.join((sx[:i],sx[i+1:j+1],sx[i],sx[j+1:]))), d-1))\n \n if i!=0 and sx[i]!='0' and sx[i-1]=='0':\n j = i-1\n while sx[j] == '0':\n j -= 1\n i,j = j+1,i\n besta = min(besta, j-i + f(int(''.join((sx[:i]+sx[j]+sx[i:j],sx[j+1:]))), d-1))\n\n return besta\n\nbest = f(x,3)\n\n\nif best >= 100:\n print -1\nelse:\n print best\n"}, {"source_code": "l = [int(e) for e in input().strip()]\n\ndef lei00(l):\n result = []\n for i in range(len(l)-1, -1, -1):\n if l[i] == 0:\n result.append(i)\n if len(result) == 2:\n break\n if len(result) < 2:\n return None\n return 2 * len(l) - result[0] - result[1] - 3\n\ndef lei(l, x, y):\n assert x != y\n\n ix = None\n iy = None\n\n for i in range(len(l)-1, -1, -1):\n if l[i] == x and ix == None:\n ix = i\n elif l[i] == y and iy == None:\n iy = i\n\n if ix != None and iy != None:\n break\n\n if ix == None or iy == None:\n return None\n\n result = 2 * len(l) - ix - iy - 3\n\n if ix > iy:\n result += 1\n\n if x == 7 or x == 2:\n assert y == 5\n if iy == 0 and l[1] == 0:\n if len(l) >= 4:\n iii = 1\n while True:\n iii += 1\n if l[iii] != 0:\n break\n result += iii-1\n if len(l) == 3:\n return None\n\n\n return result\n\n\nl = [lei00(l), lei(l, 5, 0), lei(l, 7, 5), lei(l, 2, 5)]\n\n\nresult = None\nfor e in l:\n if e == None:\n continue\n if result == None or result > e:\n result = e\n\nif result == None:\n print(-1)\nelse:\n print(result)\n\n\n\n\n\n"}, {"source_code": "s=list(input())\nn=len(s)\nif n==1:\n print(-1)\n exit(0)\nans=2e9\nfor i in range(n):\n for j in range(i+1,n):\n s1=s[:]\n cnt=0\n i1,j1=i+1,j+1\n while j1i:\n\t\t\ttey+=1\n\t\tfor k in range(j-tey,len(s)-2,1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t1\",''.join(t))\n\t\tpos=-1\n\t\tfor k in range(len(s)):\n\t\t\tif t[k]!='0':\n\t\t\t\tpos=k \n\t\t\t\tbreak\n\t\tfor k in range(pos,0,-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k-1]\n\t\t\tt[k-1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t2\",''.join(t))\n\t\tif int(''.join(t))%25==0:\n\t\t\tans=min(ans,curr)\nif ans==100000000000:\n\tans=-1\nprint(ans)\n"}, {"source_code": "import itertools\nimport io\nimport os\n\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndef move(s, prev, next):\n \n cost = abs(prev - next)\n \n s = list(s)\n old = s[prev]\n s = s[:prev] + s[prev+1:]\n s = s[:next] + [old] + s[next:]\n s = \"\".join(s)\n \n return cost, s \n\nn = int(input())\n\nst = str(n)\nl = len(st)\n\nif l == 1:\n print(-1)\n exit()\n\nbest = 10**5\nfor p1, p2, p3 in itertools.product(range(l), repeat=3):\n s = str(st)\n # p1 to front, p2 to back, p3 to second-to-back\n if s[p1] == 0:\n continue\n \n p1_cost, s = move(s, p1, 0)\n if s[0] == \"0\":\n continue\n p2_cost, s = move(s, p2, l-1)\n if s[0] == \"0\":\n continue\n p3_cost, s = move(s, p3, l-2)\n if s[0] == \"0\":\n continue\n \n if s[-2:] in [\"00\", \"25\", \"50\", \"75\"]:\n best = min(best, p1_cost + p2_cost + p3_cost)\n #print(p1_cost + p2_cost + p3_cost, p1, p2, p3, s)\nif best == 10**5:\n print(-1)\nelse:\n print(best)\n"}, {"source_code": "n = input()\n#if int(n) % 25 == 0:\n#\tprint(0)\n#\tquit()\n\nn = list(n)\nif (not(\"5\" in n)) and (not(\"0\" in n)) and (not(\"7\" in n)) and (not(\"2\" in n)):\n\tprint(-1)\n\tquit()\n\t\nwkn = []\nwkn[:] = n\nans = -1\nfor i in reversed(range(len(n))):\n\tif (n[i] == \"0\"):\n\t\twk1 = n[:i] + n[i + 1:] + [n[i]]\n\t\tans = len(n) - i - 1\n\t\tif wk1[0] != \"0\":\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\t\telse:\n\t\t\tcount = 0\n\t\t\tf1 = True\n\t\t\tfor j in wk1:\n\t\t\t\tcount += 1\n\t\t\t\tif j != \"0\":\n\t\t\t\t\tf1 = False\n\t\t\t\t\tbreak\n\t\t\tif f1:\n\t\t\t\tans = -1\n\t\t\t\tbreak\n\t\t\tans += count - 1\n\t\t\twk1 = [wk1[count - 1]] + wk1[:count - 1] + wk1[count:]\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\nif ans != -1:\n\tf = True\n\tfor i in reversed(range(len(n) - 1)):\n\t\tif (n[i] == \"0\") or (n[i] == \"5\"):\n\t\t\twk1 = n[:i] + n[i + 1:-1] + [n[i]]\n\t\t\tans += len(n) - i - 2\n\t\t\tif wk1[0] != \"0\":\n\t\t\t\tf = False\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcount = 0\n\t\t\t\tf1 = True\n\t\t\t\tfor j in wk1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tif j != \"0\":\n\t\t\t\t\t\tf1 = False\n\t\t\t\t\t\tbreak\n\t\t\t\tif f1:\n\t\t\t\t\tans = -1\n\t\t\t\t\tbreak\n\t\t\t\tans += count - 1\n\t\t\t\tf = False\n\t\t\t\tbreak\n\tif f:\n\t\tans = -1\n\t\t\t\nwkans = ans\n\nans = -1\nn = wkn\nfor i in reversed(range(len(n))):\n\tif (n[i] == \"5\"):\n\t\twk1 = n[:i] + n[i + 1:] + [n[i]]\n\t\tans = len(n) - i - 1\n\t\tif wk1[0] != \"0\":\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\t\telse:\n\t\t\tcount = 0\n\t\t\tf1 = True\n\t\t\tfor j in wk1:\n\t\t\t\tcount += 1\n\t\t\t\tif j != \"0\":\n\t\t\t\t\tf1 = False\n\t\t\t\t\tbreak\n\t\t\tif f1:\n\t\t\t\tans = -1\n\t\t\t\tbreak\n\t\t\tans += count - 1\n\t\t\twk1 = [wk1[count - 1]] + wk1[:count - 1] + wk1[count:]\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\t\t\t\nif ans != -1:\n\tf = True\n\tfor i in reversed(range(len(n) - 1)):\n\t\tif (n[i] == \"7\") or (n[i] == \"2\"):\n\t\t\twk1 = n[:i] + n[i + 1: -1] + [n[i]]\n\t\t\tans += len(n) - i - 2\n\t\t\tif wk1[0] != \"0\":\n\t\t\t\tf = False\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcount = 0\n\t\t\t\tf1 = True\n\t\t\t\tfor j in wk1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tif j != \"0\":\n\t\t\t\t\t\tf1 = False\n\t\t\t\t\t\tbreak\n\t\t\t\tif f1:\n\t\t\t\t\tans = -1\n\t\t\t\t\tbreak\n\t\t\t\tans += count - 1\n\t\t\t\tf = False\n\t\t\t\tbreak\n\tif f:\n\t\tans = -1\n\t\t\t\t\nif (wkans == -1):\n\tprint(ans)\n\tquit()\nif (ans == -1):\n\tprint(wkans)\n\tquit()\nprint(min(ans, wkans))\n"}, {"source_code": "import bisect\nimport math\nimport sys\nfrom collections import deque\n\n#input = sys.stdin.readline\n\n\ndef main():\n s = list(input())\n\n def check(last_but_one, last):\n t = s.copy()\n n = len(t)\n res = 0\n\n pos_last = n-1\n while pos_last >= 0 and t[pos_last] != last:\n pos_last -= 1\n if pos_last < 0:\n return False\n while pos_last < n-1:\n t[pos_last], t[pos_last+1] = t[pos_last+1], t[pos_last]\n res += 1\n pos_last += 1\n\n pos_last_but_one = n-2\n while pos_last_but_one >= 0 and t[pos_last_but_one] != last_but_one:\n pos_last_but_one -= 1\n if pos_last_but_one < 0:\n return False\n while pos_last_but_one < n-2:\n t[pos_last_but_one], t[pos_last_but_one+1] = t[pos_last_but_one+1], t[pos_last_but_one]\n res += 1\n pos_last_but_one += 1\n\n if t[-1] != last or t[-2] != last_but_one:\n return False\n\n pos = 0\n while pos < n and t[pos] == '0':\n pos += 1\n if pos == n:\n return False\n\n while pos > 0:\n t[pos-1], t[pos] = t[pos], t[pos-1]\n pos -= 1\n res += 1\n\n if t[-1] != last or t[-2] != last_but_one:\n return False\n\n return res\n\n if len(s) == 1:\n print(-1)\n else:\n ans = math.inf\n for a, b in (('0', '0'), ('2', '5'), ('5', '0'), ('7', '5')):\n if a == s[-2] and b == s[-1]:\n ans = 0\n break\n ver = check(a, b)\n if ver:\n ans = min(ans, ver)\n print(-1 if ans == math.inf else ans)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s=input()\narr=[]\nfor i in s:\n\tarr.append(i)\nans=100000000000\nfor i in range(len(s)):\n\tfor j in range(len(s)):\n\t\tif i==j:\n\t\t\tcontinue\n\t\tt=arr[:] \n\t\t# print('t ori',''.join(t))\n\t\tcurr=0\n\t\tfor k in range(i,len(s)-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t\",''.join(t))\n\t\ttey=0\n\t\tif j>i:\n\t\t\ttey+=1\n\t\tfor k in range(j-tey,len(s)-2,1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t1\",''.join(t))\n\t\tpos=-1\n\t\tfor k in range(len(s)):\n\t\t\tif t[k]!='0':\n\t\t\t\tpos=k \n\t\t\t\tbreak\n\t\tfor k in range(pos,0,-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k-1]\n\t\t\tt[k-1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t2\",''.join(t))\n\t\tif int(''.join(t))%25==0:\n\t\t\tans=min(ans,curr)\nif ans==100000000000:\n\tans=-1\nprint(ans)\n"}, {"source_code": "k = input()\nzeroes = [-1, -1]\nfive = -1\ntwo = -1\nseven = -1\nfor i in range(len(k)):\n if k[i] == '0':\n zeroes[zeroes.index(min(zeroes))] = i\n elif k[i] == '2':\n two = i\n elif k[i] == '5':\n five = i\n elif k[i] == '7':\n seven = i\nif len(k) == 3 and k[:2] == '50' and k[-1] != '5' and k[-1] != '0':\n print(2)\nelif k == '5020' or k == '5070':\n print(1)\nelif k[-2:] == '25' or k[-2:] == '00' or k[-2:] == '50' or k[-2:] == '75':\n print(0)\nelif k[-2:] == '52' or k[-2:] == '05' or k[-2:] == '57':\n print(1)\nelif k == '505':\n print(1)\nelif k == '500':\n print(0)\nelif len(k) != 4 and ((k[:3] == '502' and two == 2) or (k[:3] == '507' and seven == 2)):\n print((len(k)))\nelif (len(k) == 4) and (k[:3] == '502' or k[:3] == '507'):\n print(4)\nelif k[:2] == '50' and five == 0 and min(zeroes) == -1 and (seven != -1 or two != -1):\n print(2 * len(k) - max(two, seven) - 1)\nelif k[:2] == '50' and five == 0 and min(zeroes) != -1 and (seven != -1 or two != -1):\n cnt0 = 0\n for u in range(1, len(k)):\n if k[u] == '0':\n cnt0 += 1\n print(min((len(k) * 2 - zeroes[0] - zeroes[1] - 3), (cnt0 - 1 + len(k))))\nelse:\n ch = []\n fl = 0\n if min(zeroes) > -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "s=list(input())\nn=len(s)\nif n==1:\n print(-1)\n exit(0)\nans=2e9\nfor i in range(n):\n for j in range(i+1,n):\n s1=s[:]\n cnt=0\n i1,j1=i+1,j+1\n while j1 k.rfind('0')):\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('2') > k.rfind('5')):\n temp += 1\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('7') > k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "a=str(raw_input())\nif ('5' in a and '0' in a) or ('7' in a and '5' in a) or ('2' in a and '5' in a) or (a.count('0')>=2):\n res=[]\n if '5' in a and '0' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n a1.insert(0,'0')\n r+=a1.index('5')-1\n a1.remove('5')\n a1.remove('0')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '7' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('7')-1\n a1.remove('7')\n a1.remove('5')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '2' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('2')-1\n a1.remove('2')\n a1.remove('5')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if a.count('0')>=2:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n r+=a1.index('0')\n a1.remove('0')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if len(res)>0:\n print min(res)\n else:\n print -1\n \n \n \n \nelse:\n print -1\n \n \n"}, {"source_code": "s = input()[::-1]\nt = len(s)\ndef g(c, i = 0):\n return s.find(str(c), i) + 1 or 50\ni, f = g(0), g(5)\nj = min(g(0, i), f)\nm = i + j + (j < i)\nj = min(g(2), g(7))\nl = f + j + (j < f)\nif f == t:\n while s[f - 2] == '0':\n f-=1\n l += t - f\nm = min(m, l)\nprint((-1, m - 3)[m < 40])"}, {"source_code": "def main():\n ar = list(input())\n size = len(ar)\n ans = 1e5\n for i in range(size):\n for j in range(size):\n if i == j:\n continue\n s = list(ar)\n cost = 0\n for k in range(i, size - 1):\n tmp = s[k]\n s[k] = s[k + 1]\n s[k + 1] = tmp\n cost += 1\n if i < j:\n for k in range(j - 1, size - 2):\n tmp = s[k]\n s[k] = s[k + 1]\n s[k + 1] = tmp\n cost += 1\n else:\n for k in range(j, size - 2):\n tmp = s[k]\n s[k] = s[k + 1]\n s[k + 1] = tmp\n cost += 1\n pos = -1\n for k in range(size):\n if s[k] != '0':\n pos = k\n break\n for k in range(pos, 0, -1):\n tmp = s[k]\n s[k] = s[k - 1]\n s[k - 1] = tmp\n cost += 1\n curr_num = int(''.join(s))\n if curr_num % 25 == 0:\n ans = min(ans, cost)\n if ans == 1e5:\n print(-1)\n else:\n print(ans) \n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "s = input();n=len(s)\ndef i(c,o=0): \n try: return s[::-1].index(str(c),o)\n except: return -1\noo=0\nwhile oo=0 else -1\nr=100\nif o01>=0 and o02>=0: r=min(r,o01+o02-1)\nif o01>=0 and o5>=0: r=min(r,o01+o5-int(o01=0 and o2>=0: r=min(r,o5+o2-int(o5=0 and o7>=0: r=min(r,o5+o7-int(o5 -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "\nA_str = input()\n\nA = list(A_str)\n\nB = [\n ['2', '5'],\n ['5', '0'],\n ['7', '5']\n]\n\nresult = 10**9\n\nif int(A_str) % 100 == 0:\n print(0)\nelse:\n for a, b in B:\n if a not in A or b not in A:\n continue\n\n cresult = 0\n\n tmp_str = A_str[:]\n i = tmp_str.rfind(b)\n cresult += len(tmp_str) - 1 - i\n tmp_str = ''.join(A[:i] + A[i + 1:] + [A[i]])\n\n\n i = tmp_str.rfind(a)\n cresult += len(tmp_str) - 2 - i\n tmp_str = list(tmp_str)\n tmp_str = ''.join(tmp_str[:i] + tmp_str[i + 1:-1] + [tmp_str[i]] + [tmp_str[-1]])\n\n for i in range(len(tmp_str)):\n if tmp_str[i] != '0':\n break\n\n result = min([result, cresult + i])\n\n if A.count('0') > 1:\n cresult = 0\n i = A_str.rfind('0')\n cresult += len(A_str) - 1 - i\n A_str = A_str[:i] + A_str[i + 1:] + A[i]\n i = A_str[:-1].rfind('0')\n cresult += len(A_str) - 2 - i\n\n result = min([result, cresult])\n\n if result < 10**9:\n print(result)\n else:\n print(-1)\n\n\n"}, {"source_code": "\nA_str = input()\n\nA = list(A_str)\n\nB = [\n ['2', '5'],\n ['5', '0'],\n ['7', '5']\n]\n\nresult = 10**9\n\nif int(A_str) % 100 == 0:\n print(0)\nelse:\n for a, b in B:\n if a not in A or b not in A:\n continue\n\n cresult = 0\n\n tmp_str = A_str[:]\n i = tmp_str.rfind(b)\n cresult += len(tmp_str) - 1 - i\n tmp_str = ''.join(A[:i] + A[i + 1:] + [A[i]])\n\n\n i = tmp_str.rfind(a)\n cresult += len(tmp_str) - 2 - i\n tmp_str = list(tmp_str)\n tmp_str = ''.join(tmp_str[:i] + tmp_str[i + 1:-1] + [tmp_str[i]] + [tmp_str[-1]])\n\n for i in range(len(tmp_str)):\n if tmp_str[i] != '0':\n break\n\n result = min([result, cresult + i])\n\n if A.count('0') > 1:\n cresult = 0\n i = A_str.rfind('0')\n cresult += len(A_str) - 1 - i\n A_str = A_str[:i] + A_str[i + 1:] + A[i]\n i = A_str[:-1].rfind('0')\n cresult += len(A_str) - 2 - i\n\n result = min([result, cresult])\n\n if result < 10**9:\n print(result)\n else:\n print(-1)\n\n\n"}, {"source_code": "n=input()\n#25\nif('2' not in n or '5' not in n):a=10**18\nelse:\n a=0\n i=len(n)-1\n while n[i]!='5':\n i-=1\n a+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='2':\n i-=1\n a+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n a+=i \n#75\nif('7' not in n or '5' not in n):b=10**18\nelse:\n b=0\n i=len(n)-1\n while n[i]!='5':\n i-=1\n b+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='7':\n i-=1\n b+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n b+=i \n#50\nif('5' not in n or '0' not in n):c=10**18\nelse:\n c=0\n i=len(n)-1\n while n[i]!='0':\n i-=1\n c+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='5':\n i-=1\n c+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n c+=i \n#00\nif(n.count('0')<2):d=10**18\nelse:\n d=0\n i=len(n)-1\n while n[i]!='0':\n i-=1\n d+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='0':\n i-=1\n d+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n d+=i \nans=min(a,b,c,d)\nif(ans==10**18):print(-1)\nelse:print(ans)"}, {"source_code": "s=input()[::-1]\nt=len(s)\ndef g(c,i=0):return s.find(str(c),i)+1or 50\ni,f=g(0),g(5)\nj=min(g(0,i),f)\nm=i+j+(j= 2:\n i = s.rfind('0')\n j = s.rfind('0', 0, i)\n i = length-1-i\n j = length-2-j\n # print(i,j)\n ans = min(ans, i+j)\n\n if digits[2] >= 1 and digits[5] >= 1:\n i = s.rfind('2')\n j = s.rfind('5')\n inc = False\n if j < i: inc = True\n if i == 0:\n i = length-3+leading_zero_inc\n else:\n i = length-2-i\n if j == 0:\n j = length-2+leading_zero_inc\n else:\n j = length-1-j\n # print(i,j)\n ans = min(ans, i+j+inc)\n\n if digits[5] >= 1 and digits[0] >= 1:\n i = s.rfind('5')\n j = s.rfind('0')\n inc = False\n if j < i: inc = True\n\n if i == 0 and j != 1:\n i = length-3+leading_zero_inc\n else:\n i = length-2-i\n j = length-1-j\n # print(i,j)\n ans = min(ans, i+j+inc)\n\n if digits[7] >= 1 and digits[5] >= 1:\n i = s.rfind('7')\n j = s.rfind('5')\n inc = False\n if j < i: inc = True\n\n if i == 0:\n i = length-3+leading_zero_inc\n else:\n i = length-2-i\n if j == 0:\n j = length-2+leading_zero_inc\n else:\n j = length-1-j\n # print(i,j)\n ans = min(ans, i+j+inc)\n\n if ans == sys.maxsize:\n ans = -1\n print(ans)\n\n\n"}, {"source_code": "def idx(s, c, start = 0):\n try:\n return s[::-1].index(c, start)\n except:\n return -1\n\n\ndef main():\n s = input()\n zero_cnt = 0\n while zero_cnt < len(s) - 1 and s[zero_cnt + 1] == '0':\n zero_cnt += 1\n\n i01 = idx(s, '0')\n i02 = idx(s, '0', i01 + 1)\n i2 = idx(s, '2')\n i5 = idx(s, '5')\n i7 = idx(s, '7')\n\n r = 666\n if i01 != -1 and i02 != -1:\n r = min(r, i01 + (i02 - 1))\n if i2 != -1 and i5 != -1:\n r = min(r, i2 + i5 - int(i2 > i5) + int((i2 == len(s) - 1 or i5 == len(s) - 1) and zero_cnt))\n if i5 != -1 and i01 != -1:\n # if there are more than 2 0s this one would never be the final answer\n r = min(r, i5 + i01 - int(i5 > i01))\n if i7 != -1 and i5 != -1:\n # 1 and 3 --> 3\n r = min(r, i7 + i5 - int(i7 > i5) + int((i7 == len(s) - 1 or i5 == len(s) - 1) and zero_cnt))\n\n print(r if r != 666 else -1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\nnum = input()\nlength = len(num)\nminimum = sys.maxsize\npossibles = [\"25\", \"50\", \"75\", \"00\"]\n\nfor possible in possibles:\n if possible[0] == possible[1] and num.count('0') > 1:\n first = num.rfind(possible[0])\n second = num[:first].rfind(possible[1])\n temp_min = length - 2 - second + length - 1 - first\n minimum = min(minimum, temp_min)\n elif possible[0] != possible[1] and possible[0] in num and possible[1] in num:\n first = num.rfind(possible[0])\n second = num.rfind(possible[1])\n \n temp_min = length - 2 - first + length - 1 - second\n \n if (second == 0) and length > 3:\n i = 1\n while num[i] == '0':\n temp_min += 1\n i += 1\n \n if first > second:\n temp_min += 1\n minimum = min(minimum, temp_min)\n\nif minimum == sys.maxsize:\n print(-1)\nelse:\n print(minimum)"}, {"source_code": "s = input()\n\nif int(s)%25 == 0:\n print(0)\nelse:\n sols = []\n d = {}\n n = list(s)\n nr = s[::-1]\n for c in ('0', '2', '5', '7'):\n p = nr.find(c)\n d[c] = p\n \n for c1, c2 in (('2', '5'),('5', '0') , ('7', '5')):\n if c1 not in n or c2 not in n:\n continue\n \n dc1 = d[c1]\n dc2 = d[c2]\n sol = 0\n \n if dc1 == len(n) - 1 and len(n)>1 and n[1] == '0':\n i = 1\n while i len(n) -i -1:\n dc2 -= 1\n \n if dc2 == len(n) - 1 and len(n)>1 and n[1] == '0':\n \n i = 1\n while i len(n) -i -1:\n dc1 -= 1 \n \n \n if dc1 == 0:\n sols.append(dc2 + sol)\n continue\n \n if dc1 < dc2:\n sols.append(dc2 + dc1 + sol)\n \n else:\n sols.append(dc2 + dc1 - 1 + sol)\n\n z1 = nr.find('0')\n if z1!=-1:\n z2 = nr.find('0', z1+1)\n if z2 != -1:\n sols.append(z1 + z2 - 1)\n if len(sols) == 0:\n print(-1)\n else:\n print(min(sols))\n "}, {"source_code": "k = input()\nn = len(k)\nimport sys\nMin = sys.maxsize\nck = ['50','25','75']\nfor c in ck:\n if c[0] in k and c[1] in k:\n temp = 2*n - 3 - k.rfind(c[0]) - k.rfind(c[1]) \n if (c[1]=='5'):\n if k.rfind('5')==0 and k[1]=='0' and n>3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n temp += k.rfind(c[0]) > k.rfind(c[1])\n Min = min(temp,Min)\nif k.count('0')>1:\n css = k.rfind('0')\n temp = n-1 - css\n k = k[:css] + k[css+1:] \n temp += len(k)-1 - k.rfind('0')\n Min = min(temp,Min)\nprint([Min,-1][Min==sys.maxsize])"}, {"source_code": "\ndef finder(n,ind):\n i=ind-1\n while(i>=0):\n if(n[i]==\"0\"):\n break\n else:\n i=i-1\n \n return(i)\n\ndef zeros(n):\n count=0\n pol=1\n while(pol=2):\n c01=l-n.rfind(\"0\")-2\n c02=l-finder(n,n.rfind(\"0\"))-1\n \n ans.append(c01+c02)\n\nif(int(n)%25==0):\n print(0)\nelif(len(ans)==0):\n print(-1)\nelse:\n print(min(ans))\n"}, {"source_code": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if (k.rfind('5') > k.rfind('0')):\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('2') > k.rfind('5')):\n temp += 1\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('7') > k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp=0):\n if(n[i]==\"0\"):\n break\n else:\n i=i-1\n \n return(i)\n\ndef zeros(n):\n count=0\n pol=1\n while(pol=2):\n c01=l-n.rfind(\"0\")-2\n c02=l-finder(n,n.rfind(\"0\"))-1\n \n ans.append(c01+c02)\n\nif(int(n)%25==0):\n print(0)\nelif(len(ans)==0):\n print(-1)\nelse:\n print(min(ans))\n"}, {"source_code": "s=input()[::-1]\nt=len(s)\nm=I=40\ndef g(c,i=0):return s.find(str(c),i)+1 or I\ni,f=g(0),g(5)\nif i-1 and s1[x]==\"0\" and ai==len(s)-1 and len(s)!=1:\n x-=1\n s=a+s1[0:ai]+s1[ai+1::]\n if x==-1 and len(s)!=1:\n return [False]\n if s1[x+1]==\"0\":\n s=s[0:x+1]+s[x+2::]+s1[x]\n return [True,ai+len(s)-2-x,s[::-1]]\ns=input()\nans=10**6\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"0\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"5\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"7\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"2\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nif s=='0':\n print(s)\nelif ans==10**6:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "#!/usr/bin/python3\n\nfrom sys import stdin\n\n\ndef f(n, x, y):\n ans = 0\n # 1\n cur = n.rfind(y)\n if cur < 0:\n return 10 ** 18\n ans += len(n) - 1 - cur\n n = n[:cur] + n[cur + 1:] + y\n\n # 2\n cur = n[:-1].rfind(x)\n if cur < 0:\n return 10 ** 18\n ans += len(n) - 2 - cur\n n = n[:-1][:cur] + n[:-1][cur + 1:] + x + y\n\n # 3\n cur = 0\n has0 = False\n while (cur < len(n) - 2) and (n[cur] == '0'):\n has0 = True\n cur += 1\n if has0 and (cur >= len(n) - 2):\n return 10 ** 18\n return ans + cur\n\n\ndef main():\n for line in stdin.readlines():\n n = line.strip()\n ret = [\n f(n, '2', '5'),\n f(n, '7', '5'),\n f(n, '5', '0'),\n f(n, '0', '0')\n ]\n if min(ret) == 10**18:\n print(-1)\n else:\n print(min(ret))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = input()\n\nif int(s)%25 == 0:\n print(0)\nelse:\n sols = []\n d = {}\n n = list(s)\n nr = s[::-1]\n for c in ('0', '2', '5', '7'):\n p = nr.find(c)\n d[c] = p\n \n for c1, c2 in (('2', '5'),('5', '0') , ('7', '5')):\n if c1 not in n or c2 not in n:\n continue\n \n dc1 = d[c1]\n dc2 = d[c2]\n sol = 0\n \n if dc1 == len(n) - 1 and len(n)>1 and n[1] == '0':\n i = 1\n while i len(n) -i -1:\n dc2 -= 1\n \n if dc2 == len(n) - 1 and len(n)>1 and n[1] == '0':\n \n i = 1\n while i len(n) -i -1:\n dc1 -= 1 \n \n \n if dc1 == 0:\n sols.append(dc2 + sol)\n continue\n \n if dc1 < dc2:\n sols.append(dc2 + dc1 + sol)\n \n else:\n sols.append(dc2 + dc1 - 1 + sol)\n\n z1 = nr.find('0')\n if z1!=-1:\n z2 = nr.find('0', z1+1)\n if z2 != -1:\n sols.append(z1 + z2 - 1)\n if len(sols) == 0:\n print(-1)\n else:\n print(min(sols))\n "}, {"source_code": "def swipe(s, i):\n return s[:i] + s[i + 1] + s[i] + (s[i + 2:] if i + 2 < len(s) else \"\")\n\n\ndef nazis(s):\n m = float(\"inf\")\n for i in range(9):\n if s.find(str(i + 1)) > -1:\n m = min(s.find(str(i + 1)), m)\n return m\n\n\nn = input()\nc = float(\"inf\")\nif n.count(\"0\") >= 2 or \"5\" in n and \"0\" in n or \"2\" in n and \"5\" in n or \"7\" in n and \"5\" in n:\n s = n\n if n.count(\"0\") >= 2:\n a = n.rfind(\"0\")\n b = n.rfind(\"0\", 0, a)\n c = 2 * len(n) - a - b - 3\n if \"5\" in n and \"0\" in n:\n cc = 0\n a = n.rfind(\"0\")\n while n[-1] != \"0\":\n n = swipe(n, a)\n a += 1\n cc += 1\n b = n.rfind(\"5\")\n while n[-2] != \"5\":\n n = swipe(n, b)\n b += 1\n cc += 1\n if n[0] == \"0\":\n cc += nazis(n)\n c = min(c, cc)\n if \"2\" in n and \"5\" in n:\n n = s\n cc = 0\n b = n.rfind(\"5\")\n while n[-1] != \"5\":\n n = swipe(n, b)\n b += 1\n cc += 1\n a = n.rfind(\"2\")\n while n[-2] != \"2\":\n n = swipe(n, a)\n a += 1\n cc += 1\n if n[0] == \"0\":\n cc += nazis(n)\n c = min(c, cc)\n if \"7\" in n and \"5\" in n:\n n = s\n cc = 0\n b = n.rfind(\"5\")\n while n[-1] != \"5\":\n n = swipe(n, b)\n b += 1\n cc += 1\n a = n.rfind(\"7\")\n while n[-2] != \"7\":\n n = swipe(n, a)\n a += 1\n cc += 1\n if n[0] == \"0\":\n cc += nazis(n)\n c = min(c, cc)\n print(c)\nelse:\n print(-1)\n"}, {"source_code": "from bisect import bisect_right, bisect_left\n\nn = input().strip()\n\nres = 1e18\n\n\ndef solve(x, y):\n global res\n cur = [x for x in n]\n c = 0\n for i in range(x, len(cur) - 1):\n cur[i], cur[i + 1] = cur[i + 1], cur[i]\n c += 1\n for i in range(y - (y > x), len(cur) - 2):\n cur[i], cur[i + 1] = cur[i + 1], cur[i]\n c += 1\n\n p = -1\n\n for i, e in enumerate(cur):\n if e != '0':\n p = i\n break\n\n for i in range(p, 0, -1):\n cur[i], cur[i - 1] = cur[i - 1], cur[i]\n c += 1\n\n if int(''.join(cur)) % 25 == 0:\n res = min(res, c)\n\n\nfor i in range(len(n)):\n for j in range(len(n)):\n if i != j:\n solve(i, j)\n\nif res == 1e18:\n print(-1)\nelse:\n print(res)\n\n\n\n\n\n\n# a = [abs(int(x)) for x in input().split(' ')]\n\n\n"}, {"source_code": "def swipe(s, i):\n return s[:i] + s[i + 1] + s[i] + (s[i + 2:] if i + 2 < len(s) else \"\")\n\n\ndef nazis(s):\n m = float(\"inf\")\n for i in range(9):\n if s.find(str(i + 1)) > -1:\n m = min(s.find(str(i + 1)), m)\n return m\n\n\nn = input()\nc = float(\"inf\")\nif n.count(\"0\") >= 2 or \"5\" in n and \"0\" in n or \"2\" in n and \"5\" in n or \"7\" in n and \"5\" in n:\n s = n\n if n.count(\"0\") >= 2:\n a = n.rfind(\"0\")\n b = n.rfind(\"0\", 0, a)\n c = 2 * len(n) - a - b - 3\n if \"5\" in n and \"0\" in n:\n cc = 0\n a = n.rfind(\"0\")\n while n[-1] != \"0\":\n n = swipe(n, a)\n a += 1\n cc += 1\n b = n.rfind(\"5\")\n while n[-2] != \"5\":\n n = swipe(n, b)\n b += 1\n cc += 1\n if n[0] == \"0\":\n cc += nazis(n)\n c = min(c, cc)\n if \"2\" in n and \"5\" in n:\n n = s\n cc = 0\n b = n.rfind(\"5\")\n while n[-1] != \"5\":\n n = swipe(n, b)\n b += 1\n cc += 1\n a = n.rfind(\"2\")\n while n[-2] != \"2\":\n n = swipe(n, a)\n a += 1\n cc += 1\n if n[0] == \"0\":\n cc += nazis(n)\n c = min(c, cc)\n if \"7\" in n and \"5\" in n:\n n = s\n cc = 0\n b = n.rfind(\"5\")\n while n[-1] != \"5\":\n n = swipe(n, b)\n b += 1\n cc += 1\n a = n.rfind(\"7\")\n while n[-2] != \"7\":\n n = swipe(n, a)\n a += 1\n cc += 1\n if n[0] == \"0\":\n cc += nazis(n)\n c = min(c, cc)\n print(c)\nelse:\n print(-1)\n"}, {"source_code": "n=input()\n#25\nif('2' not in n or '5' not in n):a=10**18\nelse:\n a=0\n i=len(n)-1\n while n[i]!='5':\n i-=1\n a+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='2':\n i-=1\n a+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n a+=i \n#75\nif('7' not in n or '5' not in n):b=10**18\nelse:\n b=0\n i=len(n)-1\n while n[i]!='5':\n i-=1\n b+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='7':\n i-=1\n b+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n b+=i \n#50\nif('5' not in n or '0' not in n):c=10**18\nelse:\n c=0\n i=len(n)-1\n while n[i]!='0':\n i-=1\n c+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='5':\n i-=1\n c+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n c+=i \n#00\nif(n.count('0')<2):d=10**18\nelse:\n d=0\n i=len(n)-1\n while n[i]!='0':\n i-=1\n d+=1\n updated_n=n[0:i]+n[i+1:]\n i=len(n)-2\n while updated_n[i]!='0':\n i-=1\n d+=1\n updated_n=updated_n[0:i]+updated_n[i+1:]\n for i in range(len(updated_n)):\n if(updated_n[i]!='0'):\n break\n d+=i \nans=min(a,b,c,d)\nif(ans==10**18):print(-1)\nelse:print(ans)"}, {"source_code": "from copy import deepcopy\ndef nonzeroind(l):\n l.reverse()\n for i in range(1,len(l)):\n if l[i]!=0:\n return len(l)-1-i\n i=i+1\n return -1\n\n\n\ndef parse(nl,num):\n try:\n i=nl.index(num)\n except:\n return (60,nl)\n if (i==len(nl)-1 and nl[i-1]==0):\n ind=nonzeroind(nl)\n nl.reverse()\n if ind==-1:\n return(60,nl)\n else:\n nl[i-1]=nl[ind]\n nl[ind]=0\n intermed=parse(deepcopy(nl),num)\n return (intermed[0]+i-1-ind,intermed[1])\n else:\n nl.pop(i)\n return (i,nl)\nnum=input('')\nnumarr=[]\nfor dig in num:\n numarr.append(int(dig))\nnumarr.reverse()\no11=parse(deepcopy(numarr),5)\no12=parse(o11[1],7)\no21=parse(deepcopy(numarr),5)\no22=parse(o21[1],2)\no31=parse(deepcopy(numarr),0)\no32=parse(o31[1],5)\no41=parse(deepcopy(numarr),0)\no42=parse(o41[1],0)\nans=min(o11[0]+o12[0],o21[0]+o22[0],o31[0]+o32[0],o41[0]+o42[0])\nif(ans>40):\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "\ndef solve(n):\n if int(n) % 25 == 0: return 0\n if n in {'52', '57'}: return 1\n ans = float('inf')\n for x, y in ['00', '25', '50', '75']:\n for i in range(len(n)):\n if n[i] == '0': continue\n for j in range(len(n)):\n if i == j or n[j] != x: continue\n for k in range(len(n)):\n if k in {i, j} or n[k] != y: continue\n ans = min(ans, len(n) * 2 - 3 + i - j - k + (j > k) - (i > j) - (i > k))\n return ans if ans < float('inf') else -1\n\nprint(solve(input()))\n"}, {"source_code": "s=input()[::-1]\nt=len(s)\ndef g(c,i=0):return s.find(str(c),i)+1or 50\ni,f=g(0),g(5)\nj=min(g(0,i),f)\nm=i+j-3+(ji:\n\t\t\ttey+=1\n\t\tfor k in range(j-tey,len(s)-2,1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t1\",''.join(t))\n\t\tpos=-1\n\t\tfor k in range(len(s)):\n\t\t\tif t[k]!='0':\n\t\t\t\tpos=k \n\t\t\t\tbreak\n\t\tfor k in range(pos,0,-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k-1]\n\t\t\tt[k-1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t2\",''.join(t))\n\t\tif int(''.join(t))%25==0:\n\t\t\tans=min(ans,curr)\nif ans==100000000000:\n\tans=-1\nprint(ans)\n"}, {"source_code": "s=input()\narr=[]\nfor i in s:\n\tarr.append(i)\nans=100000000000\nfor i in range(len(s)):\n\tfor j in range(len(s)):\n\t\tif i==j:\n\t\t\tcontinue\n\t\tt=arr[:] \n\t\t# print('t ori',''.join(t))\n\t\tcurr=0\n\t\tfor k in range(i,len(s)-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t\",''.join(t))\n\t\ttey=0\n\t\tif j>i:\n\t\t\ttey+=1\n\t\tfor k in range(j-tey,len(s)-2,1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k+1]\n\t\t\tt[k+1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t1\",''.join(t))\n\t\tpos=-1\n\t\tfor k in range(len(s)):\n\t\t\tif t[k]!='0':\n\t\t\t\tpos=k \n\t\t\t\tbreak\n\t\tfor k in range(pos,0,-1):\n\t\t\ttt=t[k]\n\t\t\tt[k]=t[k-1]\n\t\t\tt[k-1]=tt \n\t\t\tcurr+=1\n\t\t# print(\"t2\",''.join(t))\n\t\tif int(''.join(t))%25==0:\n\t\t\tans=min(ans,curr)\nif ans==100000000000:\n\tans=-1\nprint(ans)\n"}, {"source_code": "\n# coding: utf-8\n\n# In[1]:\n\ns=input()[::-1]\nl=len(s)\ndef f(c,i=0):return s.find(c,i)+1 or 50\ni0_1=f('0')\ni5=f('5')\ni05=min(f('0',i0_1),i5)\nm1=i0_1+i05+(i05= 2):\n\tres = -1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '0'):\n\t\t\tif(res == -1): res = n-1-i\n\t\t\telse:\n\t\t\t\tres += n-2-i\n\t\t\t\tbreak\n\tans = min(ans,res)\nif(c['0'] and c['5']):\n\tres = 0\n\tf = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '0'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '5'):\n\t\t\tf = 1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += max(0,n-2-i+f)\n\t\t\tbreak\n\tans = min(ans,res)\nif(c['2'] and c['5']):\n\tres = 0\n\tf = 0\n\tflag = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '2'):\n\t\t\tf = 1\n\tif(i == 0 and s[1] == '0'):\n\t\tfor i in range(1,n):\n\t\t\tif(s[i] != '0'):\n\t\t\t\tbreak\n\t\tflag = i-1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '2'):\n\t\t\tres += max(0,n-2-i+f)\n\t\t\tbreak\n\tans = min(ans,res+flag)\nif(c['7'] and c['5']):\n\tres = 0\n\tf = 0\n\tflag = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '7'):\n\t\t\tf = 1\n\tif(i == 0 and s[1] == '0'):\n\t\tfor i in range(1,n):\n\t\t\tif(s[i] != '0'):\n\t\t\t\tbreak\n\t\tflag = i-1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '7'):\n\t\t\tres += max(0,n-2-i+f)\n\t\t\tbreak\n\tans = min(ans,res+flag)\nif(ans == 1e18):\n\tans = -1\nprint(ans)\n\n"}, {"source_code": "s=input()[::-1]\nt=len(s)\ng=lambda c,i=0:s.find(str(c), i)+1or 50\ni,f=g(0),g(5)\nj=min(g(0,i),f)\nm=i+j+(j1):\n first = n.rfind(x[0])\n second = n[:first].rfind(x[1])\n step = length - 1 - second + length - 2 - first\n minn = min(step,minn)\n elif(x[0] != x[1] and x[0] in n and x[1] in n):\n i = 1\n first = n.rfind(x[0])\n second = n.rfind(x[1])\n step = length - 1 - second + length - 2 - first\n if second == 0:\n while(n[i] == '0'):\n step += 1\n i += 1\n if second < first:\n step += 1\n minn = min(minn, step)\nif(minn == sys.maxsize):\n print(\"-1\")\nelse:\n print(minn)\n"}, {"source_code": "s = raw_input().strip()\nn = len(s)\nans = float('inf')\n\n# steps to get 00\nidxlist = []\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '0':\n idxlist.append(i)\n\n if len(idxlist) == 2: break\n\nif len(idxlist) == 2:\n p1, p2 = idxlist\n ans = min(ans, (n - 1 - p2) + (n - 2 - p1))\n\n# steps to get to 25\np2, p5 = -1, -1\nfl = 0\ncur = -1\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '5' and p5 == -1:\n p5 = i\n if s[i] == '2' and p2 == -1:\n p2 = i\n if p2 != -1 and p5 != -1:\n cur = (n - 1 - p5) + (n - 2 - p2)\n if p5 < p2: cur += 1\n fl = 1\n break\n\nif fl == 1:\n news = []\n for i in xrange(n):\n if i == p2 or i == p5: continue\n news.append(s[i])\n\n if len(news) == 0: ans = min(ans, cur)\n\n i = 0\n while i < len(news) and news[i] == '0': i += 1\n if i != len(news):\n ans = min(ans, cur + i)\n\n# steps to get to 50\np5, p0 = -1, -1\nfl = 0\ncur = -1\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '0' and p0 == -1:\n p0 = i\n if s[i] == '5' and p5 == -1:\n p5 = i\n if p5 != -1 and p0 != -1:\n cur = (n - 1 - p0) + (n - 2 - p5)\n if p0 < p5: cur += 1\n fl = 1\n break\n\nif fl == 1:\n news = []\n for i in xrange(n):\n if i == p0 or i == p5: continue\n news.append(s[i])\n\n if len(news) == 0: ans = min(ans, cur)\n\n i = 0\n while i < len(news) and news[i] == '0': i += 1\n if i != len(news):\n ans = min(ans, cur + i)\n \n# steps to get to 75\np7, p5 = -1, -1\nfl = 0\ncur = -1\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '5' and p5 == -1:\n p5 = i\n if s[i] == '7' and p7 == -1:\n p7 = i\n if p7 != -1 and p5 != -1:\n cur = (n - 1 - p5) + (n - 2 - p7)\n if p5 < p7: cur += 1\n fl = 1\n break\n\nif fl == 1:\n news = []\n for i in xrange(n):\n if i == p7 or i == p5: continue\n news.append(s[i])\n\n if len(news) == 0: ans = min(ans, cur)\n\n i = 0\n while i < len(news) and news[i] == '0': i += 1\n if i != len(news):\n ans = min(ans, cur + i)\n\nif ans == float('inf'):\n print -1\nelse:\n print ans\n"}, {"source_code": "s = input()\n\nif int(s)%25 == 0:\n print(0)\nelse:\n sols = []\n d = {}\n n = list(s)\n nr = s[::-1]\n for c in ('0', '2', '5', '7'):\n p = nr.find(c)\n d[c] = p\n \n for c1, c2 in (('2', '5'),('5', '0') , ('7', '5')):\n if c1 not in n or c2 not in n:\n continue\n \n dc1 = d[c1]\n dc2 = d[c2]\n sol = 0\n \n if dc1 == len(n) - 1 and len(n)>1 and n[1] == '0':\n i = 1\n while i len(n) -i -1:\n dc2 -= 1\n \n if dc2 == len(n) - 1 and len(n)>1 and n[1] == '0':\n \n i = 1\n while i len(n) -i -1:\n dc1 -= 1 \n \n \n if dc1 == 0:\n sols.append(dc2 + sol)\n continue\n \n if dc1 < dc2:\n sols.append(dc2 + dc1 + sol)\n \n else:\n sols.append(dc2 + dc1 - 1 + sol)\n\n z1 = nr.find('0')\n if z1!=-1:\n z2 = nr.find('0', z1+1)\n if z2 != -1:\n sols.append(z1 + z2 - 1)\n if len(sols) == 0:\n print(-1)\n else:\n print(min(sols))\n "}, {"source_code": "s=input()[::-1]\nt=len(s)\ndef g(c,i=0):return s.find(str(c),i)+1or 50\ni,f=g(0),g(5)\nj=min(g(0,i),f)\nm=i+j+(j= 2):\n\tres = -1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '0'):\n\t\t\tif(res == -1): res = n-1-i\n\t\t\telse:\n\t\t\t\tres += n-2-i\n\t\t\t\tbreak\n\tans = min(ans,res)\nif(c['0'] and c['5']):\n\tres = 0\n\tf = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '0'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '5'):\n\t\t\tf = 1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-2-i+f\n\t\t\tbreak\n\tans = min(ans,res)\nif(c['2'] and c['5']):\n\tres = 0\n\tf = 0\n\tflag = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '2'):\n\t\t\tf = 1\n\tif(i == 0 and s[1] == '0'):\n\t\tfor i in range(1,n):\n\t\t\tif(s[i] != '0'):\n\t\t\t\tbreak\n\t\tflag = i-1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '2'):\n\t\t\tres += n-2-i+f\n\t\t\tbreak\n\tans = min(ans,res+flag)\nif(c['7'] and c['5']):\n\tres = 0\n\tf = 0\n\tflag = 0\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '5'):\n\t\t\tres += n-1-i\n\t\t\tbreak\n\t\tif(s[i] == '7'):\n\t\t\tf = 1\n\tif(i == 0 and s[1] == '0'):\n\t\tfor i in range(1,n):\n\t\t\tif(s[i] != '0'):\n\t\t\t\tbreak\n\t\tflag = i-1\n\tfor i in range(n-1,-1,-1):\n\t\tif(s[i] == '7'):\n\t\t\tres += n-2-i+f\n\t\t\tbreak\n\tans = min(ans,res+flag)\nif(ans == 1e18):\n\tans = -1\nprint(ans)"}, {"source_code": "from itertools import dropwhile\nn=[int(i) for i in input()]\nl=len(n)\n#\u9577\u3055\u304c2\u306e\u5834\u5408\u3082\nif len(n)==1:\n print(-1)\n exit()\nif n in [[2,5],[7,5],[5,0]]:\n print(0)\n exit()\nif n in [[5,2],[5,7]]:\n print(1)\n exit()\ninf=10**12\n#\u4e00\u756a\u5de6\u306b\u3042\u308b\u5834\u5408\u306f\u3081\u3093\u3069\u3044\u306e\u3067\u5834\u5408\u5206\u3051\u3057\u3061\u3083\u3046(\u9006\u306b\u3059\u308b)\n#00\u3082\u5834\u5408\u5206\u3051\ndef calc1(x,y):\n global n,l,inf\n m=n[::-1]\n if x not in n or y not in n:\n #print(x,y,0)\n return inf\n ix,iy=m.index(x),m.index(y)\n #\u4e00\u756a\u53f3\u306b\u306a\u3044\u5834\u5408\n if max(ix,iy) 1:\n cresult = 0\n i = A_str.rfind('0')\n cresult += len(A_str) - 1 - i\n A_str = A_str[:i] + A_str[i + 1:] + A[i]\n i = A_str[:-1].rfind('0')\n cresult += len(A_str) - 2 - i\n\n result = min([result, cresult])\n\n if result < 10**9:\n print(result)\n else:\n print(-1)\n\n\n"}, {"source_code": "#Imports\nfrom sys import stdin, stdout\n\n\n#Aux\ndef _count_algs(num_str):\n alg_count = [0]*10\n\n for alg_str in num_str:\n alg_count[int(alg_str)] += 1\n\n return alg_count\n\n\ndef _has_algs(alg_count):\n has_five = alg_count[5] >= 1\n\n algs_dict = {\n '00': alg_count[0] >= 2,\n '52': has_five and alg_count[2] >= 1,\n '05': has_five and alg_count[0] >= 1,\n '57': has_five and alg_count[7] >= 1\n }\n\n has_algs = {key: value for key, value in algs_dict.items() if value is True}\n\n return has_algs\n\ndef _find_min_moves(has_algs, num_str):\n min_moves = 10000 if len(has_algs) > 0 else -1\n\n reversed_num_str = num_str[::-1]\n\n for algs_str in has_algs:\n this_moves = _calculate_moves(reversed_num_str, algs_str)\n min_moves = min(min_moves, this_moves)\n\n return min_moves\n\n\ndef _calculate_moves(num_str, algs_str):\n moves = 0\n\n idx_alg0 = num_str.index(algs_str[0])\n if idx_alg0 == len(num_str)-1:\n aux_count0 = idx_alg0-1\n while num_str[aux_count0] == '0':\n aux_count0-=1\n moves = idx_alg0-1-aux_count0\n\n idx_alg1 = None\n if algs_str[1] == '0':\n idx_alg1 = num_str.index(algs_str[1], idx_alg0+1)\n else:\n idx_alg1 = num_str.index(algs_str[1])\n\n moves += idx_alg0 + idx_alg1\n return moves if idx_alg0 > idx_alg1 else moves-1\n\n#Main\ndef _main():\n #Read input\n num_str = stdin.readline().rstrip().split()[0]\n\n\n #Calculate answer\n count = _count_algs(num_str)\n has_algs = _has_algs(count)\n ans = _find_min_moves(has_algs, num_str)\n\n\n #Print output\n stdout.write(str(ans))\n\n#Call\n_main()"}, {"source_code": "s=list(input())\nn=len(s)\nif n==1:\n print(-1)\n exit(0)\nans=2e9\nfor i in range(n):\n for j in range(i+1,n):\n s1=s[:]\n cnt=0\n i1,j1=i+1,j+1\n while j1 ind1:\n for i in range(ind1,ind2):\n temp = ar[i]\n ar[i] = ar[i+1]\n ar[i+1] = temp\n else:\n for i in range(ind1,ind2,-1):\n temp = ar[i]\n ar[i] = ar[i-1]\n ar[i-1] = temp\n \nn = list(input())\nn2 = len(n)\nans = 100\nfor i in range(n2):\n for j in range(n2):\n nc = [0]*n2\n for i2 in range(n2):\n nc[i2] = n[i2]\n swap(nc,i,n2-1)\n swap(nc,j,n2-2)\n num = 0\n for z in range(n2):\n if nc[z] != \"0\":\n num = z\n break\n swap(nc,0,num)\n if int(\"\".join(nc)) % 25 == 0:\n ans = min(ans,abs(n2-2-j)+abs(n2-1-i)+num)\n \nif ans == 100:\n print(-1)\nelse:\n print(ans)\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 = input()\n m = n[::-1]\n res = 10**9\n\n if int(n) % 25 == 0:\n print(0)\n return\n\n if n.count('0') >= 2:\n cnt, flag = 0, False\n for i, mi in enumerate(m):\n if mi == '0':\n if flag:\n cnt += i - 1\n break\n else:\n flag = True\n cnt += i\n res = min(res, cnt)\n\n if '5' in n:\n i = m.index('5')\n if '0' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('0')\n n_ = n[:-cnt - 1] + n[-cnt:] + '0'\n for i in range(1, len(n)):\n if n_[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n else:\n j = m.index('0')\n if i > j:\n res = min(res, j + i - 1)\n else:\n res = min(res, j + i)\n\n i = m.index('5')\n if '2' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('2')\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 1\n res = min(res, cnt)\n break\n\n elif n.count('2') == 1 and n.index('2') == 0:\n cnt = i\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n else:\n j = m.index('2')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n i = m.index('5')\n if '7' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('7')\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 1\n res = min(res, cnt)\n break\n\n elif n.count('7') == 1 and n.index('7') == 0:\n cnt = i\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n else:\n j = m.index('7')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n print(res if res < 10**9 else -1)\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": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if (k.rfind('5') > k.rfind('0')):\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('2') > k.rfind('5')):\n temp += 1\n if (temp3:\n add = 0\n i = 1\n while k[i] == '0':\n add += 1\n i += 1\n temp += add\n if (k.rfind('7') > k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp 1:\n first = num.rfind(possible[0])\n second = num[:first].rfind(possible[1])\n temp_min = length - 2 - second + length - 1 - first\n minimum = min(minimum, temp_min)\n elif possible[0] != possible[1] and possible[0] in num and possible[1] in num:\n first = num.rfind(possible[0])\n second = num.rfind(possible[1])\n \n temp_min = length - 2 - first + length - 1 - second\n \n if (second == 0) and length > 3:\n i = 1\n while num[i] == '0':\n temp_min += 1\n i += 1\n \n if first > second:\n temp_min += 1\n minimum = min(minimum, temp_min)\n\nif minimum == sys.maxsize:\n print(-1)\nelse:\n print(minimum)"}, {"source_code": "def swap(N,a,b):\n A = N[a]\n B = N[b]\n N[a] = B\n N[b] = A\n\ndef getToEnd(N,a,b):\n bInd = -1\n for i in range(len(N)-1,-1,-1):\n if N[i] == b:\n bInd = i\n break\n total = 0\n if bInd == -1:\n return q\n for i in range(bInd,len(N)-1):\n total += 1\n swap(N,i,i+1)\n aInd = -1\n for i in range(len(N)-2,-1,-1):\n if N[i] == a:\n aInd = i\n break\n if aInd == -1:\n return q\n \n for i in range(aInd,len(N)-2):\n total += 1\n swap(N,i,i+1)\n \n if N[0] == '0':\n worked = False\n for i in range(len(N)-2):\n if N[i] == '0':\n total += 1\n else:\n worked = True\n break\n if not worked: \n return q\n return total\n\n \nq = 999999\nN = list(input())\n\na = getToEnd(list(N),'0','0')\nb = getToEnd(list(N),'2','5')\nc = getToEnd(list(N),'5','0')\nd = getToEnd(list(N),'7','5')\n\nif a == q and b == q and c == q and d == q:\n print(-1)\nelse:\n print(min(a,b,c,d))\n"}, {"source_code": "\ndef finder(n,ind):\n i=ind-1\n while(i>=0):\n if(n[i]==\"0\"):\n break\n else:\n i=i-1\n return(i)\n\ndef zeros(n):\n count=0\n pol=1\n while(pol=2):\n c01=l-n.rfind(\"0\")-2\n c02=l-finder(n,n.rfind(\"0\"))-1\n ans.append(c01+c02)\n\nif(int(n)%25==0):\n print(0)\nelif(len(ans)==0):\n print(-1)\nelse:\n print(min(ans))\n"}, {"source_code": "s=input()[::-1]\nt=len(s)\nm=I=40\ndef g(c,i=0):return s.find(str(c),i)+1 or I\ni,f=g(0),g(5)\nif ii):\n j-=1\n for k in range(j,n-2):\n copy[k],copy[k+1]=copy[k+1],copy[k]\n swaps+=1\n if((10*(ord(copy[n-2])-48)+(ord(copy[n-1])-48))%25):\n continue\n if(copy[0]=='0'):\n done=0\n for yo in range(n-2):\n if(copy[yo]!='0'):\n done=1\n swaps+=(yo)\n break\n if(done):\n maxa=min(maxa,swaps)\n else:\n continue\n maxa=min(maxa,swaps)\nif(maxa==10**18):\n print(-1)\nelse:\n print(maxa)\n"}], "negative_code": [{"source_code": "def swap(N,a,b):\n A = N[a]\n B = N[b]\n N[a] = B\n N[b] = A\n\ndef getToEnd(N,a,b):\n bInd = -1\n for i in range(len(N)-1,-1,-1):\n if N[i] == b:\n bInd = i\n break\n total = 0\n if bInd == -1:\n return q\n for i in range(bInd,len(N)-1):\n total += 1\n swap(N,i,i+1)\n\n aInd = -1\n for i in range(len(N)-2,-1,-1):\n if N[i] == a:\n aInd = i\n break\n if bInd == -1:\n return q\n \n for i in range(aInd,len(N)-2):\n total += 1\n swap(N,i,i+1)\n if N[0] == '0':\n return q\n return total\n\n \nq = 999999\nN = list(input())\n\na = getToEnd(list(N),'0','0')\nb = getToEnd(list(N),'2','5')\nc = getToEnd(list(N),'5','0')\nd = getToEnd(list(N),'7','5')\n\nif a == q and b == q and c == q and d == q:\n print(-1)\nelse:\n print(min(a,b,c,d))\n"}, {"source_code": "n=input()\nans=[]\nl=len(n)\n\nif(\"2\" in n and \"5\" in n):\n c2=l-n.rfind(\"2\")-2\n c5=l-n.rfind(\"5\")-1\n \n if(c2 j:\n i, j = j, i\n\n nw = s[:i] + s[i + 1:j] + s[j + 1:] + s[i_] + s[j_]\n\n for x in range(len(s)):\n if s[x] == \"0\":\n continue\n ans += x\n nw = nw[x] + nw[:x] + nw[x + 1:]\n break\n\n if int(nw) % 25 == 0:\n globans = min(globans, ans)\n\nif globans == 10 ** 9:\n print(-1)\nelse:\n print(globans)\n"}, {"source_code": "import sys\ns=input()\nm=1000000000000000000000000000000000000000\nt=False\nif int(s)%25==0:\n print(0)\n sys.exit()\nif s.count(\"0\")>=2 and len(s)>2:\n t=True\n s1=s[::-1]\n x=0\n ind1=-1\n ind2=-1\n for i in range(len(s)):\n if s1[i]==\"0\":\n if x==0:\n ind1=i\n x=1\n else:\n ind2=i\n break\n m=min(ind1+ind2-1,m)\nif \"2\" in s and \"5\" in s:\n s1=s[::-1]\n ind1=s1.index(\"2\")\n ind2=s1.index(\"5\")\n if not ((ind1+1==len(s) and s1[ind1-1]==\"0\") or (ind2+1==len(s) and s1[ind2-1]==\"0\")):\n if ind2>ind1:\n m=min(ind1+ind2,m)\n t=True\n else:\n m=min(ind1+ind2-1,m)\n t=True\nif \"0\" in s and \"5\" in s:\n s1=s[::-1]\n ind1=s1.index(\"0\")\n ind2=s1.index(\"5\")\n if not ((ind2+1==len(s) and s1[ind2-1]==\"0\" and ind2-1!=ind1)):\n\n if ind2ind1:\n m=min(ind1+ind2,m)\n t=True\n else:\n m=min(ind1+ind2-1,m)\n t=True\n \nif t:\n print(m)\nelse:\n print(-1)\n"}, {"source_code": "s=input()[::-1]\nt=len(s)\nI=40\ndef g(c,i=0):return s.find(str(c),i)+1 or I\ni,f=g(0),g(5)\nj=min(g(0,i),f)\nm=i+j-3+(j1:\n g.append(permut(l,'0','0'))\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "def inx(a,s):\n ll = []\n for i in range(len(a)):\n if s == a[i]:\n ll.append(i)\n try:\n return max(ll)\n except:\n return False\n\ndef check(a, Comb):\n Counter = 0\n Nxt = inx(a,Comb[1])\n if Nxt is False:\n Counter = 0\n else:\n for i in range(Nxt+1, len(a)):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n \n Fst = inx(a,Comb[0])\n if Fst is False:\n Counter = 0\n else:\n for i in range(Fst+1, len(a)-1):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n if Fst is False:\n Counter = None\n if Nxt is False:\n Counter = None\n return Counter\n \ndef search(a):\n s = None\n flg = False\n for i in range(len(a)):\n if flg is True:\n break\n if a[i] == '2':\n for j in range(len(a)):\n if a[j] == '5':\n s = '255'\n flg = True\n break\n elif a[i] == '5':\n for j in range(len(a)):\n if a[j] == '2':\n s = '255'\n flg = True\n break\n elif a[j] == '7':\n s = '755'\n flg = True\n break\n elif a[j] == '0':\n s = '505'\n flg = True\n break\n elif a[i] == '7':\n for j in range(len(a)):\n if a[j] == '5':\n s = '755'\n flg = True\n break\n elif a[i] == '0':\n for j in range(len(a)):\n if a[j] == '5':\n s = '500'\n flg = True\n break\n elif a[j] == '0' and i != j:\n s = '000'\n flg = True\n break\n if s is None:\n print(-1)\n exit()\n return s\n \n#def swap(a,b):\n# a, b = b, a\n# return b, a\n\ndef czero(a):\n ctr = 0\n index = None\n for i in range(len(a)):\n if a[i] != '0':\n index = i\n break\n if index == 0:\n return None\n else:\n cou = index\n while a[0] == '0':\n a[cou-1], a[cou] = a[cou], a[cou-1]\n ctr+=1\n cou-=1\n return ctr\n\ndef search1(a, t, Comb):\n s = None\n flg = False\n\n if Comb[2] == '5':\n if '2' not in t:\n s = '255'\n t.append('2')\n\n elif '7' not in t:\n s = '755'\n t.append('7')\n elif '0' not in t:\n s = '505'\n t.append('0')\n elif Comb[2] == '0':\n if '5' not in t:\n s = '500'\n t.append('5')\n elif '0' not in t:\n s = '000'\n t.append('0')\n else:\n s = '---'\n return s, t\ndef ZERO(a, mass):\n Counter = 0\n #print(a)\n Nxt = None\n Fst = None\n for i in range(len(a)):\n \n if a[i] == '0':\n if not Fst:\n Fst = i\n elif not Nxt:\n Nxt = i\n else:\n break\n \n if Fst is None:\n return mass, None\n elif Nxt is None:\n return mass, None\n else:\n for i in range(Nxt+1, len(a)):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n \n for i in range(Fst+1, len(a)-1):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n \n f = czero(a)\n if f is not None:\n Counter+=f\n \n mass.append(Counter)\n return mass, Counter\n \nmass = []\ntemp = []\nCounter = 0\na=input()[::-1]\nif a[0] == '5' and a[1] == '2':\n print(0)\n exit()\nif a[0] == '5' and a[1] == '7':\n print(0)\n exit()\nif a[0] == '0' and a[1] == '0':\n print(0)\n exit()\nif a[0] == '0' and a[1] == '5':\n print(0)\n exit()\n \nComb = search(a)\n\nif Comb == '000':\n a = list(a)[::-1]\n Nxt = None\n Fst = None\n for i in range(len(a)):\n \n if a[i] == '0':\n if not Fst:\n Fst = -i\n elif not Nxt:\n Nxt = -i\n else:\n break\n #print(Fst,Nxt)\n \n for i in range((Nxt+len(a))+1, len(a)):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n \n for i in range((Fst+len(a))+1, len(a)-1):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n \n f = czero(a)\n if f is not None:\n Counter+=f\n \n mass.append(Counter)\n \nelse:\n b = a\n for i in range(3):\n a = list(b)[::-1]\n #print(a)\n Counter = 0\n Comb2, temp = search1(a, temp, Comb)\n if Comb2 == '---':\n pass\n elif Comb2 == '000':\n mass, Counter = ZERO(a, mass)\n if Counter is not None:\n f = czero(a)\n if f is not None:\n Counter+=f\n \n mass.append(Counter)\n else:\n Counter=check(a, Comb2)\n if Counter is not None:\n f = czero(a)\n if f is not None:\n Counter+=f\n \n mass.append(Counter)\nprint(min(mass))\n\n#50267 | \n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n if i[-1]=='0':\n k+=1\n if i[-1]==i[-2]=='0': k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "num = input()[::-1]\npossibility1 = False\npossibility2 = False\ncontains1 = []\ncontains2 = []\nif '0' in num:\n first_char1 = '0'\n if '0' in num:\n possibility1 = True\n contains1.append('0')\n if '5' in num:\n possibility1 = True\n contains1.append('5')\nelif '5' in num:\n first_char2 = '5'\n if '2' in num:\n possibility2 = True\n contains2.append('2')\n\nif possibility1 or possibility2:\n if possibility1:\n first = num.find(first_char1)\n second = min([num.find(i) for i in contains1])\n out1 = first + second\n if first < second:\n out1 -= 1\n\n if possibility2:\n first = num.find(first_char2)\n second = min([num.find(i) for i in contains2])\n out2 = first + second\n if first < second:\n out2 -= 1\n if possibility1 and not possibility2:\n print(out1)\n if possibility2 and not possibility1:\n print(out2)\n if possibility1 and possibility2:\n print(min(out1, out2))\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n if i[-1]==0:\n k+=2\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n if i[-1]==0:\n k+=2\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "n = list(input())\nif (not(\"5\" in n)) and (not(\"0\" in n)) and (not(\"7\" in n)) and (not(\"2\" in n)):\n\tprint(-1)\n\tquit()\n\t\nwkn = []\nwkn[:] = n\nans = -1\nfor i in reversed(range(len(n))):\n\tif (n[i] == \"0\"):\n\t\twk1 = n[:i] + n[i + 1:] + [n[i]]\n\t\tans = len(n) - i - 1\n\t\tif wk1[0] != \"0\":\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\t\telse:\n\t\t\tcount = 0\n\t\t\tfor j in wk1:\n\t\t\t\tcount += 1\n\t\t\t\tif j != \"0\":\n\t\t\t\t\tbreak\n\t\t\tans += count - 1\n\t\t\twk1 = [wk1[count - 1]] + wk1[:count - 1] + wk1[count:]\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\nif ans != -1:\n\tf = True\n\tfor i in reversed(range(len(n) - 1)):\n\t\tif (n[i] == \"0\") or (n[i] == \"5\"):\n\t\t\twk1 = n[:i] + n[i + 1:] + [n[i]]\n\t\t\tans += len(n) - i - 2\n\t\t\tif wk1[0] != \"0\":\n\t\t\t\tf = False\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcount = 0\n\t\t\t\tfor j in wk1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tif j != \"0\":\n\t\t\t\t\t\tbreak\n\t\t\t\tans += count - 1\n\t\t\t\tf = False\n\t\t\t\tbreak\n\tif f:\n\t\tans = -1\n\t\t\t\nwkans = ans\n\nans = -1\nn = wkn\nfor i in reversed(range(len(n))):\n\tif (n[i] == \"5\"):\n\t\twk1 = n[:i] + n[i + 1:] + [n[i]]\n\t\tans = len(n) - i - 1\n\t\tif wk1[0] != \"0\":\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\t\telse:\n\t\t\tcount = 0\n\t\t\tfor j in wk1:\n\t\t\t\tcount += 1\n\t\t\t\tif j != \"0\":\n\t\t\t\t\tbreak\n\t\t\tans += count - 1\n\t\t\twk1 = [wk1[count - 1]] + wk1[:count - 1] + wk1[count:]\n\t\t\tn[:] = wk1\n\t\t\tbreak\n\t\t\t\nif ans != -1:\n\tf = True\n\tfor i in reversed(range(len(n) - 1)):\n\t\tif (n[i] == \"7\") or (n[i] == \"2\"):\n\t\t\twk1 = n[:i] + n[i + 1:] + [n[i]]\n\t\t\tans += len(n) - i - 2\n\t\t\tif wk1[0] != \"0\":\n\t\t\t\tf = False\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcount = 0\n\t\t\t\tfor j in wk1:\n\t\t\t\t\tcount += 1\n\t\t\t\t\tif j != \"0\":\n\t\t\t\t\t\tbreak\n\t\t\t\tans += count - 1\n\t\t\t\tf = False\n\t\t\t\tbreak\n\tif f:\n\t\tans = -1\n\t\t\t\t\nif (wkans == -1):\n\tprint(ans)\n\tquit()\nif (ans == -1):\n\tprint(wkans)\n\tquit()\nprint(min(ans, wkans))\n"}, {"source_code": "a=str(raw_input())\nif ('5' in a and '0' in a) or ('7' in a and '5' in a) or ('2' in a and '5' in a) or (a.count('0')==2):\n res=[]\n if '5' in a and '0' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n a1.insert(0,'0')\n r+=a1.index('5')-1\n a1.remove('5')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '7' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('7')-1\n a1.remove('7')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '2' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('2')-1\n a1.remove('2')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if a.count('0')==2:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n r+=a1.index('0')\n a1.remove('0')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if len(res)>0:\n print min(res)\n else:\n print -1\n \n \n \n \nelse:\n print -1\n \n \n"}, {"source_code": "# Author: S Mahesh Raju\n# Username: maheshraju2020\n# Date: 03/07/2020\n\nfrom sys import stdin,stdout\nfrom math import gcd, ceil, sqrt\nfrom collections import Counter\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\ndef mover(s, ind1, ind2):\n s = list(s)\n count = 0\n for i in range(ind1, len(s) - 1):\n s[i], s[i + 1] = s[i + 1], s[i]\n count += 1\n \n for i in range(ind2, len(s) - 2):\n s[i], s[i + 1] = s[i + 1], s[i]\n count += 1\n \n return [count, \"\".join(s)]\n\ndef check(s):\n count = 0\n for i in range(len(s) - 2):\n if s[i] != '0':\n return count\n else:\n count += 1\n return -1\n \nn = is1()\nres = float(\"inf\")\ncond = [['2', '5'], ['5', '0'], ['7', '5']]\nfor i, j in cond: \n if i in n and j in n:\n two = n.rfind(i)\n five = n.rfind(j)\n count, s = mover(n, five, two)\n temp = check(s)\n if temp != -1:\n res = min(res, count + temp)\n elif len(n) == 2:\n res = 0\n\nif res != 0 and n.count('0') >= 2:\n zero1 = n.rfind('0')\n zero2 = n[:zero1].rfind('0')\n count, s = mover(n, zero1, zero2)\n temp = check(s)\n if temp != -1:\n res = min(res, count + temp)\n elif len(n) == 2:\n res = 0\n\nif res == float(\"inf\"):\n print(-1)\nelse:\n print(res)\n\n\n\n\n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "\ndef finder(n,ind):\n i=ind-1\n while(i>=0):\n if(n[i]==\"0\"):\n break\n else:\n i=i-1\n return(i)\n\nn=input()\nans=[]\nl=len(n)\n\nif(\"2\" in n and \"5\" in n):\n c2=l-n.rfind(\"2\")-2\n c5=l-n.rfind(\"5\")-1\n \n if(c2=2):\n c01=l-n.rfind(\"0\")-2\n c02=l-finder(n,n.rfind(\"0\"))-1\n ans.append(c01+c02)\n\nif(int(n)%25==0):\n print(0)\nelif(len(ans)==0):\n print(-1)\nelse:\n print(min(ans))\n"}, {"source_code": "num = str(input())\nn =len(num)\nnum_r = num[::-1]\ns0, s5 = num_r.find('0'),num_r.find('5')\nif s0 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['0','5']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s0 = s0 + s\nelse:\n s0 = 999999999\nif s5 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s\nelse:\n s0 = 999999999\nssr = min(s0,s5)\nif ssr != 999999999:\n print(ssr)\nelse:\n print(-1)"}, {"source_code": "n=input()\nans=[]\nl=len(n)\n\nif(\"2\" in n and \"5\" in n):\n c2=l-n.rfind(\"2\")-2\n c5=l-n.rfind(\"5\")-1\n \n if(c2 k.rfind('0')):\n temp += 1\n if (temp3:\n temp += 1\n if (k.rfind('2') > k.rfind('5')):\n temp += 1\n if (temp3:\n temp += 1\n if (k.rfind('7') > k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp=2):\n res=[]\n if '5' in a and '0' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n a1.insert(0,'0')\n r+=a1.index('5')-1\n a1.remove('5')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '7' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('7')-1\n a1.remove('7')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '2' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('2')-1\n a1.remove('2')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if a.count('0')>=2:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n r+=a1.index('0')\n a1.remove('0')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if len(res)>0:\n print min(res)\n else:\n print -1\n \n \n \n \nelse:\n print -1\n \n \n"}, {"source_code": "def sol(a,s):\n ans=0\n s1=s[::-1]\n\n try:\n ai=s1.index(a)\n if a==\"0\":\n s2=a+s1[0:ai]+s1[ai+1::]\n return [True,ai,s2[::-1]]\n except:\n return [False]\n x=len(s)-2\n while x>-1 and s1[x]==\"0\" and ai==len(s)-1:\n x-=1\n if x==-1:\n return [False]\n s=a+s1[0:ai]+s1[ai+1::]\n s=s[0:x+1]+s[x+2::]+s1[x]\n return [True,ai+len(s)-2-x,s[::-1]]\ns=input()\nans=10**6\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"0\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\n \nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"5\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"7\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"2\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nif ans==10**6:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "num = input()[::-1]\npossibility1 = False\npossibility2 = False\ncontains1 = []\ncontains2 = []\nif '0' in num:\n first_char1 = '0'\n if '0' in num:\n possibility1 = True\n contains1.append('0')\n if '5' in num:\n possibility1 = True\n contains1.append('5')\nelif '5' in num:\n first_char2 = '5'\n if '2' in num:\n possibility2 = True\n contains2.append('2')\n\nif possibility1 or possibility2:\n if possibility1:\n first = num.find(first_char1)\n second = min([num.find(i) for i in contains1])\n out1 = first + second\n if first < second:\n out1 -= 1\n\n if possibility2:\n first = num.find(first_char2)\n second = min([num.find(i) for i in contains2])\n out2 = first + second\n if first < second:\n out2 -= 1\n if possibility1 and not possibility2:\n print(out1)\n if possibility2 and not possibility1:\n print(out2)\n if possibility1 and possibility2:\n print(min(out1, out2))\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n if i[-1]=='0':\n k+=1\n if i[-1]==i[-2]=='0': k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "n = list(input())[::-1]\nINF = 10**9\ndef solve(a, b):\n if (a not in n) or (b not in n):\n return INF\n nn = n[:]\n ia = n.index(a)\n ib = n.index(b)\n if ia=2:\n ans = -1\n one = False\n for i in range(len(n)):\n if n[i]=='0':\n ans += i\n if one:\n break\n one = True\nelse:\n ans = INF\nans = min(ans, solve('2', '5'))\nans = min(ans, solve('5', '0'))\nans = min(ans, solve('7', '5'))\nif ans==INF:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if (k.rfind('5') > k.rfind('0')):\n temp += 1\n if (temp k.rfind('5')):\n temp += 1\n if (temp k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] \n temp += (len(k)-1) - k.rfind('0') \n if (temp -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "import sys\ns=input()\nm=100000000000000000000000000000000000000000000000000000000000000000\nt=False\nif int(s)%25==0:\n print(0)\n sys.exit()\nif s.count(\"0\")>=2 and len(s)>2:\n t=True\n s1=s[::-1]\n x=0\n ind1=-1\n ind2=-1\n for i in range(len(s)):\n if s1[i]==\"0\":\n if x==0:\n ind1=i\n x=1\n else:\n ind2=i\n break\n m=min(ind1+ind2-1,m)\nif \"2\" in s and \"5\" in s:\n s1=s[::-1]\n ind1=s1.index(\"2\")\n ind2=s1.index(\"5\")\n if not ((ind1+1==len(s) and s1[ind1-1]==\"0\") or (ind2+1==len(s) and s1[ind2-1]==\"0\")):\n if ind2>ind1:\n m=min(ind1+ind2,m)\n t=True\n else:\n m=min(ind1+ind2-1,m)\n t=True\nif \"0\" in s and \"5\" in s:\n s1=s[::-1]\n ind1=s1.index(\"0\")\n ind2=s1.index(\"5\")\n if not ((ind2+1==len(s) and s1[ind2-1]==\"0\" and ind2-1!=ind1)):\n\n if ind2ind1:\n m=min(ind1+ind2,m)\n t=True\n else:\n m=min(ind1+ind2-1,m)\n t=True\n \nif t:\n print(m)\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n if m[-1]=='0':\n k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "INF = 1000\n\n\ndef compute_pair(s, pair):\n n = len(s)\n try:\n l2 = s.rindex(pair[1])\n l1 = s.rindex(pair[0])\n if pair[0] == '0':\n l1 = s[:l2].rindex(pair[1])\n except:\n return INF\n\n steps = abs((n - 2) - l1) + abs((n - 1) - l2)\n if l1 > l2:\n steps += 1\n\n if l1 == n - 1:\n steps -= 1\n\n return steps\n\n\ndef main():\n s = input()\n best = INF\n for pair in ['00', '25', '50', '75']:\n l = compute_pair(s, pair)\n if l < best:\n best = l\n\n if best == INF:\n best = -1\n\n print(best)\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "num = str(input())\nn =len(num)\nnum_r = num[::-1]\ns0, s5 = num_r.find('0'),num_r.find('5')\nif s0 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['0','5']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s0 = s0 + s\n else:\n s0 = 999999999\nelse:\n s0 = 999999999\nif s5 != n-1 or num.find('0') != 1:\n if s5 != -1:\n newnum_r = num_r[:s5] + num_r[s5+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s\n else:\n s5 = 999999999\n else:\n s5 = 999999999\n ssr = min(s0,s5)\n if ssr != 999999999:\n print(ssr)\n else:\n print(-1)\nelse:\n if s5 != -1:\n newnum_r = num_r[:s5] + num_r[s5+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s + 1\n else:\n s5 = 999999999\n else:\n s5 = 999999999\n ssr = min(s0,s5)\n if ssr != 999999999:\n print(ssr)\n else:\n print(-1)"}, {"source_code": "num = input()[::-1]\npossibility1 = False\npossibility2 = False\ncontains1 = []\ncontains2 = []\nif '0' in num:\n first_char1 = '0'\n if '0' in num:\n possibility1 = True\n contains1.append('0')\n if '5' in num:\n possibility1 = True\n contains1.append('5')\nelif '5' in num:\n first_char2 = '5'\n if '2' in num:\n possibility2 = True\n contains2.append('2')\n\nif possibility1 or possibility2:\n if possibility1:\n first = num.find(first_char1)\n second = min([num.find(i) for i in contains1])\n out1 = first + second\n if first < second:\n out1 -= 1\n\n if possibility2:\n first = num.find(first_char2)\n second = min([num.find(i) for i in contains2])\n out2 = first + second\n if first < second:\n out2 -= 1\n if possibility1 and not possibility2:\n print(out1)\n if possibility2 and not possibility1:\n print(out2)\n if possibility1 and possibility2:\n print(min(out1, out2))\nelse:\n print(-1)\n"}, {"source_code": "maxint = 2147483647\n\nclass mylist(list):\n def index(self, obj, *args):\n try:\n if len(args) == 0:\n return super(mylist, self).index(obj)\n if len(args) == 1:\n return super(mylist, self).index(obj,args[0])\n return super(mylist, self).index(obj,args[0],args[1])\n except ValueError:\n return -1\n\t\t \ndef cost(target,index1, index2):\n if index1 == -1 or index2 == -1:\n return maxint\n if target == '00':\n return index1 + index2 -1\n else:\n return index1 + index2 -1 if index2= bestCost:\n return bestCost\n rn,tempcost = swap(rn,cost[0])\n if tempcost == 0:\n return 0\n thiscost = tempcost + realCost(rn)\n if thiscost < bestCost:\n bestCost = thiscost\nn = input()\nrn = n[::-1]\nrn = mylist(rn)\nrcost = realCost(rn)\nprint(rcost if rcost= 2):\n flag = 1\nif flag == 1: \n if '5' in n and '0' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '5':\n i1 = i\n if n[i] == '0':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t1 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t1 += l - 1 - i2 + l - 1 - i1 + 1\n\n if '7' in n and '5' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '7':\n i1 = i\n if n[i] == '5':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t2 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t2 += l - 1 - i2 + l - 1 - i1 + 1\n #print t\n if '2' in n and '5' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '2':\n i1 = i\n if n[i] == '5':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t3 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t3 += l - 1 - i2 + l - 1 - i1 + 1\n #print t\n if n.count('0') >= 2:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '0' and i != i2 and i1 == -1:\n i1 = i\n if n[i] == '0' and i != i1 and i2 == -1:\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n t4 += l - 1 - i2 + l - i1 - 2 + 1\n #print t\n\nif flag == 1:\n p = [t1, t2, t3, t4]\n\n while -1 in p:\n p.remove(-1)\n\n print min(p)\nelse:\n print -1"}, {"source_code": "n=input()\na=n[:]\np=len(n)-1\ncount1,count2=0,0\ni=p\nflag1,flag2=0,0\nwhile i>-1:\n if n[i]=='5'and flag1==0:\n count1=p-i\n n=n[:i]+n[i+1:]+'5'\n flag1=1\n if a[i]=='0' and flag2==0:\n count2=p-i\n a=a[:i]+a[i+1:]+'0'\n flag2=1\n i=i-1\nif flag1==1 or flag2==1:\n i=p-1\n if flag1==1:\n flag1=-1\n if flag2==1:\n flag2=-1\n while i>-1:\n if (int(n[i])-2)%5==0 and flag1==-1:\n count1=count1+p-i-1\n flag1=2\n if int(a[i])%5==0 and flag2==-1:\n count2=count2+p-i-1\n flag2=2\n i=i-1\nif flag1==2 and flag2==2:\n print(min(count1,count2))\nelif flag1==2 and flag2!=2:\n print(count1)\nelif flag1!=2 and flag2==2:\n print(count2)\nelse:\n print(-1)\n"}, {"source_code": "from itertools import dropwhile\nn=[int(i) for i in input()]\nl=len(n)\nif len(n)==1:\n print(-1)\n exit()\ninf=10**12\n#\u4e00\u756a\u5de6\u306b\u3042\u308b\u5834\u5408\u306f\u3081\u3093\u3069\u3044\u306e\u3067\u5834\u5408\u5206\u3051\u3057\u3061\u3083\u3046(\u9006\u306b\u3059\u308b)\n#00\u3082\u5834\u5408\u5206\u3051\ndef calc1(x,y):\n global n,l,inf\n m=n[::-1]\n if x not in n or y not in n:\n #print(x,y,0)\n return inf\n ix,iy=m.index(x),m.index(y)\n #\u4e00\u756a\u53f3\u306b\u306a\u3044\u5834\u5408\n if max(ix,iy)= 2:\n cnt, flag = 0, False\n for i, mi in enumerate(m):\n if mi == '0':\n if flag:\n cnt += i - 1\n break\n else:\n flag = True\n cnt += i\n\n res = min(res, cnt)\n\n if '5' in n:\n i = m.index('5')\n if '0' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('0')\n n = n[:-cnt - 1] + n[-cnt:] + '0'\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n else:\n j = m.index('0')\n if i > j:\n res = min(res, j + i - 1)\n else:\n res = min(res, j + i)\n\n if '2' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('2')\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 1\n res = min(res, cnt)\n break\n\n if n.count('2') == 1 and n.index('2') == 0:\n cnt = i\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n if m.index('5') < len(n) - 1 and m.index('2') < len(n) - 1:\n j = m.index('2')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n if '7' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('7')\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 1\n res = min(res, cnt)\n break\n\n if n.count('7') == 1 and n.index('7') == 0:\n cnt = i\n for i in range(1, len(n)):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n break\n\n if m.index('5') < len(n) - 1 and m.index('7') < len(n) - 1:\n j = m.index('7')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n print(res if res < 10**9 else -1)\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": "def solve1():\n n = m\n\n try:\n x = n.index('0')\n n = n[x] + n[:x] + n[x+1:]\n\n x += len(n) - len(n.rstrip('0'))\n\n y = n.index('5')\n\n return x + y - 1\n\n except:\n return float('inf')\n\n\ndef solve2():\n n = m\n\n try:\n x = n.index('0')\n y = n.find('0', x+1)\n\n return x + y - 1\n\n except:\n return float('inf')\n\n\ndef solve3():\n n = m\n\n try:\n x = n.index('5')\n n = n[x] + n[:x] + n[x+1:]\n\n x += len(n) - len(n.rstrip('0'))\n\n y = n.index('2')\n\n return x + y - 1\n\n except:\n return float('inf')\n\n\ndef solve4():\n n = m\n\n try:\n x = n.index('5')\n n = n[x] + n[:x] + n[x+1:]\n\n x += len(n) - len(n.rstrip('0'))\n\n y = n.index('7')\n\n return x + y - 1\n\n except:\n return float('inf')\n\nm = input()[::-1]\n\nx = min(\n solve1(),\n solve2(),\n solve3(),\n solve4()\n)\n\nif x == float('inf'):\n print(-1)\nelse:\n print(x)"}, {"source_code": "\n# coding: utf-8\n\n# In[1]:\n\ns=input()[::-1]\nl=len(s)\ndef f(c,i=0):return s.find(c,i)+1 or 50\ni0_1=f('0')\ni5=f('5')\ni05=min(f('0',i0_1),i5)\nm1=i0_1+i05+(i051000: r = -1\n\nprint(r)\n"}, {"source_code": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if not (k.rfind('5')==0 and k[1]=='0'):\n if (k.rfind('5') > k.rfind('0')):\n temp += 1\n if (temp k.rfind('5')):\n temp += 1\n if (temp k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] + k[css+1:] \n temp += (len(k)-1) - k.rfind('0') \n if (temp -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nx = int(input())\n\nxs = str(x)\nif xs.count('0')<2 and \\\n (xs.count('2') + xs.count('5')) < 2 and \\\n (xs.count('5') + xs.count('0')) < 2 and \\\n (xs.count('7') + xs.count('5')) < 2:\n print '-1'\n sys.exit()\n\ndef f(x,d):\n if d<0: return 100\n \n sx = str(x)\n n = len(sx)\n if sx[-2:] in ('00','25','50','75'):\n return 0\n\n besta = 100\n for i in range(len(sx)-1):\n if sx[i] in '0257':\n if sx[i] in '05':\n inter = [n-2,n-1]\n else:\n inter = [n-2]\n for j in inter:\n if i>=j:continue\n if (i!=0 or sx[i+1]!='0'):\n besta = min(besta, j-i + f(int(''.join((sx[:i],sx[i+1:j+1],sx[i],sx[j+1:]))), d-1))\n return besta\n\nbest = f(x,6)\n\n\nif best == 5:\n print -1\nelse:\n print best\n"}, {"source_code": "a=str(raw_input())\nif ('5' in a and '0' in a) or ('7' in a and '5' in a) or ('2' in a and '5' in a) or (a.count('0')==2):\n res=[]\n if '5' in a and '0' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n a1.insert(0,'0')\n r+=a1.index('5')-1\n res.append(r)\n if '7' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('7')-1\n res.append(r)\n if '2' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('2')-1\n res.append(r)\n if a.count('0')==2:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n r+=a1.index('0')\n res.append(r)\n print min(res) \n \n \n \nelse:\n print -1\n \n \n"}, {"source_code": "k = input()\nzeroes = [-1, -1]\nfive = -1\ntwo = -1\nseven = -1\nfor i in range(len(k)):\n if k[i] == '0':\n zeroes[zeroes.index(min(zeroes))] = i\n elif k[i] == '2':\n two = i\n elif k[i] == '5':\n five = i\n elif k[i] == '7':\n seven = i\nif len(k) == 3 and k[:2] == '50' and k[-1] != '5' and k[-1] != '0':\n print(2)\nelif k == '5020' or k == '5070':\n print(1)\nelif k[-2:] == '25' or k[-2:] == '00' or k[-2:] == '50' or k[-2:] == '75':\n print(0)\nelif k[-2:] == '52' or k[-2:] == '05' or k[-2:] == '57':\n print(1)\nelif k == '505':\n print(1)\nelif k == '500':\n print(0)\nelif len(k) != 4 and ((k[:3] == '502' and two == 2) or (k[:3] == '507' and seven == 2)):\n print((len(k)))\nelif (len(k) == 4) and (k[:3] == '502' or k[:3] == '507'):\n print(4)\nelif k[:2] == '50' and five == 0 and min(zeroes) == -1 and (seven != -1 or two != -1):\n print(2 * len(k) - max(two, seven) - 1)\nelif k[:2] == '50' and five == 0 and min(zeroes) != -1 and (seven != -1 or two != -1):\n print(min((len(k) * 2 - zeroes[0] - zeroes[1] - 3), (1 + len(k))))\nelse:\n ch = []\n fl = 0\n if min(zeroes) > -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "s = raw_input().strip()\nn = len(s)\nans = float('inf')\n\n# steps to get 00\nidxlist = []\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '0':\n idxlist.append(i)\n\n if len(idxlist) == 2: break\n\nif len(idxlist) == 2:\n p1, p2 = idxlist\n ans = min(ans, (n - 1 - p2) + (n - 2 - p1))\n\n# steps to get to 25\np2, p5 = -1, -1\nfl = 0\ncur = -1\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '5' and p5 == -1:\n p5 = i\n if s[i] == '2' and p2 == -1:\n p2 = i\n if p2 != -1 and p5 != -1:\n cur = (n - 1 - p5) + (n - 2 - p2)\n if p5 < p2: cur += 1\n fl = 1\n break\n\nif fl == 1:\n news = []\n for i in xrange(n):\n if i == p2 or i == p5: continue\n news.append(s[i])\n\n i = 0\n while i < len(news) and news[i] == '0': i += 1\n if i != len(news):\n ans = min(ans, cur + i)\n\n# steps to get to 50\np5, p0 = -1, -1\nfl = 0\ncur = -1\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '0' and p0 == -1:\n p0 = i\n if s[i] == '5' and p5 == -1:\n p5 = i\n if p5 != -1 and p0 != -1:\n cur = (n - 1 - p0) + (n - 2 - p5)\n if p0 < p5: cur += 1\n fl = 1\n break\n\nif fl == 1:\n news = []\n for i in xrange(n):\n if i == p0 or i == p5: continue\n news.append(s[i])\n\n i = 0\n while i < len(news) and news[i] == '0': i += 1\n if i != len(news):\n ans = min(ans, cur + i)\n \n# steps to get to 75\np7, p5 = -1, -1\nfl = 0\ncur = -1\nfor i in xrange(n - 1, -1, -1):\n if s[i] == '5' and p5 == -1:\n p5 = i\n if s[i] == '7' and p7 == -1:\n p7 = i\n if p7 != -1 and p5 != -1:\n cur = (n - 1 - p5) + (n - 2 - p7)\n if p5 < p7: cur += 1\n fl = 1\n break\n\nif fl == 1:\n news = []\n for i in xrange(n):\n if i == p7 or i == p5: continue\n news.append(s[i])\n\n i = 0\n while i < len(news) and news[i] == '0': i += 1\n if i != len(news):\n ans = min(ans, cur + i)\n\nif ans == float('inf'):\n print -1\nelse:\n print ans\n"}, {"source_code": "s=input()[::-1]\nm=I=41\nf=s.find('5')+1\ni=s.find('0')+1\nt=len(s)\nif i:\n j=min(s.find('0',i)+1or I,f or I)\n if j-1 and s1[x]==\"0\" and ai==len(s)-1:\n x-=1\n if x==-1:\n return [False]\n s=a+s1[0:ai]+s1[ai+1::]\n s=s[0:x+1]+s[x+2::]+s1[x]\n return [True,ai+len(s)-2-x,s[::-1]]\ns=input()\nans=10**6\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"0\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\n \nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"5\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"7\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"2\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nif ans==10**6:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "s=input()[::-1]\nm=I=41\nf=s.find('5')+1\ni=s.find('0')+1\nt=len(s)\nif i:\n j=min(s.find('0',i)+1or I,f or I)\n if j2)and i[-2]==0):\n i[-2],i[-3]=i[-3],i[-2]\n k+=1\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "import sys\ndef sol(a,s):\n ans=0\n s1=s[::-1]\n\n try:\n ai=s1.index(a)\n if a==\"0\":\n s2=a+s1[0:ai]+s1[ai+1::]\n return [True,ai,s2[::-1]]\n except:\n return [False]\n x=len(s)-2\n while x>-1 and s1[x]==\"0\" and ai==len(s)-1:\n x-=1\n if x==-1:\n return [False]\n s=a+s1[0:ai]+s1[ai+1::]\n s=s[0:x+1]+s[x+2::]+s1[x]\n return [True,ai+len(s)-2-x,s[::-1]]\ns=input()\nif int(s)%25==0:\n print(0)\n sys.exit()\nans=10**6\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"0\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\n \nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"5\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"7\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"2\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nif ans==10**6:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "import sys\ns=input()\nm=10000000000000000000000000000000000\nt=False\nif int(s)%25==0:\n print(0)\n sys.exit()\nif s.count(\"0\")>=2 and len(s)>2:\n t=True\n s1=s[::-1]\n x=0\n ind1=-1\n ind2=-1\n for i in range(len(s)):\n if s1[i]==\"0\":\n if x==0:\n ind1=i\n x=1\n else:\n ind2=i\n break\n m=min(ind1+ind2-1,m)\nif \"2\" in s and \"5\" in s:\n s1=s[::-1]\n ind1=s1.index(\"2\")\n ind2=s1.index(\"5\")\n if not ((ind1+1==len(s) and s1[ind1-1]==\"0\") or (ind2+1==len(s) and s1[ind2-1]==\"0\")):\n if ind2>ind1:\n m=min(ind1+ind2,m)\n t=True\n else:\n m=min(ind1+ind2-1,m)\n t=True\nif \"0\" in s and \"5\" in s:\n s1=s[::-1]\n ind1=s1.index(\"0\")\n ind2=s1.index(\"5\")\n if not ((ind2+1==len(s) and s1[ind2-1]==\"0\" and ind2-1!=ind1)):\n\n if ind2ind1:\n m=min(ind1+ind2,m)\n t=True\n else:\n m=min(ind1+ind2-1,m)\n t=True\n \nif t:\n print(m)\nelse:\n print(-1)\n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n if m[-1]=='0':\n k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "n = raw_input()\nl = len(n)\nt1 = -1\nt2 = -1\nt3 = -1\nt4 = -1\nflag = 0\nif ('5' in n and '0' in n) or ('7' in n and '5' in n) or ('2' in n and '5' in n) or (n.count('0') >= 2):\n flag = 1\nif flag == 1: \n if '5' in n and '0' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '5':\n i1 = i\n if n[i] == '0':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t1 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t1 += l - 1 - i2 + l - 1 - i1 + 1\n\n if '7' in n and '5' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '7':\n i1 = i\n if n[i] == '5':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t2 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t2 += l - 1 - i2 + l - 1 - i1 + 1\n if (i1 == 0 or i2 == 0) and n[1] == '0':\n t2 = -1\n #print t\n if '2' in n and '5' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '2':\n i1 = i\n if n[i] == '5':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n \n if i2 > i1:\n t3 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t3 += l - 1 - i2 + l - 1 - i1 + 1\n if (i1 == 0 or i2 == 0) and n[1] == '0':\n t3 = -1\n #print t\n if n.count('0') >= 2:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '0' and i != i2 and i1 == -1:\n i1 = i\n if n[i] == '0' and i != i1 and i2 == -1:\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n t4 += l - 1 - i2 + l - i1 - 2 + 1\n #print t\n\nif flag == 1:\n p = [t1, t2, t3, t4]\n #print p\n while -1 in p:\n p.remove(-1)\n\n print min(p)\nelse:\n print -1"}, {"source_code": "num = str(input())\nn =len(num)\nnum_r = num[::-1]\ns0, s5 = num_r.find('0'),num_r.find('5')\nif s0 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['0','5']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s0 = s0 + s\nelse:\n s0 = 999999999\nif s5 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s\nelse:\n s0 = 999999999\nssr = min(s0,s5)\nif ssr != 999999999:\n print(ssr)\nelse:\n print(-1)"}, {"source_code": "s = input().strip()[::-1]\n\ndef find(a, b):\n if a not in s or b not in s: return 40\n i = s.index(a)\n if(a == b):\n if b not in s[i+1]: return 40\n j = s.index(b, i+1)\n else: j = s.index(b)\n return i + j + (1 if j < i else 0)\n\nt = min(find('0', '0'), find('2', '5'), find('5', '0'), find('7', '5'))\nprint(t if t < 40 else -1)\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 = input()\n m = n[::-1]\n\n res = 10**9\n if n.count('0') >= 2: \n cnt, flag = 0, False\n for i, mi in enumerate(m):\n if mi == '0':\n if flag:\n cnt += i - 1\n break\n else:\n flag = True\n cnt += i\n\n res = min(res, cnt)\n\n if '5' in n:\n i = m.index('5')\n if '0' in n:\n j = m.index('0')\n if i > j:\n res = min(res, j + i - 1)\n else:\n res = min(res, j + i)\n if '2' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('2')\n for i in range(1, len(n) - 1):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n elif n.count('2') == 1 and n.index('2') == 0:\n cnt = i\n for i in range(1, len(n) - 1):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n else:\n j = m.index('2')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n if '7' in n:\n if n.count('5') == 1 and n.index('5') == 0:\n cnt = m.index('7')\n for i in range(1, len(n) - 1):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n elif n.count('7') == 1 and n.index('7') == 0:\n cnt = i\n for i in range(1, len(n) - 1):\n if n[i] != '0':\n cnt += i - 1\n cnt += len(n) - 2\n res = min(res, cnt)\n else:\n j = m.index('7')\n if i > j:\n res = min(res, j + i)\n else:\n res = min(res, j + i - 1)\n\n print(res if res < 10**9 else -1)\n\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": "\n \n\ndef search(a):\n s = None\n flg = False\n for i in range(len(a)):\n if flg is True:\n break\n if a[i] == '2':\n for j in range(len(a)):\n if a[j] == '5':\n s = '25'\n flg = True\n break\n elif a[i] == '5':\n for j in range(len(a)):\n if a[j] == '2':\n s = '25'\n flg = True\n break\n elif a[j] == '7':\n s = '75'\n flg = True\n break\n elif a[j] == '0':\n s = '50'\n flg = True\n break\n elif a[i] == '7':\n for j in range(len(a)):\n if a[j] == '5':\n s = '75'\n flg = True\n break\n elif a[i] == '0':\n for j in range(len(a)):\n if a[j] == '5':\n s = '50'\n flg = True\n break\n elif a[j] == '0' and i != j:\n s = '00'\n flg = True\n break\n if s is None:\n print(-1)\n exit()\n return s\n \n#def swap(a,b):\n# a, b = b, a\n# return b, a\n\ndef czero(a):\n ctr = 0\n index = None\n for i in range(len(a)):\n if a[i] != 0:\n index = i\n break\n if index == 0:\n return None\n else:\n cou = index\n while a[0] == '0':\n a[cou-1], a[cou] = a[cou], a[cou-1]\n ctr+=1\n cou-=1\n return ctr\n\nCounter = 0\na=input()[::-1]\n\nComb = search(a)\n\na = list(a)[::-1]\n\n\nNxt = a.index(Comb[1])\nfor i in range(Nxt+1, len(a)):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\nFst = a.index(Comb[0])\nfor i in range(Fst+1, len(a)-1):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n\nf = czero(a)\n\nif f is None:\n print(Counter)\nelse:\n print(Counter+f)\n\n"}, {"source_code": "n = list(input())[::-1]\nINF = 10**9\nif n in ['25', '50', '75']:\n print(0)\n exit(0)\n\ndef solve(a, b):\n if (a not in n) or (b not in n):\n return INF\n nn = n[:]\n ia = nn.index(a)\n nn = [a]+nn[:ia]+nn[ia+1:]\n ib = nn.index(b)\n nn = [a,b]+nn[1:ib]+nn[ib+1:]\n cnt = 0\n for i in range(len(n)-1, 1, -1):\n if nn[i]!='0':\n break\n cnt += 1\n else:\n return INF\n return ia+ib+cnt-1\nif n.count('0')>=2:\n ans = -1\n one = False\n for i in range(len(n)):\n if n[i]=='0':\n ans += i\n if one:\n break\n one = True\nelse:\n ans = INF\nans = min(ans, solve('5', '2'))\nans = min(ans, solve('0', '5'))\nans = min(ans, solve('5', '7'))\nif ans==INF:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "k = input()\nzeroes = [-1, -1]\nfive = -1\ntwo = -1\nseven = -1\nfor i in range(len(k)):\n if k[i] == '0':\n zeroes[zeroes.index(min(zeroes))] = i\n elif k[i] == '2':\n two = i\n elif k[i] == '5':\n five = i\n elif k[i] == '7':\n seven = i\nif len(k) == 3 and k[:2] == '50' and k[-1] != '5' and k[-1] != '0':\n print(2)\nelif k == '5020' or k == '5070':\n print(1)\nelif k[-2:] == '25' or k[-2:] == '00' or k[-2:] == '50' or k[-2:] == '75':\n print(0)\nelif k[-2:] == '52' or k[-2:] == '05' or k[-2:] == '57':\n print(1)\nelif k == '505':\n print(1)\nelif k == '500':\n print(0)\nelif k[:3] == '500' and five == 0:\n print(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\nelif len(k) != 4 and ((k[:3] == '502' and two == 2) or (k[:3] == '507' and seven == 2)):\n print((len(k)))\nelif (len(k) == 4) and (k[:3] == '502' or k[:3] == '507'):\n print(4)\nelif k[:2] == '50' and five == 0 and min(zeroes) == -1 and (seven != -1 or two != -1):\n print(2 * len(k) - max(two, seven) - 1)\nelse:\n ch = []\n fl = 0\n if min(zeroes) > -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "n = input()[::-1]\nc0 = n.count('0')\nc2 = n.count('2')\nc5 = n.count('5')\nc7 = n.count('7')\ns = 1e9\nif c0 > 1:\n i = n.find('0')\n j = n.find('0', i + 1)\n s = min(s, i + j - 1)\nif c2 and c5:\n i = n.find('2')\n j = n.find('5')\n r = j + i - 1 + (j > i)\n i, j = sorted([i, j])\n m = n[:i] + n[i + 1: j] + n[j + 1:]\n if not (m and m[-1] == '0'):\n s = min(s, r)\nif c5 and c0:\n i = n.find('5')\n j = n.find('0')\n s = min(s, j + i - 1 + (j > i))\nif c7 and c5:\n i = n.find('7')\n j = n.find('5')\n r = j + i - 1 + (j > i)\n i, j = sorted([i, j])\n m = n[:i] + n[i + 1: j] + n[j + 1:]\n if not (m and m[-1] == '0'):\n s = min(s, r)\nprint(-1 if s == 1e9 else s)\n"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nx = int(input())\n\nxs = str(x)\nif xs.count('0')<2 and \\\n (xs.count('2') + xs.count('5')) < 2 and \\\n (xs.count('5') + xs.count('0')) < 2 and \\\n (xs.count('7') + xs.count('5')) < 2:\n print '-1'\n sys.exit()\n\ndef f(x,d):\n sx = str(x)\n n = len(sx)\n if sx[-2:] in ('00','25','50','75'):\n return 0\n if d<0: return 100\n\n besta = 100\n for i in range(len(sx)-1):\n if sx[i] in '0257':\n if sx[i] in '05':\n inter = [n-2,n-1]\n else:\n inter = [n-2]\n if i+1=j:continue\n if (i!=0 or sx[i+1]!='0'):\n besta = min(besta, j-i + f(int(''.join((sx[:i],sx[i+1:j+1],sx[i],sx[j+1:]))), d-1))\n return besta\n\nbest = f(x,2)\n\n\nif best >= 100:\n print -1\nelse:\n print best\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\nS = list(map(int, input()))\nN = len(S)\n\nif N <= 1:\n print(-1)\n exit()\n\ndef calc(num1, num2):\n if S[-2] == num1 and S[-1] == num2:\n return 0\n if S[-1] == num1 and S[-2] == num2:\n return 1\n res = 0\n cnt = 1\n T = S[:]\n for i in range(N-3, -1, -1):\n if T[i] == num1:\n T[i], T[-2] = T[-2], T[i]\n j = i\n while j < N and T[j] == 0:\n j += 1\n cnt += 1\n if j == N:\n return INF\n else:\n T[i], T[j] = T[j], T[i]\n break\n else:\n cnt += 1\n else:\n return INF\n res += cnt\n cnt = 2\n for i in range(N-3, -1, -1):\n if S[i] == num2:\n T[i], T[-2] = T[-2], T[i]\n j = i\n while j < N and T[j] == 0:\n j += 1\n cnt += 1\n if j == N:\n return INF\n else:\n T[i], T[j] = T[j], T[i]\n break\n else:\n cnt += 1\n else:\n return INF\n res += cnt\n return res\n\nans = min(calc(5, 0), calc(2, 5), calc(7, 5), calc(0, 0))\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "num = str(input())\nn =len(num)\nnum_r = num[::-1]\ns0, s5 = num_r.find('0'),num_r.find('5')\nif s0 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['0','5']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s0 = s0 + s\nelse:\n s0 = 999999999\nif s5 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s\nelse:\n s5 = 999999999\nssr = min(s0,s5)\nif ssr != 999999999:\n print(ssr)\nelse:\n print(-1)"}, {"source_code": "def permutate(s):\n answer = 1000\n n = len(s)\n z = 0\n if s.count('2') >= 1 and s.count('5') >= 1:\n k1 = s.rfind('2')\n k2 = s.rfind('5')\n s1 = s[:k1] + s[(k1 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k2 < k1:\n answer = min(answer, 2 * n - k2 - k1 - 2 + z)\n elif k2 > k1:\n answer = min(answer, 2 * n - k2 - k1 - 3 + z)\n if s.count('5') >= 1 and s.count('0') >= 1:\n k3 = s.rfind('5')\n k4 = s.rfind('0')\n s1 = s[:k3] + s[(k3 + 1):]\n m = s1.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k4 < k3:\n answer = min(answer, 2 * n - k4 - k3 - 2 + z)\n elif k4 > k3:\n answer = min(answer, 2 * n - k4 - k3 - 3 + z)\n if s.count('7') >= 1 and s.count('5') >= 1:\n k5 = s.rfind('7')\n k6 = s.rfind('5')\n s1 = s[:k5] + s[(k5 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k6 < k5:\n answer = min(answer, 2 * n - k5 - k6 - 2 + z)\n elif k6 > k5:\n answer = min(answer, 2 * n - k6 - k5 - 3 + z)\n if s.count('0') > 1:\n k7 = s.rfind('0')\n k8 = s[:s.rfind(\"0\")].rfind(\"0\")\n s1 = s[:k7] + s[(k7 + 1):]\n m = s.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z += i\n answer = min(answer, 2 * n - 3 - k7 - k8 + z)\n if answer == 1000:\n return -1\n return answer\n\n\nl = input()\nprint(permutate(l))\n"}, {"source_code": "num = str(input())\n\nendings = [[0, 0], [5, 2], [0, 5], [5, 7]]\nlenght = len(num)\ncandidate = []\n\nfor tup in endings:\n poss = []\n ind = []\n checked = []\n count = 0\n\n for i in tup:\n \n for j in range(lenght - 1, -1, -1):\n \n index = lenght - j - 1\n \n if str(i) == num[j] and j not in ind and int(num[j]) not in checked:\n\n if len(ind):\n if str(tup[1]) == num[j] and j < ind[0]:\n index = lenght - j - 2\n ind.append(j)\n poss.append(index)\n checked.append(i)\n count += 1\n \n \n if count == 2:\n s = sum(poss)\n \n if (num[1] == '0' and 1 not in poss) or (num[2] == '0' or 2 not in poss):\n if (0 in poss and 1 in poss) and num[2] == '0': \n s += 2\n elif (0 in poss and num[1] == '0'):\n s += 1\n \n candidate.append(s) \n break\n \nif len(candidate):\n print(min(candidate))\nelse:\n print(-1)"}, {"source_code": "s = input().strip()\n\ndef find(a, b):\n if a not in s or b not in s: return 40\n j = s.rindex(b)\n i = 0\n for t,v in enumerate(s):\n if t != j and v == a: i = t\n o = 0\n if not (i and j) and len(s) > 2:\n for t in range(len(s)):\n if t != i and t != j and s[t] == '0': o += 1\n return (i > j) + 2 * len(s) - i - j - 3 + o\n\nt = min(find('0', '0'), find('2', '5'), find('5', '0'), find('7', '5'))\nprint(t if t < 40 else -1)\n"}, {"source_code": "a=str(raw_input())\nif ('5' in a and '0' in a) or ('7' in a and '5' in a) or ('2' in a and '5' in a) or (a.count('0')==2):\n res=[]\n if '5' in a and '0' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n a1.insert(0,'0')\n r+=a1.index('5')-1\n a1.remove('5')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '7' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('7')-1\n a1.remove('7')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if '2' in a and '5' in a:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('5')\n a1.remove('5')\n a1.insert(0,'5')\n r+=a1.index('2')-1\n a1.remove('2')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if a.count('0')==2:\n a1=list(a)\n a1=a1[::-1]\n r=a1.index('0')\n a1.remove('0')\n r+=a1.index('0')\n a1.remove('0')\n aux=True\n if '0' in a1 and a1[-1]=='0':\n aux=False\n ct=0\n for k in a1[::-1]:\n if k != '0':\n r+=ct\n aux=True\n break\n ct+=1\n if aux:\n res.append(r)\n if len(res)>0:\n print min(res)\n else:\n print -1\n \n \n \n \nelse:\n print -1\n \n \n"}, {"source_code": "def permutate(s):\n answer = 1000\n n = len(s)\n z = 0\n if s.count('2') >= 1 and s.count('5') >= 1:\n k1 = s.rfind('2')\n k2 = s.rfind('5')\n s1 = s[:k1] + s[(k1 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if len(s2) > 0 and s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n break\n if k2 < k1:\n answer = min(answer, 2 * n - k2 - k1 - 2 + z)\n elif k2 > k1:\n answer = min(answer, 2 * n - k2 - k1 - 3 + z)\n z = 0\n if s.count('5') >= 1 and s.count('0') >= 1:\n k3 = s.rfind('5')\n k4 = s.rfind('0')\n s1 = s[:k3] + s[(k3 + 1):]\n m = s1.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n print(s2)\n if len(s2) > 0 and s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n break\n print(z)\n if k4 < k3:\n answer = min(answer, 2 * n - k4 - k3 - 2 + z)\n elif k4 > k3:\n print(2 * n - k4 - k3 - 3 + z)\n answer = min(answer, 2 * n - k4 - k3 - 3 + z)\n z = 0\n if s.count('7') >= 1 and s.count('5') >= 1:\n k5 = s.rfind('7')\n k6 = s.rfind('5')\n s1 = s[:k5] + s[(k5 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if len(s2) > 0 and s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n break\n if k6 < k5:\n answer = min(answer, 2 * n - k5 - k6 - 2 + z)\n elif k6 > k5:\n answer = min(answer, 2 * n - k6 - k5 - 3 + z)\n z = 0\n if s.count('0') > 1:\n k7 = s.rfind('0')\n k8 = s[:s.rfind(\"0\")].rfind(\"0\")\n s1 = s[:k7] + s[(k7 + 1):]\n m = s1.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if len(s2) > 0 and s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n break\n answer = min(answer, 2 * n - 3 - k7 - k8 + z)\n if answer == 1000:\n return -1\n return answer\n\n\nl = input()\nprint(permutate(l))\n"}, {"source_code": "\nA_str = input()\n\nA = list(A_str)\n\nB = [\n ['2', '5'],\n ['5', '0'],\n ['7', '5']\n]\n\nresult = 10**9\n\nif int(A_str) % 100 == 0:\n print(0)\nelse:\n for a, b in B:\n if a not in A or b not in A:\n continue\n\n cresult = 0\n\n tmp_str = A_str[:]\n i = tmp_str.rfind(b)\n cresult += len(tmp_str) - 1 - i\n tmp_str = ''.join(A[:i] + A[i + 1:] + [A[i]])\n\n\n i = tmp_str.rfind(a)\n cresult += len(tmp_str) - 2 - i\n tmp_str = list(tmp_str)\n tmp_str = ''.join(tmp_str[:i] + tmp_str[i + 1:-1] + [tmp_str[i]] + [tmp_str[-1]])\n\n for i in range(len(tmp_str)):\n if tmp_str[i] != '0':\n break\n\n result = min([result, cresult + i])\n\n if A.count('0') > 1:\n cresult = 0\n i = A_str.rfind('0')\n cresult += len(A_str) - 1 - i\n i = A_str[:-1].rfind('0')\n cresult += len(A_str) - 2 - i\n\n result = min([result, cresult])\n\n if result < 10**9:\n print(result)\n else:\n print(-1)\n\n\n"}, {"source_code": "def permutate(s):\n answer = 1000\n n = len(s)\n z = 0\n if s.count('2') >= 1 and s.count('5') >= 1:\n k1 = s.rfind('2')\n k2 = s.rfind('5')\n s1 = s[:k1] + s[(k1 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k2 < k1:\n answer = min(answer, 2 * n - k2 - k1 - 2 + z)\n elif k2 > k1:\n answer = min(answer, 2 * n - k2 - k1 - 3 + z)\n if s.count('5') >= 1 and s.count('0') >= 1:\n k3 = s.rfind('5')\n k4 = s.rfind('0')\n s1 = s[:k3] + s[(k3 + 1):]\n m = s1.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k4 < k3:\n answer = min(answer, 2 * n - k4 - k3 - 2 + z)\n elif k4 > k3:\n answer = min(answer, 2 * n - k4 - k3 - 3 + z)\n if s.count('7') >= 1 and s.count('5') >= 1:\n k5 = s.rfind('7')\n k6 = s.rfind('5')\n s1 = s[:k5] + s[(k5 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k5 < k6:\n answer = min(answer, 2 * n - k5 - k6 - 2 + z)\n elif k5 > k6:\n answer = min(answer, 2 * n - k6 - k5 - 3 + z)\n if s.count('0') > 1:\n k7 = s.rfind('0')\n k8 = s[:s.rfind(\"0\")].rfind(\"0\")\n s1 = s[:k7] + s[(k7 + 1):]\n m = s.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n answer = min(answer, 2 * n - 3 - k7 - k8 + z)\n if answer == 1000:\n return -1\n return answer\n\n\nn = input()\nprint(permutate(n))\n"}, {"source_code": "a = input()[::-1]\nd = ['52','05','57']\nif len(a)<2: print(-1)\nelse:\n if a[:2] in d:\n print(0)\n else:\n ans = 99999999\n if len([i for i in a if i =='0']) >=2:\n x,y=-1,-1\n for i in range(len(a)):\n if a[i] == '0':\n if x<0:x = i\n elif y<0:y = i\n else:break\n ans = x+y-1\n \n \n for p in d:\n x,y = -1,-1\n for i in range(len(a)):\n if a[i] == p[0] and x<0:\n x = i\n if a[i] == p[1] and y<0:\n y = i\n if x<0 or y<0: continue\n print(x,y)\n c = 0\n if x>y:\n c+1\n x,y = y,x\n if y == len(a)-1 and a[-1] == '0' and x != len(a)-2:\n for i in range(len(a)-1):\n if a[i]!='0' and i != x:\n z=i\n c+=len(a)-2-z\n c+=x+y-1\n ans = min(ans,c)\n if ans == 99999999: ans = -1\n print(ans)"}, {"source_code": "n=int(input())\nl=(list(str(n)))[::-1]\ng=[]\ndef permut(l,c,c1):\n i=l.copy()\n k=0\n while(True):\n if i.index(c)==0:break\n else:\n j=i.index(c)\n i[j],i[j-1]=i[j-1],i[j]\n k+=1\n m=i[1:]\n while(True):\n if m.index(c1)==0:break\n else:\n j=m.index(c1)\n m[j],m[j-1]=m[j-1],m[j]\n k+=1\n if m[-1]=='0':\n k+=1\n return(k)\n\nif (('2'in l) and ('5' in l)):\n g.append(permut(l,'5','2'))\nif (('5'in l) and ('0' in l)):\n g.append(permut(l,'0','5'))\nif (('7'in l) and ('5' in l)):\n g.append(permut(l,'5','7'))\nif l.count('0')>1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "def permutate(s):\n answer = 1000\n n = len(s)\n z = 0\n if s.count('2') >= 1 and s.count('5') >= 1:\n k1 = s.rfind('2')\n k2 = s.rfind('5')\n s1 = s[:k1] + s[(k1 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k2 < k1:\n answer = min(answer, 2 * n - k2 - k1 - 2 + z)\n elif k2 > k1:\n answer = min(answer, 2 * n - k2 - k1 - 3 + z)\n if s.count('5') >= 1 and s.count('0') >= 1:\n k3 = s.rfind('5')\n k4 = s.rfind('0')\n s1 = s[:k3] + s[(k3 + 1):]\n m = s1.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k4 < k3:\n answer = min(answer, 2 * n - k4 - k3 - 2 + z)\n elif k4 > k3:\n answer = min(answer, 2 * n - k4 - k3 - 3 + z)\n if s.count('7') >= 1 and s.count('5') >= 1:\n k5 = s.rfind('7')\n k6 = s.rfind('5')\n s1 = s[:k5] + s[(k5 + 1):]\n m = s1.rfind('5')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n if k5 < k6:\n answer = min(answer, 2 * n - k5 - k6 - 2 + z)\n elif k5 > k6:\n answer = min(answer, 2 * n - k6 - k5 - 3 + z)\n if s.count('0') > 1:\n k7 = s.rfind('0')\n k8 = s[:s.rfind(\"0\")].rfind(\"0\")\n s1 = s[:k7] + s[(k7 + 1):]\n m = s.rfind('0')\n s2 = s1[:m] + s1[(m + 1):]\n if s2[0] == '0':\n for i in range(1, len(s2)):\n if s2[i] != 0:\n z = i\n answer = min(answer, 2 * n - 3 - k7 - k8 + z)\n if answer == 1000:\n return -1\n return answer\n\n\nn = input()\nprint(permutate(n))\n"}, {"source_code": "\nA_str = input()\n\nA = list(A_str)\n\nB = [\n ['2', '5'],\n ['5', '0'],\n ['7', '5']\n]\n\nresult = 10**9\n\nif int(A_str) % 100 == 0:\n print(0)\nelse:\n for a, b in B:\n if a not in A or b not in A:\n continue\n\n cresult = 0\n\n tmp_str = A_str[:]\n i = tmp_str.rfind(b)\n cresult += len(tmp_str) - 1 - i\n tmp_str = ''.join(A[:i] + A[i + 1:] + [A[i]])\n\n i = tmp_str.rfind(a)\n cresult += len(tmp_str) - 2 - i\n\n result = min([result, cresult])\n\n if A.count('0') > 1:\n cresult = 0\n i = A_str.rfind('0')\n cresult += len(A_str) - 1 - i\n i = A_str[:-1].rfind('0')\n cresult += len(A_str) - 2 - i\n\n result = min([result, cresult])\n\n if result < 10**9:\n print(result)\n else:\n print(-1)\n\n\n"}, {"source_code": "k = input()\nzeroes = [-1, -1]\nfive = -1\ntwo = -1\nseven = -1\nfor i in range(len(k)):\n if k[i] == '0':\n zeroes[zeroes.index(min(zeroes))] = i\n elif k[i] == '2':\n two = i\n elif k[i] == '5':\n five = i\n elif k[i] == '7':\n seven = i\nif len(k) == 3 and k[:2] == '50' and k[-1] != '5' and k[-1] != '0':\n print(2)\nelif k == '5020' or k == '5070':\n print(1)\nelif k[-2:] == '25' or k[-2:] == '00' or k[-2:] == '50' or k[-2:] == '75':\n print(0)\nelif k[-2:] == '52' or k[-2:] == '05' or k[-2:] == '57':\n print(1)\nelif k == '505':\n print(1)\nelif k == '500':\n print(0)\nelif k[:3] == '500' and five == 0:\n print(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\nelif len(k) != 4 and ((k[:3] == '502' and two == 2) or (k[:3] == '507' and seven == 2)):\n print((len(k)))\nelif (len(k) == 4) and (k[:3] == '502' or k[:3] == '507'):\n print(4)\nelif k[:2] == '50' and five == 0 and min(zeroes) == -1 and (seven != -1 or two != -1):\n print(2 * len(k) - max(two, seven) - 1)\nelse:\n ch = []\n fl = 0\n if min(zeroes) > -1:\n fl = 1\n ch.append(len(k) * 2 - zeroes[0] - zeroes[1] - 3)\n if five != -1 and max(zeroes) > -1:\n fl = 1\n if five < (max(zeroes)):\n ch.append(2 * len(k) - max(zeroes) - five - 3)\n else:\n ch.append(2 * len(k) - max(zeroes) - five - 2)\n if five != -1:\n if two != -1:\n fl = 1\n if two < five:\n ch.append(2 * len(k) - two - five - 3)\n else:\n ch.append(2 * len(k) - two - five - 2)\n if seven != -1:\n fl = 1\n if seven < five:\n ch.append(2 * len(k) - seven - five - 3)\n else:\n ch.append(2 * len(k) - seven - five - 2)\n if fl:\n print(min(ch))\n else:\n print(-1)"}, {"source_code": "num = str(input())\n\nendings = [[0, 0], [5, 2], [0, 5], [5, 7]]\nlenght = len(num)\ncandidate = []\n\n\nif lenght == 2:\n if [int(num[1]), int(num[0])] in endings:\n print(0)\n else:\n print(-1)\n exit()\n\n\nfor tup in endings:\n poss = []\n ind = []\n leftCheck = [i for i in tup]\n count = 0\n\n for i in tup:\n \n for j in range(lenght - 1, -1, -1):\n \n index = lenght - j - 1\n \n if str(i) == num[j] and j not in ind and int(num[j]) in leftCheck:\n\n if len(ind):\n if str(tup[1]) == num[j] and j < ind[0]:\n index -= 1\n ind.append(j)\n poss.append(index)\n del leftCheck[leftCheck.index(i)]\n count += 1\n \n \n if count == 2:\n s = sum(poss)\n \n if (num[1] == '0' and 1 not in ind) or (num[2] == '0' or 2 not in ind):\n if (0 in poss and 1 in ind) and num[2] == '0' and int(num[2]) not in tup: \n s += 2\n elif (0 in ind and num[1] == '0') and (int(num[1]) not in tup):\n s += 1\n \n candidate.append(s)\n break\n \nif len(candidate):\n print(min(candidate))\nelse:\n print(-1)"}, {"source_code": "n =input()\nn2 = len(n)\nnum1 = n.rfind('5')\nnum2 = n.rfind('7')\nnum3 = n.rfind('2')\nnum4 = n.rfind('0')\nnum5 = n[:num4].rfind('0')\nnum6 = -1\nnum7 = n.find('0')\nfor i in range(1,n2):\n if n[i] != '0':\n num6 = i\n break\nif ((num1 != -1 and num4!= -1) or (num1 != -1 and num2!= -1)\n or (num3 != -1 and num1!= -1) or (num4 != -1 and num5!= -1)):\n ans = 100\n if num1 != -1 and num4!= -1:\n if num1 > num4:\n ans = min(ans,abs(n2-2-num1)+1 + abs(n2-1-num4))\n else:\n ans = min(ans,abs(n2-2-num1) + abs(n2-1-num4))\n if num4 != -1 and num5!= -1:\n ans = min(ans,abs(n2-2-num5) + abs(n2-1-num4))\n if num1 != -1 and num2!= -1:\n if n2 == 2:\n ans = min(ans,abs(n2-2-num2) + abs(n2-1-num1))\n elif num4 == -1:\n if num2 > num1:\n ans = min(ans,abs(n2-2-num2)+1 +abs( n2-1-num1))\n else:\n ans = min(ans,abs(n2-2-num2) +abs( n2-1-num1))\n elif not((num1 == 0 and num2 == 1 and num7 == 2) or (num2 == 0 and num1 == 1 and num7 == 2)):\n if (num1 == 0 or num2 == 0) and num7 == 1:\n ans = min(ans,abs(n2-2-num2) + abs(n2-1-num1) + num6 - 1)\n elif num2 > num1:\n ans = min(ans,abs(n2-2-num2)+1 +abs( n2-1-num1))\n else:\n ans = min(ans,abs(n2-2-num2) +abs( n2-1-num1))\n if num1 != -1 and num3!= -1:\n if n2 == 2:\n ans = min(ans,abs(n2-2-num3) + abs(n2-1-num1))\n elif num4 == -1:\n if num3 > num1:\n ans = min(ans,abs(n2-2-num3)+1 + abs(n2-1-num1))\n else:\n ans = min(ans,abs(n2-2-num3) + abs(n2-1-num1))\n elif not((num1 == 0 and num3 == 1 and num7 == 2) or (num3 == 0 and num1 == 1 and num7 == 2)):\n if (num1 == 0 or num3 == 0) and num7 == 1:\n ans = min(ans,abs(n2-2-num3) + abs(n2-1-num1) + num6 - 1)\n elif num3 > num1:\n ans = min(ans,abs(n2-2-num3)+1 +abs( n2-1-num1))\n else:\n ans = min(ans,abs(n2-2-num3) +abs( n2-1-num1))\n if n[n2-2:] == \"05\" or n[n2-2:] == \"57\" or n[n2-2:] == \"52\":\n ans = 1\n if n[n2-2:] == \"50\" or n[n2-2:] == \"75\" or n[n2-2:] == \"25\" or n[n2-2:] == \"00\":\n ans = 0\n print(ans)\nelse:\n print(-1)\n"}, {"source_code": "\n \n\ndef search(a):\n s = None\n flg = False\n for i in range(len(a)):\n if flg is True:\n break\n if a[i] == '2':\n for j in range(len(a)):\n if a[j] == '5':\n s = '25'\n flg = True\n break\n elif a[i] == '5':\n for j in range(len(a)):\n if a[j] == '2':\n s = '25'\n flg = True\n break\n elif a[j] == '7':\n s = '75'\n flg = True\n break\n elif a[j] == '0':\n s = '50'\n flg = True\n break\n elif a[i] == '7':\n for j in range(len(a)):\n if a[j] == '5':\n s = '75'\n flg = True\n break\n elif a[i] == '0':\n for j in range(len(a)):\n if a[j] == '5':\n s = '50'\n flg = True\n break\n elif a[j] == '0' and i != j:\n s = '00'\n flg = True\n break\n if s is None:\n print(-1)\n exit()\n return s\n \n#def swap(a,b):\n# a, b = b, a\n# return b, a\n\ndef czero(a):\n ctr = 0\n index = None\n for i in range(len(a)):\n if a[i] != 0:\n index = i\n break\n if index == 0:\n return None\n else:\n cou = index\n while a[0] == '0':\n a[cou-1], a[cou] = a[cou], a[cou-1]\n ctr+=1\n cou-=1\n return ctr\n\nCounter = 0\na=input()[::-1]\n\nComb = search(a)\n\na = list(a)[::-1]\n\n\nNxt = a.index(Comb[1])\nfor i in range(Nxt+1, len(a)):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\nFst = a.index(Comb[0])\nfor i in range(Fst+1, len(a)-1):\n a[i-1], a[i] = a[i], a[i-1]\n Counter+=1\n\nf = czero(a)\n\nif f is None:\n print(Counter)\nelse:\n print(Counter+f)\n\n"}, {"source_code": "n=input()\nans=[]\nl=len(n)\n\nif(\"2\" in n and \"5\" in n):\n c2=l-n.rfind(\"2\")-2\n c5=l-n.rfind(\"5\")-1\n \n if(c2-1 and s1[x]==\"0\" and ai==len(s)-1 and len(s)!=1:\n x-=1\n if x==-1 and len(s)!=1:\n return [False]\n s=a+s1[0:ai]+s1[ai+1::]\n s=s[0:x+1]+s[x+2::]+s1[x]\n return [True,ai+len(s)-2-x,s[::-1]]\ns=input()\nans=10**6\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"0\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"0\",s)\nif x[0]:\n y=sol(\"5\",x[2][0:-1])\n if y[0] and int(y[2]+\"0\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"7\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nx=sol(\"5\",s)\nif x[0]:\n y=sol(\"2\",x[2][0:-1])\n if y[0] and int(y[2]+\"5\")%25==0:\n ans=min(x[1]+y[1],ans)\nif s=='0':\n print(s)\nelif ans==10**6:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "num = str(input())\n\nendings = [[0, 0], [5, 2], [0, 5], [5, 7]]\nlenght = len(num)\ncandidate = []\n\nfor tup in endings:\n poss = []\n ind = []\n count = 0\n\n for i in tup:\n \n for j in range(lenght - 1, -1, -1):\n \n index = lenght - j - 1\n \n if str(i) == num[j] and j not in ind:\n \n if len(ind):\n if str(tup[1]) == num[j] and j < ind[0]:\n index -= 1\n ind.append(j)\n poss.append(index)\n \n \n count += 1\n if count == 2:\n candidate.append(sum(poss))\n break\n \nif len(candidate):\n print(min(candidate))\nelse:\n print(-1)"}, {"source_code": "k = input()\nimport sys\nMin = sys.maxsize\nif '5' in k and '0' in k:\n temp = (len(k)-2) - k.rfind('5') + (len(k)-1) - k.rfind('0') \n if (k.rfind('5') > k.rfind('0')):\n temp += 1\n if (temp k.rfind('5')):\n temp += 1\n if (temp k.rfind('5')):\n temp += 1\n if (temp1:\n css = k.rfind('0')\n temp = (len(k)-1) - css\n k = k[:css] \n temp += (len(k)-1) - k.rfind('0') \n if (temp0:\n print min(res)\n else:\n print -1\n \n \n \n \nelse:\n print -1\n \n \n"}, {"source_code": "n = raw_input()\nl = len(n)\nt1 = -1\nt2 = -1\nt3 = -1\nt4 = -1\nflag = 0\nif ('5' in n and '0' in n) or ('7' in n and '5' in n) or ('2' in n and '5' in n) or (n.count('0') >= 2):\n flag = 1\nif flag == 1: \n if '5' in n and '0' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '5':\n i1 = i\n if n[i] == '0':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t1 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t1 += l - 1 - i2 + l - 1 - i1 + 1\n\n if '7' in n and '5' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '7':\n i1 = i\n if n[i] == '5':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n if i2 > i1:\n t2 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t2 += l - 1 - i2 + l - 1 - i1 + 1\n if (i1 == 0 or i2 == 0) and n[1] == '0':\n t2 = -1\n #print t\n if '2' in n and '5' in n:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '2':\n i1 = i\n if n[i] == '5':\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n \n if i2 > i1:\n t3 += l - 1 - i2 + l - i1 - 2 + 1\n else:\n t3 += l - 1 - i2 + l - 1 - i1 + 1\n if (i1 == 0 or i2 == 0) and n[1] == '0':\n t3 = -1\n #print t\n if n.count('0') >= 2:\n i1 = -1\n i2 = -1\n for i in range(l - 1, -1, -1):\n if n[i] == '0' and i != i2 and i1 == -1:\n i1 = i\n if n[i] == '0' and i != i1 and i2 == -1:\n i2 = i\n if i1 >= 0 and i2 >= 0:\n break\n t4 += l - 1 - i2 + l - i1 - 2 + 1\n #print t\n\nif flag == 1:\n p = [t1, t2, t3, t4]\n print p\n while -1 in p:\n p.remove(-1)\n\n print min(p)\nelse:\n print -1"}, {"source_code": "num = str(input())\nn =len(num)\nnum_r = num[::-1]\ns0, s5 = num_r.find('0'),num_r.find('5')\nif s0 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['0','5']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s0 = s0 + s\n else:\n s0 = 999999999\nelse:\n s0 = 999999999\nif s5 != n-1 or num.find('0') != 1:\n if s5 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s\n else:\n s5 = 999999999\n ssr = min(s0,s5)\n if ssr != 999999999:\n print(ssr)\n else:\n print(-1)\nelse:\n if s5 != -1:\n newnum_r = num_r[:s0] + num_r[s0+1:]\n c= []\n for a in ['2','7']:\n if newnum_r.find(a) != -1:\n c.append(newnum_r.find(a))\n if c != []:\n s = min(c)\n s5 = s5 + s + 1\n else:\n s5 = 999999999\n ssr = min(s0,s5)\n if ssr != 999999999:\n print(ssr)\n else:\n print(-1)"}, {"source_code": "s=input()[::-1]\nt=len(s)\nm=I=40\ndef g(c,i=0):return s.find(str(c),i)+1 or I\ni,f=g(0),g(5)\nif i1:\n g.append(permut(l,'0','0'))\n\nif g==[]:print(-1)\nelse:print(min(g))\n \n"}, {"source_code": "maxint = 2147483647\n\nclass mylist(list):\n def index(self, obj, *args):\n try:\n if len(args) == 0:\n return super(mylist, self).index(obj)\n if len(args) == 1:\n return super(mylist, self).index(obj,args[0])\n return super(mylist, self).index(obj,args[0],args[1])\n except ValueError:\n return -1\n\t\t \ndef cost(target,index1, index2):\n if index1 == -1 or index2 == -1:\n return maxint\n if target == '00':\n return index1 + index2 -1\n else:\n return index1 + index2 -1 if index2= bestCost:\n return bestCost\n rn,tempcost = swap(rn,cost[0])\n if tempcost == 0:\n return 0\n thiscost = tempcost + realCost(rn)\n if thiscost < bestCost:\n bestCost = thiscost\nn = input()\nrn = n[::-1]\nrn = mylist(rn)\nrcost = realCost(rn)\nprint(rcost if rcostmax):\n\t\tmax = count\nprint max"}, {"source_code": "n=int(input())\nar=[0]*101\nfr=[int(p) for p in input().split()]\nfor i in range(n):\n x=fr[i]\n ar[x]+=1\nar.sort()\nprint(ar[100])"}, {"source_code": "n = input()\narr = list(map(int,input().split()))\nnew_arr = list(set(arr))\nmaxx = 0\nfor i in new_arr:\n ans = arr.count(i)\n if ans>=maxx:\n maxx = ans\nprint(maxx)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nx=a[0]\nb=[]\ny=0\nfor i in range(1,n):\n if x!=a[i]:\n if y>0:\n b.append(y)\n x = a[i]\n y=0\n else:\n y=y+1\n if i==n-1:\n b.append(y)\nif b==[]:\n print(1)\nelse:\n print(max(b)+1)\n"}, {"source_code": "n= int(input())\na=input().split()\ncount=0 \nnew=1\nb=[]\nfor i in a:\n b.append(a.count(i))\n \nprint(max(b)) "}, {"source_code": "m=0\nk=0\nimport math\na=int(input())\nb=list(map(int,input().split()))\nb.sort()\ni=b[a-1]\nb.append(0)\nfor i in range(a):\n if b[i]==b[i+1]:\n m+=1\n else:\n if m> k:\n k=m\n m=0\nprint(k+1)\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb=1\nfor i in a:\n b = max(b, a.count(i))\nprint(b)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=a.count(max(set(a), key=a.count))\nprint(b)\n"}, {"source_code": "n=int(input())\nm=list()\nc=int(1)\na=list(map(int,input().split()))\na.sort()\nfor i in range(n-1):\n if a[i]==a[i+1]:\n c+=1\n #elif a[n-1]==a[n-2]:\n # c+=1\n else:\n m.append(c)\n c=1\n#if a[n-1]==a[n-2]:\n# c+=1\nm.append(c)\n#print(m)\nm.sort()\n#print(m)\nprint(m[len(m)-1])"}, {"source_code": "t=input()\nd=map(int,raw_input().split())\nma={}\nmaximum=1\nfor i in d:\n\tif ma.has_key(i):\n\t\tma[i]+=1\n\t\tif ma[i]>maximum:\n\t\t\tmaximum=ma[i]\n\telse:\n\t\tma[i]=1\nprint maximum"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\na_used = [0]*n\nans = 0\n\nwhile 0 in a_used:\n\tans+=1\n\ttmp = []\n\tfor i in range(n):\n\t\tif a[i] not in tmp and a_used[i] == 0:\n\t\t\ttmp.append(a[i])\n\t\t\ta_used[i] = 1\n\nprint(ans)\n"}, {"source_code": "def countPockets():\n MAX_COIN_VALUE = 100\n coinCount = int(raw_input())\n coins = [int(c) for c in raw_input().split(' ')]\n coinsMap = [0] * MAX_COIN_VALUE\n\n for coin in coins:\n coinsMap[coin-1] += 1\n\n print(max(coinsMap))\n\ncountPockets()\n"}, {"source_code": "import collections\nn = int(input())\nA = list(map(int,input().split()))\nC = collections.Counter(A)\nans = max(C.values())\nprint(ans)\n"}, {"source_code": "from collections import Counter\n\ndef find_pockets(arr):\n ctr = Counter(arr)\n values = list(ctr.values())\n pockets = 0\n while values:\n values = [c-1 for c in values if c != 0]\n pockets += 1\n print(pockets-1)\n\nif __name__ == '__main__':\n n = input()\n arr = list(map(int, input().split()))\n find_pockets(arr)"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\nmax = 0\nfor i in range(1,101) :\n \n x = a.count(i)\n \n if x > max :\n max = x\n\nprint max "}, {"source_code": "n = int(input())\na = sorted(list(map(int, input().split())))\nsolution = 1\ncount = 1\nlast = a[0]\nfor i in a[1:]:\n if last == i:\n count += 1\n else:\n count = 1\n solution = max(solution, count)\n last = i\nprint(solution)"}, {"source_code": "n=int(input())\narr=input().split()\nfor i in range(n):\n arr[i]=int(arr[i])\nmax=0\nfor i in arr:\n j=arr.count(i)\n if(max x:\n x = k\n k = 0\nif x <= k:\n x = k\nprint(x+1)\n"}, {"source_code": "from collections import Counter\nn=int(input())\narr=list(map(int,input().split()))\nc=Counter(arr)\nm=1\nfor key,value in c.items():\n\t\tif(value>m):\n\t\t\tm=value\nprint(m)\n"}, {"source_code": "n = int(input())\nA = list(map(int,input().split()))\ncnt = [0 for i in range(max(A)+1)]\nans = 0\nfor i in A:\n cnt[i]+=1\n ans = max(cnt[i],ans)\nprint(ans)"}, {"source_code": "n = int(input())\na = list(map(int,input().strip().split()))[:n]\n\nflag = 1\nb = []\nfor i in range(n) :\n x = a[i+1:n]\n y = x.count(a[i])\n b.append(y+1)\nprint(max(b))"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\na = sorted(a)\nm = 1\nl = -1\ns = 0\nfor i in range(0, n):\n\tif a[i] == l:\n\t\ts+=1\n\telse:\n\t\tm = max(s, m)\n\t\tl = a[i]\n\t\ts = 1\nm = max(s, m)\nprint(m)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nd,mx={},-1e64\nfor v in a:\n if v in d:\n d[v]+=1\n else:\n d[v]=1\nfor k in d:\n mx=max(mx,d[k])\nprint(mx)"}, {"source_code": "n=int(input())\nar=list(map(int,input().split()))\ncnt=[0 for i in range(101)]\nfor i in range(n):\n cnt[ar[i]]+=1\nprint(max(cnt))"}, {"source_code": "n=input()\nd=[int(z) for z in raw_input().split(' ')]\ns=[]\n\nfor i in d:\n\ts.append(d.count(i))\nprint max(s)"}, {"source_code": "n = int(input())\na = []\nainp = raw_input()\n\nai = ainp.split(\" \")\nfor i in range(0,n):\n\ta.append(int(ai[i]))\n\n\n\nans = 0\nfor i in range(0,n):\n\tcount = 0\n\tfor j in range(0,n):\n\t\tif a[i] == a[j] :\n\t\t\tcount+=1\n\t\t\t\n\tif count > ans:\n\t\tans = count\n\t\nprint(ans)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nmax_n = 0\nfor i in a:\n if a.count(i)>max_n:\n max_n = a.count(i)\n\nprint(max_n)"}, {"source_code": "from collections import Counter\nn=int(raw_input())\nl=map(int,raw_input().split())\na=Counter(l)\nb=a.keys()\nl1=[]\nfor i in range(len(b)):\n l1.append(a[b[i]])\nprint max(l1)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\na = sorted(a)\ncur_ans = 1\nans = 1\nfor i in range(1,n):\n if a[i] == a[i-1]:\n cur_ans += 1\n else:\n ans = max(ans, cur_ans)\n cur_ans = 1\nans = max(ans, cur_ans)\nprint(ans)"}, {"source_code": "inp=input\nli=list\niinp=lambda : int(inp())\nent=lambda : map(int,inp().split())\nlient=lambda : [int(i) for i in inp().split()]\nli0= lambda x: [0 for i in range(x)]\nstent=lambda : [i for i in inp()]\n\nfrom collections import Counter\nn=iinp()\nmonedas=lient()\nma=Counter(monedas)\nres=max(ma.values())\nprint(res)"}, {"source_code": "def do():\n n = int(input())\n dat = list(map(int, input().split()))\n import collections\n c = collections.Counter(dat)\n res = c.most_common(1)[0][1]\n print(res)\n\n\n\n\n\ndo()\n\n\n\ndef templ():\n #input = sys.stdin.readline\n from pprint import pprint\n #import sys\n #sys.setrecursionlimit(100000)\n\n\n q = int(input())\n for _ in range(q):\n s = input()\n n = int(input())\n n, k = map(int, input().split())\n dat = list(map(int, input().split()))\n\n\n dat = [1, 2, 3]\n print(\" \".join(list(map(str, res))))\n\n pass\n import math\n math.ceil(1.2)\n math.floor(1.2)\n round(1.2, 3)\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\ni=0\nmx=0\nwhile i mx:\n mx=x\nprint(mx)"}, {"source_code": "raw_input()\nar = map(int, raw_input().split())\nc = 0\n\nfor i in xrange(101):\n co = 0\n for j in ar:\n if j == i:\n co += 1\n c = max(c, co)\n\nprint c"}, {"source_code": "n=int(input())\nl=list(map(int,raw_input().strip().split()))\ns=set(l)\nt=[]\nif n==len(s):\n print(\"1\")\nelse:\n for i in s:\n t +=[l.count(i)]\n print(max(t))\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split(\" \"))\n\nar = [0]*101\nfor i in a:\n ar[i] += 1\n\nprint(max(ar))\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\np=set(l)\nm=[]\nfor i in p:\n m.append(l.count(i))\nprint(max(m)) "}, {"source_code": "n = int(input())\na = sorted(list(map(int, input().split())))\nsolution = 1\ncount = 1\nlast = a[0]\nfor i in a[1:]:\n if last == i:\n count += 1\n solution = max(solution, count)\n else:\n count = 1\n last = i\nprint(solution)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb=1\nfor i in a:\n b = max(b, a.count(i))\nprint(b)\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nans = 0\nk = set(l)\n\nfor i in k:\n c = l.count(i)\n if c > ans:\n ans = c\n else:\n continue\n\nprint(ans)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\na_used = [0]*n\nans = 0\n\nwhile 0 in a_used:\n\tans+=1\n\ttmp = []\n\tfor i in range(n):\n\t\tif a[i] not in tmp and a_used[i] == 0:\n\t\t\ttmp.append(a[i])\n\t\t\ta_used[i] = 1\n\nprint(ans)\n"}, {"source_code": "from collections import Counter\ninput()\nl=list(map(int,input().split()))\nprint(max(Counter(l).values()))"}, {"source_code": "n=int(raw_input())\n\ninputs=raw_input().split()\n\ncoins={}\n\nfor i in inputs:\n if int(i) not in coins.keys():\n coins[int(i)]=1\n else:\n coins[int(i)] += 1\n\npockets=coins[coins.keys()[0]]\n\nfor i in coins:\n if coins[i] > pockets:\n pockets = coins[i]\n\nprint pockets\n"}, {"source_code": "from collections import Counter\nn = int(input())\nprint(max(Counter(map(int, input().split())).values()))"}, {"source_code": "n=input()\ns=map(int,raw_input().split(\" \"))\na=s[0]\nm=1\nq=1\ns.sort()\nfor i in range(1,len(s)):\n if s[i]==s[i-1]:\n m+=1\n else:\n m=1\n if q f:\n f = n.count(i)\nprint(f)\n"}, {"source_code": "n=int(input())\narr=[int(i) for i in input().split()]\nx=list(map(lambda x:arr.count(x),arr))\nprint(max(x))\n"}, {"source_code": "n=input()\ns=raw_input()\nl=s.split()\nmin=1\nfor t in range(1,n):\n if l[t]==l[0]:\n min+=1\nfor i in range(1,n):\n temp=1\n for j in range(i+1,n):\n if l[j]==l[i]:\n temp+=1\n if temp>min:\n min=temp\nprint min\n \n \n \n \n"}, {"source_code": "n=(int)(input())\nl=list(map(int,input().split()))\n # a,b=map(int,input().split())\nar=[0]*101\nfor i in range(n):\n ar[l[i]]+=1\nar.sort()\nprint(ar[100])"}, {"source_code": "'''\n1003a\n-----\n\n'''\n\nn=input()\nL=raw_input()\nx=L.split()\narr=[]\n\nfor i in x:\n arr.append(int(i))\n\nmaxc=0\n\nfor i in arr:\n n=arr.count(i)\n if n>=maxc:\n maxc=n\n\nprint maxc\n \n \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())\na = ma(int, ti())\nd = {}\nfor i in a:\n\tif d.has_key(i):\n\t\td[i] += 1\n\telse:\n\t\td[i] = 1\nos(max(d.values()))"}, {"source_code": "n=int(input())\nl=list(map(int,raw_input().strip().split()))\ns=set(l)\nt=[]\nif n==len(s):\n print(\"1\")\nelse:\n for i in s:\n t +=[l.count(i)]\n print(max(t))\n"}, {"source_code": "a=int(input())\nb=list(map(int,input().split()))\nc=0\nfor i in range(a):\n count=b.count(b[i])\n if count>c:\n c=count\nprint(c)"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nm = max(l)\nans = []\ni = 0\nwhile i <= m:\n ans.append(0)\n i += 1\ny = 0\nwhile y < n:\n ans[l[y]] += 1\n y += 1\nprint(max(ans))\n"}, {"source_code": "n = int(raw_input())\nl = map(int, raw_input().split())\ns = set()\nmaior = 0\n\nfor i in xrange(n):\n s.add(l[i])\nfor i in xrange(len(s)):\n tmp = l.count(s.pop())\n if(tmp > maior):\n maior = tmp \n\nprint(maior)"}, {"source_code": "import operator\nn = int(input())\nmas = list(map(int, input().split()))\nd = {}\nuniq = set(sorted(mas))\nfor i in uniq:\n d[i] = 0\nfor i in mas:\n d[i] += 1\nprint(max(d.values()))"}, {"source_code": "from collections import Counter\n\nn = int(input())\na = [int(s) for s in input().split()]\n\nprint(Counter(a).most_common(1)[0][1])\n"}, {"source_code": "n = int(raw_input())\n\nar = sorted(map(int, raw_input().split()))\n\nf = []\n\nfor i in ar:\n\tf.append(ar.count(i))\n\nprint max(f)\n\n"}, {"source_code": "class Main:\n def __init__(self):\n self.n = int(input())\n self.a = [int(x) for x in input().split()]\n\n def main(self):\n print(max(self.a.count(x) for x in set(self.a)))\n\nif __name__ == \"__main__\":\n Main().main()"}, {"source_code": "n=int(input())\nar=input().split()\nf=[0]*101\nfor i in range (0,n):\n ar[i]=int(ar[i])\n f[ar[i]]+=1\nprint(max(f)) "}, {"source_code": "n=int(input())\narr=[int(i) for i in input().split()]\nx=list(map(lambda x:arr.count(x),arr))\nprint(max(x))\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())\na = ma(int, ti())\nd = {}\nfor i in a:\n\tif d.has_key(i):\n\t\td[i] += 1\n\telse:\n\t\td[i] = 1\nos(max(d.values()))"}, {"source_code": "n=input()\nimport collections\nl=map(int,raw_input().split())\nd=collections.Counter(l)\nprint max(d.values())\n"}, {"source_code": "n=int(input())\ncount=0\nz=1\nar=sorted(list(map(int,input().split())))\nfor i in range(len(ar)-1):\n if ar[i+1]==ar[i]:\n count+=1\n else: \n z=max(z,count+1)\n count=0\nprint(max(count+1,z))"}, {"source_code": "from collections import *\nn = int(input())\na = list(map(int,input().split()))\nc = Counter(a)\nprint(max(c.values()))"}, {"source_code": "from collections import Counter\nprint '' if raw_input() == 0 else '' + str(Counter(map(int, raw_input().split(' '))).most_common(1)[0][1])"}, {"source_code": "n=int(input())\nm=list()\nc=int(1)\na=list(map(int,input().split()))\na.sort()\nfor i in range(n-1):\n if a[i]==a[i+1]:\n c+=1\n #elif a[n-1]==a[n-2]:\n # c+=1\n else:\n m.append(c)\n c=1\n#if a[n-1]==a[n-2]:\n# c+=1\nm.append(c)\n#print(m)\nm.sort()\n#print(m)\nprint(m[len(m)-1])"}, {"source_code": "n=int(input())\nl=input().split()\nli=[int(i) for i in l]\nmaxa=0\nhashi=dict()\nfor i in li:\n if i in hashi:\n hashi[i]+=1\n else:\n hashi[i]=1\nfor i in hashi:\n maxa=max(maxa,hashi[i])\nprint(maxa)\n"}, {"source_code": "import collections\n\nn = input()\nl = map(int, raw_input().split())\nm = collections.Counter(l).values()\nprint max(m)\n"}, {"source_code": "n = input()\nstring = raw_input()\nlist = []\nlist = string.split()\nfor a in range (0, n):\n list[a] = int(list[a])\ndic = {}\nfor a in list:\n dic[a] = 0\nfor a in list:\n dic[a] += 1\nmaxi = 0\nfor a in range (0, len(dic.values())):\n maxi = max(maxi, dic.values()[a])\nprint maxi"}, {"source_code": "import collections\nn = int(input())\na = list(map(int, input().split()))\nC = collections.Counter(a).most_common()\nprint(C[0][1])\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nmax_n = 0\nfor i in a:\n if a.count(i)>max_n:\n max_n = a.count(i)\n\nprint(max_n)"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nk = 0\nx = 0\nfor i in range(1, n):\n if a[i] == a[i-1]:\n k+=1\n else:\n if k > x:\n x = k\n k = 0\nif x <= k:\n x = k\nprint(x+1)\n"}, {"source_code": "import collections\nn = int(input())\nA = list(map(int,input().split()))\nC = collections.Counter(A)\nans = max(C.values())\nprint(ans)\n"}, {"source_code": "from collections import Counter\nn = int(raw_input())\nlis=map(int,raw_input().split())\ns=Counter(lis)\ntt=[]\nfor i in s.values():\n tt.append(i)\nprint max(tt)\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())\na = ma(int, ti())\nd = {}\nfor i in a:\n\tif d.has_key(i):\n\t\td[i] += 1\n\telse:\n\t\td[i] = 1\nos(max(d.values()))"}, {"source_code": "n=input()\nd=[int(z) for z in raw_input().split(' ')]\ns=[]\n\nfor i in d:\n\ts.append(d.count(i))\nprint max(s)"}, {"source_code": "n = int(input())\nls = list(map(int,input().split()))\nls.sort()\nans = 1\ni=0\nwhile i < len(ls)-1:\n cnt = 1\n while ls[i] == ls[i+1]:\n cnt+=1\n i+=1\n if i==n-1:\n break\n i+=1\n ans=max(ans,cnt)\nprint(ans)"}, {"source_code": "n=input()\na=map(int,raw_input().split())\n\nb=[0]*100\n\nfor i in range(n):\n b[a[i]-1]+=1\n\nprint max(b)\n"}, {"source_code": "n=input()\ns=raw_input()\nl=s.split()\nmin=1\nfor t in range(1,n):\n if l[t]==l[0]:\n min+=1\nfor i in range(1,n):\n temp=1\n for j in range(i+1,n):\n if l[j]==l[i]:\n temp+=1\n if temp>min:\n min=temp\nprint min\n \n \n \n \n"}], "negative_code": [{"source_code": "s = int(input())\nn = list(map(int, input().split()))\nanswer = 0\nfor i in range (100):\n d= n.count(i)\n if d>answer:\n answer = d\nprint(answer)"}, {"source_code": "a = int(input())\nli = sorted(list(map(int, input().split())))\nb = 0\nfor i in range(a-1):\n if li[i] == li[i+1]:\n b += 1\nif b == 0:\n print(1)\nelse:\n print(b)"}, {"source_code": "input()\na = list(map(int,input().split()))\nb = list(set(a))\ntot=0\nk=0\nif len(b)==len(a):\n print(\"1\")\nelif len(a)%len(b)==0:\n tot=int(len(a)/len(b))\n print(tot)\nelif (len(a)/2)0:\n b.append(y)\n x = a[i]\n y=0\n else:\n y=y+1\nif b==[]:\n print(n)\nelse:\n print(max(b)+1)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\na = sorted(a)\nm = 1\nl = -1\ns = 0\nfor i in range(0, n):\n\tif a[i] == l:\n\t\ts+=1\n\telse:\n\t\tm = max(s, m)\n\t\tl = a[i]\n\t\ts = 1\nprint(m)\n"}, {"source_code": "COINS = int(input())\n\nARRAY = list()\n\nSPLIT = input().split(' ')\n\nfor i in range(COINS):\n ARRAY.append(int(SPLIT[i]))\n\nCOUNT = 1\n\n\nARRAY.sort()\nhighest_val = 0\nfor i in range(len(ARRAY)):\n num = ARRAY.count(i)\n if highest_val < num:\n highest_val = num\n COUNT = highest_val\n\nprint(str(COUNT))"}, {"source_code": "x = int(input())\ny = list(map(int , input().split()))\ny.sort()\nwin = 0\n\n\nfor c in range (101):\n if y.count(c) > win:\n win = c\n\nprint(win)\nprint(y.count(win+1))\n\n\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\n\nif len(set(l)) < len(l):\n print(2)\nelse:\n print(1) "}, {"source_code": "n = int(input())\nif n != 0:\n a = list(map(int, input().split()))\n \n b = [0] * n\n for i in range(n):\n b[i] = set()\n \n c = 1\n for elem in a:\n for i in range(c):\n if not (elem in b[i]):\n b[i].add(elem)\n break\n else:\n b[c-1].add(elem)\n c += 1\n print(c)\nelse:\n print(0)"}, {"source_code": "m=0\nimport math\na=int(input())\nb=list(map(int,input().split()))\nfor i in range(a):\n k=0\n for j in range (a):\n if b[j]==b[i]:\n k+=1\n if k>m:\n m=k\nprint(int(k))\n\n"}, {"source_code": "n = int(input())\na = sorted(list(map(int, input().split())))\nprint(a)\nsolution = 1\ncount = 1\nlast = a[0]\nfor i in a[1:]:\n if last == i:\n count += 1\n else:\n count = 1\n solution = max(solution, count)\n last = i\nprint(solution)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = []\nfor i in range(n):\n b = [a.count(a[i])]\nprint(max(b))"}, {"source_code": "x = int(input())\ny = list(map(int , input().split()))\ny.sort()\nwin = 0\n\n\nfor c in range (101):\n if y.count(c) > win:\n win = c\n\n\nprint(y.count(win+1))\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue May 28 20:03:18 2019\n\n@author: fsshakkhor\n\"\"\"\n\nn = input()\nara = list(map(int,input().split()))\n\nans = 1\nst = set()\nfor i in range(len(ara)):\n if ara[i] in st:\n ans += 1\n st.clear()\n else:\n st.add(ara[i])\n \nprint(ans)"}, {"source_code": "n=int(input())\nm=list(map(int,input().split()))\nx=[m.count(i) for i in range(n)]\nprint(max(x))\t\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nfor i in range(n):\n if not arr[i] & 1:\n arr[i] -= 1\nprint(*arr)"}, {"source_code": "def answer():\n n = int(input())\n a = [int(x) for x in input().split()]\n c = []\n i=0\n a.sort()\n while i maxf:\n\t\tmaxf = f[t]\n\nprint(max(f))\n\n\t\n\n\n\n\n\n"}, {"source_code": "n=int(input())\narr=[int(x) for x in input().split()]\narr.sort()\npocket=1\ni=0\nwhile i 0:\n ans += str(k)+ \" \"\n k = 0\nansNum = ans[:-1].split(\" \")\nprint(len(ansNum))\nprint(ans)\n\n\n"}, {"source_code": "n = input()\nb =list(map(int,input().split()))\nflag = [0 for i in range(110)]\nfor i in b:\n flag[i]+=1\ns = set()\nfor i in range(110):\n s.add(flag[i])\nprint(len(s)-1)"}, {"source_code": "n = int(input())\ncount = 0\nl = list(map(int, input().split()))\nfor i in range(n):\n for j in range(i + 1, n):\n if(l[i] == l[j]):\n count += 1\nprint(count)"}, {"source_code": "n = int(input())\nlis = input().split(\" \")\ncount=0\nMax=0\n\nfor i in range(0,len(lis)):\n for k in range(1,i):\n if lis[i]==lis[k]:\n count+=1\n print(i,lis[i],k,lis[k],count)\n if count>Max:\n Max=count\nif Max==0:\n Max+=1 \n \nprint(Max)"}, {"source_code": "n = int(input())\na = input().split(' ')\nl = set(a)\nif len(a) - len(l) == 0:\n print(\"1\")\nelse:\n print(len(a) - len(l))"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ns=set(a)\nc=[]\nfor i in s:\n t=a.count(i)\n c.append(t)\nif len(c)>1:\n m=max(c)\n t=c.count(m)\n if t==len(c):\n print(t)\n else:\n print(m)\nelse:\n print(n)"}, {"source_code": "#http://codeforces.com/contest/1003/problem/0\nn=int(input())\nc=list(map(int,input().split()))\nA=list(set(c))\nif len(A)==1 or len(A)==len(c):\n ans=1\nelse:\n ans=2\nprint(ans)\n"}, {"source_code": "n = int(input())\n\nn = input()\ncoins=[]\n\nfor x in n.split(\" \"):\n coins.append(int(x))\n\n\ncoins = sorted(coins)\n\npoc = []\ndup = []\nadd = 0\ntemp = 0\n\n\nfor x in coins :\n\n if int(x) not in poc :\n poc.append(int(x))\n temp = temp + abs(temp-add)\n add = 0 \n\n else:\n if int(x) not in dup :\n dup.append(int(x))\n else:\n add+=1\n\n\nif len(dup) >= 1:\n if add > 0 :\n temp = temp+ abs(temp-add)\n print (1+1+temp)\n else:\n print (1+1+temp)\n\nelse:\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"}, {"source_code": "n = 1\na = [100]\nk = 1\ni = 0\nfor i in a:\n if a.count(i) >= 2:\n k += 1\nprint(k)\n \n \n \n\n\n \n \n\n \n\n\n\n\n"}, {"source_code": "n = int(input())\nmas = list(map(int, input().split()))\nd = {}\nuniq = set(sorted(mas))\nfor i in uniq:\n d[i] = 0\nfor i in mas:\n d[i] += 1\nprint(d[max(d)])"}, {"source_code": "n=int(input())\nst=input().split(\" \")\narr=[int(x) for x in st]\ndic={}\nfor i in arr:\n dic[i]=dic.get(i,0)+1\nprint(max(dic, key=dic.get))"}, {"source_code": "def main():\n n = int(input()) # Input N\n arr = list(map(int, input().split(' '))) # Input Array\n\n pockets = []\n hand = []\n\n for coin in arr:\n if coin not in hand:\n hand.append(coin)\n else:\n hand = [coin]\n pockets.append(hand)\n\n print(len(pockets) if not hand else len(pockets) + 1)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "a = int(input())\nli = sorted(list(map(int, input().split())))\nb = 0\nfor i in range(a-1):\n if li[i] == li[i+1]:\n b+=1\nif b == 0:\n print(1)\nelif b == a-1:\n print(a)\nelse:\n print(b)"}, {"source_code": "n=int(input())\nx=input().split()\na=0\nflag=0\nfor i in range(len(x)):\n\tfor j in range(i+1,len(x)):\n\t\t# print(x[i],x[j])\n\t\tif x[i]==x[j]:\n\t\t\ta+=1\n\t\t\tflag=1\n\t\t\tbreak\nif flag == 1:\n\tprint(a)\nelse :\n\ta=1\n\tprint(a)"}, {"source_code": "from math import ceil\nI = input\nn = int(I())\ncoins = I().split()\nA = []\nB = []\n\nfor i in range(0,n):\n\tif coins[i] not in A:\n\t\tA.append(coins[i])\n\telse:\n\t\tB.append(coins[i])\n\nif len(A) > 0 and len(B)>0:\n\tprint(2)\nelse:\n\tprint(1)\n"}, {"source_code": "# -*- coding:utf-8 -*-\n#[n, m] = [int(x) for x in raw_input().split()]\n\ncache = {}\ndef some_func():\n \"\"\"\n \"\"\"\n n = input()\n n_list = [int(x) for x in raw_input().split()]\n for v in n_list:\n cache[v] = 1\n\n return n-len(cache)+1\n\n\n\nif __name__ == '__main__':\n print some_func()\n\n\n\n"}, {"source_code": "x = int(input())\ny = list(map(int , input().split()))\ny.sort()\nwin = 0\n\n\nfor c in range (101):\n if y.count(c) > win:\n win = c\n\nif x == 100 and y[0] == 99:\n print(99)\nelse:\n print(y.count(win))\n\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nb = set(a)\n\nprint(len(a) - len(b) if len(a) - len(b) > 0 else 1)"}, {"source_code": "raw_input()\nar = ' ' + raw_input() + ' '\n\nc = 0\nfor i in xrange(101):\n c = max(c, ar.count(' ' + str(i) + ' '))\n\nprint c"}, {"source_code": "n=int(input())\nlist=[int(item) for item in input().split()]\nlist.sort()\nprint(list)\nprev=list[0]\nsizes=[]\ncnt=0\nfor i in range(1,n):\n if(list[i]==prev):\n cnt+=1\n else:\n sizes.append(cnt)\n cnt=1\n prev=list[i]\nprint(max(sizes))\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline\n\n\n############ ---- Input Functions ---- ############\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 list(s[:len(s) - 1])\n\n\ndef invr():\n return (map(int, input().split()))\n\n\ndef Count_Repeat(x):\n _size = len(x)\n #repeated = []\n count = 0\n for i in range(_size):\n k = i + 1\n for j in range(k, _size):\n if x[i] == x[j] :\n count = count+1\n return count\n\n\nt= inp()\nlist = inlt()\nc = Count_Repeat(list)\nif c == 0:\n print(1)\nelse :\n print(c)\n\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nx=a[0]\nb=[]\ny=0\nfor i in range(1,n):\n if x!=a[i]:\n if y>0:\n b.append(y)\n x = a[i]\n y=0\n else:\n y=y+1\nif b==[]:\n print(1)\nelse:\n print(max(b)+1)\n"}, {"source_code": "n = int(input())\nnumbers = list(map(int, input().split(\" \")))\nls = [[numbers[0]]]\nfor i in range(1,n):\n flag = 0\n for j in range(0, len(ls)):\n if i not in ls[j]:\n ls[j].append(numbers[i])\n flag = 1\n break\n if flag == 0:\n ls.append([numbers[i]])\nprint(ls)\nprint(len(ls))"}, {"source_code": "charNum = int(input())\nstring = input()\nk = 0\nans = \"\"\nfor i in range(0,len(string)):\n if string[i] == \"B\":\n k += 1\n else:\n if k > 0:\n ans += str(k)+ \" \"\n k = 0\nansNum = ans[:-1].split(\" \")\nprint(len(ansNum))\nprint(ans)\n\n\n"}, {"source_code": "n = int(input())\nmas = list(map(int, input().split()))\nd = {}\nuniq = set(sorted(mas))\nfor i in uniq:\n d[i] = 0\nfor i in mas:\n d[i] += 1\nprint(max(d, key=d.get))"}, {"source_code": "a=int(input())\nb=list(map(int,input().rstrip().split()))\nr=len(b)\nc=[0]*101\ncount=0\nfor x in range(101):\n count=0\n for y in range(r):\n if x==b[y]:\n count+=1\n c[x]=count\n\n\n\nc.sort()\nprint(c[99])\n \n \n"}, {"source_code": "from collections import Counter\n\ndef find_pockets(arr):\n ctr = Counter(arr)\n values = list(ctr.values())\n print(\"The values are\", values)\n pockets = 0\n while values:\n values = [c-1 for c in values if c != 0]\n print(values)\n pockets += 1\n print(pockets-1)\n\n\n\n\n\nif __name__ == '__main__':\n n = input()\n arr = list(map(int, input().split()))\n find_pockets(arr)"}, {"source_code": "n = int(input())\ns = [int(x) for x in input().split(' ')]\nif len(s) - len(set(s)) == 0:\n print(1)\nelse:\n print(len(s) - len(set(s)))\n"}, {"source_code": "n = int(input())\n\nn = input()\ncoins=[]\n\nfor x in n.split(\" \"):\n coins.append(int(x))\n\n\ncoins = sorted(coins)\n\npoc = []\ndup = []\nadd = 0\ntemp = 0\n\n\nfor x in coins :\n\n if int(x) not in poc :\n poc.append(int(x))\n temp = temp + abs(temp-add)\n add = 0 \n\n else:\n if int(x) not in dup :\n dup.append(int(x))\n else:\n add+=1\n\n\nif len(dup) >= 1:\n if add > 0 :\n temp = temp+ abs(temp-add)\n print (1+1+temp)\n else:\n print (1+1+temp)\n\nelse:\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"}, {"source_code": "n = int(input())\na = [int(_) for _ in input().split()]\nfor i in a:\n if a.count(i)>1:\n print(a.count(i))\n break\n else:\n print('1')\n break\n"}, {"source_code": "COINS = int(input())\n\nARRAY = list()\n\nSPLIT = input().split(' ')\n\nfor i in range(COINS):\n ARRAY.append(int(SPLIT[i]))\n\nCOUNT = '1'\n\n\nARRAY.sort()\nhighest_val = 0\nfor i in range(len(ARRAY)):\n num = ARRAY.count(i)\n if highest_val < num:\n COUNT = str(num)\n\nprint(COUNT)"}, {"source_code": "n = int(input())\nlis = input().split(\" \")\ncount=0\nMax=0\n\nfor i in range(0,len(lis)):\n for k in range(1,i):\n if lis[i]==lis[k]:\n count+=1\n if count>Max:\n Max=count\nif Max==0:\n Max+=1 \n\nprint(Max)"}, {"source_code": "n = int(input())\ns = [int(x) for x in input().split(' ')]\nif len(s) - len(set(s)) == 0:\n print(1)\nelse:\n print(len(s) - len(set(s)))\n"}, {"source_code": "x = int(input())\ny = list(map(int , input().split()))\ny.sort()\nwin = 0\n\n\nfor c in range (101):\n if y.count(c) > win:\n win = c+1\n\nprint(win)\nprint(y.count(win))\n\n\n"}, {"source_code": "n = int(input())\ns = [int(x) for x in input().split(' ')]\nif len(s) - len(set(s)) == 0:\n print(1)\nelif len(set(s)) == 1:\n print(len(s))\nelse:\n print(len(s) - len(set(s)))\n"}, {"source_code": "m=0\nimport math\na=int(input())\nb=list(map(int,input().split()))\nfor i in range(a):\n k=0\n for j in range (a):\n if b[j]==b[i]:\n k+=1\n q=math.sqrt(k)\n if q>m:\n m=q\nprint(int(m+0.999))\n"}, {"source_code": "n = int(input())\nlis = input().split(\" \")\ncount=0\nMax=0\n\nfor i in range(0,len(lis)):\n for k in range(1,i):\n if lis[i]==lis[k]:\n count+=1\n print(i,lis[i],k,lis[k],count)\n if count>Max:\n Max=count\nif Max==0:\n Max+=1 \n \nprint(Max)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = []\nfor i in range(n):\n b = [a.count(a[i])]\nprint(max(b))"}, {"source_code": "n = int(input())\nl = sorted(list(map(int,input().split())))\nma = 0\nh = 0\nfor f in range(n-1) :\n if l[f] == l[f+1] :\n h += 1\n else :\n if h > ma :\n ma = h\n h = 0\nprint(ma)"}, {"source_code": "from sys import stdin\nfrom collections import defaultdict\nn = int(stdin.readline().rstrip())\nchars = stdin.readline().rstrip()\nc = defaultdict(int)\n\nfor char in chars:\n c[char] += 1\n\nones = min(c['o'], c['n'], c['e'])\nc['o'] -= ones; c['n'] -= ones; c['e'] -= ones\n\nzeroes = min(c['z'], c['e'], c['r'], c['o'])\n\nfor i in range(ones):\n print('{} '.format(1), end='')\n\nfor i in range(zeroes):\n print('{} '.format(0), end='')"}, {"source_code": "n = int(input())\na = sorted(list(map(int, input().split())))\nprint(a)\nsolution = 1\ncount = 1\nlast = a[0]\nfor i in a[1:]:\n if last == i:\n count += 1\n else:\n count = 1\n solution = max(solution, count)\n last = i\nprint(solution)"}, {"source_code": "m=0\nimport math\na=int(input())\nb=list(map(int,input().split()))\nfor i in range(a):\n k=0\n for j in range (a):\n if b[j]==b[i]:\n k+=1\n q=math.sqrt(k)\n if q>m:\n m=q\nprint(int(m+0.999))\n"}, {"source_code": "n = int(input())\nl = sorted(list(map(int,input().split())))\nma = 0\nh = 1\nfor f in range(n-1) :\n if l[f] == l[f+1] :\n h += 1\n if h > ma : ma = h\n else : h = 1\nprint(ma)\n"}, {"source_code": "n = int(input())\nlis = input().split(\" \")\ncount=0\nMax=0\n\nfor i in range(0,len(lis)):\n for k in range(1,i):\n if lis[i]==lis[k]:\n count+=1\n print(i,lis[i],k,lis[k],count)\n if count>Max:\n Max=count\nif Max==0:\n Max+=1 \n \nprint(Max)"}, {"source_code": "n = int(input())\nnumbers = list(map(int, input().split(\" \")))\nls = [[numbers[0]]]\nfor i in range(1,n):\n flag = 0\n for j in range(0, len(ls)):\n if i not in ls[j]:\n ls[j].append(numbers[i])\n flag = 1\n break\n if flag == 0:\n ls.append([numbers[i]])\nprint(ls)\nprint(len(ls))"}, {"source_code": "class pockets:\n\n def __init__(self,m):\n self.m=[]\n self.m.append(m)\n\n\nc=int(input())\nval=[]\np=1\nval=list(map(int,input().strip().split(\" \")))\n#for i in range(c):\n # val.append(int(input()))\n\n\n\nl=[]\n\nfor i in range(c):\n\tif (len(l)<1):\n\t l.append(pockets(val[i]))\n\t #print(\"first coin\",val[i],\" added and number of pockets=\",p,\"\\n\")\n\telse:\n\t\tfor j in range (len(l)):\n\t\t\tadded=0\n\t\t\tif val[i] not in l[j].m:\n\t\t\t\tl[j].m.append(val[i])\n\t\t\t\t#print(\"new coin\",val[i],\" added in old pocketand number of pockets=\",p,\"\\n\")\n\t\t\t\tadded=1\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcontinue\n\t\tif added is 0:\n\t\t\tl.append(pockets(val[i]))\n\t\t\tp=p+1\n\t\t\t#print(\"new coin\",val[i],\" added in new pocketand number of pockets=\",p,\"\\n\")\n\t\t\tbreak\n \n \nprint(p)\n\n\n\n\n\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nk = 0\nfor i in a:\n k += 1\nc = set(a)\nb = 0\nfor i in c:\n b += 1\nj = k - b\nif b == 1:\n j += 1\n print(j)\nelse:\n print(j)"}, {"source_code": "t=input()\nd=map(int,raw_input().split())\nma={}\nmaximum=0\nfor i in d:\n\tif ma.has_key(i):\n\t\tma[i]+=1\n\t\tif ma[i]>maximum:\n\t\t\tmaximum=ma[i]\n\telse:\n\t\tma[i]=1\nprint maximum"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\nfor i in a:\n x=a.count(i)\nprint(x)"}, {"source_code": "from math import ceil\nI = input\nn = int(I())\ncoins = I().split()\nA = []\nB = []\n\nfor i in range(0,n):\n\tif coins[i] not in A:\n\t\tA.append(coins[i])\n\telse:\n\t\tB.append(coins[i])\n\nif len(A) > 0 and len(B)>0:\n\tprint(2)\nelse:\n\tprint(1)\n"}, {"source_code": "try:\n n=int(input())\n l=list(map(int,input().split()))\n cnt=0\n for i in l:\n if l.count(i)>=2:\n cnt+=1\n a=n-cnt\n if a==n:\n print(1)\n else:\n print(cnt)\nexcept:\n pass\n\n"}, {"source_code": "#1003A Polycarp's Pockets\n\nn = int(input())\nentrada = str(input())\nentrada = entrada.split()\ncoins = [int(x) for x in entrada]\n\ncoins.sort()\n\ncounter = 1\nvalues_counter = [1]\n\nfor i in range(1,n):\n if coins[i] == coins[i-1]:\n counter += 1\n else:\n values_counter.append(counter)\n counter = 1\n \nprint(max(values_counter))\n "}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\nans=-1\nfor i in s:\n x=s.count(i)\n if x>ans:\n ans=x\nprint(x)\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().strip().split())\nif n <= 1:\n print(n)\nelse:\n a = sorted(a)\n\n result = 0\n current = 1\n prev = -1\n\n for item in a:\n if prev == item:\n current += 1\n else:\n if current > result:\n result = current\n current = 1\n prev = item\n\n print(result)"}, {"source_code": "n = int(input())\n\ncoins = input()\n\npoc = []\ndup = []\n\n\n\nfor x in coins.split(\" \") :\n if int(x) not in poc :\n poc.append(int(x))\n\n else:\n dup.append(int(x))\n\nif len(dup) > 1:\n dup = sorted(dup)\n\n add = 1\n for y in range(1,len(dup)):\n if dup[y] == dup[y-1]:\n add += 1\n\n else:\n pass\n\nelif len(dup) == 1 :\n add = 1\n\nelse:\n add = 0 \n\n\n\n\n\nprint (1 + add)\n \n\n\n \n \n \n\n \n\n \n \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": "from math import ceil\nI = input\nn = int(I())\ncoins = I().split()\nA = []\nB = []\nif n == 1:\n\tprint(1)\nelse:\n\tfor i in range(0,n):\n\t\tif coins[i] not in A:\n\t\t\tA.append(coins[i])\n\t\telse:\n\t\t\tB.append(coins[i])\n\tA = set(A)\n\tB = set(B)\n\tif len(A.intersection(B)) > 0:\n\t\tprint(2)\n\telse:\n\t\tprint(1)\n"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nted=[0 for i in range(110)]\nfor x in arr:\n\tted[x]+=1\nans=0\nwhile True:\n\tmx=max(ted)\n\t# print(mx)\n\tif mx==0:\n\t\tbreak\n\tind=0\n\tfor i in range(110):\n\t\tif ted[i]==mx:\n\t\t\tind=i\n\t\t\tbreak\n\twhile ted[ind]==mx:\n\t\tted[ind]-=1\n\t\tind+=1\n\tans+=1\nprint(ans)"}, {"source_code": "n=int(input())\ncount=0\nz=1\nar=sorted(list(map(int,input().split())))\nfor i in range(len(ar)-1):\n if ar[i+1]==ar[i]:\n count+=1\n z=max(z,count+1)\n count=0\nprint(z)"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\nprint(n - len(set(A)))\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nk = 0\ni = 0\nfor i in a:\n if a.count(i) >= 2:\n k += 1\n else:\n k = 1\nprint(k)\n\n \n \n \n\n\n \n \n\n \n\n\n\n\n"}, {"source_code": "def main():\n n = int(input()) # Input N\n arr = list(map(int, input().split(' '))) # Input Array\n\n pockets = []\n hand = []\n\n for coin in arr:\n if coin not in hand:\n hand.append(coin)\n else:\n pockets.append(hand)\n hand = []\n\n print(len(pockets) if not hand else len(pockets) + 1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nx=[]\nfor i in range(n):\n p=l.count(i)\n x.append(p)\nz=max(x)\nprint(z)\n\n\n\n\n"}, {"source_code": "x = int(input())\ny = list(map(int , input().split()))\ny.sort()\nwin = 0\n\n\nfor c in range (101):\n if y.count(c) > win:\n win = c\n\nprint(win)\nprint(y.count(win+1))\n\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nx=a[0]\nb=[]\ny=0\nfor i in range(1,n):\n if x!=a[i]:\n if y>0:\n b.append(y)\n x = a[i]\n y=0\n else:\n y=y+1\nif b==[]:\n print(n)\nelse:\n print(max(b)+1)\n"}, {"source_code": "import sys\n\nif __name__ == \"__main__\":\n\n n = int(sys.stdin.readline())\n l = sys.stdin.readline().strip('\\n').split(' ')\n\n l.sort()\n count = 1\n aux = 1\n\n for j in range(1,n):\n if l[j-1] == l[j]:\n count+=1\n\n\n if count>aux:\n aux = count\n continue\n\n else:\n count = 0\n\n print (aux)"}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\nans=-1\nfor i in s:\n x=s.count(i)\n if x>ans:\n ans=x\nprint(x)\n"}, {"source_code": "n = int(input())\na = []\nainp = raw_input()\nprint(ainp)\nai = ainp.split(\" \")\nfor i in range(0,n):\n\ta.append(int(ai[i]))\n\n\n\nans = 0\nfor i in range(0,n):\n\tcount = 0\n\tfor j in range(0,n):\n\t\tif a[i] == a[j] :\n\t\t\tcount+=1\n\t\t\t\n\tif count > ans:\n\t\tans = count\n\t\nprint(ans)\n"}, {"source_code": "try:\n n=int(input())\n l=list(map(int,input().split()))\n cnt=0\n for i in l:\n if l.count(i)>=2:\n cnt+=1\n a=n-cnt\n if a==n:\n print(1)\n else:\n print(cnt)\nexcept:\n pass\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nb = set(a)\n\nprint(len(a) - len(b) if len(a) - len(b) > 0 else 1)"}, {"source_code": "from sys import exit\nn = int(input())\ns = list(map(int, input().split()))\nans = 0\nfor i in range(101):\n ans = max(ans, s.count(i))"}, {"source_code": "from collections import OrderedDict\n\nx = int(input())\ny = list(map(int , input().split()))\n\ndef group_list(lst):\n res = [(el, lst.count(el)) for el in lst]\n return list(OrderedDict(res).items())\n\nz = []\nfor x,y in group_list(y):\n z.append(y)\n \nprint(z[-1])\n\n\n\n\n"}, {"source_code": "class pockets:\n\n def __init__(self,m):\n self.m=[]\n self.m.append(m)\n\n\nc=int(input())\nval=[]\np=1\nval=list(map(int,input().strip().split(\" \")))\n#for i in range(c):\n # val.append(int(input()))\n\n\n\nl=[]\n\nfor i in range(c):\n\tif (len(l)<1):\n\t l.append(pockets(val[i]))\n\t print(\"first coin\",val[i],\" added and number of pockets=\",p,\"\\n\")\n\telse:\n\t\tfor j in range (len(l)):\n\t\t\tadded=0\n\t\t\tif val[i] not in l[j].m:\n\t\t\t\tl[j].m.append(val[i])\n\t\t\t\tprint(\"new coin\",val[i],\" added in old pocketand number of pockets=\",p,\"\\n\")\n\t\t\t\tadded=1\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcontinue\n\t\tif (added==0):\n\t\t\tl.append(pockets(val[i]))\n\t\t\tp=p+1\n\t\t\tprint(\"new coin\",val[i],\" added in new pocketand number of pockets=\",p,\"\\n\")\n\t\t\t#break\n \n \nprint(p)\n\n\n\n\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nb=[]\nc=[1]\nfor i in range(len(a)-1):\n if a[i]!=a[i+1]:\n b.append(i+1)\nfor x in range(1,len(b)):\n c.append(b[x]-b[x-1])\nprint(max(c))\n"}, {"source_code": "#http://codeforces.com/contest/1003/problem/0\nn=int(input())\nc=list(map(int,input().split()))\nA=list(set(c))\nif len(A)==1 :\n ans=1\nif len(A)>=2 and len(A)!=len(c):\n ans=2\nprint(ans)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nk = 0\nfor i in a:\n k += 1\nprint(k)\nc = set(a)\nb = 0\nfor i in c:\n b += 1\nprint(b)\nj = k - b\nprint(j + 1)"}], "src_uid": "f30329023e84b4c50b1b118dc98ae73c"} {"nl": {"description": "You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard.Initially, you have an empty string. Until you type the whole string, you may perform the following operation: add a character to the end of the string. Besides, at most once you may perform one additional operation: copy the string and append it to itself.For example, if you have to type string abcabca, you can type it in 7 operations if you type all the characters one by one. However, you can type it in 5 operations if you type the string abc first and then copy it and type the last character.If you have to type string aaaaaaaaa, the best option is to type 4 characters one by one, then copy the string, and then type the remaining character.Print the minimum number of operations you need to type the given string.", "input_spec": "The first line of the input containing only one integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the length of the string you have to type. The second line containing the string s consisting of n lowercase Latin letters.", "output_spec": "Print one integer number\u00a0\u2014 the minimum number of operations you need to type the given string.", "sample_inputs": ["7\nabcabca", "8\nabcdefgh"], "sample_outputs": ["5", "8"], "notes": "NoteThe first test described in the problem statement.In the second test you can only type all the characters one by one."}, "positive_code": [{"source_code": "length = input()\ntext = input()\nlen_dec = 0\nconseq_str = str()\nmatch_length = 0\nmatch_found = False\ntry:\n idx = 0\n length = 1\n while idx < len(text):\n conseq_str = text[:idx+1]\n poss_match = text[idx+1:idx+length+1]\n if (conseq_str == poss_match):\n match_length = length\n match_found = True\n length += 1\n idx += 1\n if(match_found):\n total_moves = match_length + 1 + (len(text)-2*match_length)\n else:\n total_moves = len(text)\n print (total_moves)\nexcept:\n print (0)"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\n# from math import *\nfrom collections import *\n# from fractions import *\n# from 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=1000000007\nEPS=1e-6\ndef Ceil(a,b): return a//b+int(a%b>0)\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=Int()\ns=input()\n\nans=0\nok=True\n\nwhile(len(s)):\n ans+=1\n if(len(s)%2): s=s[:-1]\n else:\n k=len(s)//2\n if(s[:k]==s[k:] and ok): \n s=s[:k]\n ok=False\n else: s=s[:-1]\n\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\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\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());s=input()\nans=n\nfor i in range(1,n//2+1):\n if s[0:i]==s[i:i*2]:\n ans=min(ans,n-i+1)\nprint(ans)"}, {"source_code": "n=int(input())\ns=input()\nmid=n//2\nwhile s[:mid]!=s[mid:2*mid] and mid!=0:\n mid-=1\nprint(min(n,n-mid+1))"}, {"source_code": "\ndef doshit(st,steps,ct):\n global n;global s\n #print(\" \"*steps,st,steps) \n if st==s:\n return steps\n if len(st)>n//2:\n return steps+(n-len(st))\n else:\n x=1<<63\n if st==s[len(st):2*len(st)] and ct==0:\n t=2*st\n x=min(doshit(t,steps+1,1),x)\n t1=st+s[len(st)]\n x=min(x,doshit(t1,steps+1,ct))\n return x\n \n\n\n\nn=int(input())\ns=input()\nprint(doshit(s[0],1,0))"}, {"source_code": "n, s = int(input()), input()\ne = 0\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: e=i\nprint(n-max(e-1,0))\n"}, {"source_code": "n=int(input())\ns=input()\nc=\"\"\nmini=len(s)\nfor i in range(len(s)//2):\n c+=s[i]\n if(c==s[i+1:i+1+len(c)]):\n if(mini>i+2+len(s)-2*(i+1)):\n mini=i+2+len(s)-2*(i+1)\nprint (mini)"}, {"source_code": "n = int(input())\ns = input()\nmini = n\nfor i in range(int(n/2)+1):\n left = s[0:i]\n length = len(s[0:i])\n right = s[i:i+length]\n if left==right:\n mini = min(mini,(n-length+1))\nprint (mini)\n"}, {"source_code": "n = input()\nn = int(n)\nstr = input()\n\nindicator = 0\n\nMax = 0\n\nfor i in range(int(n/2)):\n s1 = str[:i + 1]\n s2 = str[i+1:2*i + 2]\n\n\n if s1 == s2:\n Max = len(s1)\n\n\nif Max > 0:\n print(n - Max + 1)\nelse:\n print(n)\n"}, {"source_code": "n = int(input())\ns = input()\nz = [0] * n\nfor i in range(n):\n if 2 * i <= n:\n if s[:i] == s[i:2 * i]:\n z[i] = i\nif max(z) != 0:\n print(n - max(z) + 1)\nelse:\n print(n)"}, {"source_code": "N = int(input())\ns = input().strip()\nminus=0\nfor i in range(len(s)):\n if s[:i+1]==s[i+1:i*2+2]:\n minus= i\nprint(len(s)-minus)"}, {"source_code": "n = int(input())\ns = input()\nsize = 0\ni = n-1\nwhile i>-1:\n if i%2 ==0:\n size+=1\n i-=1\n elif s[:(i+1)//2]==s[(i+1)//2:(i+1)]:\n size +=(i+1)//2+1\n break\n else:\n size +=2\n i-=2\n\n\nprint(size)\n"}, {"source_code": "n = int(input())\ns= input()\nc=0\nfor i in range(int(n/2),0,-1):\n if(s[0:i]==s[i:2*i]):\n print(n-i+1)\n c=1\n break\nif(c==0): print(n)\n"}, {"source_code": "n=int(input())\ns=input()\nm=1\nfor i in range(1,n//2+1):\n if s[:i]==s[i:2*i]:\n m=i\nprint(n-m+1)"}, {"source_code": "n=input()\ns=raw_input()\na=n\nfor i in range(1,n/2+1):\n if s[:i]==s[i:i*2]:\n a=min(a,1+n-i)\nprint a"}, {"source_code": "import sys\n\nn = int(input())\ns = input()\nans = 0\n\nfor i in range(1, n):\n if s[:i] == s[i:i+i]:\n ans = max(ans, i-1)\n\nprint(n - ans)\n"}, {"source_code": "n = int(input())\ns = input()\n\nm = ''\nfor i in range(1, len(s)):\n if s[0:i] == s[i:i * 2] and len(s[0:i]) > len(m):\n m = s[0:i]\n\nif len(m) == 0:\n print(len(s))\nelse:\n print(len(s) - len(m) + 1)"}, {"source_code": "n=int(input())\nx=0\ns=input()\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: x=i\nprint(n-max(x-1,0))"}, {"source_code": "n, a, j, i = int(input()), input(), 0, 0\nwhile i < n // 2 + 1:\n if a[:i] == a[i:2 * i]:\n j = max(i, j)\n i += 1\nprint([n, n + 1 - j][j > 0])\n"}, {"source_code": "n,a,j,i=int(input()),input(),0,0\nwhile i0])"}, {"source_code": "n=int(input())\ns=input()\nmid=n//2\nwhile s[:mid]!=s[mid:2*mid] and mid!=0:\n mid-=1\nprint(min(n,n-mid+1))\n"}, {"source_code": "n = int(input())\ns = input()\nd = \"\"\nMax = len(s)\ncount = Max\nfor i in range(len(s)//2):\n d = d + s[i]\n if s[i+1:].find(d) == 0:\n count = len(s) - len(d) + 1\n if count < Max :\n Max = count\nprint(count)"}, {"source_code": "length = input()\ntext = input()\nlen_dec = 0\nconseq_str = str()\nmatch_length = 0\nmatch_found = False\ntry:\n idx = 0\n length = 1\n while idx < len(text):\n conseq_str = text[:idx+1]\n poss_match = text[idx+1:idx+length+1]\n if (conseq_str == poss_match):\n match_length = length\n match_found = True\n length += 1\n idx += 1\n if(match_found):\n total_moves = match_length + 1 + (len(text)-2*match_length)\n else:\n total_moves = len(text)\n print (total_moves)\nexcept:\n print (0)"}, {"source_code": "n, s = int(input()), input()\n\nfor L in range(len(s) // 2, 1, -1):\n if s[:L] == s[L:2*L]:\n print(n - L + 1)\n break\nelse:\n print(n)"}, {"source_code": "n=int(input())\nx=' '\nx+=str(input())\nz=0\nflag=1\nwhile n>0:\n\tif(n%2==1):\n\t\tz+=1\n\t\tn-=1\n\telif(n%2==0):\n\t\tif x[1:(n//2)+1]==x[n//2+1:1+n] and flag==1:\n\t\t\tn=n//2\n\t\t\tz+=1\n\t\t\tflag=0\n\t\telse:\n\t\t\tn-=1\n\t\t\tz+=1\nprint(int(z))"}, {"source_code": "n = int(input())\ns = input()\n\nm = ''\nfor i in range(1, len(s)):\n if s[0:i] == s[i:i * 2] and len(s[0:i]) > len(m):\n m = s[0:i]\n\nif len(m) == 0:\n print(len(s))\nelse:\n print(len(s) - len(m) + 1)"}, {"source_code": "\ndef doshit(st,steps,ct):\n global n;global s\n #print(\" \"*steps,st,steps) \n if st==s:\n return steps\n if len(st)>n//2:\n return steps+(n-len(st))\n else:\n x=1<<63\n if st==s[len(st):2*len(st)] and ct==0:\n t=2*st\n x=min(doshit(t,steps+1,1),x)\n t1=st+s[len(st)]\n x=min(x,doshit(t1,steps+1,ct))\n return x\n \n\n\n\nn=int(input())\ns=input()\nprint(doshit(s[0],1,0))"}, {"source_code": "n=input()\nx=0\ns=raw_input()\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: x=i\nprint(n-max(x-1,0))"}, {"source_code": "# cook your dish here\nn = int(input())\nstr = input()\nmax1= 0 \n\nfor i in range(1,int(n/2)+1):\n if(str[:i] == str[i:i+i]):\n max1 = max(max1,i)\nif(max1 > 0):\n max1 = max1 - 1\nprint(n - max1)"}, {"source_code": "n = int(input())\ns = input()\nans = n\nfor p in range(1, n):\n if 2 * p > n:\n break\n if s[:p] + s[:p] == s[:(2 * p)]:\n ans = min(ans, p + 1 + n - 2 * p)\nprint(ans)\n"}, {"source_code": "n = int(input())\ns = input()\nans = n\nfor i in range(n // 2 + 1):\n if s[:i] == s[i:2*i]:\n ans = min(ans, n - i + 1)\nprint(ans)\n"}, {"source_code": "n = int(input())\ns = input()\nfor l in range(n // 2, -1, -1):\n if s[:l] == s[l:2 * l]:\n print(n - max(0, l - 1))\n break"}, {"source_code": "n=int(input())\ns=input()\nindcopy=0\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: indcopy=i\nprint(min(n, n-indcopy+1))\n \n"}, {"source_code": "n = int(input())\ns = input()\nd = \"\"\nMax = len(s)\ncount = Max\nfor i in range(len(s)):\n d = d + s[i]\n if s[i+1:].find(d) == 0:\n count = len(s) - len(d) + 1\n if count < Max :\n Max = count\nprint(count)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Apr 1 15:33:47 2018\n\n@author: Harsh Pathak\n\"\"\"\n\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Apr 1 14:17:29 2018\n\n@author: Harsh Pathak\n\"\"\"\ndef find_similarities(string):\n flag = 0\n for i in range(len(string)):\n for j in range(i+1,len(string)):\n if string[i]==string[j]:\n flag = 1\n return flag\ndef find_largest_occurence(string):\n char_list = []\n len_list = []\n for i in range(1,len(string)):\n stored_str = string[0:i]\n j=i\n check_str = string[j:j+i]\n if check_str == stored_str:\n char_list.append(check_str)\n len_list.append(i)\n main_dict = dict(zip(len_list,char_list))\n return main_dict\nlen_string = int(input())\nstring = input()\nflag = find_similarities(string)\nif flag == 0:\n print (len_string)\nelse:\n val_dict = find_largest_occurence(string)\n if bool(val_dict)==True:\n max_val = max(val_dict,key=val_dict.get)\n print (len_string-max_val+1)\n else:\n print (len_string)"}, {"source_code": "#!/bin/env python\n# -*- encoding: UTF-8 -*-\n\ndef mp():\n return map(int,str(raw_input()).split())\n\nn = int(raw_input())\ns = str(raw_input())\n\nans = n\nfor i in range(n/2):\n if s[:i+1] == s[i+1:2*i+2]:\n ans = min(ans, i + 1 + 1 + n - 2*i -2)\nprint ans\n"}, {"source_code": "\ndef string_count (string='name', idx=0, num=100, end=100):\n flag = True\n for i in range (idx, end+1):\n if i+num >= len(string):\n flag = False; break\n if string[i] == string[i+num]:\n flag = True\n else:\n flag = False\n break\n return flag\n\nx = int(input())\ns = str(input())\nmax = 0\n\n#for i in range (0, x-1):\nz = 1\nu = 0\nwhile 1:\n #u = 0\n v = s.find(s[0],z)\n if v < 0: break\n tmp = v - u\n r = string_count(s, 1, tmp, v-1)\n if tmp > max and r==True:\n max = tmp\n z = v+1\n\nif max > 0: max -= 1\n\nprint (x - max)"}, {"source_code": "n=int(input());s=input()\nans=n\nfor i in range(1,n//2+1):\n if s[0:i]==s[i:i*2]:\n ans=min(ans,n-i+1)\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nd = \"\"\nMax = len(s)\ncount = Max\nfor i in range(len(s)):\n d = d + s[i]\n if s[i+1:].find(d) == 0:\n count = len(s) - len(d) + 1\n if count < Max :\n Max = count\nprint(Max)"}, {"source_code": "n=int(input())\na=input()\nct=0\nh=1\np=0\nt=0\nm=int(n/2)\nwhile 1:\n if a[0:m]==a[m:2*m]:\n ct=n-m+1\n break\n if m==1:\n ct=n\n break\n m-=1\nif n==1:\n print(1)\nelse:\n print(ct)"}, {"source_code": "\n\nn = int(input())\n\nA = input()\n\nbest_result = n\n\nfor i in range(1, n // 2 + 1):\n if A[0:i] == A[i:2 * i]:\n best_result = i + 1 + n - 2 * i\n\nprint(best_result)\n"}, {"source_code": "n = int(input())\ns = input()\ni = n-1\nmoves = 0\nwhile(i>=0):\n\t# print(i)\n\tc = 1\n\tif((n-i)>=i and i>0):\n\t\tfor j in range(i):\n\t\t\tif(s[j] != s[i+j]):\n\t\t\t\tc = 0\n\telse:\n\t\tc = 0\n\tif(c == 0):\n\t\tmoves += 1\n\t\ti-=1\n\telse:\n\t\tmoves += 1\n\t\ti-=i\nprint(moves)\n"}, {"source_code": "n = int(input())\ns = input()\nz = [0] * n\nfor i in range(n):\n if 2 * i <= n:\n if s[:i] == s[i:2 * i]:\n z[i] = i\nif max(z) != 0:\n print(n - max(z) + 1)\nelse:\n print(n)"}, {"source_code": "n=input();txt=raw_input();i=1\nfor i in xrange(n/2,0,-1):\n if txt[:i]*2==txt[:i*2]:\n break\nprint (i+1)+(n-i*2)\n"}, {"source_code": "n = int(input())\ns = input()\nans = n\nfor l in range(1, n // 2 + 1):\n if s[:l] == s[l:2*l]:\n ans = min(ans, n - l + 1)\n\nprint(ans)\n"}, {"source_code": "n = int(raw_input().strip())\ns = list(raw_input().strip())\nmaxequals = 0\nfor i in range(n):\n if(((2 * (i + 1)) <= n) and (s[0 : i + 1] == s[i + 1 : 2 * (i + 1)])):\n maxequals = i\nprint len(s) - maxequals"}, {"source_code": "import re\nprint input()+1-len(re.match(r'(.*)\\1',raw_input()).group(1)or[0])"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(n // 2, -1, -1):\n if (s[:i] == s[i:2 * i]):\n break\nprint(min(n, n + 1 - i))"}, {"source_code": "n,a,j,i=int(input()),input(),0,1\nwhile i0])"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nbest = n\nfor l in range(1, n / 2 + 1):\n if 2 * l > n: break\n if s[:l] == s[l:2*l]:\n best = min(best, l + 1 + n - 2 * l)\n\nprint best\n"}, {"source_code": "n = int(input())\nword = input()\n\ntempPatt = \"\"\n\ncount = 1\nwhile count < n:\n pattern = word[0:count]\n pos = word.find(pattern)\n pos2 = word.find(pattern,pos+len(pattern))\n if pos2 == pos+len(pattern):\n tempPatt = pattern\n \n count += 1\n\nif tempPatt != \"\":\n print(len(word) - len(tempPatt) + 1)\nelse:\n print(n)\n\n\n"}, {"source_code": "n = int(input())\ns = input()\noperations = n\nfor i in reversed(range(1,n // 2 + 1)):\n if s[:i] == s[i:2*i]:\n operations = n - i + 1\n break\nprint(operations)"}, {"source_code": "b=input()\ns=input()\nn=len(s)\nc=len(s)\nisMade=0\nwhile c>0:\n #print (c)\n if c%2==1 and isMade==0:\n #print(s[:c//2+1],s[c//2+1:c+1])\n if s[:c//2+1]==s[c//2+1:c+1]:\n n-=(c//2)\n c=c//2+1\n isMade=1\n c-=1\nprint(n)"}, {"source_code": "n = int(input())\ns = input()\nd = \"\"\nMax = len(s)\ncount = Max\nfor i in range(len(s)):\n d = d + s[i]\n if s[i+1:].find(d) == 0:\n count = len(s) - len(d) + 1\n if count < Max :\n Max = count\nprint(count)"}, {"source_code": "n=int(raw_input())\nst=raw_input()\na=n\nfor i in xrange(1,n):\n\tp=st[:i]\n\tif st.startswith(p*2):\n\t\ta=n-i+1\nprint a"}, {"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())\ns = ti()\n\nif n == 1:\n\tos(1)\n\texit()\nif n == 2:\n\tos(2)\n\texit()\n\nptr = n\nans = n\nwhile ptr>1:\n\tif s[:ptr-1] == s[ptr-1: 2*(ptr-1)]:\n\t\tans -= ptr-1\n\t\tos(ans+1)\n\t\texit()\n\tptr -= 1\nos(n)\n"}, {"source_code": "\nn = int(input())\ns= input()\nmx =0\ni = 0\nfor j in range(i+1,n):\n if s[i:j] == s[j: (j+(j-i))%(n+1)]:\n mx = max(mx,(j-i))\nif mx ==0:\n print(n)\nelse:\n print(n - mx+1)"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nc = 0\nmn = n\n\nwhile i < n:\n #print(i, s[0: i // 2 + 1], s[i//2 + 1:i + 1])\n if i % 2 == 1 and s[0: i // 2 + 1] == s[i//2 + 1:i + 1]:\n c = i // 2\n i += 1\n mn = min(mn, n if c == 0 else n - c)\nprint(mn)"}, {"source_code": "n = int(input())\ns = str(input())\nx = 0\nfor i in range(n):\n if s[:i] == s[i:i+i]:\n x = max(i,x)\nif x:\n print(n-x+1)\nelse:\n print(n)"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nbest = n\nfor l in range(1, n / 2 + 1):\n if 2 * l > n: break\n if s[:l] == s[l:2*l]:\n best = min(best, l + 1 + n - 2 * l)\n\nprint best\n"}, {"source_code": "# itne me hi thakk gaye?\nn = int(input())\ns = input()\nto_check = ''\nmini = len(s)\nfor i in range(n):\n to_check += s[i]\n next = s.find(to_check, i+1)\n # print(to_check, next, i)\n if next == -1:\n continue\n elif next == i+1:\n # if next == i+1:\n typing = n - len(to_check) + 1\n mini = min(mini, typing)\nprint(mini)"}, {"source_code": "n=int(input())\ns=input()\nm=1\nfor i in range(1,n//2+1):\n if s[:i]==s[i:2*i]:\n m=i\nprint(n-m+1)"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(n // 2, -1, -1):\n if (s[:i] == s[i:2 * i]):\n break\nprint(min(n, n + 1 - i))"}, {"source_code": "\nn = int(input())\nst = input()\n\nans = 0\nmid = n // 2\nwhile mid > 0:\n\tif st[:mid] == st[mid: mid * 2]:\n\t\tans = mid + 1\n\t\tbreak\n\telse:\n\t\tmid -= 1\n\nans += n - mid * 2\nprint(ans)\n"}, {"source_code": "import re\nprint input()+1-len(re.match(r'(.*)\\1',raw_input()).group(1)or[0])"}, {"source_code": "n = int(raw_input())\ns = raw_input()\ni = 0\nres = n\nfor i in range(1, n):\n ss = s[:i]\n if len(ss) * 2 > n:\n break\n if ss == s[i:i+i]:\n res = i + 1 + n - 2 * i\nprint res\n"}, {"source_code": "n = int(input())\ns = input()\nfor i in range(n // 2, -1, -1):\n if s[:i] == s[i: 2 * i]:\n print(min(n, n - i + 1))\n exit()\n"}, {"source_code": "n=int(raw_input())\ns=raw_input()\nres=0\nmaxcool=0\nfor i in range(2,n/2+1):\n if s[:i]*2==s[:2*i]:\n maxcool=i\nres=n\nif maxcool>1:\n res-=maxcool-1\nprint res"}, {"source_code": "import sys\n\nn = int(input())\ns = input()\nans = 0\n\nfor i in range(1, n):\n if s[:i] == s[i:i+i]:\n ans = max(ans, i-1)\n\nprint(n - ans)\n"}, {"source_code": "n = int(input())\na = input()\nx = 0\nfor i in range(n//2, 1, -1):\n if a[0:i] == a[i:(i+i)]:\n x = i-1\n break\nprint(n-x)\n"}, {"source_code": "n=int(input())\nx=0\ns=input()\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: x=i\nprint(n-max(x-1,0))"}, {"source_code": "import sys,math \nn=int(input())\ns=input()\nans=0\ni=n-1\nflag=True\nwhile(i>=0):\n if i%2==1 and s[:i//2+1]==s[i//2+1:i+1] and flag:\n ans+=1 \n i//=2\n flag=False\n else:\n i-=1 \n ans+=1 \nprint(ans) \n \n \n \n \n \n"}, {"source_code": "n = int(input())\ntypestr = input()\nslen = len(typestr)\n\nans = slen\n\n\nfor k in range(slen):\n if k+k-1 1 and h > 1:\n if s[:l] == s[l:l + h]:\n count = l\n break\n else:\n l = (len(s) - i) // 2\n h = (len(s) - i) // 2\n i += 2\n copy = count + 1\n left = n - 2 * count\n print(left + copy)\nelse:\n s = s[:len(s) - 1]\n l = len(s) // 2\n h = len(s) // 2 # + l\n count = 1\n i = 0\n while l > 1 and h > 1:\n if s[:l] == s[l:l + h]:\n count = l\n break\n else:\n l = (len(s) - i) // 2\n h = (len(s) - i) // 2\n i += 2\n copy = count + 1\n left = n - 2 * count\n print(left + copy)\n"}, {"source_code": "#empty str\n#add 1 character to end until you get whole string\n#or\n#only once\n#append the string to itself\n#print minimum operations needed to print given str\n#FIND LONGEST REPEATING HALF STRING\n#gstr = 'afdfasdf....'\n#str = \"\"\n#while str!=gstr:\n#\tstr+=\n#\t\n#\n\nn = int(raw_input())\ns = raw_input()\nrpg = \"\"\nci = None\nfor i in xrange(2,(n/2)+1):\n\t#print s[:i]*2\n\t#print s[:(2*i)+1]\n\tif s[:i]*2 == s[:2*i]:\n\t\trpg = s[:i]\n\t\tci = i\n\nif rpg!=\"\":\n\topc = len(rpg) + 1 + len(s[2*ci:])\nelse:\n\topc = len(s)\n\nprint opc"}, {"source_code": "def main():\n n = int(input())\n line = input()\n ans = 0\n for i in range(50):\n if line[:i + 1] == line[i + 1:2 * (i + 1)]:\n ans = i\n print(n - ans)\n\n\nmain()"}, {"source_code": "input()\ninputString = input()\nans = 0\nfor i in range(len(inputString) - 1, -1, -1):\n ans += 1\n #print(ans)\n if i % 2 == 0:\n continue\n if(inputString[: (i + 1) // 2] == inputString[(i + 1) // 2 : i + 1]):\n #print(inputString[: (i + 1) // 2] + \" \" + inputString[(i + 1) // 2 : i + 1])\n ans += i // 2 + 1\n break\n\nprint(ans)\nexit()\n\n"}, {"source_code": "def main():\n n = map(int, input().split())\n\n string = input()\n\n idx, result, consumed = len(string), 0, False\n\n while idx > 0:\n if idx % 2 == 0 and string[:idx // 2] == string[idx // 2:idx] and not consumed:\n idx //= 2\n consumed = True\n else:\n idx -= 1\n result += 1\n\n print(result)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n = int(input())\ns = input()\nl = int(n//2)\nans = n\nfor i in range(l,-1,-1):\n if(s[:i]==s[i:2*i]):\n ans = min(ans,n-i+1)\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nd = \"\"\nMax = len(s)\ncount = Max\nfor i in range(len(s)):\n d = d + s[i]\n if s[i+1:].find(d) == 0:\n count = len(s) - len(d) + 1\n if count < Max :\n Max = count\nprint(Max)"}, {"source_code": "n=int(input())\ns=input()\nans=n\nfor i in range(1,n):\n if(2*i>n):\n break\n if(s[:i]+s[:i]==s[:2*i]):\n ans=min(ans,n+1-i)\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nans = n\nfor i in range(n // 2 + 1):\n if s[:i] == s[i:2*i]:\n ans = min(ans, n - i + 1)\nprint(ans)\n"}, {"source_code": "b=input()\ns=input()\nn=len(s)\nc=len(s)\nisMade=0\nwhile c>0:\n #print (c)\n if c%2==1 and isMade==0:\n #print(s[:c//2+1],s[c//2+1:c+1])\n if s[:c//2+1]==s[c//2+1:c+1]:\n n-=(c//2)\n c=c//2+1\n isMade=1\n c-=1\nprint(n)"}, {"source_code": "n = int(input())\ns = input()\nd = \"\"\nMax = len(s)\ncount = Max\nfor i in range(len(s)):\n d = d + s[i]\n if s[i+1:].find(d) == 0:\n count = len(s) - len(d) + 1\n if count < Max :\n Max = count\nprint(Max)"}, {"source_code": "n,a,j,i=int(input()),input(),0,1\nwhile i0])"}, {"source_code": "\"\"\" just need to count substring from indx 0 to n/2 not from any i index. will be only one substring or dont hav any though it may exist\"\"\"\nwhile True:\n\ttry:\n\n\t\tn = int(input())\n\t\ts = input()\n\t\tres, cunt, i = n, 0, 1\n\t\twhile i<= int(n/2):\n\t\t\tj, k = 0, i\n\t\t\t#print(j,k)\n\t\t\twhile j 3:\n for i in range(2, n):\n t = 2\n while i * t <= n and st[0:i] == st[i:i * t]:\n t += 1\n data.append((t - 2, i))\n mx1 = max(data, key=lambda x: (x[0], x[1]))[1]\n mx2 = max(data, key=lambda x: (x[0], x[1]))[0]\n print(mx1 + mx2 + (n - mx1 * mx2 - mx1))\nelse:\n print(n)"}, {"source_code": "n = int(raw_input())\nstrng = raw_input()\n\nnum_operations = 0\ni = len(strng)\nwhile i > 0:\n if i % 2 == 0 and strng[:i / 2] == strng[i / 2:i]:\n num_operations += 1\n num_operations += i / 2\n break\n num_operations += 1\n i -= 1\n\nprint num_operations\n"}, {"source_code": "n, s = int(input()), input()\ne = 0\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: e=i\nprint(n-max(e-1,0))\n"}, {"source_code": "n =int(input())\nstring =input()\nmaxstr =''\n\nfor i in range(1,len(string)):\n substr =string[:i]\n remstr =string[i:]\n if len(substr) > len(remstr):\n break\n same =1\n for i in range(len(substr)):\n if substr[i] != remstr[i]:\n same =0\n break\n if not same:\n continue\n maxstr =substr\nif maxstr != '':\n print(n-len(maxstr)+1)\n quit()\nprint(len(string))"}, {"source_code": "n=int(input())\nx=0\ns=input()\nfor i in range(1,n//2+1):\n if s[:i]==s[i:i*2]: x=i\nprint(n-max(x-1,0))"}, {"source_code": "n = input()\ntxt = str(raw_input())\npat = ''\nwyn = n\nwyn2 = 0\npat = txt[0]\nfor y in range(1, len(txt), +1):\n pat += txt[y]\n dl = 1\n wyn2 = 0\n while True:\n if y + len(pat) * dl <= len(txt):\n nn = y + 1 + (len(pat) * (dl - 1))\n nnn = y + len(pat) * dl\n temp_wyn = txt.count(pat, nn, nnn + 1)\n if temp_wyn == 1:\n wyn2 += 1\n dl += 1\n if len(pat) + wyn2 + (n - ((wyn2 + 1) * len(pat))) < wyn:\n wyn = len(pat) + wyn2 + (n - ((wyn2 + 1) * len(pat)))\n break\n else:\n break\nprint wyn"}, {"source_code": "n=int(input())\ns=input()\nans=n\n\nfor i in range(1,int(n/2)+1):\n\tif s[:i]==s[i:2*i] :\n\t\tans=n-i+1\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nans = 0\nfor i in range(1,n):\n a = s[:i]\n b = s[i:]\n if(len(a)>len(b)):\n break\n if(b[:len(a)]==a):\n ans = i\nif(ans==0):\n print(n)\nelse: \n f_ans = ans+1+(n-2*ans)\n print(f_ans)\n"}, {"source_code": "n, s = int(input()), input()\n\nfor L in range(n // 2, 1, -1):\n if s[:L] == s[L:2*L]:\n print(n - L + 1)\n break\nelse:\n print(n)"}, {"source_code": "n = int(input())\ns= input()\nc=0\nfor i in range(int(n/2),0,-1):\n if(s[0:i]==s[i:2*i]):\n print(n-i+1)\n c=1\n break\nif(c==0): print(n)\n"}], "negative_code": [{"source_code": "import re\nn = int(input()) ;s = input()\nt = re.sub(r'^(.+)\\1.*', r'\\1', s)\nprint(t)\nif len(t) == len(s):\n\tprint(len(s))\nelse:\n\tprint(len(s) - len(t) + 1)"}, {"source_code": "number=int(input())\nstring=input()\nstr=string[0]\nindex=1\nstr_o=1\nwhile index < number:\n\tif str[:index]==string[index:2*(index)]:\n\t\tstr_o += 1\n\t\tindex *= 2\n\t\tstr += str\n\telse:\n\t\tstr_o += 1\n\t\tindex += 1\n\t\tstr+=string[index - 1]\nf = False\nc = string[0]\nfor i in range(number):\n\tif c != string[i]:\n\t\tf = True\n\t\tbreak\nif f == False:\n\tstr_o = 0\n\twk1 = number\n\twhile wk1 > 0:\n\t\tif wk1 % 2 == 1:\n\t\t\tstr_o += 1\n\t\t\twk1 -= 1\n\t\tif wk1 == 0:\n\t\t\tbreak\n\t\twk1 = wk1 // 2\n\t\tstr_o += 1\nprint(str_o)\t\n"}, {"source_code": "def solve(i):\n if len(word) == i:\n return 0\n\n a = 10**9\n if i*2 <= len(word) and word[:i] == word[i:i*2]:\n a = solve(i*2)\n return min(1+a, 1+solve(i+1))\n\ninput()\nword = input()\nprint (1+solve(1))\n"}, {"source_code": "n=int(input())\nch=input()\ns=0\ni=0\nif ch.count(ch[0])==n:\n\n print((n+1)//2)\nelse:\n while i=0:\n s+=1+a-i\n i+=a+j-i\n break\n elif j==n:\n s+=n-i\n i=n\n \n print(s)\n \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\n\nn = int(ti())\ns = ti()\n\nif n == 1:\n\tos(1)\n\texit()\nif n == 2:\n\tos(2)\n\texit()\n\nnews = \"\" + s[n-1]\nsl = 1\nptr = n-2\nans = 1\ndone = False\nwhile ptr != 0:\n\tif s[ptr] != s[0]:\n\t\tnews = s[ptr] + news\n\t\tsl += 1\n\t\tptr -= 1\n\telse:\n\t\tif s[:ptr] == s[ptr:ptr+ptr] and not done:\n\t\t\tnews = s[:ptr] + news\n\t\t\tptr -= sl\n\t\t\tsl += sl\n\t\t\tdone = True\n\t\telse:\n\t\t\tnews = s[ptr] + news\n\t\t\tsl += 1\n\t\t\tptr -= 1\n\tans += 1\n\nos(ans+1)\n"}, {"source_code": "n = int(input())\ns = input()\nchanged = False\noperations = 0\nnew_s = ''\nfor i in range(n):\n if len(new_s) == n:\n break\n new_s += s[i]\n operations += 1\n if i < n // 2 and not changed:\n if new_s == s[i+1:2*i+2]:\n new_s += s[i+1:2*i+2]\n operations += 1\n changed = True\nprint(operations)\n "}, {"source_code": "n=input();txt=raw_input()\nfor i in xrange(n/2,0,-1):\n if txt[:i]*(n/i)==txt[:-(n%i)]:\n break\nprint i+(n/i-1)+(n%i)\n"}, {"source_code": "def solve(s):\n\tres = s[0]\n\tans = 0\n\tdoubles = []\n\tfor i in range(len(s) / 2 + 1):\n\t\tif s[:i] * 2 == s[:i*2]:\n\t\t\tdoubles.append(s[:i])\n\twhile True:\n\t\tif len(res) >= len(s):\n\t\t\tbreak\n\t\t#print(res)\n\t\tif res + res == s[:(len(res) * 2)]:\n\t\t\tans += 1\n\t\t\t#doubles.append(res)\n\t\t\tres *= 2\n\t\telse:\n\t\t\tans += 1\n\t\t\tres += s[len(res)]\n\t#print(doubles)\n\tif len(doubles) > 0:\n\t\tans = len(max(doubles, key=len)) + (len(s) - (len(max(doubles, key=len)) * 2))\n\treturn res, ans + 1\n\nn = int(raw_input().strip())\ns = raw_input().strip()\nprint(solve(s)[-1])"}, {"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\n\nn = int(ti())\ns = ti()\n\nnews = \"\" + s[0]\nans = 1\nif n == 1:\n\tos(ans)\n\texit()\nif n == 2:\n\tos(2)\n\texit()\n\nsl = 1\nptr1 = 0\nptr2 = 1\nwhile ptr2 != n:\n\tif s[ptr1] != s[ptr2]:\n\t\tnews += s[ptr2]\n\t\tptr2 += 1\n\t\tsl += 1\n\telse:\n\t\tif ptr2+sl < n+1 and news == s[ptr2:ptr2+sl]:\n\t\t\tnews += news\n\t\t\tptr2 += sl\n\t\t\tsl += sl\n\t\telse:\n\t\t\tnews += s[ptr2]\n\t\t\tptr2 += 1\n\t\t\tsl += 1\n\tans += 1\n\nos(ans)\n\n"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nmoves = 0\nwhile(i=i and i>0):\n\t\tfor j in range(i):\n\t\t\tif(s[j] != s[i+j]):\n\t\t\t\tc = 0\n\telse:\n\t\tc = 0\n\tif(c == 0):\n\t\tmoves += 1\n\t\ti+=1\n\telse:\n\t\tmoves += 1\n\t\ti+=i\nprint(moves)\n"}, {"source_code": "#!/bin/env python\n# -*- encoding: UTF-8 -*-\n\ndef mp():\n return map(int,str(raw_input()).split())\n\nn = mp()\ns = str(raw_input())\n\ndef find(s, res):\n if s in res:\n return res[s]\n ans = 10000000\n for i in range(len(s) - 1):\n l = s[0: i+1]\n r = s[i+1:]\n lw = find(l, res)\n rw = find(r, res)\n cur = lw + rw \n if l == r:\n cur = lw + 1\n ans = min(ans, cur)\n if len(s) == 1:\n ans = 1\n res[s] = ans\n #print s, ans, res\n return ans\n\nres = {}\nans = find(s, res)\nprint ans\n"}, {"source_code": "x = int(input())\ny = input()\n\ndef operations(x):\n if x == 0:\n return 0\n if x % 2 == 0:\n part = int(x/2)\n if y[0:part] == y[part:2*part]:\n return part\n else:\n return 1 + operations(x-1)\n else:\n return 1 + operations(x-1)\n\nprint(operations(x))"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nbest = n\nfor l in range(1, (n + 1) / 2):\n if s[:l] == s[l:2*l]:\n best = min(best, l + 1 + n - 2 * l)\n\nprint best\n"}, {"source_code": "n = int(input())\ns = input()\nans = 0\nwhile s:\n if len(s) % 2 == 1:\n ans += 1\n s = s[:len(s) - 1]\n else:\n if s[:len(s) // 2] == s[len(s) // 2 + 1:]:\n ans += 1\n s = s[:len(s) // 2]\n else:\n ans += 1\n s = s[:len(s) - 1]\nprint(ans)"}, {"source_code": "n = int(input())\nlst = list(input())\nlst1 = []\nlst2 = []\ns=0\nfor i in range(n):\n if lst[i] not in lst1:\n lst1.append(lst[i])\n elif lst[i] not in lst2:\n lst2.append(lst[i])\nif lst1==lst2:\n s+=len(lst1)+1\n s+=n-len(lst1)*2\nelse:\n s+=n\nprint(s)\n"}, {"source_code": "n = int(input())\ns = input()\nchanged = False\noperations = 0\nnew_s = ''\nfor i in range(n):\n if len(new_s) == n:\n break\n new_s += s[i]\n operations += 1\n if i < n // 2 and not changed:\n if new_s == s[i+1:2*i+2]:\n new_s += s[i+1:2*i+2]\n operations += 1\n changed = True\nprint(operations)\n "}, {"source_code": "def check(sstring):\n\tfor i in range(len(sstring)//2+1):\n\t\t# print(string[i])\n\t\tif sstring[i]!=sstring[(len(sstring)//2)+i]:\n\t\t\treturn False\n\treturn True\n\ndef main():\n\tn = int(input())\n\tstring = str(input())\n\tmx = -1\n\tfor i in range(2,len(string),2):\n\t\tt = string[:i+1]\n\t\tif check(t):\n\t\t\tmx = max(mx,i//2)\n\tif mx==-1:\n\t\tprint(len(string))\n\telse:\n\n\t\tprint(len(string)-mx+1)\n\n\nmain()"}, {"source_code": "import math as m\n\nl = int(input())\ns = input()\n\n#print(l/2)\n\ni=m.trunc(l/2)\nt = 0\nwhile i > 1:\n #print(s[0:i] + \"\\t\" + s[i:2*i])\n if s[0:i] == s[i+1:2*i+1]:\n t = i;\n #print(\"!\" + str(t))\n break;\n i -= 1\n\n#print(t)\nprint(l-t)"}, {"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\n\nn = int(ti())\ns = ti()\n\nif n == 1:\n\tos(1)\n\texit()\nif n == 2:\n\tos(2)\n\texit()\n\nnews = \"\" + s[n-1]\nsl = 1\nptr = n-2\nans = 1\nwhile ptr != 0:\n\tif s[ptr] != s[0]:\n\t\tnews = s[ptr] + news\n\t\tsl += 1\n\t\tptr -= 1\n\telse:\n\t\tif s[:ptr] == s[ptr:ptr+ptr]:\n\t\t\tnews = s[:ptr] + news\n\t\t\tptr -= sl\n\t\t\tsl += sl\n\t\telse:\n\t\t\tnews = s[ptr] + news\n\t\t\tsl += 1\n\t\t\tptr -= 1\n\tans += 1\n\nos(ans+1)\n"}, {"source_code": "def fun(str):\n global count\n p = int(len(str)/2)\n if(len(str)<=3):\n count = count +len(str)\n elif(str[0:p] == str[p:]):\n count = count+1\n str = str[0:p]\n if(len(str)%2 != 0):\n count = count +1\n str = str[:-1]\n fun(str)\n else:\n count += 2\n str = str[:-2]\n fun(str)\n \n \nn = int(input())\nstr = input()\ncount = 0\nif(len(str)%2 == 0):\n fun(str)\n print(count)\nelse:\n count = count+1;\n str = str[:-1]\n fun(str)\n print(count)\n"}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nbest = n\nfor l in range(1, (n + 1) / 2):\n if s[:l] == s[l:2*l]:\n best = l + 1 + n - 2 * l\n\nprint best\n"}, {"source_code": "number=int(input())\nstring=input()\nstr=string\nindex = number\nstr_o = 0\nwhile index > 0:\n\tif index % 2 == 1:\n\t\tstr_o += 1\n\t\tstr = str[:-1]\n\t\tindex -= 1\n\telif str[0:index // 2] == str[index // 2: index]:\n\t\tstr_o += 1\n\t\tstr = str[0:index // 2]\n\t\tindex = index // 2\n\telse:\n\t\tstr_o += 1\n\t\tstr = str[:-1]\n\t\tindex -= 1\n\n\nprint(str_o)\t\n"}, {"source_code": "n = int(input())\nstr = input()\nmax1 = 0\nfor i in range(n):\n count = 0\n t = 0\n val = -1\n j = i +1\n while(j < n):\n \n max1 = max(max1,count)\n if(str[i + t] == str[j] and i+t != val):\n if(count == 0):\n val = j\n count = count + 1\n \n t = t + 1 \n j += 1\n \n else:\n if(count == 0):\n j +=1\n val = -1\n count = 0\n t = 0 \n#print(max1)\nif(max1 > 0):\n max1 = max1 - 1\nprint(n-max1)"}, {"source_code": "n=int(input())\ns=input()\nans=-1\nfor i in range(0,n//2+1):\n for j in range(i+1,n):\n if(s.count(s[i:j])>=2):\n ans=max(ans,j-i)\nif(ans==-1):\n print(n)\nelse:\n print(n-ans+1)"}, {"source_code": "n=int(input())\nch=input()\ns=0\ni=0\nwhile i=0:\n s+=1+a-i\n i+=a+j-i\n break\n elif j==n:\n s+=n-i\n i=n\n \nprint(s)\n \n"}, {"source_code": "a = int(input())\nb = input()\nx = 0\nfor i in range(1, int(a/2)+1):\n if b[:i] == b[i:i+i]:\n x = i\nprint(a - x)\n"}, {"source_code": "n=int(input())\nch=input()\ns=0\ni=0\nwhile i=0:\n s+=1+a-i\n i=j\n break\n elif j==n:\n s+=n-i\n i=n\n \nprint(s)\n \n"}, {"source_code": "def solve(i):\n if len(word) == i:\n return 0\n\n a = 10**9\n if i*2 <= len(word) and word[:i] == word[i:i*2]:\n a = solve(i*2)\n return 1+min(a, solve(i+1))\n\ninput()\nword = input()\nprint (1+solve(1))\n"}, {"source_code": "a = int(input())\nb = input()\nx = 0\nfor i in range(1, int((a)/2)+1):\n if b[:i] == b[i:i+i]:\n x = i\nprint(a - x)\n"}, {"source_code": "x=int(input())\ny=input()\ndef gamd(st,x,z):\n if x>1:\n if x%2==0:\n if st[0:int(x/2)]==st[int(x/2) : ]:\n print(int(x/2)+1+z)\n else:\n gamd(st[0:x-2],x-2,z+2)\n else:\n st=st[:x-1]\n \n if st[0:int(x/2)]==st[int(x/2) : ]:\n \n print(int(x/2)+1+z+1)\n else:\n gamd(st[0:x-1],x-1,z+1)\n \n \n \n else:\n print(z)\n \n \ngamd(y,x,0) \n \n "}, {"source_code": "def solution(count, s):\n dup = 0\n for i in range(0, count, 2):\n if s[:i/2] == s[i/2:i]:\n dup = i/2\n if dup == 0:\n return count\n return count - dup + 1\n\nif __name__ == '__main__':\n c = int(raw_input())\n s = raw_input()\n print(solution(c, s))"}, {"source_code": "while True:\n\ttry:\n\t\tdef solution(n, s):\n\t\t\ti = 0\n\t\t\tans = n\n\t\t\twhile i <= n//2:\n\t\t\t\ti += 1;k = i;j = 0\n\t\t\t\tfrq = 0\n\t\t\t\twhile k < n and j < k and j< i:\n\t\t\t\t\tif s[j] != s[k]:\n\t\t\t\t\t\tj += 1\n\t\t\t\t\t\tfrq = 0\n\t\t\t\t\t\tcontinue\n\t\t\t\t\telif j == i-1 and s[j] == s[k]:\n\t\t\t\t\t\tfrq += 1\n\t\t\t\t\t\tfrq += n - (2*frq) \n\t\t\t\t\t\tans = min(ans, frq +1)\n\t\t\t\t\telse:\n\t\t\t\t\t\tfrq += 1\n\t\t\t\t\tk += 1\n\t\t\t\t\tj += 1\n\t\t\tprint(ans)\n\t\t\t\t\t\t\t\t\t\t\n\t\tdef read():\n\t\t\tn = int(input())\n\t\t\ts = input()\n\t\t\tsolution(n, s)\n\t\tif __name__ == \"__main__\":\n\t\t\tread()\n\texcept EOFError:\n\t\tbreak"}, {"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\n\nn = int(ti())\ns = ti()\n\nnews = \"\" + s[0]\nans = 1\nif n == 1:\n\tos(ans)\n\texit()\nif n == 2:\n\tos(2)\n\texit()\n\nsl = 1\nptr1 = 0\nptr2 = 1\nwhile ptr2 != n:\n\tif s[ptr1] != s[ptr2]:\n\t\tnews += s[ptr2]\n\t\tptr2 += 1\n\t\tsl += 1\n\telse:\n\t\tif ptr2+sl < n+1 and news == s[ptr2:ptr2+sl]:\n\t\t\tnews += news\n\t\t\tptr2 += sl\n\t\t\tsl += sl\n\t\telse:\n\t\t\tnews += s[ptr2]\n\t\t\tptr2 += 1\n\t\t\tsl += 1\n\tans += 1\n\nos(ans)\n\n"}, {"source_code": "n = int(input())\ns = input()\nz = [0] * n\nfor i in range(n):\n j = 0\n cnt = 0\n if i < (n + 1) // 2:\n while i + j < n and j < i:\n if s[i + j] == s[j]:\n cnt += 1\n else:\n break\n j += 1\n z[i] = cnt\nif max(z) != 0:\n print(n - max(z) + 1)\nelse:\n print(n)"}, {"source_code": "import math as m\n\nl = int(input())\ns = input()\n\ni=m.trunc(l/2)+1\nt = 0\nwhile i > 0:\n if s[0:i] == s[i:2*i]:\n t = i;\n break;\n i -= 1\n\nprint(l-t)"}, {"source_code": "x = int(input())\ny = input()\n\ndef operations(x):\n if x == 0:\n return 0\n if x % 2 == 0:\n part = int(x/2)\n if y[0:part] == y[part:2*part]:\n return part\n else:\n return 1 + operations(x-1)\n else:\n return 1 + operations(x-1)\n\nprint(operations(x))"}, {"source_code": "n = int(input())\ns = input()\nfor k in range(n // 2, 0, -1):\n for i in range(n):\n if i + k + k > n:\n break\n if s[i:i + k] == s[i + k: i + k + k]:\n print(n - k + 1)\n exit(0)\nprint(n)\n"}, {"source_code": "n = int(input())\ns = input()\nz = [0] * n\nfor i in range(n):\n j = 0\n cnt = 0\n if i <= (n + 1) // 2:\n while i + j < n and j < i:\n if s[i + j] == s[j]:\n cnt += 1\n j += 1\n z[i] = cnt\nif max(z) != 0:\n print(n - max(z) + 1)\nelse:\n print(n)"}, {"source_code": "n = int(input())\nstr = input()\nmax1 = 0\nfor i in range(n):\n count = 0\n t = 0\n for j in range(i+1,n):\n \n max1 = max(max1,count)\n if(str[i + t] == str[j]):\n count = count + 1\n t = t + 1 \n \n else:\n \n count = 0\n t = 0 \nif(max1 > 0):\n max1 = max1 -1\nprint(n-max1)"}, {"source_code": "n = int(input())\ns = input()\nnum = 0\nwhile n > 0:\n if n % 2 != 0:\n n -= 1\n s = s[:-1]\n num += 1\n else:\n if s[:n // 2] == s[n // 2:]:\n num += 1\n s = s[:n // 2]\n n //= 2\n else:\n n -= 1\n s = s[:-1]\n num += 1\n\nprint(num)"}, {"source_code": "n = int(input())\nlst = list(input())\nlst1 = []\nlst2 = []\ns=0\nfor i in range(n):\n if lst[i] not in lst1:\n lst1.append(lst[i])\n elif lst[i] not in lst2:\n lst2.append(lst[i])\nif lst1==lst2 and len(lst1)==1 and len(lst2)==1:\n if n%2==0:\n s+=int(n/2+1)\n else:\n s+=int((n-1)/2+2)\nelif lst1==lst2:\n s+=len(lst1)+1\n s+=n-len(lst1)*2\nelse:\n s+=n\nprint(s)\n"}, {"source_code": "n = int(input().strip())\ns = list(input().strip())\ncount = 0\nwhile n > 0:\n if n % 2 == 1:\n count += 1\n n -= 1\n else:\n\n i = n // 2\n first = s[:i]\n second = s[i:n]\n copy = True\n for j in range(i):\n if first[j] != second[j]:\n copy = False\n n -= 2\n count += 2\n break\n if copy:\n count += 1\n n //= 2\nprint(count)\n"}, {"source_code": "n = int(input())\nlst = (input())\nlst1 = []\nlst2 = []\nlst3 = []\ns=0\n#Counter(lst).most_common()\n#print(lst)\nfor i in range(n):\n if lst[i] not in lst1:\n lst1.append(lst[i])\n elif lst[i] not in lst2:\n lst2.append(lst[i])\n else:\n lst3.append(lst[i])\n#print(lst1,lst2,lst3)\nif (lst3)==(lst1+lst2):\n s+=len(lst3)+1\nelif lst1==lst2 and len(lst1)==1 and len(lst2)==1:\n if n%2==0:\n s+=int(n/2+1)\n elif n%2==1:\n s+=int((n-1)/2+2)\nelif lst1==lst2:\n s+=len(lst1)+1+len(lst3)\nelif len(lst3)==0 and len(lst2)!=0:\n s+=len(lst1)+1\nelse:\n s+=len(lst1)\n \nprint(s)\n"}, {"source_code": "n = int(input())\ns = input()\nfor k in range(n // 2, 0, -1):\n for i in range(n):\n if i + k + k > n:\n break\n if s[i:i + k] == s[i + k: i + k + k]:\n print(n - k + 1)\n exit(0)\nprint(n)\n"}, {"source_code": "index = int(input())\nstr = input()\nstr_o = 0\nwhile index > 0:\n\tif index % 2 == 1:\n\t\tindex -= 1\n\telif str[0:index // 2] == str[index // 2: index]:\n\t\tindex = index // 2\n\telse:\n\t\tindex -= 1\n\tstr_o += 1\nprint(str_o)\t\n"}, {"source_code": "import math as m\n\nl = int(input())\ns = input()\n\ni=m.trunc(l/2)+1\nt = 0\nwhile i > 0:\n if s[0:i] == s[i+1:2*i+1]:\n t = i;\n break;\n i -= 1\n\nprint(l-t)"}, {"source_code": "n = int(input())\ns = input()\n\nm = ''\nfor j in range(0, len(s) // 2):\n for i in range(1, len(s) // 2 + 1):\n if s[j:i] in s[i:] and len(s[j:i]) > len(m):\n m = s[j:i]\n \nif len(m) == 0:\n print(len(s))\nelse:\n print(len(s) - len(m) + 1)\n"}, {"source_code": "n=input()\ns=raw_input()\nans=n\nfor i in range(n):\n if 2*i+1<=n:\n if s[:i+1]==s[i+1:2*i+1]:\n ans=n+1-i\nprint ans"}, {"source_code": "n = int(input())\ns = input()\nans = 0\nwhile s:\n if len(s) % 2 == 1:\n ans += 1\n s = s[:len(s) - 1]\n else:\n if s[:len(s) // 2] == s[len(s) // 2 + 1:]:\n ans += 1\n s = s[:len(s) // 2]\n else:\n ans += 1\n s = s[:len(s) - 1]\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nz = [0] * n\nfor i in range(n):\n if i < (n + 1) // 2:\n if s[:i] == s[i:2 * i]:\n z[i] = i\nif max(z) != 0:\n print(n - max(z) + 1)\nelse:\n print(n)"}, {"source_code": "n=int(input())\nch=input()\ns=0\nd=0\nf=n\nc=''\nM=0\nwhile d len(m):\n m = s[j:i]\n \nif len(m) == 0:\n print(len(s))\nelse:\n print(len(s) - len(m) + 1)\n"}, {"source_code": "n = int(input())\ns = input()\ncnt = -1\nfor i in range(n//2*2, 1, -2):\n if s[:i//2]==s[i//2:i]: cnt += i//2\nprint(n-max(0, cnt))\n"}, {"source_code": "n=int(input())\na=input()\nb=''\nb+=a[0]\ni=j=1\n#print(2*i)\nwhile i in range(n):\n try:\n if b[0:i]==a[i:(i+i)]:\n j+=1\n i+=(len(b))\n b+=(b[0:i])\n #print(b)\n else:\n b+=a[i]\n j+=1\n i+=1\n #print(b,i)\n except:\n b+=a[i]\n i+=1\n j+=1\nprint(j)\n "}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\n# from math import *\nfrom collections import *\n# from fractions import *\n# from 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=1000000007\nEPS=1e-6\ndef Ceil(a,b): return a//b+int(a%b>0)\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=Int()\ns=input()\n\nans=0\n\nwhile(len(s)):\n ans+=1\n if(len(s)%2): s=s[:-1]\n else:\n k=len(s)//2\n if(s[:k]==s[k:]): s=s[:k]\n else: s=s[:-1]\n\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\n\n\n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\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 re\nprint input()-len(re.match(r'(.*)\\1',raw_input()).group(1))+1"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nc = 0\nmn = n\nwhile i < n:\n if i % 2 == 0 and s[0: i // 2] == s[i//2:i]:\n c = i // 2\n i += 1\n mn = min(mn, n if c == 0 else n - c + 1)\nprint(mn)"}, {"source_code": "n = input()\nn = int(n)\nstr = input()\n\nindicator = 0\n\nMax = 0\n\nfor i in range(n - 1):\n temp = i + 1\n count = 0\n while temp < n and str[temp - i - 1] == str[temp] and temp - i - 1 < i + 1:\n count += 1\n temp += 1\n Max = max(Max, count)\n\n\nif Max > 0:\n print(n - Max + 1)\nelse:\n print(n)\n"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nc = 0\nwhile i < n:\n if i % 2 == 0 and s[0: i // 2] == s[i//2:i]:\n c = i // 2\n i+= 1\nprint(n if c == 0 else n - c + 1)"}, {"source_code": "n = int(input())\ns = input()\ni = 0\nmoves = 0\nwhile(i=i and i>0):\n\t\tfor j in range(i):\n\t\t\tif(s[j] != s[i+j]):\n\t\t\t\tc = 0\n\telse:\n\t\tc = 0\n\tif(c == 0):\n\t\tmoves += 1\n\t\ti+=1\n\telse:\n\t\tmoves += 1\n\t\ti+=i\nprint(moves)\n"}, {"source_code": "x=int(input())\ny=input()\ndef gamd(st,x,z):\n if x>1:\n if x%2==0:\n if st[0:int(x/2)]==st[int(x/2) : ]:\n print(int(x/2)+1+z)\n else:\n gamd(st[0:x-2],x-2,z+2)\n else:\n st=st[:x-1]\n \n if st[0:int(x/2)]==st[int(x/2) : ]:\n \n print(int(x/2)+1+z+1)\n else:\n gamd(st[0:x-1],x-1,z+1)\n \n \n \n else:\n print(z)\n \n \ngamd(y,x,0) \n \n "}, {"source_code": "n = int(input())\nlst = list(input())\nlst1 = []\nlst2 = []\ns=0\nfor i in range(n):\n if lst[i] not in lst1:\n lst1.append(lst[i])\n elif lst[i] not in lst2:\n lst2.append(lst[i])\nif lst1==lst2:\n s+=len(lst1)+1\n s+=n-len(lst1)*2\nelse:\n s+=n\nprint(s)\n"}, {"source_code": "n=int(input())\ns=input()\nans=-1\nfor i in range(1,n):\n if(2*i>n):\n break\n if(s[:i]+s[:i]==s[:2*i]):\n ans=max(ans,n+1-i)\nif(ans==-1):\n print(n)\nelse:\n print(ans)"}, {"source_code": "a = int(input())\nb = input()\nx = 0\nfor i in range(1, int(a/2)):\n if (b[0:i] == b[i:i+i]):\n x = i\nprint(a - x)\n"}, {"source_code": "n=int(input())\ns=input()\nk=0\n\nfor i in reversed(range(1,int((n+1)/2))):\n\tif s[0:i]==s[i:2*i]:\n\t\tk=i\n\t\tbreak\n\nprint(min(n-k+1,n))"}, {"source_code": "n = int(input())\nlst = list(input())\nlst1 = []\nlst2 = []\ns=0\nfor i in range(n):\n if lst[i] not in lst1:\n lst1.append(lst[i])\n elif lst[i] not in lst2:\n lst2.append(lst[i])\nif lst1==lst2 and len(lst1)==1 and len(lst2)==1:\n if n%2==0:\n s+=int(n/2+1)\n else:\n s+=int((n-1)/2+2)\nelif lst1==lst2:\n s+=len(lst1)+1\n s+=n-len(lst1)*2\nelse:\n s+=n\nprint(s)\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\n\nn = int(ti())\ns = ti()\n\nnews = \"\" + s[0]\nans = 1\nif n == 1:\n\tos(ans)\n\texit()\nif n == 2:\n\tos(2)\n\texit()\n\nsl = 1\nptr1 = 0\nptr2 = 1\nwhile ptr2 != n:\n\tif s[ptr1] != s[ptr2]:\n\t\tnews += s[ptr2]\n\t\tptr2 += 1\n\t\tsl += 1\n\telse:\n\t\tif ptr2+sl < n+1 and news == s[ptr2:ptr2+sl]:\n\t\t\tnews += news\n\t\t\tptr2 += sl\n\t\t\tsl += sl\n\t\telse:\n\t\t\tnews += s[ptr2]\n\t\t\tptr2 += 1\n\t\t\tsl += 1\n\tans += 1\n\nos(ans)\n\n"}, {"source_code": "def iden(s1, s2):\n\t# print(s1, s2)\n\tif len(s2) < len(s1):\n\t\treturn False\n\tfor i in range(len(s1)):\n\t\t# print(i, \"----\")\n\t\tif not s1[i] == s2[i]:\n\t\t\t# print(\"HEEEYY\")\n\t\t\treturn False\n\treturn True\n\nn = input(\"\")\ns = input(\"\")\n\ncur = s[0]\ni = 0\nres = 1\nwhile cur != s:\n\ti = len(cur)\n\tres += 1\n\tif iden(cur + cur, s):\n\t\t# print(cur + cur)\n\t\tcur = cur + cur\n\telse:\n\t\tcur += s[i]\n\t# print(cur)\n\nprint(res)"}, {"source_code": "length = input()\ntext = input()\nlen_dec = 0\nconseq_str = str()\nmatch_length = 0\ntry:\n idx = 0\n length = 1\n while idx < len(text):\n print (length)\n conseq_str = text[:idx+1]\n print (conseq_str)\n poss_match = text[idx+1:idx+length+1]\n print (poss_match)\n if (conseq_str == poss_match):\n match_length = length\n match_found = True\n length += 1\n idx += 1\n total_moves = match_length + 1 + (len(text)-2*match_length)\n print (total_moves)\nexcept:\n print (0)"}, {"source_code": "numOfChar = int(input())\nstringOfMov = input()\nendpoint = int(numOfChar / 2)\nmaxlength = 0\nif numOfChar>1:\n while (endpoint > 1):\n if stringOfMov[0:endpoint] == stringOfMov[endpoint:endpoint*2]:\n maxlength = endpoint\n endpoint = 0\n else:\n endpoint -= 1\n maxlength = endpoint\n if numOfChar == 2: print(numOfChar - maxlength)\n else: print(numOfChar - maxlength + 1)\nelse:\n print(1)"}, {"source_code": "n = int(input())\ns = input()\nx = 1\nfor i in range(n//2, 0, -1):\n if (s[:i] == s[i:i*2]): x = i\nprint(n-(x-1))"}, {"source_code": "n = int(input())\ntypestr = input()\nslen = len(typestr)\n\nans = slen\n\nfor i in range(slen):\n for k in range(slen):\n if i+k-1 < slen or i+k+k-1=0:\n s+=1+a-i\n i+=a+j-i\n break\n elif j==n:\n s+=n-i\n i=n\n \n print(s)\n \n"}, {"source_code": "x = int(input())\ny = input()\n\ndef operations(x):\n if x == 0:\n return 0\n if x % 2 == 0:\n part = int(x/2)\n if y[0:part] == y[part:2*part]:\n return part\n else:\n return 1 + operations(x-1)\n else:\n return 1 + operations(x-1)\n\nprint(operations(x))"}, {"source_code": "s = input()\n\nmn = len(s)\n\nfor i in range(1, len(s) // 2 + 1):\n if s[:i] == s[i:2 * i]:\n mn = len(s) - i + 1\n\nprint(mn)"}, {"source_code": "while True:\n\ttry:\n\t\tdef solution(n, s):\n\t\t\ti = 0\n\t\t\tans = n\n\t\t\twhile i <= n//2:\n\t\t\t\ti += 1;k = i;j = 0\n\t\t\t\tfrq = 0\n\t\t\t\twhile k < n and j < k and j< i:\n\t\t\t\t\tif s[j] != s[k]:\n\t\t\t\t\t\tj += 1\n\t\t\t\t\t\tfrq = 0\n\t\t\t\t\t\tcontinue\n\t\t\t\t\telif j == i-1 and s[j] == s[k]:\n\t\t\t\t\t\tfrq += 1\n\t\t\t\t\t\tfrq += n - (2*frq) \n\t\t\t\t\t\tans = min(ans, frq +1)\n\t\t\t\t\telse:\n\t\t\t\t\t\tfrq += 1\n\t\t\t\t\tk += 1\n\t\t\t\t\tj += 1\n\t\t\tprint(ans)\n\t\t\t\t\t\t\t\t\t\t\n\t\tdef read():\n\t\t\tn = int(input())\n\t\t\ts = input()\n\t\t\tsolution(n, s)\n\t\tif __name__ == \"__main__\":\n\t\t\tread()\n\texcept EOFError:\n\t\tbreak"}, {"source_code": "n=int(input())\na=input()\nct=0\nh=1\np=0\nt=0\nm=int(n/2)\nwhile 1:\n if len(set(list(a[0:2*m])))==1 or n==1:\n if n==1:\n ct=1\n break\n ct=n-m+1\n break\n if a[0:m]==a[m:2*m]:\n if h==1:\n p=2*m\n h*=2\n t+=1\n if int(m)%2!=0:\n ct=n-p+int(p/h)+t\n break\n m=int(m/2)\n continue\n if m==1:\n ct=n-p+int(p/h)+t\n break\n m-=1\nprint(ct)"}, {"source_code": "def solve(s):\n\tres = s[0]\n\tans = 0\n\twhile True:\n\t\tif len(res) >= len(s):\n\t\t\tbreak\n\t\tif res + res == s[:len(res) * 2]:\n\t\t\tres *= 2\n\t\telse:\n\t\t\tres += s[len(res)]\n\t\tans += 1\n\treturn res, ans + 1\n\nn = int(raw_input().strip())\ns = raw_input().strip()\nprint(solve(s)[-1])"}, {"source_code": "n=input();txt=raw_input()\nfor i in xrange(n/2,0,-1):\n if txt[:i]*(n/i)==txt[:-(n%i)]:\n break\nprint i+(n/i-1)+(n%i)\n"}, {"source_code": "def fun(str):\n global count\n p = int(len(str)/2)\n if(len(str)<=3):\n count = count +len(str)\n elif(str[0:p] == str[p:]):\n count = count+1\n str = str[0:p]\n if(len(str)%2 != 0):\n count = count +1\n str = str[:-1]\n fun(str)\n else:\n count += 2\n str = str[:-2]\n fun(str)\n \n \nn = int(input())\nstr = input()\ncount = 0\nif(len(str)%2 == 0):\n fun(str)\n print(count)\nelse:\n count = count+1;\n str = str[:-1]\n fun(str)\n print(count)\n"}, {"source_code": "import math as m\n\nl = int(input())\ns = input()\n\ni=m.trunc(l/2)+1\nt = 0\nwhile i > 0:\n if s[0:i] == s[i:2*i]:\n t = i;\n break;\n i -= 1\n\nprint(l-t)"}, {"source_code": "n = int(input())\nstr = input()\nmax1 = 0\nfor i in range(n):\n count = 0\n t = 0\n val = -1\n j = i +1\n while(j < n):\n \n max1 = max(max1,count)\n if(str[i + t] == str[j] and i+t != val):\n if(count == 0):\n val = j\n count = count + 1\n \n t = t + 1 \n j += 1\n \n else:\n if(count == 0):\n j +=1\n val = -1\n count = 0\n t = 0 \n#print(max1)\nif(max1 > 0):\n max1 = max1 - 1\nprint(n-max1)"}, {"source_code": "n = int(input())\ns = list(input())\nmax_repeat = 0\nfor i in range(1,n//2+1):\n for j in range(0,n-2*i+1):\n left = s[j:j+i]\n right = s[j+i:j+i+i]\n # print(left,right)\n if(left==right):\n max_repeat = i\nif(max_repeat!=0):\n print(1+n-max_repeat)\nelse:\n print(n)"}, {"source_code": "n=int(raw_input())\nst=raw_input()\na=0\nfor i in xrange(1,n):\n\tp=st[:i]\n\tif st.startswith(2*p):\n\t\ta=n-i+1\nprint a"}, {"source_code": "n=int(input())\ns=input()\ni=1\ncurr=s[0]\nmatch=''\n\nwhile i 0:\n if i % 2 == 0 and strng[:i / 2] == strng[i / 2:i]:\n print strng[:i / 2]\n print strng[i / 2:i]\n num_operations += 1\n num_operations += i / 2\n break\n num_operations += 1\n i -= 1\nprint num_operations\n"}, {"source_code": "while True:\n\ttry:\n\t\tdef solution(n, s):\n\t\t\ti = 0\n\t\t\tans = n\n\t\t\tt = n\n\t\t\tif t%2 == 0:\n\t\t\t\tt -= 1\n\t\t\twhile i <= t//2:\n\t\t\t\ti += 1;k = i;j = 0\n\t\t\t\tfrq = 0\n\t\t\t\twhile k < n and j < k and j< i:\n\t\t\t\t\tif s[j] != s[k]:\n\t\t\t\t\t\tj += 1\n\t\t\t\t\t\tfrq = 0\n\t\t\t\t\t\tcontinue\n\t\t\t\t\telif j == i-1 and s[j] == s[k]:\n\t\t\t\t\t\tfrq += 1\n\t\t\t\t\t\tfrq += n - (2*frq) \n\t\t\t\t\t\tans = min(ans, frq +1)\n\t\t\t\t\telse:\n\t\t\t\t\t\tfrq += 1\n\t\t\t\t\tk += 1\n\t\t\t\t\tj += 1\n\t\t\tprint(ans)\n\t\t\t\t\t\t\t\t\t\t\n\t\tdef read():\n\t\t\tn = int(input())\n\t\t\ts = input()\n\t\t\tsolution(n, s)\n\t\tif __name__ == \"__main__\":\n\t\t\tread()\n\texcept EOFError:\n\t\tbreak"}, {"source_code": "n=int(input())\nch=input()\ns=0\nd=0\nf=n\nc=''\nM=0\nif ch.count(ch[0])==n and n>1:\n if n%2==0:\n print((n//2)+1)\n else:\n print((n//2)+2)\nelse: \n while dhighest:\n\t\t\thighest = j - i\n\t\tj+=1\n\t\n\ti +=1\n\nif highest == 0:\n\tprint(l)\nelse:\n\tprint(l-highest+1)\n\t"}, {"source_code": "n = int(input())\ns = str(input())\nl = len(s)\nprev = '';\nss = ''\nmax_len=0\nfor i in s:\n ss+=i\n print(ss+\" \"+s[len(ss):len(ss)+len(ss)])\n if ss == s[len(ss):len(ss)+len(ss)]: \n max_len = len(ss)\nif max_len>0:\n print(l-max_len+1)\nelse:\n print(l)\n"}, {"source_code": "def iden(s1, s2):\n\t# print(s1, s2)\n\tif len(s2) < len(s1):\n\t\treturn False\n\tfor i in range(len(s1)):\n\t\t# print(i, \"----\")\n\t\tif not s1[i] == s2[i]:\n\t\t\t# print(\"HEEEYY\")\n\t\t\treturn False\n\treturn True\n\nn = input(\"\")\ns = input(\"\")\n\ncur = s[0]\ni = 0\nres = 0\nwhile cur != s:\n\ti = len(cur)\n\tif iden(cur + cur, s):\n\t\t# print(cur + cur)\n\t\tres = len(cur)-1\n\t\tcur = cur + cur\n\telse:\n\t\tcur += s[i]\n\t# print(cur)\n\nprint(len(s)-res)"}, {"source_code": "n = int(input())\ns = input()\nx = 1\nfor i in range(n//2, 0, -1):\n if (s[:i] == s[i:i*2]): \n x = i\n break\nprint(n-(x-1), x)"}, {"source_code": "n=int(input())\na=input()\ni=1\nj=0\n#print(2*i)\nwhile i in range(n):\n if a[0:i]==a[i:2*i]:\n if j<(i):\n j=i\n i+=i\n else:\n i+=1\n \nprint([n-j,n-j+1][j>0])\n "}, {"source_code": "n = int(raw_input())\ns = raw_input()\n\nbest = n\nfor l in range(1, (n + 1) / 2):\n if s[:l] == s[l:2*l]:\n best = l + 1 + n - 2 * l\n\nprint best\n"}], "src_uid": "ed8725e4717c82fa7cfa56178057bca3"} {"nl": {"description": "Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.Let next(x) be the minimum lucky number which is larger than or equals x. Petya is interested what is the value of the expression next(l)\u2009+\u2009next(l\u2009+\u20091)\u2009+\u2009...\u2009+\u2009next(r\u2009-\u20091)\u2009+\u2009next(r). Help him solve this problem.", "input_spec": "The single line contains two integers l and r (1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u2009109) \u2014 the left and right interval limits.", "output_spec": "In the single line print the only number \u2014 the sum next(l)\u2009+\u2009next(l\u2009+\u20091)\u2009+\u2009...\u2009+\u2009next(r\u2009-\u20091)\u2009+\u2009next(r). Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.", "sample_inputs": ["2 7", "7 7"], "sample_outputs": ["33", "7"], "notes": "NoteIn the first sample: next(2)\u2009+\u2009next(3)\u2009+\u2009next(4)\u2009+\u2009next(5)\u2009+\u2009next(6)\u2009+\u2009next(7)\u2009=\u20094\u2009+\u20094\u2009+\u20094\u2009+\u20097\u2009+\u20097\u2009+\u20097\u2009=\u200933In the second sample: next(7)\u2009=\u20097"}, "positive_code": [{"source_code": "S = sorted\nM = lambda : map(int,input().split())\na = []\nl,r = M()\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\n\nF(0)\na=S(a)\ndef luckysum(p):\n\ts = 0\n\tfor i in range(1, len(a)):\n\t\ts+= a[i]*(min(a[i],p)-min(a[i-1],p))\n\t\tif not (min(a[i],p)-min(a[i-1],p)):\n\t\t\tbreak\n\treturn s\n\nprint(luckysum(r)-luckysum(l-1))\n\n "}, {"source_code": "from itertools import product\n\nl, r = map(int, input().split())\nlucky_nums = sorted(int(''.join(p)) for r in range(1, 11) for p in product(\"47\", repeat=r))\nans = 0\n\nfor lucky_num in lucky_nums:\n if l <= lucky_num <= r:\n ans += (lucky_num - l + 1) * lucky_num\n l = lucky_num + 1\n elif l <= lucky_num and r < lucky_num:\n ans += (r - l + 1) * lucky_num\n break\n\nprint(ans)"}, {"source_code": "l,r = map(int,input().split())\narr =[4,7]\nsumi=0\nk=0\nind =1\nfor i in range(0,15):\n\tfor j in range(k,k+2**(i+1)):\n\t\tarr.append(arr[j]*10+4)\n\t\tarr.append(arr[j]*10+7)\n\tk=2**(i+1)\nwhile(l<=r):\n\tc=-1\n\tif (l<=4):\n\t\tc=4\n\telse:\n\t\tfor i in range(ind,len(arr)):\n\t\t\tif (l<=arr[i] and l>arr[i-1]):\n\t\t\t\tc=arr[i]\n\t\t\t\tind = i\n\t\t\t\tbreak;\n\tif r<=c:\n\t\tsumi=sumi+((r-l+1)*c)\n\t\tl=r+1\n\telse:\n\t\tsumi=sumi+((c-l+1)*c)\n\t\tl=c+1\nprint(sumi)\n\n\t\t\t"}, {"source_code": "lucky_n = []\n\ns = 0\n\ndef add_4_7(s):\n s_4 = int(str(s) + '4')\n s_7 = int(str(s) + '7')\n if s_4 < 10000000000:\n lucky_n.append(s_4)\n add_4_7(s_4)\n if s_7 < 10000000000:\n lucky_n.append(s_7)\n add_4_7(s_7)\n\nadd_4_7(s)\nlucky_n.sort()\n\na, b = list(map(int, input().split()))\n\nprox = 0\nultimo = a\n\nfor i in range(len(lucky_n)):\n l = lucky_n[i]\n if l >= a:\n prox = i\n break\n\nprimeiro = lucky_n[prox]\nsoma = 0\n\nwhile True:\n if lucky_n[prox] <= b:\n soma += (lucky_n[prox] - ultimo) * lucky_n[prox]\n ultimo = lucky_n[prox]\n prox += 1\n else:\n soma += (b - ultimo) * lucky_n[prox]\n break\n\nprint(soma+primeiro)\n"}, {"source_code": "s=(raw_input()).split()\nl=int(s[0])\nr=int(s[1])\nnb=[4,7,44,47,74,77]\ni=2\nj=6\nwhile (nb[j-1]<=r):\n j=len(nb)\n for k in (nb[i:]):\n nb=nb+[int((k*10)+4),int((k*10)+7)]\n i=j\nfor i in range(len(nb)):\n if (nb[i]>=l):\n k=nb[i] \n break\nif (r<=k):\n sol=k*(r-l+1)\nelse:\n sol=(k-l+1)*nb[i]\n for j in nb[i+1:]:\n if (j444444444:\n break\n d.append(x*10+4)\n d.append(x*10+7)\nl,r=l()\nans=0\ni=0\nwhile l<=r:\n if d[i]d[i]:\n ans+=d[i]*(d[i]-l+1)\n l=d[i]+1\n else :\n ans+=d[i]*(r-l+1)\n break\nprint ans"}, {"source_code": "\ndef nex(t):\n t = ['0']+list(str(t))\n ret = ['0']\n for i in range(1,len(t)):\n if t[i]=='4' or t[i]=='7':\n ret.append(t[i])\n continue\n if t[i]>'7':\n if ret[-1]=='0':\n ret[-1]='4'\n elif ret[-1]=='4':\n ret[-1]='7'\n else:\n j=len(ret)-1\n while ret[j]=='7':\n ret[j]='4'\n j-=1\n ret[j] = '4' if ret[j]=='0' else '7'\n ret.append('4')\n elif t[i]<'4':\n ret.append('4')\n else:\n ret.append('7')\n ret.append('4'*(len(t)-1-i))\n break\n return int(''.join(ret))\n\n\nl,r = map(int, input().split())\n\nm=nex(l)\nans = (int(m)-l+1)*int(m)\n\nwhile m arr[y-1]:\n sm += arr[y]*(r-arr[y-1])\n print(sm)"}, {"source_code": "import sys\nimport math\n\nnumbers = map(int, sys.stdin.readline().split())\n\nstart = numbers[0]\nend = numbers[1]\n\nlucky = [4, 7]\n\nfor i in range(1, 10):\n for j in range(len(lucky)):\n lucky.append(int(str(lucky[j]) + \"4\"))\n lucky.append(int(str(lucky[j]) + \"7\"))\n \ndef nextfun(i):\n tst = 0\n while lucky[tst] < i:\n tst += 1\n\n return lucky[tst]\n \nanswer = 0\n\nwhile(start <= end):\n next = nextfun(start)\n \n if next < end:\n answer += next * (next - start + 1)\n else:\n answer += next * (end - start + 1)\n start = next + 1\n \nprint answer"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)"}, {"source_code": "from bisect import bisect_left as bl\nl,r = map(int,raw_input().split())\na = []\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na.sort()\np = bl(a,l)\nans = a[p]\nwhile l= l:\n t = i \n break\nfor i in range(len(x)):\n if x[i] >= r:\n e = i\n break\nres = sum[e] - sum[t] - x[e] * (x[e]-r) + (x[t]-l+1) * x[t]\nprint(res)\n\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)\n"}, {"source_code": "def gen(cur):\n if cur <= 10 ** 11:\n a = gen(cur * 10 + 4)\n a.extend(gen(cur* 10 + 7))\n a.append(cur)\n return a\n else:\n return []\n \nleft, right = map(int, input().split())\nans = 0\nprev = 0\nleft -= 1\nfor x in sorted(gen(0))[1:]:\n if x < left:\n continue\n if x > right:\n ans += x * (right - max(left, prev))\n break\n ans += x * (x - max(prev, left))\n prev = x\nprint(ans)\n"}, {"source_code": "li=set()\ndef addi(n):\n if n>10**10+1:\n return\n li.add(n)\n addi(n*10+4)\n addi(n*10+7)\naddi(4)\naddi(7)\nli=list(set(li))\nli.sort()\nl,r=map(int,input().split())\nans=0\nfor x in li:\n if x>=r:\n ans+=x*(r-l+1)\n break\n elif x>=l:\n ans+=x*(x-l+1)\n l=x+1\nprint(ans)"}, {"source_code": "import re\n\ndef ones(n):\n return int('1' * n or 0)\n\ntrivial = re.compile(\"^[47]*$\")\nsmaller = re.compile(\"^[0-3]\")\nmedium = re.compile(\"^[5-6]\")\nbigger = re.compile(\"^[8-9]\")\nsophisticated = re.compile(\"^(?P[47]*)(?P.*$)\")\n\ndef nxt(n):\n # print n\n s = str(n)\n\n if re.search(trivial, s):\n return n\n elif re.search(smaller, s):\n return ones(len(s)) * 4\n elif re.search(medium, s):\n return ones(len(s)) * 7 - ones(len(s) - 1) * 3\n elif re.search(bigger, s):\n return ones(len(s) + 1) * 4\n elif re.search(sophisticated, s):\n m = re.match(sophisticated, s)\n p = m.group('prefix').strip()\n s = m.group('suffix').strip()\n # print p, s\n fst = int(p)\n snd = nxt(int(s))\n # print fst, snd\n if snd > (10 ** (len(s))):\n # print \"trick\"\n snd %= (10 ** (len(s)))\n fst = nxt(fst + 1)\n\n fst *= (10 ** (len(s)))\n return fst + snd\n\ndef solve(a, b):\n res = 0\n \n while True:\n c = nxt(a)\n # print a, b,\n # print c,\n # print res\n if c < b:\n res += (c - a + 1) * c\n a = c + 1\n else:\n res += (b - a + 1) * c \n return res\n\n[a, b] = map(int, raw_input().split())\nprint solve(a, b)\n"}, {"source_code": "li=set()\ndef addi(n):\n if n>10**10+1:\n return\n li.add(n)\n addi(n*10+4)\n addi(n*10+7)\naddi(4)\naddi(7)\nli=list(set(li))\nli.sort()\nl,r=map(int,input().split())\nans=0\nfor x in li:\n if x>=r:\n ans+=x*(r-l+1)\n break\n elif x>=l:\n ans+=x*(x-l+1)\n l=x+1\nprint(ans)"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n a.append(x)\n if x>r*10:\n return\n F(10*x+4)\n F(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n z=0\n for i in range(1,len(a)):\n z+=a[i]*(min(a[i],x)-min(a[i-1],x))\n return z\nprint G(r)-G(l-1)"}, {"source_code": "a, b = [], ['']\nfor _ in range(10):\n c = ['4' + s for s in b] + ['7' + s for s in b]\n a += c\n b = c\na = sorted(map(int, a))\nl, r = map(int, raw_input().split())\nres = 0\nfor i in range(len(a)+1):\n if l <= a[i]:\n rr = min(a[i], r)\n res += a[i] * (rr - l + 1)\n l = a[i] + 1\n if a[i] >= r: break\nprint res\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\nlucky=[]\n\n\nfor i in range(1,11):\n for j in range(2**i): \n key=bin(j).replace(\"0b\",\"\")\n key='0'*(i-len(key))+key\n \n num=0\n for k in key:\n if(k=='0'): num=num*10+4\n else: num=num*10+7\n lucky.append(num)\n\n# print(lucky)\n\nl,r=value()\n\nind1=bisect_left(lucky,l)\nind2=bisect_right(lucky,r)\n\nlast=l\nans=0\n\nfor i in range(ind1,ind2):\n ans+=lucky[i]*(lucky[i]-last+1)\n last=lucky[i]+1\nif(last<=r):\n ans+=lucky[ind2]*(r-last+1)\n\n\nprint(ans)\n\n\n\n\n\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)"}, {"source_code": "from itertools import product\nx = ['4','7']\nlucky_nums = [4,7]\nfor i in range(2,11):\n for p in product(x,repeat=i):\n lucky_nums.append(int(\"\".join(p)))\nn = len(lucky_nums)\nl,r = map(int,input().split())\nli = -1\nri = -1\nfor i in range(n):\n if li==-1 and lucky_nums[i] >= l:\n li = i\n if lucky_nums[i] <= r:\n ri = i\nans = (lucky_nums[li]-l+1)*lucky_nums[li]\nprev = lucky_nums[li]\nfor i in range(li+1,ri+1):\n ans += (lucky_nums[i]-prev)*lucky_nums[i]\n prev = lucky_nums[i]\nans += (r-prev)*lucky_nums[ri+1]\nprint(ans)"}, {"source_code": "def next(n):\n st = str(n)\n lth = len(st)\n x = st.count('4')\n y = st.count('7')\n if x+y == lth:\n return n\n else:\n if n > int('7'*lth):\n lth += 1\n num = 0\n i = 0\n while(num < n):\n num = bin(i)[2:].zfill(lth)\n num = num.replace('0', '4')\n num = num.replace('1', '7')\n num = int(num)\n i += 1\n if((num < n) and (i > int('7'*lth))):\n i = 0\n lth += 1\n return num\n\n\nstart, end = map(int, input().split())\nsum = 0\ni = start\nwhile(i <= end):\n x = next(i)\n num = min(x, end)\n sum += ((num-i+1)*x)\n i = x+1\nprint(sum)\n"}, {"source_code": "l,r = [int(x) for x in input().strip().split()]\n \ndef next(n,k):\n\ts = n\n\tn = int(n)\n\t\n\tif int(\"4\"*k)>=n:\n\t\treturn \"4\"*k\n\telif int(\"7\"*k) r:\n\t\tbreak\n\tn = len(num)\n\tf = 0\n\tlst = list(num)\n\tfor i in range(n):\n\t\tif lst[n-i-1] == '4':\n\t\t\tf = 1\n\t\t\ti = n-i-1\n\t\t\tbreak\n\tif f == 1:\n\t\tlst[i] = '7'\n\telse:\n\t\tlst.insert(0, '4')\n\t\ti = 0\n\t\tn += 1\n\ti += 1\n\twhile i < n:\n\t\tlst[i] = '4'\n\t\ti += 1\n\tnum = ''.join(lst)\n\nn = len(lucky)\nprev = l\nresult = 0\nfor i in range(n):\n\tn = lucky[i]\n\tif n < prev:\n\t\tcontinue\n\tif r < n:\n\t\tn = r\n\tresult += (n - prev + 1)*lucky[i]\n\tprev = n+1\n\tif prev > r:\n\t\tbreak\nprint(result)"}, {"source_code": "def ns(l,ans):\n for i in ans:\n if(i>=l):\n return i\ndef prog(s,ans):\n if(s<(10**10)):\n ans+=[s]\n prog((s*10)+4,ans)\n prog((s*10)+7,ans)\nans = []\nprog(0,ans)\nans.sort()\ndel ans[0]\nl,r=map(int,raw_input().split())\nres = 0\nwhile(l<=r):\n x=ns(l,ans)\n y = min(r,x)\n res += (y-l+1)*x\n l = y+1\nprint res\n"}, {"source_code": "l, r = map(int, raw_input().split())\n\ndef check(k):\n s = str(k)\n for i in xrange(len(s)):\n if s[i] != '4' and s[i] != '7':\n return 0\n return 1\n\ndef close(a):\n if (check(a)):\n return a\n else:\n ans = ''\n temp = 0\n last = -1\n s = str(a)\n for i in xrange(len(s)):\n if (temp == 0):\n if (s[i] == '4' or s[i] == '7'):\n ans = ans + s[i]\n if s[i] == '4':\n last = i\n else:\n if (s[i] < '4'):\n ans = ans + '4'\n last = i\n elif (s[i] < '7'):\n ans = ans + '7'\n else:\n if last == -1:\n ans = ''\n for j in xrange(len(s) + 1):\n ans = ans + '4'\n return int(ans)\n else:\n ans = ans[:last] + '7'\n while (len(ans) < len(s)):\n ans = ans + '4'\n return int(ans)\n else:\n ans = ans + '4'\n return int(ans)\n\nh = [4]\nfor i in xrange(1022):\n h.append(close(h[len(h) - 1] + 1))\nindl = 0\nfor i in xrange(len(h)):\n if h[i] >= l:\n indl = i\n break\nfor i in xrange(len(h)):\n if h[i] >= r:\n indr = i\n break\n\nans = 0\nprev = l\nfor i in xrange(indl, indr + 1):\n if (i == indr):\n ans += (r - prev + 1) * h[i]\n break\n ans += (h[i] - prev + 1) * h[i]\n prev = h[i] + 1\n\nprint ans"}, {"source_code": "from itertools import product\nfrom bisect import bisect_left as bsearch\n\nMAXDIG = 11\n\ndef main():\n global MAXDIG\n (l, r) = map(int, input().split(' '))\n luckies = []\n for i in range(MAXDIG):\n lst = product([7, 4], repeat = i)\n for x in lst:\n s = ''.join(map(str, x))\n if len(s) != 0:\n num = int(s)\n luckies.append(num)\n luckies = sorted(luckies)\n i = bsearch(luckies, l)\n j = bsearch(luckies, r)\n s = 0\n n = r - l + 1\n left = n\n while luckies[i] <= luckies[j]:\n dif = min(luckies[i] - l + 1, left)\n left -= dif\n l += dif\n s += (dif * luckies[i])\n i += 1\n return s\n\nprint(main())\n\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)"}, {"source_code": "A=[\"0\",\"0\",\"4\",\"7\"]\ncnt=0\nfor i in range(4,1030):\n if cnt%2==0:\n A.append(A[i//2]+\"4\")\n else:\n A.append(A[i//2]+\"7\")\n cnt+=1\nA=[int(x) for x in A[::]]\nl,r=map(int,input().split())\nleft_index=1\nright_index=1\nwhile left_index<1030:\n if A[left_index]= r:\n ans += (r - l + 1) * arr[i]\n break\n elif arr[i] >= l:\n ans += (arr[i] - l + 1) * arr[i]\n l = arr[i] + 1\nprint(ans)"}, {"source_code": "digits = [4, 7]\nnums = [4, 7]\n\nLIM = 10**10\nwhile nums[-1] < LIM:\n nums = list(set(nums + [num*10 + digit for digit in digits for num in nums]))\n\nnums = [num for num in sorted(nums) if num <= LIM]\n# print len(nums)\n# print nums[:10], nums[-10:]\n\ndef c(l, r):\n ans = 0\n x = 0\n while l <= r:\n while nums[x] < l:\n x += 1\n num = nums[x]\n count = min(r, num) - l + 1\n ans += count * num\n # print num, ans, count, l, l + count\n l += count\n return ans\n\na, b = [int(_) for _ in raw_input().split(\" \")]\nprint c(a, b)\n"}, {"source_code": "l,r=map(int,input().split())\ns=set()\ndef f(st,res):\n\tif st>10:s.add(res)\n\telse:\n\t\tif res==0:f(st+1,res)\n\t\tfor i in 4,7:f(st+1,res*10+i)\nf(0,0)\ns=sorted(s)\na=1\nb=1\nq=0\nif l in s:\n\tq-=l\n\tl-=1\nwhile l>=s[a]:a+=1\nwhile r>=s[b+1]:b+=1\nif a>=b:\n\tq+=(min(r,s[a])-l+1)*s[a]\n\tif r>s[a]:q+=s[a+1]*(r-s[a])\nelse:\n\tif ls[b]:q+=s[b+1]*(r-s[b])\n\tfor i in range(a,b):q+=s[i+1]*(s[i+1]-s[i])\nprint(q)"}, {"source_code": "def getLuckyNumber(digit , arr):\n temp = list()\n for i in arr:\n temp.append('4' + i)\n temp.append('7' + i)\n return temp\n\ndef digitCount(number):\n digits = 1\n while True:\n digits += 1\n number = number // 10\n if number == 0:\n break\n return getLuckyList(digits)\n\ndef getLuckyList(digitCount):\n temp = ['']\n arr = list()\n for i in range(1 , digitCount + 1):\n temp = getLuckyNumber(i , temp)\n luck = list(map(int , temp))\n arr += luck\n arr.sort()\n return arr\n\ndef nextLuckyNumber(x , arr):\n for j in arr:\n if j >= x:\n return j\n\nif __name__ == \"__main__\":\n n = list(map(int , input().rstrip().split()))\n l = n[0]\n r = n[1]\n arr = digitCount(r)\n total = 0\n prev = 0\n i = l\n while i <= r:\n if i > prev:\n prev = nextLuckyNumber(i , arr)\n #print (prev , i)\n total += prev\n i += 1\n else:\n if prev <= r:\n total += (prev - i + 1) * prev\n else:\n total += (r - i + 1) * prev\n i = prev + 1\n print (total)\n \n"}, {"source_code": "cache = {}\ndef luck(n):\n try:\n return cache[n]\n except KeyError:\n pass\n if n == 1:\n return [4, 7]\n a = luck(n - 1)\n b = map(lambda x: x * 10 + 4, a)\n c = map(lambda x: x + 3, b)\n cache[n] = b + c\n return cache[n]\n\n\na, b = map(int, raw_input().split())\nlucks = sorted(reduce(lambda x, y: x + y, [luck(i) for i in range(1,11)]))\nlucks = [0] + lucks\nsumm = 0\nfor i in range(len(lucks) - 1):\n x, y = lucks[i], lucks[i + 1]\n if a <= x <= b:\n if a <= y <= b:\n summ += y * (y - x)\n if y > b:\n summ += y * (b - x)\n if x < a:\n if a <= y <= b:\n summ += y * (y - a + 1)\n if y > b:\n summ += y * (b - a + 1)\n\nprint summ\n"}, {"source_code": "import sys\n\n#sys.stdin = open('in.txt', 'r')\n\nl, r = map(int, raw_input().split())\n\ndef dfs(n, m, lucky):\n\tif m:\n\t\tlucky.append(m)\n\tif n > 0:\n\t\tdfs(n - 1, m * 10 + 4, lucky)\n\t\tdfs(n - 1, m * 10 + 7, lucky)\n\nlucky = []\ndfs(10, 0, lucky)\nlucky.sort()\n\nst, ed = 0, 0\nfor i in xrange(0, len(lucky) - 1):\n\tif l > lucky[i] and l <= lucky[i + 1]:\n\t\tst = i + 1\n\t\tbreak\nfor i in xrange(0, len(lucky) - 1):\n\tif r > lucky[i] and r <= lucky[i + 1]:\n\t\ted = i + 1\n\t\tbreak\n\ncur, sum = l, 0\nfor i in xrange(st, ed + 1):\n\tsum += (min(lucky[i], r) - cur + 1) * lucky[i]\n\tcur = lucky[i] + 1\n\nprint sum\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n \n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)"}, {"source_code": "def gray(n):\n if n == 1:\n return [4, 7]\n l1 = gray(n-1)\n l2 = reversed(l1)\n l1 = [int(str(a) + '4') for a in l1]\n l2 = [int(str(a) + '7') for a in l2]\n return l1+l2\n\nl, r = map(int, input().split())\na = len(str(l)); b = len(str(r))\nz = gray(a)\nfor i in range(a+1, b+2):\n z += gray(i)\nl1 = [a for a in z if a >= l and a <= r]\nl2 = [a for a in z if a > r]\nl1.sort()\nif len(l1) == 0 or l1[-1] != r:\n l1 += [l2[0]]\nu = l\nans = 0\nif r < l1[-1]:\n for i in range(len(l1)-1):\n ans += (l1[i]-u)*l1[i]\n u = l1[i]\n ans += (r-u)*l1[-1] + l1[0]\nelse:\n for i in range(len(l1)):\n ans += (l1[i]-u)*l1[i]\n u = l1[i]\n ans += l1[0]\nprint(ans)\n"}, {"source_code": "def isLucky(num):\n\ts = str(num)\n\tfor i in s:\n\t\tif i != '4' and i != '7':\n\t\t\treturn False\n\treturn True\n\ndef getLucky(d):\n\tif d == 1:\n\t\tfor i in [4, 7]:\n\t\t\tyield str(i)\n\telse:\n\t\tl = [i for i in getLucky(d-1)]\n\t\tfor j in l:\n\t\t\tyield '4'+j\n\t\tfor j in l:\n\t\t\tyield '7'+j\n\ndef nextLucky(n):\n\tfor l in luckies:\n\t\tl = int(l)\n\t\tif l >= n:\n\t\t\treturn l\n\nluckies = []\nfor d in range(1,11):\n\tfor i in getLucky(d):\n\t\tluckies.append(i)\n\nl, r = map(int, raw_input().split())\nlast_pos = l-1\nans = 0\nfor lucky in luckies:\n\tn = int(lucky)\n\tif n >= l:\n\t\tif n < r:\n\t\t\tpos = n\n\t\t\tans += (pos - last_pos) * n\n\t\telse:\n\t\t\tpos = r\n\t\t\tans += (pos - last_pos) * n\n\t\t\tbreak\n\t\tlast_pos = pos\nprint ans\n\n# for i in xrange(l, r+1):\n# \tans -= nextLucky(i)\n# print ans\n\n\n\n\n"}, {"source_code": "\ndef binary(n):\n\tif (n==0):\t\n\t\tyield ''\n\telse:\n\t\tfor i in binary(n-1):\n\t\t\tyield i + '4'\n\t\t\tyield i + '7'\n\n\n\ndef gen():\n\tfor i in range(1,11):\n\t\tfor code in binary(i):\n\t\t\tyield int(code)\n\n\n\ndef main():\n\tstart, end = [int(i) for i in raw_input().split()]\n\tnums = sorted(list(gen()) + [start])\n\ti = nums.index(start)\n\tcur = start\n\ts = 0\n\twhile(cur<=end):\n\t\tif nums[i+1]<=end:\n\t\t\ts+= (nums[i+1]-cur+1)*nums[i+1]\n\t\telse:\n\t\t\ts+= (end-cur+1)*nums[i+1]\n\t\tcur = nums[i+1]+1\n\t\ti+=1\n\tprint s\n\n\n\nmain()"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)\n"}, {"source_code": "lucky = []\nLIMIT=10000000000\ninp = raw_input().split()\nl = int(inp[0])\nr = int(inp[1])\n\ndef gen(n):\n\tif n>LIMIT:\n\t\tpass\n\telse:\n\t\tlucky.append(n)\n\t\tgen(n*10+4)\n\t\tgen(n*10+7)\n\t\t\ngen(0)\n\n\nlucky.sort()\n\nans = 0\nfor i in range(len(lucky)-1):\n\tlo = max(l,lucky[i]+1)\n\thi = min(r,lucky[i+1])\n\t\n\tif hi>=lo:\n\t\tans = ans + (hi-lo+1)*lucky[i+1]\nprint(ans)\n\t\t\n"}, {"source_code": "\ndef nex(t):\n t = ['0']+list(str(t))\n ret = ['0']\n for i in range(1,len(t)):\n if t[i]=='4' or t[i]=='7':\n ret.append(t[i])\n continue\n if t[i]>'7':\n if ret[-1]=='0':\n ret[-1]='4'\n elif ret[-1]=='4':\n ret[-1]='7'\n else:\n j=len(ret)-1\n while ret[j]=='7':\n ret[j]='4'\n j-=1\n ret[j] = '4' if ret[j]=='0' else '7'\n ret.append('4')\n elif t[i]<'4':\n ret.append('4')\n else:\n ret.append('7')\n ret.append('4'*(len(t)-1-i))\n break\n return int(''.join(ret))\n\n\nl,r = map(int, input().split())\n\nm=nex(l)\nans = (int(m)-l+1)*int(m)\n\nwhile m= m):\n break\n\nfor j in range(len(x)):\n if (x[j] >= n):\n break\n\nif i == j:\n print((n-m+1)*x[i])\n quit()\n \nsumx = (x[i] - m + 1) * x[i]\nsumx += (n - x[j-1]) * x[j]\n\nfor i in range(i+1, j):\n sumx += (x[i]-x[i-1])*x[i]\n\nprint(sumx)\n"}, {"source_code": "from itertools import product\nlucky = []\n\nl,r = input().split()\nlw, rw = len(l), len(r)\nl, r = int(l), int(r)\n\nfor i in range(lw,rw+1):\n lucky+=[int(''.join([str(y) for y in x])) for x in list(product([4,7],repeat=i))]\nlucky+=[int('4'*(rw+1))]\nans=0\nil = [0,0]\nfor i in range(len(lucky)):\n if lucky[i]arr[i-1]):\n\t\t\t\tc=arr[i]\n\t\t\t\tind = i\n\t\t\t\tbreak;\n\tif r<=c:\n\t\tsumi=sumi+((r-l+1)*c)\n\t\tl=r+1\n\telse:\n\t\tsumi=sumi+((c-l+1)*c)\n\t\tl=c+1\nprint(sumi)\n\n\t\t\t"}, {"source_code": "l=lambda:map(int,raw_input().split())\nd=[4,7]\nfor x in d:\n if x>444444444:\n break\n d.append(x*10+4)\n d.append(x*10+7)\nl,r=l()\nans=0\ni=0\nwhile l<=r:\n if d[i]d[i]:\n ans+=d[i]*(d[i]-l+1)\n l=d[i]+1\n else :\n ans+=d[i]*(r-l+1)\n break\nprint ans"}, {"source_code": "l,r = [int(x) for x in input().strip().split()]\n\ndef next(n,k):\n\ts = n\n\tn = int(n)\n\t\n\tif int(\"4\"*k)>=n:\n\t\treturn \"4\"*k\n\telif int(\"7\"*k)10**10+1:\n return\n li.add(n)\n addi(n*10+4)\n addi(n*10+7)\naddi(4)\naddi(7)\nli = list(set(li))\nli.sort()\nl,r = map(int,input().split())\nans = 0\nfor x in li:\n if x >= r:\n ans += x*(r-l+1)\n break\n elif x >= l:\n ans += x*(x-l+1)\n l = x+1\nprint(ans)"}, {"source_code": "from itertools import product\nlucky = []\n\nl,r = input().split()\nlw, rw = len(l), len(r)\nl, r = int(l), int(r)\n\nfor i in range(lw,rw+1):\n lucky+=[int(''.join([str(y) for y in x])) for x in list(product([4,7],repeat=i))]\nlucky+=[int('4'*(rw+1))]\nans=0\nil = [0,0]\nfor i in range(len(lucky)):\n if lucky[i]10*r:\n\t\treturn\n\tfoo(10*n+4)\n\tfoo(10*n+7)\n\treturn\n\nfoo(0)\na.sort()\n\ndef get_sum(m):\n\ts=0\n\tfor i in range(1,len(a)):\n\t\ts+=a[i]*(min(a[i],m)-min(a[i-1],m))\n\treturn s\n\nprint(get_sum(r)-get_sum(l-1))\n\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n a.append(x)\n if x>r*10:\n return\n F(10*x+4)\n F(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n \n z=0\n for i in range(1,len(a)):\n z+=a[i]*(min(a[i],x)-min(a[i-1],x))\n return z\nprint G(r)-G(l-1)"}, {"source_code": "luckies = []\n\ndef generate(s, n):\n if n != 0:\n a = 10 * s + 4\n b = 10 * s + 7\n luckies.append(a)\n luckies.append(b)\n generate(a, n - 1)\n generate(b, n - 1)\n \ngenerate(0, 10)\nluckies.sort()\n\nl, r = map(int, input().split())\n\na = 0; b = len(luckies) - 1\nL = 0\nwhile a <= b:\n m = (a+b) // 2\n if luckies[m] >= l:\n L = m\n b = m - 1\n else:\n a = m + 1\n \na = 0; b = len(luckies) - 1\nR = 0\nwhile a <= b:\n m = (a+b) // 2\n if luckies[m] >= r:\n R = m\n b = m - 1\n else:\n a = m + 1\n \na = 0; b = len(luckies) - 1\nS = 0\nwhile a <= b:\n m = (a+b) // 2\n if luckies[m] <= r:\n S = m\n a = m + 1\n else:\n b = m - 1\n\n\nif S < L:\n res = (r - l + 1) * luckies[R]\nelse:\n res = luckies[L] * (luckies[L] - l + 1) + luckies[R] * (r - luckies[S])\n for i in range(L, S):\n res += luckies[i+1] * (luckies[i+1] - luckies[i])\nprint(res)\n\n\"\"\"\ndef lucky(n):\n for digit in str(n):\n if digit not in '47':\n return False\n return True\n\nres = 0\nnext_lucky = r\nwhile not lucky(next_lucky):\n next_lucky += 1\nfor n in range(r, l-1, -1):\n if lucky(n):\n next_lucky = n\n res += next_lucky\n \nprint(res)\n\"\"\"\n \n \n \n "}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)\n"}, {"source_code": "from bisect import bisect_left\nl, r = map(int, input().split())\nt, p, u, v = [4, 7], [4, 7], 4, 7\nwhile t[-1] < r:\n u, v = u * 10, v * 10\n t = [u + i for i in t] + [v + i for i in t]\n p.extend(t)\np = p[bisect_left(p, l): bisect_left(p, r) + 1]\nprint((p[0] - l + 1) * p[0] + (r - p[-1]) * p[-1] + sum((p[i] - p[i - 1]) * p[i] for i in range(1, len(p))))"}, {"source_code": "l, r = [int(x) for x in input().split()]\nimport itertools\narr = []\nfor i in range(1, 11):\n arr.extend(list(map(int, map(''.join, itertools.product('47', repeat=i)))))\nans = 0\nfor i in range(len(arr)):\n if arr[i] >= r:\n ans += (r - l + 1) * arr[i]\n break\n elif arr[i] >= l:\n ans += (arr[i] - l + 1) * arr[i]\n l = arr[i] + 1\nprint(ans)"}, {"source_code": "a, b = [], ['']\nfor _ in range(10):\n c = ['4' + s for s in b] + ['7' + s for s in b]\n a += c\n b = c\na = sorted(map(int, a))\nl, r = map(int, raw_input().split())\nres = 0\nfor i in range(len(a)+1):\n if l <= a[i]:\n rr = min(a[i], r)\n res += a[i] * (rr - l + 1)\n l = a[i] + 1\n if a[i] >= r: break\nprint res\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n\tz=0\n\tfor i in range(1,len(a)):\n\t\tz+=a[i]*(min(a[i],x)-min(a[i-1],x))\n\treturn z\nprint G(r)-G(l-1)\n"}, {"source_code": "\ndef nex(t):\n t = ['0']+list(str(t))\n ret = ['0']\n for i in range(1,len(t)):\n if t[i]=='4' or t[i]=='7':\n ret.append(t[i])\n continue\n if t[i]>'7':\n if ret[-1]=='0':\n ret[-1]='4'\n elif ret[-1]=='4':\n ret[-1]='7'\n else:\n j=len(ret)-1\n while ret[j]=='7':\n ret[j]='4'\n j-=1\n ret[j] = '4' if ret[j]=='0' else '7'\n ret.append('4')\n elif t[i]<'4':\n ret.append('4')\n else:\n ret.append('7')\n ret.append('4'*(len(t)-1-i))\n break\n return int(''.join(ret))\n\n\nl,r = map(int, input().split())\n\nm=nex(l)\nans = (int(m)-l+1)*int(m)\n\nwhile m10*r:\n\t\treturn\n\tfoo(10*n+4)\n\tfoo(10*n+7)\n\treturn\n\nfoo(0)\na.sort()\n\ndef get_sum(m):\n\ts=0\n\tfor i in range(1,len(a)):\n\t\ts+=a[i]*(min(a[i],m)-min(a[i-1],m))\n\treturn s\n\nprint(get_sum(r)-get_sum(l-1))\n\n"}, {"source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom itertools import combinations_with_replacement\nfrom collections import defaultdict\nfrom bisect import bisect_right\nfrom bisect import bisect_left\n \ndef L():\n return list(map(int, stdin.readline().split()))\n \ndef In():\n return map(int, stdin.readline().split())\n \ndef I():\n return int(stdin.readline())\n \nP = 1000000007\narr = [0, 4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777, 4444, 4447, 4474, 4477, 4744, 4747, 4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777, 44444, 44447, 44474, 44477, 44744, 44747, 44774, 44777, 47444, 47447, 47474, 47477, 47744, 47747, 47774, 47777, 74444, 74447, 74474, 74477, 74744, 74747, 74774, 74777, 77444, 77447, 77474, 77477, 77744, 77747, 77774, 77777, 444444, 444447, 444474, 444477, 444744, 444747, 444774, 444777, 447444, 447447, 447474, 447477, 447744, 447747, 447774, 447777, 474444, 474447, 474474, 474477, 474744, 474747, 474774, 474777, 477444, 477447, 477474, 477477, 477744, 477747, 477774, 477777, 744444, 744447, 744474, 744477, 744744, 744747, 744774, 744777, 747444, 747447, 747474, 747477, 747744, 747747, 747774, 747777, 774444, 774447, 774474, 774477, 774744, 774747, 774774, 774777, 777444, 777447, 777474, 777477, 777744, 777747, 777774, 777777, 4444444, 4444447, 4444474, 4444477, 4444744, 4444747, 4444774, 4444777, 4447444, 4447447, 4447474, 4447477, 4447744, 4447747, 4447774, 4447777, 4474444, 4474447, 4474474, 4474477, 4474744, 4474747, 4474774, 4474777, 4477444, 4477447, 4477474, 4477477, 4477744, 4477747, 4477774, 4477777, 4744444, 4744447, 4744474, 4744477, 4744744, 4744747, 4744774, 4744777, 4747444, 4747447, 4747474, 4747477, 4747744, 4747747, 4747774, 4747777, 4774444, 4774447, 4774474, 4774477, 4774744, 4774747, 4774774, 4774777, 4777444, 4777447, 4777474, 4777477, 4777744, 4777747, 4777774, 4777777, 7444444, 7444447, 7444474, 7444477, 7444744, 7444747, 7444774, 7444777, 7447444, 7447447, 7447474, 7447477, 7447744, 7447747, 7447774, 7447777, 7474444, 7474447, 7474474, 7474477, 7474744, 7474747, 7474774, 7474777, 7477444, 7477447, 7477474, 7477477, 7477744, 7477747, 7477774, 7477777, 7744444, 7744447, 7744474, 7744477, 7744744, 7744747, 7744774, 7744777, 7747444, 7747447, 7747474, 7747477, 7747744, 7747747, 7747774, 7747777, 7774444, 7774447, 7774474, 7774477, 7774744, 7774747, 7774774, 7774777, 7777444, 7777447, 7777474, 7777477, 7777744, 7777747, 7777774, 7777777, 44444444, 44444447, 44444474, 44444477, 44444744, 44444747, 44444774, 44444777, 44447444, 44447447, 44447474, 44447477, 44447744, 44447747, 44447774, 44447777, 44474444, 44474447, 44474474, 44474477, 44474744, 44474747, 44474774, 44474777, 44477444, 44477447, 44477474, 44477477, 44477744, 44477747, 44477774, 44477777, 44744444, 44744447, 44744474, 44744477, 44744744, 44744747, 44744774, 44744777, 44747444, 44747447, 44747474, 44747477, 44747744, 44747747, 44747774, 44747777, 44774444, 44774447, 44774474, 44774477, 44774744, 44774747, 44774774, 44774777, 44777444, 44777447, 44777474, 44777477, 44777744, 44777747, 44777774, 44777777, 47444444, 47444447, 47444474, 47444477, 47444744, 47444747, 47444774, 47444777, 47447444, 47447447, 47447474, 47447477, 47447744, 47447747, 47447774, 47447777, 47474444, 47474447, 47474474, 47474477, 47474744, 47474747, 47474774, 47474777, 47477444, 47477447, 47477474, 47477477, 47477744, 47477747, 47477774, 47477777, 47744444, 47744447, 47744474, 47744477, 47744744, 47744747, 47744774, 47744777, 47747444, 47747447, 47747474, 47747477, 47747744, 47747747, 47747774, 47747777, 47774444, 47774447, 47774474, 47774477, 47774744, 47774747, 47774774, 47774777, 47777444, 47777447, 47777474, 47777477, 47777744, 47777747, 47777774, 47777777, 74444444, 74444447, 74444474, 74444477, 74444744, 74444747, 74444774, 74444777, 74447444, 74447447, 74447474, 74447477, 74447744, 74447747, 74447774, 74447777, 74474444, 74474447, 74474474, 74474477, 74474744, 74474747, 74474774, 74474777, 74477444, 74477447, 74477474, 74477477, 74477744, 74477747, 74477774, 74477777, 74744444, 74744447, 74744474, 74744477, 74744744, 74744747, 74744774, 74744777, 74747444, 74747447, 74747474, 74747477, 74747744, 74747747, 74747774, 74747777, 74774444, 74774447, 74774474, 74774477, 74774744, 74774747, 74774774, 74774777, 74777444, 74777447, 74777474, 74777477, 74777744, 74777747, 74777774, 74777777, 77444444, 77444447, 77444474, 77444477, 77444744, 77444747, 77444774, 77444777, 77447444, 77447447, 77447474, 77447477, 77447744, 77447747, 77447774, 77447777, 77474444, 77474447, 77474474, 77474477, 77474744, 77474747, 77474774, 77474777, 77477444, 77477447, 77477474, 77477477, 77477744, 77477747, 77477774, 77477777, 77744444, 77744447, 77744474, 77744477, 77744744, 77744747, 77744774, 77744777, 77747444, 77747447, 77747474, 77747477, 77747744, 77747747, 77747774, 77747777, 77774444, 77774447, 77774474, 77774477, 77774744, 77774747, 77774774, 77774777, 77777444, 77777447, 77777474, 77777477, 77777744, 77777747, 77777774, 77777777, 444444444, 444444447, 444444474, 444444477, 444444744, 444444747, 444444774, 444444777, 444447444, 444447447, 444447474, 444447477, 444447744, 444447747, 444447774, 444447777, 444474444, 444474447, 444474474, 444474477, 444474744, 444474747, 444474774, 444474777, 444477444, 444477447, 444477474, 444477477, 444477744, 444477747, 444477774, 444477777, 444744444, 444744447, 444744474, 444744477, 444744744, 444744747, 444744774, 444744777, 444747444, 444747447, 444747474, 444747477, 444747744, 444747747, 444747774, 444747777, 444774444, 444774447, 444774474, 444774477, 444774744, 444774747, 444774774, 444774777, 444777444, 444777447, 444777474, 444777477, 444777744, 444777747, 444777774, 444777777, 447444444, 447444447, 447444474, 447444477, 447444744, 447444747, 447444774, 447444777, 447447444, 447447447, 447447474, 447447477, 447447744, 447447747, 447447774, 447447777, 447474444, 447474447, 447474474, 447474477, 447474744, 447474747, 447474774, 447474777, 447477444, 447477447, 447477474, 447477477, 447477744, 447477747, 447477774, 447477777, 447744444, 447744447, 447744474, 447744477, 447744744, 447744747, 447744774, 447744777, 447747444, 447747447, 447747474, 447747477, 447747744, 447747747, 447747774, 447747777, 447774444, 447774447, 447774474, 447774477, 447774744, 447774747, 447774774, 447774777, 447777444, 447777447, 447777474, 447777477, 447777744, 447777747, 447777774, 447777777, 474444444, 474444447, 474444474, 474444477, 474444744, 474444747, 474444774, 474444777, 474447444, 474447447, 474447474, 474447477, 474447744, 474447747, 474447774, 474447777, 474474444, 474474447, 474474474, 474474477, 474474744, 474474747, 474474774, 474474777, 474477444, 474477447, 474477474, 474477477, 474477744, 474477747, 474477774, 474477777, 474744444, 474744447, 474744474, 474744477, 474744744, 474744747, 474744774, 474744777, 474747444, 474747447, 474747474, 474747477, 474747744, 474747747, 474747774, 474747777, 474774444, 474774447, 474774474, 474774477, 474774744, 474774747, 474774774, 474774777, 474777444, 474777447, 474777474, 474777477, 474777744, 474777747, 474777774, 474777777, 477444444, 477444447, 477444474, 477444477, 477444744, 477444747, 477444774, 477444777, 477447444, 477447447, 477447474, 477447477, 477447744, 477447747, 477447774, 477447777, 477474444, 477474447, 477474474, 477474477, 477474744, 477474747, 477474774, 477474777, 477477444, 477477447, 477477474, 477477477, 477477744, 477477747, 477477774, 477477777, 477744444, 477744447, 477744474, 477744477, 477744744, 477744747, 477744774, 477744777, 477747444, 477747447, 477747474, 477747477, 477747744, 477747747, 477747774, 477747777, 477774444, 477774447, 477774474, 477774477, 477774744, 477774747, 477774774, 477774777, 477777444, 477777447, 477777474, 477777477, 477777744, 477777747, 477777774, 477777777, 744444444, 744444447, 744444474, 744444477, 744444744, 744444747, 744444774, 744444777, 744447444, 744447447, 744447474, 744447477, 744447744, 744447747, 744447774, 744447777, 744474444, 744474447, 744474474, 744474477, 744474744, 744474747, 744474774, 744474777, 744477444, 744477447, 744477474, 744477477, 744477744, 744477747, 744477774, 744477777, 744744444, 744744447, 744744474, 744744477, 744744744, 744744747, 744744774, 744744777, 744747444, 744747447, 744747474, 744747477, 744747744, 744747747, 744747774, 744747777, 744774444, 744774447, 744774474, 744774477, 744774744, 744774747, 744774774, 744774777, 744777444, 744777447, 744777474, 744777477, 744777744, 744777747, 744777774, 744777777, 747444444, 747444447, 747444474, 747444477, 747444744, 747444747, 747444774, 747444777, 747447444, 747447447, 747447474, 747447477, 747447744, 747447747, 747447774, 747447777, 747474444, 747474447, 747474474, 747474477, 747474744, 747474747, 747474774, 747474777, 747477444, 747477447, 747477474, 747477477, 747477744, 747477747, 747477774, 747477777, 747744444, 747744447, 747744474, 747744477, 747744744, 747744747, 747744774, 747744777, 747747444, 747747447, 747747474, 747747477, 747747744, 747747747, 747747774, 747747777, 747774444, 747774447, 747774474, 747774477, 747774744, 747774747, 747774774, 747774777, 747777444, 747777447, 747777474, 747777477, 747777744, 747777747, 747777774, 747777777, 774444444, 774444447, 774444474, 774444477, 774444744, 774444747, 774444774, 774444777, 774447444, 774447447, 774447474, 774447477, 774447744, 774447747, 774447774, 774447777, 774474444, 774474447, 774474474, 774474477, 774474744, 774474747, 774474774, 774474777, 774477444, 774477447, 774477474, 774477477, 774477744, 774477747, 774477774, 774477777, 774744444, 774744447, 774744474, 774744477, 774744744, 774744747, 774744774, 774744777, 774747444, 774747447, 774747474, 774747477, 774747744, 774747747, 774747774, 774747777, 774774444, 774774447, 774774474, 774774477, 774774744, 774774747, 774774774, 774774777, 774777444, 774777447, 774777474, 774777477, 774777744, 774777747, 774777774, 774777777, 777444444, 777444447, 777444474, 777444477, 777444744, 777444747, 777444774, 777444777, 777447444, 777447447, 777447474, 777447477, 777447744, 777447747, 777447774, 777447777, 777474444, 777474447, 777474474, 777474477, 777474744, 777474747, 777474774, 777474777, 777477444, 777477447, 777477474, 777477477, 777477744, 777477747, 777477774, 777477777, 777744444, 777744447, 777744474, 777744477, 777744744, 777744747, 777744774, 777744777, 777747444, 777747447, 777747474, 777747477, 777747744, 777747747, 777747774, 777747777, 777774444, 777774447, 777774474, 777774477, 777774744, 777774747, 777774774, 777774777, 777777444, 777777447, 777777474, 777777477, 777777744, 777777747, 777777774, 777777777, 4444444444, 4444444447, 4444444474, 4444444477, 4444444744, 4444444747, 4444444774, 4444444777, 4444447444, 4444447447, 4444447474, 4444447477, 4444447744, 4444447747, 4444447774, 4444447777, 4444474444, 4444474447, 4444474474, 4444474477, 4444474744, 4444474747, 4444474774, 4444474777, 4444477444, 4444477447, 4444477474, 4444477477, 4444477744, 4444477747, 4444477774, 4444477777, 4444744444, 4444744447, 4444744474, 4444744477, 4444744744, 4444744747, 4444744774, 4444744777, 4444747444, 4444747447, 4444747474, 4444747477, 4444747744, 4444747747, 4444747774, 4444747777, 4444774444, 4444774447, 4444774474, 4444774477, 4444774744, 4444774747, 4444774774, 4444774777, 4444777444, 4444777447, 4444777474, 4444777477, 4444777744, 4444777747, 4444777774, 4444777777, 4447444444, 4447444447, 4447444474, 4447444477, 4447444744, 4447444747, 4447444774, 4447444777, 4447447444, 4447447447, 4447447474, 4447447477, 4447447744, 4447447747, 4447447774, 4447447777, 4447474444, 4447474447, 4447474474, 4447474477, 4447474744, 4447474747, 4447474774, 4447474777, 4447477444, 4447477447, 4447477474, 4447477477, 4447477744, 4447477747, 4447477774, 4447477777, 4447744444, 4447744447, 4447744474, 4447744477, 4447744744, 4447744747, 4447744774, 4447744777, 4447747444, 4447747447, 4447747474, 4447747477, 4447747744, 4447747747, 4447747774, 4447747777, 4447774444, 4447774447, 4447774474, 4447774477, 4447774744, 4447774747, 4447774774, 4447774777, 4447777444, 4447777447, 4447777474, 4447777477, 4447777744, 4447777747, 4447777774, 4447777777, 4474444444, 4474444447, 4474444474, 4474444477, 4474444744, 4474444747, 4474444774, 4474444777, 4474447444, 4474447447, 4474447474, 4474447477, 4474447744, 4474447747, 4474447774, 4474447777, 4474474444, 4474474447, 4474474474, 4474474477, 4474474744, 4474474747, 4474474774, 4474474777, 4474477444, 4474477447, 4474477474, 4474477477, 4474477744, 4474477747, 4474477774, 4474477777, 4474744444, 4474744447, 4474744474, 4474744477, 4474744744, 4474744747, 4474744774, 4474744777, 4474747444, 4474747447, 4474747474, 4474747477, 4474747744, 4474747747, 4474747774, 4474747777, 4474774444, 4474774447, 4474774474, 4474774477, 4474774744, 4474774747, 4474774774, 4474774777, 4474777444, 4474777447, 4474777474, 4474777477, 4474777744, 4474777747, 4474777774, 4474777777, 4477444444, 4477444447, 4477444474, 4477444477, 4477444744, 4477444747, 4477444774, 4477444777, 4477447444, 4477447447, 4477447474, 4477447477, 4477447744, 4477447747, 4477447774, 4477447777, 4477474444, 4477474447, 4477474474, 4477474477, 4477474744, 4477474747, 4477474774, 4477474777, 4477477444, 4477477447, 4477477474, 4477477477, 4477477744, 4477477747, 4477477774, 4477477777, 4477744444, 4477744447, 4477744474, 4477744477, 4477744744, 4477744747, 4477744774, 4477744777, 4477747444, 4477747447, 4477747474, 4477747477, 4477747744, 4477747747, 4477747774, 4477747777, 4477774444, 4477774447, 4477774474, 4477774477, 4477774744, 4477774747, 4477774774, 4477774777, 4477777444, 4477777447, 4477777474, 4477777477, 4477777744, 4477777747, 4477777774, 4477777777, 4744444444, 4744444447, 4744444474, 4744444477, 4744444744, 4744444747, 4744444774, 4744444777, 4744447444, 4744447447, 4744447474, 4744447477, 4744447744, 4744447747, 4744447774, 4744447777, 4744474444, 4744474447, 4744474474, 4744474477, 4744474744, 4744474747, 4744474774, 4744474777, 4744477444, 4744477447, 4744477474, 4744477477, 4744477744, 4744477747, 4744477774, 4744477777, 4744744444, 4744744447, 4744744474, 4744744477, 4744744744, 4744744747, 4744744774, 4744744777, 4744747444, 4744747447, 4744747474, 4744747477, 4744747744, 4744747747, 4744747774, 4744747777, 4744774444, 4744774447, 4744774474, 4744774477, 4744774744, 4744774747, 4744774774, 4744774777, 4744777444, 4744777447, 4744777474, 4744777477, 4744777744, 4744777747, 4744777774, 4744777777, 4747444444, 4747444447, 4747444474, 4747444477, 4747444744, 4747444747, 4747444774, 4747444777, 4747447444, 4747447447, 4747447474, 4747447477, 4747447744, 4747447747, 4747447774, 4747447777, 4747474444, 4747474447, 4747474474, 4747474477, 4747474744, 4747474747, 4747474774, 4747474777, 4747477444, 4747477447, 4747477474, 4747477477, 4747477744, 4747477747, 4747477774, 4747477777, 4747744444, 4747744447, 4747744474, 4747744477, 4747744744, 4747744747, 4747744774, 4747744777, 4747747444, 4747747447, 4747747474, 4747747477, 4747747744, 4747747747, 4747747774, 4747747777, 4747774444, 4747774447, 4747774474, 4747774477, 4747774744, 4747774747, 4747774774, 4747774777, 4747777444, 4747777447, 4747777474, 4747777477, 4747777744, 4747777747, 4747777774, 4747777777, 4774444444, 4774444447, 4774444474, 4774444477, 4774444744, 4774444747, 4774444774, 4774444777, 4774447444, 4774447447, 4774447474, 4774447477, 4774447744, 4774447747, 4774447774, 4774447777, 4774474444, 4774474447, 4774474474, 4774474477, 4774474744, 4774474747, 4774474774, 4774474777, 4774477444, 4774477447, 4774477474, 4774477477, 4774477744, 4774477747, 4774477774, 4774477777, 4774744444, 4774744447, 4774744474, 4774744477, 4774744744, 4774744747, 4774744774, 4774744777, 4774747444, 4774747447, 4774747474, 4774747477, 4774747744, 4774747747, 4774747774, 4774747777, 4774774444, 4774774447, 4774774474, 4774774477, 4774774744, 4774774747, 4774774774, 4774774777, 4774777444, 4774777447, 4774777474, 4774777477, 4774777744, 4774777747, 4774777774, 4774777777, 4777444444, 4777444447, 4777444474, 4777444477, 4777444744, 4777444747, 4777444774, 4777444777, 4777447444, 4777447447, 4777447474, 4777447477, 4777447744, 4777447747, 4777447774, 4777447777, 4777474444, 4777474447, 4777474474, 4777474477, 4777474744, 4777474747, 4777474774, 4777474777, 4777477444, 4777477447, 4777477474, 4777477477, 4777477744, 4777477747, 4777477774, 4777477777, 4777744444, 4777744447, 4777744474, 4777744477, 4777744744, 4777744747, 4777744774, 4777744777, 4777747444, 4777747447, 4777747474, 4777747477, 4777747744, 4777747747, 4777747774, 4777747777, 4777774444, 4777774447, 4777774474, 4777774477, 4777774744, 4777774747, 4777774774, 4777774777, 4777777444, 4777777447, 4777777474, 4777777477, 4777777744, 4777777747, 4777777774, 4777777777, 7444444444, 7444444447, 7444444474, 7444444477, 7444444744, 7444444747, 7444444774, 7444444777, 7444447444, 7444447447, 7444447474, 7444447477, 7444447744, 7444447747, 7444447774, 7444447777, 7444474444, 7444474447, 7444474474, 7444474477, 7444474744, 7444474747, 7444474774, 7444474777, 7444477444, 7444477447, 7444477474, 7444477477, 7444477744, 7444477747, 7444477774, 7444477777, 7444744444, 7444744447, 7444744474, 7444744477, 7444744744, 7444744747, 7444744774, 7444744777, 7444747444, 7444747447, 7444747474, 7444747477, 7444747744, 7444747747, 7444747774, 7444747777, 7444774444, 7444774447, 7444774474, 7444774477, 7444774744, 7444774747, 7444774774, 7444774777, 7444777444, 7444777447, 7444777474, 7444777477, 7444777744, 7444777747, 7444777774, 7444777777, 7447444444, 7447444447, 7447444474, 7447444477, 7447444744, 7447444747, 7447444774, 7447444777, 7447447444, 7447447447, 7447447474, 7447447477, 7447447744, 7447447747, 7447447774, 7447447777, 7447474444, 7447474447, 7447474474, 7447474477, 7447474744, 7447474747, 7447474774, 7447474777, 7447477444, 7447477447, 7447477474, 7447477477, 7447477744, 7447477747, 7447477774, 7447477777, 7447744444, 7447744447, 7447744474, 7447744477, 7447744744, 7447744747, 7447744774, 7447744777, 7447747444, 7447747447, 7447747474, 7447747477, 7447747744, 7447747747, 7447747774, 7447747777, 7447774444, 7447774447, 7447774474, 7447774477, 7447774744, 7447774747, 7447774774, 7447774777, 7447777444, 7447777447, 7447777474, 7447777477, 7447777744, 7447777747, 7447777774, 7447777777, 7474444444, 7474444447, 7474444474, 7474444477, 7474444744, 7474444747, 7474444774, 7474444777, 7474447444, 7474447447, 7474447474, 7474447477, 7474447744, 7474447747, 7474447774, 7474447777, 7474474444, 7474474447, 7474474474, 7474474477, 7474474744, 7474474747, 7474474774, 7474474777, 7474477444, 7474477447, 7474477474, 7474477477, 7474477744, 7474477747, 7474477774, 7474477777, 7474744444, 7474744447, 7474744474, 7474744477, 7474744744, 7474744747, 7474744774, 7474744777, 7474747444, 7474747447, 7474747474, 7474747477, 7474747744, 7474747747, 7474747774, 7474747777, 7474774444, 7474774447, 7474774474, 7474774477, 7474774744, 7474774747, 7474774774, 7474774777, 7474777444, 7474777447, 7474777474, 7474777477, 7474777744, 7474777747, 7474777774, 7474777777, 7477444444, 7477444447, 7477444474, 7477444477, 7477444744, 7477444747, 7477444774, 7477444777, 7477447444, 7477447447, 7477447474, 7477447477, 7477447744, 7477447747, 7477447774, 7477447777, 7477474444, 7477474447, 7477474474, 7477474477, 7477474744, 7477474747, 7477474774, 7477474777, 7477477444, 7477477447, 7477477474, 7477477477, 7477477744, 7477477747, 7477477774, 7477477777, 7477744444, 7477744447, 7477744474, 7477744477, 7477744744, 7477744747, 7477744774, 7477744777, 7477747444, 7477747447, 7477747474, 7477747477, 7477747744, 7477747747, 7477747774, 7477747777, 7477774444, 7477774447, 7477774474, 7477774477, 7477774744, 7477774747, 7477774774, 7477774777, 7477777444, 7477777447, 7477777474, 7477777477, 7477777744, 7477777747, 7477777774, 7477777777, 7744444444, 7744444447, 7744444474, 7744444477, 7744444744, 7744444747, 7744444774, 7744444777, 7744447444, 7744447447, 7744447474, 7744447477, 7744447744, 7744447747, 7744447774, 7744447777, 7744474444, 7744474447, 7744474474, 7744474477, 7744474744, 7744474747, 7744474774, 7744474777, 7744477444, 7744477447, 7744477474, 7744477477, 7744477744, 7744477747, 7744477774, 7744477777, 7744744444, 7744744447, 7744744474, 7744744477, 7744744744, 7744744747, 7744744774, 7744744777, 7744747444, 7744747447, 7744747474, 7744747477, 7744747744, 7744747747, 7744747774, 7744747777, 7744774444, 7744774447, 7744774474, 7744774477, 7744774744, 7744774747, 7744774774, 7744774777, 7744777444, 7744777447, 7744777474, 7744777477, 7744777744, 7744777747, 7744777774, 7744777777, 7747444444, 7747444447, 7747444474, 7747444477, 7747444744, 7747444747, 7747444774, 7747444777, 7747447444, 7747447447, 7747447474, 7747447477, 7747447744, 7747447747, 7747447774, 7747447777, 7747474444, 7747474447, 7747474474, 7747474477, 7747474744, 7747474747, 7747474774, 7747474777, 7747477444, 7747477447, 7747477474, 7747477477, 7747477744, 7747477747, 7747477774, 7747477777, 7747744444, 7747744447, 7747744474, 7747744477, 7747744744, 7747744747, 7747744774, 7747744777, 7747747444, 7747747447, 7747747474, 7747747477, 7747747744, 7747747747, 7747747774, 7747747777, 7747774444, 7747774447, 7747774474, 7747774477, 7747774744, 7747774747, 7747774774, 7747774777, 7747777444, 7747777447, 7747777474, 7747777477, 7747777744, 7747777747, 7747777774, 7747777777, 7774444444, 7774444447, 7774444474, 7774444477, 7774444744, 7774444747, 7774444774, 7774444777, 7774447444, 7774447447, 7774447474, 7774447477, 7774447744, 7774447747, 7774447774, 7774447777, 7774474444, 7774474447, 7774474474, 7774474477, 7774474744, 7774474747, 7774474774, 7774474777, 7774477444, 7774477447, 7774477474, 7774477477, 7774477744, 7774477747, 7774477774, 7774477777, 7774744444, 7774744447, 7774744474, 7774744477, 7774744744, 7774744747, 7774744774, 7774744777, 7774747444, 7774747447, 7774747474, 7774747477, 7774747744, 7774747747, 7774747774, 7774747777, 7774774444, 7774774447, 7774774474, 7774774477, 7774774744, 7774774747, 7774774774, 7774774777, 7774777444, 7774777447, 7774777474, 7774777477, 7774777744, 7774777747, 7774777774, 7774777777, 7777444444, 7777444447, 7777444474, 7777444477, 7777444744, 7777444747, 7777444774, 7777444777, 7777447444, 7777447447, 7777447474, 7777447477, 7777447744, 7777447747, 7777447774, 7777447777, 7777474444, 7777474447, 7777474474, 7777474477, 7777474744, 7777474747, 7777474774, 7777474777, 7777477444, 7777477447, 7777477474, 7777477477, 7777477744, 7777477747, 7777477774, 7777477777, 7777744444, 7777744447, 7777744474, 7777744477, 7777744744, 7777744747, 7777744774, 7777744777, 7777747444, 7777747447, 7777747474, 7777747477, 7777747744, 7777747747, 7777747774, 7777747777, 7777774444, 7777774447, 7777774474, 7777774477, 7777774744, 7777774747, 7777774774, 7777774777, 7777777444, 7777777447, 7777777474, 7777777477, 7777777744, 7777777747, 7777777774, 7777777777, 44444444444, 44444444447, 44444444474, 44444444477, 44444444744, 44444444747, 44444444774, 44444444777, 44444447444, 44444447447, 44444447474, 44444447477, 44444447744, 44444447747, 44444447774, 44444447777, 44444474444, 44444474447, 44444474474, 44444474477, 44444474744, 44444474747, 44444474774, 44444474777, 44444477444, 44444477447, 44444477474, 44444477477, 44444477744, 44444477747, 44444477774, 44444477777, 44444744444, 44444744447, 44444744474, 44444744477, 44444744744, 44444744747, 44444744774, 44444744777, 44444747444, 44444747447, 44444747474, 44444747477, 44444747744, 44444747747, 44444747774, 44444747777, 44444774444, 44444774447, 44444774474, 44444774477, 44444774744, 44444774747, 44444774774, 44444774777, 44444777444, 44444777447, 44444777474, 44444777477, 44444777744, 44444777747, 44444777774, 44444777777, 44447444444, 44447444447, 44447444474, 44447444477, 44447444744, 44447444747, 44447444774, 44447444777, 44447447444, 44447447447, 44447447474, 44447447477, 44447447744, 44447447747, 44447447774, 44447447777, 44447474444, 44447474447, 44447474474, 44447474477, 44447474744, 44447474747, 44447474774, 44447474777, 44447477444, 44447477447, 44447477474, 44447477477, 44447477744, 44447477747, 44447477774, 44447477777, 44447744444, 44447744447, 44447744474, 44447744477, 44447744744, 44447744747, 44447744774, 44447744777, 44447747444, 44447747447, 44447747474, 44447747477, 44447747744, 44447747747, 44447747774, 44447747777, 44447774444, 44447774447, 44447774474, 44447774477, 44447774744, 44447774747, 44447774774, 44447774777, 44447777444, 44447777447, 44447777474, 44447777477, 44447777744, 44447777747, 44447777774, 44447777777, 44474444444, 44474444447, 44474444474, 44474444477, 44474444744, 44474444747, 44474444774, 44474444777, 44474447444, 44474447447, 44474447474, 44474447477, 44474447744, 44474447747, 44474447774, 44474447777, 44474474444, 44474474447, 44474474474, 44474474477, 44474474744, 44474474747, 44474474774, 44474474777, 44474477444, 44474477447, 44474477474, 44474477477, 44474477744, 44474477747, 44474477774, 44474477777, 44474744444, 44474744447, 44474744474, 44474744477, 44474744744, 44474744747, 44474744774, 44474744777, 44474747444, 44474747447, 44474747474, 44474747477, 44474747744, 44474747747, 44474747774, 44474747777, 44474774444, 44474774447, 44474774474, 44474774477, 44474774744, 44474774747, 44474774774, 44474774777, 44474777444, 44474777447, 44474777474, 44474777477, 44474777744, 44474777747, 44474777774, 44474777777, 44477444444, 44477444447, 44477444474, 44477444477, 44477444744, 44477444747, 44477444774, 44477444777, 44477447444, 44477447447, 44477447474, 44477447477, 44477447744, 44477447747, 44477447774, 44477447777, 44477474444, 44477474447, 44477474474, 44477474477, 44477474744, 44477474747, 44477474774, 44477474777, 44477477444, 44477477447, 44477477474, 44477477477, 44477477744, 44477477747, 44477477774, 44477477777, 44477744444, 44477744447, 44477744474, 44477744477, 44477744744, 44477744747, 44477744774, 44477744777, 44477747444, 44477747447, 44477747474, 44477747477, 44477747744, 44477747747, 44477747774, 44477747777, 44477774444, 44477774447, 44477774474, 44477774477, 44477774744, 44477774747, 44477774774, 44477774777, 44477777444, 44477777447, 44477777474, 44477777477, 44477777744, 44477777747, 44477777774, 44477777777, 44744444444, 44744444447, 44744444474, 44744444477, 44744444744, 44744444747, 44744444774, 44744444777, 44744447444, 44744447447, 44744447474, 44744447477, 44744447744, 44744447747, 44744447774, 44744447777, 44744474444, 44744474447, 44744474474, 44744474477, 44744474744, 44744474747, 44744474774, 44744474777, 44744477444, 44744477447, 44744477474, 44744477477, 44744477744, 44744477747, 44744477774, 44744477777, 44744744444, 44744744447, 44744744474, 44744744477, 44744744744, 44744744747, 44744744774, 44744744777, 44744747444, 44744747447, 44744747474, 44744747477, 44744747744, 44744747747, 44744747774, 44744747777, 44744774444, 44744774447, 44744774474, 44744774477, 44744774744, 44744774747, 44744774774, 44744774777, 44744777444, 44744777447, 44744777474, 44744777477, 44744777744, 44744777747, 44744777774, 44744777777, 44747444444, 44747444447, 44747444474, 44747444477, 44747444744, 44747444747, 44747444774, 44747444777, 44747447444, 44747447447, 44747447474, 44747447477, 44747447744, 44747447747, 44747447774, 44747447777, 44747474444, 44747474447, 44747474474, 44747474477, 44747474744, 44747474747, 44747474774, 44747474777, 44747477444, 44747477447, 44747477474, 44747477477, 44747477744, 44747477747, 44747477774, 44747477777, 44747744444, 44747744447, 44747744474, 44747744477, 44747744744, 44747744747, 44747744774, 44747744777, 44747747444, 44747747447, 44747747474, 44747747477, 44747747744, 44747747747, 44747747774, 44747747777, 44747774444, 44747774447, 44747774474, 44747774477, 44747774744, 44747774747, 44747774774, 44747774777, 44747777444, 44747777447, 44747777474, 44747777477, 44747777744, 44747777747, 44747777774, 44747777777, 44774444444, 44774444447, 44774444474, 44774444477, 44774444744, 44774444747, 44774444774, 44774444777, 44774447444, 44774447447, 44774447474, 44774447477, 44774447744, 44774447747, 44774447774, 44774447777, 44774474444, 44774474447, 44774474474, 44774474477, 44774474744, 44774474747, 44774474774, 44774474777, 44774477444, 44774477447, 44774477474, 44774477477, 44774477744, 44774477747, 44774477774, 44774477777, 44774744444, 44774744447, 44774744474, 44774744477, 44774744744, 44774744747, 44774744774, 44774744777, 44774747444, 44774747447, 44774747474, 44774747477, 44774747744, 44774747747, 44774747774, 44774747777, 44774774444, 44774774447, 44774774474, 44774774477, 44774774744, 44774774747, 44774774774, 44774774777, 44774777444, 44774777447, 44774777474, 44774777477, 44774777744, 44774777747, 44774777774, 44774777777, 44777444444, 44777444447, 44777444474, 44777444477, 44777444744, 44777444747, 44777444774, 44777444777, 44777447444, 44777447447, 44777447474, 44777447477, 44777447744, 44777447747, 44777447774, 44777447777, 44777474444, 44777474447, 44777474474, 44777474477, 44777474744, 44777474747, 44777474774, 44777474777, 44777477444, 44777477447, 44777477474, 44777477477, 44777477744, 44777477747, 44777477774, 44777477777, 44777744444, 44777744447, 44777744474, 44777744477, 44777744744, 44777744747, 44777744774, 44777744777, 44777747444, 44777747447, 44777747474, 44777747477, 44777747744, 44777747747, 44777747774, 44777747777, 44777774444, 44777774447, 44777774474, 44777774477, 44777774744, 44777774747, 44777774774, 44777774777, 44777777444, 44777777447, 44777777474, 44777777477, 44777777744, 44777777747, 44777777774, 44777777777, 47444444444, 47444444447, 47444444474, 47444444477, 47444444744, 47444444747, 47444444774, 47444444777, 47444447444, 47444447447, 47444447474, 47444447477, 47444447744, 47444447747, 47444447774, 47444447777, 47444474444, 47444474447, 47444474474, 47444474477, 47444474744, 47444474747, 47444474774, 47444474777, 47444477444, 47444477447, 47444477474, 47444477477, 47444477744, 47444477747, 47444477774, 47444477777, 47444744444, 47444744447, 47444744474, 47444744477, 47444744744, 47444744747, 47444744774, 47444744777, 47444747444, 47444747447, 47444747474, 47444747477, 47444747744, 47444747747, 47444747774, 47444747777, 47444774444, 47444774447, 47444774474, 47444774477, 47444774744, 47444774747, 47444774774, 47444774777, 47444777444, 47444777447, 47444777474, 47444777477, 47444777744, 47444777747, 47444777774, 47444777777, 47447444444, 47447444447, 47447444474, 47447444477, 47447444744, 47447444747, 47447444774, 47447444777, 47447447444, 47447447447, 47447447474, 47447447477, 47447447744, 47447447747, 47447447774, 47447447777, 47447474444, 47447474447, 47447474474, 47447474477, 47447474744, 47447474747, 47447474774, 47447474777, 47447477444, 47447477447, 47447477474, 47447477477, 47447477744, 47447477747, 47447477774, 47447477777, 47447744444, 47447744447, 47447744474, 47447744477, 47447744744, 47447744747, 47447744774, 47447744777, 47447747444, 47447747447, 47447747474, 47447747477, 47447747744, 47447747747, 47447747774, 47447747777, 47447774444, 47447774447, 47447774474, 47447774477, 47447774744, 47447774747, 47447774774, 47447774777, 47447777444, 47447777447, 47447777474, 47447777477, 47447777744, 47447777747, 47447777774, 47447777777, 47474444444, 47474444447, 47474444474, 47474444477, 47474444744, 47474444747, 47474444774, 47474444777, 47474447444, 47474447447, 47474447474, 47474447477, 47474447744, 47474447747, 47474447774, 47474447777, 47474474444, 47474474447, 47474474474, 47474474477, 47474474744, 47474474747, 47474474774, 47474474777, 47474477444, 47474477447, 47474477474, 47474477477, 47474477744, 47474477747, 47474477774, 47474477777, 47474744444, 47474744447, 47474744474, 47474744477, 47474744744, 47474744747, 47474744774, 47474744777, 47474747444, 47474747447, 47474747474, 47474747477, 47474747744, 47474747747, 47474747774, 47474747777, 47474774444, 47474774447, 47474774474, 47474774477, 47474774744, 47474774747, 47474774774, 47474774777, 47474777444, 47474777447, 47474777474, 47474777477, 47474777744, 47474777747, 47474777774, 47474777777, 47477444444, 47477444447, 47477444474, 47477444477, 47477444744, 47477444747, 47477444774, 47477444777, 47477447444, 47477447447, 47477447474, 47477447477, 47477447744, 47477447747, 47477447774, 47477447777, 47477474444, 47477474447, 47477474474, 47477474477, 47477474744, 47477474747, 47477474774, 47477474777, 47477477444, 47477477447, 47477477474, 47477477477, 47477477744, 47477477747, 47477477774, 47477477777, 47477744444, 47477744447, 47477744474, 47477744477, 47477744744, 47477744747, 47477744774, 47477744777, 47477747444, 47477747447, 47477747474, 47477747477, 47477747744, 47477747747, 47477747774, 47477747777, 47477774444, 47477774447, 47477774474, 47477774477, 47477774744, 47477774747, 47477774774, 47477774777, 47477777444, 47477777447, 47477777474, 47477777477, 47477777744, 47477777747, 47477777774, 47477777777, 47744444444, 47744444447, 47744444474, 47744444477, 47744444744, 47744444747, 47744444774, 47744444777, 47744447444, 47744447447, 47744447474, 47744447477, 47744447744, 47744447747, 47744447774, 47744447777, 47744474444, 47744474447, 47744474474, 47744474477, 47744474744, 47744474747, 47744474774, 47744474777, 47744477444, 47744477447, 47744477474, 47744477477, 47744477744, 47744477747, 47744477774, 47744477777, 47744744444, 47744744447, 47744744474, 47744744477, 47744744744, 47744744747, 47744744774, 47744744777, 47744747444, 47744747447, 47744747474, 47744747477, 47744747744, 47744747747, 47744747774, 47744747777, 47744774444, 47744774447, 47744774474, 47744774477, 47744774744, 47744774747, 47744774774, 47744774777, 47744777444, 47744777447, 47744777474, 47744777477, 47744777744, 47744777747, 47744777774, 47744777777, 47747444444, 47747444447, 47747444474, 47747444477, 47747444744, 47747444747, 47747444774, 47747444777, 47747447444, 47747447447, 47747447474, 47747447477, 47747447744, 47747447747, 47747447774, 47747447777, 47747474444, 47747474447, 47747474474, 47747474477, 47747474744, 47747474747, 47747474774, 47747474777, 47747477444, 47747477447, 47747477474, 47747477477, 47747477744, 47747477747, 47747477774, 47747477777, 47747744444, 47747744447, 47747744474, 47747744477, 47747744744, 47747744747, 47747744774, 47747744777, 47747747444, 47747747447, 47747747474, 47747747477, 47747747744, 47747747747, 47747747774, 47747747777, 47747774444, 47747774447, 47747774474, 47747774477, 47747774744, 47747774747, 47747774774, 47747774777, 47747777444, 47747777447, 47747777474, 47747777477, 47747777744, 47747777747, 47747777774, 47747777777, 47774444444, 47774444447, 47774444474, 47774444477, 47774444744, 47774444747, 47774444774, 47774444777, 47774447444, 47774447447, 47774447474, 47774447477, 47774447744, 47774447747, 47774447774, 47774447777, 47774474444, 47774474447, 47774474474, 47774474477, 47774474744, 47774474747, 47774474774, 47774474777, 47774477444, 47774477447, 47774477474, 47774477477, 47774477744, 47774477747, 47774477774, 47774477777, 47774744444, 47774744447, 47774744474, 47774744477, 47774744744, 47774744747, 47774744774, 47774744777, 47774747444, 47774747447, 47774747474, 47774747477, 47774747744, 47774747747, 47774747774, 47774747777, 47774774444, 47774774447, 47774774474, 47774774477, 47774774744, 47774774747, 47774774774, 47774774777, 47774777444, 47774777447, 47774777474, 47774777477, 47774777744, 47774777747, 47774777774, 47774777777, 47777444444, 47777444447, 47777444474, 47777444477, 47777444744, 47777444747, 47777444774, 47777444777, 47777447444, 47777447447, 47777447474, 47777447477, 47777447744, 47777447747, 47777447774, 47777447777, 47777474444, 47777474447, 47777474474, 47777474477, 47777474744, 47777474747, 47777474774, 47777474777, 47777477444, 47777477447, 47777477474, 47777477477, 47777477744, 47777477747, 47777477774, 47777477777, 47777744444, 47777744447, 47777744474, 47777744477, 47777744744, 47777744747, 47777744774, 47777744777, 47777747444, 47777747447, 47777747474, 47777747477, 47777747744, 47777747747, 47777747774, 47777747777, 47777774444, 47777774447, 47777774474, 47777774477, 47777774744, 47777774747, 47777774774, 47777774777, 47777777444, 47777777447, 47777777474, 47777777477, 47777777744, 47777777747, 47777777774, 47777777777, 74444444444, 74444444447, 74444444474, 74444444477, 74444444744, 74444444747, 74444444774, 74444444777, 74444447444, 74444447447, 74444447474, 74444447477, 74444447744, 74444447747, 74444447774, 74444447777, 74444474444, 74444474447, 74444474474, 74444474477, 74444474744, 74444474747, 74444474774, 74444474777, 74444477444, 74444477447, 74444477474, 74444477477, 74444477744, 74444477747, 74444477774, 74444477777, 74444744444, 74444744447, 74444744474, 74444744477, 74444744744, 74444744747, 74444744774, 74444744777, 74444747444, 74444747447, 74444747474, 74444747477, 74444747744, 74444747747, 74444747774, 74444747777, 74444774444, 74444774447, 74444774474, 74444774477, 74444774744, 74444774747, 74444774774, 74444774777, 74444777444, 74444777447, 74444777474, 74444777477, 74444777744, 74444777747, 74444777774, 74444777777, 74447444444, 74447444447, 74447444474, 74447444477, 74447444744, 74447444747, 74447444774, 74447444777, 74447447444, 74447447447, 74447447474, 74447447477, 74447447744, 74447447747, 74447447774, 74447447777, 74447474444, 74447474447, 74447474474, 74447474477, 74447474744, 74447474747, 74447474774, 74447474777, 74447477444, 74447477447, 74447477474, 74447477477, 74447477744, 74447477747, 74447477774, 74447477777, 74447744444, 74447744447, 74447744474, 74447744477, 74447744744, 74447744747, 74447744774, 74447744777, 74447747444, 74447747447, 74447747474, 74447747477, 74447747744, 74447747747, 74447747774, 74447747777, 74447774444, 74447774447, 74447774474, 74447774477, 74447774744, 74447774747, 74447774774, 74447774777, 74447777444, 74447777447, 74447777474, 74447777477, 74447777744, 74447777747, 74447777774, 74447777777, 74474444444, 74474444447, 74474444474, 74474444477, 74474444744, 74474444747, 74474444774, 74474444777, 74474447444, 74474447447, 74474447474, 74474447477, 74474447744, 74474447747, 74474447774, 74474447777, 74474474444, 74474474447, 74474474474, 74474474477, 74474474744, 74474474747, 74474474774, 74474474777, 74474477444, 74474477447, 74474477474, 74474477477, 74474477744, 74474477747, 74474477774, 74474477777, 74474744444, 74474744447, 74474744474, 74474744477, 74474744744, 74474744747, 74474744774, 74474744777, 74474747444, 74474747447, 74474747474, 74474747477, 74474747744, 74474747747, 74474747774, 74474747777, 74474774444, 74474774447, 74474774474, 74474774477, 74474774744, 74474774747, 74474774774, 74474774777, 74474777444, 74474777447, 74474777474, 74474777477, 74474777744, 74474777747, 74474777774, 74474777777, 74477444444, 74477444447, 74477444474, 74477444477, 74477444744, 74477444747, 74477444774, 74477444777, 74477447444, 74477447447, 74477447474, 74477447477, 74477447744, 74477447747, 74477447774, 74477447777, 74477474444, 74477474447, 74477474474, 74477474477, 74477474744, 74477474747, 74477474774, 74477474777, 74477477444, 74477477447, 74477477474, 74477477477, 74477477744, 74477477747, 74477477774, 74477477777, 74477744444, 74477744447, 74477744474, 74477744477, 74477744744, 74477744747, 74477744774, 74477744777, 74477747444, 74477747447, 74477747474, 74477747477, 74477747744, 74477747747, 74477747774, 74477747777, 74477774444, 74477774447, 74477774474, 74477774477, 74477774744, 74477774747, 74477774774, 74477774777, 74477777444, 74477777447, 74477777474, 74477777477, 74477777744, 74477777747, 74477777774, 74477777777, 74744444444, 74744444447, 74744444474, 74744444477, 74744444744, 74744444747, 74744444774, 74744444777, 74744447444, 74744447447, 74744447474, 74744447477, 74744447744, 74744447747, 74744447774, 74744447777, 74744474444, 74744474447, 74744474474, 74744474477, 74744474744, 74744474747, 74744474774, 74744474777, 74744477444, 74744477447, 74744477474, 74744477477, 74744477744, 74744477747, 74744477774, 74744477777, 74744744444, 74744744447, 74744744474, 74744744477, 74744744744, 74744744747, 74744744774, 74744744777, 74744747444, 74744747447, 74744747474, 74744747477, 74744747744, 74744747747, 74744747774, 74744747777, 74744774444, 74744774447, 74744774474, 74744774477, 74744774744, 74744774747, 74744774774, 74744774777, 74744777444, 74744777447, 74744777474, 74744777477, 74744777744, 74744777747, 74744777774, 74744777777, 74747444444, 74747444447, 74747444474, 74747444477, 74747444744, 74747444747, 74747444774, 74747444777, 74747447444, 74747447447, 74747447474, 74747447477, 74747447744, 74747447747, 74747447774, 74747447777, 74747474444, 74747474447, 74747474474, 74747474477, 74747474744, 74747474747, 74747474774, 74747474777, 74747477444, 74747477447, 74747477474, 74747477477, 74747477744, 74747477747, 74747477774, 74747477777, 74747744444, 74747744447, 74747744474, 74747744477, 74747744744, 74747744747, 74747744774, 74747744777, 74747747444, 74747747447, 74747747474, 74747747477, 74747747744, 74747747747, 74747747774, 74747747777, 74747774444, 74747774447, 74747774474, 74747774477, 74747774744, 74747774747, 74747774774, 74747774777, 74747777444, 74747777447, 74747777474, 74747777477, 74747777744, 74747777747, 74747777774, 74747777777, 74774444444, 74774444447, 74774444474, 74774444477, 74774444744, 74774444747, 74774444774, 74774444777, 74774447444, 74774447447, 74774447474, 74774447477, 74774447744, 74774447747, 74774447774, 74774447777, 74774474444, 74774474447, 74774474474, 74774474477, 74774474744, 74774474747, 74774474774, 74774474777, 74774477444, 74774477447, 74774477474, 74774477477, 74774477744, 74774477747, 74774477774, 74774477777, 74774744444, 74774744447, 74774744474, 74774744477, 74774744744, 74774744747, 74774744774, 74774744777, 74774747444, 74774747447, 74774747474, 74774747477, 74774747744, 74774747747, 74774747774, 74774747777, 74774774444, 74774774447, 74774774474, 74774774477, 74774774744, 74774774747, 74774774774, 74774774777, 74774777444, 74774777447, 74774777474, 74774777477, 74774777744, 74774777747, 74774777774, 74774777777, 74777444444, 74777444447, 74777444474, 74777444477, 74777444744, 74777444747, 74777444774, 74777444777, 74777447444, 74777447447, 74777447474, 74777447477, 74777447744, 74777447747, 74777447774, 74777447777, 74777474444, 74777474447, 74777474474, 74777474477, 74777474744, 74777474747, 74777474774, 74777474777, 74777477444, 74777477447, 74777477474, 74777477477, 74777477744, 74777477747, 74777477774, 74777477777, 74777744444, 74777744447, 74777744474, 74777744477, 74777744744, 74777744747, 74777744774, 74777744777, 74777747444, 74777747447, 74777747474, 74777747477, 74777747744, 74777747747, 74777747774, 74777747777, 74777774444, 74777774447, 74777774474, 74777774477, 74777774744, 74777774747, 74777774774, 74777774777, 74777777444, 74777777447, 74777777474, 74777777477, 74777777744, 74777777747, 74777777774, 74777777777, 77444444444, 77444444447, 77444444474, 77444444477, 77444444744, 77444444747, 77444444774, 77444444777, 77444447444, 77444447447, 77444447474, 77444447477, 77444447744, 77444447747, 77444447774, 77444447777, 77444474444, 77444474447, 77444474474, 77444474477, 77444474744, 77444474747, 77444474774, 77444474777, 77444477444, 77444477447, 77444477474, 77444477477, 77444477744, 77444477747, 77444477774, 77444477777, 77444744444, 77444744447, 77444744474, 77444744477, 77444744744, 77444744747, 77444744774, 77444744777, 77444747444, 77444747447, 77444747474, 77444747477, 77444747744, 77444747747, 77444747774, 77444747777, 77444774444, 77444774447, 77444774474, 77444774477, 77444774744, 77444774747, 77444774774, 77444774777, 77444777444, 77444777447, 77444777474, 77444777477, 77444777744, 77444777747, 77444777774, 77444777777, 77447444444, 77447444447, 77447444474, 77447444477, 77447444744, 77447444747, 77447444774, 77447444777, 77447447444, 77447447447, 77447447474, 77447447477, 77447447744, 77447447747, 77447447774, 77447447777, 77447474444, 77447474447, 77447474474, 77447474477, 77447474744, 77447474747, 77447474774, 77447474777, 77447477444, 77447477447, 77447477474, 77447477477, 77447477744, 77447477747, 77447477774, 77447477777, 77447744444, 77447744447, 77447744474, 77447744477, 77447744744, 77447744747, 77447744774, 77447744777, 77447747444, 77447747447, 77447747474, 77447747477, 77447747744, 77447747747, 77447747774, 77447747777, 77447774444, 77447774447, 77447774474, 77447774477, 77447774744, 77447774747, 77447774774, 77447774777, 77447777444, 77447777447, 77447777474, 77447777477, 77447777744, 77447777747, 77447777774, 77447777777, 77474444444, 77474444447, 77474444474, 77474444477, 77474444744, 77474444747, 77474444774, 77474444777, 77474447444, 77474447447, 77474447474, 77474447477, 77474447744, 77474447747, 77474447774, 77474447777, 77474474444, 77474474447, 77474474474, 77474474477, 77474474744, 77474474747, 77474474774, 77474474777, 77474477444, 77474477447, 77474477474, 77474477477, 77474477744, 77474477747, 77474477774, 77474477777, 77474744444, 77474744447, 77474744474, 77474744477, 77474744744, 77474744747, 77474744774, 77474744777, 77474747444, 77474747447, 77474747474, 77474747477, 77474747744, 77474747747, 77474747774, 77474747777, 77474774444, 77474774447, 77474774474, 77474774477, 77474774744, 77474774747, 77474774774, 77474774777, 77474777444, 77474777447, 77474777474, 77474777477, 77474777744, 77474777747, 77474777774, 77474777777, 77477444444, 77477444447, 77477444474, 77477444477, 77477444744, 77477444747, 77477444774, 77477444777, 77477447444, 77477447447, 77477447474, 77477447477, 77477447744, 77477447747, 77477447774, 77477447777, 77477474444, 77477474447, 77477474474, 77477474477, 77477474744, 77477474747, 77477474774, 77477474777, 77477477444, 77477477447, 77477477474, 77477477477, 77477477744, 77477477747, 77477477774, 77477477777, 77477744444, 77477744447, 77477744474, 77477744477, 77477744744, 77477744747, 77477744774, 77477744777, 77477747444, 77477747447, 77477747474, 77477747477, 77477747744, 77477747747, 77477747774, 77477747777, 77477774444, 77477774447, 77477774474, 77477774477, 77477774744, 77477774747, 77477774774, 77477774777, 77477777444, 77477777447, 77477777474, 77477777477, 77477777744, 77477777747, 77477777774, 77477777777, 77744444444, 77744444447, 77744444474, 77744444477, 77744444744, 77744444747, 77744444774, 77744444777, 77744447444, 77744447447, 77744447474, 77744447477, 77744447744, 77744447747, 77744447774, 77744447777, 77744474444, 77744474447, 77744474474, 77744474477, 77744474744, 77744474747, 77744474774, 77744474777, 77744477444, 77744477447, 77744477474, 77744477477, 77744477744, 77744477747, 77744477774, 77744477777, 77744744444, 77744744447, 77744744474, 77744744477, 77744744744, 77744744747, 77744744774, 77744744777, 77744747444, 77744747447, 77744747474, 77744747477, 77744747744, 77744747747, 77744747774, 77744747777, 77744774444, 77744774447, 77744774474, 77744774477, 77744774744, 77744774747, 77744774774, 77744774777, 77744777444, 77744777447, 77744777474, 77744777477, 77744777744, 77744777747, 77744777774, 77744777777, 77747444444, 77747444447, 77747444474, 77747444477, 77747444744, 77747444747, 77747444774, 77747444777, 77747447444, 77747447447, 77747447474, 77747447477, 77747447744, 77747447747, 77747447774, 77747447777, 77747474444, 77747474447, 77747474474, 77747474477, 77747474744, 77747474747, 77747474774, 77747474777, 77747477444, 77747477447, 77747477474, 77747477477, 77747477744, 77747477747, 77747477774, 77747477777, 77747744444, 77747744447, 77747744474, 77747744477, 77747744744, 77747744747, 77747744774, 77747744777, 77747747444, 77747747447, 77747747474, 77747747477, 77747747744, 77747747747, 77747747774, 77747747777, 77747774444, 77747774447, 77747774474, 77747774477, 77747774744, 77747774747, 77747774774, 77747774777, 77747777444, 77747777447, 77747777474, 77747777477, 77747777744, 77747777747, 77747777774, 77747777777, 77774444444, 77774444447, 77774444474, 77774444477, 77774444744, 77774444747, 77774444774, 77774444777, 77774447444, 77774447447, 77774447474, 77774447477, 77774447744, 77774447747, 77774447774, 77774447777, 77774474444, 77774474447, 77774474474, 77774474477, 77774474744, 77774474747, 77774474774, 77774474777, 77774477444, 77774477447, 77774477474, 77774477477, 77774477744, 77774477747, 77774477774, 77774477777, 77774744444, 77774744447, 77774744474, 77774744477, 77774744744, 77774744747, 77774744774, 77774744777, 77774747444, 77774747447, 77774747474, 77774747477, 77774747744, 77774747747, 77774747774, 77774747777, 77774774444, 77774774447, 77774774474, 77774774477, 77774774744, 77774774747, 77774774774, 77774774777, 77774777444, 77774777447, 77774777474, 77774777477, 77774777744, 77774777747, 77774777774, 77774777777, 77777444444, 77777444447, 77777444474, 77777444477, 77777444744, 77777444747, 77777444774, 77777444777, 77777447444, 77777447447, 77777447474, 77777447477, 77777447744, 77777447747, 77777447774, 77777447777, 77777474444, 77777474447, 77777474474, 77777474477, 77777474744, 77777474747, 77777474774, 77777474777, 77777477444, 77777477447, 77777477474, 77777477477, 77777477744, 77777477747, 77777477774, 77777477777, 77777744444, 77777744447, 77777744474, 77777744477, 77777744744, 77777744747, 77777744774, 77777744777, 77777747444, 77777747447, 77777747474, 77777747477, 77777747744, 77777747747, 77777747774, 77777747777, 77777774444, 77777774447, 77777774474, 77777774477, 77777774744, 77777774747, 77777774774, 77777774777, 77777777444, 77777777447, 77777777474, 77777777477, 77777777744, 77777777747, 77777777774, 77777777777]\n\nl, r = In()\nx = bisect_left(arr, l)\ny = bisect_right(arr, r)\nif l == r:\n print(arr[x])\nelif x == y:\n print((r-l+1)*arr[x])\nelse:\n sm = arr[x]*(arr[x]-l+1)\n for i in range(x+1, y):\n sm += (arr[i]-arr[i-1])*arr[i]\n if r > arr[y-1]:\n sm += arr[y]*(r-arr[y-1])\n print(sm)"}, {"source_code": "number = raw_input()\nnum1, num2 = number.split(\" \")\nnum1 = int(num1)\nnum2 = int (num2)\n\nans = []\n\ndef number_list(n):\n\tif n == 1:\n\t ans.extend(['4','7'])\n\telse:\n\t\tx = number_list(n - 1)\n\t\tfor num in x:\n\t\t\tans.append('4' + num)\n\t\tfor num in x:\n\t\t\tans.append('7' + num)\n\treturn ans[:]\n\nlucky_num = map(int, set(number_list(9)) )\nlucky_num.append(4444444444)\n\nsum = 0\n\nwhile num1 <= num2:\n\ta = min (n for n in lucky_num if n >= num1)\n\tif a > num2:\n\t\tsum = sum + (num2 - num1 + 1) * a\n\telse:\n\t\tsum = sum + (a - num1 + 1) * a\n\tnum1 = a + 1\n\nprint sum"}, {"source_code": "from bisect import bisect_left\nl, r = map(int, input().split())\nt, p, u, v = [4, 7], [4, 7], 4, 7\nwhile t[-1] < r:\n u, v = u * 10, v * 10\n t = [u + i for i in t] + [v + i for i in t]\n p.extend(t)\np = p[bisect_left(p, l): bisect_left(p, r) + 1]\nprint((p[0] - l + 1) * p[0] + (r - p[-1]) * p[-1] + sum((p[i] - p[i - 1]) * p[i] for i in range(1, len(p))))"}, {"source_code": "from bisect import bisect_left\nl, r = map(int, input().split())\nt, p, u, v = [4, 7], [4, 7], 4, 7\nwhile t[-1] < r:\n u, v = u * 10, v * 10\n t = [u + i for i in t] + [v + i for i in t]\n p.extend(t)\np = p[bisect_left(p, l): bisect_left(p, r) + 1]\nprint((p[0] - l + 1) * p[0] + (r - p[-1]) * p[-1] + sum((p[i] - p[i - 1]) * p[i] for i in range(1, len(p))))"}, {"source_code": "def Gen_lucky(n,s):\n if(len(s)==n):\n L.append(int(s))\n return\n Gen_lucky(n,s+\"4\")\n Gen_lucky(n,s+\"7\")\n return\n \n\n\n\n\nl,r=map(int,input().split())\n\nL=[]\nfor i in range(1,11):\n Gen_lucky(i,\"\")\nL.sort()\nind1=0\nfor i in range(len(L)):\n if(L[i]>=l):\n ind1=i\n break\nind2=0\nfor i in range(len(L)):\n if(L[i]>=r):\n ind2=i\n break\np=l\nx=0\nfor i in range(ind1,ind2+1):\n h=L[i]\n if(i==ind2):\n h=r\n x+=(h-p+1)*(L[i])\n p=L[i]+1\nprint(x)\n \n"}, {"source_code": "from itertools import product\nfrom bisect import bisect_left as bsearch\n\nMAXDIG = 11\n\ndef main():\n global MAXDIG\n (l, r) = map(int, input().split(' '))\n luckies = []\n for i in range(MAXDIG):\n lst = product([7, 4], repeat = i)\n for x in lst:\n s = ''.join(map(str, x))\n if len(s) != 0:\n num = int(s)\n luckies.append(num)\n luckies = sorted(luckies)\n i = bsearch(luckies, l)\n j = bsearch(luckies, r)\n s = 0\n n = r - l + 1\n left = n\n while luckies[i] <= luckies[j]:\n dif = min(luckies[i] - l + 1, left)\n left -= dif\n l += dif\n s += (dif * luckies[i])\n i += 1\n return s\n\nprint(main())\n\n"}, {"source_code": "l,r=map(int,input().split())\ns=set()\ndef f(st,res):\n\tif st>10:s.add(res)\n\telse:\n\t\tif res==0:f(st+1,res)\n\t\tfor i in 4,7:f(st+1,res*10+i)\nf(0,0)\ns=sorted(s)\na=1\nb=1\nq=0\nif l in s:\n\tq-=l\n\tl-=1\nwhile l>=s[a]:a+=1\nwhile r>=s[b+1]:b+=1\nif a>=b:\n\tq+=(min(r,s[a])-l+1)*s[a]\n\tif r>s[a]:q+=s[a+1]*(r-s[a])\nelse:\n\tif ls[b]:q+=s[b+1]*(r-s[b])\n\tfor i in range(a,b):q+=s[i+1]*(s[i+1]-s[i])\nprint(q)"}, {"source_code": "'''input\n1000000000 1000000000\n'''\nfrom bisect import *\nv = set()\nv.add(\"4\")\ndef generate_lucky(curr):\n if int(curr) > 10000000000:\n return\n v.add(curr)\n generate_lucky(curr + \"4\")\n generate_lucky(curr + \"7\")\n\nl,r = map(int,raw_input().split())\ngenerate_lucky(\"4\")\ngenerate_lucky(\"7\")\n\nx = [int(y) for y in v]\nx = sorted(x)\nintervals = {}\n\ns = 0\nfor i in x:\n intervals[i] = (s + 1,i)\n s = i\n\nans = 0\n# print l,r\nfor y in sorted(intervals.keys()):\n if max(l,intervals[y][0]) <= min(r,intervals[y][1]):\n ans += y * (abs(max(l,intervals[y][0]) - min(r,intervals[y][1]))+1)\n\nprint ans"}, {"source_code": "def naxt(i) :\n e=bin(i+2)\n e=e[3:]\n e=e.replace(\"0\",\"4\")\n e=e.replace(\"1\",\"7\")\n return int(e)\ni=0\nans=0\npr=0\nl,r=map(int,input().split())\nwhile(True):\n t=naxt(i)\n \n ans+=max((min(r,t)-max(l,pr)+1)*t,0)\n pr=t+1\n if r<=t :\n break\n i+=1\n \nprint(ans)\n \n \n \n \n"}, {"source_code": "l,r=map(int,(input().split()))\nlucky=[4,7]\nif l==1000000000 and r==1000000000:\n print(4444444444)\nelse:\n for i in range(1,11):\n \n for j in lucky[pow(2,i)-2:pow(2,i+1)+1]:\n \n lucky.append(4*pow(10,i) + j)\n lucky.append(7*pow(10,i)+ j)\n \n s_lucky=sorted(lucky)\n \n add=0\n while l>s_lucky[0]:\n del s_lucky[0]\n start=lucky[0]\n for i in s_lucky:\n\n if i>=r:\n end=s_lucky.index(i)\n break;\n add=0 \n \n if len(s_lucky[0:end+1])==1:\n print(s_lucky[0]*(r-l+1))\n else:\n for i in range(end+1):\n if i==0:\n add=add+s_lucky[0]*(s_lucky[0]-l+1)\n \n elif i<=end-1:\n \n add=add+s_lucky[i]*(s_lucky[i]-s_lucky[i-1])\n \n else:\n if r= l:\n t = i \n break\nfor i in range(len(x)):\n if x[i] >= r:\n e = i\n break\nres = sum[e] - sum[t] - x[e] * (x[e]-r) + (x[t]-l+1) * x[t]\nprint(res)\n\n"}, {"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\nle,r=mi()\nl=[]\ndef F(x):\n l.append(x)\n if x>r*10:return\n F(10*x+4)\n F(10*x+7)\nF(0)\n \nl.sort() \n\ns=0\ni=le-1\nj=0\nwhile(ii:\n s+=(min(l[j],r)-i)*l[j] \n i=l[j]\n j+=1\nprint(s)"}, {"source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom itertools import combinations_with_replacement\nfrom collections import defaultdict\nfrom bisect import bisect_right\nfrom bisect import bisect_left\n \ndef L():\n return list(map(int, stdin.readline().split()))\n \ndef In():\n return map(int, stdin.readline().split())\n \ndef I():\n return int(stdin.readline())\n \nP = 1000000007\narr = [0, 4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777, 4444, 4447, 4474, 4477, 4744, 4747, 4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777, 44444, 44447, 44474, 44477, 44744, 44747, 44774, 44777, 47444, 47447, 47474, 47477, 47744, 47747, 47774, 47777, 74444, 74447, 74474, 74477, 74744, 74747, 74774, 74777, 77444, 77447, 77474, 77477, 77744, 77747, 77774, 77777, 444444, 444447, 444474, 444477, 444744, 444747, 444774, 444777, 447444, 447447, 447474, 447477, 447744, 447747, 447774, 447777, 474444, 474447, 474474, 474477, 474744, 474747, 474774, 474777, 477444, 477447, 477474, 477477, 477744, 477747, 477774, 477777, 744444, 744447, 744474, 744477, 744744, 744747, 744774, 744777, 747444, 747447, 747474, 747477, 747744, 747747, 747774, 747777, 774444, 774447, 774474, 774477, 774744, 774747, 774774, 774777, 777444, 777447, 777474, 777477, 777744, 777747, 777774, 777777, 4444444, 4444447, 4444474, 4444477, 4444744, 4444747, 4444774, 4444777, 4447444, 4447447, 4447474, 4447477, 4447744, 4447747, 4447774, 4447777, 4474444, 4474447, 4474474, 4474477, 4474744, 4474747, 4474774, 4474777, 4477444, 4477447, 4477474, 4477477, 4477744, 4477747, 4477774, 4477777, 4744444, 4744447, 4744474, 4744477, 4744744, 4744747, 4744774, 4744777, 4747444, 4747447, 4747474, 4747477, 4747744, 4747747, 4747774, 4747777, 4774444, 4774447, 4774474, 4774477, 4774744, 4774747, 4774774, 4774777, 4777444, 4777447, 4777474, 4777477, 4777744, 4777747, 4777774, 4777777, 7444444, 7444447, 7444474, 7444477, 7444744, 7444747, 7444774, 7444777, 7447444, 7447447, 7447474, 7447477, 7447744, 7447747, 7447774, 7447777, 7474444, 7474447, 7474474, 7474477, 7474744, 7474747, 7474774, 7474777, 7477444, 7477447, 7477474, 7477477, 7477744, 7477747, 7477774, 7477777, 7744444, 7744447, 7744474, 7744477, 7744744, 7744747, 7744774, 7744777, 7747444, 7747447, 7747474, 7747477, 7747744, 7747747, 7747774, 7747777, 7774444, 7774447, 7774474, 7774477, 7774744, 7774747, 7774774, 7774777, 7777444, 7777447, 7777474, 7777477, 7777744, 7777747, 7777774, 7777777, 44444444, 44444447, 44444474, 44444477, 44444744, 44444747, 44444774, 44444777, 44447444, 44447447, 44447474, 44447477, 44447744, 44447747, 44447774, 44447777, 44474444, 44474447, 44474474, 44474477, 44474744, 44474747, 44474774, 44474777, 44477444, 44477447, 44477474, 44477477, 44477744, 44477747, 44477774, 44477777, 44744444, 44744447, 44744474, 44744477, 44744744, 44744747, 44744774, 44744777, 44747444, 44747447, 44747474, 44747477, 44747744, 44747747, 44747774, 44747777, 44774444, 44774447, 44774474, 44774477, 44774744, 44774747, 44774774, 44774777, 44777444, 44777447, 44777474, 44777477, 44777744, 44777747, 44777774, 44777777, 47444444, 47444447, 47444474, 47444477, 47444744, 47444747, 47444774, 47444777, 47447444, 47447447, 47447474, 47447477, 47447744, 47447747, 47447774, 47447777, 47474444, 47474447, 47474474, 47474477, 47474744, 47474747, 47474774, 47474777, 47477444, 47477447, 47477474, 47477477, 47477744, 47477747, 47477774, 47477777, 47744444, 47744447, 47744474, 47744477, 47744744, 47744747, 47744774, 47744777, 47747444, 47747447, 47747474, 47747477, 47747744, 47747747, 47747774, 47747777, 47774444, 47774447, 47774474, 47774477, 47774744, 47774747, 47774774, 47774777, 47777444, 47777447, 47777474, 47777477, 47777744, 47777747, 47777774, 47777777, 74444444, 74444447, 74444474, 74444477, 74444744, 74444747, 74444774, 74444777, 74447444, 74447447, 74447474, 74447477, 74447744, 74447747, 74447774, 74447777, 74474444, 74474447, 74474474, 74474477, 74474744, 74474747, 74474774, 74474777, 74477444, 74477447, 74477474, 74477477, 74477744, 74477747, 74477774, 74477777, 74744444, 74744447, 74744474, 74744477, 74744744, 74744747, 74744774, 74744777, 74747444, 74747447, 74747474, 74747477, 74747744, 74747747, 74747774, 74747777, 74774444, 74774447, 74774474, 74774477, 74774744, 74774747, 74774774, 74774777, 74777444, 74777447, 74777474, 74777477, 74777744, 74777747, 74777774, 74777777, 77444444, 77444447, 77444474, 77444477, 77444744, 77444747, 77444774, 77444777, 77447444, 77447447, 77447474, 77447477, 77447744, 77447747, 77447774, 77447777, 77474444, 77474447, 77474474, 77474477, 77474744, 77474747, 77474774, 77474777, 77477444, 77477447, 77477474, 77477477, 77477744, 77477747, 77477774, 77477777, 77744444, 77744447, 77744474, 77744477, 77744744, 77744747, 77744774, 77744777, 77747444, 77747447, 77747474, 77747477, 77747744, 77747747, 77747774, 77747777, 77774444, 77774447, 77774474, 77774477, 77774744, 77774747, 77774774, 77774777, 77777444, 77777447, 77777474, 77777477, 77777744, 77777747, 77777774, 77777777, 444444444, 444444447, 444444474, 444444477, 444444744, 444444747, 444444774, 444444777, 444447444, 444447447, 444447474, 444447477, 444447744, 444447747, 444447774, 444447777, 444474444, 444474447, 444474474, 444474477, 444474744, 444474747, 444474774, 444474777, 444477444, 444477447, 444477474, 444477477, 444477744, 444477747, 444477774, 444477777, 444744444, 444744447, 444744474, 444744477, 444744744, 444744747, 444744774, 444744777, 444747444, 444747447, 444747474, 444747477, 444747744, 444747747, 444747774, 444747777, 444774444, 444774447, 444774474, 444774477, 444774744, 444774747, 444774774, 444774777, 444777444, 444777447, 444777474, 444777477, 444777744, 444777747, 444777774, 444777777, 447444444, 447444447, 447444474, 447444477, 447444744, 447444747, 447444774, 447444777, 447447444, 447447447, 447447474, 447447477, 447447744, 447447747, 447447774, 447447777, 447474444, 447474447, 447474474, 447474477, 447474744, 447474747, 447474774, 447474777, 447477444, 447477447, 447477474, 447477477, 447477744, 447477747, 447477774, 447477777, 447744444, 447744447, 447744474, 447744477, 447744744, 447744747, 447744774, 447744777, 447747444, 447747447, 447747474, 447747477, 447747744, 447747747, 447747774, 447747777, 447774444, 447774447, 447774474, 447774477, 447774744, 447774747, 447774774, 447774777, 447777444, 447777447, 447777474, 447777477, 447777744, 447777747, 447777774, 447777777, 474444444, 474444447, 474444474, 474444477, 474444744, 474444747, 474444774, 474444777, 474447444, 474447447, 474447474, 474447477, 474447744, 474447747, 474447774, 474447777, 474474444, 474474447, 474474474, 474474477, 474474744, 474474747, 474474774, 474474777, 474477444, 474477447, 474477474, 474477477, 474477744, 474477747, 474477774, 474477777, 474744444, 474744447, 474744474, 474744477, 474744744, 474744747, 474744774, 474744777, 474747444, 474747447, 474747474, 474747477, 474747744, 474747747, 474747774, 474747777, 474774444, 474774447, 474774474, 474774477, 474774744, 474774747, 474774774, 474774777, 474777444, 474777447, 474777474, 474777477, 474777744, 474777747, 474777774, 474777777, 477444444, 477444447, 477444474, 477444477, 477444744, 477444747, 477444774, 477444777, 477447444, 477447447, 477447474, 477447477, 477447744, 477447747, 477447774, 477447777, 477474444, 477474447, 477474474, 477474477, 477474744, 477474747, 477474774, 477474777, 477477444, 477477447, 477477474, 477477477, 477477744, 477477747, 477477774, 477477777, 477744444, 477744447, 477744474, 477744477, 477744744, 477744747, 477744774, 477744777, 477747444, 477747447, 477747474, 477747477, 477747744, 477747747, 477747774, 477747777, 477774444, 477774447, 477774474, 477774477, 477774744, 477774747, 477774774, 477774777, 477777444, 477777447, 477777474, 477777477, 477777744, 477777747, 477777774, 477777777, 744444444, 744444447, 744444474, 744444477, 744444744, 744444747, 744444774, 744444777, 744447444, 744447447, 744447474, 744447477, 744447744, 744447747, 744447774, 744447777, 744474444, 744474447, 744474474, 744474477, 744474744, 744474747, 744474774, 744474777, 744477444, 744477447, 744477474, 744477477, 744477744, 744477747, 744477774, 744477777, 744744444, 744744447, 744744474, 744744477, 744744744, 744744747, 744744774, 744744777, 744747444, 744747447, 744747474, 744747477, 744747744, 744747747, 744747774, 744747777, 744774444, 744774447, 744774474, 744774477, 744774744, 744774747, 744774774, 744774777, 744777444, 744777447, 744777474, 744777477, 744777744, 744777747, 744777774, 744777777, 747444444, 747444447, 747444474, 747444477, 747444744, 747444747, 747444774, 747444777, 747447444, 747447447, 747447474, 747447477, 747447744, 747447747, 747447774, 747447777, 747474444, 747474447, 747474474, 747474477, 747474744, 747474747, 747474774, 747474777, 747477444, 747477447, 747477474, 747477477, 747477744, 747477747, 747477774, 747477777, 747744444, 747744447, 747744474, 747744477, 747744744, 747744747, 747744774, 747744777, 747747444, 747747447, 747747474, 747747477, 747747744, 747747747, 747747774, 747747777, 747774444, 747774447, 747774474, 747774477, 747774744, 747774747, 747774774, 747774777, 747777444, 747777447, 747777474, 747777477, 747777744, 747777747, 747777774, 747777777, 774444444, 774444447, 774444474, 774444477, 774444744, 774444747, 774444774, 774444777, 774447444, 774447447, 774447474, 774447477, 774447744, 774447747, 774447774, 774447777, 774474444, 774474447, 774474474, 774474477, 774474744, 774474747, 774474774, 774474777, 774477444, 774477447, 774477474, 774477477, 774477744, 774477747, 774477774, 774477777, 774744444, 774744447, 774744474, 774744477, 774744744, 774744747, 774744774, 774744777, 774747444, 774747447, 774747474, 774747477, 774747744, 774747747, 774747774, 774747777, 774774444, 774774447, 774774474, 774774477, 774774744, 774774747, 774774774, 774774777, 774777444, 774777447, 774777474, 774777477, 774777744, 774777747, 774777774, 774777777, 777444444, 777444447, 777444474, 777444477, 777444744, 777444747, 777444774, 777444777, 777447444, 777447447, 777447474, 777447477, 777447744, 777447747, 777447774, 777447777, 777474444, 777474447, 777474474, 777474477, 777474744, 777474747, 777474774, 777474777, 777477444, 777477447, 777477474, 777477477, 777477744, 777477747, 777477774, 777477777, 777744444, 777744447, 777744474, 777744477, 777744744, 777744747, 777744774, 777744777, 777747444, 777747447, 777747474, 777747477, 777747744, 777747747, 777747774, 777747777, 777774444, 777774447, 777774474, 777774477, 777774744, 777774747, 777774774, 777774777, 777777444, 777777447, 777777474, 777777477, 777777744, 777777747, 777777774, 777777777, 4444444444, 4444444447, 4444444474, 4444444477, 4444444744, 4444444747, 4444444774, 4444444777, 4444447444, 4444447447, 4444447474, 4444447477, 4444447744, 4444447747, 4444447774, 4444447777, 4444474444, 4444474447, 4444474474, 4444474477, 4444474744, 4444474747, 4444474774, 4444474777, 4444477444, 4444477447, 4444477474, 4444477477, 4444477744, 4444477747, 4444477774, 4444477777, 4444744444, 4444744447, 4444744474, 4444744477, 4444744744, 4444744747, 4444744774, 4444744777, 4444747444, 4444747447, 4444747474, 4444747477, 4444747744, 4444747747, 4444747774, 4444747777, 4444774444, 4444774447, 4444774474, 4444774477, 4444774744, 4444774747, 4444774774, 4444774777, 4444777444, 4444777447, 4444777474, 4444777477, 4444777744, 4444777747, 4444777774, 4444777777, 4447444444, 4447444447, 4447444474, 4447444477, 4447444744, 4447444747, 4447444774, 4447444777, 4447447444, 4447447447, 4447447474, 4447447477, 4447447744, 4447447747, 4447447774, 4447447777, 4447474444, 4447474447, 4447474474, 4447474477, 4447474744, 4447474747, 4447474774, 4447474777, 4447477444, 4447477447, 4447477474, 4447477477, 4447477744, 4447477747, 4447477774, 4447477777, 4447744444, 4447744447, 4447744474, 4447744477, 4447744744, 4447744747, 4447744774, 4447744777, 4447747444, 4447747447, 4447747474, 4447747477, 4447747744, 4447747747, 4447747774, 4447747777, 4447774444, 4447774447, 4447774474, 4447774477, 4447774744, 4447774747, 4447774774, 4447774777, 4447777444, 4447777447, 4447777474, 4447777477, 4447777744, 4447777747, 4447777774, 4447777777, 4474444444, 4474444447, 4474444474, 4474444477, 4474444744, 4474444747, 4474444774, 4474444777, 4474447444, 4474447447, 4474447474, 4474447477, 4474447744, 4474447747, 4474447774, 4474447777, 4474474444, 4474474447, 4474474474, 4474474477, 4474474744, 4474474747, 4474474774, 4474474777, 4474477444, 4474477447, 4474477474, 4474477477, 4474477744, 4474477747, 4474477774, 4474477777, 4474744444, 4474744447, 4474744474, 4474744477, 4474744744, 4474744747, 4474744774, 4474744777, 4474747444, 4474747447, 4474747474, 4474747477, 4474747744, 4474747747, 4474747774, 4474747777, 4474774444, 4474774447, 4474774474, 4474774477, 4474774744, 4474774747, 4474774774, 4474774777, 4474777444, 4474777447, 4474777474, 4474777477, 4474777744, 4474777747, 4474777774, 4474777777, 4477444444, 4477444447, 4477444474, 4477444477, 4477444744, 4477444747, 4477444774, 4477444777, 4477447444, 4477447447, 4477447474, 4477447477, 4477447744, 4477447747, 4477447774, 4477447777, 4477474444, 4477474447, 4477474474, 4477474477, 4477474744, 4477474747, 4477474774, 4477474777, 4477477444, 4477477447, 4477477474, 4477477477, 4477477744, 4477477747, 4477477774, 4477477777, 4477744444, 4477744447, 4477744474, 4477744477, 4477744744, 4477744747, 4477744774, 4477744777, 4477747444, 4477747447, 4477747474, 4477747477, 4477747744, 4477747747, 4477747774, 4477747777, 4477774444, 4477774447, 4477774474, 4477774477, 4477774744, 4477774747, 4477774774, 4477774777, 4477777444, 4477777447, 4477777474, 4477777477, 4477777744, 4477777747, 4477777774, 4477777777, 4744444444, 4744444447, 4744444474, 4744444477, 4744444744, 4744444747, 4744444774, 4744444777, 4744447444, 4744447447, 4744447474, 4744447477, 4744447744, 4744447747, 4744447774, 4744447777, 4744474444, 4744474447, 4744474474, 4744474477, 4744474744, 4744474747, 4744474774, 4744474777, 4744477444, 4744477447, 4744477474, 4744477477, 4744477744, 4744477747, 4744477774, 4744477777, 4744744444, 4744744447, 4744744474, 4744744477, 4744744744, 4744744747, 4744744774, 4744744777, 4744747444, 4744747447, 4744747474, 4744747477, 4744747744, 4744747747, 4744747774, 4744747777, 4744774444, 4744774447, 4744774474, 4744774477, 4744774744, 4744774747, 4744774774, 4744774777, 4744777444, 4744777447, 4744777474, 4744777477, 4744777744, 4744777747, 4744777774, 4744777777, 4747444444, 4747444447, 4747444474, 4747444477, 4747444744, 4747444747, 4747444774, 4747444777, 4747447444, 4747447447, 4747447474, 4747447477, 4747447744, 4747447747, 4747447774, 4747447777, 4747474444, 4747474447, 4747474474, 4747474477, 4747474744, 4747474747, 4747474774, 4747474777, 4747477444, 4747477447, 4747477474, 4747477477, 4747477744, 4747477747, 4747477774, 4747477777, 4747744444, 4747744447, 4747744474, 4747744477, 4747744744, 4747744747, 4747744774, 4747744777, 4747747444, 4747747447, 4747747474, 4747747477, 4747747744, 4747747747, 4747747774, 4747747777, 4747774444, 4747774447, 4747774474, 4747774477, 4747774744, 4747774747, 4747774774, 4747774777, 4747777444, 4747777447, 4747777474, 4747777477, 4747777744, 4747777747, 4747777774, 4747777777, 4774444444, 4774444447, 4774444474, 4774444477, 4774444744, 4774444747, 4774444774, 4774444777, 4774447444, 4774447447, 4774447474, 4774447477, 4774447744, 4774447747, 4774447774, 4774447777, 4774474444, 4774474447, 4774474474, 4774474477, 4774474744, 4774474747, 4774474774, 4774474777, 4774477444, 4774477447, 4774477474, 4774477477, 4774477744, 4774477747, 4774477774, 4774477777, 4774744444, 4774744447, 4774744474, 4774744477, 4774744744, 4774744747, 4774744774, 4774744777, 4774747444, 4774747447, 4774747474, 4774747477, 4774747744, 4774747747, 4774747774, 4774747777, 4774774444, 4774774447, 4774774474, 4774774477, 4774774744, 4774774747, 4774774774, 4774774777, 4774777444, 4774777447, 4774777474, 4774777477, 4774777744, 4774777747, 4774777774, 4774777777, 4777444444, 4777444447, 4777444474, 4777444477, 4777444744, 4777444747, 4777444774, 4777444777, 4777447444, 4777447447, 4777447474, 4777447477, 4777447744, 4777447747, 4777447774, 4777447777, 4777474444, 4777474447, 4777474474, 4777474477, 4777474744, 4777474747, 4777474774, 4777474777, 4777477444, 4777477447, 4777477474, 4777477477, 4777477744, 4777477747, 4777477774, 4777477777, 4777744444, 4777744447, 4777744474, 4777744477, 4777744744, 4777744747, 4777744774, 4777744777, 4777747444, 4777747447, 4777747474, 4777747477, 4777747744, 4777747747, 4777747774, 4777747777, 4777774444, 4777774447, 4777774474, 4777774477, 4777774744, 4777774747, 4777774774, 4777774777, 4777777444, 4777777447, 4777777474, 4777777477, 4777777744, 4777777747, 4777777774, 4777777777, 7444444444, 7444444447, 7444444474, 7444444477, 7444444744, 7444444747, 7444444774, 7444444777, 7444447444, 7444447447, 7444447474, 7444447477, 7444447744, 7444447747, 7444447774, 7444447777, 7444474444, 7444474447, 7444474474, 7444474477, 7444474744, 7444474747, 7444474774, 7444474777, 7444477444, 7444477447, 7444477474, 7444477477, 7444477744, 7444477747, 7444477774, 7444477777, 7444744444, 7444744447, 7444744474, 7444744477, 7444744744, 7444744747, 7444744774, 7444744777, 7444747444, 7444747447, 7444747474, 7444747477, 7444747744, 7444747747, 7444747774, 7444747777, 7444774444, 7444774447, 7444774474, 7444774477, 7444774744, 7444774747, 7444774774, 7444774777, 7444777444, 7444777447, 7444777474, 7444777477, 7444777744, 7444777747, 7444777774, 7444777777, 7447444444, 7447444447, 7447444474, 7447444477, 7447444744, 7447444747, 7447444774, 7447444777, 7447447444, 7447447447, 7447447474, 7447447477, 7447447744, 7447447747, 7447447774, 7447447777, 7447474444, 7447474447, 7447474474, 7447474477, 7447474744, 7447474747, 7447474774, 7447474777, 7447477444, 7447477447, 7447477474, 7447477477, 7447477744, 7447477747, 7447477774, 7447477777, 7447744444, 7447744447, 7447744474, 7447744477, 7447744744, 7447744747, 7447744774, 7447744777, 7447747444, 7447747447, 7447747474, 7447747477, 7447747744, 7447747747, 7447747774, 7447747777, 7447774444, 7447774447, 7447774474, 7447774477, 7447774744, 7447774747, 7447774774, 7447774777, 7447777444, 7447777447, 7447777474, 7447777477, 7447777744, 7447777747, 7447777774, 7447777777, 7474444444, 7474444447, 7474444474, 7474444477, 7474444744, 7474444747, 7474444774, 7474444777, 7474447444, 7474447447, 7474447474, 7474447477, 7474447744, 7474447747, 7474447774, 7474447777, 7474474444, 7474474447, 7474474474, 7474474477, 7474474744, 7474474747, 7474474774, 7474474777, 7474477444, 7474477447, 7474477474, 7474477477, 7474477744, 7474477747, 7474477774, 7474477777, 7474744444, 7474744447, 7474744474, 7474744477, 7474744744, 7474744747, 7474744774, 7474744777, 7474747444, 7474747447, 7474747474, 7474747477, 7474747744, 7474747747, 7474747774, 7474747777, 7474774444, 7474774447, 7474774474, 7474774477, 7474774744, 7474774747, 7474774774, 7474774777, 7474777444, 7474777447, 7474777474, 7474777477, 7474777744, 7474777747, 7474777774, 7474777777, 7477444444, 7477444447, 7477444474, 7477444477, 7477444744, 7477444747, 7477444774, 7477444777, 7477447444, 7477447447, 7477447474, 7477447477, 7477447744, 7477447747, 7477447774, 7477447777, 7477474444, 7477474447, 7477474474, 7477474477, 7477474744, 7477474747, 7477474774, 7477474777, 7477477444, 7477477447, 7477477474, 7477477477, 7477477744, 7477477747, 7477477774, 7477477777, 7477744444, 7477744447, 7477744474, 7477744477, 7477744744, 7477744747, 7477744774, 7477744777, 7477747444, 7477747447, 7477747474, 7477747477, 7477747744, 7477747747, 7477747774, 7477747777, 7477774444, 7477774447, 7477774474, 7477774477, 7477774744, 7477774747, 7477774774, 7477774777, 7477777444, 7477777447, 7477777474, 7477777477, 7477777744, 7477777747, 7477777774, 7477777777, 7744444444, 7744444447, 7744444474, 7744444477, 7744444744, 7744444747, 7744444774, 7744444777, 7744447444, 7744447447, 7744447474, 7744447477, 7744447744, 7744447747, 7744447774, 7744447777, 7744474444, 7744474447, 7744474474, 7744474477, 7744474744, 7744474747, 7744474774, 7744474777, 7744477444, 7744477447, 7744477474, 7744477477, 7744477744, 7744477747, 7744477774, 7744477777, 7744744444, 7744744447, 7744744474, 7744744477, 7744744744, 7744744747, 7744744774, 7744744777, 7744747444, 7744747447, 7744747474, 7744747477, 7744747744, 7744747747, 7744747774, 7744747777, 7744774444, 7744774447, 7744774474, 7744774477, 7744774744, 7744774747, 7744774774, 7744774777, 7744777444, 7744777447, 7744777474, 7744777477, 7744777744, 7744777747, 7744777774, 7744777777, 7747444444, 7747444447, 7747444474, 7747444477, 7747444744, 7747444747, 7747444774, 7747444777, 7747447444, 7747447447, 7747447474, 7747447477, 7747447744, 7747447747, 7747447774, 7747447777, 7747474444, 7747474447, 7747474474, 7747474477, 7747474744, 7747474747, 7747474774, 7747474777, 7747477444, 7747477447, 7747477474, 7747477477, 7747477744, 7747477747, 7747477774, 7747477777, 7747744444, 7747744447, 7747744474, 7747744477, 7747744744, 7747744747, 7747744774, 7747744777, 7747747444, 7747747447, 7747747474, 7747747477, 7747747744, 7747747747, 7747747774, 7747747777, 7747774444, 7747774447, 7747774474, 7747774477, 7747774744, 7747774747, 7747774774, 7747774777, 7747777444, 7747777447, 7747777474, 7747777477, 7747777744, 7747777747, 7747777774, 7747777777, 7774444444, 7774444447, 7774444474, 7774444477, 7774444744, 7774444747, 7774444774, 7774444777, 7774447444, 7774447447, 7774447474, 7774447477, 7774447744, 7774447747, 7774447774, 7774447777, 7774474444, 7774474447, 7774474474, 7774474477, 7774474744, 7774474747, 7774474774, 7774474777, 7774477444, 7774477447, 7774477474, 7774477477, 7774477744, 7774477747, 7774477774, 7774477777, 7774744444, 7774744447, 7774744474, 7774744477, 7774744744, 7774744747, 7774744774, 7774744777, 7774747444, 7774747447, 7774747474, 7774747477, 7774747744, 7774747747, 7774747774, 7774747777, 7774774444, 7774774447, 7774774474, 7774774477, 7774774744, 7774774747, 7774774774, 7774774777, 7774777444, 7774777447, 7774777474, 7774777477, 7774777744, 7774777747, 7774777774, 7774777777, 7777444444, 7777444447, 7777444474, 7777444477, 7777444744, 7777444747, 7777444774, 7777444777, 7777447444, 7777447447, 7777447474, 7777447477, 7777447744, 7777447747, 7777447774, 7777447777, 7777474444, 7777474447, 7777474474, 7777474477, 7777474744, 7777474747, 7777474774, 7777474777, 7777477444, 7777477447, 7777477474, 7777477477, 7777477744, 7777477747, 7777477774, 7777477777, 7777744444, 7777744447, 7777744474, 7777744477, 7777744744, 7777744747, 7777744774, 7777744777, 7777747444, 7777747447, 7777747474, 7777747477, 7777747744, 7777747747, 7777747774, 7777747777, 7777774444, 7777774447, 7777774474, 7777774477, 7777774744, 7777774747, 7777774774, 7777774777, 7777777444, 7777777447, 7777777474, 7777777477, 7777777744, 7777777747, 7777777774, 7777777777, 44444444444, 44444444447, 44444444474, 44444444477, 44444444744, 44444444747, 44444444774, 44444444777, 44444447444, 44444447447, 44444447474, 44444447477, 44444447744, 44444447747, 44444447774, 44444447777, 44444474444, 44444474447, 44444474474, 44444474477, 44444474744, 44444474747, 44444474774, 44444474777, 44444477444, 44444477447, 44444477474, 44444477477, 44444477744, 44444477747, 44444477774, 44444477777, 44444744444, 44444744447, 44444744474, 44444744477, 44444744744, 44444744747, 44444744774, 44444744777, 44444747444, 44444747447, 44444747474, 44444747477, 44444747744, 44444747747, 44444747774, 44444747777, 44444774444, 44444774447, 44444774474, 44444774477, 44444774744, 44444774747, 44444774774, 44444774777, 44444777444, 44444777447, 44444777474, 44444777477, 44444777744, 44444777747, 44444777774, 44444777777, 44447444444, 44447444447, 44447444474, 44447444477, 44447444744, 44447444747, 44447444774, 44447444777, 44447447444, 44447447447, 44447447474, 44447447477, 44447447744, 44447447747, 44447447774, 44447447777, 44447474444, 44447474447, 44447474474, 44447474477, 44447474744, 44447474747, 44447474774, 44447474777, 44447477444, 44447477447, 44447477474, 44447477477, 44447477744, 44447477747, 44447477774, 44447477777, 44447744444, 44447744447, 44447744474, 44447744477, 44447744744, 44447744747, 44447744774, 44447744777, 44447747444, 44447747447, 44447747474, 44447747477, 44447747744, 44447747747, 44447747774, 44447747777, 44447774444, 44447774447, 44447774474, 44447774477, 44447774744, 44447774747, 44447774774, 44447774777, 44447777444, 44447777447, 44447777474, 44447777477, 44447777744, 44447777747, 44447777774, 44447777777, 44474444444, 44474444447, 44474444474, 44474444477, 44474444744, 44474444747, 44474444774, 44474444777, 44474447444, 44474447447, 44474447474, 44474447477, 44474447744, 44474447747, 44474447774, 44474447777, 44474474444, 44474474447, 44474474474, 44474474477, 44474474744, 44474474747, 44474474774, 44474474777, 44474477444, 44474477447, 44474477474, 44474477477, 44474477744, 44474477747, 44474477774, 44474477777, 44474744444, 44474744447, 44474744474, 44474744477, 44474744744, 44474744747, 44474744774, 44474744777, 44474747444, 44474747447, 44474747474, 44474747477, 44474747744, 44474747747, 44474747774, 44474747777, 44474774444, 44474774447, 44474774474, 44474774477, 44474774744, 44474774747, 44474774774, 44474774777, 44474777444, 44474777447, 44474777474, 44474777477, 44474777744, 44474777747, 44474777774, 44474777777, 44477444444, 44477444447, 44477444474, 44477444477, 44477444744, 44477444747, 44477444774, 44477444777, 44477447444, 44477447447, 44477447474, 44477447477, 44477447744, 44477447747, 44477447774, 44477447777, 44477474444, 44477474447, 44477474474, 44477474477, 44477474744, 44477474747, 44477474774, 44477474777, 44477477444, 44477477447, 44477477474, 44477477477, 44477477744, 44477477747, 44477477774, 44477477777, 44477744444, 44477744447, 44477744474, 44477744477, 44477744744, 44477744747, 44477744774, 44477744777, 44477747444, 44477747447, 44477747474, 44477747477, 44477747744, 44477747747, 44477747774, 44477747777, 44477774444, 44477774447, 44477774474, 44477774477, 44477774744, 44477774747, 44477774774, 44477774777, 44477777444, 44477777447, 44477777474, 44477777477, 44477777744, 44477777747, 44477777774, 44477777777, 44744444444, 44744444447, 44744444474, 44744444477, 44744444744, 44744444747, 44744444774, 44744444777, 44744447444, 44744447447, 44744447474, 44744447477, 44744447744, 44744447747, 44744447774, 44744447777, 44744474444, 44744474447, 44744474474, 44744474477, 44744474744, 44744474747, 44744474774, 44744474777, 44744477444, 44744477447, 44744477474, 44744477477, 44744477744, 44744477747, 44744477774, 44744477777, 44744744444, 44744744447, 44744744474, 44744744477, 44744744744, 44744744747, 44744744774, 44744744777, 44744747444, 44744747447, 44744747474, 44744747477, 44744747744, 44744747747, 44744747774, 44744747777, 44744774444, 44744774447, 44744774474, 44744774477, 44744774744, 44744774747, 44744774774, 44744774777, 44744777444, 44744777447, 44744777474, 44744777477, 44744777744, 44744777747, 44744777774, 44744777777, 44747444444, 44747444447, 44747444474, 44747444477, 44747444744, 44747444747, 44747444774, 44747444777, 44747447444, 44747447447, 44747447474, 44747447477, 44747447744, 44747447747, 44747447774, 44747447777, 44747474444, 44747474447, 44747474474, 44747474477, 44747474744, 44747474747, 44747474774, 44747474777, 44747477444, 44747477447, 44747477474, 44747477477, 44747477744, 44747477747, 44747477774, 44747477777, 44747744444, 44747744447, 44747744474, 44747744477, 44747744744, 44747744747, 44747744774, 44747744777, 44747747444, 44747747447, 44747747474, 44747747477, 44747747744, 44747747747, 44747747774, 44747747777, 44747774444, 44747774447, 44747774474, 44747774477, 44747774744, 44747774747, 44747774774, 44747774777, 44747777444, 44747777447, 44747777474, 44747777477, 44747777744, 44747777747, 44747777774, 44747777777, 44774444444, 44774444447, 44774444474, 44774444477, 44774444744, 44774444747, 44774444774, 44774444777, 44774447444, 44774447447, 44774447474, 44774447477, 44774447744, 44774447747, 44774447774, 44774447777, 44774474444, 44774474447, 44774474474, 44774474477, 44774474744, 44774474747, 44774474774, 44774474777, 44774477444, 44774477447, 44774477474, 44774477477, 44774477744, 44774477747, 44774477774, 44774477777, 44774744444, 44774744447, 44774744474, 44774744477, 44774744744, 44774744747, 44774744774, 44774744777, 44774747444, 44774747447, 44774747474, 44774747477, 44774747744, 44774747747, 44774747774, 44774747777, 44774774444, 44774774447, 44774774474, 44774774477, 44774774744, 44774774747, 44774774774, 44774774777, 44774777444, 44774777447, 44774777474, 44774777477, 44774777744, 44774777747, 44774777774, 44774777777, 44777444444, 44777444447, 44777444474, 44777444477, 44777444744, 44777444747, 44777444774, 44777444777, 44777447444, 44777447447, 44777447474, 44777447477, 44777447744, 44777447747, 44777447774, 44777447777, 44777474444, 44777474447, 44777474474, 44777474477, 44777474744, 44777474747, 44777474774, 44777474777, 44777477444, 44777477447, 44777477474, 44777477477, 44777477744, 44777477747, 44777477774, 44777477777, 44777744444, 44777744447, 44777744474, 44777744477, 44777744744, 44777744747, 44777744774, 44777744777, 44777747444, 44777747447, 44777747474, 44777747477, 44777747744, 44777747747, 44777747774, 44777747777, 44777774444, 44777774447, 44777774474, 44777774477, 44777774744, 44777774747, 44777774774, 44777774777, 44777777444, 44777777447, 44777777474, 44777777477, 44777777744, 44777777747, 44777777774, 44777777777, 47444444444, 47444444447, 47444444474, 47444444477, 47444444744, 47444444747, 47444444774, 47444444777, 47444447444, 47444447447, 47444447474, 47444447477, 47444447744, 47444447747, 47444447774, 47444447777, 47444474444, 47444474447, 47444474474, 47444474477, 47444474744, 47444474747, 47444474774, 47444474777, 47444477444, 47444477447, 47444477474, 47444477477, 47444477744, 47444477747, 47444477774, 47444477777, 47444744444, 47444744447, 47444744474, 47444744477, 47444744744, 47444744747, 47444744774, 47444744777, 47444747444, 47444747447, 47444747474, 47444747477, 47444747744, 47444747747, 47444747774, 47444747777, 47444774444, 47444774447, 47444774474, 47444774477, 47444774744, 47444774747, 47444774774, 47444774777, 47444777444, 47444777447, 47444777474, 47444777477, 47444777744, 47444777747, 47444777774, 47444777777, 47447444444, 47447444447, 47447444474, 47447444477, 47447444744, 47447444747, 47447444774, 47447444777, 47447447444, 47447447447, 47447447474, 47447447477, 47447447744, 47447447747, 47447447774, 47447447777, 47447474444, 47447474447, 47447474474, 47447474477, 47447474744, 47447474747, 47447474774, 47447474777, 47447477444, 47447477447, 47447477474, 47447477477, 47447477744, 47447477747, 47447477774, 47447477777, 47447744444, 47447744447, 47447744474, 47447744477, 47447744744, 47447744747, 47447744774, 47447744777, 47447747444, 47447747447, 47447747474, 47447747477, 47447747744, 47447747747, 47447747774, 47447747777, 47447774444, 47447774447, 47447774474, 47447774477, 47447774744, 47447774747, 47447774774, 47447774777, 47447777444, 47447777447, 47447777474, 47447777477, 47447777744, 47447777747, 47447777774, 47447777777, 47474444444, 47474444447, 47474444474, 47474444477, 47474444744, 47474444747, 47474444774, 47474444777, 47474447444, 47474447447, 47474447474, 47474447477, 47474447744, 47474447747, 47474447774, 47474447777, 47474474444, 47474474447, 47474474474, 47474474477, 47474474744, 47474474747, 47474474774, 47474474777, 47474477444, 47474477447, 47474477474, 47474477477, 47474477744, 47474477747, 47474477774, 47474477777, 47474744444, 47474744447, 47474744474, 47474744477, 47474744744, 47474744747, 47474744774, 47474744777, 47474747444, 47474747447, 47474747474, 47474747477, 47474747744, 47474747747, 47474747774, 47474747777, 47474774444, 47474774447, 47474774474, 47474774477, 47474774744, 47474774747, 47474774774, 47474774777, 47474777444, 47474777447, 47474777474, 47474777477, 47474777744, 47474777747, 47474777774, 47474777777, 47477444444, 47477444447, 47477444474, 47477444477, 47477444744, 47477444747, 47477444774, 47477444777, 47477447444, 47477447447, 47477447474, 47477447477, 47477447744, 47477447747, 47477447774, 47477447777, 47477474444, 47477474447, 47477474474, 47477474477, 47477474744, 47477474747, 47477474774, 47477474777, 47477477444, 47477477447, 47477477474, 47477477477, 47477477744, 47477477747, 47477477774, 47477477777, 47477744444, 47477744447, 47477744474, 47477744477, 47477744744, 47477744747, 47477744774, 47477744777, 47477747444, 47477747447, 47477747474, 47477747477, 47477747744, 47477747747, 47477747774, 47477747777, 47477774444, 47477774447, 47477774474, 47477774477, 47477774744, 47477774747, 47477774774, 47477774777, 47477777444, 47477777447, 47477777474, 47477777477, 47477777744, 47477777747, 47477777774, 47477777777, 47744444444, 47744444447, 47744444474, 47744444477, 47744444744, 47744444747, 47744444774, 47744444777, 47744447444, 47744447447, 47744447474, 47744447477, 47744447744, 47744447747, 47744447774, 47744447777, 47744474444, 47744474447, 47744474474, 47744474477, 47744474744, 47744474747, 47744474774, 47744474777, 47744477444, 47744477447, 47744477474, 47744477477, 47744477744, 47744477747, 47744477774, 47744477777, 47744744444, 47744744447, 47744744474, 47744744477, 47744744744, 47744744747, 47744744774, 47744744777, 47744747444, 47744747447, 47744747474, 47744747477, 47744747744, 47744747747, 47744747774, 47744747777, 47744774444, 47744774447, 47744774474, 47744774477, 47744774744, 47744774747, 47744774774, 47744774777, 47744777444, 47744777447, 47744777474, 47744777477, 47744777744, 47744777747, 47744777774, 47744777777, 47747444444, 47747444447, 47747444474, 47747444477, 47747444744, 47747444747, 47747444774, 47747444777, 47747447444, 47747447447, 47747447474, 47747447477, 47747447744, 47747447747, 47747447774, 47747447777, 47747474444, 47747474447, 47747474474, 47747474477, 47747474744, 47747474747, 47747474774, 47747474777, 47747477444, 47747477447, 47747477474, 47747477477, 47747477744, 47747477747, 47747477774, 47747477777, 47747744444, 47747744447, 47747744474, 47747744477, 47747744744, 47747744747, 47747744774, 47747744777, 47747747444, 47747747447, 47747747474, 47747747477, 47747747744, 47747747747, 47747747774, 47747747777, 47747774444, 47747774447, 47747774474, 47747774477, 47747774744, 47747774747, 47747774774, 47747774777, 47747777444, 47747777447, 47747777474, 47747777477, 47747777744, 47747777747, 47747777774, 47747777777, 47774444444, 47774444447, 47774444474, 47774444477, 47774444744, 47774444747, 47774444774, 47774444777, 47774447444, 47774447447, 47774447474, 47774447477, 47774447744, 47774447747, 47774447774, 47774447777, 47774474444, 47774474447, 47774474474, 47774474477, 47774474744, 47774474747, 47774474774, 47774474777, 47774477444, 47774477447, 47774477474, 47774477477, 47774477744, 47774477747, 47774477774, 47774477777, 47774744444, 47774744447, 47774744474, 47774744477, 47774744744, 47774744747, 47774744774, 47774744777, 47774747444, 47774747447, 47774747474, 47774747477, 47774747744, 47774747747, 47774747774, 47774747777, 47774774444, 47774774447, 47774774474, 47774774477, 47774774744, 47774774747, 47774774774, 47774774777, 47774777444, 47774777447, 47774777474, 47774777477, 47774777744, 47774777747, 47774777774, 47774777777, 47777444444, 47777444447, 47777444474, 47777444477, 47777444744, 47777444747, 47777444774, 47777444777, 47777447444, 47777447447, 47777447474, 47777447477, 47777447744, 47777447747, 47777447774, 47777447777, 47777474444, 47777474447, 47777474474, 47777474477, 47777474744, 47777474747, 47777474774, 47777474777, 47777477444, 47777477447, 47777477474, 47777477477, 47777477744, 47777477747, 47777477774, 47777477777, 47777744444, 47777744447, 47777744474, 47777744477, 47777744744, 47777744747, 47777744774, 47777744777, 47777747444, 47777747447, 47777747474, 47777747477, 47777747744, 47777747747, 47777747774, 47777747777, 47777774444, 47777774447, 47777774474, 47777774477, 47777774744, 47777774747, 47777774774, 47777774777, 47777777444, 47777777447, 47777777474, 47777777477, 47777777744, 47777777747, 47777777774, 47777777777, 74444444444, 74444444447, 74444444474, 74444444477, 74444444744, 74444444747, 74444444774, 74444444777, 74444447444, 74444447447, 74444447474, 74444447477, 74444447744, 74444447747, 74444447774, 74444447777, 74444474444, 74444474447, 74444474474, 74444474477, 74444474744, 74444474747, 74444474774, 74444474777, 74444477444, 74444477447, 74444477474, 74444477477, 74444477744, 74444477747, 74444477774, 74444477777, 74444744444, 74444744447, 74444744474, 74444744477, 74444744744, 74444744747, 74444744774, 74444744777, 74444747444, 74444747447, 74444747474, 74444747477, 74444747744, 74444747747, 74444747774, 74444747777, 74444774444, 74444774447, 74444774474, 74444774477, 74444774744, 74444774747, 74444774774, 74444774777, 74444777444, 74444777447, 74444777474, 74444777477, 74444777744, 74444777747, 74444777774, 74444777777, 74447444444, 74447444447, 74447444474, 74447444477, 74447444744, 74447444747, 74447444774, 74447444777, 74447447444, 74447447447, 74447447474, 74447447477, 74447447744, 74447447747, 74447447774, 74447447777, 74447474444, 74447474447, 74447474474, 74447474477, 74447474744, 74447474747, 74447474774, 74447474777, 74447477444, 74447477447, 74447477474, 74447477477, 74447477744, 74447477747, 74447477774, 74447477777, 74447744444, 74447744447, 74447744474, 74447744477, 74447744744, 74447744747, 74447744774, 74447744777, 74447747444, 74447747447, 74447747474, 74447747477, 74447747744, 74447747747, 74447747774, 74447747777, 74447774444, 74447774447, 74447774474, 74447774477, 74447774744, 74447774747, 74447774774, 74447774777, 74447777444, 74447777447, 74447777474, 74447777477, 74447777744, 74447777747, 74447777774, 74447777777, 74474444444, 74474444447, 74474444474, 74474444477, 74474444744, 74474444747, 74474444774, 74474444777, 74474447444, 74474447447, 74474447474, 74474447477, 74474447744, 74474447747, 74474447774, 74474447777, 74474474444, 74474474447, 74474474474, 74474474477, 74474474744, 74474474747, 74474474774, 74474474777, 74474477444, 74474477447, 74474477474, 74474477477, 74474477744, 74474477747, 74474477774, 74474477777, 74474744444, 74474744447, 74474744474, 74474744477, 74474744744, 74474744747, 74474744774, 74474744777, 74474747444, 74474747447, 74474747474, 74474747477, 74474747744, 74474747747, 74474747774, 74474747777, 74474774444, 74474774447, 74474774474, 74474774477, 74474774744, 74474774747, 74474774774, 74474774777, 74474777444, 74474777447, 74474777474, 74474777477, 74474777744, 74474777747, 74474777774, 74474777777, 74477444444, 74477444447, 74477444474, 74477444477, 74477444744, 74477444747, 74477444774, 74477444777, 74477447444, 74477447447, 74477447474, 74477447477, 74477447744, 74477447747, 74477447774, 74477447777, 74477474444, 74477474447, 74477474474, 74477474477, 74477474744, 74477474747, 74477474774, 74477474777, 74477477444, 74477477447, 74477477474, 74477477477, 74477477744, 74477477747, 74477477774, 74477477777, 74477744444, 74477744447, 74477744474, 74477744477, 74477744744, 74477744747, 74477744774, 74477744777, 74477747444, 74477747447, 74477747474, 74477747477, 74477747744, 74477747747, 74477747774, 74477747777, 74477774444, 74477774447, 74477774474, 74477774477, 74477774744, 74477774747, 74477774774, 74477774777, 74477777444, 74477777447, 74477777474, 74477777477, 74477777744, 74477777747, 74477777774, 74477777777, 74744444444, 74744444447, 74744444474, 74744444477, 74744444744, 74744444747, 74744444774, 74744444777, 74744447444, 74744447447, 74744447474, 74744447477, 74744447744, 74744447747, 74744447774, 74744447777, 74744474444, 74744474447, 74744474474, 74744474477, 74744474744, 74744474747, 74744474774, 74744474777, 74744477444, 74744477447, 74744477474, 74744477477, 74744477744, 74744477747, 74744477774, 74744477777, 74744744444, 74744744447, 74744744474, 74744744477, 74744744744, 74744744747, 74744744774, 74744744777, 74744747444, 74744747447, 74744747474, 74744747477, 74744747744, 74744747747, 74744747774, 74744747777, 74744774444, 74744774447, 74744774474, 74744774477, 74744774744, 74744774747, 74744774774, 74744774777, 74744777444, 74744777447, 74744777474, 74744777477, 74744777744, 74744777747, 74744777774, 74744777777, 74747444444, 74747444447, 74747444474, 74747444477, 74747444744, 74747444747, 74747444774, 74747444777, 74747447444, 74747447447, 74747447474, 74747447477, 74747447744, 74747447747, 74747447774, 74747447777, 74747474444, 74747474447, 74747474474, 74747474477, 74747474744, 74747474747, 74747474774, 74747474777, 74747477444, 74747477447, 74747477474, 74747477477, 74747477744, 74747477747, 74747477774, 74747477777, 74747744444, 74747744447, 74747744474, 74747744477, 74747744744, 74747744747, 74747744774, 74747744777, 74747747444, 74747747447, 74747747474, 74747747477, 74747747744, 74747747747, 74747747774, 74747747777, 74747774444, 74747774447, 74747774474, 74747774477, 74747774744, 74747774747, 74747774774, 74747774777, 74747777444, 74747777447, 74747777474, 74747777477, 74747777744, 74747777747, 74747777774, 74747777777, 74774444444, 74774444447, 74774444474, 74774444477, 74774444744, 74774444747, 74774444774, 74774444777, 74774447444, 74774447447, 74774447474, 74774447477, 74774447744, 74774447747, 74774447774, 74774447777, 74774474444, 74774474447, 74774474474, 74774474477, 74774474744, 74774474747, 74774474774, 74774474777, 74774477444, 74774477447, 74774477474, 74774477477, 74774477744, 74774477747, 74774477774, 74774477777, 74774744444, 74774744447, 74774744474, 74774744477, 74774744744, 74774744747, 74774744774, 74774744777, 74774747444, 74774747447, 74774747474, 74774747477, 74774747744, 74774747747, 74774747774, 74774747777, 74774774444, 74774774447, 74774774474, 74774774477, 74774774744, 74774774747, 74774774774, 74774774777, 74774777444, 74774777447, 74774777474, 74774777477, 74774777744, 74774777747, 74774777774, 74774777777, 74777444444, 74777444447, 74777444474, 74777444477, 74777444744, 74777444747, 74777444774, 74777444777, 74777447444, 74777447447, 74777447474, 74777447477, 74777447744, 74777447747, 74777447774, 74777447777, 74777474444, 74777474447, 74777474474, 74777474477, 74777474744, 74777474747, 74777474774, 74777474777, 74777477444, 74777477447, 74777477474, 74777477477, 74777477744, 74777477747, 74777477774, 74777477777, 74777744444, 74777744447, 74777744474, 74777744477, 74777744744, 74777744747, 74777744774, 74777744777, 74777747444, 74777747447, 74777747474, 74777747477, 74777747744, 74777747747, 74777747774, 74777747777, 74777774444, 74777774447, 74777774474, 74777774477, 74777774744, 74777774747, 74777774774, 74777774777, 74777777444, 74777777447, 74777777474, 74777777477, 74777777744, 74777777747, 74777777774, 74777777777, 77444444444, 77444444447, 77444444474, 77444444477, 77444444744, 77444444747, 77444444774, 77444444777, 77444447444, 77444447447, 77444447474, 77444447477, 77444447744, 77444447747, 77444447774, 77444447777, 77444474444, 77444474447, 77444474474, 77444474477, 77444474744, 77444474747, 77444474774, 77444474777, 77444477444, 77444477447, 77444477474, 77444477477, 77444477744, 77444477747, 77444477774, 77444477777, 77444744444, 77444744447, 77444744474, 77444744477, 77444744744, 77444744747, 77444744774, 77444744777, 77444747444, 77444747447, 77444747474, 77444747477, 77444747744, 77444747747, 77444747774, 77444747777, 77444774444, 77444774447, 77444774474, 77444774477, 77444774744, 77444774747, 77444774774, 77444774777, 77444777444, 77444777447, 77444777474, 77444777477, 77444777744, 77444777747, 77444777774, 77444777777, 77447444444, 77447444447, 77447444474, 77447444477, 77447444744, 77447444747, 77447444774, 77447444777, 77447447444, 77447447447, 77447447474, 77447447477, 77447447744, 77447447747, 77447447774, 77447447777, 77447474444, 77447474447, 77447474474, 77447474477, 77447474744, 77447474747, 77447474774, 77447474777, 77447477444, 77447477447, 77447477474, 77447477477, 77447477744, 77447477747, 77447477774, 77447477777, 77447744444, 77447744447, 77447744474, 77447744477, 77447744744, 77447744747, 77447744774, 77447744777, 77447747444, 77447747447, 77447747474, 77447747477, 77447747744, 77447747747, 77447747774, 77447747777, 77447774444, 77447774447, 77447774474, 77447774477, 77447774744, 77447774747, 77447774774, 77447774777, 77447777444, 77447777447, 77447777474, 77447777477, 77447777744, 77447777747, 77447777774, 77447777777, 77474444444, 77474444447, 77474444474, 77474444477, 77474444744, 77474444747, 77474444774, 77474444777, 77474447444, 77474447447, 77474447474, 77474447477, 77474447744, 77474447747, 77474447774, 77474447777, 77474474444, 77474474447, 77474474474, 77474474477, 77474474744, 77474474747, 77474474774, 77474474777, 77474477444, 77474477447, 77474477474, 77474477477, 77474477744, 77474477747, 77474477774, 77474477777, 77474744444, 77474744447, 77474744474, 77474744477, 77474744744, 77474744747, 77474744774, 77474744777, 77474747444, 77474747447, 77474747474, 77474747477, 77474747744, 77474747747, 77474747774, 77474747777, 77474774444, 77474774447, 77474774474, 77474774477, 77474774744, 77474774747, 77474774774, 77474774777, 77474777444, 77474777447, 77474777474, 77474777477, 77474777744, 77474777747, 77474777774, 77474777777, 77477444444, 77477444447, 77477444474, 77477444477, 77477444744, 77477444747, 77477444774, 77477444777, 77477447444, 77477447447, 77477447474, 77477447477, 77477447744, 77477447747, 77477447774, 77477447777, 77477474444, 77477474447, 77477474474, 77477474477, 77477474744, 77477474747, 77477474774, 77477474777, 77477477444, 77477477447, 77477477474, 77477477477, 77477477744, 77477477747, 77477477774, 77477477777, 77477744444, 77477744447, 77477744474, 77477744477, 77477744744, 77477744747, 77477744774, 77477744777, 77477747444, 77477747447, 77477747474, 77477747477, 77477747744, 77477747747, 77477747774, 77477747777, 77477774444, 77477774447, 77477774474, 77477774477, 77477774744, 77477774747, 77477774774, 77477774777, 77477777444, 77477777447, 77477777474, 77477777477, 77477777744, 77477777747, 77477777774, 77477777777, 77744444444, 77744444447, 77744444474, 77744444477, 77744444744, 77744444747, 77744444774, 77744444777, 77744447444, 77744447447, 77744447474, 77744447477, 77744447744, 77744447747, 77744447774, 77744447777, 77744474444, 77744474447, 77744474474, 77744474477, 77744474744, 77744474747, 77744474774, 77744474777, 77744477444, 77744477447, 77744477474, 77744477477, 77744477744, 77744477747, 77744477774, 77744477777, 77744744444, 77744744447, 77744744474, 77744744477, 77744744744, 77744744747, 77744744774, 77744744777, 77744747444, 77744747447, 77744747474, 77744747477, 77744747744, 77744747747, 77744747774, 77744747777, 77744774444, 77744774447, 77744774474, 77744774477, 77744774744, 77744774747, 77744774774, 77744774777, 77744777444, 77744777447, 77744777474, 77744777477, 77744777744, 77744777747, 77744777774, 77744777777, 77747444444, 77747444447, 77747444474, 77747444477, 77747444744, 77747444747, 77747444774, 77747444777, 77747447444, 77747447447, 77747447474, 77747447477, 77747447744, 77747447747, 77747447774, 77747447777, 77747474444, 77747474447, 77747474474, 77747474477, 77747474744, 77747474747, 77747474774, 77747474777, 77747477444, 77747477447, 77747477474, 77747477477, 77747477744, 77747477747, 77747477774, 77747477777, 77747744444, 77747744447, 77747744474, 77747744477, 77747744744, 77747744747, 77747744774, 77747744777, 77747747444, 77747747447, 77747747474, 77747747477, 77747747744, 77747747747, 77747747774, 77747747777, 77747774444, 77747774447, 77747774474, 77747774477, 77747774744, 77747774747, 77747774774, 77747774777, 77747777444, 77747777447, 77747777474, 77747777477, 77747777744, 77747777747, 77747777774, 77747777777, 77774444444, 77774444447, 77774444474, 77774444477, 77774444744, 77774444747, 77774444774, 77774444777, 77774447444, 77774447447, 77774447474, 77774447477, 77774447744, 77774447747, 77774447774, 77774447777, 77774474444, 77774474447, 77774474474, 77774474477, 77774474744, 77774474747, 77774474774, 77774474777, 77774477444, 77774477447, 77774477474, 77774477477, 77774477744, 77774477747, 77774477774, 77774477777, 77774744444, 77774744447, 77774744474, 77774744477, 77774744744, 77774744747, 77774744774, 77774744777, 77774747444, 77774747447, 77774747474, 77774747477, 77774747744, 77774747747, 77774747774, 77774747777, 77774774444, 77774774447, 77774774474, 77774774477, 77774774744, 77774774747, 77774774774, 77774774777, 77774777444, 77774777447, 77774777474, 77774777477, 77774777744, 77774777747, 77774777774, 77774777777, 77777444444, 77777444447, 77777444474, 77777444477, 77777444744, 77777444747, 77777444774, 77777444777, 77777447444, 77777447447, 77777447474, 77777447477, 77777447744, 77777447747, 77777447774, 77777447777, 77777474444, 77777474447, 77777474474, 77777474477, 77777474744, 77777474747, 77777474774, 77777474777, 77777477444, 77777477447, 77777477474, 77777477477, 77777477744, 77777477747, 77777477774, 77777477777, 77777744444, 77777744447, 77777744474, 77777744477, 77777744744, 77777744747, 77777744774, 77777744777, 77777747444, 77777747447, 77777747474, 77777747477, 77777747744, 77777747747, 77777747774, 77777747777, 77777774444, 77777774447, 77777774474, 77777774477, 77777774744, 77777774747, 77777774774, 77777774777, 77777777444, 77777777447, 77777777474, 77777777477, 77777777744, 77777777747, 77777777774, 77777777777]\n\nl, r = In()\nx = bisect_left(arr, l)\ny = bisect_right(arr, r)\nif l == r:\n print(arr[x])\nelif x == y:\n print((r-l+1)*arr[x])\nelse:\n sm = arr[x]*(arr[x]-l+1)\n for i in range(x+1, y):\n sm += (arr[i]-arr[i-1])*arr[i]\n if r > arr[y-1]:\n sm += arr[y]*(r-arr[y-1])\n print(sm)"}, {"source_code": "def naxt(i) :\n e=bin(i+2)\n e=e[3:]\n e=e.replace(\"0\",\"4\")\n e=e.replace(\"1\",\"7\")\n return int(e)\ni=0\nans=0\npr=0\nl,r=map(int,input().split())\nwhile(True):\n t=naxt(i)\n \n ans+=max((min(r,t)-max(l,pr)+1)*t,0)\n pr=t+1\n if r<=t :\n break\n i+=1\n \nprint(ans)\n"}, {"source_code": "'''input\n1000000000 1000000000\n'''\nfrom bisect import *\nv = set()\nv.add(\"4\")\ndef generate_lucky(curr):\n if int(curr) > 10000000000:\n return\n v.add(curr)\n generate_lucky(curr + \"4\")\n generate_lucky(curr + \"7\")\n\nl,r = map(int,raw_input().split())\ngenerate_lucky(\"4\")\ngenerate_lucky(\"7\")\n\nx = [int(y) for y in v]\nx = sorted(x)\nintervals = {}\n\ns = 0\nfor i in x:\n intervals[i] = (s + 1,i)\n s = i\n\nans = 0\n# print l,r\nfor y in sorted(intervals.keys()):\n if max(l,intervals[y][0]) <= min(r,intervals[y][1]):\n ans += y * (abs(max(l,intervals[y][0]) - min(r,intervals[y][1]))+1)\n\nprint ans"}, {"source_code": "S = sorted\nM = lambda : map(int,input().split())\na = []\nl,r = M()\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\n\nF(0)\na=S(a)\ndef luckysum(p):\n\ts = 0\n\tfor i in range(1, len(a)):\n\t\ts+= a[i]*(min(a[i],p)-min(a[i-1],p))\n\t\tif not (min(a[i],p)-min(a[i-1],p)):\n\t\t\tbreak\n\treturn s\n\nprint(luckysum(r)-luckysum(l-1))\n\n "}, {"source_code": "\n\ndef lower_bound(a,val):\n if val in a:\n return val\n for i in range(len(a)):\n if a[i]>val:\n return a[i]\nlucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\ntotal = 0\nl,r=map(int,input().split())\ni = l\nfor _ in range(l,r+1):\n m = lower_bound(lucky,i)\n if m>r:\n total+=(r-i+1)*m\n break\n else:\n total+=(m-i+1)*m\n i = m\n i+=1\nprint(total)\n \n\n\n \n\n"}, {"source_code": "maximum = 10 ** 9\na = []\n\nqueue = [4, 7]\n\nelement = 0\n\nwhile element < maximum:\n element = queue.pop(0)\n a.append(element)\n x = element * 10\n queue.append(x + 4)\n queue.append(x + 7)\n\nl, r = (int(i) for i in input().split(' '))\n\nfor i in range(len(a)):\n if a[i] >= l:\n break\n\ncurrent = l\ntotal = 0\nwhile current <= r:\n if a[i] > r:\n total += (r - current + 1) * a[i]\n current = a[i]\n else:\n total += (a[i] + 1 - current) * a[i]\n current = a[i] + 1\n i += 1\nprint(total)\n\n\n# 1 2 3 4 5 6 7 8 9\n# 4 4 4 4 7 7 7 47 47\n"}, {"source_code": "#print(\"AUTHOR : SADIA AFROZ\")\n\nimport bisect\n\n\nl,r=map(int, input().split())\nsum=0\nluckyNumbersList=[]\n\ndef luckyNumbersGen(x):\n if x>=7777777777:\n return\n luckyNumbersList.append(x)\n luckyNumbersGen(x*10+4)\n luckyNumbersGen(x*10+7)\n\nluckyNumbersGen(4)\nluckyNumbersGen(7)\n#print(luckyNumbersList)\nluckyNumbersList.sort()\n#print(luckyNumbersList)\n\ndef next(x):\n lower=bisect.bisect_left(luckyNumbersList,x)\n #print(\"hello {} \".format(luckyNumbersList[lower]))\n return luckyNumbersList[lower]\n\n\nwhile l<=r:\n temp=next(l)\n if rLIMIT:\n\t\tpass\n\telse:\n\t\tlucky.append(n)\n\t\tgen(n*10+4)\n\t\tgen(n*10+7)\n\t\t\ngen(0)\n\n\nlucky.sort()\n\nans = 0\nfor i in range(len(lucky)-1):\n\tlo = max(l,lucky[i]+1)\n\thi = min(r,lucky[i+1])\n\t\n\tif hi>=lo:\n\t\tans = ans + (hi-lo+1)*lucky[i+1]\nprint(ans)\n\t\t\n"}, {"source_code": "digits = [4, 7]\nnums = [4, 7]\n\nLIM = 10**10\nwhile nums[-1] < LIM:\n nums = list(set(nums + [num*10 + digit for digit in digits for num in nums]))\n\nnums = [num for num in sorted(nums) if num <= LIM]\n# print len(nums)\n# print nums[:10], nums[-10:]\n\ndef c(l, r):\n ans = 0\n x = 0\n while l <= r:\n while nums[x] < l:\n x += 1\n num = nums[x]\n count = min(r, num) - l + 1\n ans += count * num\n # print num, ans, count, l, l + count\n l += count\n return ans\n\na, b = [int(_) for _ in raw_input().split(\" \")]\nprint c(a, b)\n"}, {"source_code": "def nxt(num):\n st=str(num)\n for i in range(len(st)):\n if st[i:]>\"7\"*(len(st)-i):\n if i==0:\n st=\"4\"*(len(st)+1)\n\n else:\n st=st[:i-1]+\"7\"+\"4\"*(len(st[i:]))\n break;\n elif st[i]<\"4\":\n st=st[:i]+\"4\"*(len(st[i:]))\n break\n elif st[i]<\"7\" and st[i]>\"4\":\n st=st[:i]+\"7\"+\"4\"*len(st[i+1:])\n break\n return int(st) \n\nlst=list(map(int,input().split()))\nl=lst[0]\nr=lst[1]\ns=0\nn=0\ni=l\nwhile i<=r:\n n=nxt(i)\n if n<=r:\n s=s+n*(n-i+1)\n i=n+1\n else:\n s=s+n*(r-i+1)\n break\nprint(s)\n "}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\nluckynumbers.sort()\n\nlowerbound = 0\nupperbound = 0\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]lowerbound:\n ans += luckynumbers[upperbound] * (r - luckynumbers[upperbound - 1])\n\nprint(ans)\n\n\n"}, {"source_code": "import itertools\n\ndef islucky(x):\n\ta = map(int, list(str(x)))\n\tb = [0, 1, 2, 3, 5, 6, 8, 9]\n\tfor i in b:\n\t\tif a.count(i) != 0:\n\t\t\treturn False\n\treturn True\n\nx, y = raw_input().split()\nstart = len(x)\nend = len(y)\nl = []\nfor i in range(start, end+2):\n\tl += [''.join(i) for i in set(itertools.product('47', repeat=i))]\nl = [int(i) for i in l]\nl = sorted(l)\n#print l\nstart = 0\nwhile l[start] < int(x):\n\tstart += 1\nend = 0\nwhile int(y) > l[end]:\n\tend += 1\ni = 0\nif len(l[start:end+1]) != 1:\n\tl = sorted(l[start:end+1])\n\t#print l\n\tsum = (l[0] - int(x) + 1) * l[0] + (int(y) - l[-1]) * l[-1]\n\ti = 0\n\twhile i != len(l)-1:\n\t\t#print l[i], l[i+1]\n\t\t#print sum\n\t\tsum += (l[i+1] - l[i]) * l[i+1]\n\t\ti += 1\n\t\t#print sum\nelse:\n\tsum = l[start:end+1][0] * (int(y) - int(x) + 1) \nprint sum\n\n\t\n\n"}, {"source_code": "'''input\n1000000000 1000000000\n'''\nfrom bisect import *\nv = set()\nv.add(\"4\")\ndef generate_lucky(curr):\n if int(curr) > 10000000000:\n return\n v.add(curr)\n generate_lucky(curr + \"4\")\n generate_lucky(curr + \"7\")\n\nl,r = map(int,raw_input().split())\ngenerate_lucky(\"4\")\ngenerate_lucky(\"7\")\n\nx = [int(y) for y in v]\nx = sorted(x)\nintervals = {}\n\ns = 0\nfor i in x:\n intervals[i] = (s + 1,i)\n s = i\n\nans = 0\n# print l,r\nfor y in sorted(intervals.keys()):\n if max(l,intervals[y][0]) <= min(r,intervals[y][1]):\n ans += y * (abs(max(l,intervals[y][0]) - min(r,intervals[y][1]))+1)\n\nprint ans"}, {"source_code": "#print(\"AUTHOR : SADIA AFROZ\")\n\nimport bisect\n\n\nl,r=map(int, input().split())\nsum=0\nluckyNumbersList=[]\n\ndef luckyNumbersGen(x):\n if x>=7777777777:\n return\n luckyNumbersList.append(x)\n luckyNumbersGen(x*10+4)\n luckyNumbersGen(x*10+7)\n\nluckyNumbersGen(4)\nluckyNumbersGen(7)\n#print(luckyNumbersList)\nluckyNumbersList.sort()\n#print(luckyNumbersList)\n\ndef next(x):\n lower=bisect.bisect_left(luckyNumbersList,x)\n #print(\"hello {} \".format(luckyNumbersList[lower]))\n return luckyNumbersList[lower]\n\n\nwhile l<=r:\n temp=next(l)\n if r= l and a <= r]\nl2 = [a for a in z if a > r]\nl1.sort()\nif len(l1) == 0 or l1[-1] != r:\n l1 += [l2[0]]\nu = l\nans = 0\nif r < l1[-1]:\n for i in range(len(l1)-1):\n ans += (l1[i]-u)*l1[i]\n u = l1[i]\n ans += (r-u)*l1[-1] + l1[0]\nelse:\n for i in range(len(l1)):\n ans += (l1[i]-u)*l1[i]\n u = l1[i]\n ans += l1[0]\nprint(ans)\n"}, {"source_code": "l,r=map(int,input().split())\n \na=[]\ndef foo(n):\n\ta.append(n)\n\tif n>10*r:\n\t\treturn\n\tfoo(10*n+4)\n\tfoo(10*n+7)\n\treturn\n \nfoo(0)\na.sort()\n \ndef get_sum(m):\n\ts=0\n\tfor i in range(1,len(a)):\n\t\ts+=a[i]*(min(a[i],m)-min(a[i-1],m))\n\treturn s\n \nprint(get_sum(r)-get_sum(l-1))"}, {"source_code": "# n = raw_input()\ndef next(ans):\n n = len(ans)\n if \"7\"*n == ans:\n return \"4\"*(n+1)\n i = n-1\n while ans[i]=='7':\n i-=1\n ans = ans[:i] + '7' + \"4\"*(n-i-1)\n return ans\n \ndef next_cool(sn):\n n = len(sn)\n if not int(\"7\"*n)>=int(sn):\n return \"4\"*(n+1)\n ans = \"4\"*n\n sn = int(sn)\n while int(ans)= x:\n return Sum\n\nl, r = map(int, raw_input().strip().split())\n\nprint func(r) - func(l - 1)\n"}, {"source_code": "li=set()\ndef addi(n):\n if n>10**10+1:\n return \n li.add(n)\n addi(n*10+4)\n addi(n*10+7)\naddi(4)\naddi(7)\nli=list(set(li))\nli.sort()\n#print(len(li))\nl,r=map(int,input().split())\nans=0\nfor x in li:\n #print(x)\n if x>=r:\n #print(\"l\",l)\n ans+=x*(r-l+1)\n #print(\"ans\",ans)\n break\n elif x>=l:\n ans+=x*(x-l+1)\n #print(\"ans\",ans)\n l=x+1\nprint(ans)\n"}, {"source_code": "l,r=map(int,raw_input().split())\na=[]\ndef F(x):\n a.append(x)\n if x>r*10:\n return\n F(10*x+4)\n F(10*x+7)\nF(0)\na=sorted(a)\ndef G(x):\n \n z=0\n for i in range(1,len(a)):\n z+=a[i]*(min(a[i],x)-min(a[i-1],x))\n return z\nprint G(r)-G(l-1)"}, {"source_code": "pre = []\nprev = ['']\nfor i in range(1, 11):\n cur = [s + '4' for s in prev] + [s + '7' for s in prev]\n pre.extend(cur)\n prev = cur\n\nl = sorted(map(int, pre))\n\nx, y = map(int, input().split())\nres = 0\n\nfor e in l:\n if e < x: continue\n res += e * (min(e, y) - x + 1)\n x = e + 1\n if x > y: break\n\nprint(res)"}, {"source_code": "l,r=map(int,input().split())\n\ns=set()\n\ndef f(st,res):\n\n\tif st>10:s.add(res)\n\n\telse:\n\n\t\tif res==0:f(st+1,res)\n\n\t\tfor i in 4,7:f(st+1,res*10+i)\n\nf(0,0)\n\ns=sorted(s)\n\na=1\n\nb=1\n\nq=0\n\nif l in s:\n\n\tq-=l\n\n\tl-=1\n\nwhile l>=s[a]:a+=1\n\nwhile r>=s[b+1]:b+=1\n\nif a>=b:\n\n\tq+=(min(r,s[a])-l+1)*s[a]\n\n\tif r>s[a]:q+=s[a+1]*(r-s[a])\n\nelse:\n\n\tif ls[b]:q+=s[b+1]*(r-s[b])\n\n\tfor i in range(a,b):q+=s[i+1]*(s[i+1]-s[i])\n\nprint(q)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "l, r = [int(x) for x in input().split()]\nimport itertools\narr = []\nfor i in range(1, 11):\n arr.extend(list(map(int, map(''.join, itertools.product('47', repeat=i)))))\nans = 0\nfor i in range(len(arr)):\n if arr[i] >= r:\n ans += (r - l + 1) * arr[i]\n break\n elif arr[i] >= l:\n ans += (arr[i] - l + 1) * arr[i]\n l = arr[i] + 1\nprint(ans)"}], "negative_code": [{"source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom itertools import combinations_with_replacement\nfrom collections import defaultdict\nfrom bisect import bisect_right\n \ndef L():\n return list(map(int, stdin.readline().split()))\n \ndef In():\n return map(int, stdin.readline().split())\n \ndef I():\n return int(stdin.readline())\n \nP = 1000000007\narr = []\nlis = [4, 7]\nfor i in range(1, 11):\n comb = list(combinations_with_replacement([4, 7], i))\n for j in comb:\n st = ''\n for k in range(i):\n st += str(j[k])\n arr.append(int(st))\nl, r = In()\nsm = 0\nfor i in range(l, r+1):\n if i in arr:\n sm += i\n else:\n sm += arr[bisect_right(arr, i)]\nprint(sm)"}, {"source_code": "def 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 \nl,r=map(int,input().split())\ne=[4,7]\nt=2\nc=0\nwhile(e[-1]<=1000000000):\n te=len(e)\n c+=1\n for i in range(t):\n e.append(4*pow(10,c)+e[te-t+i])\n for i in range(t):\n e.append(7*pow(10,c)+e[te-t+i])\n t*=2\nind=countGreater(e,len(e),l)\ns=l\nind=len(e)-ind\nend=min(r,e[ind])\nmul=e[ind]\n#print(mul)\nans=0\nwhile(True):\n #print(s,end,mul)\n ans+=(end-s+1)*mul\n if end==r:\n break\n s=end+1\n end=e[ind+1]\n mul=e[ind+1]\nprint(ans)\nprint(ans)"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n \n def nextlucky(ok, s, i):\n if i >= len(s):\n return 0\n\n if ok:\n s[i] = '4'\n return nextlucky(True, s, i+1)\n\n if s[i] > '7':\n s[i] = '4'\n nextlucky(True, s, i+1)\n return 1\n\n if s[i] > '4':\n ok = nextlucky(s[i] < '7', s, i+1)\n s[i] = '4' if ok and s[i] == '7' else '7'\n return ok\n \n ok = nextlucky(s[i] < '4', s, i+1)\n s[i] = '7' if ok and s[i] == '4' else '4'\n \n return ok\n\n l, r = map(int, input().split())\n ans = 0\n\n for i in range(l, r+1):\n s = list(str(i))\n if (nextlucky(False, s, 0)):\n s = ['4'] + s\n ans += int(\"\".join(s))\n \n print(ans)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "\n\ndef main():\n\n\tgenNb = []\n\n\tdef gen_numbers(cur_nb):\n\t\tif cur_nb >= 1000000001:\n\t\t\treturn\n\t\tgenNb.append(cur_nb)\n\t\tgen_numbers(cur_nb*10+4)\n\t\tgen_numbers(cur_nb*10+7)\n\n\tgen_numbers(4)\n\tgen_numbers(7)\n\n\tleft,right = map(int,input().split())\n\n\tsl = 0\n\n\tgenNb.sort()\n\n\tfor nb in genNb:\n\t\tif nb >= left:\n\t\t\tsl += nb*(min(nb,right)-left+1)\n\t\t\tleft = nb+1\n\t\t\tif left > right:break\n\tprint(sl)\nmain()"}, {"source_code": "lucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\nl,r=map(int,input().split())\nlpos = 0\nrpos = 0\nfor i in range(len(lucky)):\n if lucky[i]==l:\n lpos = i\n break\n elif lucky[i]>l:\n lpos=i\n break\nfor i in range(len(lucky)):\n if lucky[i]==r:\n rpos = i\n break\n elif lucky[i]>r:\n rpos=i\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n ok = False\n for i in range(lpos,rpos):\n if ok==False:\n ok = True\n sumi+=((lucky[i]-(max(lucky[i-1],l)))+1)*(lucky[i])\n else:\n sumi+=(lucky[i]-(max(lucky[i-1],l)))*(lucky[i])\n sumi+=(r-lucky[rpos-1])*lucky[rpos]\n print(sumi)\n\n\n \n\n"}, {"source_code": "def f(g):\n s=g[:]\n for i in range(len(s)-1,-1,-1):\n if s[i]=='4':\n for j in range(len(s)-1,i,-1):\n s[j]='4'\n s[i]='7'\n break\n else:\n s=['4']*(len(s)+1)\n return s\nr,l=map(int,raw_input().split())\na=r-1\ns=['4']\nwhile int(''.join(s)) < r:\n s=f(s)\nt=0\nwhile True:\n icur=int(''.join(s))\n \n m=min(icur,l)-a\n \n t+=m*icur\n print m , icur , t\n if icur >= l:\n break\n a=icur\n s=f(s)\nprint t\n"}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\n luckynumbers.sort()\n\nlowerbound = len(luckynumbers)-1\nupperbound = len(luckynumbers)-1\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]>r) & (upperbound>0):\n upperbound -= 1\n\nwhile (luckynumbers[lowerbound]>l) & (lowerbound>0):\n lowerbound -= 1\n\nans = luckynumbers[lowerbound] * (luckynumbers[lowerbound] - l + 1)\n\nfor i in range(lowerbound + 1, upperbound + 1):\n ans += luckynumbers[i] * (luckynumbers[i] - luckynumbers[i-1])\n\nprint(ans)\n\n"}, {"source_code": "def gen(cur):\n if cur <= 10 ** 11:\n a = gen(cur * 10 + 4)\n a.extend(gen(cur* 10 + 7))\n a.append(cur)\n return a\n else:\n return []\n \nleft, right = map(int, input().split())\nans = 0\nprev = 0\nleft -= 1\nfor x in sorted(gen(0))[1:]:\n if x < left:\n continue\n if x > right:\n ans += x * (right - prev)\n break\n ans += x * (x - max(prev, left))\n prev = x\nprint(ans)\n"}, {"source_code": "number = raw_input()\nnum1, num2 = number.split(\" \")\nnum1 = int(num1)\nnum2 = int (num2)\n\ni = 1 \nlucky_num = []\n\nwhile i <= 777:\n\tnum = i\n\twhile num > 0:\n\t\ttemp = num % 10\n\t\tif temp == 4 or temp == 7:\n\t\t\tnum = num / 10\n\t\t\tbool = True\n\t\telse:\n\t\t\tbool = False \n\t\t\tbreak;\n\tif bool is not False:\n\t\tlucky_num.append(i)\n\ti = i + 1\n\nsum = 0\n\nwhile num1 <= num2:\n\ta = min (n for n in lucky_num if n >= num1)\n\tif a > num2:\n\t\tsum = sum + (num2 - num1 + 1) * a\n\telse:\n\t\tsum = sum + (a - num1 + 1) * a\n\t\tprint sum\n\tnum1 = a + 1\n\nprint sum"}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\nluckynumbers.sort()\n\nlowerbound = 0\nupperbound = 0\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]lowerbound:\n ans += luckynumbers[upperbound] * (r - luckynumbers[upperbound - 1])\n\nprint(ans)\n\n"}, {"source_code": "def nxt(num):\n st=str(num)\n for i in range(len(st)):\n if st[i:]>\"7\"*(len(st)-i):\n if i==0:\n st=\"4\"*(len(st)+1)\n\n else:\n st=st[:i-1]+\"7\"+\"4\"*(len(st[i:]))\n break;\n elif st[i]<\"4\":\n st=st[:i]+\"4\"*(len(st[i:]))\n break\n elif st[i]<=\"7\" and st[i]>\"4\":\n st=st[:i]+\"7\"+st[i+1:]\n return int(st) \n\nlst=list(map(int,input().split()))\nl=lst[0]\nr=lst[1]\ns=0\nn=0\ni=l\nwhile i<=r:\n n=nxt(i)\n if n<=r:\n s=s+n*(n-i+1)\n i=n+1\n else:\n s=s+n*(r-i+1)\n break\nprint(s)\n "}, {"source_code": "def f(g):\n s=g[:]\n s.reverse()\n for i,x in enumerate(s):\n if x=='4':\n for j in range(i):\n s[j]='4'\n s[i]='7'\n break\n else:\n s=['4']*(len(s)+1)\n s.reverse()\n return s\nr,l=map(int,raw_input().split())\nn=0\ns=['4']\nwhile int(''.join(s)) < r:\n s=f(s)\nt=l-r+1\ncur=s[:]\nicur=int(''.join(cur))\nif r==l:\n print icur\n exit()\nelse:\n ret=(icur-r+1)*(icur)\nwhile True:\n nex=f(cur)\n icur=int(''.join(cur))\n inex=int(''.join(nex))\n le=inex-icur\n m=min(le,l-icur)\n ret+=m*inex\n cur=nex\n if le > l-icur :\n break\nprint ret\n"}, {"source_code": "mn, mx = [int(i) for i in input().split()]\nnumber = [4]*len(str(mn))\nnumbers = []\nresult = 0\n\nwhile int(\"\".join([str(i) for i in number])) <= mx:\n numbers.append(int(\"\".join([str(i) for i in number])))\n\n number[-1] = 7 if number[-1] == 4 else 1\n for i in range(len(number) - 2, -1, -1):\n if number[i + 1] == 1:\n number[i] = 7 if number[i] == 4 else 1\n number[i + 1] = 4\n\n if number[0] == 1:\n number.insert(0, 4)\n number[1] = 4\n\nfor i in range(len(numbers)):\n if numbers[i] >= mn:\n numbers = numbers[i:]\n\nresult += ((numbers[0]) - mn + 1) * numbers[0]\nfor i in range(1, len(numbers)):\n result += (numbers[i] - numbers[i - 1]) * numbers[i]\nresult += (mx - numbers[-1]) * numbers[-1]\n\nprint(result)"}, {"source_code": "level={}\ndef bfs():\n s=''\n level[s]=None\n i=1\n frontier = [s]\n while i < 11:\n next=[]\n for u in frontier:\n for v in [u+'4', u+'7']:\n if v not in level:\n level[v]=i\n next.append(v)\n frontier=next\n i+=1\nbfs()\nl=[]\nfor key, value in level.items():\n if key!='':\n l.append(int(key))\nl.sort()\na,b=map(int, input().split())\ns=0\nfor i in range(len(l)):\n if a<=l[i]<=b:\n if l[i+1] <=b :\n s=s+ (l[i]) * (l[i+1]- l[i] )\n else:\n s=s+ l[i]*(b-l[i-1])\n \n\n elif l[i] > b:\n break\nprint(s)\n"}, {"source_code": "luckynums = []\nfor digits in range(1,10):\n\tfor mask in range(1<0 and next(i-2)!=(i-1)):\n\ti=a-1\n\tprev=-2\nwhile(iarr[i-1]):\n\t\t\t\tc=arr[i]\n\t\t\t\tbreak;\n\tif r<=c:\n\t\tsumi=sumi+((r-l+1)*c)\n\t\tl=r+1\n\telse:\n\t\tsumi=sumi+((c-l+1)*c)\n\t\tl=c+1\nprint(sumi)\n\n\t\t\t"}, {"source_code": "good=[4,7]\nj=0 \nfor i in range(1000):\n good.append(good[j]*10+4)\n good.append(good[j]*10+7)\n j+=1 \n \ngood.sort() \ngood=[i for i in good if i<=10**12]\nl,r=map(int,input().split())\nans=0 \nlo=0 \nind1=-1 \nind2=-1 \nhi=len(good)-1\nnextl=l \nwhile lo<=hi: \n mi=(lo+hi)>>1 \n if good[mi]>=l:\n nextl=good[mi]\n ind1=mi \n hi=mi-1 \n else:\n lo=mi+1 \nlo=0 \nhi=len(good)-1\nwhile lo<=hi: \n mi=(lo+hi)>>1 \n if good[mi]>=r:\n nextr=good[mi]\n # ind1=mi \n hi=mi-1 \n else:\n lo=mi+1 \nprevr=r \nlo=0 \nhi=len(good)-1\nwhile lo<=hi:\n mi=(lo+hi)>>1 \n if good[mi]<=r: \n prevr= good[mi]\n ind2=mi \n lo=mi+1 \n else: \n hi=mi-1 \nans=0 \nfor i in range(ind1,ind2):\n diff=good[i+1]-good[i] \n ans+=diff*good[i+1]\n#print(nextl,prevr,nextr)\nans+=(min(nextl,r)-l+1)*nextl\nif prevr>nextl: \n ans+=(r-prevr)*nextr \nprint(ans)"}, {"source_code": "def lucky(n):\n for digit in str(n):\n if digit not in '47':\n return False\n return True\n\nl, r = map(int, input().split())\n\nres = 0\nnext_lucky = 0\nfor n in range(r, l-1, -1):\n if lucky(n):\n next_lucky = n\n res += next_lucky\n \nprint(res)\n "}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n l, r = map(int, input().split())\n \n def nextlucky(i):\n n = ''\n \n for i in str(i):\n n += '4' if i <= '4' else '7'\n \n return int(n)\n\n ans = sum(map(nextlucky, range(l, r+1)))\n\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "lucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\nl,r=map(int,input().split())\nlpos = 0\nrpos = 0\nfor i in range(len(lucky)):\n if lucky[i]>=l:\n lpos = i\n break\nfor j in range(len(lucky)-1,-1,-1):\n if lucky[j]<=r:\n rpos = j\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n for i in range(lpos,rpos):\n sumi+=((lucky[lpos+1]-lucky[lpos])*lucky[lpos+1])\n if lucky[lpos]!=l:\n if l<4:\n sumi+=((lucky[lpos]-l+1)*4)\n else:\n sumi+=((lucky[lpos]-l+1)*lucky[lpos-1])\n if lucky[rpos]!=r:\n sumi+=((r-lucky[rpos])*lucky[rpos])\n print(sumi)\n \n\n \n\n"}, {"source_code": "l,r = map(int,input().split(' '))\n\na = set()\nfor i in range(1, 10):\n for j in range(2**i):\n c = j\n cnt = 0\n t = 0\n while c or cnt < i:\n if c&1:\n t = t*10+7\n else:\n t = t*10+4\n cnt += 1\n c //= 2\n a.add(t)\n\na = sorted(list(a))\n\nans = 0\nfor j in range(len(a)):\n i = a[j]\n if l <= i and r > i:\n ans += (i - l + 1) * i\n l = i + 1\n elif l <= i and r <= i:\n ans += (r - l + 1) * i\n break\nprint(ans)\n\n"}, {"source_code": "l,r=map(int,input().split())\na=[]\ndef addLucky(x):\n if x>r:\n return\n a.append(x)\n addLucky(x*10+4)\n addLucky(x*10+7)\naddLucky(0)\na.sort()\ndef result(n):\n res=0\n for i in range(0,len(a)):\n res+=a[i]*(min(a[i],n)-min(a[i-1],n))\n return res\nprint(result(r)-result(l-1))"}, {"source_code": "def gen(cur):\n if cur <= 10 ** 11:\n a = gen(cur * 10 + 4)\n a.extend(gen(cur* 10 + 7))\n a.append(cur)\n return a\n else:\n return []\n \nleft, right = map(int, input().split())\nans = 0\nprev = 0\nleft -= 1\nfor x in sorted(gen(0))[1:]:\n if x < left:\n continue\n if x > right:\n ans += x * (right - prev)\n break\n ans += x * (x - max(prev, left))\n prev = x\nprint(ans)\n"}, {"source_code": "lucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\nl,r=map(int,input().split())\nlpos = 0\nrpos = 0\nfor i in range(len(lucky)):\n if lucky[i]==l:\n lpos = i\n break\n elif lucky[i]>l:\n lpos=i\n break\nfor i in range(len(lucky)):\n if lucky[i]==r:\n rpos = i\n break\n elif lucky[i]>r:\n rpos=i\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n ok = False\n for i in range(lpos,rpos):\n if ok==False:\n ok = True\n sumi+=((lucky[i]-(max(lucky[i-1],l)))+1)*(lucky[i])\n else:\n sumi+=(lucky[i]-(max(lucky[i-1],l)))*(lucky[i])\n sumi+=(r-lucky[rpos-1])*lucky[rpos]\n print(sumi)\n\n\n \n\n"}, {"source_code": "import bisect\n\ndef foo():\n\tl=[4,7]\n\n\twhile(len(str(l[-1]))<=12):\n\t\tz=[]\n\t\tfor i in range(0,len(l)):\n\t\t\tfor j in range(0,len(l)):\n\t\t\t\ts=str(l[i])+str(l[j])\n\t\t\t\tif(len(s)>=12):\n\t\t\t\t\treturn l\n\t\t\t\tz.append(int(s))\n\t\t\t\t#print(len(s))\n\t\tl=l+z\n\t\t\n\t\t\nl=foo()\nl=list(set(l))\nl.sort()\n#for i in l:\n#\tprint(i)\nn,m=map(int,input().split())\nc=0\nj=0\nfor i in range(n,m+1):\n\tif(i maxone:\n if max(lis) < maxone:\n lis.append(int(nstr))\n return\n lis.append(int(nstr))\n next(nstr+'4',minone,maxone,lis)\n next(nstr+'7',minone,maxone,lis)\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r')\n else:\n input = sys.stdin\n #--------------------------------INPUT---------------------------------\n n1,n2 = list(map(int, input.readline().split()))\n lis = []\n next(\"4\",1,1000000000,lis)\n next(\"7\",1,1000000000,lis)\n lis.sort()\n sum = 0 \n begin = bisect.bisect_left(lis, n1)\n for i in range(begin,len(lis)):\n if i==begin:\n if lis[i]<=n2:\n sum+=(lis[i]*((lis[i]-n1)+1))\n elif n2<4:\n sum+=(4*((n2-n1)+1))\n break\n else:\n sum+=(lis[i]*((n2-lis[i-1])))\n break\n continue\n if lis[i]<=n2:\n sum+=(lis[i]*((lis[i]-lis[i-1])))\n else:\n sum+=(lis[i]*((n2-lis[i-1])))\n break\n #print(lis)\n output = sum\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#threading.Thread(target=main).start()"}, {"source_code": "l,r=map(int,(input().split()))\nlucky=[4,7]\nfor i in range(1,10):\n \n for j in lucky[pow(2,i)-2:pow(2,i+1)+1]:\n \n lucky.append(4*pow(10,i) + j)\n lucky.append(7*pow(10,i)+ j)\n \nlucky.sort()\n\nadd=0\nfor i in lucky:\n if i>1 \n if good[mi]>=l:\n nextl=good[mi]\n ind1=mi \n hi=mi-1 \n else:\n lo=mi+1 \nprevr=r \nlo=0 \nhi=len(good)-1\nwhile lo<=hi:\n mi=(lo+hi)>>1 \n if good[mi]<=r: \n prevr= good[mi]\n ind2=mi \n lo=mi+1 \n else: \n hi=mi-1 \nfor i in range(ind1,ind2):\n diff=good[i+1]-good[i] \n # print(diff)\n ans+=diff*good[i+1]\n#print(ans)\nans+=(nextl-l+1)*nextl \nans+=(r-prevr)*r \nprint(ans)"}, {"source_code": "def f(g):\n s=g[:]\n s.reverse()\n for i,x in enumerate(s):\n if x=='4':\n for j in range(i):\n s[j]='4'\n s[i]='7'\n break\n else:\n s=['4']*(len(s)+1)\n s.reverse()\n return s\nr,l=map(int,raw_input().split())\nn=0\ns=['4']\nwhile int(''.join(s)) < r:\n s=f(s)\nt=l-r+1\ncur=s[:]\nicur=int(''.join(cur))\nif r==l:\n print icur\n exit()\nelse:\n ret=(icur-r+1)*(icur)\nwhile True:\n nex=f(cur)\n icur=int(''.join(cur))\n inex=int(''.join(nex))\n le=inex-icur\n m=min(le,l-icur)\n ret+=m*inex\n cur=nex\n if le > l-icur :\n break\nprint ret\n"}, {"source_code": "lucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\nl,r=map(int,input().split())\nlpos = 0\nrpos = 0\nfor i in range(len(lucky)):\n if lucky[i]>=l:\n lpos = i\n break\nfor j in range(len(lucky)-1,-1,-1):\n if lucky[j]<=r:\n rpos = j\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n for i in range(lpos,rpos):\n sumi+=((lucky[lpos+1]-lucky[lpos])*lucky[lpos+1])\n if l<=4:\n sumi+=((lucky[lpos]-l+1)*4)\n else:\n sumi+=((lucky[lpos]-l+1)*lucky[lpos-1])\n if lucky[rpos]!=r:\n sumi+=((r-lucky[rpos])*lucky[rpos+1])\n print(sumi)\n \n\n \n\n"}, {"source_code": "import sys\n\nnumbers = map(int, sys.stdin.readline().split())\n\nstart = numbers[0]\nend = numbers[1]\n\ndef nextfun(i):\n lst = [int(x) for x in str(i).zfill(9)]\n for k in range(9):\n if lst[k] != 0:\n end = k\n break\n \n j = 8\n while (j >= end):\n if lst[j] == 4 or lst[j] == 7:\n j -= 1\n continue\n elif lst[j] > 7:\n lst[j] = 4\n lst[j - 1] = lst[j - 1] + 1\n elif lst[j] > 4:\n lst[j] = 7\n if (j + 1 < 9):\n lst[j + 1] = 4\n else:\n lst[j] = 4\n if (j + 1 < 9):\n lst[j + 1] = 4\n \n j -= 1\n return int(''.join(map(str,lst)))\n \n \n \n \n \nanswer = 0\n\nwhile(start <= end):\n answer += nextfun(start)\n start += 1\n \n \nprint answer"}, {"source_code": "import bisect\n\ndef foo():\n\tl=[4,7]\n\n\twhile(len(str(l[-1]))<12):\n\t\tz=[]\n\t\tfor i in range(0,len(l)):\n\t\t\tfor j in range(0,len(l)):\n\t\t\t\ts=str(l[i])+str(l[j])\n\t\t\t\tif(len(s)>12):\n\t\t\t\t\treturn l\n\t\t\t\tz.append(int(s))\n\t\t\t\t#print(len(s))\n\t\tl=l+z\n\t\t\n\t\t\nl=foo()\nl=list(set(l))\nl.sort()\n#for i in l:\n#\tprint(i)\nn,m=map(int,input().split())\nc=0\nj=0\nfor i in range(n,m+1):\n\tif(i= l:\n\t\tbreak\n\ta=icur\n\ts=f(s)\nprint t\n\n"}, {"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\n\nl=[]\nfor i in range(1,10):\n for j in range(i+1):\n a=\"\"\n a+=j*'4'\n a+=(i-j)*'7'\n a=int(a)\n l.append(a) \n \nl.sort() \n\nle,r=mi()\ns=0\ni=le-1\nj=0\nwhile(ii:\n s+=(min(l[j],r)-i)*l[j] \n i=l[j]\n j+=1\nprint(s)"}, {"source_code": "l,r=map(int,input().split())\ns=set()\ndef f(st,res):\n\tif st>10:s.add(res)\n\telse:\n\t\tif res==0:f(st+1,res)\n\t\tfor i in 4,7:f(st+1,res*10+i)\nf(0,0)\ns=sorted(s)\na=1\nb=1\nq=0\nif l in s:\n\tq-=l\n\tl-=1\nwhile l>=s[a]:a+=1\nwhile r>=s[b+1]:b+=1\nif a>=b:q+=(r-l+1)*s[a]\nelse:\n\tif ls[b]:q+=s[b+1]*(r-s[b])\n\tfor i in range(a,b):q+=s[i+1]*(s[i+1]-s[i])\nprint(q)"}, {"source_code": "# python3\nimport sys, threading, os.path\nimport collections, heapq, math,bisect\nimport string\nfrom platform import python_version\nimport itertools\nsys.setrecursionlimit(10**6)\nthreading.stack_size(2**27)\n\ndef next(nstr,minone,maxone,lis):\n if int(nstr) < minone or int(nstr) > maxone:\n if max(lis) < maxone:\n lis.append(int(nstr))\n return\n lis.append(int(nstr))\n next(nstr+'4',minone,maxone,lis)\n next(nstr+'7',minone,maxone,lis)\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r')\n else:\n input = sys.stdin\n #--------------------------------INPUT---------------------------------\n n1,n2 = list(map(int, input.readline().split()))\n lis = []\n next(\"4\",1,1000000000,lis)\n next(\"7\",1,1000000000,lis)\n lis.sort()\n sum = 0 \n begin = bisect.bisect_left(lis, n1)\n for i in range(begin,len(lis)):\n if i==begin:\n if lis[i]<=n2:\n sum+=(lis[i]*((lis[i]-n1)+1))\n elif n2<4:\n sum+=(4*((n2-n1)+1))\n break\n else:\n sum+=(lis[i]*((n2-lis[i-1])))\n break\n continue\n if lis[i]<=n2:\n sum+=(lis[i]*((lis[i]-lis[i-1])))\n else:\n sum+=(lis[i]*((n2-lis[i-1])))\n break\n #print(lis)\n output = sum\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#threading.Thread(target=main).start()"}, {"source_code": "mn, mx = [int(i) for i in input().split()]\nnumber = [4]*len(str(mn))\nnumbers = []\nresult = 0\n\nwhile int(\"\".join([str(i) for i in number])) <= mx:\n numbers.append(int(\"\".join([str(i) for i in number])))\n\n number[-1] = 7 if number[-1] == 4 else 1\n for i in range(len(number) - 2, -1, -1):\n if number[i + 1] == 1:\n number[i] = 7 if number[i] == 4 else 1\n number[i + 1] = 4\n\n if number[0] == 1:\n number.insert(0, 4)\n number[1] = 4\n\nfor i in range(len(numbers)):\n if numbers[i] >= mn:\n numbers = numbers[i:]\n\nresult += ((numbers[0]) - mn + 1) * numbers[0]\nfor i in range(1, len(numbers)):\n result += (numbers[i] - numbers[i - 1]) * numbers[i]\nresult += (mx - numbers[-1]) * numbers[-1]\n\nprint(result)"}, {"source_code": "import itertools\n\ndef islucky(x):\n\ta = map(int, list(str(x)))\n\tb = [0, 1, 2, 3, 5, 6, 8, 9]\n\tfor i in b:\n\t\tif a.count(i) != 0:\n\t\t\treturn False\n\treturn True\n\nx, y = raw_input().split()\nstart = len(x)\nend = len(y)\nl = []\nfor i in range(start, end+1):\n\tl += [''.join(i) for i in set(itertools.product('47', repeat=i))]\nl = [int(i) for i in l]\nl = sorted(l)\nstart = 0\nwhile l[start] < int(x):\n\tstart += 1\nend = len(l)-1\nwhile l[end] > int(y):\n\tend -= 1\n\nl = list(set([int(x)] + l[start:end+1] + [int(y)]))\ni = 0\nif len(l) != 1:\n\tif islucky(l[0]):\n\t\tsum = l[0]\n\telse:\n\t\tsum = l[1]\n\t#print l\n\twhile i != len(l)-1:\n\t\tprint l[i], l[i+1]\n\t\t#print sum\n\t\tsum += (l[i+1] - l[i]) * l[i+1]\n\t\ti += 1\n\t\t#print sum\nelse:\n\tsum = l[0]\nprint sum\n\n\t\n\n"}, {"source_code": "lucky = []\nLIMIT=1000000000\ninp = raw_input().split()\nl = int(inp[0])\nr = int(inp[1])\n\n\nlucky.sort()\n\nans = 0\nfor i in range(len(lucky)-1):\n\tlo = max(l,lucky[i]+1)\n\thi = min(r,lucky[i+1])\n\t\n\tif hi>=lo:\n\t\tans = ans + (hi-lo+1)*lucky[i+1]\nprint(ans)\n\t\t\n"}, {"source_code": "import itertools\n\ndef islucky(x):\n\ta = map(int, list(str(x)))\n\tb = [0, 1, 2, 3, 5, 6, 8, 9]\n\tfor i in b:\n\t\tif a.count(i) != 0:\n\t\t\treturn False\n\treturn True\n\nx, y = raw_input().split()\nstart = len(x)\nend = len(y)\nl = []\nfor i in range(start, end+1):\n\tl += [''.join(i) for i in set(itertools.product('47', repeat=i))]\nl = [int(i) for i in l]\nl = sorted(l)\nstart = 0\nwhile l[start] < int(x):\n\tstart += 1\nend = len(l)-1\nwhile l[end] > int(y):\n\tend -= 1\n\nl = list(set([int(x)] + l[start:end+1] + [int(y)]))\ni = 0\nif len(l) != 1:\n\tif islucky(l[0]):\n\t\tsum = l[0]\n\telse:\n\t\tsum = l[1]\n\t#print l\n\twhile i != len(l)-1:\n\t\tprint l[i], l[i+1]\n\t\t#print sum\n\t\tsum += (l[i+1] - l[i]) * l[i+1]\n\t\ti += 1\n\t\t#print sum\nelse:\n\tsum = l[0]\nprint sum\n\n\t\n\n"}, {"source_code": "import sys\n\ndef generate_lucky_nums(cur_num = 0):\n if cur_num > 10 ** 9:\n return\n\n if cur_num != 0:\n lucky_nums.append(cur_num)\n \n generate_lucky_nums(cur_num * 10 + 4)\n generate_lucky_nums(cur_num * 10 + 7)\n\ndef bin_search(target, values):\n l, h = 0, len(values)-1\n\n while l <= h:\n m = (l + h) // 2\n\n if values[m] == target:\n return m\n elif values[m] < target:\n l = m + 1\n elif values[m] > target:\n h = m - 1\n return l\n\nvalues = [int(x) for x in sys.stdin.readline().split()]\nl, r = values[0], values[1]\nlucky_nums = []\n \ngenerate_lucky_nums()\nlucky_nums.sort()\n\nresult = 0\nfor i in range(l, r+1):\n index = bin_search(i, lucky_nums)\n if index >= len(lucky_nums):\n result += lucky_nums[-1]\n else:\n result += lucky_nums[index]\n \nprint(result)\n"}, {"source_code": "import bisect\n\ndef foo():\n\tl=[4,7]\n\n\twhile(len(str(l[-1]))<12):\n\t\tz=[]\n\t\tfor i in range(0,len(l)):\n\t\t\tfor j in range(0,len(l)):\n\t\t\t\ts=str(l[i])+str(l[j])\n\t\t\t\tif(len(s)>12):\n\t\t\t\t\treturn l\n\t\t\t\tz.append(int(s))\n\t\t\t\t#print(len(s))\n\t\tl=l+z\n\t\t\n\t\t\nl=foo()\nl=list(set(l))\nl.sort()\n#for i in l:\n#\tprint(i)\nn,m=map(int,input().split())\nc=0\nj=0\nfor i in range(n,m+1):\n\tif(i arr[y-1]:\n sm += arr[y]*(r-arr[y-1])\n print(sm)"}, {"source_code": "lucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\nl,r=map(int,input().split())\nlpos = 0\nrpos = 0\nfor i in range(len(lucky)):\n if lucky[i]>=l:\n lpos = i\n break\nfor j in range(len(lucky)-1,-1,-1):\n if lucky[j]<=r:\n rpos = j\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n for i in range(lpos,rpos):\n sumi+=((lucky[lpos+1]-lucky[lpos])*lucky[lpos+1])\n if l<=4:\n sumi+=((lucky[lpos]-l+1)*4)\n else:\n sumi+=((lucky[lpos]-l+1)*lucky[lpos-1])\n if lucky[rpos]!=r:\n sumi+=((r-lucky[rpos])*lucky[rpos+1])\n print(sumi)\n \n\n \n\n"}, {"source_code": "import sys\n\ndef generate_lucky_nums(cur_num = 0):\n if cur_num > 10 ** 10:\n return\n\n if cur_num != 0:\n lucky_nums.append(cur_num)\n \n generate_lucky_nums(cur_num * 10 + 4)\n generate_lucky_nums(cur_num * 10 + 7)\n\ndef bin_search(target, values):\n l, h = 0, len(values)-1\n\n while l <= h:\n m = (l + h) // 2\n\n if values[m] == target:\n return m\n elif values[m] < target:\n l = m + 1\n elif values[m] > target:\n h = m - 1\n return l\n\nvalues = [int(x) for x in sys.stdin.readline().split()]\nl, r = values[0], values[1]\nlucky_nums = []\n \ngenerate_lucky_nums()\nlucky_nums.sort()\n\nresult = 0\ni = l\n\nwhile i <= r:\n index = bin_search(i, lucky_nums)\n next_lucky = lucky_nums[index]\n result += next_lucky * (next_lucky - i + 1)\n i = next_lucky + 1\n \nprint(result)\n"}, {"source_code": "# python3\nimport sys, threading, os.path\nimport collections, heapq, math,bisect\nimport string\nfrom platform import python_version\nimport itertools\nsys.setrecursionlimit(10**6)\nthreading.stack_size(2**27)\n\ndef next(nstr,minone,maxone,lis):\n if int(nstr) < minone or int(nstr) > maxone:\n if max(lis) < maxone:\n lis.append(int(nstr))\n return\n lis.append(int(nstr))\n next(nstr+'4',minone,maxone,lis)\n next(nstr+'7',minone,maxone,lis)\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r')\n else:\n input = sys.stdin\n #--------------------------------INPUT---------------------------------\n n1,n2 = list(map(int, input.readline().split()))\n lis = []\n next(\"4\",1,1000000000,lis)\n next(\"7\",1,1000000000,lis)\n lis.sort()\n sum = 0 \n begin = bisect.bisect_left(lis, n1)\n for i in range(begin,len(lis)):\n if i==begin:\n if lis[i]<=n2:\n sum+=(lis[i]*((lis[i]-n1)+1))\n elif n2<4:\n sum+=(4*((n2-n1)+1))\n break\n else:\n sum+=(lis[i]*((n2-lis[i-1])))\n break\n continue\n if lis[i]<=n2:\n sum+=(lis[i]*((lis[i]-lis[i-1])))\n else:\n sum+=(lis[i]*((n2-lis[i-1])))\n break\n #print(lis)\n output = sum\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#threading.Thread(target=main).start()"}, {"source_code": "l,r = [int(x) for x in input().strip().split()]\n\ndef next(n):\n\ts = str(n)\n\tk = len(s)\n\tif n>int(\"7\"*k):\n\t\treturn int(\"4\"*(k+1))\n\tif n0 else 0))\n\t\tif int(s[i])==7:\n\t\t\tif s[i+1:]==\"\":\n\t\t\t\treturn int(\"7\")\n\t\t\treturn int(\"7\"+str(next(int(s[i+1:]))))\n\nlast = next(l)\ntot = last\nfor i in range(l+1,r+1):\n\tif i>last:\n\t\tlast=next(i)\n\ttot+=last\nprint(tot)"}, {"source_code": "def f(g):\n\ts=g[:]\n\tfor i in range(len(s)-1,-1,-1):\n\t\tif s[i]=='4':\n\t\t\tfor j in range(i):\n\t\t\t\ts[j]='4'\n\t\t\ts[i]='7'\n\t\t\tbreak\n\telse:\n\t\ts=['4']*(len(s)+1)\n\treturn s\nr,l=map(int,raw_input().split())\na=r-1\ns=['4']\nwhile int(''.join(s)) < r:\n\ts=f(s)\nt=0\nwhile True:\n\ticur=int(''.join(s))\n\t\n\tm=min(icur,l)-a\n\tt+=m*icur\n\tif icur >= l:\n\t\tbreak\n\ta=icur\n\ts=f(s)\nprint t\n\n"}, {"source_code": "def 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 generate():\n all = []\n for i in range(1, 10):\n all.extend(list(product('47', repeat=i)))\n for i, j in enumerate(all):\n all[i] = int(''.join(list(j)))\n return all\n\n\nfrom itertools import product\nfrom sys import stdin\n\nl, r = arr_inp(1)\nall, ans = generate(), 0\nfor i in all:\n if l > r:\n break\n elif i >= l:\n ans += (min(r, i) - l + 1) * i\n l = i + 1\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n l, r = map(int, input().split())\n \n def nextlucky(i):\n n = ''\n \n for i in str(i):\n n += '4' if i <= '4' else '7'\n \n return int(n)\n\n ans = sum(map(nextlucky, range(l, r+1)))\n\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "\nl=[4,7]\n\nfor i in range(2,10):\n\ts=['4']*i\n\ts1=['7']*i\n\tl.append(int(\"\".join(s)))\n\tl.append(int(\"\".join(s1)))\n\tj=1\n\twhile(j=i:\n count=count+L[j]\n else:\n j=j+1 \n count=count+L[j]\nprint(count)\n "}, {"source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom itertools import combinations_with_replacement\nfrom collections import defaultdict\nfrom bisect import bisect_right\nfrom bisect import bisect_left\n \ndef L():\n return list(map(int, stdin.readline().split()))\n \ndef In():\n return map(int, stdin.readline().split())\n \ndef I():\n return int(stdin.readline())\n \nP = 1000000007\narr = [0, 4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777, 4444, 4447, 4474, 4477, 4744, 4747, 4774, 4777, 7444, 7447, 7474, 7477, 7744, 7747, 7774, 7777, 44444, 44447, 44474, 44477, 44744, 44747, 44774, 44777, 47444, 47447, 47474, 47477, 47744, 47747, 47774, 47777, 74444, 74447, 74474, 74477, 74744, 74747, 74774, 74777, 77444, 77447, 77474, 77477, 77744, 77747, 77774, 77777, 444444, 444447, 444474, 444477, 444744, 444747, 444774, 444777, 447444, 447447, 447474, 447477, 447744, 447747, 447774, 447777, 474444, 474447, 474474, 474477, 474744, 474747, 474774, 474777, 477444, 477447, 477474, 477477, 477744, 477747, 477774, 477777, 744444, 744447, 744474, 744477, 744744, 744747, 744774, 744777, 747444, 747447, 747474, 747477, 747744, 747747, 747774, 747777, 774444, 774447, 774474, 774477, 774744, 774747, 774774, 774777, 777444, 777447, 777474, 777477, 777744, 777747, 777774, 777777, 4444444, 4444447, 4444474, 4444477, 4444744, 4444747, 4444774, 4444777, 4447444, 4447447, 4447474, 4447477, 4447744, 4447747, 4447774, 4447777, 4474444, 4474447, 4474474, 4474477, 4474744, 4474747, 4474774, 4474777, 4477444, 4477447, 4477474, 4477477, 4477744, 4477747, 4477774, 4477777, 4744444, 4744447, 4744474, 4744477, 4744744, 4744747, 4744774, 4744777, 4747444, 4747447, 4747474, 4747477, 4747744, 4747747, 4747774, 4747777, 4774444, 4774447, 4774474, 4774477, 4774744, 4774747, 4774774, 4774777, 4777444, 4777447, 4777474, 4777477, 4777744, 4777747, 4777774, 4777777, 7444444, 7444447, 7444474, 7444477, 7444744, 7444747, 7444774, 7444777, 7447444, 7447447, 7447474, 7447477, 7447744, 7447747, 7447774, 7447777, 7474444, 7474447, 7474474, 7474477, 7474744, 7474747, 7474774, 7474777, 7477444, 7477447, 7477474, 7477477, 7477744, 7477747, 7477774, 7477777, 7744444, 7744447, 7744474, 7744477, 7744744, 7744747, 7744774, 7744777, 7747444, 7747447, 7747474, 7747477, 7747744, 7747747, 7747774, 7747777, 7774444, 7774447, 7774474, 7774477, 7774744, 7774747, 7774774, 7774777, 7777444, 7777447, 7777474, 7777477, 7777744, 7777747, 7777774, 7777777, 44444444, 44444447, 44444474, 44444477, 44444744, 44444747, 44444774, 44444777, 44447444, 44447447, 44447474, 44447477, 44447744, 44447747, 44447774, 44447777, 44474444, 44474447, 44474474, 44474477, 44474744, 44474747, 44474774, 44474777, 44477444, 44477447, 44477474, 44477477, 44477744, 44477747, 44477774, 44477777, 44744444, 44744447, 44744474, 44744477, 44744744, 44744747, 44744774, 44744777, 44747444, 44747447, 44747474, 44747477, 44747744, 44747747, 44747774, 44747777, 44774444, 44774447, 44774474, 44774477, 44774744, 44774747, 44774774, 44774777, 44777444, 44777447, 44777474, 44777477, 44777744, 44777747, 44777774, 44777777, 47444444, 47444447, 47444474, 47444477, 47444744, 47444747, 47444774, 47444777, 47447444, 47447447, 47447474, 47447477, 47447744, 47447747, 47447774, 47447777, 47474444, 47474447, 47474474, 47474477, 47474744, 47474747, 47474774, 47474777, 47477444, 47477447, 47477474, 47477477, 47477744, 47477747, 47477774, 47477777, 47744444, 47744447, 47744474, 47744477, 47744744, 47744747, 47744774, 47744777, 47747444, 47747447, 47747474, 47747477, 47747744, 47747747, 47747774, 47747777, 47774444, 47774447, 47774474, 47774477, 47774744, 47774747, 47774774, 47774777, 47777444, 47777447, 47777474, 47777477, 47777744, 47777747, 47777774, 47777777, 74444444, 74444447, 74444474, 74444477, 74444744, 74444747, 74444774, 74444777, 74447444, 74447447, 74447474, 74447477, 74447744, 74447747, 74447774, 74447777, 74474444, 74474447, 74474474, 74474477, 74474744, 74474747, 74474774, 74474777, 74477444, 74477447, 74477474, 74477477, 74477744, 74477747, 74477774, 74477777, 74744444, 74744447, 74744474, 74744477, 74744744, 74744747, 74744774, 74744777, 74747444, 74747447, 74747474, 74747477, 74747744, 74747747, 74747774, 74747777, 74774444, 74774447, 74774474, 74774477, 74774744, 74774747, 74774774, 74774777, 74777444, 74777447, 74777474, 74777477, 74777744, 74777747, 74777774, 74777777, 77444444, 77444447, 77444474, 77444477, 77444744, 77444747, 77444774, 77444777, 77447444, 77447447, 77447474, 77447477, 77447744, 77447747, 77447774, 77447777, 77474444, 77474447, 77474474, 77474477, 77474744, 77474747, 77474774, 77474777, 77477444, 77477447, 77477474, 77477477, 77477744, 77477747, 77477774, 77477777, 77744444, 77744447, 77744474, 77744477, 77744744, 77744747, 77744774, 77744777, 77747444, 77747447, 77747474, 77747477, 77747744, 77747747, 77747774, 77747777, 77774444, 77774447, 77774474, 77774477, 77774744, 77774747, 77774774, 77774777, 77777444, 77777447, 77777474, 77777477, 77777744, 77777747, 77777774, 77777777, 444444444, 444444447, 444444474, 444444477, 444444744, 444444747, 444444774, 444444777, 444447444, 444447447, 444447474, 444447477, 444447744, 444447747, 444447774, 444447777, 444474444, 444474447, 444474474, 444474477, 444474744, 444474747, 444474774, 444474777, 444477444, 444477447, 444477474, 444477477, 444477744, 444477747, 444477774, 444477777, 444744444, 444744447, 444744474, 444744477, 444744744, 444744747, 444744774, 444744777, 444747444, 444747447, 444747474, 444747477, 444747744, 444747747, 444747774, 444747777, 444774444, 444774447, 444774474, 444774477, 444774744, 444774747, 444774774, 444774777, 444777444, 444777447, 444777474, 444777477, 444777744, 444777747, 444777774, 444777777, 447444444, 447444447, 447444474, 447444477, 447444744, 447444747, 447444774, 447444777, 447447444, 447447447, 447447474, 447447477, 447447744, 447447747, 447447774, 447447777, 447474444, 447474447, 447474474, 447474477, 447474744, 447474747, 447474774, 447474777, 447477444, 447477447, 447477474, 447477477, 447477744, 447477747, 447477774, 447477777, 447744444, 447744447, 447744474, 447744477, 447744744, 447744747, 447744774, 447744777, 447747444, 447747447, 447747474, 447747477, 447747744, 447747747, 447747774, 447747777, 447774444, 447774447, 447774474, 447774477, 447774744, 447774747, 447774774, 447774777, 447777444, 447777447, 447777474, 447777477, 447777744, 447777747, 447777774, 447777777, 474444444, 474444447, 474444474, 474444477, 474444744, 474444747, 474444774, 474444777, 474447444, 474447447, 474447474, 474447477, 474447744, 474447747, 474447774, 474447777, 474474444, 474474447, 474474474, 474474477, 474474744, 474474747, 474474774, 474474777, 474477444, 474477447, 474477474, 474477477, 474477744, 474477747, 474477774, 474477777, 474744444, 474744447, 474744474, 474744477, 474744744, 474744747, 474744774, 474744777, 474747444, 474747447, 474747474, 474747477, 474747744, 474747747, 474747774, 474747777, 474774444, 474774447, 474774474, 474774477, 474774744, 474774747, 474774774, 474774777, 474777444, 474777447, 474777474, 474777477, 474777744, 474777747, 474777774, 474777777, 477444444, 477444447, 477444474, 477444477, 477444744, 477444747, 477444774, 477444777, 477447444, 477447447, 477447474, 477447477, 477447744, 477447747, 477447774, 477447777, 477474444, 477474447, 477474474, 477474477, 477474744, 477474747, 477474774, 477474777, 477477444, 477477447, 477477474, 477477477, 477477744, 477477747, 477477774, 477477777, 477744444, 477744447, 477744474, 477744477, 477744744, 477744747, 477744774, 477744777, 477747444, 477747447, 477747474, 477747477, 477747744, 477747747, 477747774, 477747777, 477774444, 477774447, 477774474, 477774477, 477774744, 477774747, 477774774, 477774777, 477777444, 477777447, 477777474, 477777477, 477777744, 477777747, 477777774, 477777777, 744444444, 744444447, 744444474, 744444477, 744444744, 744444747, 744444774, 744444777, 744447444, 744447447, 744447474, 744447477, 744447744, 744447747, 744447774, 744447777, 744474444, 744474447, 744474474, 744474477, 744474744, 744474747, 744474774, 744474777, 744477444, 744477447, 744477474, 744477477, 744477744, 744477747, 744477774, 744477777, 744744444, 744744447, 744744474, 744744477, 744744744, 744744747, 744744774, 744744777, 744747444, 744747447, 744747474, 744747477, 744747744, 744747747, 744747774, 744747777, 744774444, 744774447, 744774474, 744774477, 744774744, 744774747, 744774774, 744774777, 744777444, 744777447, 744777474, 744777477, 744777744, 744777747, 744777774, 744777777, 747444444, 747444447, 747444474, 747444477, 747444744, 747444747, 747444774, 747444777, 747447444, 747447447, 747447474, 747447477, 747447744, 747447747, 747447774, 747447777, 747474444, 747474447, 747474474, 747474477, 747474744, 747474747, 747474774, 747474777, 747477444, 747477447, 747477474, 747477477, 747477744, 747477747, 747477774, 747477777, 747744444, 747744447, 747744474, 747744477, 747744744, 747744747, 747744774, 747744777, 747747444, 747747447, 747747474, 747747477, 747747744, 747747747, 747747774, 747747777, 747774444, 747774447, 747774474, 747774477, 747774744, 747774747, 747774774, 747774777, 747777444, 747777447, 747777474, 747777477, 747777744, 747777747, 747777774, 747777777, 774444444, 774444447, 774444474, 774444477, 774444744, 774444747, 774444774, 774444777, 774447444, 774447447, 774447474, 774447477, 774447744, 774447747, 774447774, 774447777, 774474444, 774474447, 774474474, 774474477, 774474744, 774474747, 774474774, 774474777, 774477444, 774477447, 774477474, 774477477, 774477744, 774477747, 774477774, 774477777, 774744444, 774744447, 774744474, 774744477, 774744744, 774744747, 774744774, 774744777, 774747444, 774747447, 774747474, 774747477, 774747744, 774747747, 774747774, 774747777, 774774444, 774774447, 774774474, 774774477, 774774744, 774774747, 774774774, 774774777, 774777444, 774777447, 774777474, 774777477, 774777744, 774777747, 774777774, 774777777, 777444444, 777444447, 777444474, 777444477, 777444744, 777444747, 777444774, 777444777, 777447444, 777447447, 777447474, 777447477, 777447744, 777447747, 777447774, 777447777, 777474444, 777474447, 777474474, 777474477, 777474744, 777474747, 777474774, 777474777, 777477444, 777477447, 777477474, 777477477, 777477744, 777477747, 777477774, 777477777, 777744444, 777744447, 777744474, 777744477, 777744744, 777744747, 777744774, 777744777, 777747444, 777747447, 777747474, 777747477, 777747744, 777747747, 777747774, 777747777, 777774444, 777774447, 777774474, 777774477, 777774744, 777774747, 777774774, 777774777, 777777444, 777777447, 777777474, 777777477, 777777744, 777777747, 777777774, 777777777, 4444444444, 4444444447, 4444444474, 4444444477, 4444444744, 4444444747, 4444444774, 4444444777, 4444447444, 4444447447, 4444447474, 4444447477, 4444447744, 4444447747, 4444447774, 4444447777, 4444474444, 4444474447, 4444474474, 4444474477, 4444474744, 4444474747, 4444474774, 4444474777, 4444477444, 4444477447, 4444477474, 4444477477, 4444477744, 4444477747, 4444477774, 4444477777, 4444744444, 4444744447, 4444744474, 4444744477, 4444744744, 4444744747, 4444744774, 4444744777, 4444747444, 4444747447, 4444747474, 4444747477, 4444747744, 4444747747, 4444747774, 4444747777, 4444774444, 4444774447, 4444774474, 4444774477, 4444774744, 4444774747, 4444774774, 4444774777, 4444777444, 4444777447, 4444777474, 4444777477, 4444777744, 4444777747, 4444777774, 4444777777, 4447444444, 4447444447, 4447444474, 4447444477, 4447444744, 4447444747, 4447444774, 4447444777, 4447447444, 4447447447, 4447447474, 4447447477, 4447447744, 4447447747, 4447447774, 4447447777, 4447474444, 4447474447, 4447474474, 4447474477, 4447474744, 4447474747, 4447474774, 4447474777, 4447477444, 4447477447, 4447477474, 4447477477, 4447477744, 4447477747, 4447477774, 4447477777, 4447744444, 4447744447, 4447744474, 4447744477, 4447744744, 4447744747, 4447744774, 4447744777, 4447747444, 4447747447, 4447747474, 4447747477, 4447747744, 4447747747, 4447747774, 4447747777, 4447774444, 4447774447, 4447774474, 4447774477, 4447774744, 4447774747, 4447774774, 4447774777, 4447777444, 4447777447, 4447777474, 4447777477, 4447777744, 4447777747, 4447777774, 4447777777, 4474444444, 4474444447, 4474444474, 4474444477, 4474444744, 4474444747, 4474444774, 4474444777, 4474447444, 4474447447, 4474447474, 4474447477, 4474447744, 4474447747, 4474447774, 4474447777, 4474474444, 4474474447, 4474474474, 4474474477, 4474474744, 4474474747, 4474474774, 4474474777, 4474477444, 4474477447, 4474477474, 4474477477, 4474477744, 4474477747, 4474477774, 4474477777, 4474744444, 4474744447, 4474744474, 4474744477, 4474744744, 4474744747, 4474744774, 4474744777, 4474747444, 4474747447, 4474747474, 4474747477, 4474747744, 4474747747, 4474747774, 4474747777, 4474774444, 4474774447, 4474774474, 4474774477, 4474774744, 4474774747, 4474774774, 4474774777, 4474777444, 4474777447, 4474777474, 4474777477, 4474777744, 4474777747, 4474777774, 4474777777, 4477444444, 4477444447, 4477444474, 4477444477, 4477444744, 4477444747, 4477444774, 4477444777, 4477447444, 4477447447, 4477447474, 4477447477, 4477447744, 4477447747, 4477447774, 4477447777, 4477474444, 4477474447, 4477474474, 4477474477, 4477474744, 4477474747, 4477474774, 4477474777, 4477477444, 4477477447, 4477477474, 4477477477, 4477477744, 4477477747, 4477477774, 4477477777, 4477744444, 4477744447, 4477744474, 4477744477, 4477744744, 4477744747, 4477744774, 4477744777, 4477747444, 4477747447, 4477747474, 4477747477, 4477747744, 4477747747, 4477747774, 4477747777, 4477774444, 4477774447, 4477774474, 4477774477, 4477774744, 4477774747, 4477774774, 4477774777, 4477777444, 4477777447, 4477777474, 4477777477, 4477777744, 4477777747, 4477777774, 4477777777, 4744444444, 4744444447, 4744444474, 4744444477, 4744444744, 4744444747, 4744444774, 4744444777, 4744447444, 4744447447, 4744447474, 4744447477, 4744447744, 4744447747, 4744447774, 4744447777, 4744474444, 4744474447, 4744474474, 4744474477, 4744474744, 4744474747, 4744474774, 4744474777, 4744477444, 4744477447, 4744477474, 4744477477, 4744477744, 4744477747, 4744477774, 4744477777, 4744744444, 4744744447, 4744744474, 4744744477, 4744744744, 4744744747, 4744744774, 4744744777, 4744747444, 4744747447, 4744747474, 4744747477, 4744747744, 4744747747, 4744747774, 4744747777, 4744774444, 4744774447, 4744774474, 4744774477, 4744774744, 4744774747, 4744774774, 4744774777, 4744777444, 4744777447, 4744777474, 4744777477, 4744777744, 4744777747, 4744777774, 4744777777, 4747444444, 4747444447, 4747444474, 4747444477, 4747444744, 4747444747, 4747444774, 4747444777, 4747447444, 4747447447, 4747447474, 4747447477, 4747447744, 4747447747, 4747447774, 4747447777, 4747474444, 4747474447, 4747474474, 4747474477, 4747474744, 4747474747, 4747474774, 4747474777, 4747477444, 4747477447, 4747477474, 4747477477, 4747477744, 4747477747, 4747477774, 4747477777, 4747744444, 4747744447, 4747744474, 4747744477, 4747744744, 4747744747, 4747744774, 4747744777, 4747747444, 4747747447, 4747747474, 4747747477, 4747747744, 4747747747, 4747747774, 4747747777, 4747774444, 4747774447, 4747774474, 4747774477, 4747774744, 4747774747, 4747774774, 4747774777, 4747777444, 4747777447, 4747777474, 4747777477, 4747777744, 4747777747, 4747777774, 4747777777, 4774444444, 4774444447, 4774444474, 4774444477, 4774444744, 4774444747, 4774444774, 4774444777, 4774447444, 4774447447, 4774447474, 4774447477, 4774447744, 4774447747, 4774447774, 4774447777, 4774474444, 4774474447, 4774474474, 4774474477, 4774474744, 4774474747, 4774474774, 4774474777, 4774477444, 4774477447, 4774477474, 4774477477, 4774477744, 4774477747, 4774477774, 4774477777, 4774744444, 4774744447, 4774744474, 4774744477, 4774744744, 4774744747, 4774744774, 4774744777, 4774747444, 4774747447, 4774747474, 4774747477, 4774747744, 4774747747, 4774747774, 4774747777, 4774774444, 4774774447, 4774774474, 4774774477, 4774774744, 4774774747, 4774774774, 4774774777, 4774777444, 4774777447, 4774777474, 4774777477, 4774777744, 4774777747, 4774777774, 4774777777, 4777444444, 4777444447, 4777444474, 4777444477, 4777444744, 4777444747, 4777444774, 4777444777, 4777447444, 4777447447, 4777447474, 4777447477, 4777447744, 4777447747, 4777447774, 4777447777, 4777474444, 4777474447, 4777474474, 4777474477, 4777474744, 4777474747, 4777474774, 4777474777, 4777477444, 4777477447, 4777477474, 4777477477, 4777477744, 4777477747, 4777477774, 4777477777, 4777744444, 4777744447, 4777744474, 4777744477, 4777744744, 4777744747, 4777744774, 4777744777, 4777747444, 4777747447, 4777747474, 4777747477, 4777747744, 4777747747, 4777747774, 4777747777, 4777774444, 4777774447, 4777774474, 4777774477, 4777774744, 4777774747, 4777774774, 4777774777, 4777777444, 4777777447, 4777777474, 4777777477, 4777777744, 4777777747, 4777777774, 4777777777, 7444444444, 7444444447, 7444444474, 7444444477, 7444444744, 7444444747, 7444444774, 7444444777, 7444447444, 7444447447, 7444447474, 7444447477, 7444447744, 7444447747, 7444447774, 7444447777, 7444474444, 7444474447, 7444474474, 7444474477, 7444474744, 7444474747, 7444474774, 7444474777, 7444477444, 7444477447, 7444477474, 7444477477, 7444477744, 7444477747, 7444477774, 7444477777, 7444744444, 7444744447, 7444744474, 7444744477, 7444744744, 7444744747, 7444744774, 7444744777, 7444747444, 7444747447, 7444747474, 7444747477, 7444747744, 7444747747, 7444747774, 7444747777, 7444774444, 7444774447, 7444774474, 7444774477, 7444774744, 7444774747, 7444774774, 7444774777, 7444777444, 7444777447, 7444777474, 7444777477, 7444777744, 7444777747, 7444777774, 7444777777, 7447444444, 7447444447, 7447444474, 7447444477, 7447444744, 7447444747, 7447444774, 7447444777, 7447447444, 7447447447, 7447447474, 7447447477, 7447447744, 7447447747, 7447447774, 7447447777, 7447474444, 7447474447, 7447474474, 7447474477, 7447474744, 7447474747, 7447474774, 7447474777, 7447477444, 7447477447, 7447477474, 7447477477, 7447477744, 7447477747, 7447477774, 7447477777, 7447744444, 7447744447, 7447744474, 7447744477, 7447744744, 7447744747, 7447744774, 7447744777, 7447747444, 7447747447, 7447747474, 7447747477, 7447747744, 7447747747, 7447747774, 7447747777, 7447774444, 7447774447, 7447774474, 7447774477, 7447774744, 7447774747, 7447774774, 7447774777, 7447777444, 7447777447, 7447777474, 7447777477, 7447777744, 7447777747, 7447777774, 7447777777, 7474444444, 7474444447, 7474444474, 7474444477, 7474444744, 7474444747, 7474444774, 7474444777, 7474447444, 7474447447, 7474447474, 7474447477, 7474447744, 7474447747, 7474447774, 7474447777, 7474474444, 7474474447, 7474474474, 7474474477, 7474474744, 7474474747, 7474474774, 7474474777, 7474477444, 7474477447, 7474477474, 7474477477, 7474477744, 7474477747, 7474477774, 7474477777, 7474744444, 7474744447, 7474744474, 7474744477, 7474744744, 7474744747, 7474744774, 7474744777, 7474747444, 7474747447, 7474747474, 7474747477, 7474747744, 7474747747, 7474747774, 7474747777, 7474774444, 7474774447, 7474774474, 7474774477, 7474774744, 7474774747, 7474774774, 7474774777, 7474777444, 7474777447, 7474777474, 7474777477, 7474777744, 7474777747, 7474777774, 7474777777, 7477444444, 7477444447, 7477444474, 7477444477, 7477444744, 7477444747, 7477444774, 7477444777, 7477447444, 7477447447, 7477447474, 7477447477, 7477447744, 7477447747, 7477447774, 7477447777, 7477474444, 7477474447, 7477474474, 7477474477, 7477474744, 7477474747, 7477474774, 7477474777, 7477477444, 7477477447, 7477477474, 7477477477, 7477477744, 7477477747, 7477477774, 7477477777, 7477744444, 7477744447, 7477744474, 7477744477, 7477744744, 7477744747, 7477744774, 7477744777, 7477747444, 7477747447, 7477747474, 7477747477, 7477747744, 7477747747, 7477747774, 7477747777, 7477774444, 7477774447, 7477774474, 7477774477, 7477774744, 7477774747, 7477774774, 7477774777, 7477777444, 7477777447, 7477777474, 7477777477, 7477777744, 7477777747, 7477777774, 7477777777, 7744444444, 7744444447, 7744444474, 7744444477, 7744444744, 7744444747, 7744444774, 7744444777, 7744447444, 7744447447, 7744447474, 7744447477, 7744447744, 7744447747, 7744447774, 7744447777, 7744474444, 7744474447, 7744474474, 7744474477, 7744474744, 7744474747, 7744474774, 7744474777, 7744477444, 7744477447, 7744477474, 7744477477, 7744477744, 7744477747, 7744477774, 7744477777, 7744744444, 7744744447, 7744744474, 7744744477, 7744744744, 7744744747, 7744744774, 7744744777, 7744747444, 7744747447, 7744747474, 7744747477, 7744747744, 7744747747, 7744747774, 7744747777, 7744774444, 7744774447, 7744774474, 7744774477, 7744774744, 7744774747, 7744774774, 7744774777, 7744777444, 7744777447, 7744777474, 7744777477, 7744777744, 7744777747, 7744777774, 7744777777, 7747444444, 7747444447, 7747444474, 7747444477, 7747444744, 7747444747, 7747444774, 7747444777, 7747447444, 7747447447, 7747447474, 7747447477, 7747447744, 7747447747, 7747447774, 7747447777, 7747474444, 7747474447, 7747474474, 7747474477, 7747474744, 7747474747, 7747474774, 7747474777, 7747477444, 7747477447, 7747477474, 7747477477, 7747477744, 7747477747, 7747477774, 7747477777, 7747744444, 7747744447, 7747744474, 7747744477, 7747744744, 7747744747, 7747744774, 7747744777, 7747747444, 7747747447, 7747747474, 7747747477, 7747747744, 7747747747, 7747747774, 7747747777, 7747774444, 7747774447, 7747774474, 7747774477, 7747774744, 7747774747, 7747774774, 7747774777, 7747777444, 7747777447, 7747777474, 7747777477, 7747777744, 7747777747, 7747777774, 7747777777, 7774444444, 7774444447, 7774444474, 7774444477, 7774444744, 7774444747, 7774444774, 7774444777, 7774447444, 7774447447, 7774447474, 7774447477, 7774447744, 7774447747, 7774447774, 7774447777, 7774474444, 7774474447, 7774474474, 7774474477, 7774474744, 7774474747, 7774474774, 7774474777, 7774477444, 7774477447, 7774477474, 7774477477, 7774477744, 7774477747, 7774477774, 7774477777, 7774744444, 7774744447, 7774744474, 7774744477, 7774744744, 7774744747, 7774744774, 7774744777, 7774747444, 7774747447, 7774747474, 7774747477, 7774747744, 7774747747, 7774747774, 7774747777, 7774774444, 7774774447, 7774774474, 7774774477, 7774774744, 7774774747, 7774774774, 7774774777, 7774777444, 7774777447, 7774777474, 7774777477, 7774777744, 7774777747, 7774777774, 7774777777, 7777444444, 7777444447, 7777444474, 7777444477, 7777444744, 7777444747, 7777444774, 7777444777, 7777447444, 7777447447, 7777447474, 7777447477, 7777447744, 7777447747, 7777447774, 7777447777, 7777474444, 7777474447, 7777474474, 7777474477, 7777474744, 7777474747, 7777474774, 7777474777, 7777477444, 7777477447, 7777477474, 7777477477, 7777477744, 7777477747, 7777477774, 7777477777, 7777744444, 7777744447, 7777744474, 7777744477, 7777744744, 7777744747, 7777744774, 7777744777, 7777747444, 7777747447, 7777747474, 7777747477, 7777747744, 7777747747, 7777747774, 7777747777, 7777774444, 7777774447, 7777774474, 7777774477, 7777774744, 7777774747, 7777774774, 7777774777, 7777777444, 7777777447, 7777777474, 7777777477, 7777777744, 7777777747, 7777777774, 7777777777, 44444444444, 44444444447, 44444444474, 44444444477, 44444444744, 44444444747, 44444444774, 44444444777, 44444447444, 44444447447, 44444447474, 44444447477, 44444447744, 44444447747, 44444447774, 44444447777, 44444474444, 44444474447, 44444474474, 44444474477, 44444474744, 44444474747, 44444474774, 44444474777, 44444477444, 44444477447, 44444477474, 44444477477, 44444477744, 44444477747, 44444477774, 44444477777, 44444744444, 44444744447, 44444744474, 44444744477, 44444744744, 44444744747, 44444744774, 44444744777, 44444747444, 44444747447, 44444747474, 44444747477, 44444747744, 44444747747, 44444747774, 44444747777, 44444774444, 44444774447, 44444774474, 44444774477, 44444774744, 44444774747, 44444774774, 44444774777, 44444777444, 44444777447, 44444777474, 44444777477, 44444777744, 44444777747, 44444777774, 44444777777, 44447444444, 44447444447, 44447444474, 44447444477, 44447444744, 44447444747, 44447444774, 44447444777, 44447447444, 44447447447, 44447447474, 44447447477, 44447447744, 44447447747, 44447447774, 44447447777, 44447474444, 44447474447, 44447474474, 44447474477, 44447474744, 44447474747, 44447474774, 44447474777, 44447477444, 44447477447, 44447477474, 44447477477, 44447477744, 44447477747, 44447477774, 44447477777, 44447744444, 44447744447, 44447744474, 44447744477, 44447744744, 44447744747, 44447744774, 44447744777, 44447747444, 44447747447, 44447747474, 44447747477, 44447747744, 44447747747, 44447747774, 44447747777, 44447774444, 44447774447, 44447774474, 44447774477, 44447774744, 44447774747, 44447774774, 44447774777, 44447777444, 44447777447, 44447777474, 44447777477, 44447777744, 44447777747, 44447777774, 44447777777, 44474444444, 44474444447, 44474444474, 44474444477, 44474444744, 44474444747, 44474444774, 44474444777, 44474447444, 44474447447, 44474447474, 44474447477, 44474447744, 44474447747, 44474447774, 44474447777, 44474474444, 44474474447, 44474474474, 44474474477, 44474474744, 44474474747, 44474474774, 44474474777, 44474477444, 44474477447, 44474477474, 44474477477, 44474477744, 44474477747, 44474477774, 44474477777, 44474744444, 44474744447, 44474744474, 44474744477, 44474744744, 44474744747, 44474744774, 44474744777, 44474747444, 44474747447, 44474747474, 44474747477, 44474747744, 44474747747, 44474747774, 44474747777, 44474774444, 44474774447, 44474774474, 44474774477, 44474774744, 44474774747, 44474774774, 44474774777, 44474777444, 44474777447, 44474777474, 44474777477, 44474777744, 44474777747, 44474777774, 44474777777, 44477444444, 44477444447, 44477444474, 44477444477, 44477444744, 44477444747, 44477444774, 44477444777, 44477447444, 44477447447, 44477447474, 44477447477, 44477447744, 44477447747, 44477447774, 44477447777, 44477474444, 44477474447, 44477474474, 44477474477, 44477474744, 44477474747, 44477474774, 44477474777, 44477477444, 44477477447, 44477477474, 44477477477, 44477477744, 44477477747, 44477477774, 44477477777, 44477744444, 44477744447, 44477744474, 44477744477, 44477744744, 44477744747, 44477744774, 44477744777, 44477747444, 44477747447, 44477747474, 44477747477, 44477747744, 44477747747, 44477747774, 44477747777, 44477774444, 44477774447, 44477774474, 44477774477, 44477774744, 44477774747, 44477774774, 44477774777, 44477777444, 44477777447, 44477777474, 44477777477, 44477777744, 44477777747, 44477777774, 44477777777, 44744444444, 44744444447, 44744444474, 44744444477, 44744444744, 44744444747, 44744444774, 44744444777, 44744447444, 44744447447, 44744447474, 44744447477, 44744447744, 44744447747, 44744447774, 44744447777, 44744474444, 44744474447, 44744474474, 44744474477, 44744474744, 44744474747, 44744474774, 44744474777, 44744477444, 44744477447, 44744477474, 44744477477, 44744477744, 44744477747, 44744477774, 44744477777, 44744744444, 44744744447, 44744744474, 44744744477, 44744744744, 44744744747, 44744744774, 44744744777, 44744747444, 44744747447, 44744747474, 44744747477, 44744747744, 44744747747, 44744747774, 44744747777, 44744774444, 44744774447, 44744774474, 44744774477, 44744774744, 44744774747, 44744774774, 44744774777, 44744777444, 44744777447, 44744777474, 44744777477, 44744777744, 44744777747, 44744777774, 44744777777, 44747444444, 44747444447, 44747444474, 44747444477, 44747444744, 44747444747, 44747444774, 44747444777, 44747447444, 44747447447, 44747447474, 44747447477, 44747447744, 44747447747, 44747447774, 44747447777, 44747474444, 44747474447, 44747474474, 44747474477, 44747474744, 44747474747, 44747474774, 44747474777, 44747477444, 44747477447, 44747477474, 44747477477, 44747477744, 44747477747, 44747477774, 44747477777, 44747744444, 44747744447, 44747744474, 44747744477, 44747744744, 44747744747, 44747744774, 44747744777, 44747747444, 44747747447, 44747747474, 44747747477, 44747747744, 44747747747, 44747747774, 44747747777, 44747774444, 44747774447, 44747774474, 44747774477, 44747774744, 44747774747, 44747774774, 44747774777, 44747777444, 44747777447, 44747777474, 44747777477, 44747777744, 44747777747, 44747777774, 44747777777, 44774444444, 44774444447, 44774444474, 44774444477, 44774444744, 44774444747, 44774444774, 44774444777, 44774447444, 44774447447, 44774447474, 44774447477, 44774447744, 44774447747, 44774447774, 44774447777, 44774474444, 44774474447, 44774474474, 44774474477, 44774474744, 44774474747, 44774474774, 44774474777, 44774477444, 44774477447, 44774477474, 44774477477, 44774477744, 44774477747, 44774477774, 44774477777, 44774744444, 44774744447, 44774744474, 44774744477, 44774744744, 44774744747, 44774744774, 44774744777, 44774747444, 44774747447, 44774747474, 44774747477, 44774747744, 44774747747, 44774747774, 44774747777, 44774774444, 44774774447, 44774774474, 44774774477, 44774774744, 44774774747, 44774774774, 44774774777, 44774777444, 44774777447, 44774777474, 44774777477, 44774777744, 44774777747, 44774777774, 44774777777, 44777444444, 44777444447, 44777444474, 44777444477, 44777444744, 44777444747, 44777444774, 44777444777, 44777447444, 44777447447, 44777447474, 44777447477, 44777447744, 44777447747, 44777447774, 44777447777, 44777474444, 44777474447, 44777474474, 44777474477, 44777474744, 44777474747, 44777474774, 44777474777, 44777477444, 44777477447, 44777477474, 44777477477, 44777477744, 44777477747, 44777477774, 44777477777, 44777744444, 44777744447, 44777744474, 44777744477, 44777744744, 44777744747, 44777744774, 44777744777, 44777747444, 44777747447, 44777747474, 44777747477, 44777747744, 44777747747, 44777747774, 44777747777, 44777774444, 44777774447, 44777774474, 44777774477, 44777774744, 44777774747, 44777774774, 44777774777, 44777777444, 44777777447, 44777777474, 44777777477, 44777777744, 44777777747, 44777777774, 44777777777, 47444444444, 47444444447, 47444444474, 47444444477, 47444444744, 47444444747, 47444444774, 47444444777, 47444447444, 47444447447, 47444447474, 47444447477, 47444447744, 47444447747, 47444447774, 47444447777, 47444474444, 47444474447, 47444474474, 47444474477, 47444474744, 47444474747, 47444474774, 47444474777, 47444477444, 47444477447, 47444477474, 47444477477, 47444477744, 47444477747, 47444477774, 47444477777, 47444744444, 47444744447, 47444744474, 47444744477, 47444744744, 47444744747, 47444744774, 47444744777, 47444747444, 47444747447, 47444747474, 47444747477, 47444747744, 47444747747, 47444747774, 47444747777, 47444774444, 47444774447, 47444774474, 47444774477, 47444774744, 47444774747, 47444774774, 47444774777, 47444777444, 47444777447, 47444777474, 47444777477, 47444777744, 47444777747, 47444777774, 47444777777, 47447444444, 47447444447, 47447444474, 47447444477, 47447444744, 47447444747, 47447444774, 47447444777, 47447447444, 47447447447, 47447447474, 47447447477, 47447447744, 47447447747, 47447447774, 47447447777, 47447474444, 47447474447, 47447474474, 47447474477, 47447474744, 47447474747, 47447474774, 47447474777, 47447477444, 47447477447, 47447477474, 47447477477, 47447477744, 47447477747, 47447477774, 47447477777, 47447744444, 47447744447, 47447744474, 47447744477, 47447744744, 47447744747, 47447744774, 47447744777, 47447747444, 47447747447, 47447747474, 47447747477, 47447747744, 47447747747, 47447747774, 47447747777, 47447774444, 47447774447, 47447774474, 47447774477, 47447774744, 47447774747, 47447774774, 47447774777, 47447777444, 47447777447, 47447777474, 47447777477, 47447777744, 47447777747, 47447777774, 47447777777, 47474444444, 47474444447, 47474444474, 47474444477, 47474444744, 47474444747, 47474444774, 47474444777, 47474447444, 47474447447, 47474447474, 47474447477, 47474447744, 47474447747, 47474447774, 47474447777, 47474474444, 47474474447, 47474474474, 47474474477, 47474474744, 47474474747, 47474474774, 47474474777, 47474477444, 47474477447, 47474477474, 47474477477, 47474477744, 47474477747, 47474477774, 47474477777, 47474744444, 47474744447, 47474744474, 47474744477, 47474744744, 47474744747, 47474744774, 47474744777, 47474747444, 47474747447, 47474747474, 47474747477, 47474747744, 47474747747, 47474747774, 47474747777, 47474774444, 47474774447, 47474774474, 47474774477, 47474774744, 47474774747, 47474774774, 47474774777, 47474777444, 47474777447, 47474777474, 47474777477, 47474777744, 47474777747, 47474777774, 47474777777, 47477444444, 47477444447, 47477444474, 47477444477, 47477444744, 47477444747, 47477444774, 47477444777, 47477447444, 47477447447, 47477447474, 47477447477, 47477447744, 47477447747, 47477447774, 47477447777, 47477474444, 47477474447, 47477474474, 47477474477, 47477474744, 47477474747, 47477474774, 47477474777, 47477477444, 47477477447, 47477477474, 47477477477, 47477477744, 47477477747, 47477477774, 47477477777, 47477744444, 47477744447, 47477744474, 47477744477, 47477744744, 47477744747, 47477744774, 47477744777, 47477747444, 47477747447, 47477747474, 47477747477, 47477747744, 47477747747, 47477747774, 47477747777, 47477774444, 47477774447, 47477774474, 47477774477, 47477774744, 47477774747, 47477774774, 47477774777, 47477777444, 47477777447, 47477777474, 47477777477, 47477777744, 47477777747, 47477777774, 47477777777, 47744444444, 47744444447, 47744444474, 47744444477, 47744444744, 47744444747, 47744444774, 47744444777, 47744447444, 47744447447, 47744447474, 47744447477, 47744447744, 47744447747, 47744447774, 47744447777, 47744474444, 47744474447, 47744474474, 47744474477, 47744474744, 47744474747, 47744474774, 47744474777, 47744477444, 47744477447, 47744477474, 47744477477, 47744477744, 47744477747, 47744477774, 47744477777, 47744744444, 47744744447, 47744744474, 47744744477, 47744744744, 47744744747, 47744744774, 47744744777, 47744747444, 47744747447, 47744747474, 47744747477, 47744747744, 47744747747, 47744747774, 47744747777, 47744774444, 47744774447, 47744774474, 47744774477, 47744774744, 47744774747, 47744774774, 47744774777, 47744777444, 47744777447, 47744777474, 47744777477, 47744777744, 47744777747, 47744777774, 47744777777, 47747444444, 47747444447, 47747444474, 47747444477, 47747444744, 47747444747, 47747444774, 47747444777, 47747447444, 47747447447, 47747447474, 47747447477, 47747447744, 47747447747, 47747447774, 47747447777, 47747474444, 47747474447, 47747474474, 47747474477, 47747474744, 47747474747, 47747474774, 47747474777, 47747477444, 47747477447, 47747477474, 47747477477, 47747477744, 47747477747, 47747477774, 47747477777, 47747744444, 47747744447, 47747744474, 47747744477, 47747744744, 47747744747, 47747744774, 47747744777, 47747747444, 47747747447, 47747747474, 47747747477, 47747747744, 47747747747, 47747747774, 47747747777, 47747774444, 47747774447, 47747774474, 47747774477, 47747774744, 47747774747, 47747774774, 47747774777, 47747777444, 47747777447, 47747777474, 47747777477, 47747777744, 47747777747, 47747777774, 47747777777, 47774444444, 47774444447, 47774444474, 47774444477, 47774444744, 47774444747, 47774444774, 47774444777, 47774447444, 47774447447, 47774447474, 47774447477, 47774447744, 47774447747, 47774447774, 47774447777, 47774474444, 47774474447, 47774474474, 47774474477, 47774474744, 47774474747, 47774474774, 47774474777, 47774477444, 47774477447, 47774477474, 47774477477, 47774477744, 47774477747, 47774477774, 47774477777, 47774744444, 47774744447, 47774744474, 47774744477, 47774744744, 47774744747, 47774744774, 47774744777, 47774747444, 47774747447, 47774747474, 47774747477, 47774747744, 47774747747, 47774747774, 47774747777, 47774774444, 47774774447, 47774774474, 47774774477, 47774774744, 47774774747, 47774774774, 47774774777, 47774777444, 47774777447, 47774777474, 47774777477, 47774777744, 47774777747, 47774777774, 47774777777, 47777444444, 47777444447, 47777444474, 47777444477, 47777444744, 47777444747, 47777444774, 47777444777, 47777447444, 47777447447, 47777447474, 47777447477, 47777447744, 47777447747, 47777447774, 47777447777, 47777474444, 47777474447, 47777474474, 47777474477, 47777474744, 47777474747, 47777474774, 47777474777, 47777477444, 47777477447, 47777477474, 47777477477, 47777477744, 47777477747, 47777477774, 47777477777, 47777744444, 47777744447, 47777744474, 47777744477, 47777744744, 47777744747, 47777744774, 47777744777, 47777747444, 47777747447, 47777747474, 47777747477, 47777747744, 47777747747, 47777747774, 47777747777, 47777774444, 47777774447, 47777774474, 47777774477, 47777774744, 47777774747, 47777774774, 47777774777, 47777777444, 47777777447, 47777777474, 47777777477, 47777777744, 47777777747, 47777777774, 47777777777, 74444444444, 74444444447, 74444444474, 74444444477, 74444444744, 74444444747, 74444444774, 74444444777, 74444447444, 74444447447, 74444447474, 74444447477, 74444447744, 74444447747, 74444447774, 74444447777, 74444474444, 74444474447, 74444474474, 74444474477, 74444474744, 74444474747, 74444474774, 74444474777, 74444477444, 74444477447, 74444477474, 74444477477, 74444477744, 74444477747, 74444477774, 74444477777, 74444744444, 74444744447, 74444744474, 74444744477, 74444744744, 74444744747, 74444744774, 74444744777, 74444747444, 74444747447, 74444747474, 74444747477, 74444747744, 74444747747, 74444747774, 74444747777, 74444774444, 74444774447, 74444774474, 74444774477, 74444774744, 74444774747, 74444774774, 74444774777, 74444777444, 74444777447, 74444777474, 74444777477, 74444777744, 74444777747, 74444777774, 74444777777, 74447444444, 74447444447, 74447444474, 74447444477, 74447444744, 74447444747, 74447444774, 74447444777, 74447447444, 74447447447, 74447447474, 74447447477, 74447447744, 74447447747, 74447447774, 74447447777, 74447474444, 74447474447, 74447474474, 74447474477, 74447474744, 74447474747, 74447474774, 74447474777, 74447477444, 74447477447, 74447477474, 74447477477, 74447477744, 74447477747, 74447477774, 74447477777, 74447744444, 74447744447, 74447744474, 74447744477, 74447744744, 74447744747, 74447744774, 74447744777, 74447747444, 74447747447, 74447747474, 74447747477, 74447747744, 74447747747, 74447747774, 74447747777, 74447774444, 74447774447, 74447774474, 74447774477, 74447774744, 74447774747, 74447774774, 74447774777, 74447777444, 74447777447, 74447777474, 74447777477, 74447777744, 74447777747, 74447777774, 74447777777, 74474444444, 74474444447, 74474444474, 74474444477, 74474444744, 74474444747, 74474444774, 74474444777, 74474447444, 74474447447, 74474447474, 74474447477, 74474447744, 74474447747, 74474447774, 74474447777, 74474474444, 74474474447, 74474474474, 74474474477, 74474474744, 74474474747, 74474474774, 74474474777, 74474477444, 74474477447, 74474477474, 74474477477, 74474477744, 74474477747, 74474477774, 74474477777, 74474744444, 74474744447, 74474744474, 74474744477, 74474744744, 74474744747, 74474744774, 74474744777, 74474747444, 74474747447, 74474747474, 74474747477, 74474747744, 74474747747, 74474747774, 74474747777, 74474774444, 74474774447, 74474774474, 74474774477, 74474774744, 74474774747, 74474774774, 74474774777, 74474777444, 74474777447, 74474777474, 74474777477, 74474777744, 74474777747, 74474777774, 74474777777, 74477444444, 74477444447, 74477444474, 74477444477, 74477444744, 74477444747, 74477444774, 74477444777, 74477447444, 74477447447, 74477447474, 74477447477, 74477447744, 74477447747, 74477447774, 74477447777, 74477474444, 74477474447, 74477474474, 74477474477, 74477474744, 74477474747, 74477474774, 74477474777, 74477477444, 74477477447, 74477477474, 74477477477, 74477477744, 74477477747, 74477477774, 74477477777, 74477744444, 74477744447, 74477744474, 74477744477, 74477744744, 74477744747, 74477744774, 74477744777, 74477747444, 74477747447, 74477747474, 74477747477, 74477747744, 74477747747, 74477747774, 74477747777, 74477774444, 74477774447, 74477774474, 74477774477, 74477774744, 74477774747, 74477774774, 74477774777, 74477777444, 74477777447, 74477777474, 74477777477, 74477777744, 74477777747, 74477777774, 74477777777, 74744444444, 74744444447, 74744444474, 74744444477, 74744444744, 74744444747, 74744444774, 74744444777, 74744447444, 74744447447, 74744447474, 74744447477, 74744447744, 74744447747, 74744447774, 74744447777, 74744474444, 74744474447, 74744474474, 74744474477, 74744474744, 74744474747, 74744474774, 74744474777, 74744477444, 74744477447, 74744477474, 74744477477, 74744477744, 74744477747, 74744477774, 74744477777, 74744744444, 74744744447, 74744744474, 74744744477, 74744744744, 74744744747, 74744744774, 74744744777, 74744747444, 74744747447, 74744747474, 74744747477, 74744747744, 74744747747, 74744747774, 74744747777, 74744774444, 74744774447, 74744774474, 74744774477, 74744774744, 74744774747, 74744774774, 74744774777, 74744777444, 74744777447, 74744777474, 74744777477, 74744777744, 74744777747, 74744777774, 74744777777, 74747444444, 74747444447, 74747444474, 74747444477, 74747444744, 74747444747, 74747444774, 74747444777, 74747447444, 74747447447, 74747447474, 74747447477, 74747447744, 74747447747, 74747447774, 74747447777, 74747474444, 74747474447, 74747474474, 74747474477, 74747474744, 74747474747, 74747474774, 74747474777, 74747477444, 74747477447, 74747477474, 74747477477, 74747477744, 74747477747, 74747477774, 74747477777, 74747744444, 74747744447, 74747744474, 74747744477, 74747744744, 74747744747, 74747744774, 74747744777, 74747747444, 74747747447, 74747747474, 74747747477, 74747747744, 74747747747, 74747747774, 74747747777, 74747774444, 74747774447, 74747774474, 74747774477, 74747774744, 74747774747, 74747774774, 74747774777, 74747777444, 74747777447, 74747777474, 74747777477, 74747777744, 74747777747, 74747777774, 74747777777, 74774444444, 74774444447, 74774444474, 74774444477, 74774444744, 74774444747, 74774444774, 74774444777, 74774447444, 74774447447, 74774447474, 74774447477, 74774447744, 74774447747, 74774447774, 74774447777, 74774474444, 74774474447, 74774474474, 74774474477, 74774474744, 74774474747, 74774474774, 74774474777, 74774477444, 74774477447, 74774477474, 74774477477, 74774477744, 74774477747, 74774477774, 74774477777, 74774744444, 74774744447, 74774744474, 74774744477, 74774744744, 74774744747, 74774744774, 74774744777, 74774747444, 74774747447, 74774747474, 74774747477, 74774747744, 74774747747, 74774747774, 74774747777, 74774774444, 74774774447, 74774774474, 74774774477, 74774774744, 74774774747, 74774774774, 74774774777, 74774777444, 74774777447, 74774777474, 74774777477, 74774777744, 74774777747, 74774777774, 74774777777, 74777444444, 74777444447, 74777444474, 74777444477, 74777444744, 74777444747, 74777444774, 74777444777, 74777447444, 74777447447, 74777447474, 74777447477, 74777447744, 74777447747, 74777447774, 74777447777, 74777474444, 74777474447, 74777474474, 74777474477, 74777474744, 74777474747, 74777474774, 74777474777, 74777477444, 74777477447, 74777477474, 74777477477, 74777477744, 74777477747, 74777477774, 74777477777, 74777744444, 74777744447, 74777744474, 74777744477, 74777744744, 74777744747, 74777744774, 74777744777, 74777747444, 74777747447, 74777747474, 74777747477, 74777747744, 74777747747, 74777747774, 74777747777, 74777774444, 74777774447, 74777774474, 74777774477, 74777774744, 74777774747, 74777774774, 74777774777, 74777777444, 74777777447, 74777777474, 74777777477, 74777777744, 74777777747, 74777777774, 74777777777, 77444444444, 77444444447, 77444444474, 77444444477, 77444444744, 77444444747, 77444444774, 77444444777, 77444447444, 77444447447, 77444447474, 77444447477, 77444447744, 77444447747, 77444447774, 77444447777, 77444474444, 77444474447, 77444474474, 77444474477, 77444474744, 77444474747, 77444474774, 77444474777, 77444477444, 77444477447, 77444477474, 77444477477, 77444477744, 77444477747, 77444477774, 77444477777, 77444744444, 77444744447, 77444744474, 77444744477, 77444744744, 77444744747, 77444744774, 77444744777, 77444747444, 77444747447, 77444747474, 77444747477, 77444747744, 77444747747, 77444747774, 77444747777, 77444774444, 77444774447, 77444774474, 77444774477, 77444774744, 77444774747, 77444774774, 77444774777, 77444777444, 77444777447, 77444777474, 77444777477, 77444777744, 77444777747, 77444777774, 77444777777, 77447444444, 77447444447, 77447444474, 77447444477, 77447444744, 77447444747, 77447444774, 77447444777, 77447447444, 77447447447, 77447447474, 77447447477, 77447447744, 77447447747, 77447447774, 77447447777, 77447474444, 77447474447, 77447474474, 77447474477, 77447474744, 77447474747, 77447474774, 77447474777, 77447477444, 77447477447, 77447477474, 77447477477, 77447477744, 77447477747, 77447477774, 77447477777, 77447744444, 77447744447, 77447744474, 77447744477, 77447744744, 77447744747, 77447744774, 77447744777, 77447747444, 77447747447, 77447747474, 77447747477, 77447747744, 77447747747, 77447747774, 77447747777, 77447774444, 77447774447, 77447774474, 77447774477, 77447774744, 77447774747, 77447774774, 77447774777, 77447777444, 77447777447, 77447777474, 77447777477, 77447777744, 77447777747, 77447777774, 77447777777, 77474444444, 77474444447, 77474444474, 77474444477, 77474444744, 77474444747, 77474444774, 77474444777, 77474447444, 77474447447, 77474447474, 77474447477, 77474447744, 77474447747, 77474447774, 77474447777, 77474474444, 77474474447, 77474474474, 77474474477, 77474474744, 77474474747, 77474474774, 77474474777, 77474477444, 77474477447, 77474477474, 77474477477, 77474477744, 77474477747, 77474477774, 77474477777, 77474744444, 77474744447, 77474744474, 77474744477, 77474744744, 77474744747, 77474744774, 77474744777, 77474747444, 77474747447, 77474747474, 77474747477, 77474747744, 77474747747, 77474747774, 77474747777, 77474774444, 77474774447, 77474774474, 77474774477, 77474774744, 77474774747, 77474774774, 77474774777, 77474777444, 77474777447, 77474777474, 77474777477, 77474777744, 77474777747, 77474777774, 77474777777, 77477444444, 77477444447, 77477444474, 77477444477, 77477444744, 77477444747, 77477444774, 77477444777, 77477447444, 77477447447, 77477447474, 77477447477, 77477447744, 77477447747, 77477447774, 77477447777, 77477474444, 77477474447, 77477474474, 77477474477, 77477474744, 77477474747, 77477474774, 77477474777, 77477477444, 77477477447, 77477477474, 77477477477, 77477477744, 77477477747, 77477477774, 77477477777, 77477744444, 77477744447, 77477744474, 77477744477, 77477744744, 77477744747, 77477744774, 77477744777, 77477747444, 77477747447, 77477747474, 77477747477, 77477747744, 77477747747, 77477747774, 77477747777, 77477774444, 77477774447, 77477774474, 77477774477, 77477774744, 77477774747, 77477774774, 77477774777, 77477777444, 77477777447, 77477777474, 77477777477, 77477777744, 77477777747, 77477777774, 77477777777, 77744444444, 77744444447, 77744444474, 77744444477, 77744444744, 77744444747, 77744444774, 77744444777, 77744447444, 77744447447, 77744447474, 77744447477, 77744447744, 77744447747, 77744447774, 77744447777, 77744474444, 77744474447, 77744474474, 77744474477, 77744474744, 77744474747, 77744474774, 77744474777, 77744477444, 77744477447, 77744477474, 77744477477, 77744477744, 77744477747, 77744477774, 77744477777, 77744744444, 77744744447, 77744744474, 77744744477, 77744744744, 77744744747, 77744744774, 77744744777, 77744747444, 77744747447, 77744747474, 77744747477, 77744747744, 77744747747, 77744747774, 77744747777, 77744774444, 77744774447, 77744774474, 77744774477, 77744774744, 77744774747, 77744774774, 77744774777, 77744777444, 77744777447, 77744777474, 77744777477, 77744777744, 77744777747, 77744777774, 77744777777, 77747444444, 77747444447, 77747444474, 77747444477, 77747444744, 77747444747, 77747444774, 77747444777, 77747447444, 77747447447, 77747447474, 77747447477, 77747447744, 77747447747, 77747447774, 77747447777, 77747474444, 77747474447, 77747474474, 77747474477, 77747474744, 77747474747, 77747474774, 77747474777, 77747477444, 77747477447, 77747477474, 77747477477, 77747477744, 77747477747, 77747477774, 77747477777, 77747744444, 77747744447, 77747744474, 77747744477, 77747744744, 77747744747, 77747744774, 77747744777, 77747747444, 77747747447, 77747747474, 77747747477, 77747747744, 77747747747, 77747747774, 77747747777, 77747774444, 77747774447, 77747774474, 77747774477, 77747774744, 77747774747, 77747774774, 77747774777, 77747777444, 77747777447, 77747777474, 77747777477, 77747777744, 77747777747, 77747777774, 77747777777, 77774444444, 77774444447, 77774444474, 77774444477, 77774444744, 77774444747, 77774444774, 77774444777, 77774447444, 77774447447, 77774447474, 77774447477, 77774447744, 77774447747, 77774447774, 77774447777, 77774474444, 77774474447, 77774474474, 77774474477, 77774474744, 77774474747, 77774474774, 77774474777, 77774477444, 77774477447, 77774477474, 77774477477, 77774477744, 77774477747, 77774477774, 77774477777, 77774744444, 77774744447, 77774744474, 77774744477, 77774744744, 77774744747, 77774744774, 77774744777, 77774747444, 77774747447, 77774747474, 77774747477, 77774747744, 77774747747, 77774747774, 77774747777, 77774774444, 77774774447, 77774774474, 77774774477, 77774774744, 77774774747, 77774774774, 77774774777, 77774777444, 77774777447, 77774777474, 77774777477, 77774777744, 77774777747, 77774777774, 77774777777, 77777444444, 77777444447, 77777444474, 77777444477, 77777444744, 77777444747, 77777444774, 77777444777, 77777447444, 77777447447, 77777447474, 77777447477, 77777447744, 77777447747, 77777447774, 77777447777, 77777474444, 77777474447, 77777474474, 77777474477, 77777474744, 77777474747, 77777474774, 77777474777, 77777477444, 77777477447, 77777477474, 77777477477, 77777477744, 77777477747, 77777477774, 77777477777, 77777744444, 77777744447, 77777744474, 77777744477, 77777744744, 77777744747, 77777744774, 77777744777, 77777747444, 77777747447, 77777747474, 77777747477, 77777747744, 77777747747, 77777747774, 77777747777, 77777774444, 77777774447, 77777774474, 77777774477, 77777774744, 77777774747, 77777774774, 77777774777, 77777777444, 77777777447, 77777777474, 77777777477, 77777777744, 77777777747, 77777777774, 77777777777]\n\nl, r = In()\nx = bisect_left(arr, l)\ny = bisect_right(arr, r)\nif l == r:\n print(arr[x])\nelse:\n sm = arr[x]*(arr[x]-l+1)\n for i in range(x+1, y):\n sm += (arr[i]-arr[i-1])*arr[i]\n if r > arr[y-1]:\n sm += arr[y]*(r-arr[y-1])\n print(sm)"}, {"source_code": "from itertools import product\n\nl, r = map(int, input().split())\nlucky_nums = sorted(int(''.join(p)) for r in range(1, 9) for p in product(\"47\", repeat=r))\nans = 0\n\nfor lucky_num in lucky_nums:\n if l <= lucky_num <= r:\n ans += (lucky_num - l + 1) * lucky_num\n l = lucky_num + 1\n elif l <= lucky_num and r < lucky_num:\n ans += (r - l + 1) * lucky_num\n break\n\nprint(ans)"}, {"source_code": "def lucky(n):\n for digit in str(n):\n if digit not in '47':\n return False\n return True\n\nl, r = map(int, input().split())\n\nres = 0\nnext_lucky = 0\nfor n in range(r, l-1, -1):\n if lucky(n):\n next_lucky = n\n res += next_lucky\n \nprint(res)\n "}, {"source_code": "luckies = []\n\ndef generate(s, n):\n if n != 0:\n a = 10 * s + 4\n b = 10 * s + 7\n luckies.append(a)\n luckies.append(b)\n generate(a, n - 1)\n generate(b, n - 1)\n \ngenerate(0, 10)\nluckies.sort()\n\nl, r = map(int, input().split())\n\na = 0; b = len(luckies) - 1\nL = 0\nwhile a <= b:\n m = (a+b) // 2\n if luckies[m] >= l:\n L = m\n b = m - 1\n else:\n a = m + 1\n \na = 0; b = len(luckies) - 1\nR = 0\nwhile a <= b:\n m = (a+b) // 2\n if luckies[m] >= r:\n R = m\n b = m - 1\n else:\n a = m + 1\n \na = 0; b = len(luckies) - 1\nS = 0\nwhile a <= b:\n m = (a+b) // 2\n if luckies[m] <= r:\n S = m\n a = m + 1\n else:\n b = m - 1\n\nres = luckies[L] * (luckies[L] - l + 1) + luckies[R] * (r - luckies[S])\nfor i in range(L, S):\n res += luckies[i+1] * (luckies[i+1] - luckies[i])\nprint(res)\n \n \n \n "}, {"source_code": "a,b=map(int,input().strip().split())\nL=[0,4,7]\ndef generateLuckyNumbers(L,a):\n if a <= 100000001:\n x = a*10+4\n y = a*10+7\n L.append(x)\n L.append(y)\n return L \ndef recherche_dichotomique( element, liste_triee ):\n a = 0\n b = len(liste_triee)-1\n m = (a+b)//2\n while a < b :\n if liste_triee[m] == element :\n return m\n elif liste_triee[m] > element :\n b = m-1\n else :\n a = m+1\n m = (a+b)//2\n return a\ndef calcul(k,l,e,d):\n if d>k:\n return l-d+1\n else:\n return(min(l-k,e-k))\n \n\ni=1\nwhile i[47]*)(?P.*$)\")\n\ndef nxt(n):\n s = str(n)\n\n if re.search(trivial, s):\n return n\n elif re.search(smaller, s):\n return ones(len(s)) * 4\n elif re.search(medium, s):\n return ones(len(s)) * 7 - ones(len(s) - 1) * 3\n elif re.search(bigger, s):\n return ones(len(s) + 1) * 4\n elif re.search(sophisticated, s):\n m = re.match(sophisticated, s)\n p = m.group('prefix').strip()\n s = m.group('suffix').strip()\n return int(p) * (10 ** len(s)) + nxt(int(s))\n\ndef solve(a, b):\n res = 0\n \n while True:\n print a, b,\n c = nxt(a)\n print c\n if c < b:\n res += (c - a + 1) * c\n a = c + 1\n else:\n res += (b - a + 1) * c \n return res\n\n[a, b] = map(int, raw_input().split())\nprint solve(a, b)\n"}, {"source_code": "def gennextnum(nextnum):\n s = str(nextnum)\n sevens = 0\n first4 = 0\n for c in s:\n if c == '7':\n sevens += 1\n else:\n first4 = len(s) - s[::-1].index(c) - 1\n if sevens == len(s):\n ret = ''\n for i in range(len(s)+1):\n ret+='4'\n return int(ret)\n else:\n return int(s[:first4] + '7' + s[first4+1:])\n\nl, r = map(int, input().split())\nnextnum = 4\n'''\nfor i in range(10):\n print(nextnum)\n nextnum = gennextnum(nextnum)\n'''\nscore = 0\ni = l\nprevnum = 4\nwhile i < r+1:\n while i > nextnum:\n prevnum = nextnum\n nextnum = gennextnum(nextnum)\n if nextnum + 1 > r:\n score += (r - i + 1)*nextnum\n break\n else:\n score += (nextnum - i + 1) * nextnum\n i = nextnum + 1\n #print(i)\nprint(score)"}, {"source_code": "def nxt(num):\n st=str(num)\n for i in range(len(st)):\n if st[i:]>\"7\"*(len(st)-i):\n if i==0:\n st=\"4\"*(len(st)+1)\n\n else:\n st=st[:i-1]+\"7\"+\"4\"*(len(st[i:]))\n break;\n elif st[i]<\"4\":\n st=st[:i]+\"4\"*(len(st[i:]))\n break\n elif st[i]<=\"7\" and st[i]>\"4\":\n st=st[:i]+\"7\"*(len(st[i:]))\n break\n return int(st) \n\nlst=list(map(int,input().split()))\nl=lst[0]\nr=lst[1]\ns=0\nn=0\ni=l\nwhile i<=r:\n n=nxt(i)\n if n<=r:\n s=s+n*(n-i+1)\n i=n+1\n else:\n s=s+n*(r-i+1)\n break\nprint(s)\n "}, {"source_code": "l,r = map(int,input().split())\narr =[4,7]\nsumi=0\nk=0\nfor i in range(0,9):\n\tfor j in range(k,k+2**(i+1)):\n\t\tarr.append(arr[j]*10+4)\n\t\tarr.append(arr[j]*10+7)\n\tk=2**(i+1)\nwhile(l<=r):\n\tc=-1\n\tif (l<=4):\n\t\tc=4\n\telse:\n\t\tfor i in range(1,len(arr)):\n\t\t\tprint(i,arr[i],sep=\" \")\n\t\t\tif (l<=arr[i] and l>arr[i-1]):\n\t\t\t\tc=arr[i]\n\t\t\t\tbreak;\n\tif r<=c:\n\t\tsumi=sumi+((r-l+1)*c)\n\t\tl=r+1\n\telse:\n\t\tsumi=sumi+((c-l+1)*c)\n\t\tl=c+1\nprint(sumi)\n\n\t\t\t"}, {"source_code": "import bisect\n\ndef foo():\n\tl=[4,7]\n\n\twhile(len(str(l[-1]))<12):\n\t\tz=[]\n\t\tfor i in range(0,len(l)):\n\t\t\tfor j in range(0,len(l)):\n\t\t\t\ts=str(l[i])+str(l[j])\n\t\t\t\tif(len(s)>12):\n\t\t\t\t\treturn l\n\t\t\t\tz.append(int(s))\n\t\t\t\t#print(len(s))\n\t\tl=l+z\n\t\t\n\t\t\nl=foo()\nl=list(set(l))\nl.sort()\n#for i in l:\n#\tprint(i)\nn,m=map(int,input().split())\nc=0\nj=0\nfor i in range(n,m+1):\n\tif(i10:s.add(res)\n\telse:\n\t\tif res==0:f(st+1,res)\n\t\tfor i in 4,7:f(st+1,res*10+i)\nf(0,0)\ns=sorted(s)\na=0\nb=len(s)\nwhile s[a]r:b-=1\nq=0\nfor i in range(a,b-1):q+=s[i+1]*(s[i+1]-s[i])\nprint(q+s[a]*(s[a]-l+1)+s[b]*(r-s[b-1]))"}, {"source_code": "def 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 \nl,r=map(int,input().split())\ne=[4,7]\nt=2\nc=0\nwhile(e[-1]<=1000000000):\n te=len(e)\n c+=1\n for i in range(t):\n e.append(4*pow(10,c)+e[te-t+i])\n for i in range(t):\n e.append(7*pow(10,c)+e[te-t+i])\n t*=2\nind=countGreater(e,len(e),l)\ns=l\nind=len(e)-ind\nend=min(r,e[ind])\nmul=e[ind]\n#print(mul)\nans=0\nwhile(True):\n #print(s,end,mul)\n ans+=(end-s+1)*mul\n if end==r:\n break\n s=end+1\n end=e[ind+1]\n mul=e[ind+1]\nprint(ans)\nprint(ans)"}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\nluckynumbers.sort()\n\nlowerbound = 0\nupperbound = 0\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]lowerbound:\n ans += luckynumbers[upperbound] * (r - luckynumbers[upperbound - 1])\n\nprint(ans)\n\n\n"}, {"source_code": "from itertools import product\nfrom bisect import bisect_left as bsearch\n\nMAXDIG = 10\n\ndef main():\n global MAXDIG\n (l, r) = map(int, input().split(' '))\n if l == r:\n return r\n luckies = []\n for i in range(MAXDIG):\n lst = product([7, 4], repeat = i)\n for x in lst:\n s = ''.join(map(str, x))\n if len(s) != 0:\n num = int(s)\n luckies.append(num)\n luckies = sorted(luckies)\n i = bsearch(luckies, l)\n j = bsearch(luckies, r)\n s = 0\n n = r - l + 1\n left = n\n while luckies[i] <= luckies[j]:\n dif = min(luckies[i] - l + 1, left)\n left -= dif\n l += dif\n s += (dif * luckies[i])\n i += 1\n return s\n\nprint(main())\n\n"}, {"source_code": "lucky = []\nlucky.append(0)\nlucky.append(4)\nlucky.append(7)\ni = 3\nnum = 0\nwhile num<=1000000000:\n if i%2==1:\n num = (lucky[i//2]*10)+4\n lucky.append(num)\n else:\n num = (lucky[(i//2)-1]*10)+7\n lucky.append(num)\n i+=1\nlucky=sorted(lucky)\nl,r=map(int,input().split())\nlpos = 0\nrpos = 0\nfor i in range(len(lucky)):\n if lucky[i]>=l:\n lpos = i\n break\nfor j in range(len(lucky)-1,-1,-1):\n if lucky[j]<=r:\n rpos = j\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n for i in range(lpos,rpos):\n sumi+=((lucky[lpos+1]-lucky[lpos])*lucky[lpos+1])\n if lucky[lpos]!=l:\n if l<4:\n sumi+=((lucky[lpos]-l+1)*4)\n else:\n sumi+=((lucky[lpos]-l+1)*lucky[lpos-1])\n if lucky[rpos]!=r:\n sumi+=((r-lucky[rpos])*lucky[rpos])\n print(sumi)\n \n\n \n\n"}, {"source_code": "import bisect\nlevel={}\ndef bfs():\n s=''\n level[s]=None\n i=1\n frontier = [s]\n while i < 11:\n next=[]\n for u in frontier:\n for v in [u+'4', u+'7']:\n if v not in level:\n level[v]=i\n next.append(v)\n frontier=next\n i+=1\nbfs()\nl=[]\nfor key, value in level.items():\n if key!='':\n l.append(int(key))\nl.sort()\na,b=map(int, input().split())\ns=0\nlast=a\nfor i in range(len(l)):\n if a<=last<=b and a<=l[i]<=b:\n s=s+ l[i]*(min(l[i], b) + 1 - last)\n last=l[i]+1\n elif last > a:\n break\nprint(s)\n"}, {"source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom itertools import combinations_with_replacement\nfrom collections import defaultdict\nfrom bisect import bisect_right\n \ndef L():\n return list(map(int, stdin.readline().split()))\n \ndef In():\n return map(int, stdin.readline().split())\n \ndef I():\n return int(stdin.readline())\n \nP = 1000000007\narr = []\nlis = [4, 7]\nfor i in range(1, 11):\n comb = list(combinations_with_replacement([4, 7], i))\n for j in comb:\n st = ''\n for k in range(i):\n st += str(j[k])\n arr.append(int(st))\nl, r = In()\nsm = 0\nfor i in range(l, r+1):\n if i in arr:\n sm += i\n else:\n sm += arr[bisect_right(arr, i)]\nprint(sm)"}, {"source_code": "digits = ['4','7']\n\ns = raw_input()\nsubstrings = {}\nfor x in xrange(len(s)):\n for y in xrange(x+1, len(s)+1):\n sub = s[x:y]\n if sub[0] == '0':\n continue\n for char in sub:\n if char != '4' and char != '7':\n break\n else:\n substrings[sub] = substrings.get(sub, 0) + 1\n\nmaxcount = -1\nfor s, count in substrings.items():\n maxcount = max(maxcount, count)\n\nif maxcount == -1:\n print -1\n exit()\n\nmaxes = []\nfor s, count in substrings.items():\n if count == maxcount:\n maxes.append(s)\n\nprint list(sorted(maxes))[0]\n"}, {"source_code": "import re\n\ndef ones(n):\n return int('1' * n or 0)\n\ntrivial = re.compile(\"^[47]*$\")\nsmaller = re.compile(\"^[1-3]\")\nmedium = re.compile(\"^[5-6]\")\nbigger = re.compile(\"^[8-9]\")\nsophisticated = re.compile(\"^(?P[47]*)(?P.*$)\")\n\ndef nxt(n):\n s = str(n)\n\n if re.search(trivial, s):\n return n\n elif re.search(smaller, s):\n return ones(len(s)) * 4\n elif re.search(medium, s):\n return ones(len(s)) * 7 - ones(len(s) - 1) * 3\n elif re.search(bigger, s):\n return ones(len(s) + 1) * 4\n elif re.search(sophisticated, s):\n m = re.match(sophisticated, s)\n p = m.group('prefix').strip()\n s = m.group('suffix').strip()\n return int(p) * (10 ** len(s)) + nxt(int(s))\n\ndef solve(a, b):\n res = 0\n \n while True:\n print a, b,\n c = nxt(a)\n print c\n if c < b:\n res += (c - a + 1) * c\n a = c + 1\n else:\n res += (b - a + 1) * c \n return res\n\n[a, b] = map(int, raw_input().split())\nprint solve(a, b)\n"}, {"source_code": "a,b=map(int,input().strip().split())\nL=[0,4,7]\ndef generateLuckyNumbers(L,a):\n if a <= 100000001:\n x = a*10+4\n y = a*10+7\n L.append(x)\n L.append(y)\n return L \ndef recherche_dichotomique( element, liste_triee ):\n a = 0\n b = len(liste_triee)-1\n m = (a+b)//2\n while a < b :\n if liste_triee[m] == element :\n return m\n elif liste_triee[m] > element :\n b = m-1\n else :\n a = m+1\n m = (a+b)//2\n return a\ndef calcul(k,l,e,d):\n if d>k:\n return l-d+1\n else:\n return(min(l-k,e-k))\n \n\ni=1\nwhile i= l and s == -1:\n\t\ts = i\n\tif j <= r:\n\t\te = i\n\nif r > a[e]:\n\te += 1 \nans = 0\ni = l\nk = s\nwhile i <= r:\n\t# print(a[k] - min(i, r), a[k])\n\tans += (a[k] - min(i, r) + 1)*a[k]\n\ti = a[k] + 1\n\tk += 1\nprint(ans)"}, {"source_code": "level={}\ndef bfs():\n s=''\n level[s]=None\n i=1\n frontier = [s]\n while i < 11:\n next=[]\n for u in frontier:\n for v in [u+'4', u+'7']:\n if v not in level:\n level[v]=i\n next.append(v)\n frontier=next\n i+=1\nbfs()\nl=[]\nfor key, value in level.items():\n if key!='':\n l.append(int(key))\nl.sort()\na,b=map(int, input().split())\ns=0\nfor i in range(len(l)):\n if a<=l[i]<=b:\n if l[i+1] <=b :\n s=s+ (l[i]) * (l[i+1]- l[i] )\n else:\n s=s+ l[i]*(b-l[i-1])\n \n\n elif l[i] > b:\n break\nprint(s)\n"}, {"source_code": "import bisect\n\ndef foo():\n\tl=[4,7]\n\n\twhile(len(str(l[-1]))<=12):\n\t\tz=[]\n\t\tfor i in range(0,len(l)):\n\t\t\tfor j in range(0,len(l)):\n\t\t\t\ts=str(l[i])+str(l[j])\n\t\t\t\tif(len(s)>=12):\n\t\t\t\t\treturn l\n\t\t\t\tz.append(int(s))\n\t\t\t\t#print(len(s))\n\t\tl=l+z\n\t\t\n\t\t\nl=foo()\nl=list(set(l))\nl.sort()\n#for i in l:\n#\tprint(i)\nn,m=map(int,input().split())\nc=0\nj=0\nfor i in range(n,m+1):\n\tif(i777777777:\n break\n lucky.append(x*10+4)\n lucky.append(x*10+7)\nl,r = map(int,raw_input().split())\nsums = i = 0\ninit()\nlucky.sort()\nwhile l<=r:\n if lucky[i]int(\"7\"*k):\n\t\treturn int(\"4\"*(k+1))\n\tif n0 else 0))\n\t\tif int(s[i])==7:\n\t\t\tif s[i+1:]==\"\":\n\t\t\t\treturn int(\"7\")\n\t\t\treturn int(\"7\"+str(next(int(s[i+1:]))))\n\nlast = next(l)\ntot = last\nfor i in range(l+1,r+1):\n\tif i>last:\n\t\tlast=next(i)\n\ttot+=last\nprint(tot)"}, {"source_code": "l,r = map(int,input().split())\narr =[4,7]\nsumi=0\nk=0\nfor i in range(0,9):\n\tfor j in range(k,k+2**(i+1)):\n\t\tarr.append(arr[j]*10+4)\n\t\tarr.append(arr[j]*10+7)\n\tk=2**(i+1)\nwhile(l<=r):\n\tc=-1\n\tif (l<=4):\n\t\tc=4\n\telse:\n\t\tfor i in range(1,len(arr)):\n\t\t\tprint(i,arr[i],sep=\" \")\n\t\t\tif (l<=arr[i] and l>arr[i-1]):\n\t\t\t\tc=arr[i]\n\t\t\t\tbreak;\n\tif r<=c:\n\t\tsumi=sumi+((r-l+1)*c)\n\t\tl=r+1\n\telse:\n\t\tsumi=sumi+((c-l+1)*c)\n\t\tl=c+1\nprint(sumi)\n\n\t\t\t"}, {"source_code": "number = raw_input()\nnum1, num2 = number.split(\" \")\nnum1 = int(num1)\nnum2 = int (num2)\n\ni = 1 \nlucky_num = []\n\nwhile i <= 777:\n\tnum = i\n\twhile num > 0:\n\t\ttemp = num % 10\n\t\tif temp == 4 or temp == 7:\n\t\t\tnum = num / 10\n\t\t\tbool = True\n\t\telse:\n\t\t\tbool = False \n\t\t\tbreak;\n\tif bool is not False:\n\t\tlucky_num.append(i)\n\ti = i + 1\n\nsum = 0\n\nwhile num1 <= num2:\n\ta = min (n for n in lucky_num if n >= num1)\n\tsum = sum + (a - num1 + 1) * a\n\tnum1 = a + 1\n\nprint sum"}, {"source_code": "import sys\n\nnumbers = map(int, sys.stdin.readline().split())\n\nstart = numbers[0]\nend = numbers[1]\n\ndef nextfun(i):\n lst = [int(x) for x in str(i).zfill(9)]\n for k in range(9):\n if lst[k] != 0:\n end = k\n break\n \n j = 8\n while (j >= end):\n if lst[j] == 4 or lst[j] == 7:\n j -= 1\n continue\n elif lst[j] > 7:\n lst[j] = 4\n lst[j - 1] = lst[j - 1] + 1\n elif lst[j] > 4:\n lst[j] = 7\n if (j + 1 < 9):\n lst[j + 1] = 4\n else:\n lst[j] = 4\n if (j + 1 < 9):\n lst[j + 1] = 4\n \n j -= 1\n \n print int(''.join(map(str,lst)))\n return int(''.join(map(str,lst)))\n \n \n \n \n \nanswer = 0\n\nwhile(start <= end):\n answer += nextfun(start)\n start += 1\n \n \nprint answer"}, {"source_code": "S = sorted\nM = lambda : map(int,input().split())\na = []\nl,r = M()\ndef F(x):\n\ta.append(x)\n\tif x>r*10:\n\t\treturn\n\tF(10*x+4)\n\tF(10*x+7)\n\nF(0)\na=S(a)\ndef luckysum(p):\n\ts = 0\n\tfor i in range(1, len(a)):\n\t\ts+= min(a[i],p)-min(a[i-1],p)\n\treturn s\n\nprint(luckysum(r) - luckysum(l))\n\n "}, {"source_code": "l,r=map(int,(input().split()))\nlucky=[4,7]\nif l==1000000000 and r==1000000000:\n print(4444444444)\nelse:\n for i in range(1,11):\n \n for j in lucky[pow(2,i)-2:pow(2,i+1)+1]:\n \n lucky.append(4*pow(10,i) + j)\n lucky.append(7*pow(10,i)+ j)\n \n s_lucky=sorted(lucky)\n \n add=0\n while l>s_lucky[0]:\n del s_lucky[0]\n start=lucky[0]\n for i in s_lucky:\n\n if i>=r:\n end=s_lucky.index(i)\n break;\n add=0 \n \n for i in range(end+1):\n if i==0:\n add=add+s_lucky[0]*(s_lucky[0]-l+1)\n \n elif i<=end-1:\n \n add=add+s_lucky[i]*(s_lucky[i]-s_lucky[i-1])\n \n else:\n if r=l:\n lpos = i\n break\nfor j in range(len(lucky)-1,-1,-1):\n if lucky[j]<=r:\n rpos = j\n break\nif l==r:\n print(lucky[rpos])\nelse:\n sumi = 0\n for i in range(lpos,rpos):\n sumi+=((lucky[lpos+1]-lucky[lpos])*lucky[lpos+1])\n if lucky[lpos]!=l:\n if l<4:\n sumi+=((lucky[lpos]-l+1)*4)\n else:\n sumi+=((lucky[lpos]-l+1)*lucky[lpos-1])\n if lucky[rpos]!=r:\n sumi+=((r-lucky[rpos])*lucky[rpos+1])\n print(sumi)\n \n\n \n\n"}, {"source_code": "def get_all_lucky(length):\n\tif length == 1:\n\t\treturn [\"4\", \"7\"]\n\t\n\tans = get_all_lucky(length-1)\n\ttemp = ans.copy()\n\tfor i in temp:\n\t\tans.append(\"4\"+i)\n\t\tans.append(\"7\"+i)\n\n\treturn ans\t\n\nif __name__ == '__main__':\n\tl, r = map(int, input().split())\n\tlucky_nums = get_all_lucky(9)\n\tlucky_nums = map(int, lucky_nums)\n\tlucky_nums =sorted(lucky_nums)\t\n\tans = 0\n\t\n\tfor i in lucky_nums:\n\t\tnum_to_left = max(min(i, r) - l + 1, 0)\n\t\tans += (num_to_left*i)\n\t\tl = max(l, i+1)\n\t\tif l > r:\n\t\t\tbreak\n\n\tprint(ans) "}, {"source_code": "lucky = []\nLIMIT=1000000000\n\n\n\nlucky.sort()\n\nans = 0\nfor i in range(len(lucky)-1):\n\tlo = max(l,lucky[i]+1)\n\thi = min(r,lucky[i+1])\n\t\n\tif hi>=lo:\n\t\tans = ans + (hi-lo+1)*lucky[i+1]\nprint(ans)\n\t\t\n"}, {"source_code": "l, r = map(int, raw_input().split())\n\ndef check(k):\n s = str(k)\n for i in xrange(len(s)):\n if s[i] != '4' and s[i] != '7':\n return 0\n return 1\n\ndef close(a):\n if (check(a)):\n return a\n else:\n ans = ''\n temp = 0\n last = -1\n s = str(a)\n for i in xrange(len(s)):\n if (temp == 0):\n if (s[i] == '4' or s[i] == '7'):\n ans = ans + s[i]\n if s[i] == '4':\n last = i\n else:\n if (s[i] < '4'):\n ans = ans + '4'\n last = i\n elif (s[i] < '7'):\n ans = ans + '7'\n else:\n if last == -1:\n ans = ''\n for j in xrange(len(s) + 1):\n ans = ans + '4'\n return int(ans)\n else:\n ans = ans[:last] + '7'\n while (len(ans) < len(s)):\n ans = ans + '4'\n return int(ans)\n else:\n ans = ans + '4'\n return int(ans)\n\nh = [4]\nfor i in xrange(1022):\n h.append(close(h[len(h) - 1] + 1))\nindl = 0\nfor i in xrange(len(h)):\n if h[i] >= l:\n indl = i\n break\nfor i in xrange(len(h)):\n if h[i] >= r:\n indr = i\n break\n\nans = 0\nprev = l\nfor i in xrange(indl, indr + 1):\n ans += (h[i] - prev + 1) * h[i]\n prev = h[i] + 1\n\nprint ans"}, {"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\n\nl=[]\nfor i in range(1,11):\n for j in range(i+1):\n a=\"\"\n b=\"\"\n a+=j*'4'\n b+=(i-j)*'7'\n a+=(i-j)*'7'\n b+=j*'4'\n a=int(a)\n b=int(b)\n l.append(a) \n l.append(b)\n \nl=list(set(l))\nl.sort() \n\nle,r=mi()\ns=0\ni=le-1\nj=0\nwhile(ii:\n s+=(min(l[j],r)-i)*l[j] \n i=l[j]\n j+=1\nprint(s)"}, {"source_code": "a,b=map(int,input().strip().split())\nL=[0,4,7]\ndef generateLuckyNumbers(L,a):\n if a <= 1000000001:\n x = a*10+4\n y = a*10+7\n L.append(x)\n L.append(y)\n return L \n\n \ndef calcul(k,l,e,d):\n \n \n return(min(l-k,e-k,l-d+1,e-d+1))\n \n\ni=1\nwhile iL[j]:\n j=j+1\ncount=0 \nif b<=4:\n count=count+calcul(a,4,b,a)*4\nelse:\n while j+1=i:\n count=count+L[j]\n else:\n j=j+1 \n count=count+L[j]\nprint(count)\n "}, {"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\n\nl=[]\nfor i in range(1,10):\n for j in range(i+1):\n a=\"\"\n a+=j*'4'\n a+=(i-j)*'7'\n a=int(a)\n l.append(a) \n \nl.sort() \n\nle,r=mi()\ns=0\ni=le-1\nj=0\nwhile(ii:\n s+=(l[j]-i)*l[j] \n i=l[j]\n j+=1\nprint(s)"}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\n luckynumbers.sort()\n\nlowerbound = len(luckynumbers)-1\nupperbound = len(luckynumbers)-1\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]>r) & (upperbound>0):\n upperbound -= 1\n\nwhile (luckynumbers[lowerbound]>l) & (lowerbound>0):\n lowerbound -= 1\n\nans = luckynumbers[lowerbound] * (luckynumbers[lowerbound] - l + 1)\n\nfor i in range(lowerbound + 1, upperbound + 1):\n ans += luckynumbers[i] * (luckynumbers[i] - luckynumbers[i-1])\n\nprint(ans)\n\n"}, {"source_code": "good=[4,7]\nj=0 \nfor i in range(100):\n good.append(good[j]*10+4)\n good.append(good[j]*10+7)\n j+=1 \ngood.sort() \ngood=[i for i in good if i<=10**10]\nl,r=map(int,input().split())\nans=0 \nlo=0 \nind1=-1 \nind2=-1 \nhi=len(good)-1\nnextl=l \nwhile lo<=hi: \n mi=(lo+hi)>>1 \n if good[mi]>=l:\n nextl=good[mi]\n ind1=mi \n hi=mi-1 \n else:\n lo=mi+1 \nprevr=r \nlo=0 \nhi=len(good)-1\nwhile lo<=hi:\n mi=(lo+hi)>>1 \n if good[mi]<=r: \n prevr= good[mi]\n ind2=mi \n lo=mi+1 \n else: \n hi=mi-1 \nfor i in range(ind1,ind2):\n diff=good[i+1]-good[i] \n # print(diff)\n ans+=diff*good[i+1]\n#print(ans)\nans+=(nextl-l+1)*nextl \nans+=(r-prevr)*r \nprint(ans)"}, {"source_code": "l,r=map(int,input().split())\ns=set()\ndef f(st,res):\n\tif st>10:s.add(res)\n\telse:\n\t\tif res==0:f(st+1,res)\n\t\tfor i in 4,7:f(st+1,res*10+i)\nf(0,0)\ns=sorted(s)\na=0\nb=len(s)\nwhile s[a]r:b-=1\nq=0\nfor i in range(a,b-1):q+=s[i+1]*(s[i+1]-s[i])\nprint(q+s[a]*(s[a]-l+1)+s[b]*(r-s[b-1]))"}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\nluckynumbers.sort()\n\nlowerbound = 0\nupperbound = 0\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]lowerbound:\n ans += luckynumbers[upperbound] * (r - luckynumbers[upperbound - 1])\n\nprint(ans)\n\n\n"}, {"source_code": "l,r = map(int,input().split(' '))\n\na = set()\nfor i in range(1, 10):\n for j in range(2**i):\n c = j\n t = 0\n while c:\n if c&1:\n t = t*10+7\n else:\n t = t*10+4\n c //= 2\n if t > 0:\n a.add(t)\n elif t == 0:\n a.add(4)\n\na = sorted(list(a))\n\nans = 0\nfor j in range(len(a)):\n i = a[j]\n if l <= i and r > i:\n ans += (i - l + 1) * i\n l = i + 1\n elif l <= i and r <= i:\n ans += (r - l + 1) * i\n break\nprint(ans)\n\n"}, {"source_code": "level={}\ndef bfs():\n s=''\n level[s]=None\n i=1\n frontier = [s]\n while i < 11:\n next=[]\n for u in frontier:\n for v in [u+'4', u+'7']:\n if v not in level:\n level[v]=i\n next.append(v)\n frontier=next\n i+=1\nbfs()\nl=[]\nfor key, value in level.items():\n if key!='':\n l.append(int(key))\nl.sort()\na,b=map(int, input().split())\ns=0\nfor i in range(len(l)):\n if a<=l[i]<=b:\n if l[i+1] <=b :\n s=s+ (l[i]) * (l[i+1]- l[i] )\n else:\n s=s+ l[i]*(b-l[i-1])\n print(s, l[i], end=' ')\n print()\n\n elif l[i] > b:\n break\nprint(s)\n"}, {"source_code": "def getluckys(n):\n luckys = []\n for i in range(0,2**n):\n s = \"\"\n for j in range(0,n):\n if ((i>>j)&1) == 0:\n s+='4'\n else:\n s+='7'\n luckys.append(int(s))\n return luckys\n\nluckynumbers = []\n\nfor i in range(1,11):\n luckynumbers += getluckys(i)\n\nluckynumbers.sort()\n\nlowerbound = 0\nupperbound = 0\n\nl, r = map(int, raw_input().split(\" \"))\n\nwhile (luckynumbers[upperbound]lowerbound:\n ans += luckynumbers[upperbound] * (r - luckynumbers[upperbound - 1])\n\nprint(ans)\n\n"}, {"source_code": "import sys\n\nnumbers = map(int, sys.stdin.readline().split())\n\nstart = numbers[0]\nend = numbers[1]\n\ndef nextfun(i):\n lst = [int(x) for x in str(i).zfill(9)]\n for k in range(9):\n if lst[k] != 0:\n end = k\n break\n \n j = 8\n while (j >= end):\n if lst[j] == 4 or lst[j] == 7:\n j -= 1\n continue\n elif lst[j] > 7:\n lst[j] = 4\n lst[j - 1] = lst[j - 1] + 1\n elif lst[j] > 4:\n lst[j] = 7\n if (j + 1 < 9):\n lst[j + 1] = 4\n else:\n lst[j] = 4\n if (j + 1 < 9):\n lst[j + 1] = 4\n \n j -= 1\n \n print int(''.join(map(str,lst)))\n return int(''.join(map(str,lst)))\n \n \n \n \n \nanswer = 0\n\nwhile(start <= end):\n answer += nextfun(start)\n start += 1\n \n \nprint answer"}, {"source_code": "level={}\ndef bfs():\n s=''\n level[s]=None\n i=1\n frontier = [s]\n while i < 11:\n next=[]\n for u in frontier:\n for v in [u+'4', u+'7']:\n if v not in level:\n level[v]=i\n next.append(v)\n frontier=next\n i+=1\nbfs()\nl=[]\nfor key, value in level.items():\n if key!='':\n l.append(int(key))\nl.sort()\na,b=map(int, input().split())\ns=0\nfor i in range(len(l)):\n if a<=l[i]<=b:\n if l[i+1] <=b :\n s=s+ (l[i]) * (l[i+1]- l[i] )\n else:\n s=s+ l[i]*(b-l[i-1])\n print(s, l[i], end=' ')\n print()\n\n elif l[i] > b:\n break\nprint(s)\n"}, {"source_code": "level={}\ndef bfs():\n s=''\n level[s]=None\n i=1\n frontier = [s]\n while i < 11:\n next=[]\n for u in frontier:\n for v in [u+'4', u+'7']:\n if v not in level:\n level[v]=i\n next.append(v)\n frontier=next\n i+=1\nbfs()\nl=[]\nfor key, value in level.items():\n if key!='':\n l.append(int(key))\nl.sort()\na,b=map(int, input().split())\ns=0\nfor i in range(len(l)):\n if a<=l[i]<=b:\n if l[i+1] <=b :\n s=s+ (l[i]) * (l[i+1]- l[i] )\n else:\n s=s+ l[i]*(b-l[i-1])\n \n\n elif l[i] > b:\n break\nprint(s)\n"}], "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd"} {"nl": {"description": "Fox Ciel studies number theory.She thinks a non-empty set S contains non-negative integers is perfect if and only if for any (a can be equal to b), . Where operation xor means exclusive or operation (http://en.wikipedia.org/wiki/Exclusive_or).Please calculate the number of perfect sets consisting of integers not greater than k. The answer can be very large, so print it modulo 1000000007 (109\u2009+\u20097).", "input_spec": "The first line contains an integer k (0\u2009\u2264\u2009k\u2009\u2264\u2009109).", "output_spec": "Print a single integer \u2014 the number of required sets modulo 1000000007 (109\u2009+\u20097).", "sample_inputs": ["1", "2", "3", "4"], "sample_outputs": ["2", "3", "5", "6"], "notes": "NoteIn example 1, there are 2 such sets: {0} and {0, 1}. Note that {1} is not a perfect set since 1 xor 1 = 0 and {1} doesn't contain zero.In example 4, there are 6 such sets: {0}, {0, 1}, {0, 2}, {0, 3}, {0, 4} and {0, 1, 2, 3}."}, "positive_code": [{"source_code": "from math import factorial\nMOD = 10**9+7\n\nk = int(input())\nbink = list(map(int, bin(k)[2:]))\nN = len(bink)\n\n# dp[i][j][k] = first i bits, j bases,\n# k = 1 if maxor matches k, 0 else\ndp = [[[0,0] for j in range(i+2)] for i in range(N+1)]\ndp[0][0][1] = 1\nfor i in range(1, N+1):\n for j in range(i+1):\n # k = 0 -> 0\n dp[i][j][0]+= 2**j * dp[i-1][j][0] # distribute\n if j: dp[i][j][0]+= dp[i-1][j-1][0] # new base\n # k = 1 -> 0\n odd = 2**(j-1) if j else 0\n even = 2**j - odd\n if bink[i-1] == 1:\n dp[i][j][0]+= even * dp[i-1][j][1] # distribute even\n # k = 1 -> 1\n if bink[i-1] == 0:\n dp[i][j][1]+= even * dp[i-1][j][1] # distribute even\n else:\n dp[i][j][1]+= odd * dp[i-1][j][1] # distribute odd\n if j: dp[i][j][1]+= dp[i-1][j-1][1] # new base\nans = sum(map(sum, dp[-1]))\nprint(ans % MOD)"}], "negative_code": [{"source_code": "from math import factorial\nMOD = 10**9+7\n\ndef binom(n, k):\n if k > n-k: return binom(n, n-k)\n res = 1\n for i in range(k): res = res*(n-i)//(i+1)\n return res\n\ndef comp_ones_vecs(k, n):\n # k ones, n vectors\n if k < n: return 0\n ans = 0\n for Z in range(n):\n ans+= (-1)**Z * binom(n,Z) * (n-Z)**k\n return ans // factorial(n)\n\ndef comp_ones_frees_vecs(k, f, n):\n # k prefixed ones, f digits of freedom, n vectors\n ans = 0\n for i in range(f+1):\n ans+= comp_ones_vecs(k+i, n) * binom(f, i)\n return ans\n\ndef comp_ones_frees(k, f):\n # k prefixed ones, f digits of freedom\n ans = 0\n for n in range(1, k+f+1):\n ans+= comp_ones_frees_vecs(k, f, n)\n return ans\n\nk = int(input())\nbink = list(map(int, bin(k)[2:]))\nans = 1 + comp_ones_frees(sum(bink), 0)\nones = 0\nfor i in range(len(bink)):\n if bink[i] == 0: continue\n ans+= comp_ones_frees(ones, len(bink)-i-1)\n ones+= 1\nprint(ans % MOD)"}], "src_uid": "ead64d8e3134fa8f29881cb487e52f60"} {"nl": {"description": "The Little Elephant very much loves sums on intervals.This time he has a pair of integers l and r (l\u2009\u2264\u2009r). The Little Elephant has to find the number of such integers x (l\u2009\u2264\u2009x\u2009\u2264\u2009r), that the first digit of integer x equals the last one (in decimal notation). For example, such numbers as 101, 477474 or 9 will be included in the answer and 47, 253 or 1020 will not.Help him and count the number of described numbers x for a given pair l and r.", "input_spec": "The single line contains a pair of integers l and r (1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009\u2264\u20091018) \u2014 the boundaries of the interval. Please, do not use the %lld specifier to read or write 64-bit integers in \u0421++. It is preferred to use cin, cout streams or the %I64d specifier.", "output_spec": "On a single line print a single integer \u2014 the answer to the problem.", "sample_inputs": ["2 47", "47 1024"], "sample_outputs": ["12", "98"], "notes": "NoteIn the first sample the answer includes integers 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44. "}, "positive_code": [{"source_code": "def f(n):\n mx = len(str(n))\n ans = 0\n for i in range(1, mx):\n for j in range(1, 10):\n if i == 1:\n ans += 1\n else:\n ans += (10 ** (i - 2))\n for j in range(1, 10):\n if mx == 1:\n if j <= n:\n ans += 1\n else:\n break\n continue\n if int(str(j) + '0' * (mx - 2) + str(j)) > n:\n break\n if int(str(j) + '9' * (mx - 2) + str(j)) <= n:\n ans += (10 ** (mx - 2))\n else:\n val = int(str(n)[1:-1]) + 1\n if str(n)[-1] < str(n)[0]:\n val -= 1\n ans += val\n break\n return ans\n\n\nL, R = map(int, input().split())\nprint(f(R) - f(L - 1))\n"}, {"source_code": "l,r=input().split()\ndef ans(n):\n a=0\n if len(n)==1:\n return int(n)\n elif len(n)==2:\n if n[1]<=n[0]:\n return int(n[0])+9\n else:\n return int(n[0])+10\n else:\n for i in range(len(n)-1):\n if i>0:\n a+=int(n[i])*(10**(len(n)-i-2))\n else:\n a+=(int(n[i])-1)*(10**(len(n)-i-2))\n if i==len(n)-2:\n if n[-1]>n[0]:\n a+=1\n return a\nx=ans(r)\ny=ans(l)\nif int(l)>99:\n for i in range(len(l)-1,1,-1):\n y+=ans('9'*i)+1\nif int(r)>99:\n for i in range(len(r)-1,1,-1):\n x+=ans('9'*i)+1\nif r[0]==r[-1]:\n x+=1\nprint(x-y)\n \n\n \n \n \n"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = map(int,input().split())\nprint(f(r)-f(l-1))\n"}, {"source_code": "def get(x):\n\tif x <= 9: return x\n\tans = 0\n\ts = str(x)\n\tfor i in xrange(1, len(s)):\n\t\tans += 9 * (1 if 1 == i else 10 ** (i - 2))\n\tans += (ord(s[0]) - ord('0') - 1) * (10 ** (len(s) - 2))\n\tmid = int(s[1:-1]) if len(s) > 2 else 0\n\tans += mid + 1 if s[-1] >= s[0] else mid\n\treturn ans\n\ndef main():\n\tleft, right = map(int, raw_input().split())\n\tprint get(right) - get(left - 1)\n\nif __name__ == \"__main__\": main()\n"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = map(int,input().split())\nprint(f(r)-f(l-1))\n"}, {"source_code": "p = [0, 1, 1]\np.extend([10 ** x for x in range(1,19)])\n#print(p)\n#a, b = input().split()\n#I need to find the num which are smaller then this \n\ndef get_count(num):\n\tif len(num) == 1:\n\t\treturn int(num)\n\telif len(num) == 2:\n\t\treturn int(num[0]) + 8 if num[0] > num[1] else int(num[0]) + 9\n\telse:\n\t\tresult = 18\n\t\tfor i in range(3, len(num)):\n\t\t\tresult += p[i] * 9\n\t\tfirstDig = int(num[0])\n\t\tlastDig = int(num[-1])\n\t\tresult += (firstDig - 1) * (10 ** (len(num) - 2) )\n\t\tif firstDig <= lastDig:\n\t\t\tresult += int(num[1:-1]) + 1\n\t\telse:\n\t\t\tresult += int(num[1:-1])\n\n\t\treturn result\n\n\na, b = input().split()\nca = (get_count(a))\ncb = (get_count(b))\n# print(ca)\n# print(cb)\nprint(cb - ca + 1 if a[0] == a[-1] else cb - ca )\n# base = p[len(num)]\n\n# result = 0\n# i = 1\n# while i < len(num):\n# \tresult += p[i] * 9\n# \ti += 1\n\n# start = int(num[0])\n# end = int(num[-1])\n\n# result += (start - 1) * (p[len(num) - 2] * 9)\n# if start <= end:\n# \tresult += int(num[1:-1]) + 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"}, {"source_code": "def Solve(t):\n if(t < 10):\n return t;\n A = 9\n for i in range(2 , 20):\n if(10 ** i - 1 <= t):\n A += 9 * (10 ** (i - 2))\n else:\n fd = int(str(t)[0])\n ld = t % 10\n A += (fd - 1) * (10 ** (i - 2))\n t -= fd * (10 ** (i - 1))\n if(ld >= fd):\n A += 1\n t = t // 10\n A += t\n break\n return A\nl , r = map(int , input().split())\nprint(Solve(r) - Solve(l - 1))\n \n"}, {"source_code": "def f(x):\n\tif x < 10:\n\t\treturn x\n\tcount = x/10 + 9\n\tif int(str(x)[0]) > int(str(x)[-1]):\n\t\tcount -= 1\n\treturn count\na, b = map(int, raw_input().split())\nprint f(b) - f(a - 1)"}, {"source_code": "l=lambda:map(int,raw_input().split())\na,b=l()\ndef fun(x):\n if x<10:\n return x\n r=x%10\n if int(str(x)[0])>r:\n return x/10-1+9\n else:\n return x/10+9\nprint fun(b)-fun(a-1)"}, {"source_code": "l,r=map(int,raw_input().split())\ndef get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))\nprint get(r)-get(l-1)"}, {"source_code": "import bisect\ndef cal(n):\n x=str(n)\n res=0\n if len(x)==1:\n return n\n for i in range(1,len(x)):\n res=res+9*(10**(max(0,i-2)))\n a=[]\n for i in range(1,10):\n s=str(i)+'0'*(max(0,len(x)-2))+str(i)\n a.append(int(s))\n j=bisect.bisect_right(a,n)\n res=res+(j-1)*(10**(max(0,len(x)-2)))\n if j=2:\n res=res+1\n if int(x[0])>int(x[-1]):\n res=res-1\n return res\nl,r=list(map(int,input().split()))\nans=cal(r)-cal(l)\nif str(l)[0]==str(l)[-1]:\n ans=ans+1\nprint(ans)"}, {"source_code": "def f(s):\n if s == '0':\n return 0\n n = len(s)\n if n > 2:\n sum = '9' * (n-2)\n sum = int(sum) + 9\n elif n == 2:\n sum = 9\n else:\n sum = int(s)\n\n ss = s[0]\n cs = int(s)\n cs -= 10**(n-1)\n s = str(cs)\n n = len(s)\n\n for si in s[:-1]:\n sum += int(si) * 10**(n-2)\n n -= 1\n if int(s[-1]) >= int(ss):\n sum += 1\n return sum\n\n\nl, r = map(int, raw_input().split())\nprint f(str(r)) - f(str(l-1))\n"}, {"source_code": "#! python\n\nl, r = input().split()\n\ndef count(s: str) -> int:\n if s[0] != s[-1]:\n while s[0] != s[-1]:\n s = str(int(s) - 1)\n\n length = len(s)\n\n if length == 1:\n return int(s)\n\n if length == 2:\n return 9 + int(s[0])\n\n # length > 2\n\n cnt = 9 + 9\n\n cnt += 1 + int(s[1:-1])\n cnt += (int(s[0]) - 1) * 10 ** (length - 2)\n\n cnt += sum(9 * 10 ** (n - 2) for n in range(3, length))\n\n return cnt\n\n\n\n\nprint((l[0] != l[-1]) * -1 + count(r) - count(l) + 1)\n\n"}, {"source_code": "def count(x):\n if x < 10:\n res = x\n else: \n f = x % 10\n d = x // 10\n co = 1\n res = 9\n while x > 99:\n res += 9*co\n co *= 10\n x //= 10\n x //= 10 \n res += d - co\n if f >= x: \n res += 1\n return res \n\nl, r = map(int, input().split())\nprint(count(r) - count(l-1))"}, {"source_code": "import math\nl,r = map(int, input().split())\n\ndef f(x):\n x = list(map(int, x))\n a = len(x)\n if a < 2:\n return int(x[0])\n ans = 0\n for i in range(1, a):\n ans += 9* int(math.pow(10, max(0, i-2)))\n \n ans += (x[0]-1)* int(math.pow(10, max(0, a-2)))\n if len(x) > 2:\n z = x[1:len(x)-1]\n ans += int(''.join(map(str, z)))\n\n if x[0] <= x[-1]:\n ans += 1\n return int(ans)\n\nprint(f(list(str(r))) - f(list(str(l - 1))))\n"}, {"source_code": "#!/usr/bin/env python\n\nl,r = map(int, raw_input().strip().split())\n\np = [1]\nfor i in xrange(1,20):\n p.append(p[-1]*10)\n\nd = [0,9,18]\nfor i in xrange(3,20):\n d.append(d[i-1]+p[i-2]*9)\n\n\ndef cal(x):\n if x<10: return x\n elif x<100: return d[1] + x/11\n else:\n s = str(x)\n n = len(s)\n k = int(s[0]) - 1\n tmp = d[n-1] + k*p[n-2]\n tmp+=int(s[1:-1])\n if s[0]<=s[-1]:\n tmp+=1\n return tmp\n\n\nres = cal(r)-cal(l)\ns = str(l)\nif s[0]==s[-1]:\n res +=1\n\nprint res\n"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = map(int,input().split())\nprint(f(r)-f(l-1))\n"}, {"source_code": "def power(a,b):\n\tx=1\n\ty=a\n\twhile b!=0:\n\t\tif b%2==1:\n\t\t\tx=x*y\n\t\ty=y*y\n\t\tb=b/2\n\treturn x\ndef ret(s,rl):\n\trr=0\n\tk=int(s[0])\n\trr=(k-1)*power(10,rl-2)\n\tfor i in range(1,rl):\n\t\tif i==rl-1:\n\t\t\tif int(s[i]) >= int(s[0]):\n\t\t\t\trr=rr+1\n\t\telse:\n\t\t\tk=int(s[i])\n\t\t\trr=rr+(k)*power(10,rl-2-i)\n\treturn rr\ns=raw_input()\nll=s.split()\nl=str(int(ll[0])-1)\nr=ll[1]\nrl=len(r)\nll=len(l)\nif rl==1:\n\tansr=int(r)\n\tansl=int(l)\n\tprint ansr-ansl\nelse:\n\tansr=9\n\ti=2\n\twhile i < rl:\n\t\tansr=ansr+9*power(10,i-2)\n\t\ti=i+1\n\tansr=ansr+ret(r,rl)\n\tif ll==1:\n\t \tansl=int(l)\n\telse:\n\t\tansl=9\n\t\ti=2\n\t\twhile i < ll:\n\t\t\tansl=ansl+9*power(10,i-2)\n\t\t\ti=i+1\n\t\tansl=ansl+ret(l,ll)\n\tprint ansr-ansl\n"}, {"source_code": "#!/usr/bin/env python\n\ndef f(num):\n\treturn (int(num) // 10 - (0 if int(str(num)[0]) <= int(str(num)[-1]) else 1) + 9) if int(num) >= 10 else int(num)\n\na,b = map(int,raw_input().split())\nprint f(b) - f(a-1)"}, {"source_code": "#! python\n\nl, r = input().split()\n\ndef count(s: str) -> int:\n if s[0] != s[-1]:\n while s[0] != s[-1]:\n s = str(int(s) - 1)\n\n length = len(s)\n\n if length == 1:\n return int(s)\n\n if length == 2:\n return 9 + int(s[0])\n\n # length > 2\n\n cnt = 9 + 9\n\n cnt += 1 + int(s[1:-1])\n cnt += (int(s[0]) - 1) * 10 ** (length - 2)\n\n cnt += sum(9 * 10 ** (n - 2) for n in range(3, length))\n\n return cnt\n\n\n\n\nprint((l[0] != l[-1]) * -1 + count(r) - count(l) + 1)\n\n"}, {"source_code": "# n=int(input())\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n#ls=list(map(int,input().split()))\n#for i in range(m):\n# for _ in range(int(input())):\nfrom collections import Counter\n#from fractions import Fraction\n#n=int(input())\n#arr=list(map(int,input().split()))\n#ls = [list(map(int, input().split())) for i in range(n)]\nfrom math import log2\n#for _ in range(int(input())):\n#n, m = map(int, input().split())\n'''n, m = map(int, input().split())\ng=[]\nfor i in range(n):\n s=input()\n g.append(s)'''\ndef dfs(x,y,x1,y1):\n\tv.add((x,y))\n\tfor dx,dy in [(-1,0),(0,1),(1,0),(0,-1)]:\n\t\tif x+dx>=0 and x+dx=0 and y+dystr(x)[-1] else 0)\nn,m=map(int,input().split())\nprint(ans(m)-ans(n-1))\n\n\n"}, {"source_code": "def size(x):\n res = 0\n while x > 0:\n x //= 10\n res += 1\n return res\n\n\ndef first(x):\n last = 0\n while x > 0:\n last = x % 10\n x //= 10\n return last\n\n\ndef last(x):\n return x % 10\n\n\ndef cut(x):\n x //= 10\n x -= first(x) * 10 ** (size(x) - 1)\n return x\n\n\ndef part(x):\n if x < 10:\n return x\n\n res = 9\n\n for i in range(2, size(x)):\n res += 9 * 10 ** (i - 2)\n\n res += cut(x)\n res += (first(x) - 1) * 10 ** (size(x) - 2)\n if first(x) <= last(x):\n res += 1\n\n return res\n\n\nl, r = list(map(int, input().split()))\n\n\nprint(part(r) - part(l - 1))\n"}, {"source_code": "def cal(n):\n if int(n) < 10:\n return int(n)\n else:\n if n[0] <= n[-1]:\n return int(n) // 10 + 9\n else:\n return int(n) // 10 + 8\n\nl,r = map(int, raw_input().split())\nprint cal(str(r)) - cal(str(l-1))"}, {"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# from itertools import accumulate\n# from collections import defaultdict, Counter\n\ndef modinv(n,p):\n return pow(n,p-2,p)\n\ndef get_numbers(s):\n if len(s) == 1:\n return int(s)\n \n ans = 0\n n = len(s)\n for i in range(1, n):\n ans += (9 * (10 ** (max(0, i-2))))\n \n x = n-2\n for i in range(n):\n k = int(s[i])\n if i == 0:\n k -= 1\n # print(\"i = \", i, \", k = \", k)\n ans += (k * (10 ** x))\n x -= 1\n if x < 0:\n break\n if int(s[-1]) >= int(s[0]):\n ans += 1\n return ans\n\ndef main():\n #sys.stdin = open('input.txt', 'r')\n #sys.stdout = open('output.txt', 'w')\n\n # print(get_numbers(input()))\n\n l, r = [int(x) for x in input().split()]\n # print(get_numbers(str(l-1)))\n # print(get_numbers(str(r)))\n\n print(get_numbers(str(r)) - get_numbers(str(l-1)))\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": "# coding=utf-8\nfrom __future__ import division, print_function\nimport math\nimport sys\n\ndef count(n):\n #print(\"\")\n #print(n)\n if n < 10:\n return n\n cnt = 9\n ns = str(n)\n for i in range(len(ns)-1):\n for d in range(1, 10):\n m = int(\"{0}{1}{0}\".format(d, \"9\"*i))\n #print(i, d, m, cnt)\n if m <= n:\n cnt += 10**i\n else:\n if int(ns[0]) >= d:\n cnt += int(ns[1:-1] if len(ns) > 2 else 0)\n if int(ns[-1]) >= d:\n cnt += 1\n return cnt\n return cnt\n\neps = 0.0000001\nif __name__ == \"__main__\":\n l, r = map(int, sys.stdin.readline().split())\n print(\"{0}\".format(count(r) - count(l-1)))\n"}, {"source_code": "def f(x):\n if x < 10:\n return x\n return x // 10 + 9 - (0 if str(x)[0] <= str(x)[-1] else 1)\n\n\ndef main():\n l, r = map(int, input().split())\n print(f(r) - f(l - 1))\n\n\nmain()"}, {"source_code": "def pre(n):\n if n == 0:\n return 0\n if n < 10:\n return n\n if n < 100:\n return 9 + n // 11\n digit = []\n while n: \n digit += [n % 10]\n n //= 10\n ans = 10**(len(digit) - 2) - 1\n digit.reverse()\n ans += int(''.join(map(str, digit[1:-1])))\n ans += (digit[0] <= digit[-1])\n ans += 10**(len(digit) - 2) * (digit[0] - 1)\n return ans + 9\nl, r = map(int, input().split())\nprint(pre(r) - pre(l - 1))\n"}, {"source_code": "def pre(n):\n if n == 0:\n return 0\n if n < 10:\n return n\n if n < 100:\n return 9 + n // 11\n digit = []\n while n: \n digit += [n % 10]\n n //= 10\n ans = 10**(len(digit) - 2) - 1\n digit.reverse()\n ans += int(''.join(map(str, digit[1:-1])))\n ans += (digit[0] <= digit[-1])\n ans += 10**(len(digit) - 2) * (digit[0] - 1)\n return ans + 9\nl, r = map(int, input().split())\nprint(pre(r) - pre(l - 1))\n"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = map(int,input().split())\nprint(f(r)-f(l-1))\n"}, {"source_code": "n,m=raw_input().split()\ndef F(x):\n return int(x) if len(x)==1 else (int(x[0]) <= int(x[-1])) + int(x)/10+8\nprint F(m) - F(str(int(n)-1))"}, {"source_code": "l,r=map(int,raw_input().split())\ndef get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))\nprint get(r)-get(l-1)"}, {"source_code": "l=lambda:map(int,raw_input().split())\na,b=l()\ndef fun(x):\n if x<10:\n return x\n r=x%10\n if int(str(x)[0])>r:\n return x/10-1+9\n else:\n return x/10+9\nprint fun(b)-fun(a-1)"}, {"source_code": "def check(x):\n return str(x)[0]==str(x)[-1]\nl,r=map(int,raw_input().split())\nres=0\nwhile (l%10!=0)and(r>=l):\n if check(l):\n res+=1\n l+=1\nwhile (r%10!=9)and(r>=l):\n if check(r):\n res+=1\n r-=1\nres+=(r-l+1)/10\nprint res \n"}, {"source_code": "read = raw_input\nreadints = lambda: map(int, read().split())\nrange = xrange\n\ndef F(n):\n if int(n) < 10:\n return int(n)\n else:\n if n[0] <= n[-1]:\n return int(n) // 10 + 9\n else:\n return int(n) // 10 + 8\n \n\nl, r = readints()\nprint F(str(r)) - F(str(l - 1))\n"}, {"source_code": "n=input().split()\nl=int(n[0])\nr=int(n[1])\n\ns=0\nif l==235 and r==236:\n print(0)\n exit()\nif r==l and str(r)[0]==str(r)[len(str(r))-1]:\n print(1)\n exit()\nif r==l:\n print(0)\n exit()\nif r<=100:\n for i in range(l,r+1):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n print(s) \n exit()\nif l>=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]0:\n a+=int(n[i])*(10**(len(n)-i-2))\n else:\n a+=(int(n[i])-1)*(10**(len(n)-i-2))\n if i==len(n)-2:\n if n[-1]>n[0]:\n a+=1\n return a\nx=ans(r)\ny=ans(l)\nif int(l)>99:\n for i in range(len(l)-1,1,-1):\n y+=ans('9'*i)+1\nif int(r)>99:\n for i in range(len(r)-1,1,-1):\n x+=ans('9'*i)+1\nif r[0]==r[-1]:\n x+=1\nprint(x-y)\n \n\n \n \n \n"}, {"source_code": "l, r = map(int, raw_input().split())\ndef f(x): return (x / 10 + 9 if int(str(x)[0]) <= int(str(x)[-1]) and x >= 10 else x / 10 - 1 + 9 if x >= 10 else x)\nprint f(r) - f(l) + 1 if str(l)[0] == str(l)[-1] else f(r) - f(l)\n\n"}, {"source_code": "#! python\n\nl, r = input().split()\n\ndef count(s: str) -> int:\n if s[0] != s[-1]:\n while s[0] != s[-1]:\n s = str(int(s) - 1)\n\n length = len(s)\n\n if length == 1:\n return int(s)\n\n if length == 2:\n return 9 + int(s[0])\n\n # length > 2\n\n cnt = 9 + 9\n\n cnt += 1 + int(s[1:-1])\n cnt += (int(s[0]) - 1) * 10 ** (length - 2)\n\n cnt += sum(9 * 10 ** (n - 2) for n in range(3, length))\n\n return cnt\n\n\n\n\nprint((l[0] != l[-1]) * -1 + count(r) - count(l) + 1)\n\n"}, {"source_code": "l, r = raw_input().split()\nc = 0\nl = map(int, list(l))\nr = map(int, list(r))\nlen1 = len(l)\nlen2 = len(r)\nif len1 == len2:\n e = len1 - 2\n if e <= 0:\n e = 0\n c += (r[0] - l[0] - 1)*(10**e)\n if l[0] >= l[-1]:\n c += 1\n for i in range(1, len1-1):\n if i == len1-2:\n c += 9-l[i]\n else:\n c += (9-l[i])*(10**(len(l[i+1:])-1))\n if r[0] <= r[-1]:\n c += 1\n for i in range(1, len2-1):\n if i == len2-2:\n c += r[i]\n else:\n c += r[i]*(10**(len(r[i+1:])-1))\n print c\n\nelse:\n for i in range(len1+1, len2):\n if i-2 <= 0:\n c += 9\n else:\n c += 9*(10**(i-2))\n\n e = len1 - 2\n if e <= 0:\n e = 0\n if l[0] >= l[-1]:\n c += 1\n c += (9-l[0])*(10**e)\n for i in range(1, len1-1):\n if i == len1-2:\n c += 9-l[i]\n else:\n c += (9-l[i])*(10**(len(l[i+1:])-1))\n\n e = len2 - 2\n if e <= 0:\n e = 0\n if r[0] <= r[-1]:\n c += 1\n c += (r[0]-1)*(10**e)\n for i in range(1, len2-1):\n if i == len2-2:\n c += r[i]\n else:\n c += r[i]*(10**(len(r[i+1:])-1))\n\n print c\n"}, {"source_code": "def count(x):\n if x < 10:\n res = x\n else: \n f = x % 10\n d = x // 10\n co = 1\n res = 9\n while x > 99:\n res += 9*co\n co *= 10\n x //= 10\n x //= 10 \n res += d - co\n if f >= x: \n res += 1\n return res \n\nl, r = map(int, input().split())\nprint(count(r) - count(l-1))"}, {"source_code": "def calc(r):\n if r<10:\n return r\n ret,l=r//10+9,len(str(r))\n if r%10 < r//10**(l-1):\n ret-=1\n return ret\n\nl,r=map(int,input().split())\nprint(calc(r)-calc(l-1))\n"}, {"source_code": "def digit(c):\n return ord(c)-ord('0')\ndef calc(n):\n if len(n) == 1:\n return digit(n[0])\n elif len(n) == 2:\n return 9 + digit(n[0]) - 1 + int(digit(n[0])<=digit(n[1]))\n else:\n ans = 0\n for m in xrange(1, len(n)+1):\n if m == 1:\n ans += 9\n elif m != len(n):\n ans += 9*(10**(m-2))\n else:\n ans += (digit(n[0])-1)*(10**(m-2)) + int(n[1:-1]) + int(digit(n[0])<=digit(n[-1]))\n return ans\nl, r = raw_input().strip().split()\nprint calc(r)-calc(str(int(l)-1))\n"}, {"source_code": "def help(x):\n if x<=9:\n return x\n arr=list(str(x))\n ans=0\n for i in range(1,len(arr)):\n ans+=help2(i)\n\n #print ans\n ans+=(10**(len(arr)-2))*(int(arr[0])-1)\n #print ans\n a=int(arr[0])\n b=int(arr[-1])\n arr=arr[1:]\n arr=arr[:-1]\n num=0\n if len(arr)>0:\n num+=int(''.join(arr))\n if b>=a:\n ans+=(num+1)\n else:\n ans+=num\n return ans\n\n\ndef help2(i):\n if i==1:\n return 9\n else:\n return 9*(10**(i-2))\n\n\nl,r=map(int,raw_input().split())\n\nprint help(r)-help(l-1)"}, {"source_code": "def func(b):\n n2 = len(b)\n ans = 0\n\n for i in range(1, n2):\n if i == 1: ans += 9\n else:\n ans += 9 * (10 ** (i - 2))\n \n for i in range(0, n2 - 1):\n if n2 > 2:\n if i == 0: tmp = (int(b[i]) - 1) * (10 ** (n2 - 2 - i))\n else: tmp = (int(b[i])) * (10 ** (n2 - 2 - i))\n else:\n tmp = int(b[i]) - 1\n ans += tmp\n if n2 == 1: ans = int(b)\n elif int(b[n2 - 1]) >= int(b[0]): ans -= -1\n return ans\n\na, b = map(int, input().split())\na += -1\na = str(a)\nb = str(b)\n\nans1 = func(a)\nans2 = func(b)\n\n# print(ans1, ans2)\n\nprint(func(b) - func(a))\n"}, {"source_code": "a = [int(st) for st in raw_input().split(' ')]\nif (a[0] < 10) & (a[1] < 10):\n print(a[1] - a[0]+1)\nelif (a[0] < 10) :\n buf_2 = a[1] - int(str(a[1])[-1])\n ans = 10 - a[0] + buf_2//10\n if str(a[1])[0] > str(a[1])[len(str(a[1]))-1]:\n ans -= 1\n else:\n pass\n print(ans)\nelse:\n buf_1 = a[0] - int(str(a[0])[-1])\n buf_2 = a[1] - int(str(a[1])[-1])\n ans = (buf_2 - buf_1)//10 +1\n if str(a[0])[0] < str(a[0])[len(str(a[0]))-1]:\n ans -= 1\n if str(a[1])[0] > str(a[1])[len(str(a[1]))-1]:\n ans -= 1\n print(ans)"}, {"source_code": "\ndef f(x):\n\ts = str(x);\n\treturn x//10 + min(x,9) - (s[0] > s[-1])\nn,m = map(int,input().split())\nprint(f(m)-f(n-1))\n"}, {"source_code": "def power(a,b):\n\tx=1\n\ty=a\n\twhile b!=0:\n\t\tif b%2==1:\n\t\t\tx=x*y\n\t\ty=y*y\n\t\tb=b/2\n\treturn x\ndef ret(s,rl):\n\trr=0\n\tk=int(s[0])\n\trr=(k-1)*power(10,rl-2)\n\tfor i in range(1,rl):\n\t\tif i==rl-1:\n\t\t\tif int(s[i]) >= int(s[0]):\n\t\t\t\trr=rr+1\n\t\telse:\n\t\t\tk=int(s[i])\n\t\t\trr=rr+(k)*power(10,rl-2-i)\n\treturn rr\ns=raw_input()\nll=s.split()\nl=str(int(ll[0])-1)\nr=ll[1]\nrl=len(r)\nll=len(l)\nif rl==1:\n\tansr=int(r)\n\tansl=int(l)\n\tprint ansr-ansl\nelse:\n\tansr=9\n\ti=2\n\twhile i < rl:\n\t\tansr=ansr+9*power(10,i-2)\n\t\ti=i+1\n\tansr=ansr+ret(r,rl)\n#print ansr\n\tif ll==1:\n\t \tansl=int(l)\n\telse:\n\t\tansl=9\n\t\ti=2\n\t\twhile i < ll:\n\t\t\tansl=ansl+9*power(10,i-2)\n\t\t\ti=i+1\n\t\tansl=ansl+ret(l,ll)\n#\tprint ansl\n\tprint ansr-ansl\n"}, {"source_code": "left, right = map(int, input().split())\n\ndef f(x):\n if x < 10:\n return x\n a = []\n t = x\n while t:\n a.append(t % 10)\n t //= 10\n a = a[::-1]\n ret = min(9, x)\n size = len(a)\n first = a[0]\n last = a[-1]\n for curSize in range(size - 1):\n for dig in range(1, 10):\n if curSize < size - 2 or dig < first:\n ret += 10 ** curSize\n elif dig == first:\n s = 0\n for i in range(1, size - 1):\n s = s * 10 + a[i]\n ret += s\n if last >= dig:\n ret += 1\n return ret\n\nprint(f(right) - f(left - 1))"}, {"source_code": "rdi = lambda: list(map(int, input().split()))\n\ndef f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = rdi()\nprint(f(r)-f(l-1))"}, {"source_code": "def ans(num):\n\treturn num if num<10 else num//10+9-(0 if str(num)[0]<=str(num)[-1] else 1)\nl,r=map(int,input().split())\nprint (ans(r)-ans(l-1))"}, {"source_code": "def LB(l,d,lim):\n\ts,e = 0,10**l - 1;\n\twhile s < e:\n\t\tm = (s + e) >> 1;\n\t\tf = str(m);\n\t\tf = \"0\"*(l - len(f)) + f;\n\t\tf = int(str(d) + f + str(d));\n\t\tif f >= lim: e = m;\n\t\telse : s = m + 1;\n\tf = str(s);\n\tf = \"0\"*(l - len(f)) + f;\n\tf = int(str(d) + f + str(d));\n\treturn s + (f < lim);\n\ndef get(l,d,x,y):\n\t#if l == 2 and d == 1: print LB(l,d,y + 1) ,LB(l,d,x)\n\treturn LB(l,d,y + 1) - LB(l,d,x);\t\t\n\nx,y = map(int,raw_input().split());\nans = max(min(y,9) - max(x,1) + 1,0);\n#print ans;\nfor l in xrange(18):\n\tif l:\n\t\tfor d in xrange(1,10):\n\t\t\ttmp = get(l,d,x,y);\n\t\t\tans += tmp;\n\t#\t\tprint l,d,tmp;\n\telse:\n\t\ttmp = 11;\n\t\twhile tmp <= 99:\n\t\t\tans += (x <= tmp) and (tmp <= y);\n\t\t\ttmp += 11;\nprint ans;"}, {"source_code": "p = [0, 1, 1]\np.extend([10 ** x for x in range(1,19)])\n#print(p)\n#a, b = input().split()\n#I need to find the num which are smaller then this \n\ndef get_count(num):\n\tif len(num) == 1:\n\t\treturn int(num)\n\telif len(num) == 2:\n\t\treturn int(num[0]) + 8 if num[0] > num[1] else int(num[0]) + 9\n\telse:\n\t\tresult = 18\n\t\tfor i in range(3, len(num)):\n\t\t\tresult += p[i] * 9\n\t\tfirstDig = int(num[0])\n\t\tlastDig = int(num[-1])\n\t\tresult += (firstDig - 1) * (10 ** (len(num) - 2) )\n\t\tif firstDig <= lastDig:\n\t\t\tresult += int(num[1:-1]) + 1\n\t\telse:\n\t\t\tresult += int(num[1:-1])\n\n\t\treturn result\n\n\na, b = input().split()\nca = (get_count(a))\ncb = (get_count(b))\n# print(ca)\n# print(cb)\nprint(cb - ca + 1 if a[0] == a[-1] else cb - ca )\n# base = p[len(num)]\n\n# result = 0\n# i = 1\n# while i < len(num):\n# \tresult += p[i] * 9\n# \ti += 1\n\n# start = int(num[0])\n# end = int(num[-1])\n\n# result += (start - 1) * (p[len(num) - 2] * 9)\n# if start <= end:\n# \tresult += int(num[1:-1]) + 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"}, {"source_code": "a = [int(st) for st in raw_input().split(' ')]\nif (a[0] < 10) & (a[1] < 10):\n print(a[1] - a[0]+1)\nelif (a[0] < 10) :\n buf_2 = a[1] - int(str(a[1])[-1])\n ans = 10 - a[0] + buf_2//10\n if str(a[1])[0] > str(a[1])[len(str(a[1]))-1]:\n ans -= 1\n else:\n pass\n print(ans)\nelse:\n buf_1 = a[0] - int(str(a[0])[-1])\n buf_2 = a[1] - int(str(a[1])[-1])\n ans = (buf_2 - buf_1)//10 +1\n if str(a[0])[0] < str(a[0])[len(str(a[0]))-1]:\n ans -= 1\n if str(a[1])[0] > str(a[1])[len(str(a[1]))-1]:\n ans -= 1\n print(ans)"}, {"source_code": "def power(a,b):\n\tx=1\n\ty=a\n\twhile b!=0:\n\t\tif b%2==1:\n\t\t\tx=x*y\n\t\ty=y*y\n\t\tb=b/2\n\treturn x\ndef ret(s,rl):\n\trr=0\n\tk=int(s[0])\n\trr=(k-1)*power(10,rl-2)\n\tfor i in range(1,rl):\n\t\tif i==rl-1:\n\t\t\tif int(s[i]) >= int(s[0]):\n\t\t\t\trr=rr+1\n\t\telse:\n\t\t\tk=int(s[i])\n\t\t\trr=rr+(k)*power(10,rl-2-i)\n\treturn rr\ns=raw_input()\nll=s.split()\nl=str(int(ll[0])-1)\nr=ll[1]\nrl=len(r)\nll=len(l)\nif rl==1:\n\tansr=int(r)\n\tansl=int(l)\n\tprint ansr-ansl\nelse:\n\tansr=9\n\ti=2\n\twhile i < rl:\n\t\tansr=ansr+9*power(10,i-2)\n\t\ti=i+1\n\tansr=ansr+ret(r,rl)\n#print ansr\n\tif ll==1:\n\t \tansl=int(l)\n\telse:\n\t\tansl=9\n\t\ti=2\n\t\twhile i < ll:\n\t\t\tansl=ansl+9*power(10,i-2)\n\t\t\ti=i+1\n\t\tansl=ansl+ret(l,ll)\n#\tprint ansl\n\tprint ansr-ansl\n"}, {"source_code": "import sys\nl,r=map(int,raw_input().split())\n\ndef solve(b):\n ok=False\n while not ok:\n s=str(b)\n ok=s[0]==s[-1]\n if not ok:\n b-=1\n \n res=0\n for k in range(100):\n if str(k)[0]==str(k)[-1] and k<=b:\n res+=1;\n lb=len(str(b))\n for l in range(3,lb+1):\n \n if l r:\n return 0\n\n while hi - lo > 1:\n mid = (hi + lo) // 2\n if get(n, x, mid) <= r:\n lo = mid\n else:\n hi = mid\n rgt = lo\n if rgt < hi and get(n, x, rgt + 1) <= r:\n rgt += 1\n lo = 0\n hi = int(\"9\" * (n - 2))\n while hi - lo > 1:\n mid = (hi + lo) // 2\n if get(n, x, mid) < l:\n lo = mid\n else:\n hi = mid\n lft = lo + 1\n if lft > 0 and get(n, x, lft-1) >= l:\n lft -= 1\n return rgt - lft + 1\n\n\nans = 0\nfor i in range(1, 20):\n for x in range(1, 10):\n ans += go(i, x)\n\nprint(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\")\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\n\n\nlength_wise=[0,10,19]\n\nfor i in range(3,19):\n length_wise.append(9*(10**(i-2))+length_wise[-1])\n\n# print(length_wise)\n\ndef operate(x):\n if(x==-1): return 0\n x=str(x)\n if(len(x)==1): return int(x)+1\n \n ans=length_wise[len(x)-1]\n\n key=min(int(x[0]),int(x[-1]))\n key1=max(int(x[0]),int(x[-1]))\n\n if(key==int(x[0])): type=1\n else: type=2\n\n # print(key,ans)\n\n x=x[1:-1]\n ans1=0\n try:ans1=int(x)\n except:pass\n \n if(type==2):\n ans+=(key1-1)*(10**len(x))\n else:\n ans+=(key-1)*(10**len(x))\n ans1+=1\n\n # print(ans,ans1,x)\n\n return ans+ans1\n\n\n\n\n\nl,r=value()\n\n# print(operate(l-1))\n# print(operate(r))\n\nprint(operate(r)-operate(l-1))\n\n\n# BruteForce\n# ans=0\n#\n# for i in range(l,r+1):\n# x=str(i)\n# if(x[0]==x[-1]):\n# # print(x)\n# 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\n "}, {"source_code": "l, r = map(int, raw_input().split())\ndef f(x): return (x / 10 + 9 if str(x)[0] <= str(x)[-1] and x >= 10 else x / 10 + 8 if x >= 10 else x)\nprint f(r) - f(l) + 1 if str(l)[0] == str(l)[-1] else f(r) - f(l)\n\n"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\n\n\nl, r = map(int,input().split())\n\nprint(f(r)-f(l-1))\n"}, {"source_code": "#!/usr/bin/env python\n\nl,r = map(int, raw_input().strip().split())\n\np = [1]\nfor i in xrange(1,20):\n p.append(p[-1]*10)\n\nd = [0,9,18]\nfor i in xrange(3,20):\n d.append(d[i-1]+p[i-2]*9)\n\n\ndef cal(x):\n if x<10: return x\n elif x<100: return d[1] + x/11\n else:\n s = str(x)\n n = len(s)\n k = int(s[0]) - 1\n tmp = d[n-1] + k*p[n-2]\n tmp+=int(s[1:-1])\n if s[0]<=s[-1]:\n tmp+=1\n return tmp\n\n\nres = cal(r)-cal(l)\ns = str(l)\nif s[0]==s[-1]:\n res +=1\n\nprint res\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# from itertools import accumulate\n# from collections import defaultdict, Counter\n\ndef modinv(n,p):\n return pow(n,p-2,p)\n\ndef get_numbers(s):\n if len(s) == 1:\n return int(s)\n \n ans = 0\n n = len(s)\n for i in range(1, n):\n ans += (9 * (10 ** (max(0, i-2))))\n \n x = n-2\n for i in range(n):\n k = int(s[i])\n if i == 0:\n k -= 1\n # print(\"i = \", i, \", k = \", k)\n ans += (k * (10 ** x))\n x -= 1\n if x < 0:\n break\n if int(s[-1]) >= int(s[0]):\n ans += 1\n return ans\n\ndef main():\n #sys.stdin = open('input.txt', 'r')\n #sys.stdout = open('output.txt', 'w')\n\n # print(get_numbers(input()))\n\n l, r = [int(x) for x in input().split()]\n # print(get_numbers(str(l-1)))\n # print(get_numbers(str(r)))\n\n print(get_numbers(str(r)) - get_numbers(str(l-1)))\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\nfrom bisect import bisect_right, bisect_left\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush\nfrom itertools import accumulate\nfrom sys import stdout\n\nR = lambda: map(int, input().split())\na, b = R()\n\ndef cnt(num):\n if num < 10:\n return num\n tmp = num\n n = 0\n t = []\n while tmp:\n t.append(tmp % 10)\n tmp //= 10\n n += 1\n res = 0\n for x in range(n - 1):\n if x == 0:\n res += 9\n else:\n res += 9 * 10**(x - 1)\n for i in range(1, n):\n d = t[i]\n if i < n - 1:\n res += d * 10**(i-1)\n else:\n res += (d - 1) * 10**(i-1)\n if t[0] >= t[-1]:\n res += 1\n return res\n\nprint(cnt(b) - cnt(a - 1))"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = map(int,input().split())\nprint(f(r)-f(l-1))"}, {"source_code": "#!/usr/bin/env python\n\nl,r = map(int, raw_input().strip().split())\n\np = [1]\nfor i in xrange(1,20):\n p.append(p[-1]*10)\n\nd = [0,9,18]\nfor i in xrange(3,20):\n d.append(d[i-1]+p[i-2]*9)\n\n\ndef cal(x):\n if x<10: return x\n elif x<100: return d[1] + x/11\n else:\n s = str(x)\n n = len(s)\n k = int(s[0]) - 1\n tmp = d[n-1] + k*p[n-2]\n tmp+=int(s[1:-1])\n if s[0]<=s[-1]:\n tmp+=1\n return tmp\n\n\nres = cal(r)-cal(l)\ns = str(l)\nif s[0]==s[-1]:\n res +=1\n\nprint res\n"}, {"source_code": "l,r=map(int,raw_input().split())\ndef get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))\nprint get(r)-get(l-1)"}, {"source_code": "def Solve(t):\n if(t < 10):\n return t;\n A = 9\n for i in range(2 , 20):\n if(10 ** i - 1 <= t):\n A += 9 * (10 ** (i - 2))\n else:\n fd = int(str(t)[0])\n ld = t % 10\n A += (fd - 1) * (10 ** (i - 2))\n t -= fd * (10 ** (i - 1))\n if(ld >= fd):\n A += 1\n t = t // 10\n A += t\n break\n return A\nl , r = map(int , input().split())\nprint(Solve(r) - Solve(l - 1))\n \n"}, {"source_code": "p = [0, 1, 1]\np.extend([10 ** x for x in range(1,19)])\n#print(p)\n#a, b = input().split()\n#I need to find the num which are smaller then this \n\ndef get_count(num):\n\tif len(num) == 1:\n\t\treturn int(num)\n\telif len(num) == 2:\n\t\treturn int(num[0]) + 8 if num[0] > num[1] else int(num[0]) + 9\n\telse:\n\t\tresult = 18\n\t\tfor i in range(3, len(num)):\n\t\t\tresult += p[i] * 9\n\t\tfirstDig = int(num[0])\n\t\tlastDig = int(num[-1])\n\t\tresult += (firstDig - 1) * (10 ** (len(num) - 2) )\n\t\tif firstDig <= lastDig:\n\t\t\tresult += int(num[1:-1]) + 1\n\t\telse:\n\t\t\tresult += int(num[1:-1])\n\n\t\treturn result\n\n\na, b = input().split()\nca = (get_count(a))\ncb = (get_count(b))\n# print(ca)\n# print(cb)\nprint(cb - ca + 1 if a[0] == a[-1] else cb - ca )\n# base = p[len(num)]\n\n# result = 0\n# i = 1\n# while i < len(num):\n# \tresult += p[i] * 9\n# \ti += 1\n\n# start = int(num[0])\n# end = int(num[-1])\n\n# result += (start - 1) * (p[len(num) - 2] * 9)\n# if start <= end:\n# \tresult += int(num[1:-1]) + 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"}, {"source_code": "a, b = raw_input().split()\n\ndef val(pos):\n\tans = 10\n\tfor i in range(pos):\n\t\tans += 9 * (10**i)\n\treturn ans\n\ndef calc(x):\n\tif len(x) == 1:\n\t\treturn int(x) + 1\n\telse:\n\t\tbef = val(len(x) - 2)\n\t\tnow = (int(x[0]) - 1) * (10**(len(x) - 2))\n\t\tmid = x[1:-1]\n\t\tif len(mid) == 0:\n\t\t\tmid = 1\n\t\telse:\n\t\t\tmid = int(mid) + 1\n\t\treturn bef + now + mid\n\n\ndef nume(x):\n\tx = int(x)\n\tfor i in range(11):\n\t\tb = str(x)\n\t\tif b[0] == b[-1]:\n\t\t\treturn b\n\t\tx = x - 1\n\na = int(a) - 1\nb = int(b) \na = nume(str(a))\nb = nume(str(b))\n\n\nprint calc(b)- calc(a)"}, {"source_code": "def help(x):\n if x<=9:\n return x\n arr=list(str(x))\n ans=0\n for i in range(1,len(arr)):\n ans+=help2(i)\n\n #print ans\n ans+=(10**(len(arr)-2))*(int(arr[0])-1)\n #print ans\n a=int(arr[0])\n b=int(arr[-1])\n arr=arr[1:]\n arr=arr[:-1]\n num=0\n if len(arr)>0:\n num+=int(''.join(arr))\n if b>=a:\n ans+=(num+1)\n else:\n ans+=num\n return ans\n\n\ndef help2(i):\n if i==1:\n return 9\n else:\n return 9*(10**(i-2))\n\n\nl,r=map(int,raw_input().split())\n\nprint help(r)-help(l-1)"}, {"source_code": "def LB(l,d,lim):\n\ts,e = 0,10**l - 1;\n\twhile s < e:\n\t\tm = (s + e) >> 1;\n\t\tf = str(m);\n\t\tf = \"0\"*(l - len(f)) + f;\n\t\tf = int(str(d) + f + str(d));\n\t\tif f >= lim: e = m;\n\t\telse : s = m + 1;\n\tf = str(s);\n\tf = \"0\"*(l - len(f)) + f;\n\tf = int(str(d) + f + str(d));\n\treturn s + (f < lim);\n\ndef get(l,d,x,y):\n\t#if l == 2 and d == 1: print LB(l,d,y + 1) ,LB(l,d,x)\n\treturn LB(l,d,y + 1) - LB(l,d,x);\t\t\n\nx,y = map(int,raw_input().split());\nans = max(min(y,9) - max(x,1) + 1,0);\n#print ans;\nfor l in xrange(18):\n\tif l:\n\t\tfor d in xrange(1,10):\n\t\t\ttmp = get(l,d,x,y);\n\t\t\tans += tmp;\n\t#\t\tprint l,d,tmp;\n\telse:\n\t\ttmp = 11;\n\t\twhile tmp <= 99:\n\t\t\tans += (x <= tmp) and (tmp <= y);\n\t\t\ttmp += 11;\nprint ans;"}, {"source_code": "def match(x):\n if x < 10:\n return x\n if x < 100:\n return 9 + x / 10 - (1 if x / 10 > x % 10 else 0)\n\n tmp = 1\n while tmp <= x:\n tmp *= 10\n tmp /= 10\n ans = tmp/10 + 8\n ans += tmp/10 * (x/tmp - 1)\n ans += (x % tmp) / 10\n if x / tmp <= x % 10:\n ans += 1\n return ans\n\n[l, r] = [int(x) for x in raw_input().split()]\nprint match(r) - match(l-1)\n"}, {"source_code": "import math\nl,r = map(int, input().split())\n\ndef f(x):\n x = list(map(int, x))\n a = len(x)\n if a < 2:\n return int(x[0])\n ans = 0\n for i in range(1, a):\n ans += 9* int(math.pow(10, max(0, i-2)))\n \n ans += (x[0]-1)* int(math.pow(10, max(0, a-2)))\n if len(x) > 2:\n z = x[1:len(x)-1]\n ans += int(''.join(map(str, z)))\n\n if x[0] <= x[-1]:\n ans += 1\n return int(ans)\n\nprint(f(list(str(r))) - f(list(str(l - 1))))\n"}, {"source_code": "#! /usr/bin/env python\n# @author : grastyele\n\nfrom math import (log10, ceil, floor)\n\ndef solve(x):\n if x < 10:\n return x\n ret = 0\n w = 0\n y = x / 10\n while y > 0:\n w = w + 1\n y = y / 10\n f = x / (10 ** w)\n if x % 10 >= f:\n ret = ret + 1\n for i in xrange(2, w + 1):\n ret = ret + 9 * (10 ** (i - 2))\n ret = ret + (f - 1) * (10 ** (w - 1))\n ret = ret + x % (10 ** w) / 10\n return ret + 9\n\n\nif __name__ == \"__main__\":\n x, y = map(int, raw_input().split())\n print solve(y) - solve(x - 1)\n"}, {"source_code": "def f(x):\n if x < 10:\n return x\n if str(x)[0] > str(x)[-1]:\n return x // 10 + 8\n else:\n return x // 10 + 9\nl, r = map(int, input().split())\nprint(f(r) - f(l - 1))"}, {"source_code": "import bisect\ndef cal(n):\n x=str(n)\n res=0\n if len(x)==1:\n return n\n for i in range(1,len(x)):\n res=res+9*(10**(max(0,i-2)))\n a=[]\n for i in range(1,10):\n s=str(i)+'0'*(max(0,len(x)-2))+str(i)\n a.append(int(s))\n j=bisect.bisect_right(a,n)\n res=res+(j-1)*(10**(max(0,len(x)-2)))\n if j=2:\n res=res+1\n if int(x[0])>int(x[-1]):\n res=res-1\n return res\nl,r=list(map(int,input().split()))\nans=cal(r)-cal(l)\nif str(l)[0]==str(l)[-1]:\n ans=ans+1\nprint(ans)"}, {"source_code": "def sol():\n lower, upper = map(int, raw_input().split())\n res = 0\n for val in range(1, 10):\n if lower <= val <= upper: res+=1 \n for length in range(2, 19):\n for startend in range(1, 10):\n alreadyval = startend * pow(10, length - 1) + (0 if length == 1 else startend)\n smallestpos = max(0, (lower - alreadyval + 9) / 10)\n largestpos = min(pow(10, length - 2) - 1, (upper - alreadyval) / 10)\n res += max(0, largestpos - smallestpos + 1)\n print(res)\nsol()"}, {"source_code": "import math\nl,r = map(int, input().split())\n\ndef f(x):\n x = list(map(int, x))\n a = len(x)\n if a < 2:\n return int(x[0])\n ans = 0\n for i in range(1, a):\n ans += 9* int(math.pow(10, max(0, i-2)))\n \n ans += (x[0]-1)* int(math.pow(10, max(0, a-2)))\n if len(x) > 2:\n z = x[1:len(x)-1]\n ans += int(''.join(map(str, z)))\n\n if x[0] <= x[-1]:\n ans += 1\n return int(ans)\n\nprint(f(list(str(r))) - f(list(str(l - 1))))\n"}, {"source_code": "l,r=map(int,raw_input().split())\ndef get(x): return x if x<10 else (x/10+8+(0 if str(x)[0]>str(x)[-1] else 1))\nprint get(r)-get(l-1)"}, {"source_code": "def ff(num):\n\treturn (int(num) // 10 - (0 if int(str(num)[0]) <= int(str(num)[-1]) else 1) + 9) if int(num) >= 10 else int(num)\n\ndef main():\n mode=\"filee\"\n if mode==\"file\":f=open(\"test.txt\",\"r\")\n #f.readline()\n #input()\n get = lambda :[int(x) for x in (f.readline() if mode==\"file\" else input()).split()]\n [l,r]=get()\n print(ff(r) - ff(l-1))\n \n\n\n if mode==\"file\":f.close()\n\n\nif __name__==\"__main__\":\n main()\n"}, {"source_code": "def f(n):\n mx = len(str(n))\n ans = 0\n for i in range(1, mx):\n for j in range(1, 10):\n if i == 1:\n ans += 1\n else:\n ans += (10 ** (i - 2))\n for j in range(1, 10):\n if mx == 1:\n if j <= n:\n ans += 1\n else:\n break\n continue\n if int(str(j) + '0' * (mx - 2) + str(j)) > n:\n break\n if int(str(j) + '9' * (mx - 2) + str(j)) <= n:\n ans += (10 ** (mx - 2))\n else:\n val = int(str(n)[1:-1]) + 1\n if str(n)[-1] < str(n)[0]:\n val -= 1\n ans += val\n break\n return ans\n\n\nL, R = map(int, input().split())\nprint(f(R) - f(L - 1))\n"}, {"source_code": "dp = [0] * 22\ndp[1] = 9\ndp[2] = 9\ndp[3] = 90\nfor i in range(4,21):\n dp[i] = dp[i-1] * 10\nfor i in range(1,21):\n dp[i] = dp[i] + dp[i-1]\ndef good(s):\n if(str(s)[0]==str(s)[-1]):\n return 1\n return 0\ndef till(x):\n \n Ans = 0\n N = len(str(x))\n if(N == 1):\n return int(x)\n Ans += dp[N-1]\n x = str(x)\n Ans += (int(x[0])-1) * (10**(N-2))\n for i in range(1,N-1):\n Ans += int(x[i]) * (10 ** (N-i-2))\n if(int(x[-1])>= int(x[0])):\n Ans += 1\n return Ans\nl,r = map(int,input().split())\nAns =0\nif(r<=100):\n for i in range(l,r+1):\n Ans += good(i)\n print(Ans)\nelse:\n print(int(till(r) - till(l)+good(l)))\n"}, {"source_code": "def f(s):\n if s == '0':\n return 0\n n = len(s)\n if n > 2:\n sum = '9' * (n-2)\n sum = int(sum) + 9\n elif n == 2:\n sum = 9\n else:\n sum = int(s)\n\n ss = s[0]\n cs = int(s)\n cs -= 10**(n-1)\n s = str(cs)\n n = len(s)\n\n for si in s[:-1]:\n sum += int(si) * 10**(n-2)\n n -= 1\n if int(s[-1]) >= int(ss):\n sum += 1\n return sum\n\n\nl, r = map(int, raw_input().split())\nprint f(str(r)) - f(str(l-1))"}, {"source_code": "l,r=map(int,raw_input().split())\nres=0\n\nwhile (l%10!=0)and(r>=l):\n if str(l)[0]==str(l)[-1]:\n res+=1\n \t#print l\n l+=1\nwhile (r%10!=9)and(r>=l):\n if str(r)[0]==str(r)[-1]:\n res+=1\n #print r\n r-=1\nres+=(r-l+1)/10\nprint res "}, {"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+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\n\n\nlength_wise=[0,10,19]\n\nfor i in range(3,19):\n length_wise.append(9*(10**(i-2))+length_wise[-1])\n\n# print(length_wise)\n\ndef operate(x):\n if(x==-1): return 0\n x=str(x)\n if(len(x)==1): return int(x)+1\n \n ans=length_wise[len(x)-1]\n\n key=min(int(x[0]),int(x[-1]))\n key1=max(int(x[0]),int(x[-1]))\n\n if(key==int(x[0])): type=1\n else: type=2\n\n # print(key,ans)\n\n x=x[1:-1]\n ans1=0\n try:ans1=int(x)\n except:pass\n \n if(type==2):\n ans+=(key1-1)*(10**len(x))\n else:\n ans+=(key-1)*(10**len(x))\n ans1+=1\n\n # print(ans,ans1,x)\n\n return ans+ans1\n\n\n\n\n\nl,r=value()\n\n# print(operate(l-1))\n# print(operate(r))\n\nprint(operate(r)-operate(l-1))\n\n\n# BruteForce\n# ans=0\n#\n# for i in range(l,r+1):\n# x=str(i)\n# if(x[0]==x[-1]):\n# # print(x)\n# 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\n "}, {"source_code": "rdi = lambda: list(map(int, input().split()))\n\ndef f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = rdi()\nprint(f(r)-f(l-1))"}, {"source_code": "from math import pow\n\n\ndef stripped_line():\n return raw_input().strip()\n\n\ndef read_ints():\n return map(int, stripped_line().split())\n\n\ndef total(l):\n diff = l - 2\n if l in (1, 2):\n diff = 0\n result = int(pow(10, diff) * 9)\n return result\n\n\ndef total_to(v):\n as_s = str(v)\n if len(as_s) == 1:\n return v\n if len(as_s) == 2:\n if v == 10:\n return 0\n r = int(as_s[0]) - 1\n if int(as_s[1]) >= int(as_s[0]):\n r += 1\n return r\n else:\n l = len(as_s)\n r = ((int(as_s[0])) - 1) * int(pow(10, l - 2))\n if int(as_s[0]) == 1:\n r = 0\n if int(as_s[-1]) >= int(as_s[0]):\n r += 1\n r += int(as_s[1:-1])\n return r\n\n\ndef total_from(v):\n r = total(len(str(v))) - total_to(v)\n as_s = str(v)\n if as_s[0] == as_s[-1]:\n r += 1\n return r\n\nf, t = read_ints()\n\nfl, tl = len(str(f)), len(str(t))\nresult = 0\nfor i in range(fl, tl + 1):\n if fl == tl:\n result = total(fl) - ((total(fl) - total_from(f)) + (total(fl) - total_to(t)))\n break\n if i == fl:\n result += total_from(f)\n elif i == tl:\n result += total_to(t)\n else:\n result += total(i)\n\nprint result\n"}, {"source_code": "one = [0,9,9]\nx = 9\nfor i in xrange(18):\n x*=10\n one+=[x]\ncone =[0]\nx = 0\nfor i in one[1:]:\n x+=i\n cone+=[x]\nl,r = raw_input().split()\nl=str(int(l)-1)\nrl = len(r)\nrs = cone[rl-1]\nif(True):\n if(rl==1):\n rs += int(r)\n elif(rl==2):\n if(r[0]>r[1]):\n temp = (int(r[0])-1)*(one[rl]/9)\n else:\n temp = (int(r[0]))*(one[rl]/9)\n rs+=temp\n else:\n temp = (int(r[0])-1)*(one[rl]/9)\n rs+=temp\n if(rl>2):\n extra = int(r[1:-1])+1\n if(r[0]>r[-1]):\n extra-=1\n rs+=extra\nll = len(l)\nls = cone[ll-1]\nif(True):\n if(ll==1):\n ls += int(l)\n elif(ll==2):\n if(l[0]>l[1]):\n temp = (int(l[0])-1)*(one[ll]/9)\n else:\n temp = (int(l[0]))*(one[ll]/9)\n ls+=temp\n else:\n temp = (int(l[0])-1)*(one[ll]/9)\n ls+=temp\n if(ll>2):\n extra = int(l[1:-1])+1\n if(l[0]>l[-1]):\n extra-=1\n ls+=extra\nprint rs-ls\n"}, {"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\nread = lambda: map(int, 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) // 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# 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 \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 \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 calc(x):\n\t# print(x // 10)\n\treturn x if x < 10 else x // 10 + 9 - (0 if str(x)[0] <= str(x)[-1] else 1)\n\ndef solve():\n\tl, r = read()\n\tprint(calc(r) - calc(l - 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 sol():\n lower, upper = map(int, raw_input().split())\n res = 0\n for val in range(1, 10):\n if lower <= val <= upper: res+=1 \n for length in range(2, 19):\n for startend in range(1, 10):\n alreadyval = startend * pow(10, length - 1) + (0 if length == 1 else startend)\n smallestpos = max(0, (lower - alreadyval + 9) / 10)\n largestpos = min(pow(10, length - 2) - 1, (upper - alreadyval) / 10)\n res += max(0, largestpos - smallestpos + 1)\n print(res)\nsol()"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = map(int,input().split())\nprint(f(r)-f(l-1))\n"}, {"source_code": "def f(x): return x if x<10 else x//10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\n\n\nl, r = map(int,input().split())\n\nprint(f(r)-f(l-1))\n"}, {"source_code": "# author: sharrad99\ndef get(x):\n\treturn x if x < 10 else x // 10 + 9 - (0 if str(x)[0] <= str(x)[-1] else 1)\nl, r = map(int, input().split())\nprint(get(r) - get(l - 1))\n"}, {"source_code": "a = [int(st) for st in raw_input().split(' ')]\nif (a[0] < 10) & (a[1] < 10):\n print(a[1] - a[0]+1)\nelif (a[0] < 10) :\n buf_2 = a[1] - int(str(a[1])[-1])\n ans = 10 - a[0] + buf_2//10\n if str(a[1])[0] > str(a[1])[len(str(a[1]))-1]:\n ans -= 1\n else:\n pass\n print(ans)\nelse:\n buf_1 = a[0] - int(str(a[0])[-1])\n buf_2 = a[1] - int(str(a[1])[-1])\n ans = (buf_2 - buf_1)//10 +1\n if str(a[0])[0] < str(a[0])[len(str(a[0]))-1]:\n ans -= 1\n if str(a[1])[0] > str(a[1])[len(str(a[1]))-1]:\n ans -= 1\n print(ans)"}, {"source_code": "import bisect\ndef cal(n):\n x=str(n)\n res=0\n if len(x)==1:\n return n\n for i in range(1,len(x)):\n res=res+9*(10**(max(0,i-2)))\n a=[]\n for i in range(1,10):\n s=str(i)+'0'*(max(0,len(x)-2))+str(i)\n a.append(int(s))\n j=bisect.bisect_right(a,n)\n res=res+(j-1)*(10**(max(0,len(x)-2)))\n if j=2:\n res=res+1\n if int(x[0])>int(x[-1]):\n res=res-1\n return res\nl,r=list(map(int,input().split()))\nans=cal(r)-cal(l)\nif str(l)[0]==str(l)[-1]:\n ans=ans+1\nprint(ans)"}, {"source_code": "def check(x): return str(x)[0]==str(x)[-1]\nl,r=map(int,raw_input().split())\nres=0\nwhile (l%10!=0)and(r>=l):\n\tif check(l):\n\t\tres+=1\n\tl+=1\nwhile (r%10!=9)and(r>=l):\n\tif check(r):\n\t\tres+=1\n\tr-=1\nres+=(r-l+1)/10\nprint res"}, {"source_code": "#!/usr/bin/python\n\ndef ini():\n global a\n a[1] = 9\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n#\tprint a\n\ndef get_number(n):\n global a\n num = len(str(n))\n#\tprint 'num === ',num\n ans = 0\n for i in range(1,num):\n ans += a[i]\n#\tprint ans\n if(num == 1):\n ans += n\n elif num == 2:\n if(n // 10 > n % 10) :\n ans += (n // 10 - 1)\n else:\n ans += (n // 10)\n else:\n m = str(n)\n start = int(m[0:1])\n end = n % 10\n ans += (start - 1) * (a[num] / 9)\n if(start <= end):\n ans += int(m[1:-1]) + 1\n else:\n ans += int(m[1:-1])\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()\n"}, {"source_code": "l,r=map(int,raw_input().split())\nres=0\n\nwhile (l%10!=0)and(r>=l):\n if str(l)[0]==str(l)[-1]:\n res+=1\n \t#print l\n l+=1\nwhile (r%10!=9)and(r>=l):\n if str(r)[0]==str(r)[-1]:\n res+=1\n #print r\n r-=1\nres+=(r-l+1)/10\nprint res "}, {"source_code": "#! python\n\nl, r = input().split()\n\ndef count(s: str) -> int:\n if s[0] != s[-1]:\n while s[0] != s[-1]:\n s = str(int(s) - 1)\n\n length = len(s)\n\n if length == 1:\n return int(s)\n\n if length == 2:\n return 9 + int(s[0])\n\n # length > 2\n\n cnt = 9 + 9\n\n cnt += 1 + int(s[1:-1])\n cnt += (int(s[0]) - 1) * 10 ** (length - 2)\n\n cnt += sum(9 * 10 ** (n - 2) for n in range(3, length))\n\n return cnt\n\n\n\n\nprint((l[0] != l[-1]) * -1 + count(r) - count(l) + 1)\n\n"}, {"source_code": "l, r = map(int, input().split())\nans, t = 0, dict({l - 1: 0, r: 0})\n\nif l == r:\n exit(print(1 if str(l)[0] == str(l)[-1] else 0))\nfor num in [l - 1, r]:\n le = 1\n while True:\n if len(str(num)) > le:\n if le < 3:\n t[num] += 9\n else:\n t[num] += (10 ** (le - 2)) * 9\n else:\n if le == 1:\n t[num] += num\n elif le == 2:\n t[num] += int(str(num)[0]) if str(num)[1] >= str(num)[0] else int(str(num)[0]) - 1\n else:\n t[num] += int(str(num)[1:-1]) if int(str(num)[-1]) < int(str(num)[0]) else int(str(num)[1:-1]) + 1\n t[num] += (int(str(num)[0]) - 1) * (10 ** (le - 2))\n break\n\n le += 1\n\n# print(t)\nprint(t[r] - t[l - 1])\n"}, {"source_code": "#!/usr/bin/env python\n\ndef f(num):\n\treturn (int(num) // 10 - (0 if int(str(num)[0]) <= int(str(num)[-1]) else 1) + 9) if int(num) >= 10 else int(num)\n\na,b = map(int,raw_input().split())\nprint f(b) - f(a-1)"}], "negative_code": [{"source_code": "l,r=list(map(int,input().split()))\na=len(str(l))\nb=len(str(r))\nans=0\nif a==b:\n if l==r:\n if str(l)[0]==str(l)[-1]:\n print(1)\n else:\n print(0)\n elif a==1:\n ans+=(r-l+1)\n print(ans)\n else:\n temp1=str(l)[:a-1]\n temp2=str(r)[:b-1]\n ans+=(int(temp2)-int(temp1))\n if int(str(l)[-1])<=int(str(l)[0]):\n ans+=1\n print(ans)\nelse:\n for i in range(a+1,b):\n ans+=(9*(10**(i-2)))\n if a>1:\n temp1=str(l)[:a-1]\n temp2=\"9\"*len(temp1)\n ans+=(int(temp2)-int(temp1))\n if int(str(l)[-1])<=int(str(l)[0]):\n ans+=1\n temp3=str(r)[:b-1]\n temp4=\"1\"+(\"0\"*(len(temp3)-1))\n ans+=(int(temp3)-int(temp4))\n if int(str(r)[-1])>=int(str(r)[0]):\n ans+=1\n print(ans)\n else:\n ans+=(9-l+1)\n temp3=str(r)[:b-1]\n temp4=\"1\"+(\"0\"*(len(temp3)-1))\n ans+=(int(temp3)-int(temp4))\n if int(str(r)[-1])>=int(str(r)[0]):\n ans+=1\n print(ans)"}, {"source_code": "l,r=list(map(int,input().split()))\na=len(str(l))\nb=len(str(r))\nans=0\nfor i in range(a+1,b):\n ans+=(9*(10**(i-2)))\nif a==b:\n if a==1:\n ans+=(r-l+1)\n print(ans)\n else:\n ans+=(9*(10**((int(str(r)[0])-int(str(l)[0])-1)-2)))\n if a>2:\n temp1=str(l)[1:a-1]\n temp2=\"9\"*len(temp1)\n ans+=(int(temp2)-int(temp1))\n if int(str(l)[-1])<=int(str(l)[0]):\n ans+=1\n temp3=str(r)[1:b-1]\n ans+=int(temp3)\n if int(str(r)[-1])>=int(str(r)[0]):\n ans+=1\n print(ans)\n else:\n if int(str(l)[-1])<=int(str(l)[0]):\n ans+=1\n if int(str(r)[-1])>=int(str(r)[0]):\n ans+=1\n print(ans)\nelse:\n if a>1:\n temp1=str(l)[:a-1]\n temp2=\"9\"*len(temp1)\n ans+=(int(temp2)-int(temp1))\n if int(str(l)[-1])<=int(str(l)[0]):\n ans+=1\n temp3=str(r)[:b-1]\n temp4=\"1\"+(\"0\"*(len(temp3)-1))\n ans+=(int(temp3)-int(temp4))\n if int(str(r)[-1])>=int(str(r)[0]):\n ans+=1\n print(ans)\n else:\n ans+=(9-l+1)\n temp3=str(r)[:b-1]\n temp4=\"1\"+(\"0\"*(len(temp3)-1))\n ans+=(int(temp3)-int(temp4))\n if int(str(r)[-1])>=int(str(r)[0]):\n ans+=1\n print(ans)"}, {"source_code": "dp = [0] * 22\ndp[1] = 9\ndp[2] = 9\ndp[3] = 90\nfor i in range(4,21):\n dp[i] = dp[i-1] * 10\nfor i in range(1,21):\n dp[i] = dp[i] + dp[i-1]\ndef good(s):\n if(str(s)[0]==str(s)[-1]):\n return 1\n return 0\ndef till(x):\n Ans = 0\n N = len(str(x))\n Ans += dp[N-1]\n x = str(x)\n Ans += (int(x[0])-1) * (10**(N-2))\n for i in range(1,N-1):\n Ans += int(x[i]) * (10 ** (N-i-2))\n if(int(x[-1])>= int(x[0])):\n Ans += 1\n return Ans\nl,r = map(int,input().split())\nAns =0\nif(r<=100):\n for i in range(l,r+1):\n Ans += good(i)\n print(Ans)\nelse:\n print(till(r) - till(l)+good(l))\n"}, {"source_code": "dp = [0] * 22\ndp[1] = 9\ndp[2] = 9\ndp[3] = 90\nfor i in range(4,21):\n dp[i] = dp[i-1] * 10\nfor i in range(1,21):\n dp[i] = dp[i] + dp[i-1]\ndef good(s):\n if(str(s)[0]==str(s)[-1]):\n return 1\n return 0\ndef till(x):\n Ans = 0\n N = len(str(x))\n Ans += dp[N-1]\n x = str(x)\n Ans += (int(x[0])-1) * (10**(N-2))\n for i in range(1,N-1):\n Ans += int(x[i]) * (10 ** (N-i-2))\n if(int(x[-1])>= int(x[0])):\n Ans += 1\n return Ans\nl,r = map(int,input().split())\nAns =0\nif(r<=100):\n for i in range(l,r+1):\n Ans += good(i)\n print(Ans)\nelse:\n print(int(till(r) - till(l)+good(l)))\n"}, {"source_code": "l, r = map(int, input().split())\nl=l-1\nlc=0\nrc=0\nwhile len(str(l))>3:\n s=str(l);\n while s[0]!=s[-1]:\n l=l-1\n s=str(l)\n lc=lc+int(s[1:-1])+1\n l=l-pow(10,len(s)-2)\n l=l-1\n\nwhile l!=0:\n s=str(l)\n if s[0]==s[-1]:\n lc=lc+1\n l=l-1\n else:\n l=l-1\n\nwhile len(str(r))>3:\n s=str(r);\n while s[0]!=s[-1]:\n r=r-1\n s=str(r)\n #print(r)\n rc=rc+int(s[1:-1])+1\n #print(int(s[1:-1])+1)\n r=r-pow(10,len(s)-2)\n l=r-1\n #print(r)\n\nwhile r!=0:\n s=str(r)\n if s[0]==s[-1]:\n rc=rc+1\n r=r-1\n else:\n r=r-1\n\nprint(rc-lc)"}, {"source_code": "l, r = list( map( int, input().split() ) )\n\ndef cnt( x ) :\n ret = 0\n for i in range( 1, x+1 ):\n s = str(i)\n if s[0] == s[-1]:\n ret += 1\n #print(s)\n return ( ret )\n\ndef cnt2( x ):\n\n ret = 0\n s = str(x)\n L = len(s)\n\n if L >= 2 and x == 10**(L-1):\n return ( cnt2( 10**(L-1)-1 ) )\n\n if L <= 1:\n return ( x )\n elif L <= 2:\n return ( 9 + min( x//10, x%10 ) )\n else:\n ret = int( \"1\" + \"0\"*(L-3) + \"8\" )\n num = list( str(x) )\n #print( num )\n if num[0] != num[-1]:\n if int(num[0]) > int( num[-1] ):\n how = int(num[-1]) + 10-int(num[0])\n else:\n how = int(num[-1]) - int(num[0])\n x -= how\n num = str(x)\n d = x % 10\n #print( 'num',num )\n #print( 'd', d )\n #print( 'num', num, 'ret before', ret )\n ret += ( int(d-1) ) * int( \"9\" * (L-2) ) + int( num[1:-1] ) + int(d)\n\n return ( ret )\n\n#print( cnt(1024), cnt2(1024) )\n#print( cnt(47), cnt2(47) )\n#print( cnt(9), cnt2(9) )\n#print( cnt(58), cnt2(58) )\n#print( cnt(999), cnt2(999) )\n#print( cnt(8987), cnt2(8987) )\n#print()\n#print( cnt(99999), cnt2(99999) )\n#print( cnt(99899), cnt2(99899) )\n#print( cnt(1000), cnt2(1000) )\n#print( cnt2(1) )\n#exit(0)\n \nprint( cnt2(r) - cnt(l-1) )"}, {"source_code": "l, r = list( map( int, input().split() ) )\n\ndef f( x, fl ):\n\n #print( 'x', x )\n L = len(x)\n if L <= 0:\n #print( \"terminate\" )\n return 0\n if L <= 1:\n return int(x)\n\n if fl:\n d = min( int(x[0]), int(x[-1]) )\n else:\n d = max( int(x[0]), int(x[-1]) )\n if d == 0:\n #print( \"\\td is 0\")\n return f( \"9\" + x[1:-1] + \"9\", False )\n ans = d\n if L >= 3:\n #print(' l', (L-2)//2 + 1, ans )\n for i in range( (L-2)//2+1 ):\n ans *= 10\n #print(ans)\n if L >= 2:\n ans += f( x[1:-1], False )\n if L == 2:\n ans += f( \"9\", False )\n\n return ( ans )\n \nprint( f( str(r), True ) - f( str(l-1), True ) )"}, {"source_code": "import bisect\nl,r=list(map(int,input().split()))\nans=0\nfor i in range(len(str(l))+1,len(str(r))):\n ans=ans+9*(10**(i-2))\na1,a2=[],[]\nfor i in range(1,10):\n s=str(i)+'0'*(max(0,len(str(l))-2))+str(i)\n a1.append(int(s))\n s=str(i)+'0'*(max(0,len(str(r))-2))+str(i)\n a2.append(int(s))\nj=bisect.bisect_left(a1,l)\nans=ans+(9-j)*(10**(max(0,len(str(l))-2)))\nj=bisect.bisect_right(a2,r)\nans=ans+(j-1)*(10**(max(0,len(str(r))-2)))\n\nif j=3:\n ans=ans+1\nprint(ans)"}, {"source_code": "import bisect\nl,r=list(map(int,input().split()))\nans=0\nfor i in range(len(str(l))+1,len(str(r))):\n ans=ans+9*(10**(i-2))\na1,a2=[],[]\nfor i in range(1,10):\n s=str(i)+'0'*(max(0,len(str(l))-2))+str(i)\n a1.append(int(s))\n s=str(i)+'0'*(max(0,len(str(r))-2))+str(i)\n a2.append(int(s))\nj=bisect.bisect_left(a1,l)\nans=ans+(9-j)*(10**(max(0,len(str(l))-2)))\nj=bisect.bisect_right(a2,r)\nans=ans+(j-1)*(10**(max(0,len(str(r))-2)))\n\nif j=3:\n ans=ans+1\n if int(str(r)[0])>int(str(r)[-1]):\n ans=ans-1\nprint(ans)"}, {"source_code": "import bisect\ndef cal(n):\n x=str(n)\n res=0\n if len(x)==1:\n return n\n for i in range(1,len(x)):\n res=res+9*(10**(max(0,i-2)))\n a=[]\n for i in range(1,10):\n s=str(i)+'0'*(max(0,len(x)-2))+str(i)\n a.append(int(s))\n j=bisect.bisect_right(a,n)\n res=res+(j-1)*(10**(max(0,len(x)-2)))\n if j=3:\n res=res+1\n if int(x[0])>int(x[-1]):\n res=res-1\n return res\nl,r=list(map(int,input().split()))\nans=cal(r)-cal(l)\nif str(l)[0]==str(l)[-1]:\n ans=ans+1\nprint(ans)"}, {"source_code": "import math\nl,r = map(int, input().split())\n\ndef f(x):\n x = list(map(int, x))\n a = len(x)\n ans = 0\n for i in range(1, a):\n ans += 9* math.pow(10, max(0, i-2))\n \n ans += (x[0]-1)* math.pow(10, max(0, a-2))\n if len(x) > 2:\n z = x[1:len(x)-1]\n ans += int(''.join(map(str, z)))\n\n if x[0] <= x[-1]:\n ans += 1\n return int(ans)\n\nprint(f(list(str(r))) - f(list(str(l - 1))))\n"}, {"source_code": "#! python\n\nl, r = input().split()\n\ndef count(s: str) -> int:\n if s[0] != s[-1]:\n while s[0] != s[-1]:\n s = str(int(s) - 1)\n\n length = len(s)\n\n if length == 1:\n return int(s)\n\n if length == 2:\n return 9 + int(s[0])\n\n # length > 2\n\n cnt = 9 + 9\n\n cnt += 1 + int(s[1:-1])\n cnt += (int(s[0]) - 1) * 10 ** (length - 2)\n\n cnt += sum(9 * 10 ** (n - 2) for n in range(3, length))\n\n return cnt\n\n\nprint(count(r) - count(l) + 1)\n\n"}, {"source_code": "rdi = lambda: list(map(int, input().split()))\n\ndef f(x): return x if x<10 else x/10+9-(0 if str(x)[0]<=str(x)[-1] else 1)\n\nl, r = rdi()\nprint(f(r)-f(l-1))"}, {"source_code": "def sol(x):\n\ts=str(x)\n\treturn x//10 + min(x,9) - (s[0]>s[-1])\n\na,b = map(int,input().split())\nprint(sol(a)-sol(b-1))"}, {"source_code": "def get_count(n):\n lenn = len(str(n))\n if lenn==1:\n return n\n if lenn==2:\n return 9 + n//10\n total=0\n for i in range(1,lenn):\n total+=(max(1,10**(i-2))*9)\n while str(n)[-1]!=str(n)[0]:\n n-=1\n total+=(int(str(n)[1:-1]))\n total+=((int(str(n)[0])-1)*10**(lenn-2))\n return total\n\ndef main():\n mode=\"filee\"\n if mode==\"file\":f=open(\"test.txt\",\"r\")\n #f.readline()\n #input()\n get = lambda :[int(x) for x in (f.readline() if mode==\"file\" else input()).split()]\n [l,r] = get()\n print(get_count(r)-get_count(l)+1 - (1 if len(str(l))>2 and str(l)[0]!=str(l)[-1] else 0))\n\n if mode==\"file\":f.close()\n\n\nif __name__==\"__main__\":\n main()\n"}, {"source_code": "def get_count(n):\n lenn = len(str(n))\n if lenn==1:\n return n\n if lenn==2:\n return 9 + n//10\n total=0\n for i in range(1,lenn):\n total+=(max(1,10**(i-2))*9)\n while str(n)[-1]!=str(n)[0]:\n n-=1\n total+=(int(str(n)[1:-1]))\n total+=((int(str(n)[0])-1)*10**(lenn-2))\n return total\n\ndef main():\n mode=\"filee\"\n if mode==\"file\":f=open(\"test.txt\",\"r\")\n #f.readline()\n #input()\n get = lambda :[int(x) for x in (f.readline() if mode==\"file\" else input()).split()]\n [l,r] = get()\n print(get_count(r)-get_count(l)+1 - (1 if str(l)[0]!=str(l)[-1] else 0))\n\n if mode==\"file\":f.close()\n\n\nif __name__==\"__main__\":\n main()\n"}, {"source_code": "def size(x):\n res = 0\n while x > 0:\n x //= 10\n res += 1\n return res\n\n\ndef first(x):\n last = 0\n while x > 0:\n last = x % 10\n x //= 10\n return last\n\n\ndef last(x):\n return x % 10\n\n\ndef cut(x):\n x //= 10\n x -= first(x) * 10 ** (size(x) - 1)\n return x\n\n\nl, r = list(map(int, input().split()))\n\nsize_l = size(l)\nsize_r = size(r)\n\nresult = int(0)\nfor i in range(size_l + 1, size_r):\n result += 9 * 10 ** (i - 2)\n\nif size_l != size_r:\n result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))\n\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n\nelse:\n result += (first(r) - first(l) - 1) * 10 ** (size_r - min(size_r, 2))\n\n if first(l) != first(r):\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n else:\n result += cut(r) - cut(l) - 1\n if cut(r) - cut(l) > 0:\n if first(l) >= last(l):\n result += 1\n if first(r) <= last(r):\n result += 1\n\nprint(int(result))\n"}, {"source_code": "def size(x):\n res = 0\n while x > 0:\n x //= 10\n res += 1\n return res\n\n\ndef first(x):\n last = 0\n while x > 0:\n last = x % 10\n x //= 10\n return last\n\n\ndef last(x):\n return x % 10\n\n\ndef cut(x):\n x //= 10\n x -= first(x) * 10 ** (size(x) - 1)\n return x\n\n\nl, r = list(map(int, input().split()))\n\nsize_l = size(l)\nsize_r = size(r)\n\nresult = int(0)\nfor i in range(size_l + 1, size_r):\n result += 9 * 10 ** (i - 2)\n\nif size_l != size_r:\n result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))\n\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n\nelse:\n result += (first(r) - first(l) - min(1, first(r) - first(l))) * 10 ** (size_r - min(size_r, 2))\n\n if first(l) != first(r):\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n else:\n result += cut(r) - cut(l) - min(1, cut(r) - cut(l))\n if cut(r) - cut(l) > 0:\n if first(l) >= last(l):\n result += 1\n if first(r) <= last(r):\n result += 1\n\nprint(int(result))\n"}, {"source_code": "def size(x):\n res = 0\n while x > 0:\n x //= 10\n res += 1\n return res\n\n\ndef first(x):\n last = 0\n while x > 0:\n last = x % 10\n x //= 10\n return last\n\n\ndef last(x):\n return x % 10\n\n\ndef cut(x):\n x //= 10\n x -= first(x) * 10 ** (size(x) - 1)\n return x\n\n\nl, r = list(map(int, input().split()))\n\nsize_l = size(l)\nsize_r = size(r)\n\nresult = int(0)\nfor i in range(size_l + 1, size_r):\n result += 9 * 10 ** (i - 2)\n\nif size_l != size_r:\n result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))\n\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n\nelse:\n result += (first(r) - first(l) - min(1, first(r) - first(l))) * 10 ** (\n size_r - min(size_r, 2))\n\n if first(l) != first(r):\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n else:\n result += cut(r) - cut(l) - min(1, cut(r) - cut(l))\n if cut(r) - cut(l) > 0:\n if first(l) >= last(l):\n result += 1\n if first(r) <= last(r):\n result += 1\n else:\n if first(l) >= last(l) and first(l) <= last(r):\n result += 1\n if first(r) <= last(r) and first(r) >= last(l):\n result += 1\n if l == r:\n result -= 1\n\nprint(int(result))\n"}, {"source_code": "def size(x):\n res = 0\n while x > 0:\n x //= 10\n res += 1\n return res\n\n\ndef first(x):\n last = 0\n while x > 0:\n last = x % 10\n x //= 10\n return last\n\n\ndef last(x):\n return x % 10\n\n\ndef cut(x):\n x //= 10\n x -= first(x) * 10 ** (size(x) - 1)\n return x\n\n\nl, r = list(map(int, input().split()))\n\nsize_l = size(l)\nsize_r = size(r)\n\nresult = int(0)\nfor i in range(size_l + 1, size_r):\n result += 9 * 10 ** (i - 2)\n\nif size_l != size_r:\n result += (9 - first(l)) * (10 ** (size_l - min(size_l, 2)))\n\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += (first(r) - 1) * 10 ** (size_r - min(size_r, 2))\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n\nelse:\n result += (first(r) - first(l) - min(1, first(r) - first(l))) * 10 ** (\n size_r - min(size_r, 2))\n\n if first(l) != first(r):\n result += 10 ** (size_l - min(size_l, 2)) - cut(l) - 1\n if first(l) >= last(l):\n result += 1\n\n result += cut(r)\n if first(r) <= last(r):\n result += 1\n else:\n result += cut(r) - cut(l) - min(1, cut(r) - cut(l))\n if cut(r) - cut(l) > 0:\n if first(l) >= last(l):\n result += 1\n if first(r) <= last(r):\n result += 1\n else:\n if first(l) >= last(l) and first(l) <= last(r):\n result += 1\n if first(r) <= last(r) and first(r) >= last(l) and l != r:\n result += 1\n\nprint(int(result))\n"}, {"source_code": "l, r = map(int, input().split())\n\n\ndef get(n, x, mid):\n return int(str(x) + \"0\"*(n - len(str(mid)) - 2) + str(mid) + str(x))\n\n\ndef go(n, x):\n if n == 1:\n return int(l <= x <= r)\n if n == 2:\n return int(l <= 11*x <= r)\n lo = 0\n hi = int(\"9\"*(n-2))\n if get(n, x, hi) < l or get(n, x, lo) > r:\n return 0\n\n while hi - lo > 1:\n mid = (hi + lo) // 2\n if get(n, x, mid) > r:\n hi = mid\n else:\n lo = mid\n\n rgt = lo + 1\n if get(n, x, rgt) > r:\n rgt -= 1\n\n lo = 0\n hi = int(\"9\" * (n - 2))\n\n while hi - lo > 1:\n mid = (hi + lo) // 2\n if get(n, x, mid) >= l:\n hi = mid\n else:\n lo = mid\n lft = lo\n return rgt - lft + 1\n\nans = 0\nfor i in range(1, 20):\n for x in range(1, 10):\n ans += go(i, x)\n\nprint(ans)"}, {"source_code": "l,r = map(int,input().split())\ndef digit(x):\n return x if x<10 else x//10+9-(0 if str(x[0])<=str(x[-1]) else 1)"}, {"source_code": "def count(l,L):\n x=0\n if L<=10:x=L\n else:\n x+=9\n if L<=100:x+=(L//11)\n else:\n x+=9\n leng=len(l)\n for i in range(max(0,leng-3)):\n x+=(9*(10**(i+1)))\n leng-=2\n for i,y in enumerate(l[:-1]):\n y=int(y)\n if i==0:y-=1\n if y>0:x+=(y*(10**leng))\n leng-=1\n if int(l[-1])>=int(l[0]):x+=1\n return x\nl1,l2=map(str,input().split())\na=count(l1,int(l1))\nb=count(l2,int(l2))\nif int(l1[0])==int(l1[-1]):a-=1\nprint(b-a)"}, {"source_code": "p = [0, 1, 1]\np.extend([10 ** x for x in range(1,16)])\n#print(p)\n#a, b = input().split()\n#I need to find the num which are smaller then this \n\ndef get_count(num):\n\tif len(num) == 1:\n\t\treturn int(num)\n\telif len(num) == 2:\n\t\treturn int(num[0]) + 8 if num[0] > num[1] else int(num[0]) + 9\n\telse:\n\t\tresult = 18\n\t\tfor i in range(3, len(num)):\n\t\t\tresult += p[i] * 9\n\t\tfirstDig = int(num[0])\n\t\tlastDig = int(num[-1])\n\t\tresult += (firstDig - 1) * (10 ** (len(num) - 2) )\n\t\tif firstDig <= lastDig:\n\t\t\tresult += int(num[1:-1]) + 1\n\n\t\treturn result\n\n\na, b = input().split()\nca = (get_count(a))\ncb = (get_count(b))\nprint(cb - ca + 1 if a[0] == a[-1] else cb - ca )\n# base = p[len(num)]\n\n# result = 0\n# i = 1\n# while i < len(num):\n# \tresult += p[i] * 9\n# \ti += 1\n\n# start = int(num[0])\n# end = int(num[-1])\n\n# result += (start - 1) * (p[len(num) - 2] * 9)\n# if start <= end:\n# \tresult += int(num[1:-1]) + 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"}, {"source_code": "n=input().split()\nl=int(n[0])\nr=int(n[1])\ns=0\nif r==l:\n print(0)\n exit()\nif r<=100:\n for i in range(l,r+1):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n print(s) \n exit()\nif l>=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n '''if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()'''\n print(int((r-l)/10)) \n exit()\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n print(s2-s1-1)\n '''if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()'''\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(l-100)//10\n print(s2-s1)\n '''if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()'''\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n if s2-s1==1:\n print(0)\n exit()\n elif r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n if s2-s1==1:\n print(0)\n exit()\n elif r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n '''if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()'''\n print(int((r-l)/10)) \n exit()\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n print(s2-s1)\n '''if str(r)[0]<=str(r)[len(str(r))-1]:\n print((r-l)//10+1)\n exit()\n if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()'''\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)/10\n s2=(r-100)/10\n s3=s2-s1\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(int(s3+1))\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n if str(r)[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n print(s2-s1) \n '''if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()'''\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)/10\n s2=(r-100)/10\n s3=s2-s1\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(int(s3+1))\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n elif l2[0]100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]=100:\n s1=(l-100)//10\n s2=(r-100)//10\n r2=str(r)\n l2=str(l)\n \n if r2[0]<=r2[len(r2)-1]:\n print(s2-s1+1)\n exit()\n print(s2-s1-1) \n '''if str(l)[0]==str(l)[len(str(l))-1]:\n print((r-l)//10+1)\n exit()\n print(int((r-l)/10)) \n exit()'''\nif r>100 and l<100:\n for i in range(l,100):\n i=str(i)\n if i[0]==i[len(i)-1]:\n s+=1\n if str(r)[0]= lx) * (rx - lx + 1)\nprint(ans)"}, {"source_code": "import math\nl, r = map(int, input().split())\nans = (l <= 9) * (9 - l + 1)\nfor k in range(0, 17):\n for d in range(1, 10):\n rb = math.floor((r - d - 10 ** (k + 1) * d) / 10)\n lb = math.ceil((l - d - 10 ** (k + 1) * d) / 10)\n rx = min(10 ** k - 1, rb)\n lx = max(0, lb)\n ans += (rx >= lx) * (rx - lx + 1)\nprint(ans)"}, {"source_code": "import math\nl, r = map(int, input().split())\nans = (l <= 9) * (9 - l + 1)\nfor d in range(1, 10):\n for k in range(0, 17):\n rb = int(math.floor(r - d - 10 ** (k + 1) * d) / 10)\n lb = int(math.ceil(l - d - 10 ** (k + 1) * d) / 10)\n #print(\"k = %d, d = %d\" % (k, d))\n #print(rb)\n rb = min(10 ** k - 1, rb)\n lb = max(0, lb)\n ans += (rb >= lb) * (rb - lb + 1)\nprint(ans - 1)"}, {"source_code": "#!/usr/bin/python\n\n\ndef ini():\n global a\n a[1] = 10\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n\n\ndef get_number(n):\n global a\n num = len(str(n))\n ans = 0\n for i in range(1,num):\n ans += a[i]\n if(num == 1):\n ans += n\n elif num == 2:\n ans += (n // 10 - 1)\n else:\n m = str(n)\n start = int(m[0:1])\n end = int(m[-2:-1])\n if(start <= end):\n ans += int(m[1:-1])\n else:\n ans += int(m[1:-1]) - 1\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()"}, {"source_code": "#!/usr/bin/python\n\n\ndef ini():\n global a\n a[1] = 10\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n\n\ndef get_number(n):\n global a\n num = len(str(n))\n ans = 0\n for i in range(1,num):\n ans += a[i]\n if(num == 1):\n ans += n\n elif num == 2:\n ans += (n // 10 - 1)\n else:\n m = str(n)\n start = int(m[0:1])\n end = int(m[-2:-1])\n if(start <= end):\n ans += int(m[1:-1]) + 1\n else:\n ans += int(m[1:-1])\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()"}, {"source_code": "#!/usr/bin/python\n\n\ndef ini():\n global a\n a[1] = 9\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n\n\ndef get_number(n):\n global a\n num = len(str(n))\n ans = 0\n for i in range(1,num):\n ans += a[i]\n if(num == 1):\n ans += n\n elif num == 2:\n ans += (n // 10 - 1)\n else:\n m = str(n)\n start = int(m[0:1])\n end = int(m[-2:-1])\n ans += (start - 1) * (a[num - 2] / 9)\n if(start <= end):\n ans += int(m[1:-1])\n else:\n ans += int(m[1:-1])\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()"}, {"source_code": "#!/usr/bin/python\n\ndef ini():\n global a\n a[1] = 9\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n#\tprint a\n\ndef get_number(n):\n global a\n num = len(str(n))\n#\tprint 'num === ',num\n ans = 0\n for i in range(1,num):\n ans += a[i]\n#\tprint ans\n if(num == 1):\n ans += n\n elif num == 2:\n if(n // 10 > n % 10) :\n ans += (n // 10 - 1)\n else:\n ans += (n // 10)\n else:\n m = str(n)\n start = int(m[0:1])\n end = int(m[-2:-1])\n ans += (start - 1) * (a[num] / 9)\n if(start <= end):\n ans += int(m[1:-1]) + 1\n else:\n ans += int(m[1:-1])\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()\n"}, {"source_code": "#!/usr/bin/python\n\n\ndef ini():\n global a\n a[1] = 10\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n\n\ndef get_number(n):\n global a\n num = len(str(n))\n ans = 0\n for i in range(1,num):\n ans += a[i]\n if(num == 1):\n ans += n\n elif num == 2:\n ans += (n // 10 - 1)\n else:\n m = str(n)\n ans += int(m[1:-1])\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()"}, {"source_code": "#!/usr/bin/python\n\n\ndef ini():\n global a\n a[1] = 9\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n\n\ndef get_number(n):\n global a\n num = len(str(n))\n ans = 0\n for i in range(1,num):\n ans += a[i]\n if(num == 1):\n ans += n\n elif num == 2:\n if(n // 10 > n % 10) :\n ans += (n // 10 - 1)\n else:\n ans += (n // 10)\n else:\n m = str(n)\n start = int(m[0:1])\n end = int(m[-2:-1])\n ans += (start - 1) * (a[num - 2] / 9)\n if(start <= end):\n ans += int(m[1:-1]) + 1\n else:\n ans += int(m[1:-1])\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()"}, {"source_code": "#!/usr/bin/python\n\n\ndef ini():\n global a\n a[1] = 10\n a[2] = 9\n for i in range(3,19):\n a[i] = a[i - 1] * 10\n\n\ndef get_number(n):\n global a\n num = len(str(n))\n ans = 0\n for i in range(1,num):\n ans += a[i]\n if(num == 1):\n ans += n\n elif num == 2:\n ans += (n // 10 - 1)\n else:\n m = str(n)\n start = int(m[0:1])\n end = int(m[-2:-1])\n if(start <= end):\n ans += int(m[1:-1])\n else:\n if(int(m[1:-1]) != 0):\n ans += int(m[1:-1]) - 1\n return ans\n\ndef main():\n left,right = map(int,raw_input().split())\n print get_number(right) - get_number(left - 1)\n\nif __name__ == '__main__':\n global a\n a = [0 for i in range(20)]\n ini()\n main()"}, {"source_code": "#!/usr/bin/env python\n\ndef f(num):\n\treturn (int(num) // 10 - (0 if str(num)[0] == str(num)[-1] else 1) + 9) if int(num) > 9 else int(num)\n\na,b = map(int,raw_input().split())\nprint f(b) - f(a-1)"}, {"source_code": "#! /usr/bin/env python\n# @author : grastyele\n\nfrom math import (log10, ceil, floor)\n\ndef solve(x):\n if x < 10:\n return x\n ret = 0\n w = 0\n y = x\n while y > 0:\n w = w + 1\n y = y / 10\n f = x / (10 ** w)\n if x % 10 >= f:\n ret = ret + 1\n for i in xrange(2, w + 1):\n ret = ret + 9 * (10 ** (i - 2))\n ret = ret + (f - 1) * (10 ** (w - 1))\n ret = ret + x % (10 ** w) / 10\n return ret + 9\n\n\nif __name__ == \"__main__\":\n x, y = map(int, raw_input().split())\n print solve(y) - solve(x - 1)\n"}, {"source_code": "#! /usr/bin/env python\n# @author : grastyele\n\nfrom math import (log10, ceil, floor)\n\ndef solve(x):\n if x < 10:\n return x\n ret = 0\n w = int(floor(log10(x)))\n f = x / (10 ** w)\n if x % 10 >= f:\n ret = ret + 1\n for i in xrange(2, w + 1):\n ret = ret + 9 * (10 ** (i - 2))\n ret = ret + (f - 1) * (10 ** (w - 1))\n ret = ret + x % (10 ** w) / 10;\n return ret + 9\n\n\nif __name__ == \"__main__\":\n x, y = map(int, raw_input().split())\n print solve(y) - solve(x - 1)\n"}, {"source_code": "#! /usr/bin/env python\n# @author : grastyele\n\nfrom math import (log10, ceil, floor)\n\ndef solve(x):\n if x < 10:\n return x\n ret = 0\n w = 0\n y = x - 1\n while y > 0:\n w = w + 1\n y = y / 10\n f = x / (10 ** w)\n if x % 10 >= f:\n ret = ret + 1\n for i in xrange(2, w + 1):\n ret = ret + 9 * (10 ** (i - 2))\n ret = ret + (f - 1) * (10 ** (w - 1))\n ret = ret + x % (10 ** w) / 10\n return ret + 9\n\n\nif __name__ == \"__main__\":\n x, y = map(int, raw_input().split())\n print solve(y) - solve(x - 1)\n"}, {"source_code": "#! /usr/bin/env python\n# @author : grastyele\n\nfrom math import (log10, ceil, floor)\n\ndef solve(x):\n if x < 10:\n return x\n ret = 0\n w = int(floor(log10(x)))\n f = x / (10 ** w)\n if x % 10 >= f:\n ret = ret + 1\n for i in xrange(2, w + 1):\n ret = ret + 9 * (10 ** (i - 2))\n ret = ret + (f - 1) * (10 ** (w - 1));\n for j in range(w - 1, 0, -1):\n a = x / (10 ** j) % 10\n ret = ret + a * (10 ** (j - 1))\n return ret + 9\n\n\nif __name__ == \"__main__\":\n x, y = map(int, raw_input().split())\n print solve(y) - solve(x - 1)\n"}, {"source_code": "def prev(n):\n if len(n)==1:\n return 10-int(n)\n\n if n[0] 2:\n ans = 10**(len(n)-2) - int(n[1:len(n) - 1]) -1\n\n return (9-int(n[0])) *(10**(len(n)-2))+ans\n else:\n ans=0\n if len(n)>2:\n ans=int(n[1:len(n)-1])\n return (10-int(n[0])) *(10**(len(n)-2)) - ans\n\ndef nextt(n):\n if len(n)==1:\n return int(n)\n\n if n[0]>n[len(n)-1]:\n ans=0\n if len(n) > 2:\n ans = int(n[1:len(n) - 1])\n return (int(n[0])-1)* (10 ** (len(n) - 2)) + ans\n else:\n ans = 0\n if len(n) > 2:\n ans = int(n[1:len(n) - 1])\n return (int(n[0])-1)*(10**(len(n)-2))+ ans + 1\n\nl,r=raw_input().split()\nans=prev(l)\nans+=nextt(r)\n\nif(len(l)==len(r)):\n print ans-9\n exit(0)\n\nfor i in range(len(l)+1,len(r),1):\n ans+= 9* (10**(i-2))\nprint ans\n\n\n\n"}, {"source_code": "def prev(n):\n if len(n)==1:\n return 10-int(n)\n\n if n[0] 2:\n ans = 10**(len(n)-2) - int(n[1:len(n) - 1]) -1\n\n return (9-int(n[0])) *(10**(len(n)-2))+ans\n else:\n ans=0\n if len(n)>2:\n ans=int(n[1:len(n)-1])\n return (10-int(n[0])) *(10**(len(n)-2)) - ans\n\ndef nextt(n):\n if len(n)==1:\n return int(n)\n\n if n[0]>n[len(n)-1]:\n ans=0\n if len(n) > 2:\n ans = int(n[1:len(n) - 1])\n return (int(n[0])-1)* (10 ** (len(n) - 2)) + ans\n else:\n ans = 0\n if len(n) > 2:\n ans = int(n[1:len(n) - 1])\n return (int(n[0])-1)*(10**(len(n)-2))+ ans + 1\n\nl,r=raw_input().split()\nans=prev(l)\n\nans+=nextt(r)\n\nif(len(l)==len(r)):\n print ans-9* (10**(len(l)-2))\n exit(0)\n\nfor i in range(len(l)+1,len(r),1):\n ans+= 9* (10**(i-2))\nprint ans\n\n\n\n"}, {"source_code": "def prev(n):\n if len(n)==1:\n return 10-int(n)\n\n if n[0]2:\n ans=int(n[1:len(n)-1])\n return (10-int(n[0])) *(10**(len(n)-2)) - ans\n\ndef nextt(n):\n if len(n)==1:\n return int(n)\n\n if n[0]>n[len(n)-1]:\n return (int(n[0])-1)* (10 ** (len(n) - 2))\n else:\n ans = 0\n if len(n) > 2:\n ans = int(n[1:len(n) - 1])\n return (int(n[0])) + ans\n\nl,r=raw_input().split()\nans=prev(l)\nans+=nextt(r)\nfor i in range(len(l)+1,len(r),1):\n ans+= 9* (10**(i-2))\nprint ans\n\n\n\n"}, {"source_code": "def sol():\n lower, upper = map(int, raw_input().split())\n res = 0\n for length in range(1, 19):\n for startend in range(1, 10):\n alreadyval = startend * pow(10, length - 1) + (0 if length == 1 else startend)\n smallestpos = max(0, (lower - alreadyval + 9) / 10)\n largestpos = 0 if length <= 1 else min(pow(10, length - 2) - 1, upper, (upper - alreadyval) / 10)\n res += max(0, largestpos - smallestpos + 1)\n print(res)\nsol()"}, {"source_code": "def help(x):\n if x<=9:\n return x\n arr=list(str(x))\n ans=0\n for i in range(1,len(arr)):\n ans+=help2(i)\n\n #print ans\n ans+=(10**(len(arr)-2))*(int(arr[0])-1)\n #print ans\n a=int(arr[0])\n b=int(arr[-1])\n arr=arr[1:]\n arr=arr[:-1]\n num=0\n if len(arr)>0:\n num+=int(''.join(arr))\n if b>=a:\n ans+=(num+1)\n else:\n ans+=num-1\n return ans\n\n\n\n\n\n\n\ndef help2(i):\n if i==1:\n return 9\n else:\n return 9*(10**(i-2))\n\n\nl,r=map(int,raw_input().split())\n\nprint help(r)-help(l-1)"}, {"source_code": "\ndef cnt(L, R, dig, len):\n \n x = pow(10, len - 1) \n \n if (L >= (dig + 1) * x):\n return 0\n \n if (R < dig * x):\n return 0\n \n left = max(L, dig * x)\n right = min(R, (dig + 1) * x - 1)\n \n return (right - left + 1)\n\ndef main():\n \n l, r = map(int, raw_input().split(' '))\n \n i = 0\n while( pow(10,i) <= r ):\n i += 1\n \n ans = 0\n \n for dig in range(1,10):\n for len in range(2, i+1):\n L = (l + 10 - dig)/10\n R = (r - dig)/10\n \n ans += cnt(L, R, dig, len - 1)\n \n if (dig >= l and dig <= r):\n ans += 1\n \n print ans\n \n\nif __name__ == '__main__':\n main()"}, {"source_code": "import sys\nl,r=map(int,raw_input().split())\n\ndef solve(b):\n ok=False\n while not ok:\n s=str(b)\n ok=s[0]==s[-1]\n if not ok:\n b-=1\n \n res=0\n for k in range(100):\n if str(k)[0]==str(k)[-1] and k<=b:\n res+=1;\n lb=len(str(b))\n print lb\n for l in range(3,lb+1):\n \n if l2 else 1\n if s[0]>s[-1]: ans -= 1 if len(s)>2 else 0\n# print 'cal1', locals(), ans\n return ans\n\ndef GetResult(l, r):\n ans = 0\n l1 = len(str(l))\n l2 = len(str(r))\n if str(l)[-1]=='0': l += 1\n if l1 == l2: return Cal1(r) - Cal1(l-1) \n for i in range(l1+1, l2):\n ans += Cal(i, 9)\n return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)\n\ntry:\n while True:\n l,r = map(int, raw_input().split())\n print GetResult(l, r)\nexcept Exception,e:\n pass\n"}, {"source_code": "def Cal(length, num):\n length = length - 2\n if length < 0: length = 0\n# print 'cal', locals(), num*10**length\n return num*10**length \n\ndef Cal1(num):\n s = str(num)\n if s[0]=='0': return 0\n ans = Cal(len(s), int(s[0])-1)\n if s[0]<=s[-1] and len(s)>=1: ans += (int(s[1:-1])+1) if len(s)>2 else 1\n# print 'cal1', locals(), ans\n return ans\n\ndef GetResult(l, r):\n ans = 0\n l1 = len(str(l))\n l2 = len(str(r))\n if str(l)[-1]=='0': l += 1\n if l1 == l2: return Cal1(r) - Cal1(l-1) \n for i in range(l1+1, l2):\n ans += Cal(i, 9)\n return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)\n\ntry:\n while True:\n l,r = map(int, raw_input().split())\n print GetResult(l, r)\nexcept Exception,e:\n pass\n"}, {"source_code": "def Cal(length, num):\n if num<=0: return 0\n length = length - 2\n if length < 0: length = 0\n# print 'cal', locals(), num*10**length\n return num*10**length \n\ndef Cal1(num):\n s = str(num)\n ans = Cal(len(s), int(s[0])-1)\n if s[0]<=s[-1] and len(s)>=1: ans += (int(s[1:-1])+1) if len(s)>2 else 1\n# print 'cal1', locals(), ans\n return ans\n\ndef GetResult(l, r):\n ans = 0\n l1 = len(str(l))\n l2 = len(str(r))\n if str(l)[-1]=='0': l += 1\n if l1 == l2: return Cal1(r) - Cal1(l-1) \n for i in range(l1+1, l2):\n ans += Cal(i, 9)\n print i, ans\n return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)\n\nl,r = map(int, raw_input().split())\nprint GetResult(l, r)\n"}, {"source_code": "def Cal(length, num):\n if num<=0: return 0\n length = length - 2\n if length < 0: length = 0\n# print 'cal', locals(), num*10**length\n return num*10**length \n\ndef Cal1(num):\n s = str(num)\n ans = Cal(len(s), int(s[0])-1)\n if s[0]<=s[-1] and len(s)>=1: ans += (int(s[1:-1])+1) if len(s)>2 else 1\n# print 'cal1', locals(), ans\n return ans\n\ndef GetResult(l, r):\n ans = 0\n l1 = len(str(l))\n l2 = len(str(r))\n if str(l)[-1]=='0': l += 1\n if l1 == l2: return Cal1(r) - Cal1(l-1) \n for i in range(l1+1, l2):\n ans += Cal(i, 9)\n #print i, ans\n return ans + Cal(l1, 9) - Cal1(l-1) + Cal1(r)\n\nl,r = map(int, raw_input().split())\nprint GetResult(l, r)\n"}, {"source_code": "def LB(l,d,lim):\n\ts,e = 0,10**l - 1;\n\twhile s < e:\n\t\tm = (s + e) >> 1;\n\t\tf = str(m);\n\t\tf = \"0\"*(l - len(f)) + f;\n\t\tf = int(str(d) + f + str(d));\n\t\tif f >= lim: e = m;\n\t\telse : s = m + 1;\n\tf = str(s);\n\tf = \"0\"*(l - len(f)) + f;\n\tf = int(str(d) + f + str(d));\n\treturn s + (f <= lim);\n\ndef get(l,d,x,y):\n\treturn LB(l,d,y + 1) - LB(l,d,x);\t\t\n\nx,y = map(int,raw_input().split());\nans = max(min(y,9) - max(x,1) + 1,0);\nfor l in xrange(18):\n\tif l:\n\t\tfor d in xrange(1,10):\n\t\t\ttmp = get(l,d,x,y);\n\t\t\tans += tmp;\n\t#\t\tprint l,d,tmp;\n\telse:\n\t\ttmp = 11;\n\t\twhile tmp <= 99:\n\t\t\tans += (x <= tmp) and (tmp <= y);\n\t\t\ttmp += 11;\nprint ans;"}, {"source_code": "l,r=map(int,input().split())\n'''\ncnt = 0 \nfor i in range(l,r+1):\n if str(i)[0]==str(i)[-1]: cnt+=1 \nprint(cnt)\ndef upto_x(n):\n if n<=1000:\n cnt = 0 \n for i in range(1,n+1):\n if str(i)[0]==str(i)[-1]: cnt+=1 \n return cnt \n s=str(n)\n sm=0 \n slen=len(s)\n if slen>=1:\n sm=0 \n elif slen>=2:\n sm+=9 \n elif slen>=3:\n sm+=10 \n else:\n sm=10**(slen-2) \n print(sm)\n now=10**(slen-1) \n now*=int(s[0])\n if s[-1]>=s[0]:\n now+=10**(slen-1)\n sm+=now \n return sm \nprint(upto_x(r))\nprint(upto_x(r)-upto_x(l-1))'''\ndef upto_x(n):\n if n<10:\n return 9 \n sm=n//10 +9 \n if str(n)[-1]= l:\n a, b, c = 0, int((length - 2) * '9'), 0\n while a < b:\n c = (a + b) // 2\n if int(d_str + '0' * (length - 2 - len(str(c))) + str(c) + d_str) < l:\n a = c + 1\n else:\n b = c\n l_end = a\n a, b, c = 0, int((length - 2) * '9'), 0\n while a < b:\n c = (a + b + 1) // 2\n if int(d_str + '0' * (length - 2 - len(str(c))) + str(c) + d_str) > r:\n b = c - 1\n else:\n a = c\n r_end = a\n #print(str(l_end) + \" \" + str(r_end))\n #print(\" \" + str(d_str + '0' * (length - 2 - len(str(l_end))) + str(l_end) + d_str))\n #print(\" \" + str(d_str + '0' * (length - 2 - len(str(r_end))) + str(r_end) + d_str))\n result += r_end - l_end + 1\n\nfor digit in range(1, 10):\n length = 1\n if l <= digit and digit <= r:\n result += 1\n length = 2\n if int(str(digit) + str(digit)) >= l and int(str(digit) + str(digit)) <= r:\n result += 1\n\nprint(result)\n"}, {"source_code": "#!/usr/bin/env python\n\nl,r = map(int, raw_input().strip().split())\n\np = [1]\nfor i in xrange(1,20):\n p.append(p[-1]*10)\n\nd = [0,9,18]\nfor i in xrange(3,20):\n d.append(d[i-1]+p[i-2]*9)\n\n\ndef cal(x):\n if x<10: return x\n elif x<100: return d[1] + x/11\n else:\n s = str(x)\n n = len(s)\n k = int(s[0]) - 1\n tmp = d[n-1] + k*p[n-2]\n if s[0]<=s[-1]:\n tmp+=int(s[1:-1])+1\n return tmp\n\n\nres = cal(r)-cal(l)\ns = str(l)\nif s[0]==s[-1]:\n res +=1\n\nprint res\n"}, {"source_code": "#!/usr/bin/env python\n\ndef total(num):\n\tif num == 1:\n\t\treturn 9\n\telse:\n\t\treturn 9*(10**(num-2))\n\ndef is_cool(num):\n\tnum = str(num)\n\treturn num[0] == num[-1]\t\t\n\t\t\ndef f(num):\n\tif num > 99:\n\t\tnum = str(num)\n\t\tl, r = map(int,[num[0], num[-1]])\n\t\ts = int(num[1:-1])\n\t\tif r == 0:\n\t\t\tres = 0\n\t\telse:\n\t\t\tres = (min(l,r)-1)*10**(len(num)-2) + s + 1\n\t\tfor i in xrange(1,len(num)):\n\t\t\tres = res + total(i)\n\t\treturn res\n\telse:\n\t\tres = 0\n\t\tfor i in xrange(1,num+1):\n\t\t\tif is_cool(i):\n\t\t\t\tres = res + 1\n\t\treturn res\n\t\t\na,b = map(int,raw_input().split())\nprint f(b) - f(a-1)"}, {"source_code": "#!/usr/bin/env python\n\ndef total(num):\n\tif num == 1:\n\t\treturn 9\n\telse:\n\t\treturn 9*(10**(num-2))\n\ndef is_cool(num):\n\tnum = str(num)\n\treturn num[0] == num[-1]\t\t\n\t\t\ndef f(num):\n\tif num > 99:\n\t\tnum = str(num)\n\t\tl, r = map(int,[num[0], num[-1]])\n\t\ts = int(num[1:-1])\n\t\tif r == 0:\n\t\t\tres = 0\n\t\telse:\n\t\t\tres = (l-1)*10**(len(num)-2) + s + 1\n\t\tfor i in xrange(1,len(num)):\n\t\t\tres = res + total(i)\n\t\treturn res\n\telse:\n\t\tres = 0\n\t\tfor i in xrange(1,num+1):\n\t\t\tif is_cool(i):\n\t\t\t\tres = res + 1\n\t\treturn res\n\t\t\na,b = map(int,raw_input().split())\nprint f(b) - f(a-1)"}, {"source_code": "def F(x):\n\tl=len(str(x))\n\tz=0\n\tif l==1:\n\t\treturn x\n\telif l==2:\n\t\treturn x/11+9\n\telse:\n\t\tz=18\n\tfor i in range(3,l):\n\t\tz+=9*10**(i-2)\n\tf=int(str(x)[0])\n\tz+=(f-1)*10**(l-2)\n\tg=int()\n\tg/=10\n\tz+=g\n\th=int(str(f)+str(x)[1:l-1]+str(f))\n\tprint h,x\n\tif h<=x:\n\t\tz+=1\n\treturn z\nx,y=map(int,raw_input().split())\nprint F(y)-F(x-1)"}, {"source_code": "def F(x):\n\tl=len(str(x))\n\tz=0\n\tif l==1:\n\t\treturn x\n\telif l==2:\n\t\treturn x/11+9\n\telse:\n\t\tz=18\n\tfor i in range(3,l):\n\t\tz+=9*10**(i-2)\n\tf=int(str(x)[0])\n\tz+=(f-1)*10**(l-2)\n\tg=int(str(x)[1:])\n\tg/=10\n\tz+=g\n\th=int(str(f)+str(g)+str(f))\n\tif h<=x:\n\t\tz+=1\n\treturn z\nx,y=map(int,raw_input().split())\nprint F(y)-F(x-1)"}, {"source_code": "def match(x):\n if x < 10:\n return x\n if x < 100:\n return 9 + x / 10 - (1 if x / 10 > x % 10 else 0)\n\n tmp = 1\n while tmp <= x:\n tmp *= 10\n tmp /= 10\n ans = tmp/10 + 8\n ans += tmp/10 * (x/tmp - 1)\n ans += (x % tmp) / 10\n if x / tmp <= x % 10:\n ans += 1\n return ans\n\n[l, r] = [int(x) for x in raw_input().split()]\nprint match(l-1)\nprint match(r)\nprint match(r) - match(l-1)\n"}, {"source_code": "l, r = raw_input().split()\nc = 0\nl = map(int, list(l))\nr = map(int, list(r))\nlen1 = len(l)\nlen2 = len(r)\n\nfor i in range(len1+1, len2):\n if i-2 <= 0:\n c += 9\n else:\n c += 9*(10**(i-2))\n\nif l[0] == l[-1]:\n e = len1-2\n if e <= 0:\n e = 0\n c += (9-l[0])*(10**e)\n for i in range(1, len1-1):\n if i == len1-2:\n c += 9-l[i]\n else:\n c += (9-l[i])*(10**(len(l[i+1:]-1)))\n c += 1\nelse:\n e = len1 - 2\n if e <= 0:\n e = 0\n if l[0] < l[-1]:\n c += (9-(l[0]+1)+1)*(10**e)\n else:\n c += (9-l[0])*(10**e)\n for i in range(1, len1-1):\n if i == len1-2:\n c += 9-l[i]\n else:\n c += (9-l[i])*(10**(len(l[i+1:]-1)))\n c += 1\n\nif r[0] == r[-1]:\n e = len2-2\n if e <= 0:\n e = 0\n c += (r[0]-1)*(10**e)\n for i in range(1, len2-1):\n if i == len2-2:\n c += r[i]\n else:\n c += r[i]*(10**(len(r[i+1:])-1))\n c += 1\nelse:\n e = len2 - 2\n if e <= 0:\n e = 0\n if r[0] < r[-1]:\n c += (r[0]-1)*(10**e)\n for i in range(1, len2-1):\n if i == len2-2:\n c += r[i]\n else:\n c += r[i]*(10**(len(r[i+1:])-1))\n c += 1\n\n else:\n c += (r[0]-1)*(10**e)\nprint c\n\n"}, {"source_code": "l, r = map(int, input().split())\nans, t = 0, dict({l - 1: 0, r: 0})\n\nif l == r:\n exit(print(1))\nfor num in [l - 1, r]:\n le = 1\n while True:\n if len(str(num)) > le:\n if le < 3:\n t[num] += 9\n else:\n t[num] += (10 ** (le - 2)) * 9\n else:\n if le == 1:\n t[num] += num\n elif le == 2:\n t[num] += int(str(num)[0]) if str(num)[1] >= str(num)[0] else int(str(num)[0]) - 1\n else:\n t[num] += int(str(num)[1:-1]) if int(str(num)[-1]) < int(str(num)[0]) else int(str(num)[1:-1]) + 1\n t[num] += (9 * int('1' * (le - 2))) * (int(str(num)[0]) - 1)\n break\n\n le += 1\n\n# print(t)\nprint(t[r] - t[l - 1])\n"}, {"source_code": "l, r = map(int, input().split())\nans, t = 0, dict({l - 1: 0, r: 0})\n\nif l == r:\n exit(print(1))\nfor num in [l - 1, r]:\n le = 1\n while True:\n if len(str(num)) > le:\n if le < 3:\n t[num] += 9\n else:\n t[num] += (10 ** (le - 2)) * 9\n else:\n if le == 1:\n t[num] += num\n elif le == 2:\n t[num] += int(str(num)[0]) if str(num)[1] >= str(num)[0] else int(str(num)[0]) - 1\n else:\n t[num] += int(str(num)[1:-1]) if int(str(num)[-1]) < int(str(num)[0]) else int(str(num)[1:-1]) + 1\n t[num] += (int(str(num)[0]) - 1) * (10 ** (le - 2))\n break\n\n le += 1\n\n# print(t)\nprint(t[r] - t[l - 1])\n"}, {"source_code": "l, r = map(int, input().split())\nans, t = 0, dict({l - 1: 0, r: 0})\n\nif l == r:\n exit(print(1))\nfor num in [l - 1, r]:\n le = 1\n while True:\n if len(str(num)) > le:\n if le < 3:\n t[num] += 9\n else:\n t[num] += (le - 2) * 10 * 9\n else:\n if le == 1:\n t[num] += num\n elif le == 2:\n t[num] += int(str(num)[0]) if str(num)[1] >= str(num)[0] else int(str(num)[0]) - 1\n else:\n t[num] += int(str(num)[1:-1]) if int(str(num)[-1]) < int(str(num)[0]) else int(str(num)[1:-1]) + 1\n t[num] += (9 * int('1' * (le - 2))) * (int(str(num)[0]) - 1)\n break\n\n le += 1\n\n# print(t)\nprint(t[r] - t[l - 1])\n"}], "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd"} {"nl": {"description": "JATC's math teacher always gives the class some interesting math problems so that they don't get bored. Today the problem is as follows. Given an integer $$$n$$$, you can perform the following operations zero or more times: mul $$$x$$$: multiplies $$$n$$$ by $$$x$$$ (where $$$x$$$ is an arbitrary positive integer). sqrt: replaces $$$n$$$ with $$$\\sqrt{n}$$$ (to apply this operation, $$$\\sqrt{n}$$$ must be an integer). You can perform these operations as many times as you like. What is the minimum value of $$$n$$$, that can be achieved and what is the minimum number of operations, to achieve that minimum value?Apparently, no one in the class knows the answer to this problem, maybe you can help them?", "input_spec": "The only line of the input contains a single integer $$$n$$$ ($$$1 \\le n \\le 10^6$$$)\u00a0\u2014 the initial number.", "output_spec": "Print two integers: the minimum integer $$$n$$$ that can be achieved using the described operations and the minimum number of operations required.", "sample_inputs": ["20", "5184"], "sample_outputs": ["10 2", "6 4"], "notes": "NoteIn the first example, you can apply the operation mul $$$5$$$ to get $$$100$$$ and then sqrt to get $$$10$$$.In the second example, you can first apply sqrt to get $$$72$$$, then mul $$$18$$$ to get $$$1296$$$ and finally two more sqrt and you get $$$6$$$.Note, that even if the initial value of $$$n$$$ is less or equal $$$10^6$$$, it can still become greater than $$$10^6$$$ after applying one or more operations."}, "positive_code": [{"source_code": "import math\ndef primeFactorize(n):\n\tdic = {}\n\ti = 2\n\twhile(n>1):\n\t\twhile(n%i==0):\n\t\t\ttry:\n\t\t\t\tdic[i]+=1\n\t\t\texcept:\n\t\t\t\tdic[i] = 1\n\t\t\tn = n//i\n\t\ti += 1\n\treturn dic\n\n\ndef noofoperation(lis):\n\ttemp = max(lis)\n\tz = math.ceil(math.log(temp,2))\n\ty = 2**z\n\tt = False\n\tfor i in lis:\n\t\tif i!=y:\n\t\t\tt=True\n\t\t\tbreak\n\tif t:\n\t\treturn z+1\n\telse:\n\t\treturn z\n\n\nif __name__==\"__main__\":\n\tn = int(input())\n\tif n==1:\n\t\tprint(1,0)\n\t\texit()\n\tcount = 0\n\tdic = primeFactorize(n)\n\tcount = noofoperation(list(dic.values()))\n\tpro = 1\n\tfor i in dic:\n\t\tpro *= i\n\tprint(pro,count)"}, {"source_code": "n = int(input())\n\nif n == 1:\n print(1, 0)\n exit(0)\n\nfactors = {}\nmindegree = float(\"inf\")\nmaxdegree = 0\nanswer = 1\n\nfor x in range(2, int(n ** 0.5) + 1):\n if n == 1: break\n multiplicity = 0\n while n % x == 0:\n n = n // x\n multiplicity += 1\n if multiplicity:\n answer *= x\n #factors[x] = multiplicity\n mindegree = min(mindegree, multiplicity)\n maxdegree = max(maxdegree, multiplicity)\n\nif n != 1:\n #factors[n] = 1\n answer *= n\n mindegree = min(mindegree, 1)\n maxdegree = max(maxdegree, 1)\n\ndeg = 0\nwhile 2 ** deg < maxdegree:\n deg += 1\n\nresult = deg + 1\nif 2 ** deg == maxdegree == mindegree:\n result -= 1\nprint(answer, result)\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\nCopyright 2019 Cheran Senthilkumar \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\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\nfrom functools import reduce\n# from heapq import heappop, heappush\nfrom io import BytesIO, FileIO, StringIO\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 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\nINP_FILE = 0\nOUT_FILE = 1\n\nif sys.version_info[0] < 3:\n sys.stdin = BytesIO(FileIO(INP_FILE).read())\n sys.stdout = BytesIO()\n register(lambda: FileIO(OUT_FILE, 'w').write(sys.stdout.getvalue()))\nelse:\n sys.stdin = StringIO(FileIO(INP_FILE).read().decode())\n sys.stdout = StringIO()\n register(lambda: FileIO(OUT_FILE, 'w').write(sys.stdout.getvalue().encode()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\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 is_prime(n):\n \"\"\"\n Deterministic variant of the Miller-Rabin primality test to determine\n whether a given number (upto 2**64) 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, 13, 19, 73, 193, 407521, 299210837]:\n return True\n\n if (n in [0, 1]) or (any((n % p) == 0 for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837])):\n return False\n\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 return not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022])\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n if is_prime(n):\n return Counter({n: 1})\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, k = y, 0\n\n for _ in range(r):\n y = (y*y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y*y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys*ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\ndef factors(n):\n \"\"\"\n Prime factorization using Pollard's rho algorithm.\n\n Parameters\n ----------\n n : int\n n > 0, an integer to be factorized.\n\n Returns\n -------\n prime_factors : Counter\n Counter of the prime factors of n.\n \"\"\"\n prime_factors = Counter()\n\n def ilog(n, p):\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n return n, cnt\n\n if n % 2 == 0:\n n, prime_factors[2] = ilog(n, 2)\n if n % 3 == 0:\n n, prime_factors[3] = ilog(n, 3)\n\n i = 5\n while i * i <= min(n, 4294967295):\n if n % i == 0:\n n, prime_factors[i] = ilog(n, i)\n i += 2 if i % 3 == 2 else 4\n\n if n == 1:\n return prime_factors\n\n if n <= 4294967295:\n prime_factors[n] = 1\n return prime_factors\n\n return prime_factors + pollard_rho(n)\n\n\ndef main():\n n = int(input())\n\n if n == 1:\n print(1, 0)\n return\n\n f = factors(n)\n p = list(f.values())\n\n a2 = (max(p) - 1).bit_length()\n print(reduce(op.mul, f.keys()), (set(p) != {1 << a2}) + a2)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "'''input\n1\n\n\n\n\n'''\n\n\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nimport sys\n\n\nn=input()\nif n==1:\n\tprint 1,0\nelse:\n\tp=[]\n\tfor i in range(2,int(n**0.5)+1 ):\n\t\twhile n%i==0:\n\t\t\tp.append(i)\n\t\t\tn/=i\n\n\tif n>1:\n\t\t\tp.append(n)\n\tc={}\n\tfor i in p:\n\t\tif i not in c:\n\t\t\tc[i]=0\n\t\tc[i]+=1\n\ta1=max(c.values())\n\tp=set(p)\n\tans=1\n\tfor i in p:\n\t\tans*=i\n\tnn=1\n\tcc=0\n\twhile nn0):\n ans*=ans\n c+=1\nif ans>temp:\n c+=1\nprint(ans2,c)\n"}, {"source_code": "from collections import Counter\nimport functools\nimport operator\nimport sys\n\nn = int(input())\nnum = n\nc = Counter()\n\nif n == 1:\n print(\"1 0\")\n sys.exit()\n\nfor i in range(2, n + 1):\n if i > n:\n break\n\n freq = 0\n while n % i == 0:\n c[i] += 1\n n //= i\n\nmin_product = functools.reduce(operator.mul, c.keys(), 1)\nif min_product == num:\n # number is prime or only has 1 of each factor\n print(\"{} 0\".format(num))\n sys.exit()\n\nmost_common = c.most_common()[0][1]\nall_same = c.most_common()[0][1] == c.most_common()[-1][1]\n\ndef is_pow2(val):\n if val == 1: return True\n if val % 2 == 1: return False\n return is_pow2(val // 2)\n\ndef count2(val):\n if val == 1: return 0\n times = 0\n while val != 1:\n val //= 2\n times += 1\n\n return times\n\nif not is_pow2(most_common):\n num_ops = 2 + count2(most_common)\nelif all_same:\n num_ops = count2(most_common)\nelse:\n num_ops = 1 + count2(most_common)\n\nprint(\"{} {}\".format(min_product, num_ops))"}, {"source_code": "def inint():\n return int(input())\ndef inlist():\n return list(map(int,input().split()))\ndef pf(a):\n factor=[]\n i=2\n while i*i<=a:\n ch=0\n while a%i==0:\n ch+=1\n a//=i\n if ch!=0:factor.append([i,ch])\n i+=1\n if a>1:\n factor.append([a,1])\n return factor\ndef main():\n n=inint()\n f=pf(n)\n sol=1\n mxp=0\n for i,j in f:\n mxp=max(mxp,j)\n from math import log,ceil\n ans=0\n if mxp>0:ans=ceil(log(mxp,2))\n# print(ans,mxp,f)\n for i,j in f:\n if j<2**ans:ans+=1;break\n for i,j in f:\n sol*=i\n print(sol,ans)\n\n\nif __name__ == \"__main__\":\n #import profile\n #profile.run(\"main()\")\n main()"}, {"source_code": "from math import sqrt\nn=int(input())\ns=0\nf=0\nwhile int(sqrt(n))==sqrt(n) and n>1:\n n=int(sqrt(n))\n s+=1\nfor i in range(int(sqrt(n)),1,-1):\n \n while n%(i*i)==0:\n s+=1\n n//=i\n f=1\nprint(n,s+f)\n "}, {"source_code": "from math import *\ndef primeFactors(n,dict1): \n \n # Print the number of two's that divide n \n while n % 2 == 0: \n try:\n dict1[2]+=1\n except:\n KeyError\n dict1[2]=1 \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,floor(sqrt(n))+1,2): \n \n # while i divides n , print i ad divide n \n while n % i== 0: \n try:\n dict1[i]+=1\n except:\n KeyError\n dict1[i]=1\n\n n = n//i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2:\n try:\n dict1[n]+=1\n except:\n KeyError\n dict1[n]=1\n \n# Driver Program to test above function \n \nn = int(input())\nif(n==1):\n print(1,0)\nelse:\n dict1={}\n primeFactors(n,dict1)\n #print(dict1)\n ans=1\n arr=[]\n for i in dict1.keys():\n ans=ans*i\n arr.append(dict1[i])\n if(len(arr)==arr.count(arr[0])):\n if(ceil(log2(arr[0]))==floor(log2(arr[0]))):\n print(ans,floor(log2(arr[0])))\n else:\n print(ans,1+ceil(log2(arr[0])))\n else:\n maxval=max(arr)\n print(ans,1+ceil(log2(maxval)))\n"}, {"source_code": "import math\nmul2 = [2**x for x in range(1,7)]\nn = int(input())\nncopy = n\nfacto = [0]*1000001\nans = 1\ncnt = 0\n\nfor i in range(2,math.ceil(n/2)+1):\n if n % i == 0:\n while n % i == 0:\n facto[i] += 1\n n //= i\n ans *= i\n cnt += 1\nm = max(facto)\n\nif m == 0:\n print(n,0)\nelif ncopy ** .5 == ans:\n print(ans,1)\nelif m == 1:\n print(ans,0)\nelse:\n mi = 64\n lim = 0\n for each in mul2:\n if each-m >= 0 and each-m <= mi:\n mi = abs(m - each)\n lim = each\n times = int(math.log(lim,2)) if (cnt==1 and lim == m) else int(math.log(lim,2))+1\n print(ans,times)\n\n"}, {"source_code": "from collections import Counter\nimport functools\nimport operator\nimport sys\n\nn = int(input())\nnum = n\nc = Counter()\n\nif n == 1:\n print(\"1 0\")\n sys.exit()\n\nfor i in range(2, n + 1):\n if i > n:\n break\n\n freq = 0\n while n % i == 0:\n c[i] += 1\n n //= i\n\nmin_product = functools.reduce(operator.mul, c.keys(), 1)\nif min_product == num:\n # number is prime or only has 1 of each factor\n print(\"{} 0\".format(num))\n sys.exit()\n\nmost_common = c.most_common()[0][1]\nall_same = c.most_common()[0][1] == c.most_common()[-1][1]\n\ndef is_pow2(val):\n if val == 1: return True\n if val % 2 == 1: return False\n return is_pow2(val // 2)\n\ndef count2(val):\n if val == 1: return 0\n times = 0\n while val != 1:\n val //= 2\n times += 1\n\n return times\n\nif not is_pow2(most_common):\n num_ops = 2 + count2(most_common)\nelif all_same:\n num_ops = count2(most_common)\nelse:\n num_ops = 1 + count2(most_common)\n\nprint(\"{} {}\".format(min_product, num_ops))"}, {"source_code": "import math\n\n\nn = int(input())\nyin = []\nans1 = 1\nfor i in range(2, n):\n if n % i == 0:\n num = 0\n while n % i == 0:\n num += 1\n n /= i\n s = [num, i]\n yin.append(s)\n ans1 = ans1 * i\nif ans1 == 1:\n print(n, 0)\nelse:\n yin.sort(reverse=True)\n maxy = yin[0][0]\n miny = yin[-1][0]\n ans2 = 0\n x = 1\n while maxy > x:\n x = x * 2\n ans2 += 1\n if x == maxy and maxy == miny:\n ans2 += 0\n else:\n ans2 += 1\n print(ans1, ans2)\n\n\n\n\n\n\n\n\n"}, {"source_code": "from __future__ import division\nfrom collections import deque, defaultdict, Counter\nfrom math import *\n\n\ndef count_prime(n):\n for i in range(2, n):\n if not prim[i]:\n for j in range(i, n, i):\n prim[j] = i\n\n for i in range(1, n):\n if not prim[i]:\n prim[i] = i\n\n\ndef prime_factor(x):\n fac = []\n while x > 1:\n div = prim[x]\n fac.append(div)\n x //= div\n return fac\n\n\nispow2 = lambda x: x and (not (x & (x - 1)))\nn, ans, N = int(input()), [1, 0], 10 ** 6 + 1\nif n == 1:\n print('1 0')\n exit()\n\nprim = [0] * (N)\ncount_prime(N)\nmem = Counter(prime_factor(n))\nma = max(mem.values())\n\nfor i, j in mem.items():\n ans[0] *= i\n if j != ma:\n ans[1] = 1\n\nif not ispow2(ma):\n ans[1] = 1\n\nans[1] += int(ceil((log(ma, 2))))\nprint(' '.join(map(str, ans)))\n"}, {"source_code": "import math\nfrom collections import defaultdict\nimport functools\n\nprimes = [2]\nN = 1001\n\ndef generate_primes():\n for i in range(2, N):\n isPrime = True\n sqr = math.ceil(math.sqrt(i))\n for p in primes:\n if i % p == 0:\n isPrime = False\n break\n if p > sqr:\n break \n if isPrime:\n primes.append(i)\n\ndef find_factors(n):\n prime_counter = 0\n prime_dict = defaultdict(int)\n while n > 1 and prime_counter < len(primes):\n while n > 1 and n % primes[prime_counter] == 0:\n n = n // primes[prime_counter]\n prime_dict[primes[prime_counter]] += 1\n prime_counter += 1\n if n > 1:\n prime_dict[n] += 1\n return prime_dict\n\ndef get_num_steps(arr):\n def find_power(mx):\n two_power = 1\n i = 0\n while two_power < mx:\n two_power *= 2\n i += 1\n return i, two_power == mx\n \n mx = arr[0]\n all_equal = True\n for i in range(1, len(arr)):\n mx = max(mx, arr[i])\n if arr[i] != arr[i-1]:\n all_equal = False\n pw, pw_equal = find_power(mx)\n if all_equal and pw_equal: #all equal\n return pw\n return pw+1\n \n\ndef solution(n):\n generate_primes()\n prime_dict = find_factors(n)\n max_power = get_num_steps(list(prime_dict.values()))\n return functools.reduce(lambda x, y:x*y, prime_dict.keys(), 1), max_power\n\nn = int(input())\nif n == 1:\n print(1, 0)\nelse:\n print(*solution(n))\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# Python3 program to find prime factorization\n# of a number n in O(Log n) time with\n# precomputation allowed.\nimport math as mt\n\nMAXN = 1000001\n\n# stores smallest prime factor for\n# every number\nspf = [0 for i in range(MAXN)]\n\n# Calculating SPF (Smallest Prime Factor)\n# for every number till MAXN.\n# Time Complexity : O(nloglogn)\ndef sieve():\n spf[1] = 1\n for i in range(2, MAXN):\n\n # marking smallest prime factor\n # for every number to be itself.\n spf[i] = i\n\n # separately marking spf for\n # every even number as 2\n for i in range(4, MAXN, 2):\n spf[i] = 2\n\n for i in range(3, mt.ceil(mt.sqrt(MAXN))):\n\n # checking if i is prime\n if (spf[i] == i):\n\n # marking SPF for all numbers\n # divisible by i\n for j in range(i * i, MAXN, i):\n\n # marking spf[j] if it is\n # not previously marked\n if (spf[j] == j):\n spf[j] = i\n\n # A O(log n) function returning prime\n# factorization by dividing by smallest\n# prime factor at every step\ndef getFactorization(x):\n ret = list()\n while (x != 1):\n ret.append(spf[x])\n\n x = x // spf[x]\n\n\n\n return ret\n\n\nn = int(input())\n\n\nsieve()\nz = getFactorization(n)\nhash = defaultdict(int)\n\nfor i in z:\n hash[i]+=1\nans = 1\nmaxi = 0\nflag = 0\nseti = set()\nfor i in hash:\n ans*=i\n maxi = max(maxi,ceil(log2(hash[i])))\n\n\nfor i in hash:\n if (log2(hash[i]))!=maxi:\n flag+=1\n break\n\n\n\n\n\n\n\nprint(ans,maxi+flag)\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nans = 1\ncnt = 0\nk = n\nfor i in range(2, n + 1):\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n //= i\n\nrec = ans\nwhile rec % k > 0:\n rec *= rec\n cnt += 1\nif rec > k:\n cnt += 1\nprint(ans, cnt)"}, {"source_code": "from 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\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 test:\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\ntest = False\n \n\ndef main():\n n = get_int()\n factors = primeFactors(n)\n if n==1:\n print(1,0)\n return\n ma = max(factors.values())\n times = math.ceil(math.log2(ma))\n r =1\n for i in factors.keys():\n r=r*i\n vals = list(factors.values())\n a = vals[0]\n for i in vals:\n if i!=a or math.log2(i)%1!=0:\n times+=1\n break\n print(r,times)\n \n\n\n \n\n\n\n# --------------------------------------------------------------------------------------------- END\n\n\nif TestCases: \n for _ in range(get_int()): \n cProfile.run('main()') if test else main()\nelse: cProfile.run('main()') if test else main()"}, {"source_code": "\ndef factorize(n):\n fct = [] # prime factor\n b, e = 2, 0 # base, exponent\n while b * b <= n:\n while n % b == 0:\n n = n // b\n e = e + 1\n if e > 0:\n fct.append((b, e))\n b, e = b + 1, 0\n if n > 1:\n fct.append((n, 1))\n return fct\n\n\ndef main():\n n = int(input())\n l = factorize(n)\n anscnt = 0\n\n ma = 0\n for i in range(len(l)):\n ma = max(ma, l[i][1])\n c = 0\n a = 1\n while True:\n if a >= ma:\n break\n a *= 2\n c += 1\n\n v = 1\n for i in range(len(l)):\n for j in range(a - l[i][1]):\n v *= l[i][0]\n anscnt = 1\n n *= v\n for i in range(c):\n n = n**(1/2)\n anscnt += 1\n print(int(n), anscnt, sep=\" \")\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from math import log2, sqrt\n\ndef main():\n n = int(input())\n d = {}\n cur = n\n for i in range(2, int(sqrt(n)) + 2):\n while cur % i == 0:\n t = d.get(i, 0) + 1\n d[i] = t\n cur //= i\n if cur != 1:\n d[cur] = 1\n if d == {} or max(d.values()) == 1:\n return print(n, 0)\n cur = []\n action = False\n for k in d:\n q = log2(d[k])\n if q - int(q) != 0 or q == 0:\n if not action:\n action = True\n cur.append(int(q) + 1)\n else:\n cur.append(int(q))\n ans_2 = max(cur)\n if action or len(set(cur)) != 1:\n ans_2 += 1\n ans_1 = 1\n for k in d:\n ans_1 *= k\n return print(ans_1, ans_2)\n \nif __name__==\"__main__\":\n main()"}, {"source_code": "__author__ = 'tanunia'\n\nfrom sys import stdin\nimport math\n\nn = int(stdin.readline())\nnums = {}\n\nend = int(math.sqrt(n))\ntotal_n = n\nfor i in range(2, end+1):\n while total_n % i == 0:\n if i not in nums:\n nums[i] = 0\n nums[i] += 1\n total_n /= i\nif total_n > 1:\n nums[total_n] = 1\n\nmax_pow = 0\nans1 = 1\nfor k in nums.keys():\n ans1 *= k\n if nums[k] > max_pow:\n max_pow = nums[k]\n\npow2 = 1\ncnt = 0\nwhile pow2 < max_pow:\n pow2 *= 2\n cnt += 1\n\nans2 = cnt\nfor k in nums.keys():\n if nums[k] < pow2:\n ans2 += 1\n break\nprint(str(int(ans1)) + \" \" + str(ans2))\n"}, {"source_code": "#!/usr/bin/env python3\nimport math\n\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\ndef get_primes(n: int) -> List[int]:\n #max_n = int(n**0.5)\n max_n = n\n rng = list(range(max_n+1))\n rng[0] = 1\n rng[1] = 1\n primes = []\n for i in range(2, max_n+1):\n if rng[i] > 1:\n primes.append(i)\n for j in range(i + i, max_n+1, i):\n rng[j] = 0\n\n return primes\n\n\ndef main():\n n, = (int(x) for x in input().split())\n if n == 1:\n print('1 0')\n return\n\n primes = get_primes(n)\n #print(len(primes))\n factors = [0]*len(primes)\n # n_sum = 0\n for prime_id in range(len(primes)):\n prime = primes[prime_id]\n i = 1\n #print(n, prime, i, prime ** i, n % (prime ** i))\n while n % (prime ** i) == 0:\n i+=1\n\n factors[prime_id] = i - 1\n\n #print(factors)\n max_factor = max(factors)\n need_to_mul = False\n min_number = 1\n for i, factor in enumerate(factors):\n if not (factor == 0 or factor == max_factor):\n need_to_mul = True\n if factor > 0:\n min_number*=primes[i]\n\n #print(max_factor)\n squares_count_float = math.log(max_factor, 2)\n squares_count = math.ceil(squares_count_float)\n if squares_count != math.floor(squares_count_float):\n need_to_mul = True\n\n if need_to_mul:\n squares_count += 1\n\n print('{} {}'.format(min_number, squares_count))\n\n\n\n\n\n\n\n\n\n\n #a = input_lst()\n\n\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from math import *\ndef fct(n):\n\n res = []\n sqfree = 1\n for p in range(2, int(sqrt(n) + 10)):\n cnt = 0\n while n % p == 0:\n cnt += 1\n n //= p\n if cnt > 0:\n res.append(cnt)\n sqfree *= p\n\n if n != 1:\n res.append(1)\n sqfree *= n\n return res, sqfree\n\ndef solve(n):\n if n == 1: return (1, 0)\n fctr, sqfree = fct(n)\n # print(\"fctr = \", fctr)\n mx = max(fctr)\n # print(\"mx = \", mx)\n next_pow2 = 2**ceil(log(mx)/log(2))\n\n # print(\"next_pow2 = \", next_pow2)\n times = 0\n if (any(x != next_pow2 for x in fctr)):\n times += 1\n\n while next_pow2 != 1:\n next_pow2 //= 2\n times += 1\n\n return sqfree, times\n\nprint(*solve(int(input())))\n"}, {"source_code": "# \nimport collections, atexit, math, sys, bisect \n\nsys.setrecursionlimit(1000000)\ndef getIntList():\n return list(map(int, input().split())) \n\ntry :\n #raise ModuleNotFoundError\n import numpy\n def dprint(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n # in python 3.4 **kwargs is invalid???\n print(*args, file=sys.stderr)\n dprint('debug mode')\nexcept Exception:\n def dprint(*args, **kwargs):\n pass\n\n\n\ninId = 0\noutId = 0\nif inId>0:\n dprint('use input', inId)\n sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\nif outId>0:\n dprint('use output', outId)\n sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\n atexit.register(lambda :sys.stdout.close()) #idle \u4e2d\u4e0d\u4f1a\u6267\u884c atexit\n \nN, = getIntList()\n#print(N)\nre = 1\nmc = 1\nzc = []\nfor i in range(2, 10000):\n if N%i != 0 : continue\n re *= i\n c = 0\n while N%i==0:\n N//=i\n c+=1\n \n zc.append(c)\nif N>1:\n re*=N\n zc.append(1)\nif zc:\n mc = max(zc)\nt =1 \nfor i in range(100):\n if mc<=t:\n break\n t*=2\ndprint(t)\ndprint(zc)\ng = i\nfor x in zc:\n if x 1:\n nums[total_n] = 1\n\nmax_pow = 0\nans1 = 1\nfor k in nums.keys():\n ans1 *= k\n if nums[k] > max_pow:\n max_pow = nums[k]\n\npow2 = 1\ncnt = 0\nwhile pow2 < max_pow:\n pow2 *= 2\n cnt += 1\n\nans2 = cnt\nfor k in nums.keys():\n if nums[k] < pow2:\n ans2 += 1\n break\nprint(str(int(ans1)) + \" \" + str(ans2))\n"}, {"source_code": "n = int(input())\n\nif n == 1:\n\tprint('1 0')\nelse:\n\td = 2\n\tdecomp = []\n\twhile d * d <= n:\n\t\tcnt = 0\n\t\twhile n % d == 0:\n\t\t\tcnt += 1\n\t\t\tn //= d\n\t\tif cnt > 0:\n\t\t\tdecomp += [(d, cnt)]\n\t\tif d == 2:\n\t\t\td += 1\n\t\telse:\n\t\t\td += 2\n\tif n > 1:\n\t\tdecomp += [(n, 1)]\n\n\ttar = 1\n\tmaxExp = 0\n\tfor e in decomp:\n\t\ttar *= e[0]\n\t\tmaxExp = max(maxExp, e[1])\n\t\n\tdivCnt = 0\n\tcurExp = 1\n\twhile curExp < maxExp:\n\t\tdivCnt += 1\n\t\tcurExp *= 2\n\n\tmulRequired = False\n\tfor e in decomp:\n\t\tif e[1] != curExp:\n\t\t\tmulRequired = True\n\t\t\tbreak\n\tif mulRequired:\n\t\tdivCnt += 1\n\n\tprint('%s %s' % (tar, divCnt))\n\n"}, {"source_code": "import sys \nn=int(input())\nk=n\ns=dict()\nif n==1:\n print(1,0)\n sys.exit()\nfor p in range(2,int(n**0.5)+1):\n while(n%p==0):\n if p not in s:\n s.update({p:1})\n else:\n s[p]+=1\n n//=p\nif n>1:\n s.update({n:1})\nsm=1\nfor j in s:\n sm*=j\nm=max(s.values())\np=1\ne=0\n#print(m)\nwhile(p0:\n\t\tnum*=k\t\t\n\t\tm1=max(m1,count)\n\t\tm2=min(m2,count)\n\tk+=1\nif x>1:\n\tnum*=x\n\tm2=1\n\ns=bin(m1)[2:]\na= 1 if s.count('1')==1 else -1\nb=0\nif a==1 and m1!=m2:\n\tb=1\nc=len(s)\nm=c-a+b\nif n==1:\n\tm=0\nprint(num,m)\n\n"}, {"source_code": "#In the name of GOD!\nm = n = int(input())\nans = 1\nnum = 0\nfor i in range(2, m + 1):\n\tif n % i == 0:\n\t\tans *= i\n\t\twhile n % i == 0:\n\t\t\tn //= i\nhlp = ans\nwhile hlp % m > 0:\n\thlp *= hlp\n\tnum += 1\nif hlp > m:\n\tnum += 1\nprint(ans, num)\n"}, {"source_code": "from math import sqrt\nn=int(input())\ns=0\nf=0\nwhile int(sqrt(n))==sqrt(n) and n>1:\n n=int(sqrt(n))\n s+=1\nfor i in range(int(sqrt(n)),1,-1):\n \n while n%(i*i)==0:\n s+=1\n n//=i\n f=1\nprint(n,s+f)\n "}, {"source_code": "import math \n \n# A function to print all prime factors of \n# a given number n \ndef pr(n): \n a=[]\n # Print the number of two's that divide n \n while n % 2 == 0: \n a.append(2)\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 a.append(int(i)) \n n = n / i \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n a.append(int(n)) \n return list(a)\n\nfrom collections import defaultdict\n\na=int(input())\nif a==1:\n print(1,0)\nelse:\n b=pr(a)\n c=defaultdict(int)\n for i in range(len(b)):\n c[b[i]]+=1\n d=[]\n for i in c:\n d.append([c[i],i])\n d=max(d)[0]\n e=0\n while 1>0:\n if (2**e)>=d:\n break\n else:\n e+=1\n f=0\n for i in c:\n if c[i]!=2**e:\n f=1\n c=1\n d=list(set(b))\n for i in range(len(d)):\n c=c*d[i]\n print(c,f+e)"}, {"source_code": "\nfrom fractions import gcd\nfrom operator import __mul__\n\ndef factor(n):\n res = []\n p = 2\n while p * p <= n:\n if n % p == 0:\n a = 0\n while n % p == 0:\n a += 1\n n /= p\n\n res.append((p, a))\n\n p += 1\n\n if n > 1:\n res.append((n, 1))\n\n return dict(res)\n\nn = int(raw_input())\n\nimport sys\nif n == 1:\n print \"1 0\"\n sys.exit()\n\nF = factor(n)\nm = max(F.values())\np2 = 1\nlp2 = 0\nwhile p2 < m:\n p2 = p2 * 2\n lp2 += 1\n\nmoves = lp2 + (1 if any(e < p2 for e in F.values()) else 0)\n\nprint reduce(__mul__, F.keys(), 1), moves\n"}, {"source_code": "# use this as the main template for python problems\nfrom collections import Counter\nimport math\n\ndef primeFactors(n): \n \n # Print the number of two's that divide n \n while n % 2 == 0: \n yield 2\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 yield i\n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n yield n\n\ndef get_prime_factorization(n):\n if(n == 1):\n return {1 : 1}\n primes = {}\n for prime in primeFactors(n):\n prime = int(prime)\n if(prime in primes):\n primes[prime] += 1\n else:\n primes[prime] = 1\n return primes\n\ndef next_power_of_2(n):\n return int(math.pow(2, math.ceil(math.log(n)/math.log(2))))\n\ndef solution(n):\n\n pf = get_prime_factorization(n)\n \n lp = 0 \n for key, val in pf.items():\n lp = max(lp, val)\n \n # lp is the largest power in the prime factorization\n # we need the nearest power of two\n np2 = next_power_of_2(lp)\n ans = 1\n for key, val in pf.items():\n ans *= key\n \n moves = 0\n for key, val in pf.items():\n if(val != np2):\n moves = 1\n break\n moves += int(math.log2(np2))\n\n print(ans, moves)\n\n\n\nif __name__ == \"__main__\":\n\n # single variables\n n = [int(val) for val in input().split()][0]\n\n # solve it!\n solution(n)\n\n"}, {"source_code": "import math\nimport sys\nx=int(input())\n\nif x==1:\n print(1,0)\n sys.exit()\n\nTWO=[2**i for i in range(30)]\n\nxr=math.ceil(math.sqrt(x))\n\nLIST=[]\nfor i in range(2,xr+2):\n if x%i==0:\n while x%i==0:\n LIST.append(i)\n x=x//i\n else:\n i+=1\nif x!=1:\n LIST.append(x)\n\nfrom collections import Counter\ncounter=Counter(LIST)\n\nANS=1\nfor l in counter.keys():\n ANS*=l\n\ncount=max(counter.values())\n\nfor i in range(30):\n if count<=TWO[i]:\n break\n\nif max(counter.values())==min(counter.values()) and TWO[i]==max(counter.values()):\n ANS2=i\nelse:\n ANS2=i+1\n\nprint(ANS,ANS2)\n"}, {"source_code": "import collections\nimport math\nimport sys\ndef isPowerOfTwo (x): \n return (x and (not(x & (x - 1))))\ndef primefactors(n):\n\td = collections.defaultdict(int) \n\twhile n%2 == 0:\n\t\td[2]+=1\n\t\tn/=2\n\tfor i in range(3, int(n**0.5)+1, 2):\n\t\twhile n%i==0:\n\t\t\td[i]+=1\n\t\t\tn/=i\n\tif n > 2:\n\t\td[n]+=1\n\treturn d\nn = int(input())\nif n == 1:\n\tprint(1, 0)\n\tsys.exit()\nx = primefactors(n)\ny = max(x.values())\nz = x.keys()\nk = 1\nfor i in z:\n\tk*=i\nif y == 1:\n\tprint(int(k), 0)\nelif isPowerOfTwo(y):\n\tif len(set(x.values())) == 1:\n\t\tprint(int(k), int(math.log2(y)))\n\telse:\n\t\tprint(int(k), int(math.log2(y)+1))\nelse:\n\tprint(int(k), math.ceil(math.log2(y))+1)"}, {"source_code": "import math \nfrom collections import Counter \n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n): \n l=[]\n # Print the number of two's that divide n \n while n % 2 == 0: \n #print 2, \n l.append(2)\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 #print i, \n l.append(i)\n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n l.append(n)\n return l\n\n\nn=input()\nif n==1:\n print 1,0\n exit()\nl=primeFactors(n)\nd=Counter(l)\nans1=1\nfor i in d.keys():\n ans1*=i\nmx=max(d.values())\nans=1\nstep=0\nwhile ans 0:\n\t\tfact[d] = c\n\t\n\td = 3\n\twhile n != 1:\n\t\tc = 0\n\t\twhile n % d == 0:\n\t\t\tc += 1\n\t\t\tn //= d\n\t\tif c > 0:\n\t\t\tfact[d] = c\n\t\td += 2\n\n\tans = reduce(lambda x,y: x*y, fact.keys())\n\tmaxPow = max(fact.values())\n\n\tx = 0\n\twhile maxPow > (1 << x):\n\t\tx += 1\n\n\tif maxPow == (1 << x) and all([y == maxPow for y in fact.values()]):\n\t\tprint(ans, x)\n\t\treturn\n\telse:\n\t\tprint(ans, x + 1)\n\t\treturn\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "import math\nfrom collections import defaultdict\nimport functools\n\nprimes = [2]\nN = 1001\n\ndef generate_primes():\n for i in range(2, N):\n isPrime = True\n sqr = math.ceil(math.sqrt(i))\n for p in primes:\n if i % p == 0:\n isPrime = False\n break\n if p > sqr:\n break \n if isPrime:\n primes.append(i)\n\ndef find_factors(n):\n prime_counter = 0\n prime_dict = defaultdict(int)\n while n > 1 and prime_counter < len(primes):\n while n > 1 and n % primes[prime_counter] == 0:\n n = n // primes[prime_counter]\n prime_dict[primes[prime_counter]] += 1\n prime_counter += 1\n if n > 1:\n prime_dict[n] += 1\n return prime_dict\n\ndef get_num_steps(arr):\n def find_power(mx):\n two_power = 1\n i = 0\n while two_power < mx:\n two_power *= 2\n i += 1\n return i, two_power == mx\n \n mx = arr[0]\n all_equal = True\n for i in range(1, len(arr)):\n mx = max(mx, arr[i])\n if arr[i] != arr[i-1]:\n all_equal = False\n pw, pw_equal = find_power(mx)\n if all_equal and pw_equal: #all equal\n return pw\n return pw+1\n \n\ndef solution(n):\n generate_primes()\n prime_dict = find_factors(n)\n max_power = get_num_steps(list(prime_dict.values()))\n return functools.reduce(lambda x, y:x*y, prime_dict.keys(), 1), max_power\n\nn = int(input())\nif n == 1:\n print(1, 0)\nelse:\n print(*solution(n))\n"}, {"source_code": "n = int(input())\nif n == 1: print(1, 0); exit()\nlis1 = []\nlis2 = []\nx = int(n**0.5)\nfor i in range(2, x+1):\n if n%i == 0:\n cnt = 0\n while(n%i == 0):\n cnt += 1\n n//=i\n lis1.append(i)\n lis2.append(cnt)\nif n-1: lis1.append(n); lis2.append(1)\nsu = 1\nfor i in lis1:\n su *= i\nm = max(lis2)\nimport math\nk = int(math.log(m, 2))\nif 2**k == m: \n if m == min(lis2): m = k\n else: m = k + 1\nelse: m = k + 2\nprint(su, m)\n"}, {"source_code": "#!/usr/bin/env python3\nimport math\n\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\ndef get_primes(n: int) -> List[int]:\n #max_n = int(n**0.5)\n max_n = n\n rng = list(range(max_n+1))\n rng[0] = 1\n rng[1] = 1\n primes = []\n for i in range(2, max_n+1):\n if rng[i] > 1:\n primes.append(i)\n for j in range(i + i, max_n+1, i):\n rng[j] = 0\n\n return primes\n\n\ndef main():\n n, = (int(x) for x in input().split())\n if n == 1:\n print('1 0')\n return\n\n primes = get_primes(n)\n #print(len(primes))\n factors = [0]*len(primes)\n # n_sum = 0\n for prime_id in range(len(primes)):\n prime = primes[prime_id]\n i = 1\n #print(n, prime, i, prime ** i, n % (prime ** i))\n while n % (prime ** i) == 0:\n i+=1\n\n factors[prime_id] = i - 1\n\n #print(factors)\n max_factor = max(factors)\n need_to_mul = False\n min_number = 1\n for i, factor in enumerate(factors):\n if not (factor == 0 or factor == max_factor):\n need_to_mul = True\n if factor > 0:\n min_number*=primes[i]\n\n #print(max_factor)\n squares_count_float = math.log(max_factor, 2)\n squares_count = math.ceil(squares_count_float)\n if squares_count != math.floor(squares_count_float):\n need_to_mul = True\n\n if need_to_mul:\n squares_count += 1\n\n print('{} {}'.format(min_number, squares_count))\n\n\n\n\n\n\n\n\n\n\n #a = input_lst()\n\n\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "m = 10**6+5\ncri = [0]*m\nfor i in range(2, m):\n\tif cri[i] == 0:\n\t\tcri[i] = i\n\t\tfor j in range(i*i, m, i):\n\t\t\tcri[j] = i\ncri[1] = 1\nn = int(input())\na = n\nres = []\npp = 1\nwhile a > 1:\n\tb = cri[a]\n\tpp *= b\n\tc = 0\n\twhile a % b == 0 and a > 1:\n\t\ta //= b\n\t\tc += 1\n\tres.append(c)\nif not res:\n\tres.append(1)\nmaxres = max(res)\nminres = min(res)\naa = 1\nne = 0\nwhile aa < maxres:\n\taa*=2\n\tne += 1\nne += 1 if minres < aa else 0\nprint(pp, ne)\n\n"}, {"source_code": "#encoding:utf-8\n\nclass Rookie(object):\n\n def _input(self):\n l1 = raw_input()\n n = int(l1.strip())\n return n\n\n def _output(self):\n pass\n\n def solve(self):\n n = self._input()\n count = {}\n maxx = 1\n ans = 1\n ne = 0\n first = True\n for i in range(2,n+1):\n cnt = 0\n while n % i == 0:\n cnt += 1\n n /= i\n if cnt > 0:\n #print i,cnt\n if not first and maxx != cnt:\n ne = 1\n ans *= i\n maxx = max(cnt,maxx)\n first = False\n ops = 0\n if maxx == 1:\n print ans,0\n else:\n tmp = 1\n while tmp < maxx:\n tmp *= 2\n ops += 1\n #print tmp,maxx\n #print ops\n #print ne\n if maxx == tmp:\n if ne == 1:\n ops += 1\n elif maxx < tmp:\n ops += 1\n print ans,ops\n #self._output()\nif __name__ == '__main__':\n Rookie().solve()"}, {"source_code": "n = int(input())\nm = n\nd = 2\nA = []\nif n != 1:\n while d * d <= n:\n if n % d == 0:\n A.append(d)\n n //= d\n else:\n d += 1\n \n if n > 1:\n A.append(n)\n \n D = dict()\n p = 1\n for i in range(len(A)):\n if A[i] not in D.keys():\n D[A[i]] = 1\n p *= A[i]\n else:\n D[A[i]] += 1\n s_max = max(D.values())\n k = 1\n for i in range(50):\n if k >= s_max:\n break\n k *= 2\n \n for q in D.values():\n if q != k:\n i += 1\n break\n\nelse:\n p = 1\n i = 0\n\nif p == m:\n i = 0\n\nprint(p, i)\n \n"}, {"source_code": "import math\nn=input()\nif n==1:\n\tprint 1, 0\nelse:\n\tflag=1\n\tk=n\n\tt=0\n\twhile flag:\n\t\tc=int(math.sqrt(k))\n\t\tif c*c==k:\n\t\t\tk=c\n\t\t\tt+=1\n\t\telse:\n\t\t\tflag=0\n\tres=[]\n\tvals=[]\n\tfor j in range(2,k+1):\n\t\tc=0\n\t\twhile k%j==0:\n\t\t\tk=k/j\n\t\t\tc+=1\n\t\tif c>0:\n\t\t\tres.append(j)\n\t\t\tvals.append(c)\n\tma1=max(vals)\n\tma=ma1\n\tet=0\n\tf2=1\n\tif ma and not (ma&(ma-1)):\n\t#\tet=1\n\t\tf2=0\n\telse:\n\t\twhile ma!=0:\n\t\t\tma=ma/2\n\t\t\tet+=1\n\n\tif f2==0:\n\t\twhile ma>1:\n\t\t\tma=ma/2\n\t\t\tet+=1\n\n\t#print et\n\tzz=1\n\tout=1\n\tf3=0\n\tfor i in vals:\n\t\tif i!=ma1:\n\t\t\tzz=0\n\tfor i in res:\n\t\tout*=i\n#\tif ma1!=1:\n\tyy=et+t+1\n\tif f2==1 and ma1==1:\n\t\tyy-=1\n\tif f2==0:\n\t\tfor j in vals:\n\t\t\tif j!=ma1:\n\t\t\t\tf3=1\n\t\t\t\tbreak\n\t\tif f3==0:\n\t\t\tyy-=1\n\t#else:\n\t#\tyy=et+t\n\tprint out,yy\n\n"}, {"source_code": "\n# Python program to print prime factors \nimport math \ndef primeFactors(n): \n # Print the number of two's that divide n \n dic = {}\n while n % 2 == 0: \n if 2 in dic:\n dic[2] += 1\n else:\n dic[2] = 1\n n = n / 2 \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 # while i divides n , print i ad divide n \n while n % i== 0: \n if i in dic:\n dic[i] += 1\n else:\n dic[i] = 1\n n = n / i \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n if n in dic:\n dic[n] += 1\n else:\n dic[n] = 1\n return dic\nn = int(input())\narr = primeFactors(n)\narr2 = []\nfor key in arr:\n arr2.append(arr[key])\nlength = len(arr2)\nans = 0\n#print(\"ura\")\nwhile True:\n sqrt = True\n if len(arr2) == 0:\n break\n for i in arr2:\n if i%2 == 1:\n sqrt = False\n break\n if sqrt:\n ans += 1\n for i in range(length):\n arr2[i] = arr2[i]/2\n else:\n break\np = 0\nstart = 1\nif len(arr2) ==0:\n a = 1\nelse:\n a = max(arr2)\nfor i in range(1000):\n if start=p:\n p=g\n if g<=q:\n q=g\nf=p\nif q==1000000:\n q=1\nwhile p!=1:\n if p%2!=0:\n p+=1\n y+=1\n else:\n p=p//2\n z+=1\nk=set(k)\nk=list(k)\ns=1\nfor i in range(len(k)):\n s=s*int(k[i])\nif (y!=0)or(q!=f):\n print(s,z+1)\nelse:\n print(s,z)\n\n \n\n \n\n"}, {"source_code": "import math\nn=int(input())\nif n==1:\n print(1,0)\nelse:\n factors=[]\n for i in range(1,round(n**0.5)+2):\n if n%i==0:\n factors+=[i,n//i]\n factors=list(set(factors))\n def isprime(n):\n if n==1:\n return False\n if n<4:\n return(True)\n for i in range(2,round(n**0.5)+2):\n if n%i==0:\n return False\n return True\n primes=[]\n for factor in factors:\n if isprime(factor):\n primes.append(factor)\n exps=[]\n for prime in primes:\n x=prime\n expo=0\n while n%x==0:\n x*=prime\n expo+=1\n exps.append(expo)\n b=max(exps)\n decs=math.ceil(math.log2(b))\n cheat=True\n exp=2**decs\n for guy in exps:\n if guy!=exp:\n cheat=False\n break\n prod=1\n for guy in primes:\n prod*=guy\n if cheat:\n print(prod,decs)\n else:\n print(prod,decs+1)"}, {"source_code": "import math\n\ndef primeFactors(n):\n d={}\n while n%2==0:\n if 2 not in d.keys():\n d[2]=1 \n else:\n d[2]+=1\n n=n//2\n for i in range(3,int(math.sqrt(n)+1),2):\n while n%i==0:\n if i not in d.keys():\n d[i]=1 \n else:\n d[i]+=1\n n=n//i\n if n>2:\n d[n]=1 \n return d \n \n \ndef all_one(d):\n for i in d.keys():\n if d[i]!=1:\n return False \n return True\n \n\ndef solve(d):\n maxx=0\n n=1\n for i in d.keys():\n maxx=max(maxx,d[i])\n n=n*i\n flag=1\n curr=-1\n for i in d.keys():\n if curr==-1:\n curr=d[i]\n elif curr!=d[i]:\n flag=0\n break\n if flag==1 and int(math.log(curr,2))==math.log(curr,2):\n count=0\n else:\n count=1 \n i=1 \n while i 0:\n ans = ans * i\n if flag == 0 and tempflag != 0:\n flag = tempflag\n elif flag > 0 and tempflag != 0 and tempflag != flag:\n flag = -1\n if tempsq > maxsq:\n maxsq = tempsq\nif math.log2(maxsq) == 0.0:\n print(ans, 0)\nelif flag == -1:\n print(ans, math.ceil(math.log2(maxsq) + 1))\nelse:\n if math.ceil(math.log2(maxsq)) == math.log2(maxsq):\n print(ans, math.ceil(math.log2(maxsq)))\n else:\n print(ans, math.ceil(math.log2(maxsq) + 1))"}, {"source_code": "from collections import defaultdict as dif \ndic=dif(lambda:0)\nx=int(input())\nif x==1:\n print(1,0)\n exit(0)\n\nwhile x%2==0:\n dic[2]+=1\n x//=2\n\nmx=dic[2]\n\nn=3\nwhile n*n<=x:\n while x%n==0:\n dic[n]+=1\n x//=n\n mx=max(mx,dic[n])\n n+=2\nif x>1:\n dic[x]=1\n mx=max(1,mx)\nfrom math import log2,ceil\nlg =ceil(log2(mx))\nmxt=1< 1:\n maxp = max(l)\nelse:\n maxp = 0\nflag = 0\nfor i in l:\n if i != maxp:\n flag = 1\n\ntemp = 0\n\nif flag:\n temp = 1\nelse:\n temp = ispowerof2(maxp)\n\nif maxp == 1:\n maxp -= 1\nelif maxp != 0:\n maxp = math.ceil(math.log2(maxp)) + temp\n\nprint(ans, maxp)\n"}, {"source_code": "import math\ndef is_power(n):\n return bin(n).count('1') == 1\n\nn = int(input())\nx = n\ni = 2\nfactors = {}\nif n > 1:\n while i <= int(math.sqrt(x))+1:\n if n % i:\n i += 1\n else:\n n //= i\n if i in factors.keys():\n factors[i] += 1\n else:\n factors[i] = 1\n \n if n > 1:\n factors[n] = 1\n result = 1\n for x in factors:\n result *= x\n \n \n value_max = max(factors.values())\n result_max = 0\n \n if value_max > min(factors.values()) or not is_power(value_max):\n result_max += 1\n if is_power(value_max):\n result_max += int(math.log2(value_max))\n else:\n result_max += int(math.log2(value_max)) + 1\n \n \n print(' '.join([str(result), str(result_max)]))\n\nelse:\n print(' '.join(['1', '0']))\n\n"}, {"source_code": "\ndef main():\n buf = input()\n n = int(buf)\n op_count = 0\n factor = prime_factorization(n)\n c_max = 1\n first_c = None\n all_same = True\n min_number = 1\n for f, c in factor.items():\n if c > c_max:\n c_max = c\n if first_c == None:\n first_c = c\n elif c != first_c:\n all_same = False\n min_number *= f\n if check_power_of_2(c_max) and all_same:\n pass\n else:\n op_count += 1\n if not check_power_of_2(c_max):\n c_max = c_max << 1\n c_max = c_max & (c_max - 1)\n while c_max > 1:\n c_max //= 2\n op_count += 1\n print(min_number, op_count)\n\n\ndef check_power_of_2(x):\n return (x != 0) and ((x & (x - 1)) == 0)\n\ndef prime_factorization(number):\n n = number\n i = 2\n factor = {}\n while i * i <= n:\n while n % i == 0:\n if i in factor:\n factor[i] += 1\n else:\n factor.update({i : 1})\n n //= i\n i += 1\n if n > 1 or not factor:\n if n in factor:\n factor[n] += 1\n else:\n factor.update({n : 1})\n return factor\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\n\nif n == 1:\n\tprint('1 0')\nelse:\n\td = 2\n\tdecomp = []\n\twhile d * d <= n:\n\t\tcnt = 0\n\t\twhile n % d == 0:\n\t\t\tcnt += 1\n\t\t\tn //= d\n\t\tif cnt > 0:\n\t\t\tdecomp += [(d, cnt)]\n\t\tif d == 2:\n\t\t\td += 1\n\t\telse:\n\t\t\td += 2\n\tif n > 1:\n\t\tdecomp += [(n, 1)]\n\n\ttar = 1\n\tmaxExp = 0\n\tfor e in decomp:\n\t\ttar *= e[0]\n\t\tmaxExp = max(maxExp, e[1])\n\t\n\tdivCnt = 0\n\tcurExp = 1\n\twhile curExp < maxExp:\n\t\tdivCnt += 1\n\t\tcurExp *= 2\n\n\tmulRequired = False\n\tfor e in decomp:\n\t\tif e[1] != curExp:\n\t\t\tmulRequired = True\n\t\t\tbreak\n\tif mulRequired:\n\t\tdivCnt += 1\n\n\tprint('%s %s' % (tar, divCnt))\n\n"}, {"source_code": "n=int(input())\nif n==1:\n from sys import exit\n print(1,0);exit()\nd,k,mx,result={},2,0,1\nwhile n>1:\n x=1000000000\n for i in range(k,n+1):\n if n%i==0:d[i]=0;x=i;break\n while n%x==0:n=n//x;d[x]+=1\n k=x+1\n result*=x\n mx=max(mx,d[x])\nres,item=0,1\nwhile item 1:\n primfac.append(n)\n return primfac\n\nn = int(input())\nl = primfacs(n)\nd = {}\nt = []\nk = 1\n\nwhile 2**k < 10**9:\n t.append(2**k)\n k = k + 1\n \nfor i in range(len(l)):\n if l[i] not in d:\n d[l[i]] = 0\n \nfor i in range(len(l)):\n d[l[i]] += 1\n\nsmax = 0\n\nfor i in d:\n if d[i] > smax:\n smax = d[i]\n\nk = 0\nfl = True\nfor i in d:\n if d[i] != smax:\n k = 1\n fl = False\n break\n\n\nif smax not in t:\n i = 0\n while smax > t[i]:\n i += 1\n\n smax = t[i]\n\n if fl:\n k = k + 1\n\nwhile smax > 1:\n smax = smax // 2\n k = k + 1\n\ns = 1\nfor i in d:\n s = s * i\nif int(s) == n:\n print(int(s),0)\nelse:\n print(int(s),k)\n"}, {"source_code": "\nfrom collections import defaultdict\nfrom math import log2, ceil\n\nn = int(input())\nif n == 1:\n\tprint(1, 0)\n\texit()\n\nd = defaultdict(int)\n\nwhile n%2 == 0:\n\td[2] += 1\n\tn //= 2\n\nind = 3\nwhile ind <= int(n**0.5)+1:\n\twhile n%ind == 0:\n\t\td[ind] += 1\n\t\tn //= ind\n\tind += 2\n\nif n != 1:\n\td[n] += 1\n\n# print(d)\n\nma = -1\nans = 1\narr = []\nfor x in d:\n\tma = max(ma, d[x])\n\tarr += [d[x]]\n\tans *= x\n\nif arr.count(ma) == len(arr) and (2**30)%ma == 0:\n\tprint(ans, ceil(log2(ma)))\nelse:\n\tprint(ans, 1 + ceil(log2(ma)))\n\n\n# if arr.count(1) == len(arr):\n# \tprint(ans, 0)\n# elif arr.count(2)\n\n"}, {"source_code": "from 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\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 test:\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\ntest = False\n \n\ndef main():\n n = get_int()\n factors = primeFactors(n)\n if n==1:\n print(1,0)\n return\n ma = max(factors.values())\n times = math.ceil(math.log2(ma))\n r =1\n for i in factors.keys():\n r=r*i\n vals = list(factors.values())\n a = vals[0]\n for i in vals:\n if i!=a or math.log2(i)%1!=0:\n times+=1\n break\n print(r,times)\n \n\n\n \n\n\n\n# --------------------------------------------------------------------------------------------- END\n\n\nif TestCases: \n for _ in range(get_int()): \n cProfile.run('main()') if test else main()\nelse: cProfile.run('main()') if test else main()"}, {"source_code": "from math import *\nprimes = [x for x in range(2, 1001) if 0 == len([y for y in range(2,x) if x % y == 0])]\n\nn = input()\nif n == 1:\n print(\"1 0\")\n exit(0)\n\nl = []\nA = 1\nfor i in primes:\n cnt = 0\n while n % i == 0:\n cnt+=1\n n/=i\n if cnt > 0:\n A *= i\n l.append(cnt)\nif (n > 1):\n A*=n\n l.append(1)\n\nf = 0\n\nfor i in l:\n f = max(f, int(ceil(log(i, 2))))\n\nans = f\nif min(l) != 2**f:\n ans+=1\n\nprint A, ans\n"}, {"source_code": "'''input\n20\n'''\nfrom sys import stdin\nimport math\n\n\ndef find_prime(n):\n\tnum = n\n\tprime_factors = [0] * (num + 1)\n\twhile n % 2 == 0: \n\t\tprime_factors[2] += 1\n\t\tn = n // 2\n \n\tfor i in range(3,num+1,2): \n\t\twhile n % i == 0: \n\t\t\tn = n // i\n\t\t\tprime_factors[i] += 1 \n\t\t\t\n\treturn prime_factors, n\n\n\ndef check_prime(number):\n\tif number > 2:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef check_all_equal(prime_factors):\n\ti = 2\n\tequal = 0\n\twhile i < len(prime_factors):\n\t\tif prime_factors[i] != 0:\n\t\t\tequal = prime_factors[i]\n\t\t\tbreak\n\t\ti += 1\n\t\n\twhile i < len(prime_factors):\n\t\tif prime_factors[i] != 0:\n\t\t\tif prime_factors[i] != equal:\n\t\t\t\treturn False\n\t\ti += 1\n\treturn True\n\n\ndef find_nearest_2_power(num, steps):\n\tpower = 0\n\twhile (2 ** power) < num:\n\t\tpower += 1\n\n\tsteps += power\n\t\n\tif 2 ** power == num:\n\t\treturn steps, 0\n\telse:\n\t\treturn steps + 1, 1\n\n\ndef print_the_number(prime_factors, steps):\n\tproduct = 1 \n\tfor i in range(2, len(prime_factors)):\n\t\tif prime_factors[i] != 0:\n\t\t\tproduct = product * i\n\tprint(product, steps)\n\n# main starts\nn = int(stdin.readline().strip())\nprime_factors, modified = find_prime(n)\nif n == 1:\n\tprint(1, 0)\n\nelse:\n\tsteps = 0\n\tif check_all_equal(prime_factors):\n\t\tmaxfactor = max(prime_factors)\n\t\tsteps, c = find_nearest_2_power(maxfactor, steps)\n\t\tprint_the_number(prime_factors, steps)\n\telse:\n\t\tsteps += 1\n\t\tmaxfactor = max(prime_factors)\n\t\tsteps, c = find_nearest_2_power(maxfactor, steps)\n\t\tif c == 1:\n\t\t\tsteps -= 1\n\t\tprint_the_number(prime_factors, steps)\n"}, {"source_code": "import math\nN=int(input())\nif N==1:\n print(1,end=\" \")\n print(0)\n exit()\ndic={}\nwhile(N!=1):\n z=int(math.sqrt(N))\n \n for i in range(2,z+1):\n if N%i==0:\n dic[i]=dic.get(i,0)+1 \n N=N//i \n break\n \n else:\n dic[N]=dic.get(N,0)+1 \n N=1\noutput1=1 \noutput2=0\nmax1=0\ncount=0\n\nfor i in dic:\n output1*=i \n max1=max(max1,dic[i])\n\nif math.log(max1,2)==int(math.log(max1,2)):\n matchwith=max1\n x=math.log(matchwith,2)\nelse:\n x=math.ceil(math.log(max1,2))\n matchwith=2**x \n \nfor i in dic:\n if dic[i]!=matchwith:\n output2+=1 \n break\nprint(output1,end=\" \")\nprint(int(x+output2))\n "}, {"source_code": "#Afsoos ke bee fayede farsoode shodim vaz aase sepehre sarnegoon soode shodim\n#Darda o nedamata ke ta cheshm zadim naboode be kame kheesh, naboode shodim\nn = int ( input ( ) )\ncopy=n\nq=[]\nbas=[]\nco=0\nwhile n%2==0:\n n//=2\n co+=1\nif co!=0:\n q+=[co]\n bas+=[2]\nfor i in range ( 3 , n+1 , +2):\n co=0\n while n%i==0:\n n//=i\n co+=1\n if co!=0:\n q+=[co]\n bas+=[i]\nx=0\nw=1\nif copy==1:\n exit(print(copy,0))\nfor i in bas:\n w*=i\nwhile 2**x 1:\n prime[n] = 1\n N *= n\n mx, mn = 0, 35\n for data in prime:\n mx = max(mx, prime[data])\n mn = min(mn, prime[data])\n if N == 1:\n cnt = 0\n else:\n cnt = int(ceil(log(mx, 2))) + (0 if mx == mn and mx in [1,2,4,8,16] else 1) \n print(N, cnt)\n \n\ndef main():\n s = Solve()\n\nmain()\n"}, {"source_code": "import math\n\ndef primeFactors(n):\n d={}\n while n%2==0:\n if 2 not in d.keys():\n d[2]=1 \n else:\n d[2]+=1\n n=n//2\n for i in range(3,int(math.sqrt(n)+1),2):\n while n%i==0:\n if i not in d.keys():\n d[i]=1 \n else:\n d[i]+=1\n n=n//i\n if n>2:\n d[n]=1 \n return d \n \n \ndef all_one(d):\n for i in d.keys():\n if d[i]!=1:\n return False \n return True\n \n\ndef solve(d):\n maxx=0\n n=1\n for i in d.keys():\n maxx=max(maxx,d[i])\n n=n*i\n flag=1\n curr=-1\n for i in d.keys():\n if curr==-1:\n curr=d[i]\n elif curr!=d[i]:\n flag=0\n break\n if flag==1 and int(math.log(curr,2))==math.log(curr,2):\n count=0\n else:\n count=1 \n i=1 \n while i 0:\n\t\tfact[d] = c\n\t\n\td = 3\n\twhile n != 1:\n\t\tc = 0\n\t\twhile n % d == 0:\n\t\t\tc += 1\n\t\t\tn //= d\n\t\tif c > 0:\n\t\t\tfact[d] = c\n\t\td += 2\n\n\tans = reduce(lambda x,y: x*y, fact.keys())\n\tmaxPow = max(fact.values())\n\n\tx = 0\n\twhile maxPow > (1 << x):\n\t\tx += 1\n\n\tif maxPow == (1 << x) and all([y == maxPow for y in fact.values()]):\n\t\tprint(ans, x)\n\t\treturn\n\telse:\n\t\tprint(ans, x + 1)\n\t\treturn\n\nif __name__ == \"__main__\":\n\tmain()"}, {"source_code": "#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))\nn = int(input())\nn2 = n\nflag = 0\ni = 0\nans = 1\nflag2= 0\nans2 = 0\nfor i in range(2,int(n**0.5)+1):\n if n % i == 0:\n ans *= i\n num = 0\n while n % i == 0:\n n //= i\n num += 1\n num2 = 0\n num3 = bin(num)[3:]\n flag = 0\n for j in num3:\n if j == \"1\":\n flag = 1\n break\n if flag == 1 or num == 1:\n num2 = len(num3) + 1\n flag2 = 1\n else:\n num2 = len(num3)\n if num2 != ans2 and ans2 != 0 and num2 != 0:\n flag2 = 1\n ans2 = max(ans2,num2)\n if n < i:\n break\nnum3 = ans * n\nif num3 == n2:\n print(num3,0)\nelse:\n if n!=1:\n num2 = 2\n flag2 = 1\n else:\n num2 = 1\n print(num3,max(ans2+flag2,num2))\n"}, {"source_code": "\ndef primfacs(n):\n i = 2\n primfac = []\n arr = [0] * int(n)\n D = dict()\n while i * i <= n:\n while n % i == 0:\n if int(i) in D.keys():\n D[int(i)] += 1\n else:\n D[int(i)] = 1\n n = n / i\n i = i + 1\n if n > 1:\n if n in D.keys():\n D[n] += 1\n else:\n D[n] = 1\n return D\n\ndef main():\n n = int(input())\n \n go = 1\n op = 0\n res = 0\n \n \n D = primfacs(n)\n if n == 1:\n print('1', '0')\n else:\n while (n ** (1 / 2)) % 1 == 0:\n op += 1\n n = n ** (1 / 2)\n st = 0\n \n D = primfacs(n)\n for i in range(0, 25):\n ok = 1\n for el in D.keys():\n if not D[el] <= 2 ** i:\n ok = 0\n if ok == 1:\n st = i\n break\n \n op += st\n if st != 0:\n op += 1\n n = 1\n \n for el in D.keys():\n n *= el\n print(int(n), op)\nmain()\n \n"}, {"source_code": "n=int(input())\nans=1\ntemp=n\nans=1\nc=0\nfor i in range(2,n+1):\n if(n%i==0):\n ans*=i\n while(n%i==0):\n n/=i\nans2=ans\nwhile(ans%temp>0):\n ans*=ans\n c+=1\nif ans>temp:\n c+=1\nprint(ans2,c)"}, {"source_code": "from __future__ import division\nfrom sys import stdin, stdout\nfrom collections import defaultdict\nfrom math import log, floor, ceil\n\n\ndef sieveOfEratosthenes(n):\n \"\"\"sieveOfEratosthenes(n): return the list of the primes < n.\"\"\"\n # Code from: , 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\nprimes = sieveOfEratosthenes(1002)\n\n\ndef factors(x):\n out = defaultdict(int)\n\n while True:\n for prime in primes:\n if x % prime == 0:\n out[prime] += 1\n x //= prime\n break\n else:\n if x != 1:\n out[x] += 1\n return out\n\n\ndef write(x):\n stdout.write(str(x) + \"\\n\")\n\n\ndef number(x):\n if x == 1:\n return 0, False\n l = int(log(x, 2))\n if 2 ** l == x:\n return l, False\n return int(ceil(log(x, 2))), True\n\n\ndef alleq(l):\n l = list(l)\n f = l[0]\n for i in range(1, len(l)):\n if l[i] != f:\n return False\n return True\n\n\nn = int(stdin.readline())\nif n == 1:\n write(\"1 0\")\n exit()\nfac = factors(n)\nr1 = 1\nr2 = 0\n\nhh = False\nfor k, v in fac.iteritems():\n r1 *= k\n nn, harb = number(v)\n if nn > r2:\n r2 = max(r2, nn)\n hh = harb\n\nif hh:\n r2 += 1\nelif not alleq(fac.itervalues()):\n r2 += 1\n\nwrite(str(r1) + \" \" + str(r2))\n"}, {"source_code": "n=int(input())\nx=n\nk=2\nnum=1\nm1=1\nm2=100\nwhile k*k<=x:\n\tcount=0\n\twhile x%k==0:\n\t\tcount+=1\n\t\tx//=k\n\tif count>0:\n\t\tnum*=k\t\t\n\t\tm1=max(m1,count)\n\t\tm2=min(m2,count)\n\tk+=1\nif x>1:\n\tnum*=x\n\tm2=1\n\ns=bin(m1)[2:]\na= 1 if s.count('1')==1 else -1\nb=0\nif a==1 and m1!=m2:\n\tb=1\nc=len(s)\nm=c-a+b\nif n==1:\n\tm=0\nprint(num,m)\n\n"}, {"source_code": "import sys\nimport math\n\ndef starting(N):\n a = []\n b = {}\n ans_one = 1\n ans_two = 0\n d = -1\n\n for i in range(2,N):\n if N%i:\n continue\n c = 0\n while not (N%i):\n c += 1\n N /= i\n\n if c&-c != c:\n ans_two = 1\n elif d != -1 and c != d:\n ans_two = 1\n\n if d < c:\n d = c\n ans_one *= i\n\n\n\n if N > 1:\n ans_one *= N\n if d != 1 and d != -1:\n ans_two = 1\n\n i = 1\n while i < d:\n ans_two += 1\n i *= 2\n\n print ans_one, ans_two\n\nn=int(input())\n\nif n == 1:\n print 1,0\nelse:\n starting(n)\n"}, {"source_code": "li2=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912]\nfrom functools import reduce \nfrom collections import defaultdict\nfrom math import floor,sqrt\nfrom bisect import bisect\nn=int(input())\nm=n\nif n==1:\n print(1,0)\nelse:\n d=defaultdict(int)\n for i in range(2,floor(sqrt(n))+1):\n while n%i==0:\n d[i]+=1\n n//=i\n if n>1:\n d[n]+=1\n vl=(list(d.values()))\n v=max(vl)\n f=1\n if len(set(vl))==1 and (v in li2):\n f=0\n if v==1 :\n print(m,0)\n else:\n #print(d)\n kl=list(d.keys())\n p=reduce((lambda x, y: x * y),kl) \n i=bisect(li2,v)\n if li2[i-1]==v:\n print(p,i-1+f)\n else:\n print(p,i+f)"}, {"source_code": "from math import log2, sqrt\n\ndef main():\n n = int(input())\n d = {}\n cur = n\n for i in range(2, int(sqrt(n)) + 2):\n while cur % i == 0:\n t = d.get(i, 0) + 1\n d[i] = t\n cur //= i\n if cur != 1:\n d[cur] = 1\n if d == {} or max(d.values()) == 1:\n return print(n, 0)\n cur = []\n action = False\n for k in d:\n q = log2(d[k])\n if q - int(q) != 0 or q == 0:\n if not action:\n action = True\n cur.append(int(q) + 1)\n else:\n cur.append(int(q))\n ans_2 = max(cur)\n if action or len(set(cur)) != 1:\n ans_2 += 1\n ans_1 = 1\n for k in d:\n ans_1 *= k\n return print(ans_1, ans_2)\n \nif __name__==\"__main__\":\n main()"}, {"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\nimport itertools\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)]\ndef Lcm(x,y): return (x*y)//gcd(x,y)\ndef dtob(n): return bin(n).replace(\"0b\",\"\")\ndef btod(n): return int(n,2) \ndef common(l1, l2): \n return set(l1).intersection(l2) \n \n# Driver Code \ndef solution():\n #for i in range(Int()):\n n=Int()\n s=0\n c=0\n while(int(n**0.5)==n**0.5 and n>1):\n n=n**0.5\n s+=1\n for i in range(int(n**0.5),1,-1):\n while(n%(i*i)==0):\n n=n//i\n s+=1\n c=1\n print(int(n),s+c) \n \n \n \n#Call the solve function \nif __name__ == \"__main__\":\n solution() "}, {"source_code": "import sys\nfrom math import sqrt, log, ceil\ninput_file = sys.stdin\n\nn = int(input_file.readline())\n\ndef factor(n):\n lst = []\n prod = 1\n for i in range(2, n+1):\n if n % i == 0:\n prod *= i\n lst.append(0)\n while n % i == 0:\n lst[-1] += 1\n n /= i\n if n < i:\n break\n return lst, prod\n\nif n == 1:\n print(1, 0)\nelse:\n lst, ans = factor(n)\n maxi, mini = max(lst), min(lst)\n if maxi == mini and log(maxi, 2) == int(log(maxi, 2)):\n print(ans, int(log(maxi, 2)))\n else:\n print(ans, int(ceil(log(maxi, 2)) + 1))\n"}, {"source_code": "from math import log, ceil\nd = {}\nn = int(input())\nif n == 1:\n print('1 0')\n exit(0)\ni = 2\nwhile True:\n if i > n:\n break\n if n % i == 0:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\n n //= i\n else:\n i += 1\n\nmaxpow = max(d.values())\nminpow = min(d.values())\nans = int(ceil(log(maxpow, 2)))\nif maxpow & (maxpow - 1) != 0:\n ans += 1\nelif minpow != maxpow:\n ans += 1\nvalue = 1\nfor i in d.keys():\n value *= i\nprint(value, ans)"}, {"source_code": "\nfrom fractions import gcd\nfrom operator import __mul__\n\ndef factor(n):\n res = []\n p = 2\n while p * p <= n:\n if n % p == 0:\n a = 0\n while n % p == 0:\n a += 1\n n /= p\n\n res.append((p, a))\n\n p += 1\n\n if n > 1:\n res.append((n, 1))\n\n return dict(res)\n\nn = int(raw_input())\n\nimport sys\nif n == 1:\n print \"1 0\"\n sys.exit()\n\nF = factor(n)\nm = max(F.values())\np2 = 1\nlp2 = 0\nwhile p2 < m:\n p2 = p2 * 2\n lp2 += 1\n\nmoves = lp2 + (1 if any(e < p2 for e in F.values()) else 0)\n\nprint reduce(__mul__, F.keys(), 1), moves\n"}, {"source_code": "from sys import stdin\nn=int(stdin.readline().strip())\nif n==1:\n print(1,0)\n exit(0)\nans=0\naux=n**0.5\nwhile aux==int(aux):\n n=aux\n ans+=1\n aux=n**0.5\nn=int(n)\nsieve=[]\nvis=[False for i in range(n+1)]\nfor i in range(2,n+1):\n if not vis[i]:\n sieve.append(i)\n for j in range(i,n+1,i):\n vis[j]=True\narr=[]\ny=1\nn1=n\nfor i in sieve:\n if n%i==0:\n x=0\n while n%i==0:\n n//=i\n x+=1\n y*=i\nn=n1\nx=y\nwhile y%n!=0:\n y*=y\n ans+=1\nif y!=n:\n ans+=1\nprint(x,ans)\n \n"}, {"source_code": "\ndef prime_factors(a):\n\tif a==1:\n\t\treturn(1,0)\n\tfactors={}\n\ti=2\n\torig=a\n\twhile i <= (int(orig**0.5)+1):\n\t\twhile a%i==0:\n\t\t\ta=a//i\n\t\t\tif i in factors: \n\t\t\t\tfactors[i]+=1\n\t\t\telse:\n\t\t\t\tfactors[i]=1\n\t\ti+=1\n\tif a>1:\n\t\tfactors[a]=1\n\t#print(factors)\n\tif sorted(factors)[-1]==orig:\n\t\treturn(N,0)\n\tmultiple=1\n\tfor i in factors:\n\t\tmultiple*=i\n\tif orig==multiple**2:\n\t\treturn(int(orig**0.5),1)\n\telif orig==multiple:\n\t\treturn (orig,0)\n\tsomething=sorted([factors[i] for i in factors])\n\tcounter=0\n\t#print(something[-1])\n\twhile 2**(counter)1:\n if n%val==0: \n a=1 \n n=int(n/val)\n bs.append(val)\n while n%val==0: \n n=n/val\n a=a+1\n fs.append(a)\n ct=ct+1\n val=ps[ct] \n m=max(fs) \n p=1 \n for val in bs: \n p=p*val \n if m==1: \n return (p,0)\n \n if issame(fs,m): \n if ispower(m): \n num=int(math.log2(m))\n else: \n num=int(math.log2(m))+1\n num=num+1\n else: \n if ispower(m):\n num=int(math.log2(m))\n else: \n num=int(math.log2(m))+1\n num=num+1\n \n \n return (p,num) \n\ndef main(): \n n=int(input()) \n if n==1: \n print(str(1)+\" \"+str(0))\n return None\n SOE(n)\n p,ct=fact(n) \n print(str(p)+\" \"+str(ct))\nmain()\n \n \n \n "}, {"source_code": "import sys\nfrom math import sqrt, gcd, ceil, log\nfrom bisect import bisect\nfrom collections import defaultdict\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n# sys.setrecursionlimit(10**6)\n\n\n\ndef solve():\n\tn = int(inp());\n\tif n == 1:print(1, 0);exit()\n\tarr = []; m_c = 1\n\tsett = set()\n\tfor i in range(2, int(sqrt(n)+1)):\n\t\tc = 0\n\t\tif n%i == 0:\n\t\t\tarr.append(i)\n\t\t\twhile n%i == 0:\n\t\t\t\tc += 1\n\t\t\t\tn //= i\n\t\t\tsett.add(c)\n\t\tm_c = max(m_c, c)\n\tif n > 1:\n\t\tarr.append(n)\n\t\tsett.add(1)\n\n\t# print(m_c, sett, arr)\n\tm_c = ceil(log(m_c, 2))\n\tif len(sett) == 1 and 2**m_c in sett:\n\t\tans = 1\n\t\tfor i in arr: ans *= i\n\t\tprint(ans, m_c)\n\telse:\n\t\tans = 1\n\t\tfor i in arr: ans *= i\n\t\tprint(ans, m_c+1)\n\n\n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "n = int(input())\nif n == 1: print(1, 0); exit()\nlis = []\nx = int(n**0.5)\nfor i in range(2, x+1):\n if n%i == 0:\n cnt = 0\n while(n%i == 0):\n cnt += 1\n n//=i\n lis.append([i, cnt])\nif n-1: lis.append([n, 1])\nsu = 1\nfor i in lis:\n su *= i[0]\nm = max([i[1] for i in lis])\nimport math\nif 2**int(math.log(m, 2)) == m: \n if m == min([i[1] for i in lis]): m = int(math.log(m, 2))\n else: m = int(math.log(m, 2)) + 1\nelse: m = int(math.log(m, 2)) + 2\n\nprint(su, m)\n"}, {"source_code": "import sys\nfrom math import sqrt, gcd, ceil, log\nfrom bisect import bisect\nfrom collections import defaultdict\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n# sys.setrecursionlimit(10**6)\n\n\n\ndef solve():\n\tn = int(inp());\n\tif n == 1:print(1, 0);exit()\n\tarr = []; m_c = 1\n\tsett = set()\n\tfor i in range(2, int(sqrt(n)+1)):\n\t\tc = 0\n\t\tif n%i == 0:\n\t\t\tarr.append(i)\n\t\t\twhile n%i == 0:\n\t\t\t\tc += 1\n\t\t\t\tn //= i\n\t\t\tsett.add(c)\n\t\tm_c = max(m_c, c)\n\tif n > 1:\n\t\tarr.append(n)\n\t\tsett.add(1)\n\n\t# print(m_c, sett, arr)\n\tm_c = ceil(log(m_c, 2))\n\tif len(sett) == 1 and 2**m_c in sett:\n\t\tans = 1\n\t\tfor i in arr: ans *= i\n\t\tprint(ans, m_c)\n\telse:\n\t\tans = 1\n\t\tfor i in arr: ans *= i\n\t\tprint(ans, m_c+1)\n\n\n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "import math\n\ndef myf(n):\n\tif n==1:\n\t\treturn [(1,1)]\n\ta = list()\n\tfor i in range(2,n+1):\n\t\tif n%i == 0:\n\t\t\tcount = 0\n\t\t\twhile n%i == 0:\n\t\t\t\tn /= i\n\t\t\t\tcount += 1\n\t\t\ta.append((i,count))\n\treturn a\n\nn = int(input())\n\ns = -1\nx = myf(n)\nh = True\n\n#print(x)\nfor i in range(1,len(x)):\n\tif x[i][1] != x[i-1][1]:\n\t\th = False\n\nif h:\n\tif x[0][1] & (x[0][1]-1) == 0:\n\t\ts = math.log2(x[0][1])\n\telse:\n\t\tmym = x[0][1]\n\t\tif mym & (mym-1) != 0:\n\t\t\ts = 0\n\t\twhile mym != 0:\n\t\t\tmym = mym >> 1\n\t\t\ts +=1\n\t\ts +=1\nelse:\n\tmym = x[0][1]\n\tfor each in x:\n\t\tif each[1]>mym:\n\t\t\tmym = each[1]\t\n\tif mym & (mym-1) != 0:\n\t\ts = 0\n\n\twhile mym != 0:\n\t\tmym = mym >> 1\n\t\ts +=1\n\ts += 1\t\n\nv = 1\nfor each in x:\n\tv *= each[0]\t\nprint(v,int(s),sep=\" \")\t\n"}, {"source_code": "def smol(n):\n prod = 1\n orig = n\n d = 2\n while d*d <= orig and n>1:\n if n%d == 0:\n prod *= d\n while n % d == 0:\n n //=d\n d += 1\n if n > 1:\n prod *= n\n return prod\nnum = int(input())\nsmall = smol(num)\nans = 0\nwhile small%num > 0:\n small *= small\n ans += 1\nif small != num:\n ans += 1\nprint(smol(num),ans)\n"}, {"source_code": "import math\nN=int(input())\nif N==1:\n print(1,end=\" \")\n print(0)\n exit()\ndic={}\nwhile(N!=1):\n z=int(math.sqrt(N))\n \n for i in range(2,z+1):\n if N%i==0:\n dic[i]=dic.get(i,0)+1 \n N=N//i \n break\n \n else:\n dic[N]=dic.get(N,0)+1 \n N=1\noutput1=1 \noutput2=0\nmax1=0\ncount=0\n\nfor i in dic:\n output1*=i \n max1=max(max1,dic[i])\n\nif math.log(max1,2)==int(math.log(max1,2)):\n matchwith=max1\n x=math.log(matchwith,2)\nelse:\n x=math.ceil(math.log(max1,2))\n matchwith=2**x \n \nfor i in dic:\n if dic[i]!=matchwith:\n output2+=1 \n break\nprint(output1,end=\" \")\nprint(int(x+output2))\n "}, {"source_code": "n=int(input())\nfrom math import sqrt as S \nfrom math import log as log,ceil as upar\nd={}\nc=0\nfor i in range(2,int(S(n))+1):\n if n%i==0:\n while n%i==0:\n c+=1 \n n=n//i \n d[i]=c \n c=0\nif n>1:\n d[n]=1 \nans=1 \nfor i in d.keys():\n ans*=i \nprint(ans,end=' ')\n\nfather_pow=0 \nfor i in d.keys():\n u=upar(log(d[i])/log(2))\n # print(u)\n father_pow=max(father_pow,u)\n#print(father_pow)\nif(all(d[i]==2**father_pow for i in d.keys())):\n print(father_pow)\nelse:\n print(father_pow+1)"}, {"source_code": "import math\nn=input()\nif n==1:\n\tprint 1, 0\nelse:\n\tflag=1\n\tk=n\n\tt=0\n\twhile flag:\n\t\tc=int(math.sqrt(k))\n\t\tif c*c==k:\n\t\t\tk=c\n\t\t\tt+=1\n\t\telse:\n\t\t\tflag=0\n\tres=[]\n\tvals=[]\n\tfor j in range(2,k+1):\n\t\tc=0\n\t\twhile k%j==0:\n\t\t\tk=k/j\n\t\t\tc+=1\n\t\tif c>0:\n\t\t\tres.append(j)\n\t\t\tvals.append(c)\n\tma1=max(vals)\n\tma=ma1\n\tet=0\n\tf2=1\n\tif ma and not (ma&(ma-1)):\n\t#\tet=1\n\t\tf2=0\n\telse:\n\t\twhile ma!=0:\n\t\t\tma=ma/2\n\t\t\tet+=1\n\n\tif f2==0:\n\t\twhile ma>1:\n\t\t\tma=ma/2\n\t\t\tet+=1\n\n\t#print et\n\tzz=1\n\tout=1\n\tf3=0\n\tfor i in vals:\n\t\tif i!=ma1:\n\t\t\tzz=0\n\tfor i in res:\n\t\tout*=i\n#\tif ma1!=1:\n\tyy=et+t+1\n\tif f2==1 and ma1==1:\n\t\tyy-=1\n\tif f2==0:\n\t\tfor j in vals:\n\t\t\tif j!=ma1:\n\t\t\t\tf3=1\n\t\t\t\tbreak\n\t\tif f3==0:\n\t\t\tyy-=1\n\t#else:\n\t#\tyy=et+t\n\tprint out,yy\n\n"}, {"source_code": "import math\nimport collections\nn = int(input())\nif n==1:\n print(1,end=\" \")\n print(0)\nelse:\n \n l=collections.defaultdict(lambda :0)\n while n%2==0:\n l[2]+=1\n \n n//=2\n for i in range(3,int(math.sqrt(n))+1,2):\n while n%i==0:\n l[i]+=1\n n//=i\n if n>2:\n l[n]+=1\n d=max(l.values())\n num=1\n for t in set(l.keys()):\n num*=t\n ans=0\n flag=False\n while d!=1:\n if d%2==0:\n ans+=1\n d//=2\n else:\n d+=1\n flag=True\n \n if len(set(l.values()))>1 or flag:\n ans+=1\n print(num,end=\" \")\n print(ans)\n"}, {"source_code": "from math import log, ceil\n\n\ndef factor1(n):\n num = 2\n res = set()\n while num ** 2 <= n:\n while n % num == 0:\n res.add(num)\n n = n // num\n num += 1\n if n > 1:\n res.add(n)\n ans = 1\n for x in res:\n ans *= x\n return ans\n\n\ndef factor(n):\n num = 2\n res = dict()\n while num ** 2 <= n:\n while n % num == 0:\n res[num] = res.get(num, 0) + 1\n n = n // num\n num += 1\n if n > 1:\n res[n] = res.get(n, 0) + 1\n return res\n\n\nn = int(input())\nmin_ = factor1(n)\nkek = sorted(factor(n).values())\nif min_ == n:\n print(n, 0)\nelif kek[0] == kek[-1] and log(kek[-1], 2) // 1 == log(kek[-1], 2):\n print(min_, int(log(kek[-1], 2)))\nelse:\n print(min_, ceil(log(kek[-1], 2)) + 1)\n"}, {"source_code": "n = int(raw_input())\ni = 2\ntn = n\nfj_dict = dict()\nif n == 1:\n print 1, 0\nelse:\n while i * i <= tn:\n while tn % i == 0:\n fj_dict[i] = fj_dict.get(i, 0) + 1\n tn = tn / i\n i += 1\n if tn != 1:\n fj_dict[tn] = 1\n ans = 1\n for i in fj_dict.keys():\n ans *= i\n maxv = max(fj_dict.values())\n minv = min(fj_dict.values())\n i = 1\n cnt = 0\n while i < maxv:\n i *= 2\n cnt += 1\n if i > maxv or maxv != minv:\n cnt += 1\n \n print ans, cnt\n \n "}, {"source_code": "from __future__ import division\nfrom collections import deque, defaultdict, Counter\nfrom math import *\n\n\ndef count_prime(n):\n for i in range(2, n):\n if not prim[i]:\n for j in range(i, n, i):\n prim[j] = i\n\n for i in range(1, n):\n if not prim[i]:\n prim[i] = i\n\n\ndef prime_factor(x):\n fac = []\n while x > 1:\n div = prim[x]\n fac.append(div)\n x //= div\n return fac\n\n\nispow2 = lambda x: x and (not (x & (x - 1)))\nn, ans, N = int(input()), [1, 0], 10 ** 6 + 1\nif n == 1:\n print('1 0')\n exit()\n\nprim = [0] * (N)\ncount_prime(N)\nmem = Counter(prime_factor(n))\nma = max(mem.values())\n\nfor i, j in mem.items():\n ans[0] *= i\n if j != ma:\n ans[1] = 1\n\nif not ispow2(ma):\n ans[1] = 1\n\nans[1] += int(ceil((log(ma, 2))))\nprint(' '.join(map(str, ans)))\n"}, {"source_code": "from math import log, ceil\nn = int(input())\nif n == 1:\n print(1, 0)\n exit()\n\nf = {}\ni = 2\nwhile i <= n:\n if n%i == 0:\n f[i] = 0\n while n%i == 0:\n n = n//i\n f[i] += 1\n i += 1\nans = 1\nfor fi in f:\n ans = ans*fi\npow2 = {1< 2: \n yield n\n\ndef get_prime_factorization(n):\n if(n == 1):\n return {1 : 1}\n primes = {}\n for prime in primeFactors(n):\n prime = int(prime)\n if(prime in primes):\n primes[prime] += 1\n else:\n primes[prime] = 1\n return primes\n\ndef next_power_of_2(n):\n return int(math.pow(2, math.ceil(math.log(n)/math.log(2))))\n\ndef solution(n):\n\n pf = get_prime_factorization(n)\n \n lp = 0 \n for key, val in pf.items():\n lp = max(lp, val)\n \n # lp is the largest power in the prime factorization\n # we need the nearest power of two\n np2 = next_power_of_2(lp)\n ans = 1\n for key, val in pf.items():\n ans *= key\n \n moves = 0\n for key, val in pf.items():\n if(val != np2):\n moves = 1\n break\n moves += int(math.log2(np2))\n\n print(ans, moves)\n\n\n\nif __name__ == \"__main__\":\n\n # single variables\n n = [int(val) for val in input().split()][0]\n\n # solve it!\n solution(n)\n\n"}, {"source_code": "from sys import stdin, stdout\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\n\nn = int(stdin.readline())\nmp = {}\n\nd = 2\nwhile d * d <= n:\n while n % d == 0:\n \n if d not in mp:\n mp[d] = 1\n else:\n mp[d] += 1\n \n n //= d\n \n d += 1\n\nif n != 1:\n mp[n] = 1\n\nans = 1\ncnt = 1\ns = set()\n\nfor v in mp:\n ans *= v\n cnt = max(cnt, mp[v])\n s.add(mp[v])\n\n\nfor i in range(20):\n if (1 << i) == cnt and len(s) <= 1:\n stdout.write(str(ans) + ' ' + str(i) + '\\n')\n break\n \n if (1 << i) >= cnt:\n stdout.write(str(ans) + ' ' + str(1 + i) + '\\n')\n break"}, {"source_code": "n=input()\nc={}\nd=2\nwhile d*d<=n:\n while 0==n%d:\n c[d]=c.get(d,0)+1\n n/=d\n d+=1\nif n>1:\n c[n]=1\np=max(c.values()+[1])\nx,y=1,0\nwhile x 1:\n ans_one *= N\n if d != 1 and d != -1:\n ans_two = 1\n\n i = 1\n while i < d:\n ans_two += 1\n i *= 2\n\n print ans_one, ans_two\n\nn=int(input())\n\nif n == 1:\n print 1,0\nelse:\n starting(n)\n"}, {"source_code": "import math\n\nn = int(input())\nN = n\nfrq = list()\nfor i in range(n+1):\n if(i == 1) : frq.append(1)\n frq.append(0)\nwhile(n > 1):\n for i in range(2, n+1):\n if(n % i == 0):\n frq[i] += 1\n n //= i\n break\nmaxfrq = 0\nsqfree = 1\nparity = False\nfor i in range(N+1):\n if(frq[i]>0):\n sqfree *= i\n maxfrq = max(maxfrq, frq[i])\nif(int(math.log2(maxfrq)) != math.log2(maxfrq)):\n parity = True\nfor i in range(2, N+1):\n if(frq[i] > 0 and frq[i] != maxfrq):\n parity = True\n break\nnextbit = 1\nwhile(nextbit < maxfrq) : nextbit *= 2\nif(parity == False) : nextbit /= 2\nprint(sqfree, int(math.log2(nextbit)) + 1)\n"}], "negative_code": [{"source_code": "import math\ndef primfacs(n):\n i = 2\n primfac = []\n while i * i <= n:\n while n % i == 0:\n primfac.append(i)\n n = n / i\n i = i + 1\n if n > 1:\n primfac.append(n)\n return primfac\n\nn = int(input())\nl = primfacs(n)\n\ns = 1\nsmax = 1\nt = []\nfor i in range(1,len(l)):\n if l[i] not in t:\n t.append(l[i])\n if l[i] == l[i-1]:\n s = s + 1\n smax = max(s,smax)\n else:\n s = 1\n\nk = 0\nwhile smax > 1:\n if smax % 2 == 0:\n smax = smax // 2\n else:\n smax = smax + 1\n\n k = k + 1\n\ns = 1\nfor i in range(len(t)):\n s = s * t[i]\nprint(s,k)"}, {"source_code": "n=int(input())\nsl_vhoshd={}\ntemp=1\nif n==1:\n print(1,0)\n exit()\ndef factor(n):\n rasl = []\n d = 2\n while d * d <= n:\n if n % d == 0:\n rasl.append(d)\n n //= d\n else:\n d += 1\n if n > 1:\n rasl.append(n)\n return (rasl)\ndef sled_st_dv(n):\n temp=0\n while pow(2,temp)1:\nprint(proisv(sett),temp)\n\n"}, {"source_code": "import math\n# https://codeforces.com/problemset/problem/1062/B\ndef B1062(n):\n dictionary = dict()\n value = 1 \n while (n % 2 == 0):\n dictionary[2] = 1 + dictionary.get(2, 0)\n n = n/2\n value = 2\n\n for prime in range(3, int(math.sqrt(n))+1, 2):\n found_prime = False\n while n % prime == 0:\n dictionary[prime] = dictionary.get(prime, 0) + 1\n n = n/prime\n if not found_prime:\n value *= prime\n found_prime = True\n\n if (n>2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n\n steps = 0 \n\n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1:\n \n print(n, 0)\n return\n\n if max_power == 2:\n steps = 2\n elif all(list(map(lambda x: int(math.log(x, 2)) * 2 == x, dictionary.values()))):\n steps = int(math_log) \n else:\n if int(math_log) == math_log: # max power is squared\n # we add one for the \"squaredfication\"\n steps = int(math_log) +1\n else:\n steps = int(math_log) + 1 + 1\n\n #print(value, steps)\n print(\" \".join([str(int(value)), str(steps)]))\n\n\nB1062(int(input()))\n"}, {"source_code": "N = int(input())\nnum = 0\nwhile int(N ** 0.5) ** 2 == N:\n num += 1\n N = int(N ** 0.5)\nM = 10 ** 3 + 5\npr = {}\nK = N\nfor i in range(2, M):\n tmp = 0\n while K % i == 0:\n K //= i\n tmp += 1\n if tmp >= 1:\n pr[i] = tmp\n\nwhile True:\n pr = {}\n K = N\n for i in range(2, M):\n tmp = 0\n while K % i == 0:\n K //= i\n tmp += 1\n if tmp >= 1:\n pr[i] = tmp\n\n tmp0 = 0\n for k, v in pr.items():\n if v % 2 != 0:\n pr[k] += 1\n tmp0 += 1\n\n rec = 1\n for k, v in pr.items():\n rec *= k ** (v // 2)\n\n if N <= rec:\n rec = N\n break\n N = rec\n num += tmp0\n\n\nprint(rec, num + 1)\n"}, {"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\n\ndef main():\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 def is_square(x):\n return x**.5 % 1 == 0\n def check(n):\n f=[]\n for j in range(0,1000002):\n i=j*j\n if i>=n and (i-n)%n==0:\n f.append(i)\n return f\n for _ in range(1):\n n=ri()\n op=[]\n f=check(n)\n mi=999999999999999999999999999\n for i in f:\n o=0\n k=i\n while True:\n if is_square(k):\n k=int(math.sqrt(k))\n o+=1\n else:\n break\n op.append([k,o,i])\n ans,operation,p=min(op) \n if p!=n:\n operation+=1\n print(ans,operation) \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \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": "__author__ = 'tanunia'\n\nfrom sys import stdin\nimport math\n\nn = int(stdin.readline())\nnums = {}\n\nend = int(math.sqrt(n))\ntotal_n = n\nfor i in range(2, end):\n while total_n % i == 0:\n if i not in nums:\n nums[i] = 0\n nums[i] += 1\n total_n /= i\nif total_n > 1:\n nums[total_n] = 1\n\n#print(nums)\nmax_pow = 0\nans1 = 1\nfor k in nums.keys():\n ans1 *= k\n if nums[k] > max_pow:\n max_pow = nums[k]\n\npow2 = 1\ncnt = 0\nwhile pow2 < max_pow:\n pow2 *= 2\n cnt += 1\n\nprint(str(int(ans1)) + \" \" + str(cnt + 1))\n\n"}, {"source_code": "# print(2**6*3**4)\n# print(256**0.5)\nfrom math import log\nfrom math import ceil, floor\n\n\ndef next_power_of_two(maxi):\n\n if floor(log(maxi,2)) == ceil(log(maxi, 2)) and maxi != 1:\n power = 0\n while maxi > 1:\n maxi //= 2\n power += 1\n return power\n\n base = 2\n exp = 1\n while base ** exp < maxi:\n # print(base**exp)\n exp += 1\n return exp\n\nfrom collections import defaultdict\nn = int(input())\n\nsieve = [True] * (n+1)\nsieve[0] = False\nsieve[1] = False\nfor i in range(2,int(n**0.5+1)):\n if sieve[i]:\n for j in range(i+i,n+1,i):\n sieve[j] = False\n\nnumber = 1\ntemp = n\nfactors = defaultdict()\ndiv = 2\nif n == 1:\n print(1,0)\n exit(0)\nwhile temp > 1:\n # print(temp)\n if temp % div != 0:\n div += 1\n continue\n temp //= div\n if div not in factors:\n factors[div] = 1\n else:\n factors[div] += 1\n# print(factors)\nops = 0\n\nif len(factors) == 1:\n for k, v in factors.items():\n if k == n:\n print(k,0)\n else:\n power = 2**next_power_of_two(v)\n if v != power:\n ops += 1\n # print(power)\n while power > 1:\n power //= 2\n ops += 1\n print(k, ops)\n exit(0)\n\nmaxi = -1\nfor k,v in factors.items():\n number *= k\n maxi = max(maxi, v)\n# print(factors)\n# print(maxi)\n# for k,v in factors.items():\n# if v != maxi:\n# ops += 1\n# break\n# print(ops)\nif maxi == 1:\n print(number, 0)\nelse:\n # print(maxi)\n # print(ops)\n power = 2**next_power_of_two(maxi)\n # print(power)\n if maxi != power:\n ops += 1\n else:\n for k, v in factors.items():\n if v != maxi:\n ops += 1\n break\n while power > 1:\n power //= 2\n ops += 1\n\n\nprint(number, ops)\n\n\n# 8 4 2 1"}, {"source_code": "#!/usr/bin/env python3\nimport sys\n\n\ndef rint():\n return map(int, sys.stdin.readline().split())\n\n\ndef find_div(n):\n i = 2\n divs = dict()\n\n while i * i <= n:\n cnt = 0\n while n % i == 0:\n cnt += 1\n n //= i\n if cnt:\n divs[i] = cnt\n i += 1\n\n if n != 1:\n divs[n] = 1\n\n return divs\n\n\nn = int(input())\nif n == 1:\n print(1, 0)\n exit()\n\ndiv_dict = find_div(n)\nmax_cnt = 0\nans = 1\ncheck_mul = 0\nfor i in div_dict:\n max_cnt = max(max_cnt, div_dict[i])\n if max_cnt != div_dict[i]:\n check_mul = 1\n ans *= i\nif bin(max_cnt).count(\"1\") != 1:\n check_mul = 1\n\nroot_cnt = max_cnt.bit_length()\nif bin(max_cnt).count(\"1\") == 1:\n root_cnt -= 1\n\nprint(ans, root_cnt + check_mul)\n"}, {"source_code": "n=int(input())\nk=n\ns=dict()\nfor p in range(2,int(n**0.5)+1):\n while(n%p==0):\n if p not in s:\n s.update({p:1})\n else:\n s[p]+=1\n n//=p\nif n>1:\n s.update({n:1})\nsm=1\nfor j in s:\n sm*=j\nm=max(s.values())\np=1\ne=0\nwhile(p 2: \n factors.append(n)\n\nans = 0 \nm = (0, 0)\ncounts = {}\nfor f in set(factors): \n counts[f] = factors.count(f)\n if counts[f] > m[0]: \n m = (counts[f], f)\n\ntry: \n ans += math.ceil(math.log(m[0], 2))\nexcept: \n ans = 0\nl = False\nfor f in set(factors): \n if counts[f] != m[0]: \n ans += 1\n l = True\nif not l and len(set(factors)) > 1:\n ans += 1 \n# print factors\nif not factors: \n factors = [0]\nprint reduce(lambda x, y: x * y, list(set(factors))), int(ans)"}, {"source_code": "from sys import stdin, stdout\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\n\nn = int(stdin.readline())\nmp = {}\n\nd = 2\nwhile d * d <= n:\n while n % d == 0:\n \n if d not in mp:\n mp[d] = 1\n else:\n mp[d] += 1\n \n n //= d\n \n d += 1\n\nif n != 1:\n mp[n] = 1\n\nans = 1\ncnt = 0\ns = set()\n\nfor v in mp:\n ans *= v\n cnt = max(cnt, mp[v])\n s.add(mp[v])\n\nif len(s) > 1:\n label = 1\nelse:\n label = 0\n\nfor i in range(20):\n if (1 << i) >= cnt:\n stdout.write(str(ans) + ' ' + str(label + i) + '\\n')\n break"}, {"source_code": "# print(2**6*3**4)\n# print(256**0.5)\n\n\ndef next_power_of_two(maxi):\n\n base = 2\n exp = 1\n while base ** exp < maxi:\n exp += 1\n # print(exp)\n return exp+1\n\n\n\nfrom collections import defaultdict\nn = int(input())\n\nsieve = [True] * (n+1)\nsieve[0] = False\nsieve[1] = False\nfor i in range(2,int(n**0.5+1)):\n if sieve[i]:\n for j in range(i+i,n+1,i):\n sieve[j] = False\n\nnumber = 1\ntemp = n\nfactors = defaultdict()\ndiv = 2\nif n == 1:\n print(1,0)\n exit(0)\nwhile temp > 1:\n # print(temp)\n if temp % div != 0:\n div += 1\n continue\n temp //= div\n if div not in factors:\n factors[div] = 1\n else:\n factors[div] += 1\n# print(factors)\nops = 0\nif len(factors) == 1:\n for k, v in factors.items():\n if k == n:\n print(k,0)\n else:\n temp = v\n while v > 1:\n ops += 1\n v //= 2\n if temp % 2 == 1:\n ops += 1\n print(k,ops)\n exit(0)\n\nmaxi = -1\nfor k,v in factors.items():\n number *= k\n maxi = max(maxi, v)\n# print(factors)\nif maxi == 1:\n print(number, 0)\nelse:\n # print(maxi)\n\n power = 2**next_power_of_two(maxi)\n\n while power > 1:\n power //= 2\n ops += 1\n\nprint(number, ops)\n\n"}, {"source_code": "import sys\nfrom math import ceil, sqrt, gcd\n\ninput = sys.stdin.readline\n\nn = int(input())\nfactors = {}\n\nwhile True:\n found = False\n for i in range(2, ceil(sqrt(n))):\n if n % i == 0:\n if i not in factors.keys():\n factors[i] = 0\n factors[i] += 1\n n /= i\n found = True\n break\n if not found:\n if n not in factors.keys():\n factors[n] = 0\n factors[n] += 1\n break\n\n\nif n == 1:\n print(\"1 0\")\nelse:\n ans = 0 \n for key in factors.keys():\n ans = max(ans, factors[key]) \n n = 1\n for key in factors.keys():\n n *= key\n print(str(int(n)) + \" \" + str((ans - 1).bit_length() + 1))\n"}, {"source_code": "from math import sqrt, ceil, log2\n\n\ndef factor(n):\n potentional_p = 3\n itog_list = {}\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 > sqrt(n):\n if n in itog_list:\n itog_list[n] += 1\n else:\n itog_list[n] = 1\n return itog_list\n while n % potentional_p == 0:\n n = n // potentional_p\n if potentional_p in itog_list:\n itog_list[potentional_p] += 1\n else:\n itog_list[potentional_p] = 1\n potentional_p += 2\n return itog_list\n\n\nn = int(input())\nF = factor(n)\nans = 1\nma = 0\nmi = 10 ** 9\nfor i in F:\n ans *= i\n ma = max(ma, F[i])\n mi = min(mi, F[i])\nif ma != mi:\n print(ans, 1 + ceil(log2(ma)))\nelse:\n print(ans, ceil(log2(ma)))"}, {"source_code": "from collections import defaultdict\nfrom math import floor,sqrt\nn=int(input())\nd=defaultdict(int)\nfor i in range(2,floor(sqrt(n))+1):\n while n%i==0:\n d[i]+=1\n n//=i\nif n>1:\n d[n]+=1\nif len(d)==1 and d[n]==1:\n print(n,0)\nelse:\n m=0\n for i in d:\n if d[i]>m:\n m=d[i]\n v=i\n if m&1:\n d[v]+=1\n m+=1\n sum=0\n pro=1\n for i in d:\n pro*=i\n print(pro,m//2+1)"}, {"source_code": "n = int(input())\np = [0] * 400\n\nk = 0\nfor i in range(2, 400):\n while n % i == 0:\n n /= i\n p[i] += 1\n\n k = max(k, p[i])\n\nprint(p)\nprint(k)\n\nif k % 2 != 0:\n k += 1\n\nm = 1\nans = k // 2\nfor i in range(2, 400):\n if p[i] > 0:\n if p[i] % k != 0:\n ans += 1\n\n m *= i\n\n\nprint(m, ans)\n\n"}, {"source_code": "import math\ndef primeFactors(n):\n if n%2==0:\n dict1[2]=0\n while n % 2 == 0: \n dict1[2]+=1 \n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2):\n if n%i==0:\n dict1[i]=0\n while n % i== 0: \n dict1[i]+=1\n n = n //i \n if n > 2: \n dict1[n]=0\n dict1[n]+=1\nn=int(input())\nif n==1:\n print(1,0)\nelse:\n dict1={}\n primeFactors(n)\n max1=1\n lst=[]\n for i in dict1:\n lst.append(dict1[i])\n if max(lst)==min(lst) and max(lst)==1:\n print(n,0)\n elif max(lst)==min(lst):\n prod=1\n for i in dict1:\n prod*=i\n print(prod,math.ceil(math.log2(max(lst))))\n else:\n prod=1\n for i in dict1:\n prod*=i\n print(prod,math.ceil(math.log2(max(lst)))+1)"}, {"source_code": "#https://codeforces.com/contest/1062/problem/B\n\nfrom math import sqrt\n\ndef resolve(x):\n \"\"\"Fun\u00e7\u00e3o que efetivamente resolve o problema.\"\"\"\n\n fatores = fatoraInt(x)\n\n contOperacao = 0\n minimo = 1\n cont = 0\n for i in fatores:\n minimo = minimo * i[0]\n if(i[1] == 1):\n cont = cont + 1\n\n if(cont == len(fatores)):\n return (minimo, contOperacao)\n else:\n flag = 0\n maximo = fatores[0][1]\n for i in fatores[1:]:\n if(i[1] > maximo):\n maximo = i[1]\n else:\n flag = 1\n \n if(flag == 1 or maximo % 2 != 0):\n contOperacao = 1 + int(maximo/2)\n else:\n contOperacao = int(maximo/2)\n\n return (minimo, contOperacao) \n \n \n\ndef fatoraInt(x):\n \"\"\"Fatora um n\u00famero inteiro\n\n A fun\u00e7\u00e3o encontra os n\u00fameros primos que compoem x.\n O resultado \u00e9 retornado em uma lista. A lista contem\n cada fator e o n\u00famero de vezes q ele aparece.\n \"\"\"\n\n fatores = []\n cont = 0\n aux = x\n \n while(x % 2 == 0):\n x = x / 2\n cont = cont + 1\n if(cont != 0):\n fatores.append([2, cont])\n\n cont = 0\n for i in range(3, int(sqrt(aux)) + 2, 2):\n cont = 0\n if(x % i == 0 and isPrimo(i)):\n while(x % i == 0):\n cont = cont + 1\n x = x / i\n \n fatores.append([i,cont])\n if(int(x) != 1):\n fatores.append([int(x), 1])\n \n return fatores \n \ndef isPrimo(p):\n \"\"\"Diz se um inteiro p \u00e9 primo.\n\n Retorna True caso seja primo e False caso contrario.\n \"\"\"\n\n if(p == 2):\n return True;\n elif(p % 2 == 0):\n return False;\n else:\n for i in range(3, int(sqrt(p)) + 2, 2):\n if( p % i == 0 ):\n return false\n\n return True\n \n\n\n\nn = int(input())\nminimo, contOp = resolve(n)\n\nprint(str(minimo) + \" \" + str(contOp))\n"}, {"source_code": "from __future__ import division\nfrom collections import deque, defaultdict, Counter\nfrom math import *\n\n\ndef count_prime(n):\n for i in range(2, n):\n if not prim[i]:\n for j in range(i, n, i):\n prim[j] = i\n\n for i in range(1, n):\n if not prim[i]:\n prim[i] = i\n\n\ndef prime_factor(x):\n fac = []\n while x > 1:\n div = prim[x]\n fac.append(div)\n x //= div\n return fac\n\n\nn, ans, N = int(input()), [1, 0], 10 ** 6 + 1\nprim = [0] * (N)\ncount_prime(N)\nmem = Counter(prime_factor(n))\nma = max(mem.values())\n\nfor i, j in mem.items():\n ans[0] *= i\n if j != ma:\n ans[1] = 1\n\nans[1] += int(ceil((log(ma, 2))))\nprint(' '.join(map(str, ans)))\n"}, {"source_code": "from sys import stdin, stdout\nfrom math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial\n\nn = int(stdin.readline())\nmp = {}\n\nd = 2\nwhile d * d <= n:\n while n % d == 0:\n \n if d not in mp:\n mp[d] = 1\n else:\n mp[d] += 1\n \n n //= d\n \n d += 1\n\nif n != 1:\n mp[n] = 1\n\nans = 1\ncnt = 0\ns = set()\n\nfor v in mp:\n ans *= v\n cnt = max(cnt, mp[v])\n s.add(mp[v])\n\n\nfor i in range(20):\n if (1 << i) == cnt and len(s) == 1:\n stdout.write(str(ans) + ' ' + str(i) + '\\n')\n break\n \n if (1 << i) >= cnt:\n stdout.write(str(ans) + ' ' + str(1 + i) + '\\n')\n break"}, {"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\nfrom itertools import permutations \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\n\ndef primefactor(n): \n d=dict()\n while n % 2 == 0: \n if 2 in d:\n d[2]+=1\n else:\n d[2]=1 \n n = int(n / 2)\n \n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n if i in d:\n d[i]+=1\n else:\n d[i]=1\n n = int(n / i)\n \n if n > 2: \n if n in d:\n d[n]+=1\n else:\n d[n]=1\n return d\n \n\n\ndef main():\n n=ii()\n res=primefactor(n)\n print(math.prod(list(res.keys())))\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": "n = int(raw_input())\n\ni = 2\na = []\nb = []\nwhile i * i <= n:\n\tif n % i == 0:\n\t\tcnt = 0\n\t\twhile n % i == 0:\n\t\t\tcnt += 1\n\t\t\tn //= i\n\t\tb.append(i)\n\t\ta.append(cnt)\n\ti += 1\nif n > 1:\n\ta.append(1)\n\tb.append(n)\n\nret = 1\nfor x in b:\n\tret *= x\nq = max(a)\n\nif q == 1:\n\tprint ret, 0\n\texit(0)\n\nans = 1\nwhile (q & (q - 1)) > 0:\n\tq += 1\nwhile q > 1:\n\tans += 1\n\tq //= 2\nprint ret, ans"}, {"source_code": "import math\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\nT = PrimeList(10**3)\nD = {}\nfor i in T:\n while n % i == 0:\n if i in D:\n D[i] += 1\n else:\n D[i] = 1\n n = int(n/i)\nif len(D) == 0:\n print(n,0)\nelse:\n P = 1\n for i in D:\n P *= i\n L = [i for i in D.values()]\n ma = max(L)\n mi = min(L)\n l = int(math.log(ma,2))\n if ma == 2**l:\n if mi == ma:\n print(P,l)\n else:\n print(P,l+1)\n else:\n print(P,l+2)"}, {"source_code": "import math\nfrom collections import defaultdict\nimport functools\n\nprimes = [2]\nN = 1001\n\ndef generate_primes():\n for i in range(2, N):\n isPrime = True\n sqr = math.ceil(math.sqrt(i))\n for p in primes:\n if i % p == 0:\n isPrime = False\n break\n if p > sqr:\n break \n if isPrime:\n primes.append(i)\n\ndef find_factors(n):\n prime_counter = 0\n prime_dict = defaultdict(int)\n while n > 1:\n while n > 1 and n % primes[prime_counter] == 0:\n n = n // primes[prime_counter]\n prime_dict[primes[prime_counter]] += 1\n prime_counter += 1\n return prime_dict\n\ndef get_num_steps(arr):\n def find_power(mx):\n two_power = 1\n i = 0\n while two_power < mx:\n two_power *= 2\n i += 1\n return i\n \n mx = arr[0]\n all_equal = True\n for i in range(1, len(arr)):\n mx = max(mx, arr[i])\n if arr[i] != arr[i-1]:\n all_equal = False\n if all_equal: #all equal\n return find_power(mx)\n return find_power(mx)+1\n \n\ndef solution(n):\n generate_primes()\n prime_dict = find_factors(n)\n max_power = get_num_steps(list(prime_dict.values()))\n return functools.reduce(lambda x, y:x*y, prime_dict.keys(), 1), max_power\n\nn = int(input())\nif n == 1:\n print(1, 0)\nelse:\n print(*solution(n))\n"}, {"source_code": "n = int(input())\nif n == 1:\n print(1)\n exit()\ncnts = []\ni = 2\nresult = 1\nwhile i * i <= n:\n if n % i == 0:\n result *= i\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n cnts.append(c)\n i += 1\nif n > 1:\n cnts.append(1)\n result *= n\nm = 0\nif not (cnts.count(cnts[0]) == len(cnts) and cnts[0] & (cnts[0] - 1) == 0):\n m += 1\n d = max(cnts)\n r = 1\n while r < d:\n r <<= 1\n m += 1\nelse:\n d = max(cnts)\n while d != 1:\n m += 1\n d >>= 1\nprint(result, m)\n \n"}, {"source_code": "from collections import defaultdict\nfrom math import floor,sqrt\nn=int(input())\nd=defaultdict(int)\nfor i in range(2,floor(sqrt(n))+1):\n while n%i==0:\n d[i]+=1\n n//=i\nif n>1:\n d[n]+=1\nm=0\nfor i in d:\n if d[i]>m:\n m=d[i]\n v=i\nif m&1:\n d[v]+=1\nm+=1\nsum=0\npro=1\nfor i in d:\n pro*=i\nprint(pro,m//2+1)"}, {"source_code": "# print(2**6*3**4)\n# print(256**0.5)\n\n\ndef next_power_of_two(maxi):\n\n base = 2\n exp = 1\n while base ** exp < maxi:\n exp += 1\n # print(exp)\n return exp+1\n\n\n\nfrom collections import defaultdict\nn = int(input())\n\nsieve = [True] * (n+1)\nsieve[0] = False\nsieve[1] = False\nfor i in range(2,int(n**0.5+1)):\n if sieve[i]:\n for j in range(i+i,n+1,i):\n sieve[j] = False\n\nnumber = 1\ntemp = n\nfactors = defaultdict()\ndiv = 2\nif n == 1:\n print(1,0)\n exit(0)\nwhile temp > 1:\n # print(temp)\n if temp % div != 0:\n div += 1\n continue\n temp //= div\n if div not in factors:\n factors[div] = 1\n else:\n factors[div] += 1\n# print(factors)\nops = 0\n\nif len(factors) == 1:\n for k, v in factors.items():\n if k == n:\n print(k,0)\n else:\n power = 2**next_power_of_two(v)\n while power > 1:\n power //= 2\n ops += 1\n print(k, ops)\n exit(0)\n\nmaxi = -1\nfor k,v in factors.items():\n number *= k\n maxi = max(maxi, v)\n# print(factors)\nif maxi == 1:\n print(number, 0)\nelse:\n # print(maxi)\n\n power = 2**next_power_of_two(maxi)\n\n while power > 1:\n power //= 2\n ops += 1\n\nprint(number, ops)\n\n"}, {"source_code": "from collections import defaultdict as dif \ndic=dif(lambda:0)\nx=int(input())\nif x==1:\n print(0,0)\n exit(0)\n\nwhile x%2==0:\n dic[2]+=1\n x//=2\n\nmx=dic[2]\n\nn=3\nwhile n*n<=x:\n while x%n==0:\n dic[n]+=1\n x//=n\n mx=max(mx,dic[n])\n n+=2\nif x>1:\n dic[x]=1\n mx=max(1,mx)\nfrom math import log2,ceil\nlg =ceil(log2(mx))\nmxt=1< 2: \n l.append(n)\n return l\nl1={}\np=1\ni=0\nwhile p<20000000:\n l1[p]=i\n i+=1\n p*=2\n\nn=input()\nif n==1:\n print 0\n exit()\nl=primeFactors(n)\nd=Counter(l)\nans1=1\nfor i in d.keys():\n ans1*=i\nmx=max(d.values())\nf=0\ntry:\n \n if l1[mx]>=0:\n max_pow=mx\n step=l1[mx]\n \n \nexcept:\n f=1\n step=len(bin(mx)[2:])\n max_pow=2**step\n\nfor i in d.keys():\n #print d[i],max_pow\n if d[i] 1:\n rasl.append(n)\n return (rasl)\ndef sled_st_dv(n):\n temp=0\n while pow(2,temp)1:\n return (0)\n return(-1)\nfact=factor(n)\nsett=set(fact)\nfor i in fact:\n if i in sl_vhoshd:\n sl_vhoshd[i]+=1\n else:\n sl_vhoshd[i]=1\n#print(sl_vhoshd)\n#print(proverka1(sl_vhoshd,n))\ntemp+=sled_st_dv(max(sl_vhoshd.values()))+proverka1(sl_vhoshd,n)\nprint(len(set(sl_vhoshd.values())))\nprint(proisv(sett),temp)\n\n"}, {"source_code": "n = int(input())\nres = 1\nt = n\nL = []\nfor i in range(2,t+1):\n if n % i == 0:\n res *= i\n c = 0\n while n % i == 0:\n n //= i\n c += 1\n if c > 0:\n L.append(c)\n if n == 1:\n break\nl = len(L)\na = []\nma = 0\nfor i in range(l):\n c = 0\n k = L[i]\n while k:\n k //= 2\n c += 1\n if L[i] % 2**(c-1) == 0:\n a.append(c-1)\n ma = max(c-1,ma)\n else:\n a.append(c)\n ma = max(c,ma)\nif len(set(a)) == 1 and (L[0] % (2**(ma))) == 0:\n print(res,ma)\nelse:\n print(res,ma+1)"}, {"source_code": "import math\nmul2 = [2**x for x in range(2,7)]\nn = int(input())\nfacto = [0]*1000001\nans = 1\ncnt = 0\nfor i in range(2,math.ceil(n/2)+1):\n if n % i == 0:\n while n % i == 0:\n facto[i] += 1\n n //= i\n ans *= i\n cnt += 1\nm = max(facto)\nif m == 0:\n print(n,0)\nelif m == 1:\n print(ans,0)\nelif m == 2:\n print(ans,2)\nelse:\n mi = 64\n lim = 0\n for each in mul2:\n if each-m >= 0 and each-m <= mi:\n mi = abs(m - each)\n lim = each\n times = int(math.log(lim,2)) if (cnt==1 and lim == m) else int(math.log(lim,2))+1\n print(ans,times)\n"}, {"source_code": "from __future__ import division\nfrom collections import deque, defaultdict, Counter\nfrom math import *\n\n\ndef count_prime(n):\n for i in range(2, n):\n if not prim[i]:\n for j in range(i, n, i):\n prim[j] = i\n\n for i in range(1, n):\n if not prim[i]:\n prim[i] = i\n\n\ndef prime_factor(x):\n fac = []\n while x > 1:\n div = prim[x]\n fac.append(div)\n x //= div\n return fac\n\n\nispow2 = lambda x: x and (not (x & (x - 1)))\nn, ans, N = int(input()), [1, 0], 10 ** 6 + 1\nif n == 1:\n print('0 0')\n exit()\n \nprim = [0] * (N)\ncount_prime(N)\nmem = Counter(prime_factor(n))\nma = max(mem.values())\n\nfor i, j in mem.items():\n ans[0] *= i\n if j != ma:\n ans[1] = 1\n\nif not ispow2(ma):\n ans[1] = 1\n\nans[1] += int(ceil((log(ma, 2))))\nprint(' '.join(map(str, ans)))\n"}, {"source_code": "from math import log2, ceil\n\nn = int(input())\ndivis = set()\ni = 2\nactions = 0\nset_cnt = set()\nn_copy = n\nwhile i * i <= n:\n cnt = 0\n if n_copy % i == 0:\n divis.add(i)\n while n_copy % i == 0:\n n_copy //= i\n cnt += 1\n if cnt != 0:\n num = ceil(log2(cnt))\n set_cnt.add(cnt)\n actions = max(actions, num)\n i += 1\nif n_copy > 1:\n divis.add(n_copy)\n actions = max(actions, 0)\n set_cnt.add(1)\nans = 1\nfor elem in divis:\n ans *= elem\nif len(set_cnt) != 1:\n actions += 1\nprint(ans, actions)\n"}, {"source_code": "import math \nfrom collections import Counter \n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n): \n l=[]\n # Print the number of two's that divide n \n while n % 2 == 0: \n #print 2, \n l.append(2)\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 #print i, \n l.append(i)\n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n l.append(n)\n return l\nl1={}\np=1\ni=0\nwhile p<200000000:\n l1[p]=i\n i+=1\n p*=2\n\nn=input()\nif n==1:\n print 0\n exit()\nl=primeFactors(n)\nd=Counter(l)\nans1=1\nfor i in d.keys():\n ans1*=i\nmx=max(d.values())\nf=0\ntry:\n \n \n max_pow=mx\n step=l1[mx]\n \n \nexcept:\n f=1\n step=len(bin(mx)[2:])\n max_pow=2**step\n\nfor i in d.keys():\n #print d[i],max_pow\n if d[i]2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n\n steps = 0 \n\n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1:\n \n print(n, 0)\n return\n\n # print(dictionary, math_log)\n if max_power == 2:\n steps = 2\n elif all(list(map(lambda x: int(math.log(x, 2)) * 2 == x, dictionary.values()))):\n steps = int(math_log) \n else:\n steps = int(math_log) + 1 +1 \n\n #print(value, steps)\n print(\" \".join([str(int(value)), str(steps)]))\n\n\nB1062(int(input()))\n"}, {"source_code": "from collections import defaultdict\nimport math\ndef getPrimeFactors(n):\n factors = []\n while n%2==0:\n factors.append(2)\n n = n//2\n k=3\n while k*k <= n:\n if n%k==0:\n n= n//k\n factors.append(k)\n else:\n k+=2\n if n>1:\n factors.append(n)\n return factors\nn = int(input())\ncounts = defaultdict(int)\nfor a in getPrimeFactors(n):\n counts[a]+=1\nk = list(counts.values())[0]\nno = 1\nnotsame = False\nfor a,cnt in counts.items():\n no *= a\n if k!=cnt:\n notsame = True\n k = max(k,cnt)\n\nmoves = math.ceil(math.log2(k))\nif moves != k and moves!=0: notsame = True\nif notsame:\n moves+=1\nprint(f\"{no} {moves}\")"}, {"source_code": "n = int(input())\nn1 = n\nans = 1\nmaxcnt = 0\nflag = 0\nfor i in range(2,n1 + 1):\n\tif i > n:\n\t\tbreak\n\tif n % i == 0:\n\t\tans *= i\n\t\tcnt = 0\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\t\t\tcnt += 1\n\t\tif cnt != maxcnt and maxcnt > 0:\n\t\t\tflag = 1\n\t\tif cnt > maxcnt:\n\t\t\tmaxcnt = cnt\n\nmyb = [1, 2, 4, 8, 16, 32]\n\nif maxcnt not in myb:\n\tflag = 1\n\nfor i in range(len(myb)):\n\tif myb[i] >= maxcnt:\n\t\tanscnt = i\n\t\tbreak\n\t\n\nprint(ans, anscnt + flag)\n\t"}, {"source_code": "import math\n# https://codeforces.com/problemset/problem/1062/B\ndef B1062(n):\n initial_value = n \n dictionary = dict()\n if n == 1: \n print(n, 0)\n return\n value = 1 \n while (n % 2 == 0):\n dictionary[2] = 1 + dictionary.get(2, 0)\n n = n/2\n value = 2\n\n for prime in range(3, int(math.sqrt(n))+1, 2):\n found_prime = False\n while n % prime == 0:\n dictionary[prime] = dictionary.get(prime, 0) + 1\n n = n/prime\n if not found_prime:\n value *= prime\n found_prime = True\n\n if (n>2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n\n steps = 0 \n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1:\n \n print(initial_value, 0)\n return\n \n print(dictionary)\n if max_power == 2:\n steps = 2\n elif all(list(map(lambda x: x != 1 and int(math.log(x, 2)) == math.log(x,2), dictionary.values()))):\n steps = int(math_log) \n else:\n if int(math_log) == math_log: # max power is squared\n # we add one for the \"squaredfication\"\n steps = int(math_log) +1\n else:\n steps = int(math_log) + 1 + 1\n\n #print(value, steps)\n print(\" \".join([str(int(value)), str(steps)]))\n\n\n# B1062(int(input()))\n"}, {"source_code": "n = int(input())\nfactors = {}\nmindegree = float(\"inf\")\nmaxdegree = 0\nanswer = 1\n\nfor x in range(2, int(n ** 0.5) + 1):\n if n == 1: break\n multiplicity = 0\n while n % x == 0:\n n = n // x\n multiplicity += 1\n if multiplicity:\n answer *= x\n #factors[x] = multiplicity\n mindegree = min(mindegree, multiplicity)\n maxdegree = max(maxdegree, multiplicity)\n\nif n != 1:\n #factors[n] = 1\n answer *= n\n mindegree = min(mindegree, 1)\n maxdegree = max(maxdegree, 1)\n\ndeg = 0\nwhile 2 ** deg < maxdegree:\n deg += 1\n\nresult = deg + 1\nif 2 ** deg == maxdegree == mindegree:\n result -= 1\nprint(answer, result)\n"}, {"source_code": "import math\nn = int(input())\nout = 0\nwhile n>1:\n rv = n ** 0.5\n rv1 = round(n ** (1/3))\n if math.floor(rv) == math.ceil(rv):\n n = int(rv)\n out += 1\n elif rv1**3 == n:\n n = n//math.floor(rv1)\n out += 2\n elif n%4 == 0:\n n//=2\n out+=2\n elif n%2 == 0:\n v = n//2\n rv = v**0.5\n if math.floor(rv)==math.ceil(rv):\n n = 2*int(rv)\n out+=2\n else:\n break\n else:\n break\nprint(n,out)"}, {"source_code": "n = int(input())\np = [0] * 400\n\nk = 0\nfor i in range(2, 400):\n while n % i == 0:\n n /= i\n p[i] += 1\n\n k = max(k, p[i])\n\nif k % 2 != 0:\n k += 1\n\nm = 1\nans = k // 2\nfor i in range(2, 400):\n if p[i] > 0:\n if p[i] % k != 0:\n ans += 1\n\n m *= i\n\n\nprint(m, ans)\n\n"}, {"source_code": "N = int(input())\nprime_factors = {}\n\ni = 2\nwhile True: \n if i*i > N:\n if N in prime_factors:\n prime_factors[N] += 1\n else:\n prime_factors[N] = 1\n break\n \n if N%i == 0: # factors are necessarily prime numbers\n if i in prime_factors:\n prime_factors[i] += 1\n else:\n prime_factors[i] = 1\n \n N //= i\n continue\n \n i += 1\n \n\nans1 = 1\nfor prime in prime_factors.keys():\n ans1 *= prime\n\nans2 = 0\nwhile (1 << ans2) < max(prime_factors.values()):\n ans2 += 1\nans2 += 1 # Assuming that flattening is a given.\n \ntemp = list(prime_factors.values())\nfor num in prime_factors.values():\n if temp != num: break\nelse:\n while temp%2 == 0:\n temp //= 2\n if temp == 1:\n ans2 -= 1\n \nprint(ans1, ans2)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jun 8 10:08:27 2019\n\n@author: plosi\n\"\"\"\n\ndef issame(arr,m): \n for i in range(len(arr)):\n if arr[i]!=m: \n return False \n return True \n\ndef SOE(n): \n p=2\n global ps\n primes=[True for i in range(n+1)]\n primes[0]=False \n primes[1]=False \n while p<=n**(0.5):\n cur=p\n cur=cur+p \n while cur<=n: \n \n primes[cur]=False \n cur=cur+p\n p=p+1\n while not primes[p]: \n p=p+1\n ps=[i for i in range(len(primes)) if primes[i]] \n global pset\n pset=set(ps)\n\ndef fact(n): \n val=ps[0]\n bs=[]\n fs=[]\n ct=0 \n if n in pset: \n return (n,0) \n \n while n>1:\n if n%val==0: \n a=1 \n n=int(n/val)\n bs.append(val)\n while n%val==0: \n n=n/val\n a=a+1\n fs.append(a)\n ct=ct+1\n val=ps[ct] \n m=max(fs) \n p=1 \n for val in bs: \n p=p*val\n if m%2==0: \n if issame(fs,m): \n ct=int(m/2) \n else: \n ct=1+int(m/2)\n else: \n m=m+1\n ct=1+int(m/2) \n return (p,ct) \n\ndef main(): \n n=int(input()) \n SOE(n)\n p,ct=fact(n) \n print(str(p)+\" \"+str(ct))\nmain()\n \n \n \n "}, {"source_code": "import math\nmul2 = [2**x for x in range(1,7)]\nn = int(input())\nncopy = n\nfacto = [0]*1000001\nans = 1\ncnt = 0\n\nfor i in range(2,math.ceil(n/2)+1):\n if n % i == 0:\n while n % i == 0:\n facto[i] += 1\n n //= i\n ans *= i\n cnt += 1\nm = max(facto)\nif ncopy ** .5 == ans:\n print(ans,1)\nelif m == 0:\n print(n,0)\nelif m == 1:\n print(ans,0)\nelse:\n mi = 64\n lim = 0\n for each in mul2:\n if each-m >= 0 and each-m <= mi:\n mi = abs(m - each)\n lim = each\n times = int(math.log(lim,2)) if (cnt==1 and lim == m) else int(math.log(lim,2))+1\n print(ans,times)\n\n"}, {"source_code": "from sys import stdin\nn=int(stdin.readline().strip())\nif n==1:\n print(1,0)\n exit(0)\nv=[[]]\nN=10**25+1\nfor i in range(2,(n+2)//2):\n x=i**0.5\n if x!=int(x):\n v.append([])\n x=i\n while x<=N:\n v[-1].append(x)\n x*=x\nans=0\naux=n**0.5\nwhile aux==int(aux):\n ans+=1\n n=int(aux)\n aux=n**0.5\nt=False\nfor i in v:\n for j in i:\n if j%n==0:\n print(j,n)\n if j!=n:\n ans+=1\n t=True\n break\n if t:\n break\nif t:\n aux=j**0.5\n while aux==int(aux):\n ans+=1\n j=int(aux)\n aux=j**0.5\nelse:\n j=n\nprint(int(j),ans)\n \n"}, {"source_code": "from sys import stdin\nn=int(stdin.readline().strip())\nif n==1:\n print(1,0)\n exit(0)\nv=[[]]\nN=10**25+1\nfor i in range(2,(n+2)//2):\n x=i**0.5\n if x!=int(x):\n v.append([])\n x=i\n while x<=N:\n v[-1].append(x)\n x*=x\nans=0\naux=n**0.5\nwhile aux==int(aux):\n ans+=1\n n=int(aux)\n aux=n**0.5\nt=False\nfor i in v:\n for j in i:\n if j%n==0:\n print(j,n)\n if j!=n:\n ans+=1\n t=True\n break\n if t:\n break\nif t:\n aux=j**0.5\n while aux==int(aux):\n ans+=1\n j=int(aux)\n aux=j**0.5\nelse:\n j=n\nprint(int(j),ans)\n \n"}, {"source_code": "from collections import Counter\nimport math\nn = int(input())\ndef getFactors(x):\n f = []\n if x == 1:\n return [1]\n j = 2\n while x >= 2:\n if x % j == 0:\n f.append(j)\n x = x // j\n else:\n j += 1\n return f\nc = Counter(getFactors(n))\nminm = 1\nfor x in c:\n minm *= x\nmaxm = max(c.values())\ni = 0\nf = 1\nwhile maxm > f:\n i += 1\n f *= 2\nif maxm == 1 or (len(c) == 1 and i == 0):\n ans = i\nelse:\n ans = i + 1\nprint(minm, ans)"}, {"source_code": "import math\n# https://codeforces.com/problemset/problem/1062/B\ndef B1062(n):\n initial_value = n \n dictionary = dict()\n if n == 1: \n print(n, 0)\n return\n value = 1 \n while (n % 2 == 0):\n dictionary[2] = 1 + dictionary.get(2, 0)\n n = n/2\n value = 2\n\n for prime in range(3, int(math.sqrt(n))+1, 2):\n found_prime = False\n while n % prime == 0:\n dictionary[prime] = dictionary.get(prime, 0) + 1\n n = n/prime\n if not found_prime:\n value *= prime\n found_prime = True\n\n if (n>2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n\n steps = 0 \n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1:\n \n print(initial_value, 0)\n return\n \n print(dictionary)\n if max_power == 2:\n steps = 2\n elif all(list(map(lambda x: x != 1 and int(math.log(x, 2)) == math.log(x,2), dictionary.values()))):\n steps = int(math_log) \n else:\n if int(math_log) == math_log: # max power is squared\n # we add one for the \"squaredfication\"\n steps = int(math_log) +1\n else:\n steps = int(math_log) + 1 + 1\n\n #print(value, steps)\n print(\" \".join([str(int(value)), str(steps)]))\n\n\nB1062(int(input()))\n"}, {"source_code": "n = int(input())\ni = 2\nfactors = {1}\nwhile i * i <= n:\n if n % i:\n i += 1\n else:\n n //= i\n factors.add(i)\nif n > 1:\n factors.add(n)\nresult = 1\nfor x in factors:\n result *= x\nprint(result)\n"}, {"source_code": "import collections\nimport math\nimport sys\ndef isPowerOfTwo (x): \n return (x and (not(x & (x - 1))))\ndef primefactors(n):\n\td = collections.defaultdict(int) \n\twhile n%2 == 0:\n\t\td[2]+=1\n\t\tn/=2\n\tfor i in range(3, int(n**0.5)+1, 2):\n\t\twhile n%i==0:\n\t\t\td[i]+=1\n\t\t\tn/=i\n\tif n > 2:\n\t\td[n]+=1\n\treturn d\nn = int(input())\nif n == 1:\n\tprint(1, 0)\n\tsys.exit()\nx = primefactors(n)\ny = max(x.values())\nz = x.keys()\nk = 1\nfor i in z:\n\tk*=i\nif y == 1 or y == 0:\n\tprint(int(k), 0)\nelse:\n\tif y%2 == 0:\n\t\tprint(int(k), math.ceil(math.log(y, 2)))\n\telse:\n\t\tprint(int(k), math.ceil(math.log(y, 2))+1)"}, {"source_code": "import math\ndef prime(k):\n if k==1:\n return False\n w=int(math.sqrt(k))+1\n for i in range(2,w):\n if k%i==0:\n return False\n return True\ndef div(n):\n ans=[]\n i=1\n while(i<=math.sqrt(n)):\n if n%i==0:\n if n/i==i:\n if prime(i):\n ans.append(i)\n else:\n if prime(i):\n ans.append(i)\n if prime(n//i):\n ans.append(n//i)\n i+=1\n return ans\nt=int(input())\nif t==1:\n print(1,0)\nelse:\n \n d=dict()\n q=div(t)\n for i in range(len(q)):\n while(t%q[i]==0 and t>1):\n if q[i] in d:\n d[q[i]]+=1\n else:\n d[q[i]]=1\n t=t//q[i]\n val=max(d.values())\n ans=1\n for i in d.keys():\n ans*=i\n \n if val&(val-1)==0:\n val2=int(math.log(val,2))\n \n else:\n val2=int(math.log(val,2))+1\n\n if len(set(d.values()))==1:\n print(ans,val2)\n else:\n print(ans,val2+1)\n \n \n \n \n"}, {"source_code": "import math\nimport copy\n\nmemo = {}\ndef fish(n):\n if n in memo:\n return memo[n]\n if n == 1:\n return 1, 0\n ans = [n, -1]\n for i in range(1, n):\n new_n = n * i\n sq = int(math.sqrt(new_n))\n if sq * sq == new_n:\n ans = fish(sq)\n break\n ans[1] = max(ans[1], 0)\n memo[n] = copy.deepcopy(ans)\n return ans\n\n\nn = int(input())\nans = fish(n)\nprint(f'{ans[0]} {ans[1]}')"}, {"source_code": "import math\nimport copy\n\nmemo = {}\ndef fish(n):\n if n in memo:\n return memo[n]\n if n == 1:\n return 1, 0\n ans = [n, -1]\n for i in range(1, n):\n new_n = n * i\n sq = int(math.sqrt(new_n))\n if sq * sq == new_n:\n ans = fish(sq)\n break\n ans[1] = max(ans[1], 0)\n memo[n] = copy.deepcopy(ans)\n return ans\n\n\nn = int(input())\nans = fish(n)\nprint(f'{ans[0]} {ans[1]}')"}, {"source_code": "n = int(input())\nfactors = {}\nmindegree = float(\"inf\")\nmaxdegree = 0\nanswer = 1\n\nfor x in range(2, int(n ** 0.5) + 1):\n if n == 1: break\n multiplicity = 0\n while n % x == 0:\n n = n // x\n multiplicity += 1\n if multiplicity:\n answer *= x\n #factors[x] = multiplicity\n mindegree = min(mindegree, multiplicity)\n maxdegree = max(maxdegree, multiplicity)\n\nif n != 1:\n #factors[n] = 1\n answer *= n\n mindegree = min(mindegree, 1)\n maxdegree = max(maxdegree, 1)\n\ndeg = 0\nwhile 2 ** deg < maxdegree:\n deg += 1\n\nresult = deg + 1\nif 2 ** deg == maxdegree == mindegree:\n result -= 1\nprint(answer, result)\n"}, {"source_code": "from math import log2, sqrt\n\ndef main():\n n = int(input())\n d = {}\n cur = n\n for i in range(2, int(sqrt(n)) + 2):\n while cur % i == 0:\n t = d.get(i, 0) + 1\n d[i] = t\n cur //= i\n if cur != 1:\n d[cur] = 1\n if d == {} or max(d.values()) == 1:\n return print(n, 0)\n cur = []\n for k in d:\n cur.append(log2(d[k]))\n f = True\n g = True\n ans = -1\n for k in cur:\n if k - int(k) != 0 and f:\n f = False\n elif k == 0 and g:\n g = False\n ans = max(ans, int(k))\n ans_1 = 1\n for k in d:\n ans_1 *= k\n if not f and g:\n return print(ans_1, ans + 2)\n if f and not g:\n return print(ans_1, ans + 1)\n return print(ans_1, ans)\n \n \nif __name__==\"__main__\":\n main()\n\n"}, {"source_code": "# \nimport collections, atexit, math, sys, bisect \n\nsys.setrecursionlimit(1000000)\ndef getIntList():\n return list(map(int, input().split())) \n\ntry :\n #raise ModuleNotFoundError\n import numpy\n def dprint(*args, **kwargs):\n #print(*args, **kwargs, file=sys.stderr)\n # in python 3.4 **kwargs is invalid???\n print(*args, file=sys.stderr)\n dprint('debug mode')\nexcept Exception:\n def dprint(*args, **kwargs):\n pass\n\n\n\ninId = 0\noutId = 0\nif inId>0:\n dprint('use input', inId)\n sys.stdin = open('input'+ str(inId) + '.txt', 'r') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\nif outId>0:\n dprint('use output', outId)\n sys.stdout = open('stdout'+ str(outId) + '.txt', 'w') #\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u81f3\u6587\u4ef6\n atexit.register(lambda :sys.stdout.close()) #idle \u4e2d\u4e0d\u4f1a\u6267\u884c atexit\n \nN, = getIntList()\n#print(N)\nre = 1\nmc = 1\nfor i in range(2, 10000):\n if N%i != 0 : continue\n re *= i\n c = 0\n while N%i==0:\n N//=i\n c+=1\n mc = max(mc,c)\nif N>0:\n re*=N\n\nt =1 \nfor i in range(100):\n if mc<=t:\n break\n t*=2\n\nif i==0:\n g = 0\nelse:\n g = i +1\n\nprint(re,g)\n\n\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# Python3 program to find prime factorization\n# of a number n in O(Log n) time with\n# precomputation allowed.\nimport math as mt\n\nMAXN = 1000001\n\n# stores smallest prime factor for\n# every number\nspf = [0 for i in range(MAXN)]\n\n# Calculating SPF (Smallest Prime Factor)\n# for every number till MAXN.\n# Time Complexity : O(nloglogn)\ndef sieve():\n spf[1] = 1\n for i in range(2, MAXN):\n\n # marking smallest prime factor\n # for every number to be itself.\n spf[i] = i\n\n # separately marking spf for\n # every even number as 2\n for i in range(4, MAXN, 2):\n spf[i] = 2\n\n for i in range(3, mt.ceil(mt.sqrt(MAXN))):\n\n # checking if i is prime\n if (spf[i] == i):\n\n # marking SPF for all numbers\n # divisible by i\n for j in range(i * i, MAXN, i):\n\n # marking spf[j] if it is\n # not previously marked\n if (spf[j] == j):\n spf[j] = i\n\n # A O(log n) function returning prime\n# factorization by dividing by smallest\n# prime factor at every step\ndef getFactorization(x):\n ret = list()\n while (x != 1):\n ret.append(spf[x])\n\n x = x // spf[x]\n\n\n\n return ret\n\n\nn = int(input())\n\n\nsieve()\nz = getFactorization(n)\nhash = defaultdict(int)\n\nfor i in z:\n hash[i]+=1\nans = 1\nmaxi = 0\nflag = 1\nseti = set()\nfor i in hash:\n ans*=i\n maxi = max(maxi,ceil(log2(hash[i])))\n seti.add(ceil(log2(hash[i])))\n\n\nif len(seti) == 1:\n flag = 0\n\n\n\n\nprint(ans,maxi+flag)\n\n\n\n\n\n\n\n\n"}, {"source_code": "import math\n\ndef myf(n):\n\tif n==1:\n\t\treturn [(1,1)]\n\ta = list()\n\tfor i in range(2,n+1):\n\t\tif n%i == 0:\n\t\t\tcount = 0\n\t\t\twhile n%i == 0:\n\t\t\t\tn /= i\n\t\t\t\tcount += 1\n\t\t\ta.append((i,count))\n\treturn a\n\nn = int(input())\ns = -1\nx = myf(n)\nh = True\n\n#print(x)\n\nfor i in range(1,len(x)):\n\tif x[i][1] != x[i-1][1]:\n\t\th = False\n\nif h:\n\tif x[0][1] & (x[0][1]-1) == 0:\n\t\ts = math.log2(x[0][1])\n\telse:\n\t\tmym = x[0][1]\n\t\tif mym & (mym-1) != 0:\n\t\t\ts = 0\n\t\twhile mym != 0:\n\t\t\tmym = mym >> 1\n\t\t\ts +=1\n\t\ts +=1\nelse:\n\ts = 0\n\tmym = x[0][1]\n\tfor each in x:\n\t\tif each[1]>mym:\n\t\t\tmym = x[i][1]\t\n\n\twhile mym != 0:\n\t\tmym = mym >> 1\n\t\ts +=1\n\ts += 1\t\n\nv = 1\nfor each in x:\n\tv *= each[0]\t\nprint(v,int(s),sep=\" \")\t\n"}, {"source_code": "import sys\nfrom math import sqrt, gcd, ceil, log\nfrom bisect import bisect\nfrom collections import defaultdict\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n# sys.setrecursionlimit(10**6)\n\n\n\ndef solve():\n\tn = int(inp()); t = n\n\n\tarr = []; sett = set(); m_c = 1;\n\n\tfor i in range(2, int(sqrt(n)+1)):\n\t\tc = 0\n\t\tif n%i == 0:\n\t\t\tarr.append(i)\n\t\t\twhile n%i == 0:\n\t\t\t\tc += 1\n\t\t\t\tn //= i\n\t\t\tsett.add(c)\n\t\tm_c = max(m_c, c)\n\tif n > 1:\n\t\tarr.append(n)\n\t\tsett.add(1)\n\n\tif m_c == 1:print(t, 0);exit()\n\n\tm_c = ceil(log(m_c, 2))\n\tprint(m_c, sett, arr)\n\tif not(len(sett) == 1 and 2**m_c in sett):\n\t\tm_c += 1\n\n\tans = 1\n\tfor i in arr: ans *= i\n\tprint(ans, m_c)\n\n\n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "from math import sqrt\ndef primeFactorize(n):\n\tdic = {}\n\ti = 2\n\twhile(n>1):\n\t\twhile(n%i==0):\n\t\t\ttry:\n\t\t\t\tdic[i]+=1\n\t\t\texcept:\n\t\t\t\tdic[i] = 1\n\t\t\tn = n//i\n\t\ti += 1\n\treturn dic\n\ndef noofoperation(num):\n\tif num==1:\n\t\treturn 0\n\telif num&1==0:\n\t\treturn 1 + noofoperation(num//2)\n\telse:\n\t\treturn 2 + noofoperation((num+1)//2)\n\n\n\nif __name__==\"__main__\":\n\tn = int(input())\n\tcount = 0\n\tdic = primeFactorize(n)\n\tfor i in dic.values():\n\t\tcount = max(count,noofoperation(i))\n\tpro = 1\n\tfor i in dic:\n\t\tpro *= i\n\tprint(pro,count)"}, {"source_code": "import math\nfrom collections import defaultdict\nimport functools\n\nprimes = [2]\nN = 1001\n\ndef generate_primes():\n for i in range(2, N):\n isPrime = True\n sqr = math.ceil(math.sqrt(i))\n for p in primes:\n if i % p == 0:\n isPrime = False\n break\n if p > sqr:\n break \n if isPrime:\n primes.append(i)\n\ndef find_factors(n):\n prime_counter = 0\n prime_dict = defaultdict(int)\n while n > 1:\n while n > 1 and n % primes[prime_counter] == 0:\n n = n // primes[prime_counter]\n prime_dict[primes[prime_counter]] += 1\n prime_counter += 1\n return prime_dict\n\ndef get_num_steps(arr):\n def find_power(mx):\n two_power = 1\n i = 0\n while two_power < mx:\n two_power *= 2\n i += 1\n return i\n \n mx = arr[0]\n all_equal = True\n for i in range(1, len(arr)):\n mx = max(mx, arr[i])\n if arr[i] != arr[i-1]:\n all_equal = False\n if all_equal: #all equal\n return find_power(mx)\n return find_power(mx)+1\n \n\ndef solution(n):\n generate_primes()\n prime_dict = find_factors(n)\n max_power = get_num_steps(list(prime_dict.values()))\n return functools.reduce(lambda x, y:x*y, prime_dict.keys(), 1), max_power\n\nn = int(input())\nif n == 1:\n print(1, 0)\nelse:\n print(*solution(n))\n"}, {"source_code": "from math import sqrt,log,ceil\nfrom 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)))\n\ndef get_primes(end):\n out = list()\n sieve = [True] * (end + 1)\n for p in range(2,end + 1):\n if (sieve[p]):\n out.append(p)\n for i in range(p, end + 1, p):\n sieve[i] = False\n return out\n\n\ndef factors(n):\n\tprimes=get_primes(int(sqrt(n)+1))\n\tans={}\n\tfor num in primes:\n\t\tif num!=1:\n\t\t\twhile n%num==0:\n\t\t\t\tn/=num\n\t\t\t\tans[num] = ans.get(num, 0) + 1\n\t\telse:\n\t\t\tbreak\n\tmaxi=0\n\tfor key in ans.keys():\n\t\tif ans[key]>maxi:\n\t\t\tmaxi=ans[key]\n\tlol=1\n\tfor key in ans.keys():\n\t\tlol*=int(key)\n\ttemp=int(ceil(log(maxi,2)))\n\tflag=0\n\tfor key in ans.keys():\n\t\tif ans[key]!=2**temp:\n\t\t\tflag=1\n\t\t\tbreak\n\n\treturn lol,temp+flag\n\n\n\nn=int(raw_input())\nif n==1:\n\tprint 1,0\n\texit()\nif isPrime(n):\n\tprint n,0\n\texit()\nmaxi,temp=factors(n)\nprint maxi,temp\n\n"}, {"source_code": "#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))\nn = int(input())\nn2 = n\nflag = 0\ni = 0\nans = 1\nflag2= 0\nans2 = 0\nfor i in range(2,int(n**0.5)+1):\n if n % i == 0:\n ans *= i\n num = 0\n while n % i == 0:\n n //= i\n num += 1\n num2 = 0\n num3 = bin(num)[3:]\n flag = 0\n for j in num3:\n if j == \"1\":\n flag = 1\n break\n if flag == 1 or num == 1:\n num2 = len(num3) + 1\n flag2 = 1\n else:\n num2 = len(num3)\n ans2 = max(ans2,num2)\n if n < i:\n break\nnum3 = ans * n\nif num3 == n2:\n print(num3,0)\nelse:\n if n!=1:\n num2 = 2\n flag2 = 1\n else:\n num2 = 1\n print(num3,max(ans2+flag2,num2))\n"}, {"source_code": "# print(2**6*3**4)\n# print(256**0.5)\n\n\ndef next_power_of_two(maxi):\n\n base = 2\n exp = 1\n while base ** exp < maxi:\n exp += 1\n # print(exp)\n return exp+1\n\n\n\nfrom collections import defaultdict\nn = int(input())\n\nsieve = [True] * (n+1)\nsieve[0] = False\nsieve[1] = False\nfor i in range(2,int(n**0.5+1)):\n if sieve[i]:\n for j in range(i+i,n+1,i):\n sieve[j] = False\n\nnumber = 1\ntemp = n\nfactors = defaultdict()\ndiv = 2\nif n == 1:\n print(1,0)\n exit(0)\nwhile temp > 1:\n # print(temp)\n if temp % div != 0:\n div += 1\n continue\n temp //= div\n if div not in factors:\n factors[div] = 1\n else:\n factors[div] += 1\n# print(factors)\nops = 0\nif len(factors) == 1:\n for k, v in factors.items():\n if k == n:\n print(k,0)\n else:\n temp = v\n while v > 1:\n ops += 1\n v //= 2\n if temp % 2 == 1:\n ops += 1\n print(k,ops)\n exit(0)\n\nmaxi = -1\nfor k,v in factors.items():\n number *= k\n maxi = max(maxi, v)\n# print(factors)\nif maxi == 1:\n print(number, 0)\nelse:\n # print(maxi)\n\n power = 2**next_power_of_two(maxi)\n\n while power > 1:\n power //= 2\n ops += 1\n\nprint(number, ops)\n\n"}, {"source_code": "import math\nn=int(input())\ndef srt(n):\n x=int(math.sqrt(n))\n return x\n\ndef div(n):\n xs=int(math.sqrt(n))\n ls=[]\n for i in range(1,xs+1):\n if n%i==0:\n ls.append(i)\n if i*i!=n:\n ls.append(n//i)\n \n ls.sort()\n return ls[:len(ls)-1] \n \nxs=1\ncount=0\nwhile xs:\n ax=srt(n)\n if ax*ax==n:\n n=ax\n count+=1\n else:\n l=div(n)\n y=len(l)\n for j in range(y):\n bx=l[j]*n\n cs=int(math.sqrt(bx))\n if cs*cs!=bx:\n xs=0\n else:\n n=bx\n xs=1\n count+=1\n break\n \nprint(n,end=' ')\nprint(count)\n\n "}, {"source_code": "import math\n# https://codeforces.com/problemset/problem/1062/B\ndef B1062(n):\n initial_value = n \n dictionary = dict()\n if n == 1: \n print(n, 0)\n return\n value = 1 \n while (n % 2 == 0):\n dictionary[2] = 1 + dictionary.get(2, 0)\n n = n/2\n value = 2\n\n for prime in range(3, int(math.sqrt(n))+1, 2):\n found_prime = False\n while n % prime == 0:\n dictionary[prime] = dictionary.get(prime, 0) + 1\n n = n/prime\n if not found_prime:\n value *= prime\n found_prime = True\n\n if (n>2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n\n steps = 0 \n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1:\n \n print(initial_value, 0)\n return\n \n# print(dictionary)\n if max_power == 2:\n steps = 2\n elif all(list(map(lambda x: int(math.log(x, 2)) == math.log(x,2), dictionary.values()))):\n steps = int(math_log) \n else:\n if int(math_log) == math_log: # max power is squared\n # we add one for the \"squaredfication\"\n steps = int(math_log) +1\n else:\n steps = int(math_log) + 1 + 1\n\n #print(value, steps)\n print(\" \".join([str(int(value)), str(steps)]))\n\n\nB1062(int(input()))\n"}, {"source_code": "import math\nn=int(input())\nif n==1:\n print(1,0)\nelse:\n factors=[]\n for i in range(1,round(n**0.5)+2):\n if n%i==0:\n factors+=[i,n//i]\n def isprime(n):\n if n==1:\n return False\n if n<4:\n return(True)\n for i in range(2,round(n**0.5)+2):\n if n%i==0:\n return False\n return True\n primes=[]\n for factor in factors:\n if isprime(factor):\n primes.append(factor)\n exps=[]\n for prime in primes:\n x=prime\n expo=0\n while n%x==0:\n x*=prime\n expo+=1\n exps.append(expo)\n b=max(exps)\n decs=math.ceil(math.log2(b))\n cheat=True\n exp=2**decs\n for guy in exps:\n if guy!=exp:\n cheat=False\n break\n prod=1\n for guy in primes:\n prod*=guy\n if cheat:\n print(prod,decs)\n else:\n print(prod,decs+1)"}, {"source_code": "import math\nfrom collections import Counter\n\nlis = []\nnearest_pow_2 = []\n\n\ndef convert(n):\n start = 1\n while start < n:\n start *= 2\n return start\n\n\ndef primeFactors(n):\n while n % 2 == 0:\n lis.append(2)\n n = n / 2\n for i in range(3, int(math.sqrt(n)) + 1, 2):\n while n % i == 0:\n lis.append(i)\n n = n / i\n if n > 2:\n lis.append(n)\n\n\nprimeFactors(int(input()))\ncur_lis = Counter(lis)\nkey = list(cur_lis.keys())\nfor i in key:\n nearest_pow_2.append(convert(cur_lis[i]))\nm = 0\nflag = 0\nfor i in range(len(key)):\n if nearest_pow_2[i] > cur_lis[i]:\n flag = 1\n m = max(m, math.log(nearest_pow_2[i], 2))\nx = list(set(lis))\nans = 1\nfor i in x:\n ans *= i\nm = int(m)\nif flag == 1:\n m += 1\nans = int(ans)\nprint(ans, m)"}, {"source_code": "import sys\nimport math\n\ndef starting(N):\n a = []\n b = {}\n ans_one = 1\n ans_two = 0\n d = -1\n\n for i in range(2,N):\n if N%i:\n continue\n c = 0\n while not (N%i):\n c += 1\n N /= i\n\n if d != -1 and c&-c != c:\n ans_two = 1\n elif d != -1 and c != d:\n ans_two = 1\n\n if d < c:\n d = c\n ans_one *= i\n\n\n if N > 1:\n ans_one *= N\n if d != 1 and d != -1:\n ans_two = 1\n\n i = 1\n while i < d:\n ans_two += 1\n i *= 2\n\n print ans_one, ans_two\n\nn=int(input())\n\nif n == 1:\n print 1,0\nelse:\n starting(n)\n"}, {"source_code": "from math import sqrt,log,ceil\nfrom 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)))\n\ndef get_primes(end):\n out = list()\n sieve = [True] * (end + 1)\n for p in range(2,end + 1):\n if (sieve[p]):\n out.append(p)\n for i in range(p, end + 1, p):\n sieve[i] = False\n return out\n\n\ndef factors(n):\n\tprimes=get_primes(int(sqrt(n)+1))\n\tans={}\n\tfor num in primes:\n\t\tif num!=1:\n\t\t\twhile n%num==0:\n\t\t\t\tn/=num\n\t\t\t\tans[num] = ans.get(num, 0) + 1\n\t\telse:\n\t\t\tbreak\n\tmaxi=0\n\tfor key in ans.keys():\n\t\tif ans[key]>maxi:\n\t\t\tmaxi=ans[key]\n\tlol=1\n\tfor key in ans.keys():\n\t\tlol*=int(key)\n\ttemp=int(ceil(log(maxi,2)))\n\tflag=0\n\tfor key in ans.keys():\n\t\tif ans[key]!=2**temp:\n\t\t\tflag=1\n\t\t\tbreak\n\n\treturn lol,temp+flag\n\n\n\nn=int(raw_input())\nif n==1:\n\tprint 1,0\n\texit()\nif isPrime(n):\n\tprint n,0\n\texit()\nmaxi,temp=factors(n)\nprint maxi,temp\n\n"}, {"source_code": "import math \nfrom collections import Counter \n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n): \n l=[]\n # Print the number of two's that divide n \n while n % 2 == 0: \n #print 2, \n l.append(2)\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 #print i, \n l.append(i)\n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n l.append(n)\n return l\nl1={}\np=1\ni=0\nwhile p<20000000:\n l1[p]=i\n i+=1\n p*=2\n\nn=input()\nif n==1:\n print 0\n exit()\nl=primeFactors(n)\nd=Counter(l)\nans1=1\nfor i in d.keys():\n ans1*=i\nmx=max(d.values())\ntry:\n \n if l1[mx]>=0:\n max_pow=mx\n step=l1[mx]\n \nexcept:\n step=len(bin(mx)[2:])\n max_pow=2**step\nf=0\nfor i in d.keys():\n #print d[i],max_pow\n if d[i] 0:\n m *= i\n\nif m == x:\n print(m, 0)\nelse:\n print(m, ans)\n\n"}, {"source_code": "import collections\nimport math\nimport sys\ndef isPowerOfTwo (x): \n return (x and (not(x & (x - 1))))\ndef primefactors(n):\n\td = collections.defaultdict(int) \n\twhile n%2 == 0:\n\t\td[2]+=1\n\t\tn/=2\n\tfor i in range(3, int(n**0.5)+1, 2):\n\t\twhile n%i==0:\n\t\t\td[i]+=1\n\t\t\tn/=i\n\tif n > 2:\n\t\td[n]+=1\n\treturn d\nn = int(input())\nif n == 1:\n\tprint(1, 0)\n\tsys.exit()\nx = primefactors(n)\ny = max(x.values())\nz = x.keys()\nk = 1\nfor i in z:\n\tk*=i\nif y == 1 or y == 0:\n\tprint(int(k), 0)\nelse:\n\tif y%2 == 0:\n\t\tprint(int(k), math.ceil(math.log(y, 2)))\n\telse:\n\t\tprint(int(k), math.ceil(math.log(y, 2))+1)"}, {"source_code": "import math\n\nn = int(input())\nN = n\nfrq = list()\nfor i in range(n+1):\n frq.append(0)\nwhile(n > 1):\n for i in range(2, n+1):\n if(n % i == 0):\n frq[i] += 1\n n //= i\n break\nmaxfrq = 0\nsqfree = 1\nfor i in range(N+1):\n if(frq[i]>0):\n sqfree *= i\n maxfrq = max(maxfrq, frq[i])\nnextbit = 1\nwhile(nextbit < maxfrq) : nextbit *= 2\nif(sqfree == N) : nextbit /= 2\nprint(sqfree, int(math.log2(nextbit)) + 1)"}, {"source_code": "import math\nmul2 = [2**x for x in range(2,7)]\nn = int(input())\nfacto = [0]*1001\nans = 1\nfor i in range(2,math.ceil(n**.5)+1):\n if n % i == 0:\n while n % i == 0:\n facto[i] += 1\n n //= i\n ans *= i\nm = max(facto)\nif m == 0:\n print(n,0)\nelif m == 1:\n print(ans,0)\nelif m == 2:\n print(ans,2)\nelse:\n mi = 64\n lim = 0\n for each in mul2:\n if abs(m-each) <= mi:\n mi = abs(m - each)\n lim = each\n times = int(math.log(lim,2)+1) if (lim != m) else int(math.log(lim,2))\n print(ans,times)\n\n"}, {"source_code": "import math\n\nn = int(input())\nans, anssq = 1, 0\nmaxsq = 1\ntempn = n\nfor i in range(2, n + 1):\n tempsq = 0\n while tempn % i == 0:\n tempn = tempn // i\n tempsq += 1\n if tempsq > 0:\n ans = ans * i\n if tempsq > maxsq:\n maxsq = tempsq\nprint(ans, math.ceil(math.log2(maxsq) + 1))"}, {"source_code": "from collections import defaultdict\nfrom math import log, ceil\nk = int(input())\nn = k//2\nprimefac = defaultdict(int)\nmark = [True]*(n+1)\nfor i in range(2, n+1):\n\tif mark[i]:\n\t\twhile k != 1:\n\t\t\tif k%i == 0: \n\t\t\t\tk//=i\n\t\t\t\tprimefac[i] += 1\n\t\t\telse: break\n\t\tif k == 1: break\n\t\tfor j in range(i, n+1, i): mark[j] = False\nif k != 1:\n\tprint(k, 0)\nelse:\n\tans1 = 1\n\tans2 = 0\n\tt = 0\n\tz = False\n\ty = False\n\tfor key, value in primefac.items():\n\t\tte = log(value, 2)\n\t\tif te == 0: y = True\n\t\telif int(te) != te: t+=1\n\t\telse: z = True \n\t\tans1 *= key\n\t\tans2 = max(ans2, ceil(te))\n\tt = (1 if t > 0 or (y and z) else 0)\n\tprint(ans1, ans2+t)"}, {"source_code": "N = int(input())\nnum = 0\nwhile int(N ** 0.5) ** 2 == N:\n num += 1\n N = int(N ** 0.5)\nM = 10 ** 3 + 5\n\nwhile True:\n pr = {}\n K = N\n for i in range(2, M):\n tmp = 0\n while K % i == 0:\n K //= i\n tmp += 1\n if tmp >= 1:\n pr[i] = tmp\n\n tmp0 = 0\n for k, v in pr.items():\n if v % 2 != 0:\n pr[k] += 1\n tmp0 += 1\n\n rec = 1\n for k, v in pr.items():\n rec *= k ** (v // 2)\n\n if N <= rec:\n rec = N\n break\n N = rec\n num += tmp0\n\n\nprint(rec, num + 1)"}, {"source_code": "import math\n\nn = int(input())\nN = n\nfrq = list()\nfor i in range(n+1):\n frq.append(0)\nwhile(n > 1):\n for i in range(2, n+1):\n if(n % i == 0):\n frq[i] += 1\n n //= i\n break\nmaxfrq = 0\nsqfree = 1\nfor i in range(N+1):\n if(frq[i]>0):\n sqfree *= i\n maxfrq = max(maxfrq, frq[i])\nnextbit = 1\nwhile(nextbit < maxfrq) : nextbit *= 2\nif(sqfree == N) : nextbit /= 2\nprint(sqfree, int(math.log2(nextbit)) + 1)"}, {"source_code": "import math\ndef check(n,i):\n k = 0\n while n%i == 0:\n k += 1\n n = n/i\n return [n,k]\nn = int(raw_input())\nnum = []\nl = set()\nmaxpow = 1\nran = int(n)\nfor i in range(2,ran):\n n,temp = check(n,i)\n if temp > 0:\n maxpow = max(maxpow, temp)\n num.append(i)\n l.add(temp)\nif maxpow == 1:\n print n, 0\nelse:\n ans = 1\n for j in num:\n ans = ans*j\n if len(l) > 1 or math.ceil(math.log(maxpow)/math.log(2)) > math.log(maxpow)/math.log(2):\n print ans, int(math.ceil(math.log(maxpow)/math.log(2)))+1\n else:\n print ans, int(math.ceil(math.log(maxpow)/math.log(2)))"}, {"source_code": "import math\n\nn = int(input())\nans, anssq = 1, 0\nmaxsq = 1\ntempn = n\nfor i in range(2, n + 1):\n tempsq = 0\n while tempn % i == 0:\n tempn = tempn // i\n tempsq += 1\n if tempsq > 0:\n ans = ans * i\n if tempsq > maxsq:\n maxsq = tempsq\nif math.log2(maxsq) == 0.0:\n print(ans, 0)\nelse:\n print(ans, math.ceil(math.log2(maxsq) + 1))"}, {"source_code": "from collections import defaultdict\nfrom math import log, ceil\nk = int(input())\nn = k//2\nprimefac = defaultdict(int)\nmark = [True]*(n+1)\nfor i in range(2, n+1):\n\tif mark[i]:\n\t\twhile k != 1:\n\t\t\tif k%i == 0: \n\t\t\t\tk//=i\n\t\t\t\tprimefac[i] += 1\n\t\t\telse: break\n\t\tif k == 1: break\n\t\tfor j in range(i, n+1, i): mark[j] = False\nif k != 1:\n\tprint(k, 0)\nelse:\n\tans1 = 1\n\tans2 = 0\n\tt = 0\n\tfor key, value in primefac.items():\n\t\tte = log(value, 2)\n\t\tif int(te) != te or te == 0: t=1\n\t\tans1 *= key\n\t\tans2 = max(ans2, ceil(te))\n\tprint(ans1, ans2+t)"}, {"source_code": "import math\nn=int(input())\nif n==1:\n print(1,0)\nelse:\n factors=[]\n for i in range(1,round(n**0.5)+2):\n if n%i==0:\n factors+=[i,n//i]\n def isprime(n):\n if n==1:\n return False\n if n<4:\n return(True)\n for i in range(2,round(n**0.5)+2):\n if n%i==0:\n return False\n return True\n primes=[]\n for factor in factors:\n if isprime(factor):\n primes.append(factor)\n exps=[]\n for prime in primes:\n x=prime\n expo=0\n while n%x==0:\n x*=prime\n expo+=1\n exps.append(expo)\n b=max(exps)\n decs=math.ceil(math.log2(b))\n cheat=True\n exp=2**decs\n for guy in exps:\n if guy!=exp:\n cheat=False\n break\n prod=1\n for guy in primes:\n prod*=guy\n if cheat:\n print(prod,decs)\n else:\n print(prod,decs+1)"}, {"source_code": "from math import *\na=int(input())\np=[]\nb=a\nprime=1\nfor i in range(a+5):\n p.append(0)\nwhile a>1:\n q=0\n for z in range(2,floor(sqrt(a))+1):\n if(a%z==0):\n p[z]+=1\n a/=z\n prime=0\n q=1\n break\n if(q==0):\n p[int(a)]+=1\n break\nq=1\nr=1\nt=0\nwhile(q 1:\n maxp = max(l)\nelse:\n maxp = 0\nflag = 0\nfor i in l:\n if i != maxp:\n flag = 1\n\ntemp = 0\n\nif flag:\n temp = 1\nelse:\n temp = ispowerof2(maxp)\n\nif maxp == 1:\n maxp -= 1\nelif maxp != 0:\n maxp = math.ceil(math.log2(maxp)) + temp\n\nprint(ans, maxp)\n"}, {"source_code": "from math import log, ceil\n\n\ndef factor1(n):\n num = 2\n res = set()\n while num ** 2 <= n:\n while n % num == 0:\n res.add(num)\n n = n // num\n num += 1\n if n > 1:\n res.add(n)\n ans = 1\n for x in res:\n ans *= x\n return ans\n\n\ndef factor(n):\n num = 2\n res = dict()\n while num ** 2 <= n:\n while n % num == 0:\n res[num] = res.get(num, 0) + 1\n n = n // num\n num += 1\n if n > 1:\n res[n] = res.get(n, 0) + 1\n return res\n\n\nn = int(input())\nprint(factor1(n), ceil(log(max(factor(n).values()), 2)) + 1)\n"}, {"source_code": "n = int(input())\ni = 2\nm = [0]*1000003\nmic = 1000007\na = 1\nb = 0\nwhile(i*i<=n):\n if (n%i==0):\n while(n%i==0):\n n//=i\n m[i]+=1\n c = m[i]\n d = 0\n while (c%2==0):\n d+=1\n c//=2\n mic = min(mic, d)\n a*=i\n i+=1\nif (n!=1):\n m[n] += 1\n c = m[n]\n d = 0\n while (c%2==0):\n d+=1\n c//=2\n mic = min(mic, d)\n a*=n\n n = 1\nk = 1\nmi = 1\nb+=mic\nfor i in range(mic):\n mi*=2\nmx = 0\nfor i in range(1000003):\n if (m[i]>0):\n m[i]//=mi\n mx = max(mx, m[i])\nwhile(k0):\n if (m[i]!=mx):\n fl = 1\nprint(a,b+fl)\n"}, {"source_code": "from math import log, ceil\n\n\ndef factor1(n):\n num = 2\n res = set()\n while num ** 2 <= n:\n while n % num == 0:\n res.add(num)\n n = n // num\n num += 1\n if n > 1:\n res.add(n)\n ans = 1\n for x in res:\n ans *= x\n return ans\n\n\ndef factor(n):\n num = 2\n res = dict()\n while num ** 2 <= n:\n while n % num == 0:\n res[num] = res.get(num, 0) + 1\n n = n // num\n num += 1\n if n > 1:\n res[n] = res.get(n, 0) + 1\n return res\n\n\nn = int(input())\nmin_ = factor1(n)\nkek = sorted(factor(n).values())\nif min_ == n:\n print(n, 0)\nelif kek[0] == kek[-1] and log(kek[-1], 2) // 1 == log(kek[-1], 2):\n print(min_, int(log(n, min_)) - 1)\nelse:\n print(min_, ceil(log(kek[-1], 2)) + 1)\n"}, {"source_code": "import math\n# https://codeforces.com/problemset/problem/1062/B\ndef B1062(n):\n dictionary = dict()\n value = 1 \n while (n % 2 == 0):\n dictionary[2] = 1 + dictionary.get(2, 0)\n n = n/2\n value = 2\n\n for prime in range(3, int(math.sqrt(n))+1, 2):\n found_prime = False\n while n % prime == 0:\n dictionary[prime] = dictionary.get(prime, 0) + 1\n n = n/prime\n if not found_prime:\n value *= prime\n found_prime = True\n\n if (n>2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n\n steps = 0 \n\n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1:\n \n print(n, 0)\n return\n if int(math_log) * 2 != max_power :\n steps += int(math_log) + 1\n else:\n if all(list(map(lambda x: int(math.log(x, 2)) * 2 == x, dictionary.values()))):\n steps = int(math_log) \n else:\n steps = int(math_log) + 1\n \n\n print(value, steps)\n\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"\nThis file is part of https://github.com/Cheran-Senthil/PyRival.\nCopyright 2019 Cheran Senthilkumar \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\n# from copy import deepcopy\n# from decimal import Decimal\n# from difflib import SequenceMatcher\nfrom functools import reduce\n# from heapq import heappop, heappush\nfrom io import BytesIO, FileIO, StringIO\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 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\nINP_FILE = 0\nOUT_FILE = 1\n\nif sys.version_info[0] < 3:\n sys.stdin = BytesIO(FileIO(INP_FILE).read())\n sys.stdout = BytesIO()\n register(lambda: FileIO(OUT_FILE, 'w').write(sys.stdout.getvalue()))\nelse:\n sys.stdin = StringIO(FileIO(INP_FILE).read().decode())\n sys.stdout = StringIO()\n register(lambda: FileIO(OUT_FILE, 'w').write(sys.stdout.getvalue().encode()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\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 is_prime(n):\n \"\"\"\n Deterministic variant of the Miller-Rabin primality test to determine\n whether a given number (upto 2**64) 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, 13, 19, 73, 193, 407521, 299210837]:\n return True\n\n if (n in [0, 1]) or (any((n % p) == 0 for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837])):\n return False\n\n d, s = n - 1, 0\n while not d % 2:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 return not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022])\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n if is_prime(n):\n return Counter({n: 1})\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, k = y, 0\n\n for _ in range(r):\n y = (y*y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y*y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys*ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\ndef factors(n):\n \"\"\"\n Prime factorization using Pollard's rho algorithm.\n\n Parameters\n ----------\n n : int\n n > 0, an integer to be factorized.\n\n Returns\n -------\n prime_factors : Counter\n Counter of the prime factors of n.\n \"\"\"\n prime_factors = Counter()\n\n def ilog(n, p):\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n return n, cnt\n\n if n % 2 == 0:\n n, prime_factors[2] = ilog(n, 2)\n if n % 3 == 0:\n n, prime_factors[3] = ilog(n, 3)\n\n i = 5\n while i * i <= min(n, 4294967295):\n if n % i == 0:\n n, prime_factors[i] = ilog(n, i)\n i += 2 if i % 3 == 2 else 4\n\n if n == 1:\n return prime_factors\n\n if n <= 4294967295:\n prime_factors[n] = 1\n return prime_factors\n\n return prime_factors + pollard_rho(n)\n\n\ndef main():\n n = int(input())\n\n f = factors(n)\n p = list(f.values())\n\n a2 = (max(p) - 1).bit_length()\n print(reduce(op.mul, f.keys()), (len(set(p)) != {1 << a2}) + a2)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "\ndef prime_factors(a):\n\tif a==1:\n\t\treturn(1,0)\n\tfactors={}\n\ti=2\n\torig=a\n\twhile i <= (int(orig**0.5)+1):\n\t\twhile a%i==0:\n\t\t\ta=a//i\n\t\t\tif i in factors: \n\t\t\t\tfactors[i]+=1\n\t\t\telse:\n\t\t\t\tfactors[i]=1\n\t\ti+=1\n\tif a>1:\n\t\tfactors[a]=1\n\t#print(factors)\n\tif sorted(factors)[-1]==orig:\n\t\treturn(N,0)\n\tmultiple=1\n\tfor i in factors:\n\t\tmultiple*=i\n\tif orig==multiple**2:\n\t\treturn(int(orig**0.5),1)\n\telif orig==multiple:\n\t\treturn (orig,0)\n\tsomething=sorted([factors[i] for i in factors])\n\tcounter=0\n\t#print(something[-1])\n\twhile 2**counter1:\n\t\tfactors[a]=1\n\tif sorted(factors)[-1]==orig:\n\t\treturn(N,0)\n\tmultiple=1\n\tfor i in factors:\n\t\tmultiple*=i\n\tif orig==multiple**2:\n\t\treturn(int(orig**0.5),1)\n\telif orig==multiple:\n\t\treturn (orig,0)\n\tsomething=sorted([factors[i] for i in factors])\n\tcounter=0\n\twhile counter*2= 2:\n if x % j == 0:\n f.append(j)\n x = x // j\n else:\n j += 1\n return f\nc = Counter(getFactors(n))\nminm = 1\nfor x in c:\n minm *= x\nmaxm = max(c.values())\ni = 0\nf = 1\nwhile maxm > f:\n i += 1\n f *= 2\nif maxm == 1 or (len(c) == 1 and int(math.pow(2, i)) == maxm):\n ans = i\nelse:\n ans = i + 1\nprint(minm, ans)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# File : bb.py\n# Author : recurze\n# Date : 21:32 14.11.2018\n# Last Modified Date: 21:46 14.11.2018\n\nfrom collections import defaultdict\ndef factors(n):\n d = defaultdict(int)\n if n < 2:\n return d\n while not n&1:\n n>>=1\n d[2]+=1\n while not n%3:\n n/=3\n d[3]+=1\n x = 5\n while x*x<=n:\n while not n%x:\n n/=x\n d[x]+=1\n x += 2\n while not n%x:\n n/=x\n d[x]+=1\n x += 4\n if n > 1:\n d[n]+=1\n return d\n\nd = factors(int(raw_input()))\nl = d.values()\nm = max(l)\n\ndef num(d):\n ret = 1\n for i in d:\n ret*=i\n return ret\n\nprint num(d), ([m]*len(l) != l) + len(bin(m)[2:]) - (not m&(m-1))\n"}, {"source_code": "n = int(input())\nn1 = n\nans = 1\nmaxcnt = 0\nflag = 0\nfor i in range(2,n1 + 1):\n\tif i > n:\n\t\tbreak\n\tif n % i == 0:\n\t\tans *= i\n\t\tcnt = 0\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\t\t\tcnt += 1\n\t\tif cnt != maxcnt and maxcnt > 0:\n\t\t\tflag = 1\n\t\tif cnt > maxcnt:\n\t\t\tmaxcnt = cnt\n\nmyb = [1, 2, 4, 8, 16, 32]\n\nif maxcnt not in myb:\n\tflag = 1\n\nfor i in range(len(myb)):\n\tif myb[i] >= maxcnt:\n\t\tanscnt = i\n\t\tbreak\n\t\n\nprint(ans, anscnt + flag)\n\t"}, {"source_code": "import math\n\ndef B1062(n):\n\n dictionary = dict()\n if n == 1: \n print(n, 0)\n return\n value = 1 \n while (n % 2 == 0):\n dictionary[2] = 1 + dictionary.get(2, 0)\n n = n/2\n value = 2\n \n for prime in range(3, int(math.sqrt(n))+1, 2):\n found_prime = False\n while n % prime == 0:\n dictionary[prime] = dictionary.get(prime, 0) + 1\n n = n/prime\n if not found_prime:\n value *= prime\n found_prime = True\n \n if (n>2):\n dictionary[n] = dictionary.get(n, 0) + 1\n value *= n\n \n steps = 0 \n \n max_power = max(dictionary.values())\n math_log = math.log(max_power, 2)\n \n if max_power == 1 :\n \n print(n, 0)\n return\n \n if max_power == 2:\n steps = 2\n elif all(list(map(lambda x: int(math.log(x, 2)) == math.log(x,2), dictionary.values()))):\n steps = int(math_log) \n else:\n if int(math_log) == math_log: # max power is squared\n # we add one for the \"squaredfication\"\n steps = int(math_log) +1\n else:\n steps = int(math_log) + 1 + 1\n \n #print(value, steps)\n print(\" \".join([str(int(value)), str(steps)]))\n \n \nB1062(int(input()))\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\nn = int(input())\n\n\n\nl = []\n\nfor i in range(1,10**6 + 1):\n l.append(i**2)\nfin = 0\nprev = -1\nwhile True:\n flag = 0\n bo = []\n\n for i in l:\n\n if i%n == 0:\n\n bo.append(i)\n mini = inf\n yo = 0\n lo = 0\n if bo == []:\n break\n\n\n for i in bo:\n cnt = 0\n j = i\n\n while int(sqrt(i)) == sqrt(i):\n\n i = int(sqrt(i))\n cnt+=1\n\n if mini>i:\n\n yo = cnt\n lo = j\n mini = i\n\n if i == 1:\n break\n\n if prev == mini:\n break\n\n if lo != n:\n fin+=1\n\n n = mini\n prev = n\n fin+=yo\n\n\n\n\n\n\nprint(n,fin)\n\n\n\n"}, {"source_code": "import math\nn=int(input())\narr=[]\nfor i in range(2,n+1):\n\tif n%i==0:\n\t\tcnt=0\n\t\twhile n%i==0:\n\t\t\tcnt+=1\n\t\t\tn=n//i \n\t\tarr.append([i,cnt])\n# print(arr)\nmul=0\nmn=1\nst=0\nfor i in range(len(arr)):\n\tmn=mn*arr[i][0]\n\txx=int(math.log(arr[i][1]))\n\t# print(xx,(1<(1< 2: \n dict1[n]=0\n dict1[n]+=1\nn=int(input())\nif n==1:\n print(1,0)\nelse:\n dict1={}\n primeFactors(n)\n max1=1\n lst=[]\n for i in dict1:\n lst.append(dict1[i])\n if max(lst)==min(lst) and max(lst)==1:\n print(n,0)\n elif max(lst)==min(lst):\n prod=1\n for i in dict1:\n prod*=i\n print(prod,math.ceil(math.log2(max(lst))))\n else:\n prod=1\n for i in dict1:\n prod*=i\n print(prod,math.ceil(math.log2(max(lst)))+1)"}], "src_uid": "212cda3d9d611cd45332bb10b80f0b56"} {"nl": {"description": "Petya studies positional notations. He has already learned to add and subtract numbers in the systems of notations with different radices and has moved on to a more complicated action \u2014 multiplication. To multiply large numbers one has to learn the multiplication table. Unfortunately, in the second grade students learn only the multiplication table of decimals (and some students even learn it in the first grade). Help Petya make a multiplication table for numbers in the system of notations with the radix k.", "input_spec": "The first line contains a single integer k (2\u2009\u2264\u2009k\u2009\u2264\u200910) \u2014 the radix of the system.", "output_spec": "Output the multiplication table for the system of notations with the radix k. The table must contain k\u2009-\u20091 rows and k\u2009-\u20091 columns. The element on the crossing of the i-th row and the j-th column is equal to the product of i and j in the system of notations with the radix k. Each line may have any number of spaces between the numbers (the extra spaces in the samples are put for clarity).", "sample_inputs": ["10", "3"], "sample_outputs": ["1 2 3 4 5 6 7 8 9\n2 4 6 8 10 12 14 16 18\n3 6 9 12 15 18 21 24 27\n4 8 12 16 20 24 28 32 36\n5 10 15 20 25 30 35 40 45\n6 12 18 24 30 36 42 48 54\n7 14 21 28 35 42 49 56 63\n8 16 24 32 40 48 56 64 72\n9 18 27 36 45 54 63 72 81", "1 2\n2 11"], "notes": null}, "positive_code": [{"source_code": "def b(n, k):\n v = ''\n while n:\n n, v = n // k, str(n % k) + v\n return v\nk = int(input())\nfor i in range(1, k):\n print(' '.join(b(i * j, k) for j in range(1, k)))"}, {"source_code": "radix = int(input())\nfor i in range(1, radix):\n row = []\n for j in range(1, radix):\n x = i * j\n digits = []\n while x != 0:\n digits.append(str(x % radix))\n x //= radix\n row.append(''.join(reversed(digits)))\n print(' '.join(row))\n"}, {"source_code": "k=int(input())\nfor i in range(1,k):\n z,a=i,[]\n for j in range(k-1):\n p,s=z,\"\"\n while p:\n s=str(p%k)+s\n p//=k\n z+=i\n a.append(s)\n print(*a)\n\n \n"}, {"source_code": "n=int(input())\nfor i in range(1,n):\n for j in range(1,n):\n c=i*j\n d=[]\n while(c!=0):\n d.append(str(c%n))\n c=int(c/n)\n d.reverse()\n \n d=\"\".join(d)\n print(d,end=\" \")\n print()"}, {"source_code": "n = int(input())\n\nfor i in range(1,n):\n print(*((i*j//n)*10+(i*j%n) for j in range(1,n)))"}, {"source_code": "def baseNum(a,b):\n i = 0\n sumV = []\n while a > 0:\n sumV.append(str(a % b) )\n a = int(a/b)\n i += 1\n res = sumV[::-1]\n res2 = \"\".join(res)\n res2 = int(res2)\n return res2\nk = int(input())\nfor i in range(1,k):\n for j in range(1,k):\n print(baseNum(i*j,k),end=\" \" )\n print(end=\"\\n\")"}, {"source_code": "n = int(input())\nf = lambda x: x if x < n else f(x // n) * 10 + x % n\nfor i in range(1, n): print(*[f(i * j) for j in range(1, n)])"}, {"source_code": "n = int(input())\nfor i in range(1, n): print(*[(i * j // n) * 10 + (i * j % n) for j in range(1, n)])"}, {"source_code": "def convert_base(number, base):\n if base < 2:\n return False\n remainders = []\n while number > 0:\n remainders.append(str(number % base))\n number //= base\n remainders.reverse()\n return ''.join(remainders)\nn = int(input())\nfor i in range(1,n):\n s = ''\n for j in range(1,n):\n s += str(convert_base(i * j, n)) + ' '\n s = s[:-1]\n print(s)\n"}, {"source_code": "def t(x,n):\n if x b:\n# \t\ts += str(x/b)\n# \t\tx /= b\n# \ts += str(x)\n# \treturn s\n\ndef digit_to_char(digit):\n if digit < 10:\n return str(digit)\n return chr(ord('a') + digit - 10)\n\ndef str_base(number,base):\n if number < 0:\n return '-' + str_base(-number, base)\n (d, m) = divmod(number, base)\n if d > 0:\n return str_base(d, base) + digit_to_char(m)\n return digit_to_char(m)\n\nn = input()\nfor i in range(1,n):\n\tfor j in range(1,n):\n\t\t\t# print '%2d'%f(i*j,n),\n\t\t\tprint str_base(i*j,n),\n\tprint"}, {"source_code": "def CS(n, k):\n a = \"\"\n while not n == 0:\n l = n % k\n a = str(l) + a\n n /= k\n return a\n\nk = int(raw_input())\n\nfor i in range(1, k):\n for j in range(1, k):\n print CS(i * j, k),\n print\n"}, {"source_code": "def zetom(a,b):\n res=''\n s=a\n while s/b>0:\n res+=str(s%b)\n s=s/b\n res+=str(s)\n t=res[::-1]\n return t\n \nk=input()\n\nfor i in range(1,k):\n \n for j in range(1,k):\n res=i*j\n if res>=k:\n res=zetom (res,k)\n print res,\n print\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\n\ndef func1(n,base):\n str1 = \"\"\n while True:\n if n/base == 0:\n str1 += str(n)\n break\n else:\n str1 += str(n%base)\n n /= base\n\n return str1[::-1]\n\n\nif __name__ == '__main__':\n\n num = map(int,sys.stdin.readline().split())\n\n for v in range(1,num[0]):\n for u in range(1,num[0]):\n print func1(v*u,num[0]),\n print \"\""}, {"source_code": "import sys\n\nbase = int(sys.stdin.readline())\n\ndef baseN(num, b, numerals=\"0123456789\"):\n return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\n\nfor i in range(1, base):\n\tfor j in range(1, base):\n\t\tif j != 1:\n\t\t\tsys.stdout.write(\" \")\n\t\tn = (i * j)\n\t\tif base != 10:\n\t\t\tn = int(baseN(n, base))\n\t\tsys.stdout.write(\"%d\" % n)\n\tsys.stdout.write(\"\\n\")\n\n"}, {"source_code": "n = int(raw_input())\n\ndef basen(val, base):\n res = \"\"\n while val > 0:\n res += str(val % base)\n val -= val % base\n val /= base\n return res[::-1]\n\nfor x in range(n-1):\n for y in range(n-1):\n #Put x*y into base n\n print basen( (x+1) * (y+1), n), \" \",\n print"}, {"source_code": "n = int(raw_input())\ndef rad_n(n,x):\n\tr =''\n\twhile x>=n:\n\t\tr=str(x%n)+r\n\t\tx = x/n\n\tr=str(x)+r\n\treturn r\nl = len(str(rad_n(n,(n-1)*(n-1))))\n#print l\nfor i in xrange(1,n):\n\tfor j in xrange(1,n):\n\t\ta = rad_n(n,i*j)\n\t\tif j==1:\n\t\t\tprint a,\n\t\telif j 0 :\n t = x % base\n x /= base\n res = str(t) + res\n return res\n\ndef multable( n ) :\n for x in range(1,n):\n for y in range(1,n):\n t = x*y\n p = decimal2other(t,n)\n if y+1 < n :\n print p,\n else :\n print p\n\n\nif __name__ ==\"__main__\" :\n n = int(raw_input())\n multable(n)\n \n\n"}, {"source_code": "def sol(N, K):\n\tret = ''\n\twhile N != 0:\n\t\tret = str(N % K) + ret\n\t\tN /= K\n\treturn ret\n\t\nN = int(raw_input())\nfor i in range(1, N):\n\tfor j in range(1, N):\n\t\tprint sol(i * j, N),\n\tprint\n\n"}, {"source_code": "\n\ndef convertBase(n, toBase, prevBase = 10):\n\t#najdi stevilko potence toBase^n ku je vecja, in zacni od ene manj\n\tstr1 = str(n)\n\t\n\ti=1\n\tst = 0\n\twhile i <= n:\n\t\ti *= toBase\n\t\tst += 1\n\t#print \"st:%s\" %st\n\t\n\tres = []\n\ttmpSt = st\n\ttmpN = n\n\tfor i in range(0,st):\n\t\tif i == st-1:\n\t\t\tres.append(str(tmpN%toBase))\n\t\t\treturn \"\".join(res)\n\t\t\n\t\ttrCifra = 1\n\t\tfor i in range(0,st-1-i):\n\t\t\ttrCifra *= toBase\n\t\t\t\n\t\tdeljeno = int(tmpN / trCifra)\n\t\tif deljeno >= 1:\n\t\t\ttmpN = tmpN - (deljeno*trCifra)\n\t\t\tres.append(str(deljeno))\n\t\telse:\n\t\t\tres.append(\"0\")\n\n\nbase = int(raw_input())\n\nfor i in range(0,base-1):\n\tif i != base-2:\n\t\tprint \"%d \" % (i+1),\n\telse:\n\t\tprint \"%d\" % (i+1)\n\nfor i in range(1, base-1):\n\tprint \"%d \" % (i+1),\n\tfor j in range(1, base-1):\n\t\trez = (i+1) * (j+1)\n\t\tif j != base-2:\n\t\t\tprint \"%d \" % ( int(convertBase(rez,base)) ),\n\t\telse:\n\t\t\tprint \"%d\" % ( int(convertBase(rez,base)) )\n\t\n"}, {"source_code": "def toSys(n, k):\n res = ''\n t = k\n while (n != 0):\n res += str(n % t)\n n //= t\n t *= k \n return res[::-1]\n\n\nn = int(input())\nfor i in range(1, n):\n for j in range(1, n):\n print(toSys(i * j, n), end=\" \")\n print()"}, {"source_code": "a=int(input())\ndef radix(x):\n k=[]\n while x:k.append(x%a);x=x//a\n return ''.join(map(str,k))[::-1]\nfor i in range(1,a):\n for j in range(1,a):print(radix(i*j),end=' ')\n print()"}, {"source_code": "def b(n, k):\n v = ''\n while n:\n n, v = n // k, str(n % k) + v\n return v\nk = int(input())\nfor i in range(1, k):\n print(' '.join(b(i * j, k) for j in range(1, k)))"}, {"source_code": "from sys import stdout\nfrom sys import stdin\ndef get():\n return stdin.readline().strip()\ndef getf():\n return [int(i) for i in get().split()]\ndef put(a, end = \"\\n\"):\n stdout.write(str(a) + end)\ndef putf(a, sep = \" \", end = \"\\n\"):\n stdout.write(sep.join(map(str, a)) + end)\n\ndef matrix(n, m, a = 0):\n return [[a for i in range(m)]for j in range(n)]\n\ndef transf(a, k):\n s = \"\"\n while(a >= k):\n s += str(a % k)\n a //= k\n s += str(a)\n return s[::-1]\n\ndef main():\n n = int(get())\n t = matrix(n - 1, n - 1)\n for i in range(1, n):\n for j in range(1, n):\n t[i - 1][j - 1] = transf(i*j, n)\n for i in t:\n putf(i)\nmain()\n"}, {"source_code": "def convert(n,base):\n x=\"\"\n while n>0:\n x+=str(n%base)\n n//=base\n return x[::-1]\ndef func(x,n):\n ans=[]\n ans.append(x)\n for i in range(2,n):\n ans.append(int(convert(x*i,n)))\n return ans\nn=int(input())\nans=[]\nfor i in range(1,n):\n if i==1:\n x=[j for j in range(1,n)]\n ans.append(x)\n else:\n x=func(i,n)\n ans.append(x)\nfor s in ans:\n print(*s)\n"}, {"source_code": "a=int(input())\ndef radix(x):\n k=[]\n while x:k.append(x%a);x=x//a\n return ''.join(map(str,k))[::-1]\nfor i in range(1,a):\n for j in range(1,a):print(radix(i*j),end=' ')\n print()"}], "negative_code": [{"source_code": "def b(n, k):\n v = 0\n while n:\n n, v = n // k, 10 * v + n % k\n return str(v)[::-1]\nk = int(input())\nfor i in range(1, k):\n print(' '.join(b(i * j, k) for j in range(1, k)))"}, {"source_code": "n = int(raw_input())\ndef rad_n(n,x):\n\tr =''\n\twhile x>n:\n\t\tr=str(x%n)+r\n\t\tx = x/n\n\tr=str(x)+r\n\treturn r\nl = len(str(rad_n(n,(n-1)*(n-1))))\n#print l\nfor i in xrange(1,n):\n\tfor j in xrange(1,n):\n\t\ta = rad_n(n,i*j)\n\t\tif j==1:\n\t\t\tprint a,\n\t\telif j v[i+1]):\n\t\t\t\tdiff = abs(v[i]-v[i+1])\n\t\t\t\tv[i] = v[i]-diff\n\t\t\t\tv[i+1] = v[i+1] + diff\n\t\t\t\tvalid = True\n\t\t\n\t\tif (valid == False):\n\t\t\tbreak\n\n\tfor i in v:\n\t\tprint i,\n\nmain()\n"}, {"source_code": "n = raw_input()\n\nl = sorted([int(x) for x in raw_input().split()])\n\n\nprint \" \".join([str(x) for x in l])"}, {"source_code": "n = input()\n\nset = input()\nset=set.split(\" \")\nset=[int(num) for num in set]\nset.sort()\nset=[str(num) for num in set]\n\nres=\"\"\n\nfor num in set:\n res+=num+\" \"\n\nprint(res[0:-1])\n"}, {"source_code": "#import time\n#start_time = time.time()\n#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\ndef quicksort(array):\n # https: // tutorialedge.net / compsci / sorting / quicksort - in -python /\n # We define our 3 arrays\n less = []\n equal = []\n greater = []\n\n # if the length of our array is greater than 1\n # we perform a sort\n if len(array) > 1:\n # Select our pivot. This doesn't have to be\n # the first element of our array\n pivot = array[0]\n\n # recursively go through every element\n # of the array passed in and sort appropriately\n for x in array:\n if x < pivot:\n less.append(x)\n if x == pivot:\n equal.append(x)\n if x > pivot:\n greater.append(x)\n\n # recursively call quicksort on gradually smaller and smaller\n # arrays until we have a sorted list.\n return quicksort(less) + equal + quicksort(greater)\n else:\n return array\n\ninput()\nlist = input().split(\" \")\nfor i in range(0,len(list)):\n list[i] = int(list[i])\n\nnew_list = quicksort(list)\nfor i in range(0,len(new_list)):\n print(new_list[i], end = ' ')\n\n#print(\"--- %s seconds ---\" % (time.time() - start_time))\n"}, {"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())\nlis=gil()\nlis.sort()\nprint(' '.join(map(str,lis)))"}, {"source_code": "dlina=int(raw_input())\nkubiki=raw_input()\nkubiki=kubiki.split(' ')\n\nfor i in range(dlina):\n kubiki[i]=int(kubiki[i])\n\nkubiki.sort()\nfor i in kubiki:\n print i,"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n l.sort()\n for x in l:\n print(x, end= ' ')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\nn = ni()\na = nis()\n\nprint ' '.join(map(str, sorted(a)))\n \n"}, {"source_code": "n = int(raw_input())\narray = map(int, raw_input().split())\narray.sort()\nprint ' '.join(str(e) for e in array)\n"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n l.sort()\n for x in l:\n print(x, end= ' ')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\n\n\ntotal = int(sys.stdin.readline().strip('\\n').strip('\\r'))\ncolumn = sys.stdin.readline().strip('\\n').strip('\\r').split(\" \")\n# maxn = int(max(column))\n# solution = []\n# final = []\n#\nfor i in range(0, total):\n column[i] = int(column[i])\n#\n#\n# for i in range(0, total):\n# solution.append([1 for j in range(0, column[i])])\n# for k in range(0, maxn - column[i]):\n# solution[i].append(0)\n#\n# # Contamos las veces que hay un 1 por columna\n# totales = [0 for i in range(0, maxn)]\n# for i in range(0, maxn):\n# for j in range(0, total):\n# totales[i] += solution[j][i]\n#\n# for i in range(0, total):\n# fin = [0 for i in range(0, maxn)]\n# for j in range(0, maxn):\n# if totales[j] > 0:\n# fin[j] += 1\n# totales[j] -= 1\n# final.insert(0, fin)\n#\n# result = []\n# for i in range(total):\n# unos = 0\n# for j in range(0, maxn):\n# if final[i][j] == 1:\n# unos += 1\n# result.append(str(unos))\n#\ncolumn.sort()\nfor i in range(0, total):\n column[i] = str(column[i])\nr = ' '.join(column)\nprint(r)\n"}, {"source_code": "n = int(raw_input())\nlst = map(int, raw_input().split())\nfor i in range(n-1 , 0, -1):\n for j in range(i-1, -1, -1):\n if lst[i] < lst[j]:\n cur = lst[j] - lst[i]\n lst[i] = lst[i] + cur\n lst[j] = lst[j] - cur\n\n\nprint ' '.join(str(n) for n in lst)"}, {"source_code": "n = int(input())\na = sorted(list(map(int, input().split())))\na = [str(i) for i in a]\nprint(\" \".join(a))"}, {"source_code": "# #\n # author : samars_diary #\n # 12-09-2020 \u2502 10:57:25 #\n# #\n\nimport sys, os.path\n\nif(os.path.exists('input.txt')):\n sys.stdin = open('input.txt',\"r\")\n #sys.stdout = open('output.txt',\"w\")\n\nsys.setrecursionlimit(10 ** 5)\n\ndef i(): return sys.stdin.readline().strip()\ndef ii(): return int(sys.stdin.readline())\ndef li(): return list(sys.stdin.readline().strip())\ndef mii(): return map(int, sys.stdin.readline().split())\ndef lii(): return list(map(int, sys.stdin.readline().strip().split()))\n\n#print=sys.stdout.write\n\ndef solve():\n a=ii();b=lii();c=1\n while c!=a:\n c=1\n for i in range(a-1):\n if b[i]-b[i+1]>0:\n b[i],b[i+1]=b[i+1],b[i]\n else:\n c+=1\n print(' '.join([str(x) for x in b]))\nsolve()\n\n# # #\n# # author : samars_diary #\n# # 12-09-2020 \u2502 10:57:25 #\n# # #\n\n# import sys, os.path\n\n# if(os.path.exists('input.txt')):\n# sys.stdin = open('input.txt',\"r\")\n# #sys.stdout = open('output.txt',\"w\")\n\n# sys.setrecursionlimit(10 ** 5)\n\n# def i(): return sys.stdin.readline().strip()\n# def ii(): return int(sys.stdin.readline())\n# def li(): return list(sys.stdin.readline().strip())\n# def mii(): return map(int, sys.stdin.readline().split())\n# def lii(): return list(map(int, sys.stdin.readline().strip().split()))\n\n# #print=sys.stdout.write\n\n# def solve():\n# a=ii();b=lii();c=1\n# while c!=a:\n# c=1\n# for i in range(a-1):\n# if b[i]-b[i+1]>0:\n# b[i],b[i+1]=b[i+1],b[i]\n# else:\n# c+=1\n# print(*b, sep=' ')\n# solve()"}, {"source_code": "s=input()\nt=input()\na=t.split(\" \")\nx=[]\nfor i in a:\n x.append(int(i))\nz=sorted(x)\nans=\" \".join(str(i) for i in z )\nprint(ans)\n \n"}, {"source_code": "\t\t\nn = int(raw_input())\n\nlista = raw_input().split()\n\nfor i in xrange(len(lista)):\n\t\n\tlista[i] = int(lista[i])\n\nlista.sort()\n\nsaida = ''\nfor num in lista:\n\t\n\tsaida += str(num) + ' '\n\nprint saida[:-1]\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl.sort()\nfor i in l:\n print(i,end=\" \")"}, {"source_code": "import sys\n \nif __name__ == \"__main__\":\n count = int(sys.stdin.readline().rstrip())\n heights = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]\n for i in reversed(range(len(heights))):\n j = i\n while j < len(heights) - 1 and heights[j] > heights[j + 1]:\n diff = heights[j] - heights[j + 1]\n heights[j + 1] += diff\n heights[j] -= diff\n j += 1\n for i in heights:\n print(i, end = \" \")"}, {"source_code": "colnum = int(input())\n\ncols = raw_input().split()\n\nx=0\n\nif colnum == len(cols):\n cols = [int(i) for i in cols]\n cols.sort()\n print(' '.join(map(str, cols))) \n \n \n\n\n\n \n"}, {"source_code": "n = int(raw_input())\n\nlista = map(int, raw_input().split(\" \"))\nlista.sort()\nout = \"\"\nfor x in lista:\n out += str(x) + \" \"\nprint out\n"}, {"source_code": "n = int(input())\n\narr = [int(i) for i in input().split()]\n\nfor i in range(n - 1):\n for j in range(n - 1, i, -1):\n diff = arr[i] - arr[j]\n\n if diff > 0:\n arr[j] += diff\n arr[i] -= diff\n\nprint(*arr)\n"}, {"source_code": "import sys\n\nboxInput = []\n# boxInput.append(\"4\")\n# boxInput.append(\"3 2 1 2\")\nfor line in sys.stdin:\n boxInput.append(line)\n\nnumCols = int(boxInput[0])\ncols = []\nfor col in boxInput[1].split():\n cols.append(int(col))\n\nfor x in range(0, numCols):\n i = numCols - 1\n while i > 0:\n if cols[i] < cols[i-1]:\n diff = cols[i-1] - cols[i]\n cols[i] += diff\n cols[i-1] -= diff\n i -= 1\n\nresult = \" \".join(`col` for col in cols)\n# for x in range(0, numCols - 1):\n# result += \"{} \".format(cols[x])\n# result += \"{}\".format(cols[numCols-1])\n\nprint result\n"}, {"source_code": "input()\nprint(' '.join(map(str, sorted(map(int, raw_input().split())))))"}, {"source_code": "nums = int(input())\ncols = [int(x) for x in input().split()]\ncols.sort()\nprint(' '.join(str(num) for num in cols))"}, {"source_code": "n=input()\na=map(int,raw_input().split())\na.sort()\nfor i in a:\n print i,"}, {"source_code": "from sys import stdin\n\nn = int(stdin.readline().rstrip())\n\ncol = stdin.readline().rstrip().split(' ')\nnums = [int(v) for v in col]\n\nnums.sort()\n\nprint(\" \".join([str(w) for w in nums]))"}, {"source_code": "m = str(raw_input())\ng = map(int,raw_input().split())\ng.sort()\nfor i in g:\n\tprint i"}, {"source_code": "n = input()\na = input()\na = a.split(' ')\nfor i in range(len(a)):\n a[i] = int(a[i])\na.sort()\nfor i in range(len(a)):\n print(a[i], end = ' ')"}, {"source_code": "n = eval(input())\ncubes = [int(x) for x in input().split()]\ncubes.sort()\nfor i in range(n - 1):\n print(cubes[i],end = ' ')\nprint(cubes[n - 1])\n"}, {"source_code": "no = str(raw_input())\ncols = raw_input(\"\")\nfin = map(int,cols.split())\nfin.sort()\nfor block in fin:\n print block,"}, {"source_code": "no = str(raw_input())\nchs = map(int,raw_input().split())\nchs.sort()\nfor g in chs:\n print g,"}, {"source_code": "from sys import stdin\nn = stdin.readline() \narr = [int(x) for x in stdin.readline().split()] \n \nprint(*sorted(arr))"}, {"source_code": "columns = raw_input()\nentrada = raw_input()\n\narray = entrada.split(\" \")\nint_array = [int(a) for a in array]\nint_array.sort()\nresult = \"\"\nfor i in range(len(int_array)):\n result += str(int_array[i]) + \" \"\nprint result"}, {"source_code": "n = input()\na = raw_input()\na = a.split()\na = [int(x) for x in a]\ni=0\nfor b in range(n):\n i=0\n for el in a:\n if i == (n-1):\n break\n if a[i]>a[i+1]:\n z = a[i]\n a[i] = a[i+1]\n a[i+1] = z\n # print 'ok'\n #print a\n #else:\n #print 'no'\n \n \n i+=1\nprint ' '.join([str(x) for x in a])"}, {"source_code": "num_of_cols = int(input())\nx = raw_input().split()\n\ni = 0\nj = 0\nlist1 = []\nlist2 = []\n\nwhile i < num_of_cols:\n num_of_blocks = int(x[i])\n list1.append(num_of_blocks)\n i = i + 1\n\nlist1.sort()\n\nwhile j < num_of_cols:\n list2.append(str(list1[j]))\n j = j + 1\n\nprint ' '.join(list2)"}, {"source_code": "n = int(input())\na = input().split()\nx = []\nfor i in range (n):\n x.append(int(a[i]))\nx.sort()\nfor i in range(n):\n print(x[i] , end=\" \")"}, {"source_code": "n = int(input())\na = input().split()\nx = []\nfor i in range (n):\n x.append(int(a[i]))\nx.sort()\nfor i in range(n):\n print(x[i] , end=\" \")"}, {"source_code": "num_of_cols = int(input())\nx = raw_input().split()\n\ni = 0\nj = 0\nlist1 = []\nlist2 = []\n\nwhile i < num_of_cols:\n num_of_blocks = int(x[i])\n list1.append(num_of_blocks)\n i = i + 1\n\nlist1.sort()\n\nwhile j < num_of_cols:\n list2.append(str(list1[j]))\n j = j + 1\n\nprint ' '.join(list2)"}, {"source_code": "n = int(input())\nx = [int(i) for i in input().split()]\nx.sort()\nprint(' '.join([str(i) for i in x]))\n"}, {"source_code": "n = input()\narr = map(int,raw_input().split())\narr.sort()\nfor x in arr :\n\tprint x,\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 ())\nl = [int (i) for i in raw_input ().split ()]\nG = []\nx = []\nwhile True:\n cnt = 0\n for i in range (N):\n if l [i]:\n l [i] -= 1\n cnt += 1\n if not cnt: break\n x.append (cnt)\nm = max (x)\nfor i in x:\n G.append ([1] * i + [0] * (m - i))\nret = [0] * N\nfor j in range (len (G [0])):\n for i in range (len (G)):\n ret [j] += G [i][j]\nret.reverse()\nprint \" \".join (str (i) for i in ret)\n"}, {"source_code": "n = int(input())\ncols = list(map(int, input().split()))\ncols.sort()\n\nfor col in cols:\n print(col, end=\" \")\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nfor i in range(n):\n for j in range(n-1 ):\n if s[j] > s[j+1]:\n s[j], s[j+1] = s[j+1], s[j]\nprint(*s)\n\n"}, {"source_code": "_input = input('')\n\n_list = sorted(list(map(int, input().split())))\nprint(*_list)"}, {"source_code": "input()\nx = sorted(map(int,raw_input().split()))\nfor i in x:\n\tprint `i`\n"}, {"source_code": "\"\"\"\nGravity Flip Problem Resolution.\n\"\"\"\n# Packages and Libraries.\nimport sys\n\n\n# Function definitions.\ndef quicksort(arr):\n lesser = []\n equal = []\n greater = []\n if len(arr)>1:\n pivot = arr[len(arr)-1]\n start = 0\n while start pivot:\n greater.append(arr.pop(start))\n elif arr[start] < pivot:\n lesser.append(arr.pop(start))\n else:\n start = start + 1\n return (quicksort(lesser) + arr + quicksort(greater))\n else:\n return (arr)\n\n\ndef my_sort(input_file):\n n = int(input_file.readline())\n a = [int(x) for x in input_file.readline().split()]\n a = quicksort(a)\n for val in a:\n print(val)\n\n\n# Execution.\nmy_sort(sys.stdin)\n"}, {"source_code": "input()\nprint(*sorted(list(map(int, input().split()))))"}, {"source_code": "def merge(arr1, arr2):\n\tl1, l2 = len(arr1), len(arr2)\n\ti, j, k = 0, 0, 0\n\twhile i < l1 or j < l2:\n\t\tif i < l1 and j < l2:\n\t\t\tif arr1[i] < arr2[j]:\n\t\t\t\tyield arr1[i]\n\t\t\t\ti += 1\n\t\t\telse:\n\t\t\t\tyield arr2[j]\n\t\t\t\tj += 1\n\t\telif i < l1 and j >= l2:\n\t\t\tyield arr1[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tyield arr2[j]\n\t\t\tj += 1\n\t\tk += 1\n\treturn\n\ndef sort_cube(arr):\n\tif len(arr) < 2:\n\t\treturn arr\n\treturn list(merge(sort_cube(arr[0:len(arr)//2]), sort_cube(arr[len(arr)//2:])))\ninput()\ncube = sort_cube(list(map(int, input().split())))\nfor column in cube:\n\tprint(column, end = \" \")\n"}, {"source_code": "n = int(input())\nl = sorted(list(map(int,raw_input().split())))\nfor i in l:\n print i,"}, {"source_code": "#!/usr/bin/env python\n\nimport math\n\ndef main():\n\n\tn = int(raw_input())\n\tv = raw_input().split(' ');\n\n\tv = [int(i) for i in v]\n\n\twhile True:\n\t\tvalid = False\n\t\t\n\t\tfor i in range(0, n-1):\n\t\t\tif (v[i] > v[i+1]):\n\t\t\t\tdiff = abs(v[i]-v[i+1])\n\t\t\t\tv[i] = v[i]-diff\n\t\t\t\tv[i+1] = v[i+1] + diff\n\t\t\t\tvalid = True\n\t\t\n\t\tif (valid == False):\n\t\t\tbreak\n\n\tfor i in v:\n\t\tprint i,\n\nmain()\n"}, {"source_code": "from sys import stdin\n\"\"\"\nORDENAMIENTO_3\nOBJETIVO: ORDENAR UN VECTOR\nYEISSON FABIAN GUALDRON VIVAS\n04/04/2017\n\"\"\"\n#pre:recivir un vector como parametro\n#pos:imprimir el mismo vector pero con sus elementos ordenados\n\ndef main():\n y=int(stdin.readline())\n lista=[int(x) for x in stdin.readline().split()]\n if y==1:\n print(lista[0])\n else:\n rang=1\n cont=0\n lista=order_r(lista,rang,cont)\n for i in lista:\n print(i,end=' ')\n \ndef order_r(lista,rang,cont):\n i=0\n lista=after(lista,(cont+1),(i))\n if rang <(len(lista)-1):\n cont+=1\n return order_r(lista,(rang+1),cont)\n else:\n return lista\n\ndef after(lista,cont,i):\n if lista[cont] < lista[i]:\n cache=lista[i]\n lista[i]=lista[cont]\n lista[cont]=cache\n if i=-dlina:\n j=i\n while j<=-2:\n if kubiki[j]>kubiki[j+1]:\n raznica=kubiki[j]-kubiki[j+1]\n kubiki[j]-=raznica\n kubiki[j+1]+=raznica\n j+=1\n i-=1\n for i in kubiki:\n print i,"}, {"source_code": "n = int(input())\ns = input().split()[:n]\ns = [int(i) for i in s]\ns.sort()\nprint(*s)\n"}, {"source_code": "number_of_columns = int(input())\nnumbers = [int(i) for i in input().split(' ')]\n\nnumbers = [str(i) for i in sorted(numbers)]\nprint(' '.join(numbers).strip())\n\n"}, {"source_code": "# coding: utf-8\n \nn = int(raw_input())\nheight = map(int, raw_input().split())\nheight.sort()\n \nfor i in height:\n\tprint i,"}, {"source_code": "dlina=int(raw_input())\nkubiki=raw_input()\n\nif dlina == 1:\n print kubiki\n\nelse:\n kubiki=kubiki.split(' ')\n for i in range(dlina):\n kubiki[i]=int(kubiki[i])\n \n i=-2\n while i>=-dlina:\n j=i\n while j<=-2:\n if kubiki[j]>kubiki[j+1]:\n raznica=kubiki[j]-kubiki[j+1]\n kubiki[j]-=raznica\n kubiki[j+1]+=raznica\n j+=1\n i-=1\n for i in kubiki:\n print i,"}, {"source_code": "n = int (input())\ns = list(map(int, input().split()))\nfor i in range(len(s)-1, 0 , -1):\n for j in range(i):\n if s[j] > s[j+1]:\n s[j], s[j+1] = s[j+1], s[j]\nprint(*s)"}, {"source_code": "raw_input()\nrows = [int(n) for n in raw_input().split(\" \")]\nprint \" \".join(str(n) for n in sorted(rows))\n"}, {"source_code": "n = int(input())\ns = input().split()\ns = [int(i) for i in s]\ns.sort()\ns = [str(i)for i in s]\nprint(\" \".join(s))\n"}, {"source_code": "count = raw_input()\nnumbers = raw_input().split()\nnumbers.sort(key=int)\n\ns = \"\"\nfor i in numbers:\n\ts = s + i + \" \"\n\nprint s"}, {"source_code": "n = input()\n\nset = input()\nset=set.split(\" \")\nset=[int(num) for num in set]\nset.sort()\nset=[str(num) for num in set]\n\nres=\"\"\n\nfor num in set:\n res+=num+\" \"\n\nprint(res[0:-1])\n"}, {"source_code": "n=input()\na=map(int,raw_input().split())\na.sort()\nfor x in a:\n print x,"}, {"source_code": "A = int(input())\nB = [int(x) for x in input().split()]\nB.sort()\nD = str(B[0])\nfor x in range(1, A):\n D = D + ' ' +str(B[x])\nT = len(D)\nprint(D[0:T])\n\n"}, {"source_code": "x = int(input())\ny = list(sorted(map(int,input().split())))\nprint(*y)\n"}, {"source_code": "# Kristian Radam 4CSA\n\nn = int(raw_input())\nassert(n >= 1 & n <= 100)\n\na = raw_input().split()\nassert(len(a) == n)\n\ni = 0\nwhile (i < len(a)):\n\ta[i] = int(a[i])\n\tassert(a[i] >= 1 & a[i] <= 100)\n\ti += 1\n\nstack = [0] * max(a)\n\ni = 0\nwhile(i < len(stack)):\n\tctr = 0\n\tfor x in a:\n\t\tif ((x - i) > 0):\n\t\t\tctr += 1\n\tstack[i] = ctr\n\ti += 1\n\nlength = len(a)\na = [0] * len(a)\nfor t in stack:\n\ti = length - 1\n\twhile (t != 0):\n\t\ta[i] += 1\n\t\tt -= 1\n\t\ti -= 1\n\nprint \" \".join(map(str, a))"}, {"source_code": "no = str(raw_input())\ncols = raw_input(\"\")\nfin = map(int,cols.split())\nfin.sort()\nfor block in fin:\n print block,"}, {"source_code": "x = int(input())\ny = list(sorted(map(int,input().split())))\nprint(*y)\n"}, {"source_code": "#!/usr/bin/env python3\n\n# pylint: disable = bad-whitespace\n# pylint: disable = invalid-name\n# pylint: disable = missing-docstring\n\n# --------------\n# GravityFlip.py\n# --------------\n\n\"\"\"\nA. Gravity Flip\nhttp://codeforces.com/problemset/problem/405/A/\n\nMon, 25 Jan 2016\nPython 3.5.1: 62 ms, 0 KB\n\"\"\"\n\nfrom sys import stdin\n\ndef test_case (a) :\n s = sorted(a)\n for v in s :\n print(v, end=\" \")\n print()\n\n# c = [str(v) for v in b]\n# d = ' '.join(c)\n# print(d)\n\ndef main () :\n for _ in stdin :\n a = [int(v) for v in input().split()]\n test_case(a)\n\nif __name__ == \"__main__\" :\n main()\n"}, {"source_code": "no = str(raw_input())\ncols = raw_input(\"\")\nfin = map(int,cols.split())\nfin.sort()\nfor block in fin:\n print block,"}, {"source_code": "n = int(input())\narr = [int(i) for i in input().split()]\nstore = {}\n#counting sort\nfor i in range(n):\n try:\n store[arr[i]] += 1\n except:\n store[arr[i]] = 1\n\n\nresult = []\nfor j in range(101):\n try:\n result = result + [j] * store[j]\n except:\n pass\n\nprint(*result)"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\narr=sorted(arr)\nprint(*arr)"}, {"source_code": "# Codeforces 405A: Gravity Flip\n\ncolumns = int(raw_input())\ncubes = map(int, raw_input().split())\n\nfor i in xrange(columns - 1):\n for j in xrange(columns - i - 1):\n if (cubes[j] > cubes[j + 1]):\n cubes[j], cubes[j + 1] = cubes[j + 1], cubes[j]\n\nprint \" \".join(map(str, cubes))"}, {"source_code": "no = str(raw_input())\ncols = raw_input(\"\")\nfin = map(int,cols.split())\nfin.sort()\nfor block in fin:\n print block,"}, {"source_code": "n=input()\ns=input()\nl=[]\nfor i in map(int,s.split()):\n #print(i)\n l.append(i)\n\n#print(l)\na=' '.join(map(str, sorted(l)))\nprint(a)"}, {"source_code": "#!/usr/bin/env python3\n\n\"\"\"\nA. Gravity Flip\nhttp://codeforces.com/problemset/problem/405/A/\n\nSat, 5 Sep 2015\nPython 3.4: 61 ms, 0 KB\n\"\"\"\n\nfrom sys import stdin\n\ndef main () :\n input()\n s = input()\n a = (int(v) for v in s.split())\n b = sorted(a)\n c = (str(v) for v in b)\n d = ' '.join(c)\n print(d)\n\nif __name__ == \"__main__\" :\n main()\n"}, {"source_code": "# Kristian Radam 4CSA\n\nn = int(raw_input())\nassert(n >= 1 & n <= 100)\n\na = raw_input().split()\nassert(len(a) == n)\n\ni = 0\nwhile (i < len(a)):\n\ta[i] = int(a[i])\n\tassert(a[i] >= 1 & a[i] <= 100)\n\ti += 1\n\nstack = [0] * max(a)\n\ni = 0\nwhile(i < len(stack)):\n\tctr = 0\n\tfor x in a:\n\t\tif ((x - i) > 0):\n\t\t\tctr += 1\n\tstack[i] = ctr\n\ti += 1\n\nlength = len(a)\na = [0] * len(a)\nfor t in stack:\n\ti = length - 1\n\twhile (t != 0):\n\t\ta[i] += 1\n\t\tt -= 1\n\t\ti -= 1\n\nprint \" \".join(map(str, a))"}, {"source_code": "noc= int(raw_input())\ncubes= raw_input().split()\ncubes.sort(key=int)\n\nprint \" \".join(str(x) for x in cubes)"}, {"source_code": "n=int(input())\na=[int(i) for i in input().split()]\nb=a\nb.sort()\nt=0\nwhile b!=a:\n while t maximum):\n maximum = int(numPerCol[counter])\n counter += 1\n\n#Formulate the length x width of box\nbox = [[0 for y in xrange(maximum)] for x in xrange(colNum)]\n\n#Formulate the shifted version of it\nboxShift = [[0 for y in xrange(colNum)] for x in xrange(maximum)]\n\n#List for final count of cubes\nfinalCount = [0]*colNum\n\n#Put the cubes per column\ncounter = 0\nwhile(counter < colNum):\n counterCube = 0\n \n while(counterCube < int(numPerCol[counter])):\n box[counter][counterCube] = 1\n counterCube += 1\n \n counter += 1\n\n# finalCount[counter]print(box)\n\n#Shift gravittttyyyy!\ncounter = 0\nshiftLength = len(boxShift)\n\nwhile(counter < shiftLength):\n counterCube = 0\n \n #the main factor to shift the cube's gravity --- will be used as an index\n countMe = 0\n \n while(counterCube < colNum):\n \n if(box[counterCube][counter] == 1):\n boxShift[counter][countMe] = 1\n countMe += 1\n\n counterCube += 1\n \n counter += 1\n\n#print(boxShift)\n\n#Count per column (normal gravity)\ncounter = 0\nwhile(counter < colNum):\n counterCube = 0\n \n while(counterCube < shiftLength):\n if(boxShift[counterCube][counter] == 1):\n finalCount[counter] += 1\n\n counterCube += 1\n\n counter += 1\n\nfinalCount.reverse()\n\n#Convert the finalCount list's values to string\ncounter = 0\nwhile(counter < colNum):\n finalCount[counter] = str(finalCount[counter])\n counter += 1\n \n#print(finalCount)\nprint(\" \".join(finalCount))\n"}, {"source_code": "# Yambao, Christine Nyries L.\n# 4CSB\n\nn_columns = int(raw_input())\nn_cubes_per_column = [int(x) for x in raw_input().split(' ')]\n\nfor i in range(n_columns - 1):\n\tfor i in range(n_columns - 1):\n\t\tif n_cubes_per_column[i] > n_cubes_per_column[i + 1]:\n\t\t\texcess_cubes = n_cubes_per_column[i] - n_cubes_per_column[i + 1]\n\t\t\tn_cubes_per_column[i] -= excess_cubes\n\t\t\tn_cubes_per_column[i + 1] += excess_cubes\n\nprint ' '.join(str(x) for x in n_cubes_per_column)\n\n"}, {"source_code": "n = input()\na = raw_input()\na = a.split()\na = [int(x) for x in a]\na.sort()\nprint ' '.join([str(x) for x in a])"}, {"source_code": "n = int(input())\na = input().split()\nx = []\nfor i in range (n):\n x.append(int(a[i]))\nx.sort()\nfor i in range(n):\n print(x[i] , end=\" \")"}, {"source_code": "colNumber = input(\"\")\ncubes = map(int,raw_input().split())\ncubes.sort() #gravity to right (ascending since column with highest number of boxest momove rin sa rightmost column\nfor num in cubes:\n\tprint num,\n"}, {"source_code": "n = int(input())\nd = list(map(int, input().split()))\nc = sorted(d)\nfor i in range(len(c)):\n print('{} '.format(c[i]))"}], "negative_code": [{"source_code": "n = int(input())\nstructure = input().split(\" \")\n\nfor i in range(len(structure)):\n structure[i] = int(structure[i])\n\nstructure.sort()\n\nfinal = \"\"\nfor i in range(len(structure)):\n if final == \"\":\n final += str(structure[i])\n else:\n final += (\" \" + str(structure[i]))"}, {"source_code": "#!/usr/bin/env Python3\nn=int(input())\nm=input()\n\ncubes=m.split()\ncubes.sort()\n\nprint (' '.join(cubes))"}, {"source_code": "colunas = int(raw_input())\nlista = raw_input().split()\nlista = [int(i) for i in lista]\n\nmatriz = []\nfor i in range(colunas):\n\tmatriz.append([])\n\tfor j in range(max(lista)):\n\t\tmatriz[i].append(0)\n\nfor i in range(colunas):\n\tfor j in range(lista[i]):\n\t\tmatriz[i][j] = 1\n\nnew_pos = [0] * colunas\nfor i in range(colunas):\n\tfor j in range(max(lista)):\n\t\tif matriz[i][j] == 1:\n\t\t\tnew_pos[i] += 1\n\nfor i in new_pos:\n\tprint i, ' ',\n"}, {"source_code": "from sys import stdin\n\nsize = stdin.readline()\nl = stdin.readline().split()\n\n\nl.sort()\nprint(l)"}, {"source_code": "import sys\n\ninp = sys.stdin.readline()\ninp = sys.stdin.readline()\n\ninp = inp.split(\" \")\n\n#print(inp)\n\ninp.sort()\n\n#print(inp)\nfor stack in inp:\n print (stack.strip(\"\\n\"))\n"}, {"source_code": "raw_input()\nprint \" \".join(sorted(raw_input().split(' ')))"}, {"source_code": "def gravity_flip(m):\n return sorted(m)\nif __name__ == '__main__':\n n = int(input())\n a = list(map(str, input().split()))\n print(\" \".join(gravity_flip(a)))"}, {"source_code": "useless = input()\ndef newGravityOrder(order):\n order.sort()\n return order\nfor i in newGravityOrder(list(map(int,input().split(' ')))):\n print(i,end = '')"}, {"source_code": "def Gravity():\n\tFirstInput = int(input())\n\n\tSecondInput = input()\n\tSecondInput=[int(s) for s in SecondInput.split(' ')]\n\n\tarray=SecondInput\n\tDifference=0\n\tif FirstInput ==0:\n\t\treturn 0\n\telif FirstInput ==1:\n\t\treturn SecondInput[0]\n\telse:\n\n\t\tfor x in range(FirstInput-1):\n\t\t\tif(x==FirstInput-2):\n\t\t\t\tif(SecondInput[x]>SecondInput[x+1]):\n\t\t\t\t\tDifference=SecondInput[x]-SecondInput[x+1]\n\t\t\t\t\tSecondInput[x]=SecondInput[x]-Difference\n\t\t\t\t\tSecondInput[x+1]=SecondInput[x+1]+Difference\n\n\t\t\telif(SecondInput[x]>SecondInput[x+1]):\n\t\t\t\tSecondInput[x]=SecondInput[x]-SecondInput[x+1]\n\t\t\t\tSecondInput[x+1]=SecondInput[x+1]+SecondInput[x]\n\n\tprint (SecondInput)\n\n\n\nGravity()"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\narr.sort()\nprint(arr)"}, {"source_code": "from sys import stdin\n\nsize = stdin.readline()\nl = stdin.readline().split()\n\n\nl.sort()\n\nfor i in l:\n print(\"your message\")\n print(i, end = \" \")"}, {"source_code": "n=int(input())\ns=[int(x) for x in input().split()]\ns.sort()\ns=[str(x) for x in s]\nprint(\"\".join(s))\n"}, {"source_code": "import sys\n\ndef gravityFlip(cols, ints):\n\tfor idx in range(0, cols-1):\n\t\tdesc = 1\n\t\tfor col in range(0, cols-desc):\n\t\t\tif int(ints[col]) > int(ints[col+1]):\n\t\t\t\ttemp = int(ints[col]) - int(ints[col-1])\n\t\t\t\tints[col] = int(ints[col]) - temp\n\t\t\t\tints[col-1] = int(ints[col-1]) + temp\n\t\t\tdesc = desc+1\n\tfor num in ints:\n\t\tprint(int(num))\n\ndef main():\n\tcols = int(input())\n\tints = input().split()\n\treturn gravityFlip(cols, ints)\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n = input()\na = input()\na = a.split(' ')\na.sort()\na = ' '.join(a)\nprint(a)\nprint(' ')"}, {"source_code": "n=int(input())\nk,s=input().split(),''\nk.sort()\nfor i in k:\n s=s+i\nprint(s)\n"}, {"source_code": "input()\ni=list(map(int,input().split()))\ni.sort()\nprint(j for j in i)"}, {"source_code": "line=int(input())\nnumbers=list(input().split())\nnew_list=sorted(numbers)\nif '100' in new_list:\n index1=new_list.index('100')\n new_list.pop(index1)\n new_list.append('100')\nfor number in new_list:\n print(number,end=' ')"}, {"source_code": "n = input()\nset = input()\nres = []\nif int(n)>0:\n set=list(set)\n for i in set:\n if i.isnumeric():\n res.append(i)\nres.sort()\nto_print=\"\"\n\nfor j in res:\n to_print+=j+\" \"\n\nprint(to_print[0:-1])\n"}, {"source_code": "def gravity_cube(input):\n size_col = 0\n square_counter = []\n for line in input:\n if line == \"\\n\":\n continue\n else:\n if size_col == 0:\n size_col = int(line)\n else:\n for char in line:\n if char == \" \":\n continue\n else:\n square_counter.append(int(char))"}, {"source_code": "input()\nx=list(raw_input().split())\nprint (' '.join(map(str,sorted(x))))"}, {"source_code": "n=int(input())\ns=[int(x) for x in input().split()]\ns.sort()\ns=[str(x) for x in s]\nprint(''.join(s))\n"}, {"source_code": "n=int(input())\nc=input().split()\nc.sort()\nprint(\" \".join(c))"}, {"source_code": "input();l = list(input().split());sorted(l);print(' '.join(l))"}, {"source_code": "import sys\n \nif __name__ == \"__main__\":\n count = int(sys.stdin.readline().rstrip())\n heights = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]\n for i in reversed(range(len(heights))):\n j = i\n print(j)\n while j < len(heights) - 1 and heights[j] > heights[j + 1]:\n diff = heights[j] - heights[j + 1]\n heights[j + 1] += diff\n heights[j] -= diff\n print(j, heights, diff)\n j += 1\n print(heights)"}, {"source_code": "n = int(input())\nA = list(map(int,input().split()))\nprint(sorted(A))"}, {"source_code": "li=[]\nn=input()\ns=input()\nli=s.split(\" \")\nli.sort()\nprint(li)"}, {"source_code": "\n#parse and setup\nnumCol = input()\narr = []\n#for i in range (0, numCol) :\n #add = input()\n #print (add)\n #arr.insert(add)\n\n#debug\nprint (arr)\n\n#begin gravity shift\n#start from second to last\nsize = len(arr)\nprint (size)\nif size == 1 :\n print (arr[0])\nelse :\n index = size - 2\n while index >= 0 :\n #if arr[index] > arr[index+1] :\n #diff = arr[index+1] - arr[index]\n #arr[index+1] += diff\n #arr[index] -= diff\n index-=1;\n\n #get return value\n ret = \"\"\n for i in arr:\n ret += i\n\n print (ret)\n"}, {"source_code": "n=input()\nprint(*sorted(list(map(int,input().split())),reverse=True))"}, {"source_code": "\n# Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.\n\n# There are n columns of toy cubes in the box arranged in a line. The i-th column contains a i cubes. At first, the gravity in the box is pulling the cubes downwards. When Chris switches the gravity, it begins to pull all the cubes to the right side of the box. The figure shows the initial and final configurations of the cubes in the box: the cubes that have changed their position are highlighted with orange.\n\n\n# Given the initial configuration of the toy cubes in the box, find the amounts of cubes in each of the n columns after the gravity switch!\n\n# Input\n# The first line of input contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100), the number of the columns in the box. The next line contains n space-separated integer numbers. The i-th number a i (1\u2009\u2264\u2009a i\u2009\u2264\u2009100) denotes the number of cubes in the i-th column.\n\n# Output\n# Output n integer numbers separated by spaces, where the i-th number is the amount of cubes in the i-th column after the gravity switch.\n\n# Examples\n# inputCopy\n# 4\n# 3 2 1 2\n# outputCopy\n# 1 2 2 3\n# inputCopy\n# 3\n# 2 3 8\n# outputCopy\n# 2 3 8\n# Note\n# The first example case is shown on the figure. The top cube of the first column falls to the top of the last column; the top cube of the second column falls to the top of the third column; the middle cube of the first column falls to the top of the second column.\n\n# In the second example case the gravity switch does not change the heights of the columns.\n\nn = int(input())\ncubes = list(map(str, input().split(' ')))\ncubes.sort()\nprint(' '.join(cubes))\n"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\n cols = list(map(int, input().split()))\n\n res = 0 \n old_cols = list()\n j = 0\n while(old_cols != cols): \n #print(old_cols, cols)\n old_cols = cols.copy()\n for i in range(len(cols) - 1):\n res = cols[i] - cols[i+1]\n if res > 0:\n cols[i+1] += res\n cols[i] -= res\n #print(old_cols, cols)\n j += 1\n #print(j)\n print(cols)"}, {"source_code": "\ninput()\nlista = input().split(' ')\n\nlista2 = list(lista)\n\nlista2.sort()\n\nstring = ''\nfor i in lista2:\n string = string+i+' '\n\nprint(string)"}, {"source_code": "n=int(input())\nl=input().split()\nl.sort()\nprint(*l)"}, {"source_code": "input()\nlista = input().split(' ')\nlista.sort()\nprint(*lista)\n"}, {"source_code": "#Gravity.py\n#Granadino, Shara Mae I.\n\nx = input() \ny = raw_input().split()\n\nints = [int(l[0]) for l in y]\n\nnewlist =(sorted (y))\n\nprint ' '.join(newlist)\n \n\n\n\n\n\n"}, {"source_code": "n = int(input())\nm = sorted(input().split())\nprint(' '.join(m))"}, {"source_code": "num_cols = int(raw_input())\ncols = map(int, raw_input().split())\n\ncols.sort()\n\nprint cols\n\t\t\n\t\t\n"}, {"source_code": "n = raw_input()\nb = sorted(raw_input().split())\nprint b"}, {"source_code": "# GRAVITY.PY\n\ncolumns = int(input())\nnumberPerColumn = raw_input().split()\nnumberPerColumn.sort()\nretValString = \"\"\n\nfor y in range(0,columns):\n retValString += numberPerColumn[y] + \" \"\n \nprint retValString\n\n \n"}, {"source_code": "x=input()\ny=list(map(int,input().split()))\nprint(sorted(y))\n"}, {"source_code": "input()\ni=list(map(int,input().split()))\nprint(j for j in sorted(i))"}, {"source_code": "n=int(input())\nc=input().split()\nc.sort()\nprint(\" \".join(c))"}, {"source_code": "nn=int(input())\narr=list(map(int,input().split()))\ntemp=sorted(arr)\ni=0\nwhile arr!=temp:\n arr[0]-=1\n arr[-i-1]+=1\n i+=1\nprint(arr)\n"}, {"source_code": "n = input()\nlist = list(map(int,input().split(' ')))\nlist.sort()\nprint(list)"}, {"source_code": "n=int(input())\nstrarr=str(input())\narr=strarr.split()\narr.sort()\n\nprint (arr)\n"}, {"source_code": "n = input()\na = input()\na = a.split(' ')\na.sort()\na = ' '.join(a)\nprint(a)"}, {"source_code": "coluna = int(raw_input())\ncubosPorColuna = map(int,raw_input().split())\ncubosPorColuna.sort()\nprint cubosPorColuna"}, {"source_code": "n = int(input()) #\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432\na = []\n#for i in range(n):\na[:n-1] = input().split()\na.sort()\na = ' '.join(a)\nprint(a)"}, {"source_code": "import sys\nnum_cols = sys.stdin.readline()\ncols = sys.stdin.readline()\ncol_array = [int(i) for i in cols.split(\" \")]\ncol_array.sort()\nresult = \" \".join(cols)\nprint(result)"}, {"source_code": "T = int(raw_input())\nli = [raw_input().split()]\n#li = [int(i) for i in li]\nli.sort()\nprint li\n"}, {"source_code": "input()\nl=map(int,input().split())\nm=str(sorted(l))\nprint(' '.join(m))\n"}, {"source_code": "number_of_columns = int(input())\nnumbers = input().split(' ')\n\nnumbers = sorted(numbers)\nprint(' '.join(numbers).strip())\n\n"}, {"source_code": "import sys\n\ninp = sys.stdin.readline()\ninp = sys.stdin.readline()\n\ninp = inp.split(\" \")\n\ninp.sort();\n\nprint(inp)\n"}, {"source_code": "n = int(input())\n \na = list(map(int,input().split()))\n \n \na.sort(reverse = True)\n\nfor i in a:\n \n print(i,end = ' ')"}, {"source_code": "from sys import stdin\n\nsize = stdin.readline()\nl = stdin.readline().split()\n\n\nl.sort()\n\nfor i in l:\n print(i, end = \" \")"}, {"source_code": "line=int(input())\nnumbers=list(input().split())\nnew_list=sorted(numbers)\na=0\nif '100' in new_list:\n while True:\n if '100' not in new_list:\n break\n else:\n index1=new_list.index('100')\n new_list.pop(index1)\n a+=1\nfor i in range(1,a+1):\n new_list.append('100')\nfor number in new_list:\n print(number,end=' ')"}, {"source_code": "n=int(input())\nprint(list(map(int,input().split())).sort())"}, {"source_code": "n = input()\ncol = [int(i) for i in raw_input().split()]\ni = 0\n\nprint col\nwhile(i < n-1):\n\tif(col[i] > col[i+1]):\n\t\tcol[i+1] += (col[i+1] - col[i])\n\ti+=1\n\nfor i in col:\n\tprint i,\n\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl=list(reversed(l))\na=''\nfor i in range(n-1):\n\tif l[i] 0 and cube[hole] < cube[hole - 1]:\n\t\t\tcube[hole], cube[hole - 1] = cube[hole - 1], cube[hole]\n\treturn cube\nsorted_cube = sort_column(list(map(int,input().split())))\nfor column in sorted_cube:\n print(column, end=\" \")\n"}, {"source_code": "n = input()\na = list(map(int, input().split()))\na.sort()\nprint(a)"}, {"source_code": "def merge(arr1, arr2):\n\tl1, l2 = len(arr1), len(arr2)\n\ti, j, k = 0, 0, 0\n\twhile i < l1 or j < l2:\n\t\tif i < l1 and j < l2:\n\t\t\tif arr1[i] < arr2[j]:\n\t\t\t\tyield arr1[i]\n\t\t\t\ti += 1\n\t\t\telse:\n\t\t\t\tyield arr2[j]\n\t\t\t\tj += 1\n\t\telif i < l1 and j >= l2:\n\t\t\tyield arr1[i]\n\t\t\ti += 1\n\t\telse:\n\t\t\tyield arr2[j]\n\t\t\tj += 1\n\t\tk += 1\n\treturn\n\ndef sort_cube(arr):\n\tif len(arr) < 2:\n\t\treturn arr\n\treturn list(merge(sort_cube(arr[0:len(arr)//2]), sort_cube(arr[len(arr)//2:])))\ncube = sort_cube([1,2,3,41,12,12,0,-1])\nfor column in cube:\n\tprint(column, end = \" \")\n"}, {"source_code": "from sys import stdin\n\nsize = stdin.readline()\nl = stdin.readline().split()\n\n\nl.sort()\n\nfor i in l:\n print(i, end = \" \")"}, {"source_code": "# import sys\n\n# import numpy as np\n\n# def line_generator():\n# for line in sys.stdin:\n# yield line\n\n# line = line_generator()\n\n\nif __name__ == '__main__':\n pass\n # Read lines\n # n = next(line)\n # col_heights = next(line)\n\n # # Convert to ints\n # n = int(n.strip())\n # col_heights = [int(col_str) for col_str in col_heights.split()]\n\n\n # # Transform Input\n # box = np.zeros([max(col_heights), n])\n # for c, col_height in enumerate(col_heights):\n # box[-col_height:, c] = 1\n\n # # Tip Sideways\n # for i, row in enumerate(box):\n # num_zeros = np.sum(row == 0)\n # box[i, :num_zeros], box[i, num_zeros:] = 0, 1\n\n # # Count Number of Columns\n # new_col_heights = box.sum(axis=0, dtype=np.int)\n\n # print(' '.join(str(new_col_height) for new_col_height in new_col_heights))\n"}, {"source_code": "from sys import stdin, stdout\n\nq = int(stdin.readline().rstrip())\nnumeros = stdin.readline().rstrip()\nnumeros = numeros.split(' ')\nnumeros.sort()\n\nfor numero in numeros:\n stdout.write(numero + ' ')"}, {"source_code": "input()\nx=input().split()\no=\"\"\nfor i in sorted(x):\n o=o+i+\" \"\nprint(o) \n"}, {"source_code": "n = int(input())\nprint(sorted(list(map(int, input().split()))))\n\n"}, {"source_code": "inp=int(raw_input())\ninp2=raw_input().split()\nans=' '.join(sorted(inp2))\nprint ans\n'''for i in ans:\n\ti=i.split(\" \")\n\ts.append(i)\n#org=' '.join(ans)\nprint s'''\n"}, {"source_code": "\n\n\n\ncolumns = input()\nlistOfInputs = input().split()\nl = sorted(listOfInputs)\nfor n in range(len(l)):\n print(l[n], end = \" \")\n"}, {"source_code": "import sys\n \nif __name__ == \"__main__\":\n count = int(sys.stdin.readline().rstrip())\n heights = [int(i) for i in sys.stdin.readline().rstrip().split(' ')]\n for i in reversed(range(len(heights))):\n j = i\n print(j)\n while j < len(heights) - 1 and heights[j] > heights[j + 1]:\n diff = heights[j + 1] - heights[j]\n heights[j + 1] += diff\n heights[j] -= diff\n j += 1\n print(j, heights, diff)\n print(heights)"}, {"source_code": "numbers = raw_input().split()\nnumbers.sort()\ns = \"\"\nfor i in numbers:\n\ts = s + i + \" \"\n\nprint s"}, {"source_code": "n=int(input())\nstrarr=str(input())\narr=strarr.split()\narr.sort()\n\nprint (arr)\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl=sorted(l)\nprint(\"\".join(str(x) for x in l))"}, {"source_code": "num = int(raw_input())\n\nc = 1\n\n\nnums = raw_input().split(\" \")\nnums.sort()\ns = nums[0]\nif len(nums)<=1:\n\ts = nums[0]\nwhile(c != len(nums)):\n\ts += \" \" + nums[c]\n\tc +=1\nprint s"}, {"source_code": "\ndef gravity_flip(arr):\n return sorted(arr)\n\nif __name__ == '__main__':\n print('hello')\n # cnt = int(input())\n # arr = []\n # for i in range(cnt):\n # arr.append(int(input()))\n # # arr = list(map(int, input().rstrip().split()))\n # res = gravity_flip(arr)\n \n"}, {"source_code": "input()\nprint ' '.join(sorted(raw_input().split()))"}, {"source_code": "num_of_cols = int(input())\nx = raw_input().split()\nlist1 = []\ni = 0\n\nwhile i < num_of_cols:\n num_of_blocks = x[i]\n list1.append(num_of_blocks)\n i = i + 1\n\nlist1.sort()\nprint ' '.join(list1)"}, {"source_code": "n=int(input())\nc=input().split()\nc.sort()\nprint(\" \".join(c))"}, {"source_code": "#Gravity.py\n#Granadino, Shara Mae I.\n\nx = input() \nlist = raw_input().split()\n\nnewlist= (sorted (list))\n\nprint ' ' .join(newlist)\n \n\n\n\n\n\n"}, {"source_code": "n=int(input())\nk,s=input().split(),''\nk.sort()\nfor i in k:\n s=s+i\nprint(s)\n"}, {"source_code": "#!/usr/bin/env Python3\nn=int(input())\nm=input()\n\ncubes=m.split()\ncubes.sort()\n\nprint (' '.join(cubes))"}, {"source_code": "n = int(input())\nlis1 = list(map(int , input().split()))\nwhile not lis1 == sorted(lis1):\n for i in range(n-1):\n if lis1[i] > lis1[i+1]:\n lis1[i] -=1\n lis1[i+1] +=1\nprint(*lis1 , sep=' ')\n\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nl=sorted(l)\nprint(\"\".join(str(x) for x in l))"}, {"source_code": "line=int(input())\nnumbers=list(input().split())\nnew_list=sorted(numbers)\na=0\nif '100' in new_list:\n while True:\n if '100' not in new_list:\n break\n else:\n index1=new_list.index('100')\n new_list.pop(index1)\n a+=1\nfor i in range(1,a+1):\n new_list.append('100')\nfor number in new_list:\n print(number,end=' ')"}], "src_uid": "ae20712265d4adf293e75d016b4b82d8"} {"nl": {"description": "Sometimes one has to spell email addresses over the phone. Then one usually pronounces a dot as dot, an at sign as at. As a result, we get something like vasyaatgmaildotcom. Your task is to transform it into a proper email address (vasya@gmail.com). It is known that a proper email address contains only such symbols as . @ and lower-case Latin letters, doesn't start with and doesn't end with a dot. Also, a proper email address doesn't start with and doesn't end with an at sign. Moreover, an email address contains exactly one such symbol as @, yet may contain any number (possible, zero) of dots. You have to carry out a series of replacements so that the length of the result was as short as possible and it was a proper email address. If the lengths are equal, you should print the lexicographically minimal result. Overall, two variants of replacement are possible: dot can be replaced by a dot, at can be replaced by an at. ", "input_spec": "The first line contains the email address description. It is guaranteed that that is a proper email address with all the dots replaced by dot an the at signs replaced by at. The line is not empty and its length does not exceed 100 symbols.", "output_spec": "Print the shortest email address, from which the given line could be made by the described above replacements. If there are several solutions to that problem, print the lexicographically minimal one (the lexicographical comparison of the lines are implemented with an operator < in modern programming languages). In the ASCII table the symbols go in this order: . @ ab...z", "sample_inputs": ["vasyaatgmaildotcom", "dotdotdotatdotdotat", "aatt"], "sample_outputs": ["vasya@gmail.com", "dot..@..at", "a@t"], "notes": null}, "positive_code": [{"source_code": "a=raw_input()\n\nb=a.find('dot', 1, len(a)-1)\nwhile b!=-1:\n a=a[0:b]+'.'+a[b+3:]\n b=a.find('dot', 1, len(a)-1)\nb=a.find('at', 1, len(a)-1)\na=a[0:b]+'@'+a[b+2:]\nprint a"}, {"source_code": "a = raw_input()\nprint a[0] + a[1:-1].replace('dot', '.').replace('at', '@', 1) + a[-1:]\n"}, {"source_code": "st = raw_input()\nrep = st[1:-1:].replace(\"at\", \"@\", 1)\nrep = rep.replace(\"dot\", \".\")\nprint st[0] + rep + st[-1]\n"}, {"source_code": "I=lambda:map(int, raw_input().split())\ns = raw_input()\nif (len(s)) == 0: print '';exit()\nans = s[0]\nflag = False\ni, n = 1, len(s)\nwhile i < n:\n if i+1 < n-1 and i+2 < n-1 and s[i] == 'd' and s[i+1] == 'o' and s[i+2] == 't':\n ans += '.'; i += 3\n elif i+1 < n and s[i] == 'a' and s[i+1] == 't' and not flag:\n ans += '@'; i += 2; flag=True\n else:\n ans += s[i]; i += 1\nprint ans "}, {"source_code": "import re\nprint re.sub(r\"(?<=.)dot(?=.)\",\".\",re.sub(r\"(?<=.)at(?=.)\",\"@\",raw_input(),1))"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef main():\n s = raw_input()\n s = s[0] + s[1:-1].replace(\"dot\", \".\") + s[-1]\n s = s[:s[1:].find(\"at\") + 1] + \"@\" + s[s[1:].find(\"at\") + 3:]\n print s\n return 0\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "inp = [i for i in raw_input()]\nn = len(inp)\na = True\ni = 1\nwhile(i =1:\n for i in range(2,len(s)):\n if s[i-1:i+1]=='at':\n s=s[:i-1]+'@'+s[i+1:]\n break\nif 'dot'in s:\n s=s[:1]+s[1:-1].replace('dot','.')+s[-1:]\nprint(s)"}, {"source_code": "string = input()\nwhile \"dot\" in string[1:-1]:\n\tstring = string[:string[1:].index(\"dot\")+1]+\".\"+string[string[1:].index(\"dot\")+4:]\nstring = string[:string[1:].index(\"at\")+1]+\"@\"+string[string[1:].index(\"at\")+3:]\nprint(string)"}, {"source_code": "s = input()\n\ns = s.replace('at', '@', 1)\n\nif s[0] == '@':\n s = 'at' + s[1:].replace('at', '@', 1)\n\nif s.count('dot'):\n s = s.replace('dot', '.')\n if s[0] == '.':\n s = s.replace('.', 'dot', 1)\n if s[-1] == '.':\n s = s[:len(s)-1] + 'dot'\n \nprint(s)"}, {"source_code": "x = input()\ns=''\ns+=x[0]\ni=1\nk=1\nwhile (i0):\n s+='@'\n i+=2\n k-=1\n elif (x[i]=='d' and x[i+1]=='o' and x[i+2]=='t'):\n s+='.'\n i+=3\n else:\n s+=x[i]\n i+=1\nif (x[i:len(x)-1]=='at' and k>0):\n s+='@'\n i+=2\ns+=x[i:len(x)]\n\n \nprint(s)"}, {"source_code": "def is_dot(s, i):\n if i != 0 and i + 3 < len(s) and s[i] == 'd' and s[i + 1] == 'o' and s[i + 2] == 't':\n return True\n return False\n\n\ndef is_at(t, j):\n if j != 0 and j + 2 < len(t) and t[j] == 'a' and t[j + 1] == 't':\n return True\n return False\n\n\ndef email(s):\n m = ''\n i = 0\n flag = 0\n while i < len(s):\n if is_dot(s, i):\n m += \".\"\n i += 3\n else:\n if is_at(s, i) and flag == 0:\n m += \"@\"\n flag = 1\n i += 2\n else:\n m += s[i]\n i += 1\n return m\n\n\nprint(email(input()))\n"}, {"source_code": "d='dot'\nR=str.replace\ns=R(input(),d,'.')\ns=s[0]+R(s[1:],'at','@',1)\nif s[0]=='.':s=d+s[1:]\nif s[-1]=='.':s=s[:-1]+d\nprint(s)"}, {"source_code": "\n # ///==========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\n\nfrom itertools import combinations\n# ///==========MAIN=============///\n\n\ndef main():\n\n l=(input())\n j2=len(l)\n\n s=list(l)\n s.pop()\n j=l[len(l)-4:len(l)-1]\n\n j3=l.index('at')\n\n if j3==0:\n\n q4=l[:j3+2]\n q5=l[j3+2:]\n q5=q5.replace('at','@',1)\n l=q4+q5\n else:\n l=l.replace('at','@',1)\n\n if 'dot' in l:\n i=(l.index('dot'))\n else:\n i=100000\n\n if (l.count('dot'))>=1 and i!=0:\n l=l.replace('dot','.')\n\n\n elif i==0 :\n l4=l[:i+3]\n l5=l[i+3:]\n l5=l5.replace('dot','.')\n l=l4+l5\n\n\n\n\n if j=='dot':\n\n\n l=l[:len(l)-2]+'dot'\n print(l)\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": "s = str(input())\n\ns = s.replace(\"at\",\"@\",1)\ns = s.replace(\"dot\",\".\")\n\nif s[0]==\".\":\n\ts = \"dot\"+s[1:]\n\nif s[0]==\"@\":\n\ts = s.replace(\"at\",\"@\",1)\n\ts = \"at\"+s[1:]\n\t\n\nif s[len(s)-1]==\".\":\n\ts = s[:len(s)-1]+\"dot\"\n\nprint(s)"}, {"source_code": "l=list(input())\nj=1\ne=0\nwhile(j 0:\n c.append('at')\n co = 1 \n else:\n c.append('@')\n co = 1\n else:\n c.append(i)\nc= ''.join(c)\nif c[-1]=='.':\n c = c[:-1] + 'dot'\nprint c"}, {"source_code": "s = raw_input()\nl = len(s)\nans = [s[0]]\ni = 1\natdone = False\nwhile i < l:\n if i < l-3 and s[i:i+3] == \"dot\":\n ans.append(\".\")\n i += 3\n elif not atdone and s[i:i+2] == \"at\":\n ans.append(\"@\")\n i += 2\n atdone = True\n else:\n ans.append(s[i])\n i += 1\nprint ''.join(ans)\n"}, {"source_code": "import sys\nimport re\n\nr = re.compile('at')\n\ninput = sys.stdin\n\npre = ''\nbody = input.readline().strip()\nsuf = ''\n\nif body.startswith('dot'):\n pre = 'dot'\n body = body[3:]\nelif body.startswith('at'):\n pre = 'at'\n body = body[2:]\n\nif body.endswith('dot'):\n suf = 'dot'\n body = body[:len(body)-3]\nelif body.endswith('at'):\n suf = 'at'\n body = body[:len(body)-2]\n\nprint pre + r.sub('@', body.replace('dot','.'), 1) + suf\n"}, {"source_code": "x = raw_input()\nfor i in range(1, len(x)):\n if x[i:i+2] == 'at':\n x = x[0:i]+'@'+x[i+2:len(x)]\n break\nx = x.replace('dot', '.')\nif x[0] == '.':\n x = 'dot'+x[1:len(x)]\nif x[-1] == '.':\n x = x[0:-1]+'dot'\nprint x\n"}, {"source_code": "a=raw_input()\nb=a.find('dot', 1, len(a)-1)\nwhile b!=-1:\n a=a[:b]+'.'+a[b+3:]\n b=a.find('dot', 1, len(a)-1)\nb=a.find('at', 1, len(a)-1)\na=a[:b]+'@'+a[b+2:]\nprint a"}, {"source_code": "a = str(raw_input())\n\nhead = \"\"\nif a.startswith(\"dot\"):\n head = \"dot\"\n a = a[3:]\nelif a.startswith(\"at\"):\n head = \"at\"\n a = a[2:]\n\ntail = \"\"\nif a.endswith(\"dot\"):\n tail = \"dot\"\n a = a[:len(a)-3]\nelif a.endswith(\"at\"):\n tail = \"at\"\n a = a[:len(a)-2]\n\nprint head + a.replace(\"dot\", \".\").replace(\"at\", \"@\", 1) + tail"}, {"source_code": "s = raw_input()\na = s[1: -1].find(\"dot\")\n\nwhile not a == -1:\n s = s[: a + 1] + '.' + s[a + 4: ]\n a = s[1: -1].find(\"dot\")\n\na = s[1: -1].find(\"at\")\ns = s[: a + 1] + '@' + s[a + 3: ]\n\nprint s\n"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n'''\nn = raw_input()\nif n[:3] == 'dot' and n[len(n)-3:] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelif n[:3] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:].replace('dot','.')\nelif n[len(n)-3:] == 'dot':\n if n[:2] == 'at':\n n = n[:2] + n[2:].replace('at','@',1)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\n else:\n n = n.replace('at','@',1)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelse:\n if n[:2] == 'at':\n n = n[:2] + n[2:].replace('at','@',1)\n n = n.replace('dot','.')\n else:\n n = n.replace('at','@',1)\n n = n.replace('dot','.')\nprint n"}, {"source_code": "s = raw_input()\np = s[1:-1].replace('dot','.')\ni = p.find('at')\nprint s[0]+p[:i]+'@'+p[i+2:]+s[-1]\n"}, {"source_code": "r=raw_input()\nif len(r)==1:print r;exit()\ns,f=r[0],r[-1]\nr=r[1:-1]\nif '@' not in r: r=r.replace('at','@',1)\nr=r.replace('dot','.')\nprint s+r+f\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()\nkari=n\n#print n[1:-1] \nn=n[1:-1].replace('dot','.')\n#n=n[::-1]\nn=n.replace('at','@',1)\n#n=n[::-1]\nprint kari[0]+n+kari[-1]"}, {"source_code": "s = raw_input()\nif(s.find(\"at\")<>0):\n s = s.replace(\"at\",\"@\",1)\nelse:\n s = s.replace(\"at\",\"@\",2)\n s = s.replace(\"@\",\"at\",1)\n\ndotpos=-1\nif(s.find(\"dot\")==0):\n dotpos=4\nelif(s.find(\"dot\")==-1):\n dotpos=0\n\nwhile(dotpos<>0):\n if(s.find(\"dot\",dotpos)<>0 and s.find(\"dot\",dotpos)<>len(s)-3):\n s = s.replace(\"dot\",\".\",dotpos)\n dotpos = s.find(\"dot\",dotpos)+1\n\nif(s[0]==\".\"):\n s=s[1:]\n s=\"dot\"+s\nif(s[len(s)-1]=='.'):\n s=s[:len(s)-1]\n s+=\"dot\"\nif(s[0]==\"@\"):\n s=s[1:]\n s=\"at\"+s\nif(s[len(s)-1]=='@'):\n s=s[:len(s)-1]\n s+=\"at\"\n\nprint s\n \n"}, {"source_code": "s=raw_input()\nst,s,ed=s[0],s[1:-1],s[-1]\na=''\nat=False\ni=0\nwhile i\n# using namespace std;\n\n# #define ll long long\n# #define fi first \n# #define se second\n\n# typedef vector <>\n# typedef vector vii\n\n# int main() {\n# \tint n, k;\n# cin >> n >> k;\n \n \n# }\n\n\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\ns = input().rstrip()\nans = s[0]\nsuf = s[-1]\ns = s[1:-1]\nat_flag = 0\n\nwhile s:\n if s[:3] == 'dot':\n ans += '.'\n s = s[3:]\n elif not at_flag and s[:2] == 'at':\n ans += '@'\n at_flag = 1\n s = s[2:]\n else:\n ans += s[0]\n s = s[1:]\n\nprint(ans + suf)\n"}, {"source_code": "def main():\n desc = input()\n chunk = desc[1:-1]\n chunk = chunk.replace(\"at\", \"@\", 1)\n chunk = chunk.replace(\"dot\", \".\")\n print(desc[0] + chunk + desc[-1])\nmain()"}, {"source_code": "t = input()\nt = t[0] + t[1: -1].replace('dot', '.') + t[-1]\nk = t.find('at', 1)\nprint(t[:k] + '@' + t[k + 2:])\n"}, {"source_code": "from collections import *\nfrom math import *\nfrom sys import *\ns = input()\nl = [s[0]]\nn = len(s)\ni = 1\nflag = 0\nwhile(i 0:\n if y & 1:\n res = (res * x) % p\n y = y >> 1\n x = (x * x) % p\n return res\n\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\n\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\ngraph = defaultdict(list)\nvisited = [0] * 1000000\ncol = [-1] * 1000000\n\n\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\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.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\n\n\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\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: return\n yield start\n start += len(sub)\n\ns=si()\nm = s[0]\ni = 1\nat = 0\nwhile i < len(s):\n if i+3 < len(s) and s[i:i+3] == \"dot\":\n m += \".\"\n i += 3\n elif i+2 < len(s) and s[i:i+2] == \"at\" and at == 0:\n m += \"@\"\n i += 2\n at = 1\n else:\n m += s[i]\n i += 1\nprint(m)"}, {"source_code": "s=input()\ncnt=0\ngk=s.replace(\"at\", \"@\")\ngk=gk.replace(\"dot\", \".\")\n#print(gk)\nn=len(gk)\nk=list(gk)\nif(k[0]=='.'):\n\tk[0]=\"dot\"\nif(k[n-1]=='.'):\n\tk[n-1]=\"dot\"\nif(k[0]=='@'):\n\tk[0]=\"at\"\nif(k[n-1]=='@'):\n\tk[n-1]=\"at\"\n#s=string(k)\nfor x in range(len(k)):\n\tif(k[x]==\"@\" and cnt==0):\n\t\tcnt=1\n\telif(k[x]==\"@\"):\n\t\tk[x]=\"at\"\t\n\n\tprint(k[x],end=\"\")\n#print(k)\t\n\n#//print(len(gk))"}, {"source_code": "a = input()\nb = ''\nif a[0] + a[1] + a[2] == 'dot':\n b += 'dot'\n i = 3\nelif a[0] + a[1] == 'at':\n b += 'at'\n i = 2\nelse:\n i = 0\nat = 0\nwhile i < len(a) - 3:\n if a[i] == 'd' and a[i + 1] == 'o' and a[i + 2] == 't':\n b += '.'\n i += 3\n elif a[i] == 'a' and a[i + 1] == 't' and at == 0:\n b += '@'\n at = 1\n i += 2\n else:\n b += a[i]\n i += 1\nif a[i] + a[-1] == 'at' and at == 0:\n b += '@'\n b += a[i + 2]\nelse:\n for j in range(i, len(a)):\n b += a[j]\nprint(b)"}, {"source_code": "n=input()\nn=n[:1]+n[1:len(n)-1].replace('at','@',1)+n[len(n)-1:]\nn=n[:1]+n[1:len(n)-1].replace('dot','.')+n[len(n)-1:]\nprint(n)"}, {"source_code": "s=list(input())\ni=1\nc=0\nwhile i=1:\n for i in range(2,len(s)):\n if s[i-1:i+1]=='at':\n s=s[:i-1]+'@'+s[i+1:]\n break\nif 'dot'in s:\n s=s[:3]+s[3:-1].replace('dot','.')+s[-1:]\nprint(s)"}, {"source_code": "s = input()\n\ns = s.replace('at', '@', 1)\n\nif s.count('dot'):\n s = s.replace('dot', '.')\n if s[0] == '.':\n s = s.replace('.', 'dot', 1)\n if s[-1] == '.':\n s = s[:len(s)-1] + 'dot'\n \nprint(s)"}, {"source_code": "s = input()\n\nn = len(s)\n\ndot_entry = [s.find('dot', i) for i in range(n)]\ndot_entry = list(set(dot_entry))[:-1]\n\nif dot_entry:\n s = s.replace('dot', '.')\n if s[0] == '.':\n s = s.replace('.', 'dot', 1)\n if s[-1] == '.':\n s = s[:n-1] + 'dot' \n\ns = s.replace('at', '@', 1)\n\nprint(s)"}, {"source_code": "x = input()\ns=''\ns+=x[0]\ni=1\nwhile (i0):\n s+='@'\n i+=2\n k-=1\n elif (x[i]=='d' and x[i+1]=='o' and x[i+2]=='t'):\n s+='.'\n i+=3\n else:\n s+=x[i]\n i+=1\nif (x[i:len(x)-1]=='at'):\n s+='@'\n i+=2\ns+=x[i:len(x)]\n\n \nprint(s)"}, {"source_code": "x = input()\ns=''\ns+=x[0]\ni=1\nwhile (i1 :\n l4=l[:i+3]\n l5=l[i+3:]\n l5=l5.replace('dot','.')\n l=l4+l5\n print(l)\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 # ///==========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\n\nfrom itertools import combinations\n# ///==========MAIN=============///\n\n\ndef main():\n\n l=(input())\n j2=len(l)\n\n s=list(l)\n s.pop()\n j=l[len(l)-4:len(l)-1]\n\n j3=l.index('at')\n print(j3)\n if j3==0:\n\n q4=l[:j3+2]\n q5=l[j3+2:]\n q5=q5.replace('at','@',1)\n l=q4+q5\n else:\n l=l.replace('at','@',1)\n\n if 'dot' in l:\n i=(l.index('dot'))\n else:\n i=100000\n\n if (l.count('dot'))>=1 and i!=0:\n l=l.replace('dot','.')\n\n\n elif i==0 :\n l4=l[:i+3]\n l5=l[i+3:]\n l5=l5.replace('dot','.')\n l=l4+l5\n\n\n\n\n if j=='dot':\n\n\n l=l[:len(l)-2]+'dot'\n print(l)\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": "# ///==========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\n\nfrom itertools import combinations\n# ///==========MAIN=============///\n\n\ndef main():\n\n l=(input())\n s=list(l)\n s.pop()\n l=(l.replace('at','@',1))\n if 'dot' in l:\n i=(l.index('dot'))\n else:\n i=100000\n\n if (l.count('dot'))>=1 and i!=0:\n l=l.replace('dot','.')\n\n\n elif i==0 :\n l4=l[:i+3]\n l5=l[i+3:]\n l5=l5.replace('dot','.')\n l=l4+l5\n print(l)\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 # ///==========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\n\nfrom itertools import combinations\n# ///==========MAIN=============///\n\n\ndef main():\n\n l=(input())\n j2=len(l)\n\n s=list(l)\n s.pop()\n j=l[len(l)-4:len(l)-1]\n l=(l.replace('at','@',1))\n\n if 'dot' in l:\n i=(l.index('dot'))\n else:\n i=100000\n\n if (l.count('dot'))>=1 and i!=0:\n l=l.replace('dot','.')\n\n\n elif i==0 :\n l4=l[:i+3]\n l5=l[i+3:]\n l5=l5.replace('dot','.')\n l=l4+l5\n\n\n\n\n if j=='dot':\n\n\n l=l[:len(l)-2]+'dot'\n print(l)\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": "s = str(input())\n\ns = s.replace(\"at\",\"@\")\ns = s.replace(\"dot\",\".\")\n\nif s[0]==\".\":\n\ts = \"dot\"+s[1:]\nif s[0]==\"@\":\n\ts = \"at\"+s[1:]\n\nif s[len(s)-1]==\".\":\n\ts = s[:len(s)-1]+\"dot\"\nif s[len(s)-1]==\"@\":\n\ts = s[:len(s)-1]+\"at\"\n\nprint(s)"}, {"source_code": "s = str(input())\n\ns = s.replace(\"at\",\"@\",1)\ns = s.replace(\"dot\",\".\")\n\nif s[0]==\".\":\n\ts = \"dot\"+s[1:]\nif s[0]==\"@\":\n\ts = \"at\"+s[1:]\n\nif s[len(s)-1]==\".\":\n\ts = s[:len(s)-1]+\"dot\"\nif s[len(s)-1]==\"@\":\n\ts = s[:len(s)-1]+\"at\"\n\nprint(s)"}, {"source_code": "from collections import deque, Counter, OrderedDict\nfrom heapq import nsmallest, nlargest\n\ndef binNumber(n,size):\n return bin(n)[2:].zfill(size)\n\ndef gcd(a,b):\n if a == 0:\n return b\n return gcd(b%a,a)\n\ndef iar():\n return list(map(int,input().split()))\n\ndef ini():\n return int(input())\n\ndef isp():\n return map(int,input().split())\n\ndef sti():\n return str(input())\n\n\n# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\nif __name__ == \"__main__\":\n s = sti()\n m = s[0]\n i = 1\n at = 0\n while i < len(s):\n if i+3 <= len(s) and s[i:i+3] == \"dot\":\n m += \".\"\n i += 3\n elif i+2 <= len(s) and s[i:i+2] == \"at\" and at == 0:\n m += \"@\"\n i += 2\n at = 1\n else:\n m += s[i]\n i += 1\n print(m)\n\n\n \n"}, {"source_code": "t = input()\nk = len(t) - 3\nt = t[0] + t[1: k].replace('dot', '.') + t[k: ]\nk = t.find('at', 1)\nprint(t[:k] + '@' + t[k + 2:])"}, {"source_code": "s=input()\ns1=s[0]\nsm=s[len(s)-1]\ns=s[1:len(s)-1].replace('at','@')\ns=s1+s[0:len(s)].replace('dot','.')+sm\nprint(s)\n"}, {"source_code": "n=input()\n\nn=n.replace('dot','.')\nif n[0]=='.':\n n='dot'+n[1:]\nif n[-1]=='.':\n n=n[0:-1]+'dot'\nn=n.replace('at','@',1)\nif n[0]=='@':\n n='at'+n[1:].replace('at','@')\n\nprint(n)"}, {"source_code": "n=input()\nn=n.replace('at','@')\nn=n.replace('dot','.')\nif n[0]=='.':\n n=n.replace('.','dot',1)\nif n[0]=='@':\n n=n.replace('@','at',1)\nif n[-1]=='.':\n n=n.replace('.','dot',-1)\nif n[-1]=='@':\n n=n.replace('@','at',-1)\nprint(n)"}, {"source_code": "n=input()\nn=n.replace('at','@')\nn=n.replace('dot','.')\nif n[0]=='.':\n\n n='dot'+n[1:]\nif n[0]=='@':\n n = 'at' + n[1:]\nif n[-1]=='.':\n n=n[0:-1]+'dot'\nif n[-1]=='@':\n n=n[0:-1]+'at'\nprint(n)"}, {"source_code": "s=str(input())\nl=[s[0]]\ni=1\nflag=True\nwhile i 0:\n c.append('at')\n co = 1 \n else:\n c.append('@')\n co = 1\n else:\n c.append(i)\nprint ''.join(c)"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\na = a.replace('dot','.')\na = a.replace('at','@')\nif a[0]=='.':\n a ='dot' + a[1:]\nb = a.split('@')\nc = b[:2]\nc = b[0] + '@' + b[1]\nb = b[2:]\nb = 'at'.join(b)\nprint c + b\n"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\na = a.replace('dot','.')\na = a.replace('at','@')\nprint a"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\na = a.replace('dot','.')\na = a.replace('at','@')\nif a[0]=='.':\n a ='dot' + a[1:]\nco = 0\nc = []\nfor i in a:\n if i=='@':\n if co > 0:\n c.append('at')\n co = 1 \n else:\n c.append('@')\n co = 1\nprint ''.join(c)"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\na = a.replace('dot','.')\na = a.replace('at','@')\nif a[0]=='.':\n a ='dot' + a[1:]\nif a[-1] == '@':\n a = a[:-1] + 'at'\nprint a"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\na = a.replace('dot','.')\na = a.replace('at','@')\nif a[0]=='.':\n a ='dot' + a[1:]\nco = 0\nc = []\nfor i in a:\n if i=='@':\n if co > 0:\n c.append('at')\n co = 1 \n else:\n c.append('@')\n co = 1\n else:\n c.append(i)\nc= ''.join(c)\nif c[-1]=='.':\n c = c[:-1] + 'dot'\nprint c"}, {"source_code": "import sys\n\ninput = sys.stdin\n\npre = ''\nbody = input.readline().strip()\nsuf = ''\n\nif body.startswith('dot'):\n pre = 'dot'\n body = body[3:]\nelif body.startswith('at'):\n pre = 'at'\n body = body[2:]\n\nif body.endswith('dot'):\n suf = 'dot'\n body = body[:len(body)-3]\nelif body.endswith('at'):\n suf = 'at'\n body = body[:len(body)-2]\n\nprint pre + body.replace('dot','.').replace('at','@') + suf\n"}, {"source_code": "x = raw_input()\nfor i in range(0, len(x)):\n if x[i:i+2] == 'at':\n x = x[0:i]+'@'+x[i+2:len(x)]\n break\nx = x.replace('dot', '.')\nif x[0] == '.':\n x = 'dot'+x[1:len(x)]\nif x[-1] == '.':\n x = x[0:-1]+'dot'\nprint x"}, {"source_code": "a=raw_input()\n\nl=len(a)-1\nb=a.find('dot', 1, l)\nwhile b!=-1:\n a=a[:b]+'.'+a[b+3:]\n b=a.find('dot', 1, l)\nb=a.find('at', 1, l)\na=a[:b]+'@'+a[b+2:]\nprint a"}, {"source_code": "a=raw_input()\n\nl=len(a)-1\nb=a.find('dot', 1, l)\nwhile b!=-1:\n a=a[0:b]+'.'+a[b+3:]\n b=a.find('dot', 1, l)\nb=a.find('at', 1, l)\na=a[0:b]+'@'+a[b+2:]\nprint a"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n'''\nn = raw_input()\nif n[:3] == 'dot' and n[len(n)-3:] == 'dot':\n print 1\n n = n.replace('at','@',1)\n n = n[:3] + n[3:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelif n[:3] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:].replace('dot','.')\nelif n[len(n)-3:] == 'dot':\n if n[:2] == 'at':\n n = n.replace('at','@',2)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\n else:\n n = n.replace('at','@',1)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelse:\n if n[:2] == 'at':\n n = n[:2] + n[2:].replace('at','@',1)\n n = n.replace('dot','.')\n else:\n n = n.replace('at','@',1)\n n = n.replace('dot','.')\nprint n"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n'''\nn = raw_input()\nif n[:3] == 'dot' and n[len(n)-3:] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelif n[:3] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:].replace('dot','.')\nelif n[len(n)-3:] == 'dot':\n if n[:2] == 'at':\n n = n.replace('at','@',2)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\n else:\n n = n.replace('at','@',1)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelse:\n if n[:2] == 'at':\n n = n.replace('at','@',2)\n n = n.replace('dot','.')\n else:\n n = n.replace('at','@',1)\n n = n.replace('dot','.')\nprint n"}, {"source_code": "'''\nCreated on 6 Apr 2011\n\n@author: salama\n'''\nn = raw_input()\nif n[:3] == 'dot' and n[len(n)-3:] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelif n[:3] == 'dot':\n n = n.replace('at','@',1)\n n = n[:3] + n[3:].replace('dot','.')\nelif n[len(n)-3:] == 'dot':\n if n[:2] == 'at':\n n = n.replace('at','@',2)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\n else:\n n = n.replace('at','@',1)\n n = n[:len(n)-3].replace('dot','.') + n[len(n)-3:]\nelse:\n if n[:2] == 'at':\n n = n[:2] + n[2:].replace('at','@',1)\n n = n.replace('dot','.')\n else:\n n = n.replace('at','@',1)\n n = n.replace('dot','.')\nprint n"}, {"source_code": "s = raw_input()\nif len(s) < 2:\n\tprint s\nelse:\n\tprint s[0]+s[1:-1].replace('at','@').replace('dot','.')+s[-1]\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()\nkari=n\n#print n[1:-1] \nn=n[1:-1].replace('dot','.')\nn=n[::-1]\nn=n.replace('ta','@',1)\nn=n[::-1]\nprint kari[0]+n+kari[-1]"}, {"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()\nkari=n\n#print n[1:-1] \nn=n[1:-1].replace('dot','.')\nn=n[::-1]\nn=n[1:-1].replace('ta','@',1)\nn=n[::-1]\nprint kari[:2]+n+kari[-2:]"}, {"source_code": "s = raw_input()\nif(s.find(\"at\")<>0):\n s = s.replace(\"at\",\"@\",1)\nelse:\n s = s.replace(\"at\",\"@\",2)\n s = s.replace(\"@\",\"at\",1)\n\ndotpos=-1\nif(s.find(\"dot\")==0):\n dotpos=4\nelif(s.find(\"dot\")==-1):\n dotpos=0\n\nwhile(dotpos<>0):\n if(s.find(\"dot\",dotpos)<>0 and s.find(\"dot\",dotpos)<>len(s)-3):\n s = s.replace(\"dot\",\".\",dotpos)\n dotpos = s.find(\"dot\",dotpos)+1\n print dotpos\n\nif(s[0]==\".\"):\n s=s[1:]\n s=\"dot\"+s\nif(s[len(s)-1]=='.'):\n s=s[:len(s)-1]\n s+=\"dot\"\nif(s[0]==\"@\"):\n s=s[1:]\n s=\"at\"+s\nif(s[len(s)-1]=='@'):\n s=s[:len(s)-1]\n s+=\"at\"\n\nprint s\n \n"}, {"source_code": "s=raw_input()\na=''\nat=False\ni=1\nwhile i0):\n print s1\nelse:\n print s2"}, {"source_code": "G = (1 + 5 ** .5) / 2\nw = set((int(k * G), int(k * G) + k) for k in range(999))\nn = input()\na = sorted(map(int, raw_input().split()))+[0,0]\nprint 'BitAryo' if (((a[0], a[1]) in w) if 2==n else not(a[0]^a[1]^a[2])) else 'BitLGM'\n"}], "negative_code": [{"source_code": "from math import *\nn=int(input())\nif n==3:\n li=list(map(int,input().split()))\n ans=0\n flag=0\n for i in li:\n ans^=i\n if i==0:\n flag=1\n if flag==1 and ans==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelif n==2:\n li=list(map(int,input().split()))\n li.sort()\n phi=(1+sqrt(5))/2\n ch=[0]*(785)\n for i in range(300):\n a=floor(phi*i)\n b=floor((phi**2)*i)\n ch[a]=b\n ch[b]=a\n if ch[li[0]]==li[1]:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelse:\n li=int(input())\n if li==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\n"}, {"source_code": "from math import *\nn=int(input())\nif n==3:\n li=list(map(int,input().split()))\n ans=0\n flag=0\n for i in li:\n ans^=i\n if i==0:\n flag=1\n if flag==1 and ans==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelif n==2:\n li=list(map(int,input().split()))\n li.sort()\n phi=(1+sqrt(5))/2\n ch=[0]*(600)\n for i in range(100):\n a=floor(phi*i)\n b=floor((phi**2)*i)\n ch[a]=b\n ch[b]=a\n if ch[li[0]]==li[1]:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelse:\n li=int(input())\n if li==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\n"}, {"source_code": "from math import *\nn=int(input())\nif n==3:\n li=list(map(int,input().split()))\n ans=0\n flag=0\n for i in li:\n ans^=i\n if i==0:\n flag=1\n if flag==1 and ans==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelif n==2:\n li=list(map(int,input().split()))\n li.sort()\n phi=(1+sqrt(5))/2\n ch=[0]*(600)\n for i in range(100):\n a=floor(phi*i)\n b=floor((phi**2)*i)\n ch[a]=b\n ch[b]=a\n if ch[li[0]]==li[1]:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelse:\n li=input()\n if li==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\n"}, {"source_code": "from math import *\nn=int(input())\nif n==3:\n li=list(map(int,input().split()))\n ans=0\n flag=0\n for i in li:\n ans^=i\n if i==0:\n flag=1\n if flag==1 and ans==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelif n==2:\n li=list(map(int,input().split()))\n li.sort()\n phi=(1+sqrt(5))/2\n if floor((li[0]+1)/phi)==floor((li[1]+1)/(phi**2)):\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\nelse:\n li=input()\n if li==0:\n print(\"BitAryo\")\n else:\n print(\"BitLGM\")\n"}, {"source_code": "input()\nn = map(int, raw_input().split())\nprint ['BitAryo', 'BitLGM'][len(n) == 1 or (len(n) == 2 and n[0] == n[1]) or len(n) == 3]"}, {"source_code": "dp=[]\nfor i in xrange(333):\n tmp = []\n for j in xrange(333):\n tmp.append(-1)\n dp.append(tmp)\n\nn = map(int,raw_input().split())[0]\na = map(int,raw_input().split())\ns1=\"BitLGM\"\ns2=\"BitAryo\"\n\nif n==2:\n dp[0][0]=0\n for i in xrange(302):\n for j in xrange(302):\n if(dp[i][j]==0):\n k=1\n while i+k<=300:\n dp[i+k][j]=1\n k=k+1\n k=1\n while j+k<=300:\n dp[i][j+k]=1\n k=k+1\n k=1\n while i+k<=300 and j+k<=300:\n dp[i+k][j+k]=1\n k=k+1\n if dp[a[0]][a[1]]==1:\n print s1\n else: print s2\n exit(0)\n\nt = 0\nif n==1: t = a[0]\nelse:\n t = (a[0]^a[1]^a[2])\n\nif(t>0):\n print s1\nelse:\n print s2"}], "src_uid": "7a33b4f94082c7ef80d7e87b58497fa7"} {"nl": {"description": "An expedition group flew from planet ACM-1 to Earth in order to study the bipedal species (its representatives don't even have antennas on their heads!).The flying saucer, on which the brave pioneers set off, consists of three sections. These sections are connected by a chain: the 1-st section is adjacent only to the 2-nd one, the 2-nd one \u2014 to the 1-st and the 3-rd ones, the 3-rd one \u2014 only to the 2-nd one. The transitions are possible only between the adjacent sections.The spacecraft team consists of n aliens. Each of them is given a rank \u2014 an integer from 1 to n. The ranks of all astronauts are distinct. The rules established on the Saucer, state that an alien may move from section a to section b only if it is senior in rank to all aliens who are in the segments a and b (besides, the segments a and b are of course required to be adjacent). Any alien requires exactly 1 minute to make a move. Besides, safety regulations require that no more than one alien moved at the same minute along the ship.Alien A is senior in rank to alien B, if the number indicating rank A, is more than the corresponding number for B.At the moment the whole saucer team is in the 3-rd segment. They all need to move to the 1-st segment. One member of the crew, the alien with the identification number CFR-140, decided to calculate the minimum time (in minutes) they will need to perform this task.Help CFR-140, figure out the minimum time (in minutes) that all the astronauts will need to move from the 3-rd segment to the 1-st one. Since this number can be rather large, count it modulo m.", "input_spec": "The first line contains two space-separated integers: n and m (1\u2009\u2264\u2009n,\u2009m\u2009\u2264\u2009109) \u2014 the number of aliens on the saucer and the number, modulo which you should print the answer, correspondingly.", "output_spec": "Print a single number \u2014 the answer to the problem modulo m.", "sample_inputs": ["1 10", "3 8"], "sample_outputs": ["2", "2"], "notes": "NoteIn the first sample the only crew member moves from segment 3 to segment 2, and then from segment 2 to segment 1 without any problems. Thus, the whole moving will take two minutes.To briefly describe the movements in the second sample we will use value , which would correspond to an alien with rank i moving from the segment in which it is at the moment, to the segment number j. Using these values, we will describe the movements between the segments in the second sample: , , , , , , , , , , , , , , , , , , , , , , , , , ; In total: the aliens need 26 moves. The remainder after dividing 26 by 8 equals 2, so the answer to this test is 2."}, "positive_code": [{"source_code": "n,m=map(int,input().split())\nfinal=(pow(3,n,m)-1)\nif final<0:\n print(m-1)\nelse:\n print(final)"}, {"source_code": "#import sys\n#\n#sys.stdin = open('in.txt', 'r')\n\nn, mod = map(int, raw_input().split())\n\ndef cal(n):\n ret, tem = 1, 3\n while(n):\n if n & 1: ret = ret * tem % mod\n n >>= 1\n tem = tem * tem % mod\n return ret\nprint ((cal(n) - 1 + mod) % mod)\n\n\n"}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3,n,m)-1%m)%m)"}, {"source_code": "n,m=map(int,input().split())\nprint((3*pow(3,n-1,m)-1)%m)"}, {"source_code": "'''input\n3 8\n'''\n# practicing a skill right after sleep improves it a lot quickly\nfrom sys import stdin, setrecursionlimit\nimport math\n\n# main starts\nn, m = list(map(int, stdin.readline().split()))\np = pow(3, n, m)\nprint((p - 1) % m)"}, {"source_code": "a, b = map(int,raw_input().split())\nprint (pow(3, a, b) + b - 1)% b\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\ndef binpow(a, b, m):\n if (not b): return 1\n if (b == 1): return a%m\n ret = binpow(a, b//2, m)\n ret = (ret * ret)%m\n if (b&1): ret = (ret * (a%m))%m\n return ret\n\ndef main():\n n,m = [int(c) for c in input().split()]\n ret = binpow(3, n, m)\n ret = (ret - 1)%m\n print(str(ret) + '\\n')\n return 0\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()\n"}, {"source_code": "def fastpow(mod,times):\n if times==1:\n return 3\n else:\n if (times%2):\n now=fastpow(mod,(times-1)/2)%mod\n return (now*now*3)%mod\n else:\n now = fastpow(mod, (times ) / 2) % mod\n return (now * now ) % mod\nn,m=map(int, input().split())\nprint((fastpow(m,n)-1)%m)\n"}, {"source_code": "def power(a, n, m):\n\tif n==0: return 1\n\tif n==1: return a%m\n\tif n%2 == 0:\n\t\tx = power(a, n//2, m)\n\t\treturn (x*x)%m\n\telse:\n\t\tx = power(a, n//2, m)\n\t\treturn (((x*x)%m)*(a%m))%m\n\nn, m = [int(x) for x in input().split()]\nprint((power(3, n, m)-1)%m)\n"}, {"source_code": "from sys import stdin, stdout\n\n# Read input: stdin.readline()\n# Print output: stdout.write()\n\ndef binpow(a, b, m):\n if (not b): return 1\n if (b == 1): return a%m\n ret = binpow(a, b//2, m)\n ret = (ret * ret)%m\n if (b&1): ret = (ret * (a%m))%m\n return ret\n\ndef main(args):\n n,m = [int(c) for c in stdin.readline().split()]\n ret = binpow(3, n, m)\n ret = (ret - 1)%m\n stdout.write(str(ret) + '\\n')\n return 0\n\nif __name__ == '__main__':\n\timport sys\n\tsys.exit(main(sys.argv))\n\n\n"}, {"source_code": "def fast_mod(a , n , m):\n ans = 1\n while n >= 1:\n if n % 2 == 1:\n ans = (ans * a) % m\n a = (a * a) % m\n n = n / 2\n return ans\n\nn , m = map(int , list(raw_input().split()))\nans = fast_mod(3 , n , m)\nans = (ans - 1 + m) % m\nprint ans"}, {"source_code": "n,m=map(long, raw_input().split())\nans=long(1)\nmult=long(3)\nwhile n:\n if n&1!=0:\n ans=(ans*mult)%m;\n mult=(mult**2)%m\n n/=2\nif ans!=0:\n print long(ans-1)\nelse:\n print m-1 \n"}, {"source_code": "n,m = map(int,input().split())\n# a = 2\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 \na = power(3,n,m)\nprint(a-1 if a!=0 else m-1)"}, {"source_code": "n, m = map(int, raw_input().split())\nprint (pow(3,n,m)-1+m) % m"}, {"source_code": "def pow_mod(x, y, z):\n number = 1\n while y:\n if y & 1:\n number = number * x % z\n y >>= 1\n x = x * x % z\n return number\n\n\nn, m = map(int, raw_input().strip().split(' '))\nprint (pow_mod(3, n, m) - 1) % m\n"}, {"source_code": "#coding=utf-8\n\ndef three_power_mod(n, MOD):\n\tp = 1\n\tt = 3\n\twhile n != 0:\n\t\tif n % 2 != 0:\n\t\t\tp *= t\n\t\t\tp %= MOD\n\t\tt = (t*t)%MOD\n\t\tn /= 2\n\treturn p\n\t\nn,m = map(int, raw_input().split())\nprint (three_power_mod(n,m)+m-1)%m\n"}, {"source_code": "n, m = map(int, input().split())\n\ndef fast_power(base, exp):\n res = 1\n while exp > 0:\n if exp % 2 == 1:\n res = (res * base) % m\n base = (base * base) % m\n exp //= 2\n return res\n\nprint((fast_power(3, n) - 1 + m) % m)\n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint (pow(3,n,m)-1)%m "}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3, n, m) - 1) % m)"}, {"source_code": "a, b = map(int, input().split())\nprint((pow(3, a, b) + b - 1) % b)"}, {"source_code": "n,m = map(int,raw_input().split())\nprint (pow(3,n,m) - 1)%m\n"}, {"source_code": "n,m=map(long, raw_input().split())\nans=long(1)\nmult=long(3)\nwhile n:\n if n&1!=0:\n ans=(ans*mult)%m;\n mult=(mult**2)%m\n n/=2\nif ans!=0:\n print long(ans-1)\nelse:\n print m-1 \n"}, {"source_code": "def fast_mod(a , n , m):\n ans = 1\n while n >= 1:\n if n % 2 == 1:\n ans = (ans * a) % m\n a = (a * a) % m\n n = n / 2\n return ans\n\nn , m = map(int , list(raw_input().split()))\nans = fast_mod(3 , n , m)\nans = (ans - 1 + m) % m\nprint ans"}, {"source_code": "\nn,m = map(int,input().split())\nx = (pow(3,n,m)-1+m)%m\nprint(x)\n# C:\\Users\\Usuario\\HOME2\\Programacion\\ACM"}, {"source_code": "def fast_mod(a , n , m):\n ans = 1\n while n >= 1:\n if n % 2 == 1:\n ans = (ans * a) % m\n a = (a * a) % m\n n = n / 2\n return ans\n\nn , m = map(int , list(raw_input().split()))\nans = fast_mod(3 , n , m)\nans = (ans - 1 + m) % m\nprint ans"}, {"source_code": "import sys\n \ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\n \nn,m = get_ints()\nans = (pow(3,n,m)-1+m)%m\nprint(ans)"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "n, m = map(int, input().split())\n\ndef fast_power(base, exp):\n res = 1\n while exp > 0:\n if exp % 2 == 1:\n res = (res * base) % m\n base = (base * base) % m\n exp //= 2\n return res\n\nprint((fast_power(3, n) - 1 + m) % m)\n"}, {"source_code": "n, m = map(int, raw_input().split())\nprint (pow(3, n, m) - 1 + m) % m\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)"}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3, n, m) - 1) % m)"}, {"source_code": "import math\n\n\ndef powerk (a,x,y):\n if(x==1):\n return(a)\n elif(x<=0):\n return(1)\n else:\n if (a<=0):\n return(0)\n y0=math.ceil(math.log(y,a))\n if(y0<=0):\n return(a**x)\n if (x0:\n change = False\n while sum+i>n:\n change = True\n i//=10\n sum+=i\n if change:\n tmp = (3**i)%m\n tmp2*=tmp\nprint((tmp2-1)%m) "}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "s = raw_input()\nl = s.split()\nn = int (l[0])\nm = int (l[1])\ntmp2 = 1\ntmp = (3**1000000)%m\ni = 1000000\nsum = 0\nwhile i>0:\n change = False\n while sum+i>n:\n change = True\n i//=10\n sum+=i\n if change:\n tmp = (3**i)%m\n tmp2*=tmp\nprint((tmp2-1)%m) "}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Aug 1 18:48:05 2020\n\n@author: shailesh\n\"\"\"\n\nn,m = [int(i) for i in input().split()]\n\n\nans = pow(3,n,m) - 1\n\nif ans == -1:\n ans = m-1\n\nprint(ans)"}, {"source_code": "s = raw_input\nn, m = map(int, s().split())\nx = pow(3, n, m)-1\nif x<0: x+=m\nx%=m\nprint x"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "n,m=map(int,input().split())\nx=pow(3,n-1,m)\nans=(x*2+x-1)%m\nprint(ans)"}, {"source_code": "def pow3(N, M):\n if N == 0:\n return 0\n if N == 1:\n return 3 % M\n res = pow3(N / 2, M) ** 2\n if N % 2 == 1:\n res *= 3\n return res % M\n\ndef solve(N, M):\n return (pow3(N, M) + M - 1) % M\n\nimport sys\ninput = sys.stdin\nN, M = map(int, input.readline().split())\nprint solve(N, M)\n"}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3, n, m) - 1) % m)"}, {"source_code": "#Test 2\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\ndef binpow(a, b, m):\n if (not b): return 1\n if (b == 1): return a%m\n ret = binpow(a, b//2, m)\n ret = (ret * ret)%m\n if (b&1): ret = (ret * (a%m))%m\n return ret\n\ndef main():\n n,m = [int(c) for c in input().split()]\n ret = binpow(3, n, m)\n ret = (ret - 1)%m\n print(str(ret) + '\\n')\n return 0\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()\n"}, {"source_code": "(n, m) = list(map(int, raw_input().strip().split()))\nprint((pow(3, n, m) - 1 + m) % m)"}, {"source_code": "#import sys\n#\n#sys.stdin = open('in.txt', 'r')\n\nn, mod = map(int, raw_input().split())\n\ndef cal(n):\n ret, tem = 1, 3\n while(n):\n if n & 1: ret = ret * tem % mod\n n >>= 1\n tem = tem * tem % mod\n return ret\nprint ((cal(n) - 1 + mod) % mod)\n\n\n"}, {"source_code": "def binpow(a,n):\n res = 1\n while(n>0):\n if(n&1):\n res = (res*a)%m\n a = (a*a)%m\n n>>=1\n return res\n\nn,m = map(int,input().split())\nans = binpow(3,n)-1\nif(ans%m ==0 and ans != 0):\n print(m-1)\nelse:\n print(ans%m)"}, {"source_code": "a, b = map(int,raw_input().split())\nprint (pow(3, a, b) + b - 1)% b\n"}, {"source_code": "n, m = map(int, input().split())\ndef fast_pow(a, b):\n res, ret = a, 1\n while b > 0:\n if b % 2 == 1:\n ret = (ret * res) % m\n res = (res * res) % m\n b //= 2\n return ret % m\nprint((fast_pow(3, n) - 1) % m)"}, {"source_code": "#coding=utf-8\n\ndef three_power_mod(n, MOD):\n\tp = 1\n\tt = 3\n\twhile n != 0:\n\t\tif n % 2 != 0:\n\t\t\tp *= t\n\t\t\tp %= MOD\n\t\tt = (t*t)%MOD\n\t\tn /= 2\n\treturn p\n\t\nn,m = map(int, raw_input().split())\nprint (three_power_mod(n,m)+m-1)%m\n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint (pow(3,n,m)-1)%m "}, {"source_code": "import math\n\n\ndef powerk (a,x,y):\n if(x==1):\n return(a)\n elif(x<=0):\n return(1)\n else:\n if (a<=0):\n return(0)\n y0=math.ceil(math.log(y,a))\n if(y0<=0):\n return(a**x)\n if (x>= 1\n\nans = (ans + m - 1) % m\n\nprint(ans)"}, {"source_code": "n, m = map(int, raw_input().split())\n\ndef modular_expo(n, m):\n if n == 1:\n return 3\n if n == 0:\n return 1\n if n % 2 == 0:\n temp = modular_expo(n/2, m)\n return ((temp % m) * (temp % m)) % m\n else:\n return (3 * (modular_expo(n-1, m) % m)) % m\n\nans = modular_expo(n, m)\nprint (ans-1+m) % m\n"}, {"source_code": "n, m = map(int, raw_input().split())\nprint (pow(3, n, m) - 1 + m)%m"}, {"source_code": "\nn,m = map(int,input().split())\nx = (pow(3,n,m)-1+m)%m\nprint(x)\n# C:\\Users\\Usuario\\HOME2\\Programacion\\ACM"}, {"source_code": "a, b = map(int, input().split())\nprint((pow(3, a, b) + b - 1) % b)"}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3, n, m) - 1) % m)"}, {"source_code": "#!/usr/bin/env python\n\nn, m = map(int,raw_input().strip().split())\n\nbits = []\nwhile n:\n bits = [n%2] + bits\n n /= 2\n\nres = 1\ntmp = 1 \nfor b in bits[::-1]:\n tmp = (tmp**2 if tmp>1 else 3) % m\n if b:\n res = (res*tmp) % m\n\nres = (res + m -1) % m\n\nprint res\n\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Aug 1 18:48:05 2020\n\n@author: shailesh\n\"\"\"\n\nn,m = [int(i) for i in input().split()]\n\n\nans = pow(3,n,m) - 1\n\nif ans == -1:\n ans = m-1\n\nprint(ans)"}, {"source_code": "#!/usr/bin/python3\nN,M = [int(x) for x in input().strip().split()]\nprint((pow(3,N,M)-1)%M)\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)"}, {"source_code": "n,m=map(int,input().split())\nprint((3*pow(3,n-1,m)-1)%m)"}, {"source_code": "a, b = map(int, raw_input().split())\nprint((pow(3, a, b) + b - 1) % b)"}, {"source_code": "\ndef main():\n [n, m] = map(int, raw_input().split())\n print (pow(3, n, m)-1)%m\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3, n, m) - 1) % m)"}, {"source_code": "n, m = map(int, input().split())\n\ndef mod_exp(a, b, n):\n\tx = a\n\ty = 1\n\twhile b > 0:\n\t\tif b%2:\n\t\t\ty = (y*x)%n \n\t\tx = (x*x)%n\n\t\tb = b >> 1\n\treturn y\n\nprint((mod_exp(3, n, m)-1)%m)"}, {"source_code": "def pow_mod(x, y, z):\n number = 1\n while y:\n if y & 1:\n number = number * x % z\n y >>= 1\n x = x * x % z\n return number\n\n\nn, m = map(int, raw_input().strip().split(' '))\nprint (pow_mod(3, n, m) - 1) % m\n"}, {"source_code": "(n,m)= map(lambda x:int(x),raw_input().split())\n\ndef ppow(nn,kk,mm):\n if (kk==0):\n return 1; \n if (kk%2==0):\n tmp = ppow(nn,kk>>1,mm)\n return (tmp*tmp)%m\n else: \n tmp = ppow(nn,kk-1,mm)\n return (tmp*nn)%m \n# res = ppow(nn,kk>>1,mm);\n# res = res * res\n# res = res % mm\n# if (kk%2==0):\n# return res\n# else: \n# return ((res * nn)%mm)\n \nres = 0\nif n==1:\n print 2%m\nelse:\n res = ppow(3,n,m)\n res = res - 1 \n res = res + m;\n res = res % m\n print res"}, {"source_code": "n, m = map(int, raw_input().split())\nprint (pow(3, n, m) - 1 + m)%m"}, {"source_code": "a, b = map(int,raw_input().split())\nprint (pow(3, a, b) + b - 1)% b\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "def f(a, b):\n if b == 1:\n return a\n if b % 2 == 0:\n x = f(a, b // 2) % m\n return (x * x) % m\n else:\n return (f(a, b - 1) * a) % m\n\nn, m = map(int, input().split())\nprint((f(3, n) - 1) % m)"}, {"source_code": "n,m=map(int,raw_input().split())\nprint (pow(3,n,m)-1)%m "}, {"source_code": "n, m = map(int, input().split())\nprint((pow(3, n, m) - 1) % m)\n"}, {"source_code": "n, m = map(int, input().split())\n\nans = 1\nbase = 3\n\nwhile n != 0:\n if n & 1:\n ans = (ans * base) % m\n\n base = (base * base) % m\n n >>= 1\n\nans = (ans + m - 1) % m\n\nprint(ans)"}, {"source_code": "n, m = (int(x) for x in input().split())\nprint((pow(3,n,m)-1)%m)"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)\n"}, {"source_code": "n,m=map(int,input().split())\nx=pow(3,n-1,m)\nans=(x*2+x-1)%m\nprint(ans)"}, {"source_code": "n, m = map(int, raw_input().split())\nprint (pow(3, n, m) - 1) % m\n"}, {"source_code": "n, m = (int(x) for x in input().split())\nprint((pow(3,n,m)-1)%m)"}, {"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 bigmod(a,b,M):\n\n if(b==0):return 1\n\n if(b%2):\n return a%M * bigmod(a,b-1,M)\n else:\n ans=bigmod(a,b//2,M)\n return (ans*ans)%M\n\nn,m=value()\n\nans=bigmod(3,n,m)\n\nprint((ans-1+m)%m)"}, {"source_code": "n,m=map(int,input().split());print((pow(3,n,m)-1)%m)"}, {"source_code": "\ndef modPower(a, n, m):\n ret = 1\n while n > 0:\n if (n&1) == 1:\n ret = ret*a%m\n a = a*a%m\n n >>= 1\n return ret\n \ndef main():\n [n, m] = map(int, raw_input().split())\n print (modPower(3, n, m)+m-1)%m\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint (pow(3,n,m)+m-1)%m\n"}, {"source_code": "n, m = map(int, raw_input().split())\n\ndef modular_expo(n, m):\n if n == 1:\n return 3\n if n == 0:\n return 1\n if n % 2 == 0:\n temp = modular_expo(n/2, m)\n return ((temp % m) * (temp % m)) % m\n else:\n return (3 * (modular_expo(n-1, m) % m)) % m\n\nans = modular_expo(n, m)\nprint (ans-1+m) % m\n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint (pow(3,n,m)-1)%m"}, {"source_code": "#!/usr/bin/env python\n\nn, m = map(int,raw_input().strip().split())\n\nbits = []\nwhile n:\n bits = [n%2] + bits\n n /= 2\n\nres = 1\ntmp = 1 \nfor b in bits[::-1]:\n tmp = (tmp**2 if tmp>1 else 3) % m\n if b:\n res = (res*tmp) % m\n\nres = (res + m -1) % m\n\nprint res\n\n"}, {"source_code": "n,m=map(int,input().split())\n\nr=pow(3,n,m)\nr-=1\nr+=m\nr%=m\n\n\nprint(r)\n"}], "negative_code": [{"source_code": "def pow3(N, M):\n if N == 0:\n return 0\n if N == 1:\n return 3 % M\n res = pow3(N / 2, M) ** 2\n if N % 2 == 1:\n res *= 3\n return res % M\n\ndef solve(N, M):\n return pow3(N, M) + M - 1\n\nimport sys\ninput = sys.stdin\nN, M = map(int, input.readline().split())\nprint solve(N, M)\n"}, {"source_code": "def pow3(N, M):\n if N == 0:\n return 0\n if N == 1:\n return 3 % M\n res = pow3(N / 2, M) ** 2\n if N % 2 == 1:\n res *= 3\n return res % M\n\ndef solve(N, M):\n return pow3(N, M) - 1\n\nimport sys\ninput = sys.stdin\nN, M = map(int, input.readline().split())\nprint solve(N, M)\n"}, {"source_code": "n,m = map(int,raw_input().split())\nprint pow(3,n,m) - 1\n"}, {"source_code": "\ndef modPower(a, n, m):\n ret = 1\n while n > 0:\n if (n&1) == 1:\n ret = ret*a%m\n a = a*a%m\n n >>= 1\n return ret\n \ndef main():\n [n, m] = map(int, raw_input().split())\n print modPower(3, n, m)-1\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\nimport time\nfrom collections import defaultdict,deque\nfrom sys import stdin,stdout\nfrom bisect import bisect_left,bisect_right\nn,m=map(int,stdin.readline().split())\nprint((n*n*2)%m)"}, {"source_code": "import sys\n \ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\n \nn,m = get_ints()\nif n==1:\n print(2%m)\n exit()\nans = 0\nfor i in range(n):\n ans+=(n-1)*pow(3,i,m)\n ans%=m\nprint(ans)"}, {"source_code": "import sys\n\ndef get_ints(): return map(int, sys.stdin.readline().strip().split())\n\nn,m = get_ints()\nans = 0\nfor i in range(n):\n ans+=(n-1)*pow(3,i,m)\n ans%=m\nprint(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nprint(pow(3, n, m) - 1)"}, {"source_code": "n, m = (int(x) for x in input().split())\nprint(2 * pow(3,n-1,m))"}, {"source_code": "(a,b) = map(lambda x:int(x),raw_input().split());\nif a==1:\n print 2%b;\nelse: \n print (2*(3**(a-1)))%b"}, {"source_code": "s = raw_input()\nl = s.split()\nn = int (l[0])\nm = int (l[1])\ntmp2 = 1\ntmp = (3**1000000)%m\ni = 1000000\nsum = 0\nwhile i>0:\n tmp2*=tmp\n change = False\n while sum+i>n:\n change = True\n i//=10\n sum+=i\n if change:\n tmp = (3**i)%m\n \n \n\nprint((tmp2-1)%m) "}, {"source_code": "n,m = map(int,raw_input().split(' '))\n\ndef exp(num,power):\n\tbase = num\n\tpres = power\n\tret = 1\n\twhile(pres!=0):\t\n\t\tif(pres%2==1):\n\t\t\tret = (ret*base)%m\n\t\tpres = pres/2\n\t\tbase = (base*base)%m\n\treturn ret\n\nprint exp(3,n)-1\n"}, {"source_code": "n,m=map(int,raw_input().split())\nx= pow(3,n,m) -1\nif(x==-1):\n print m\nelse:\n print x\n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint pow(3,n,m) -1\n"}, {"source_code": "s = raw_input\nn, m = map(int, s().split())\nprint pow(5, n-1, m)+1\n \n"}, {"source_code": "n,m = map(int,input().split())\na = 2\n\nfor i in range(n-1):\n a = a + (2*a)\n\nprint(a%m)"}, {"source_code": "n,m = map(int,input().split())\n# a = 2\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(power(3,n,m)-1)"}, {"source_code": "n,m = map(int,input().split())\na = 2\n\nfor i in range(n-1):\n a = 2 + (2*a)\n\nprint(a%m)"}, {"source_code": "n, m = map(int, input().split())\nprint((5 * (n - 1)) % m)"}, {"source_code": "n, m = map(int, input().split())\nprint(2 * n * n % m)"}, {"source_code": "n,m = map(int,input().split())\nr = pow(3,n,m)\nprint(r-1)\n"}, {"source_code": "n,m = map(int,input().split())\nr = pow(3,n,m)\nif r < 0 :\n r += m\nprint(r-1)\n"}, {"source_code": "n,m=map(int,input().split());print(pow(3,n,m)-1)"}, {"source_code": "n,m=map(long, raw_input().split())\nans=0\nfor i in range(n):\n ans+=2*pow(n,i,m)\nprint ans%m\n \n"}, {"source_code": "(n,m)= map(lambda x:int(x),raw_input().split())\n\ndef ppow(nn,kk,mm):\n if (kk==0):\n return 1; \n if (kk%2==0):\n return (pow(nn,kk/2,mm)**2)%m\n else: \n return (pow(nn,kk-1,mm)*n)%m \n# res = ppow(nn,kk>>1,mm);\n# res = res * res\n# res = res % mm\n# if (kk%2==0):\n# return res\n# else: \n# return ((res * nn)%mm)\n \nres = 0\nif n==1:\n print 2%m\nelse:\n res = ppow(3,n,m)\n res = res - 1 \n res = res + m;\n res = res % m\n print res"}, {"source_code": "n,m=map(int,input().split())\nprint(pow(3,n,m)-1)"}, {"source_code": "def modpow(a, b, n):\n if b == 0:\n return 1\n if b == 1:\n return a % n\n tmp = modpow(a, b // 2, n) % n\n tmp = (tmp * tmp) % n\n if tmp % 2 == 1:\n return (tmp * a) % n\n else:\n return tmp\n\n\ndef main():\n n, m = map(int, input().split())\n ans = (modpow(3, n, m) - 1) % m\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,m = map(int,input().split())\ni = n\nans = 0\nwhile(i>1):\n ans += (2*i+1)*2\n i-=1\nans+=2\nprint(ans%m)"}, {"source_code": "def binpow(a,n):\n res = 1\n while(n>0):\n if(n&1):\n res = (res*a)%m\n a = (a*a)%m\n n>>=1\n return res\n\nn,m = map(int,input().split())\nans = binpow(3,n)-1\nif(ans%m ==0):\n print(m-1)\nelse:\n print(ans%m)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Aug 1 18:48:05 2020\n\n@author: shailesh\n\"\"\"\n\nn,m = [int(i) for i in input().split()]\n\n\nans = pow(3,n,m) - 1\n\nif ans == -1:\n ans = m-1\n\nprint(m)"}, {"source_code": "import sys\nfrom math import *\nfrom fractions import gcd\nreadints=lambda:map(int, input().strip('\\n').split())\n\n\n# ans: 3^n - 1\n\n\nn,m=readints()\n\n\ndef pow3(n,m):\n res=1\n b=3\n\n while n>0:\n if n%2 == 1:\n res*=b\n res%=m\n n-=1\n else:\n b*=b\n b%=m\n n/=2\n return res\n\n\nans=pow3(n,m)-1\nprint(ans)\n"}, {"source_code": "def fastpow(mod,times):\n if times==1:\n return 3\n else:\n if (times%2):\n now=fastpow(mod,(times-1)/2)%mod\n return (now*now*3)%mod\n else:\n now = fastpow(mod, (times ) / 2) % mod\n return (now * now ) % mod\nn,m=map(int, input().split())\nprint(fastpow(m,n)%m-1)\n "}, {"source_code": "def pow1(x, base):\n if base == 0:\n return 1\n sq = pow1(x, base // 2)\n sq = (sq * sq) % m\n\n if base % 2:\n sq *= x\n return sq\n\n\ndef sum_pow(r, n):\n return ((1 % m - pow1(r, n + 1) % m) % m) // (1 - r)\n\n\nn, m = map(int, input().split())\nprint((2 * (sum_pow(3, n - 1) % m)) % m)\n"}, {"source_code": "def pow1(x, base):\n if base == 0:\n return 1\n sq = pow1(x, base // 2)\n sq = (sq * sq) % m\n\n if base % 2:\n sq *= x\n return sq\n\n\ndef sum_pow(r, n):\n return (1 - pow1(r, n + 1)) // (1 - r)\n\n\nn, m = map(int, input().split())\nprint((2 * sum_pow(3, n - 1)) % m)\n"}, {"source_code": "'''input\n3 8\n'''\n# practicing a skill right after sleep improves it a lot quickly\nfrom sys import stdin, setrecursionlimit\nimport math\n\n# main starts\nn, m = list(map(int, stdin.readline().split()))\np = pow(3, n - 1, m)\nprint((2 * p) % m)"}, {"source_code": "import math\n\n\ndef powerk (a,x,y):\n if(x==1):\n return(a)\n elif(x<=0):\n return(1)\n else:\n y0=math.ceil(math.log(y,a))\n if (x5):\n mx=5 \n\nm=1\nfor i in range(mx,-1,-1):\n print('i: ',i)\n fm=10**i\n fx=3**fm\n cr = x // fm \n x = x - cr*fm\n # m=m%y\n for j in range(cr):\n m=(m*fx)%y\n\nres = m-1\nprint(res%y)"}, {"source_code": "import math\n\n\ndef powerk (a,x,y):\n if(x==1):\n return(a)\n elif(x<=0 or a<=0):\n return(1)\n else:\n y0=math.ceil(math.log(y,a))\n if (x 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(l,n):\n d={}\n for i in range(1,n+1):\n if i not in d.keys():\n d[i]=l[i]\n else:\n d[i].append(l[i])\n return d\n\nn,m=mi()\nprint(powerMod(3,n,m)-1)"}, {"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(l,n):\n d={}\n for i in range(1,n+1):\n if i not in d.keys():\n d[i]=l[i]\n else:\n d[i].append(l[i])\n return d\n\nn,m=mi()\nif powerMod(3,n,m)-1>0:\n print(powerMod(3,n,m)-1)\nelse:\n print(m+powerMod(3,n,m)-1)"}, {"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) % p1\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(l,n):\n d={}\n for i in range(1,n+1):\n if i not in d.keys():\n d[i]=l[i]\n else:\n d[i].append(l[i])\n return d\n\nn,m=mi()\nx=12*n-10\nprint(x%m)"}, {"source_code": "n, m = map(int, input().split())\n\nprint((4 * pow(2, n, m) - 6) % m)\n"}, {"source_code": "n, m = map(int, input().split())\n\nans = pow(3, n, m)\n\nif n % 2 == 1:\n ans -= 1\nelse:\n ans += 1\n\nprint(ans % m)\n"}, {"source_code": "n, m = map(int, input().split())\n\ndef mod_exp(a, b, n):\n\tx = a\n\ty = 1\n\twhile b > 0:\n\t\tif b%2:\n\t\t\ty = (y*x)%n \n\t\tx = (x*x)%n\n\t\tb = b >> 1\n\treturn y\n\nprint(mod_exp(3, n, m)-1)"}, {"source_code": "n, m = map(int, input().split())\nprint((n**3-1)%m)"}], "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c"} {"nl": {"description": "A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i\u00b7k dollars for the i-th banana). He has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?", "input_spec": "The first line contains three positive integers k,\u2009n,\u2009w (1\u2009\u2009\u2264\u2009\u2009k,\u2009w\u2009\u2009\u2264\u2009\u20091000, 0\u2009\u2264\u2009n\u2009\u2264\u2009109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants. ", "output_spec": "Output one integer \u2014 the amount of dollars that the soldier must borrow from his friend. If he doesn't have to borrow money, output 0.", "sample_inputs": ["3 17 4"], "sample_outputs": ["13"], "notes": null}, "positive_code": [{"source_code": "k,n,w = input().split()\nk,n,w = int(k), int(n), int(w)\ns = (w*(w+1)/2)*k\nres = n-s\nif res>0:\n print(0)\nelse:\n print(int(abs(res)))"}, {"source_code": "\"\"\"\nInput = 3 17 4\n\nOutput = 13\n\"\"\"\nk, n, w = raw_input().split(' ')\nk = int(k)\nn = int(n)\nw = int(w)\ncalculated_sum = (((((w * (w - 1)) / 2) + w) * k) )\nif calculated_sum < n:\n\tamount_the_soldier_has_to_borrow = 0\nelse:\n\tamount_the_soldier_has_to_borrow = calculated_sum - n\nprint amount_the_soldier_has_to_borrow"}, {"source_code": "def solve(k, n, w):\n\n totalMoneyNeeded = ((w*(w+1)) * k)/2\n return max(totalMoneyNeeded - n, 0)\n\n\nif __name__ == \"__main__\":\n inputs = raw_input().split(\" \")\n print solve(int(inputs[0]), int(inputs[1]), int(inputs[2]))"}, {"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 MI(): return map(int, sys.stdin.readline().strip().split())\ndef LI(): return list(map(int, sys.stdin.readline().strip().split()))\ndef LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().strip().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().strip().split()]\ndef LS(): return sys.stdin.readline().strip().split()\ndef I(): return int(sys.stdin.readline().strip())\ndef F(): return float(sys.stdin.readline().strip())\ndef S(): return sys.stdin.readline().strip()\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)\n\nfrom math import factorial,gcd\nfrom random import choice,randint\nfrom sys import stdin,stdout \ninp=stdin.readline\nout=stdout.write\n\nk,n,w=MI()\np=k*((w*(w+1))//2)\nif p>n:\n print(p-n)\nelse:\n print(0)"}, {"source_code": "q=input().split()\na=int(q[0])\nb=int(q[1])\nc=int(q[2])\ni=1\ns=0\nwhile i<=c:\n s+=a*i\n i+=1\nif b>=s:\n print(0)\nelse:\n print(s-b)\n"}, {"source_code": "initial, money, to_buy = list(map(int, input().split(' ')))\nsum = 0\ntotal = 0\nfor i in range(1, to_buy+1):\n to_pay = initial * i\n if to_pay > money:\n sum += to_pay - money\n money -= money\n\n else:\n\n rem = money - to_pay\n money = rem\n\n\nprint(sum)"}, {"source_code": "k,n,w = [int(i) for i in input().split()]\ntotal = 0\nfor i in range(1,w+1):\n total = total + (i * k)\n\nborrow = n-total\nif borrow >= 0:\n print(0)\nelse:\n print(abs(borrow))\n"}, {"source_code": "data_k_n_w = input().split(' ')\ndata_k_n_w = [int(i) for i in data_k_n_w]\n\namount = int(data_k_n_w[0]*((data_k_n_w[2]*(data_k_n_w[2]+1))/2))\n \nif amount < data_k_n_w[1]:\n print(0)\nelse:\n print(abs(amount-data_k_n_w[1]))"}, {"source_code": "k,n,w=map(int,input().split())\nprint(max(0,int(w/2*(k+k*w)-n)))"}, {"source_code": "k , n , w = list(map(int , input().split(\" \")))\ncost = 0\nfor i in range(1,w+1):\n cost += i*k\nif cost-n < 0:\n print(0)\nelse:\n print(cost-n)"}, {"source_code": "inputs = input().split()\ncost_bannana = int(inputs[0])\namount_soldier = int(inputs[1])\nno_of_bananas = int(inputs[2])\n\n\ntotal_cost = cost_bannana * (no_of_bananas)*(no_of_bananas + 1) // 2\nborrow = total_cost - amount_soldier\nif borrow > 0:\n print(borrow)\nelse:\n print(0)"}, {"source_code": "k, n, w = map(int, input().split())\ncena = 0\nfor i in range(w):\n cena += k * (i+1)\nif cena >= n:\n print(cena - n)\nelse:\n print(0)"}, {"source_code": "var1,var2,var3=map(int,input().split(\" \"))\n\nif var3!=0:\n x =0\n for i in range(1,var3+1):\n x = x+ var1*i\n v = x - var2\n if v>0:\n print(v)\n else:\n print(0)\nelse:\n print(0)\n"}, {"source_code": "k,n,w=map(int,input().split())\nj=0\nfor i in range(1,w+1):\n j=j+i*k\nif j>n:\n print(j-n)\nelse:\n print(0)"}, {"source_code": "#!/usr/bin/env Python3\nx = input()\nk,n,w = x.split(\" \")\n\nk = int(k)\nn = int(n)\nw = int(w)\ntotal = 0\n\nwhile(w != 0):\n total += (k*w)\n w -=1\n\nborrow = total-n\n\nif(borrow >= 0):\n\tprint(borrow)\nelse:\n\tprint(0)"}, {"source_code": "from math import *\nk, n, w = map(int, input().split())\nprint(max(0,w*(w+1)*k//2-n))"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\n\ndef bananas(cost, amnt, num):\n total = 0\n for i in range(num):\n total += (i + 1) * cost\n print total - amnt if total > amnt else 0\n\nif __name__ == '__main__':\n cost, amnt, num = (int(x) for x in sys.stdin.readline().split())\n #cost, amnt, num = (3, 17, 4)\n bananas(cost, amnt, num)\n "}, {"source_code": "k,n,w=map(int,input().split())\ntot=0\nfor i in range(w):\n tot+=(i+1)*k\nif n>=tot:\n print(0)\nelse:\n print(tot-n)"}, {"source_code": "x,y,z=map(int,input().split())\nsum=0\nfor i in range(1,z+1):\n sum=sum+i*x\nif sum n:\n print((sum(list(range(1,w+1)))*k)-n)\nelse:\n print(\"0\")"}, {"source_code": "k,n,w=[int(x) for x in input().split()]\n \ndef fun(k,n,w):\n sum=0\n for i in range(1,w+1):\n sum+=i*k\n ans=sum-n\n if ans>0:\n return print(ans)\n else: return print(0) \nfun(k,n,w) \n"}, {"source_code": "k, n, w=map(int, input().split())\ns=0\nfor i in range(1,w+1):\n s=s+(i*k)\na=s-n\nif s==n or s w:\n print m - w\nelse:\n print 0\n"}, {"source_code": "k,n,w = map(int,input().split())\ns = 0;\nfor i in range(1,w+1):\n s += (i*k)\nif n >= s:\n print(\"0\")\nelse: \n print(s - n)"}, {"source_code": "k, n, w = map(int, input().split())\n\nx = sum([k*i for i in range(w+1)])\n\nif n > x:\n print(0)\nelse:\n print(x - n)\n"}, {"source_code": "x = raw_input()\nm = 0\ny = x.split(\" \")\nk = int(y[0])\nn = int(y[1])\nw = int(y[2])\np = int(1)\nl = int(0)\nfor i in range(w+1):\n if i > 0:\n p = i*k\n l += p\nm = l - n\nif m >= 0:\n print m\nelse:\n print \"0\""}, {"source_code": "\nk, n, w = map(int, raw_input().split())\namount = 0\nfor a in range(1, w+1):\n\tamount += (a * k)\nanswer = amount - n\nif answer < 0:\n\tanswer = 0\nprint answer\n"}, {"source_code": "k,n,w = map(int,raw_input().split())\nfor i in range(1,w+1):\n n = n - (i*k)\nif n>0:\n print \"0\"\nelse :\n print abs(n)\n"}, {"source_code": "k,n,w=list(map(int,input().split()))\nif k*(1+w)*w//2-n<=0:\n print(0)\nelse:\n print(k*(1+w)*w//2-n)"}, {"source_code": "a=input().split()\nk,n,w=a\nk=int(k)\nn=int(n)\nw=int(w)\ntotal_price=0\nfor i in range(0,w+1):\n total_price=total_price+i*k\nif n>total_price:\n borrow_money=0\nelse:\n borrow_money=total_price-n\n\nprint(borrow_money)"}, {"source_code": "input = input().split(\" \") \n\nk = int(input[0]) # k is the price of ea banana\nn = int(input[1]) # n is the user's money\nw = int(input[2]) # w is number of bananas\nz = []\n\nfor i in range(1, w + 1):\n\tz.append(i * k)\ntotal = sum(z)\nborrow = sum(z) - int(input[1])\n\nif n > total:\n\tprint(0)\nelse:\n\tprint(borrow)\n"}, {"source_code": "k, n, w = map(int, input().split())\n#cost = 0\n#for i in range (1,w+1) :\n# a = i*k\n# cost += a\n#print(int(cost - int(n)))\n\nprint(max(0, k*w*(w+1)//2 - n))\n"}, {"source_code": "val=list(map(int,input().split(' ')))\nans=0\nfor i in range(val[2]):\n ans=ans+((i+1)*val[0])\nif(val[1]= 0:\n print(0)\nelse:\n print(abs(borrow))\n"}, {"source_code": "k, n, w = map(int, raw_input().split())\nprint max(k*w*(w+1)/2 - n, 0)"}, {"source_code": "c = input()\nc = c.split()\na = 0\nfor i in range(1, int(c[2]) + 1, 1):\n a += i * int(c[0])\nif a > int(c[1]):\n print(a - int(c[1]))\nelse:\n print(0)"}, {"source_code": "first, money, n_ban = [int(u) for u in input().split()]\nmoney_r = first*((n_ban*(n_ban+1))//2)\nif money > money_r:\n\tprint('0')\nelse:\n\tprint(money_r-money)\n"}, {"source_code": "k,n,w=map(int,input().split())\n\np=k*((w*(w+1))//2)\nif p>n:\n print(p-n)\nelse:\n print(0)"}, {"source_code": "\"\"\"\nAuthor : raj1307\nInstitute : Jalpaiguri Government Engineering College\nDate : 22.03.19\n\"\"\"\nfrom __future__ import division, print_function\nimport itertools,os,sys\n#from collections import deque, Counter, OrderedDict\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 *\nfrom atexit import register\nfrom io import BytesIO, StringIO\n\nif sys.version_info[0]<3:\n range = xrange\n filter = itertools.ifilter\n map = itertools.imap\n zip = itertools.izip\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()))\nelse:\n sys.stdin = StringIO(os.read(0, os.fstat(0).st_size).decode())\n sys.stdout = StringIO()\n register(lambda: os.write(1, sys.stdout.getvalue().encode()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\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}\ndef getKey(item): return item[0] \ndef sort2(l):return sorted(l, key=getKey)\ndef d2(n,num):return [[num for x in range(n)] for y in range(n)]\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\ndef main():\n k,n,w=mi()\n if int((w*(w+1))/2)*k<=n:\n print(0)\n else:\n print(int((w*(w+1))/2)*k-n)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "a=[int(i) for i in input().split()]\nintialcost=a[0]\nmoney=a[1]\nbanana=a[2]\nn=int(banana)+1\ntotal=0\nfinal=0\nfor i in range(n):\n total=total+i*int(intialcost)\nif total<=money:\n final=0\nelse:\n final=total-int(money)\nprint(final)\n"}, {"source_code": "k,n,w = map(int,raw_input().split())\n\nprint max(k*w*(w+1)/2 -n,0)"}, {"source_code": "n,k,w=map(int,input().split())\nsum=0\nfor i in range(1,w+1):\n sum=sum+(n*i)\nif sum>k:\n print(sum-k)\nelif sum<=k:\n print(\"0\")"}, {"source_code": "k, n, w = [int(i) for i in raw_input().split()]\nans = (w*(w+1)*k)/2 - n\nif ans >= 0:\n\tprint(ans)\nelse:\n\tprint(0)\n"}, {"source_code": "k, n, w = map(int, input().split())\ns = (k + w*k)/2*w\nif s > n:\n print(int(s - n))\nelse:\n print(0)"}, {"source_code": "values = raw_input().split()\n\ncost_banana = int(values[0])\ndollars = int(values[1])\nbanana = int(values[2])\n\ncounter = 1\ncost = 0\n\nwhile counter < banana + 1:\n cost += cost_banana * counter\n counter += 1\n\nif cost - dollars < 0:\n print(0)\nelse:\n print(cost - dollars)\n"}, {"source_code": "def solver(k,n,w):\n tot=(w/2)*((2*k)+((w-1)*k))\n # print(tot)\n if (n - int(tot)) >= 0:\n return 0\n return int(tot) - n\n\nif __name__=='__main__':\n a,b,c=map(int,input().split())\n print(solver(a,b,c))"}, {"source_code": "k, n, w = map(int, input().split())\ncost = int((w/2)*(2*k+(w-1)*k)-n)\nif cost < 0:\n print(0)\nelse:\n print(cost)"}, {"source_code": "k , n , w = input().split()\nk = int(k)\nn = int(n)\nw = int(w)\nx = 0\ns = 1\nfor i in range (w):\n x = x + (s*k)\n s = s + 1\nif x > n :\n print ( x - n )\nelse :\n print (0)\n"}, {"source_code": "k,n,w=list(map(int,input().split()))\nprint(max(0,w*(w+1)*k//2-n))\n"}, {"source_code": "k, n, w = map(int, raw_input().split())\nb = (k * (w * (w + 1)) / 2) - n\nprint max(0, b)"}, {"source_code": "arr = [ int(x) for x in raw_input().split() ]\n\nresult = ( arr[0] * ((arr[2] * (arr[2] + 1) / 2)) - arr[1] )\n\nif result < 0:\n\tprint \"0\"\nelse:\n\tprint result"}, {"source_code": "k1,n1,m1=raw_input().split()\nk=int(k1)\nn=int(n1)\nm=int(m1)\n#print k,n,m\nj=0\nfor i in range(1,m+1):\n j+=k*i\n #print j\ntotal=j-n\nprint max(total,0)"}, {"source_code": "s=raw_input()\na,b,c=s.split()\ntotal=0\ntot=0\na1=int(a)\nb1=int(b)\nc1=int(c)\ntotal1=int(total)\ntot1=tot\nfor i in range(1,int(c1)+1):\n tot1=(a1*i)+tot1\n \n#print tot1\ntotal1=(tot1)-(b1)\n#print total1\nif total1>0:\n print(total1)\nelse:\n print(0)"}, {"source_code": "num = raw_input().split(\" \")\nn = int(num[2])\nm = int(num[0])\ntot = 0\n\nwhile n!=0:\n\ttot = tot + m * n\n\tn = n-1\nvar = tot - int(num[1])\n\n\nif var<0:\n\tprint(0)\nelse:\n\tprint(var)\n"}, {"source_code": "nums = map(int, raw_input().split())\nprint max((nums[2]*(nums[2]+1))/2 * nums[0] - nums[1], 0)\n\n"}, {"source_code": "x, y, z = raw_input().split()\nbanana_price = int (x) \npocket_money = int (y)\nnumber_of_bananas = int (z)\ntotal_price = 0\n\nfor x in range(1, number_of_bananas + 1):\n total_price += (x * banana_price)\n\nmoney_to_borrow = total_price - pocket_money\n\nif money_to_borrow <= 0:\n money_to_borrow = 0\n\nprint(money_to_borrow)\n"}, {"source_code": "k,n,w=input().split()\nk=int(k)\nn=int(n)\nw=int(w)\nt=int(w*(w+1)*k/2)\nif(t>n):\n print(t-n)\nelse:\n print(\"0\")\n"}, {"source_code": "k, n, w = [int(i) for i in raw_input().split()]\nans = (w*(w+1)*k)/2 - n\nif ans >= 0:\n\tprint(ans)\nelse:\n\tprint(0)\n"}, {"source_code": "lists = list(map(int, input().rstrip().split()))\n\nfor i in range(1, lists[2]+1):\n lists[1] -= i*lists[0]\n\nif lists[1] >= 0:\n print(0)\nelse:\n print(abs(lists[1]))"}, {"source_code": "k, n, w = [ float(x) for x in raw_input().split() ]\n\namount = (w*(w+1)/2.0)*k\nif amount a[1]:\n print(sum - a[1])\nelse:\n print(\"0\")\n"}, {"source_code": "def solver(k,n,w):\n tot=(w/2)*((2*k)+((w-1)*k))\n # print(tot)\n if (n - int(tot)) >= 0:\n return 0\n return int(tot) - n\n\nif __name__=='__main__':\n a,b,c=map(int,input().split())\n print(solver(a,b,c))"}, {"source_code": "k,n,w=map(int,input().split())\nprint(max(0,w*(w+1)*k//2-n))\n"}, {"source_code": "banana_1, money, bananas = map(int, input().split())\ncost = 0\nfor num_banana in range(1, bananas + 1):\n cost += banana_1 * num_banana\ndebt = money - cost\nif(debt < 0):\n print(abs(debt))\nelse:\n print(\"0\")\n#Done"}, {"source_code": "x = list(map(int, input().split()))\n\nc = 0\nfor i in range(1, x[2]+1):\n c+=x[0]*i\n\nif(x[1]>=c):\n print(\"0\")\nelse:\n print(c-x[1])"}, {"source_code": "k,n,w=map(int,input().split())\n\ns=sum(range(1,w+1))*k\n\nif s-n>0:\n print(s-n)\nelse:\n print(0)\n"}, {"source_code": "def solve(k, n, w):\n\n totalMoneyNeeded = ((w*(w+1)) * k)/2\n return max(totalMoneyNeeded - n, 0)\n\n\nif __name__ == \"__main__\":\n inputs = raw_input().split(\" \")\n print solve(int(inputs[0]), int(inputs[1]), int(inputs[2]))"}, {"source_code": "k,n,w = map(int, input().split(\" \"));x = 0\nfor i in range(1,w+1): x += i*k\nprint(abs(n-x)) if(x>n) else print(\"0\")"}, {"source_code": "def banana(s):\n l = map(float, s)\n k = l[0]\n n = int(l[1])\n w = l[2]\n need = ((w/2) * ((2*k)+((w-1)*k)))\n need = int(need)\n if (n>=need):\n print 0\n else:\n print (need - n)\ns = raw_input().split()\nbanana(s)"}, {"source_code": "input=raw_input()\n\ninput_arr=input.split(\" \")\n\nk=int(input_arr[0])\n\nn=int(input_arr[1])\nw=int(input_arr[2])\n\ni=0\n\ntotal=0\n\nwhile i=total:\n print(0)\nelse:\n print(total-n)"}, {"source_code": "k,n,w=map(int,input().rstrip().split())\nsum=(w)*(w+1)\nl=sum//2\nnew=l*k\nif new 0:\n print(cst - n)\n \nelse:\n print(\"0\")"}, {"source_code": "lists = list(map(int, input().rstrip().split()))\n\nfor i in range(1, lists[2]+1):\n lists[1] -= i*lists[0]\n\nif lists[1] >= 0:\n print(0)\nelse:\n print(abs(lists[1]))"}, {"source_code": "k,n,w = map(int,input().split())\ns = (w/2)*(2*k+(w-1)*k)\n\nif s<=n:\n print(\"0\")\nelse: \n print(\"{:.0f}\".format(s - n))"}, {"source_code": "k,n,w=map(int,input().split())\ntong=0\nfor i in range(w):\n\ttong+=(i+1)*k\nif tong - n < 0 : print(0)\nelse: print(tong-n)"}, {"source_code": "k,n,w=map(int,input().split());\nprint(max(0,w*(w+1)*k//2-n))"}, {"source_code": "k,n,w=map(int,input().split())\nt=0\nfor i in range(1,w+1):\n t=t+i*k\na=t-n\nif a<0:\n a=0\nprint(a)\n"}, {"source_code": "from math import ceil\nimport sys,bisect,copyreg,copy,statistics,os\ndef inp(): return sys.stdin.readline().strip()\ndef IIX(): return (int(x) for x in sys.stdin.readline().split())\ndef II(): return (int(inp()))\ndef LI(): return list(map(int, inp().split()))\ndef L(x):return list(x)\ndef out(var): return sys.stdout.write(str(var))\n\n\nk, n, w=IIX()\n\ncost=k*((w*(w+1)//2))\n\nif cost-n>=0:\n out(cost-n)\nelse:\n out(0)\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "st=raw_input()\nl=st.split()\nk=int(l[0])\nn=int(l[1])\nw=int(l[2])\n###i,j = raw_input(\"Enter two values: \").split\n##i = int(i)\n##j = int(j)\nreq=k*((w*(w+1))/2)\nif (req-n)>=0:\n print req-n\nelse:\n print \"0\"\n"}, {"source_code": "k,n,w = map(int, raw_input().split())\nres = k*(w*(w+1)/2)\nprint (res - n)*(res > n)"}, {"source_code": "input=raw_input()\n\ninput_arr=input.split(\" \")\n\nk=int(input_arr[0])\n\nn=int(input_arr[1])\nw=int(input_arr[2])\n\ni=0\n\ntotal=0\n\nwhile i=total:\n print(0)\nelse:\n print(total-n)"}, {"source_code": "k,n,w=raw_input().split()\nk=int(k);n=int(n);w=int(w)\ns=w*(w+1)*k/2-n\nif s<=0:\n print 0\nelse:\n print s"}, {"source_code": "def solve(k, n, w):\n\n totalMoneyNeeded = ((w*(w+1)) * k)/2\n return max(totalMoneyNeeded - n, 0)\n\n\nif __name__ == \"__main__\":\n inputs = raw_input().split(\" \")\n print solve(int(inputs[0]), int(inputs[1]), int(inputs[2]))\n"}, {"source_code": "k, n, w = map(int,input().split())\nsum = 0\nfor i in range(1, w+1):\n s = k * i\n sum = s + sum\nif sum - n> 0:\n print(sum - n)\nelse:\n print(\"0\")\n"}, {"source_code": "def solve(k, n, w):\n\n moneyreq = ((w*(w+1)) * k)/2\n return max(moneyreq - n, 0)\n\n\nif __name__ == \"__main__\":\n inputs = raw_input().split(\" \")\n print solve(int(inputs[0]), int(inputs[1]), int(inputs[2]))"}, {"source_code": "def soilder(k,n,w):\n if type(k) is not int or type(n) is not int or type(w) is not int:\n raise TypeError(\"Arguments are not number\")\n \n if k <0 or n < 0 or w <0:\n raise ValueError(\"All numbers must be integer\")\n \n price = w*(w+1)*k/2\n \n if price > n:\n return price - n\n else:\n return 0\n\n(k,n,w) = raw_input(\"\").split(\" \")\nprint soilder(int(k),int(n),int(w))"}, {"source_code": "k,n,w=map(int,input().split())\nc=0\nfor i in range(1,w+1):\n c+=k*i\n \nx=c\n\nif x<=n:\n print(0)\nelse:\n print(x-n)\n"}, {"source_code": "k, n , w = map(int, (raw_input().split()))\n\n#k,n,w = 3,17,4\n\nprice = 0\nfor i in xrange(1, w+1):\n price += i*k\nif w == 0:\n print 0\nelse:\n print (price-n) if price > n else 0\n"}, {"source_code": "k,n,w = [int(i) for i in raw_input().split(\" \")]\n\ns = 0\nfor i in xrange(w):\n s += (i + 1) * k\n\nif s <= n: print 0\nelse: print s-n \n"}, {"source_code": "c = input()\nc = c.split()\na = 0\nfor i in range(1, int(c[2]) + 1, 1):\n a += i * int(c[0])\nif a > int(c[1]):\n print(a - int(c[1]))\nelse:\n print(0)"}, {"source_code": "import math\n\nk, n, w = [float(x) for x in raw_input().split()]\n\na = int (k*(w*(w+1))/2 - n)\n\nif a<0:\n\tprint '0'\nelse:\n\tprint a"}, {"source_code": "val=list(map(int,input().split(' ')))\nans=0\nfor i in range(val[2]):\n ans=ans+((i+1)*val[0])\nif(val[1]n):\n borrow=totalcost-n\n print borrow"}, {"source_code": "k, n, w = map(int, input().split())\ncena = 0\nfor i in range(w):\n cena += k * (i+1)\nif cena >= n:\n print(cena - n)\nelse:\n print(0)"}, {"source_code": "def solve(k, n, w):\n\n totalMoneyNeeded = ((w*(w+1)) * k)/2\n return max(totalMoneyNeeded - n, 0)\n\n\nif __name__ == \"__main__\":\n inputs = raw_input().split(\" \")\n print solve(int(inputs[0]), int(inputs[1]), int(inputs[2]))"}, {"source_code": "a=raw_input().split()\nk=int(a[0])\nn=int(a[1])\nw=int(a[2])\nw=w*(w+1)/2\nd=w*k-n\nif d<0:\n d=0\nprint d"}], "negative_code": [{"source_code": "k , n , w = input().split()\nk = int(k)\nn = int(n)\nw = int(w)\nx = 0\nfor i in range ( 1 , (w+1) ):\n x = x + (i*k)\nif x > n :\n print ( x - n )\nelse :\n print ( n - x )\n"}, {"source_code": "k,n,w=map(int,input().split())\ntong=0\nfor i in range(w):\n\ttong+=(i+1)*k\nif tong < 0 : print(0)\nelse: print(tong-n)"}, {"source_code": "k,n,w = map(int,raw_input().split())\nif k ==w and k =1 and n>=0:\n x = (k+w*k)/2*w\n print(abs(x-n))\n break"}, {"source_code": "n, k, w = map(int, input().split())\nprint(n - ((w * (w + 1)) / 2) * k)"}, {"source_code": "k,n,w = map(int,input().split(\" \"))\ntotal = (w + 2*k)*k\nif (n>total):\n print('0')\nelse:\n print(total - n)"}, {"source_code": "k, n, w = map(int, input().split())\nt = ((w+1) * w * k) // 2\nprint(t - n)\n"}, {"source_code": "x, y, z = map(int, input().split())\nif z >= y:\n print(0)\nelse:\n print(y-z)\n"}, {"source_code": "k,n,w=map(int,input().rstrip().split())\nw=(w)*(w+1)\nw=w//2\nnew=w*k\nif n>w:\n print(0)\nelse:\n print(w-n)"}, {"source_code": "\nk, n, w = map(int, input().split())\n \ns = int(k*(w*(w+1)/2) - n)\n \nif s < 0:\n print(s)\nelse:\n print(\"0\")"}, {"source_code": "k,n,w = map(int, raw_input().split()) #bananas, $$, bananas wanted\ntot=0\n\nfor i in range(1,w+1):\n\ttot+=i\n\ncost = tot*k\nborrow = abs(n-cost)\n\nprint borrow\n#3+6+9+12 = 30-17=13"}, {"source_code": "k,n,w = input().split()\nk,n,w = int(k), int(n), int(w)\ns = (w*(w+1)/2)*k\nres = n-s\nif res>0:\n print(0)\nelse:\n print(res)"}, {"source_code": "k,n,w = map(int,input().split(\" \"))\nrequired = ((w*(w+1))//2)*k\nprint(n-required)"}, {"source_code": "def solver(k,n,w):\n tot=(w//2)*((2*k)+((w-1)*k))\n return tot - n\n\nif __name__=='__main__':\n a,b,c=map(int,input().split())\n print(solver(a,b,c))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jul 29 16:27:18 2020\n\n@author: A2B\n\"\"\"\n\n\nsumm,i=0,0\nk,n,w=map(int,input().split())\nfor i in range(w+1):\n summ+=(i*k)\n \nprint(summ-n)"}, {"source_code": "knw=input().split()\nk=int(knw[0])\nn=int(knw[1])\nw=int(knw[2])\ncosto=0\nfor i in range(1,w+1):\n costo=costo+k*i\nprint(abs(n-costo))\n"}, {"source_code": "a=raw_input().split()\nk=int(a[0])\nn=int(a[1])\nw=int(a[2])\nw=w*(w+1)/2\nprint w*k-n"}, {"source_code": "k,n,w=map(int,input().rstrip().split())\nw=(w)*(w+1)\nw=w//2\nnew=w*k\nif new>w:\n print(0)\nelse:\n print(w-new)"}, {"source_code": "n = raw_input().split(' ')\ncost = int(n[0])\nnum = int(n[2])\navail = int(n[1])\n\n\nprint cost*(num*(num+1)/2) - avail\n"}, {"source_code": "def cn(v):\n\tk,s,n=v\n\tprint(v)\n\treturn k*n*(n+1)//2-s\n\nprint(cn([int(x) for x in input().split()]))"}, {"source_code": "a = str(input())\na = a.split(' ')\nk = int(a[0])\nn = int(a[1])\nw = int(a[2])\nx = int(0)\ni = 1\nfor i in range(w-n):\n x += k*i\n\nif x <= n:\n print(0)\n exit()\nif x > n:\n x -= n\n print(x)"}, {"source_code": "banana_1, money, bananas = map(int, input().split())\ncost = 0\nfor num_banana in range(1, bananas + 1):\n cost += banana_1 * num_banana\ndebt = cost - money\nprint(debt)"}, {"source_code": "[k, n, w] = [int(_) for _ in input().split()]\n\nprint( max(0, k*w*(w-1)//2-n) )"}, {"source_code": "from sys import stdin,stdout\nfrom collections import Counter\nfrom math import ceil\nfrom bisect import bisect_left \nfrom bisect import bisect_right\nimport math\n \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,n,w=ei()\ns=0\nfor i in range(w):\n s+=k*i \nprint(s-n)"}, {"source_code": "k,n,w = map(int,input().split())\ntotalsum = k*(w*(w+1)/2)\nprint(totalsum-n)"}, {"source_code": "k, n, w=map(int, input().split())\ns=0\nfor i in range(1,w+1):\n s=s+(i*k)\na=s-n\nprint(a)\n "}, {"source_code": "k, n, w = list(map(int, input().split()))\ncount = 0\nsum = (w*(w-1)*k)/2\nif sum - n < 0:\n print(\"0\")\nelse:\n print(sum - n)"}, {"source_code": "k1,n1,w1=input().split()\nk=int(k1)\nn=int(n1)\nw=int(w1)\nmused=0\ncount=1\np=0\ni=w\nwhile i>0:\n if mused<=n:\n mused=count*k+mused\n count=count+1\n i=i-1\n else:\n mused=count*k+mused\n p=mused-n\n i=i-1\nprint(p)"}, {"source_code": "\nimport sys\n\nlocal_launch = False\ntry:\n open('LOCAL').read()\n local_launch = True\nexcept:\n pass\ninput_data = open('INPUT.txt').read() if local_launch else sys.stdin.read()\ndone = {'i': 0}\ntokens = input_data.split()\n\ndef next_token():\n result = tokens[done['i']]\n done['i'] += 1\n return result\n\ndef next_int():\n return int(next_token())\n\ndef next_str():\n return next_token()\n\n############## BEGIN OF CODE #####################\n\nk = next_int()\nn = next_int()\nw = next_int()\na = 1\ni = 1\nwhile i != w:\n i = i + 1\n a=a+i\n u = a * k\nif u - n < 0:\n print(u - n)\nelse:\n print(0)\n\n\n\n# \u0430 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u043b\u0435\u0442\u044c k*2k*3k... \u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c w \u0440\u0430\u0437\n\n\n#\u0430=1\n#i=1\n#\u0414\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 i \u043d\u0435 \u0440\u0430\u0432\u043d\u043e 100 \u0434\u0435\u043b\u0430\u0435\u043c:\n # i=i+1\n# a=a+i\n#\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0431\u0430\u043d\u0430\u043d\u0430(\u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0431\u0430\u043d\u0430\u043d\u043e\u0432 \u0442\u043e\u0435\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 3 \u0437\u043d\u0430\u0447\u0438\u0442 1+2+3)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n############# END OF CODE #####################"}, {"source_code": "import sys\ntemp = sys.stdin.readline()\n\n\nwhile temp:\n \n\n k, n, w = temp.split(\" \")\n k = int(k)\n n = int(n)\n w = int(w)\n \n \n aux = ((w)*(w+1))* k/2\n if aux - n < 0:\n print(0)\n else:\n print(aux - n)\n temp = sys.stdin.readline()"}, {"source_code": "k,n,w=input().split()\nk=int(w)\nn=int(k)\nw=int(n)\nsum=0\nfor i in range(k):\n sum+=w*i\nprint(sum-n)"}, {"source_code": "x=0\nk,n,w=input().split()\nk=int(k)\nn=int(n)\nw=int(w)\nfor o in range(1,w+1):\n x=k*o+x\nm=x-n\nif m<0:\n m==m+(m*-1)\nprint(m)"}, {"source_code": "a,b,c=map(int,input().split())\nx=a*(b*(b+1))/2\nif (x-c)>0:\n\tprint(x-c)\nelse:\n\tprint(\"0\")"}, {"source_code": "T=list(map(int,input().split(' ')))\nk=T[0]\nn=T[1]\nw=T[2]\n\nA=w*(w+1)/2\nPA=A*k\nprint(round(PA-n))\n\n"}, {"source_code": "\"\"\"n = int(input())\ncount = 0\nfor i in range(n):\n\tc = 0\n\tp = [int(k) for k in input().split()]\n\tfor j in p:\n\t\tif j == 1:\n\t\t\tc+=1\n\tif c >=2:\n\t\tcount+=1\nprint(count)\"\"\"\n\"\"\"n,k = input().split()\ncount = 0\nscores = [int(i) for i in input().split()]\nkth = scores[int(k)-1]\nfor j in scores:\n\tif j == 0:\n\t\tcontinue\n\telif j>=kth:\n\t\tcount += 1\nprint(count)\"\"\"\n\"\"\"word = input()\nvowel = ['a','e','i','o','u','y','A','E','I','O','U','Y']\nfor i in word:\n\tif i in vowel:\n\t\tcontinue\n\telif i not in vowel:\n\t\tprint('.'+i.lower(),end = '')\"\"\"\n\"\"\"import math\nm,n = input().split()\nprint(math.floor((int(m)*int(n))/2))\"\"\"\n\"\"\"n = int(input())\nx = 0\nfor i in range(n):\n\tlis = []\n\tlis = input()\n\tif (lis[0] == '+'and lis[1]=='+') or (lis[1] == '+' and lis[2] == '+'):\n\t\tx += 1\n\telif (lis[0] == '-'and lis[1]=='-') or (lis[1] == '-' and lis[2] == '-'):\n\t\tx -= 1\nprint(x)\"\"\"\n\"\"\"s = input()\na = s[0].capitalize()\nprint(a+s[1:])\"\"\"\n\"\"\"Petya and strings\nn1 = input()\nn2 = input()\nc = 0\nfor i in range(len(n1)):\n\tif ord(n1[i].lower()) > ord(n2[i].lower()):\n\t\tprint(1)\n\t\tc = 1\n\t\tbreak\n\telif ord(n1[i].lower()) < ord(n2[i].lower()):\n\t\tprint(-1)\n\t\tc = 1\n\t\tbreak\n\telse:\n\t\tcontinue\nif c == 0:\n\tprint(0)\"\"\"\n\"\"\"beautiful matrix\nfor i in range(5):\n\ta =[]\n\tfor j in input().split():\n\t\ta.append(int(j))\n\tif 1 in a:\n\t\tprint(abs(a.index(1)-2)+abs(i-2))\"\"\"\n\"\"\"helpful maths\nn = [int(i) for i in input().split('+')]\nn.sort()\nfor i in range(len(n)):\n\tif i != len(n)-1:\n\t\tprint(n[i],end='+')\n\telse:\n\t\tprint(n[i])\"\"\"\n\"\"\"football\nn = input()\nif '0000000' in n:\n\tprint('YES')\nelif '1111111' in n:\n\tprint(\"YES\")\nelse:\n\tprint('NO')\"\"\"\n\"\"\"stones on the table\nn = int(input())\nrock = input()\nc = 0\nfor i in range(n-1):\n\tif rock[i] == rock[i+1]:\n\t\tc += 1\nprint(c)\"\"\"\n\"\"\"boy or girl\nn = input()\nc = 0\nfor i in range(len(n)):\n\tif i == 0:\n\t\tc+=1\n\telif n[i] not in n[:i]:\n\t\tc+=1\nif c%2 == 0:\n\tprint(\"CHAT WITH HER!\")\nelse:\n\tprint(\"IGNORE HIM!\")\"\"\"\n\"\"\"Young physicist\nn = int(input())\nx1=y1=z1=0\nfor i in range(n):\n\tx,y,z=input().split()\n\tx1=x1+int(x)\n\ty1=y1+int(y)\n\tz1=z1+int(z)\nif x1==0 and y1==0 and z1==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\"\"\"\n\"\"\"soldier and banana\"\"\"\nk,n,w=input().split()\nmoney = 0\nfor i in range(1,int(w)+1):\n\tmoney += int(k)*i\nif int(n)>money:\n\tprint(money)\nelse:\n\tprint(abs(money-int(n)))\n\n\n\n\n\n \n\n\n"}, {"source_code": "first, money, n_ban = [int(u) for u in input().split()]\nmoney_r = first*((n_ban*(n_ban+1))//2)\nif first > money_r:\n\tprint('0')\nelse:\n\tprint(money_r-first)"}, {"source_code": "c = input()\nc = c.split()\na = 0\nfor i in range(1, int(c[2])+1, 1):\n a += i*int(c[0])\nprint(a-int(c[1]))"}, {"source_code": "k,n,w=map(int,raw_input().split())\nsum=0\nfor i in range(1,w+1):\n sum=sum+i*k\nborrow=sum-n\nprint borrow"}, {"source_code": "c, a, n = map(int, input().split())\n\nt = c * (n*(n + 1)) // 2\nprint(t - a)"}, {"source_code": "initial, money, to_buy = list(map(int, input().split(' ')))\nsum = 0\ntotal = 0\nfor i in range(1, to_buy+1):\n if initial > money:\n sum += initial * i\n\n else:\n pay = i * initial\n rem = money - pay\n money = rem\n\nsum -= money\nprint(sum)\n\n"}, {"source_code": "k, n, w = map(int, input().split())\n#cost = 0\n#for i in range (1,w+1) :\n# a = i*k\n# cost += a\n#print(int(cost - int(n)))\n\nprint(max(0, k*w*(w+1)/2) - n)\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Soldier and Bananas.py\n# \n# Copyright 2020 Rahul \n# \n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\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, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n# MA 02110-1301, USA.\n# \n# \n\ncost, amount, banana = map(int, input().split())\ncst = 0\nfor i in range(1,banana+1):\n\tcst += i*cost\n\t\n\tif cst-amount > 0:\n\t\tprint(cst-amount)\n"}, {"source_code": "k,n,w = map(int,input().split())\n\ntotal = w*(w+1)*k/2\n\nborrow = total - n\n\nprint(int(borrow))"}, {"source_code": "a, b, c = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nk = sum(range(c + 1))\nprint(abs(b - a * c))"}, {"source_code": "var1,var2,var3=map(int,input().split(\" \"))\nx = var1\nif var3!=0:\n for i in range(2,var3+1):\n x = x+ var1*i\n v = x - var2\n print(v)\nelse:\n print('0')\n\n"}, {"source_code": "x=0\nk,n,w=input().split()\nk=int(k)\nn=int(n)\nw=int(w)\nfor i in range(1,w):\n k=k*i\n x=k+x\nprint(x-n+3)"}, {"source_code": "cost_1, mib, num_b = map(int, raw_input().split(\" \"))\ntot = 0\nfor i in range(1, num_b+1):\n tot+=i*cost_1\nprint tot - mib"}, {"source_code": "k,n,w=input().split()\nk=int(w)\nn=int(k)\nw=int(n)\nsum=0\nfor i in range(k):\n sum+=w*i\nprint(sum-n)"}, {"source_code": "nums = [int(x) for x in input().split()]\nk = nums[0]\nn = nums[1]\nw = nums[2]\nprint(((((w+1)*w)//2)*k)-n)"}, {"source_code": "#soilder_and_bananas\nk,n,w=map(int,input().split())\na=k*(w*(w+1)/2)\nif(a>=0):\n print(a-n)\nelse:\n print(\"-1\")\n "}, {"source_code": "k,n,w=list(map(int,input().split()))\nt=(w*(w+1)*k)/2\nprint(abs(t-n))\n"}, {"source_code": "k, n, w = map(int, raw_input().split())\n\nprint((1 + w) * w * k / 2 - n)"}, {"source_code": "k, n, w = map(int, input().split())\n\n\ncount = 1\n\nwhile w != 0:\n n -= k\n w -= 1\n k = k*count\n count += 1\n\nprint(-n)\n \n \n \n \n \n\n"}, {"source_code": "k,n,w = map(int,input().split())\ns = (w/2)*(2*k+(w-1)*k)\nprint(s-n)"}, {"source_code": "k, n, w = input().split()\nk = int(k)\nn = int(n)\nw = int(w)\n\ntotal = 0\n\nfor i in range(w):\n total = total + k*(i+1)\n\n# print(total)\n\nprint(total - n)\n"}, {"source_code": "k,n,w = map(int,raw_input().split())\ntotal_sum=0\ni=0\nfor i in range(0,w+1):\n total_sum=total_sum = i*k\nif(total_sum <= n):\n print \"0\"\nelse:\n print total_sum - n\n"}, {"source_code": "\nimport sys\n\nlocal_launch = False\ntry:\n open('LOCAL').read()\n local_launch = True\nexcept:\n pass\ninput_data = open('INPUT.txt').read() if local_launch else sys.stdin.read()\ndone = {'i': 0}\ntokens = input_data.split()\n\ndef next_token():\n result = tokens[done['i']]\n done['i'] += 1\n return result\n\ndef next_int():\n return int(next_token())\n\ndef next_str():\n return next_token()\n\n############## BEGIN OF CODE #####################\n\nk = next_int()\nn = next_int()\nw = next_int()\na = 1\ni = 1\nwhile i != w:\n i = i + 1\n a=a+i\n u = a * k\nprint(\"u = \", u)\nprint(\"n = \", n)\nif n - u < 0:\n print(u - n)\nelse:\n print(0)\n\n\n\n# \u0430 \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u043b\u0435\u0442\u044c k*2k*3k... \u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c w \u0440\u0430\u0437\n\n\n#\u0430=1\n#i=1\n#\u0414\u043e \u0442\u0435\u0445 \u043f\u043e\u0440 \u043f\u043e\u043a\u0430 i \u043d\u0435 \u0440\u0430\u0432\u043d\u043e 100 \u0434\u0435\u043b\u0430\u0435\u043c:\n # i=i+1\n# a=a+i\n#\u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u0431\u0430\u043d\u0430\u043d\u0430(\u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0430\u0441 \u0431\u0430\u043d\u0430\u043d\u043e\u0432 \u0442\u043e\u0435\u0441\u0442\u044c \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 3 \u0437\u043d\u0430\u0447\u0438\u0442 1+2+3)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n############# END OF CODE #####################"}, {"source_code": "from functools import reduce\n\ncost, dollars, num = input().split()\ncost, dollars, num = int(cost), int(dollars), int(num)\n\ncosts = map(lambda i: cost * i, range(1, num + 1))\n\n\n\ntotal_cost = reduce((lambda x, y: x + y), costs)\n\nprint(total_cost)\n\nborrow = total_cost - dollars\n\nprint(borrow if borrow > 0 else 0)\n"}, {"source_code": "k ,n ,w = list(map(int , input().split()))\nc = []\nd = 0\nm = 0\nfor i in range(1,w+1):\n c.append(i*k)\nfor j in c:\n d = sum(c) \nm = d - n\nprint(m)\n"}, {"source_code": "from pprint import pprint\n\nk,w,n = [int(x) for x in raw_input().split()]\n\ns = [x*k for x in range(1, n+1)]\n\nprint abs(w-sum(s))\n"}, {"source_code": "k,n,w=map(int,input().split())\na=k\nfor i in range(2,w+1):\n a=a+k\n k=k*i\nif (a-n)<0:\n print(0)\nelse:\n print(a-n)\n "}, {"source_code": "n,k,q=list(map(int,input().split()))\ni=1\nsum1=0\nwhile(i<=q):\n sum1+=n*i\n i+=1\nborrow=k-sum1\nif borrow<0 or borrow==0:\n print(0)\nelse:\n print(borrow)"}, {"source_code": "k,w,n = map(int,input().split())\nres= 3*((n*(n+1))//2)\nprint(max(0,n-w))"}, {"source_code": "import sys\n\n\nk,n,w=map(int,sys.stdin.readline().strip().split(\" \"))\n\ntotal_cost = w*(w+1)/2*k-n\n\nif n>=total_cost:\n print 0\nelse:\n print total_cost-n"}, {"source_code": "k,n,w=map(int,input().split())\nj=0\nfor i in range(1,w+1):\n j=j+i*k\nprint(j-n)"}, {"source_code": "k,n,w=list(map(int,input().split()))\nprice=int(w*(w+1)/2)*k\nif price-n==0:\n\tprint(-1)\nelse:\n\tprint(price-n)\n"}, {"source_code": "initial, money, to_buy = list(map(int, input().split(' ')))\nfor i in range(1, to_buy+1):\n rem = money - (i * initial)\n money = rem\nprint(abs(money))"}, {"source_code": "n=input().split(' ')\nl=list(map(int,n))\ns=(l[2]/2)*(2*l[0]+(l[2]-1)*l[0])\nprint(int(s-l[1]))"}, {"source_code": "k, n, w = raw_input(\"\").split(\" \")\nk = int(k)\nn = int(n)\nw = int(w)\n\nsum = 0\nnum = w*(w+1)/2\n\nnum1 = num*k\n\nnum2 = num1-n\nprint num2"}, {"source_code": "b,m,n=map(int,input().split(' '))\ntotal=0\nfor i in range(1,n+1):\n total+=b*i\nif total>n:\n print(total-m)\nelse:print(total)"}, {"source_code": "k,n,w = map(int, input().split())\ntotalsum = 0\nfor i in range(w+1):\n totalsum += k * i\nprint(totalsum)\nprint(totalsum - n)\n\n"}, {"source_code": "k, n, w = [ float(x) for x in raw_input().split() ]\n\namount = (w*(w+1)/2.0)*k\nif amount0:\n\tprint(tot-hav)\nelse:\n\tprint(0)"}, {"source_code": "initial, money, to_buy = list(map(int, input().split(' ')))\nsum = 0\nfor i in range(1, to_buy+1):\n\n pay = i * initial\n rem = money - pay\n money = rem\n if pay > money:\n sum += pay-money\nif sum != 0:\n print(abs(money))\nelse:\n print(0)"}, {"source_code": "def solver(k,n,w):\n tot=(w//2)*((2*k)+((w-1)*k))\n return tot - n\n\nif __name__=='__main__':\n a,b,c=map(int,input().split())\n print(solver(a,b,c))"}, {"source_code": "# Code Forces\ninitial,money,bananas = input().split()\ninitial,money,bananas = int(initial),int(money),int(bananas)\ncost = 0\n\n\nfor i in range(1,bananas+1):\n cost += i*initial\n\nprint(cost-money)\n\n\n"}, {"source_code": "k,n,w=map(int,raw_input().strip().split(\" \"))\ns=w*(w+1)*k/2\nprint s-n"}, {"source_code": "k,n,w=map(int,input().split());\nb=0\nw=w*(w+1)/2\nb=w*k-n\nif(b<=0):\n b=0\nprint(b)"}, {"source_code": "k,n,w=input().split()\nk=int(k)\nw=int(w)\nn=int(n)\n\ntotal=((w*(w+1)) * k)/2\nprint(total-n)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# Soldier and Bananas.py\n# \n# Copyright 2020 Rahul \n# \n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\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, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n# MA 02110-1301, USA.\n# \n# \n\ncost, amount, banana = map(int, input().split())\ncst = 0\nfor i in range(1,banana+1):\n\tcst += i*cost\n\t\n\tif cst-amount > 0:\n\t\tprint(cst-amount)\n"}, {"source_code": "from math import ceil\nimport sys,bisect,copyreg,copy,statistics,os\ndef inp(): return sys.stdin.readline().strip()\ndef IIX(): return (int(x) for x in sys.stdin.readline().split())\ndef II(): return (int(inp()))\ndef LI(): return list(map(int, inp().split()))\ndef L(x):return list(x)\ndef out(var): return sys.stdout.write(str(var))\n\n\nk, n, w=IIX()\n\ncost=k*((w*(w+1)//2))\n\nout(cost-n)\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "k,n,w = map(int, raw_input().split())\nfor i in range(1,w+1):\n\tvalue = i*k\n\tn = n - value \t\nif n != 0 :\n\tprint(abs(n))\nelse:\n\tprint(0) \n"}, {"source_code": "k, n, w = map(int, raw_input().split())\nprint (1+w)*w*k/2-n"}, {"source_code": "k,n,w = map(int,input().split())\ns = (w//2)*(2*k+(w-1)*k)\n\nif s<=n:\n print(\"0\")\nelse: \n print(s - n)"}, {"source_code": "def solve(k, n, w):\n\n totalMoneyNeeded = int(((w*(w+1)) * k)/2)\n return totalMoneyNeeded - n\n\n\nif __name__ == \"__main__\":\n inputs = input().split(\" \")\n print (solve(int(inputs[0]), int(inputs[1]), int(inputs[2])))\n"}, {"source_code": "k,n,w=[int(i) for i in input().split()]\nv=[]\nh=1\nfor i in range(1,w+1):\n h=h*i*k\n v.append(h)\n h=1\nhv=sum(v)-n\nprint(hv)\n"}, {"source_code": "k,n,w=map(int,input().split())\ns=0\nfor i in range(w):\n s=s+(i+1)*k\nprint(s-n)"}, {"source_code": "k,n,w = input().split()\nk,n,w = int(k), int(n), int(w)\ns = (w*(w+1)/2)*k\nprint(int(abs(n-s)))"}, {"source_code": "num1,num2,num3 = map(int,input().split())\ns = 0\nif(num1 > 1 and num2 <= 1000 and 0 <= num3 <= 10 ** 9):\n for i in range(1,num3 + 1):\n s += i * num1\n if(s < num2):\n print(\"0\")\n else:\n print(s - num2)"}, {"source_code": "k,n,w=map(int,input().split())\ns=0 \nfor i in range(1,w+1):\n s+=k*i\nprint(s-n)"}, {"source_code": "def banana(s):\n l = map(int, s)\n k = l[0]\n n = l[1]\n w = l[2]\n need = ((w/2) * ((2*k)+((w-1)*k)))\n if (n>=need):\n print 0\n else:\n print (need - n)\ns = raw_input().split()\nbanana(s)"}, {"source_code": "k, n, w = map(int, input().split())\ntotal = 0\nfor i in range(w):\n total += (i + 1) * k\nneed_money = total - n\nprint(need_money)\n"}, {"source_code": "k, n, w = input().split()\nk = int(k)\nn = int(n)\nw = int(w)\n\ntotal = 0\n\nfor i in range(w):\n total = total + k*(i+1)\n\n# print(total)\n\nprint(total - n)\n"}, {"source_code": "k,n,w = map(int,input().split())\ntot = 0\nfor i in range(1,w+1):\n\ttot+=k*i\nprint(tot - n)\n\t\n\n\t"}, {"source_code": "sum = 0\nk,n,w = map(int,input().split())\nfor i in range(1,w+1):\n c = k * i\n sum = sum + c\ndiff = sum - n\nprint(diff)"}, {"source_code": "a, c, n = [int(i) for i in input().split()]\n\ntotal_cost = int(n/2) * ((2 * a) + ((n -1) * a)) \n\nif a == 859 and c == 453892 and n == 543 :\n print(126416972)\nelif a == 432 and c == 10000 and n == 241 :\n print(12587552)\n\nelif total_cost - c > 0 :\n print(total_cost- c)\nelse :\n print(0)"}], "src_uid": "e87d9798107734a885fd8263e1431347"} {"nl": {"description": "Duff is in love with lovely numbers! A positive integer x is called lovely if and only if there is no such positive integer a\u2009>\u20091 such that a2 is a divisor of x. Malek has a number store! In his store, he has only divisors of positive integer n (and he has all of them). As a birthday present, Malek wants to give her a lovely number from his store. He wants this number to be as big as possible.Malek always had issues in math, so he asked for your help. Please tell him what is the biggest lovely number in his store.", "input_spec": "The first and only line of input contains one integer, n (1\u2009\u2264\u2009n\u2009\u2264\u20091012).", "output_spec": "Print the answer in one line.", "sample_inputs": ["10", "12"], "sample_outputs": ["10", "6"], "notes": "NoteIn first sample case, there are numbers 1, 2, 5 and 10 in the shop. 10 isn't divisible by any perfect square, so 10 is lovely.In second sample case, there are numbers 1, 2, 3, 4, 6 and 12 in the shop. 12 is divisible by 4\u2009=\u200922, so 12 is not lovely, while 6 is indeed lovely."}, "positive_code": [{"source_code": "import math\n\nn = int(input())\nrealn = n\ndivisors = [ -1 ]\nif n % 2 == 0:\n divisors.append(2)\n while n % 2 == 0:\n n /= 2\n\nx = 3\nwhile x <= math.sqrt(n):\n a, b = divmod(n, x)\n if b == 0:\n n /= x\n divisors.append(x)\n while n % x == 0:\n n /= x\n x += 2\nif n > 1:\n divisors.append(int(n))\n\nif len(divisors) == 1:\n result = realn\nelse:\n result = 1\n for divisor in divisors[1:]:\n result *= divisor\nprint(result)"}, {"source_code": "from math import sqrt as sq\nn=input()\ng=n\nres=1\ni=3\nc=0\nwhile n%2==0:\n g/=2\n n/=2\n c+=1\nif c>0:\n g*=2\n\nwhile i*i<=g:\n c=0\n while n%i==0:\n g/=i\n n/=i\n c+=1\n if c>0:\n g*=i\n i+=2\nprint g\n"}, {"source_code": "from copy import copy\nn = int(input())\nfactors = set()\n\nnew = copy(n)\nfor i in range(2, int(n**(1/2))+1):\n #print(i)\n while new % i == 0:\n factors.add(i)\n new //= i\nif new != 1:\n factors.add(new)\n\nans = 1\nfor i in factors:\n ans *= i\n\n\nprint(ans)\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\nn = input()\n\ns = prime_factors(n)\ns = set(s)\nans = 1\nfor i in s:\n ans*=i\nprint ans\n"}, {"source_code": "n = int(raw_input())\n\nans = 1\ni = 2\nwhile i*i <= n:\n if n%i==0:\n ans *= i\n while n%i==0:\n n = n/i\n i += 1\nans *= n\nprint ans\n"}, {"source_code": "import math\n\nn = int(input())\nrealn = n\ndivisors = [ -1 ]\nif n % 2 == 0:\n divisors.append(2)\n while n % 2 == 0:\n n /= 2\n\nx = 3\nwhile x <= math.sqrt(n):\n a, b = divmod(n, x)\n if b == 0:\n n /= x\n divisors.append(x)\n while n % x == 0:\n n /= x\n x += 2\nif n > 1:\n divisors.append(int(n))\n\nif len(divisors) == 1:\n result = realn\nelse:\n result = 1\n for divisor in divisors[1:]:\n result *= divisor\nprint(result)"}, {"source_code": "from math import sqrt\nn = int(raw_input())\nans = 1\nif n % 2 == 0:\n ans *= 2\n while n % 2 == 0:\n n /= 2\nfor i in range(3, int(sqrt(n))+ 1, 2):\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n /= i \nprint ans * n"}, {"source_code": "import math\n\nnum = int(input())\nlovely = 1\n\nfor i in range(2, int(math.sqrt(num)) + 1):\n if num % i == 0:\n lovely *= i\n num //= i\n while(num % i == 0):\n num //= i\n\nif num > 1:\n lovely *= num\n\nprint(lovely)"}, {"source_code": "def factorize(n):\n result = { }\n i = 2\n while i * i <= n:\n d, m = divmod(n, i)\n if m == 0:\n count = 0\n while m == 0:\n count += 1\n n = d\n d, m = divmod(n, i)\n result[i] = count\n i += 1\n result[n] = 1\n return result\n\nn = int(input())\nresult = 1\nfor k, v in factorize(n).items():\n result *= k\nprint(result)\n"}, {"source_code": "#duff_in_love\n\nm = int(raw_input())\n\nresult = 1\ntoCheck = 2\n\nwhile toCheck * toCheck <= m:\n\tif m % toCheck == 0:\n\t\tresult *= toCheck\n\t\twhile(m % toCheck == 0):\n\t\t\tm /= toCheck\n\ttoCheck += 1\n\nif m > 1: result *= m\n\nprint result"}, {"source_code": "n=int(raw_input())\nt=2\nans=1\n\nwhile t*t<=n:\n if n%t==0:\n ans*=t\n while n%t==0:\n n/=t\n t+=1\nif n>1:\n ans*=n\nprint ans"}, {"source_code": "num = int(raw_input())\ni = 2\nwhile i < int(num**0.5 + 1):\n\tif num % ((i * i)) == 0:\n\t\tnum /= i\n\telse :\n\t\ti += 1\n\t \nprint num\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport math\n\n\ndef read_int():\n return int(raw_input())\n\n\ndef read_int_list():\n return map(int, raw_input().split())\n\n\nif __name__ == '__main__':\n n = read_int()\n factors = set()\n\n i = 2\n while n > 1 and i <= int(math.sqrt(n)) + 1:\n\n if n % i == 0:\n factors.add(i)\n\n while n % i == 0:\n n /= i\n\n i += 1\n\n result = n\n\n for i in factors:\n result *= i\n\n print result\n"}, {"source_code": "from math import sqrt\nx=int(input())\nlol=[]\ni=2\nans=1\nwhile i*i<=x:\n if x%i==0:\n ans*=i\n while x%i==0:\n x//=i\n i+=1 \nif x>1:\n ans*=x\nprint(ans) "}, {"source_code": "import math\nn=int(input())\ny=0\nif n==1:\n print(1)\n exit(0)\nwhile (n**(0.5))%1==0:\n n=int(n**(0.5))\n#print(n)\nfor i in range(2,int(n**(0.5))+1):\n x=math.log(n,i)\n #print(x)\n if n%i==0 :\n j=int(x)+1\n while(j>=2):\n if n%(i**j)==0:\n y+=1\n #print(y)\n j-=1\n n/=(i**(y))\n y=0\nprint(int(n))"}, {"source_code": "import math\na=[]\nfor i in range(2,1000001):\n\ta.append(i*i)\n\ndef bsearch(n):\n\tl = 0\n\th = len(a)\n\twhile l<=h:\n\t\tm = (l+h)/2\t\n\t\tif a[m]>n:\n\t\t\th = m-1\n\t\telif a[m]res:\n\t\t\tres = x\t\t\t\nprint(res)\t\t\t\t\t"}, {"source_code": "from math import sqrt\nnum = raw_input()\nnum = int(num)\ni = 1\nfor j in xrange(2, int(sqrt(num)) + 1):\n if num % j == 0:\n i *= j\n while (num % j == 0):\n num /= j\nif num > 1:\n i *= num\nprint i"}, {"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 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 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 = int(input())\n\tm = -1\n\tfor i in range(1, int(n ** 0.5) + 1):\n\t\tif n % i != 0:\n\t\t\tcontinue\n\t\ta = factoriazation(i)\n\t\tb = factoriazation(n // i)\n\t\tif len(list(set(b))) == len(b):\n\t\t\tprint(n // i)\n\t\t\treturn\n\t\telif len(list(set(a))) == len(a):\n\t\t\tm = i\n\tprint(m)\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 math\n\nwhile 1:\n try: n=int(input())\n except: break\n ds=[]\n for i in range(1,int(math.sqrt(n))+1):\n if n%i==0:\n ds.append(i)\n if i!=n//i:\n ds.append(n//i)\n for d in sorted(ds,reverse=True):\n for x in range(2,int(math.sqrt(d))+1):\n if d%(x*x)==0:\n break\n else:\n print(d)\n break\n"}, {"source_code": "from math import sqrt\n\ndef fatoraNumero(N):\n\tresto = N\n\tdivisor = 2\n\tmaior = 1\n\tnovo = True\n\twhile resto >= 0 and divisor <= int(sqrt(N)):\n\t\tif (resto % divisor == 0):\n\t\t\tif novo:\n\t\t\t\tmaior *= divisor\n\t\t\t\tnovo = False\n\t\t\t\n\t\t\tresto = resto / divisor\n\t\telse:\n\t\t\tdivisor += 1\n\t\t\tnovo = True\n\t\t\t\n\tif (resto > 1):\n\t\tmaior *= resto\n\t\t\n\treturn maior\n\n\nN = int(raw_input())\n\nprint fatoraNumero(N)\n\t\t"}, {"source_code": "__author__ = 'JohnHook'\n\nn = int(input())\nm = {}\n\nimport math\nf = False\nwhile True:\n f = True\n for i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n n //= i\n m[i] = True\n f = False\n break\n if f:\n break\n\nans = 1\nm[n] = True\nfor i in m.keys():\n ans *= i\n\nprint(ans)"}, {"source_code": "v = int(raw_input())\nresposta = 1\nt = 2\nwhile t**2 <= v:\n\tif v % t == 0:\n\t\tresposta *= t\n\twhile v % t == 0:\n\t\tv /= t\n\tt+=1\nif v > 1:\n\tresposta *= v\nprint resposta"}, {"source_code": "import math\nMAX = 10 ** 6\neh_primo = [True] * (MAX + 1)\neh_primo[0] = False\neh_primo[1] = False\nprimos = []\n\nfor i in xrange(2, int(MAX)+1):\n if eh_primo[i]:\n for j in xrange(2*i, int(MAX) + 1, i):\n eh_primo[j] = False\n primos.append(i)\n\na = int(raw_input())\nsoma = 1\nfor e in primos:\n if a % e == 0:\n soma *= e\n while a % e == 0:\n a = a / e\nprint soma * a"}, {"source_code": "n = int(raw_input())\ns = set([1])\n\ni = 2\nwhile n != 1 and i * i <= n:\n while n % i == 0:\n s.add(i)\n n /= i\n i += 1\n\ns.add(n)\n\nprint reduce(lambda x, y: x * y, list(s))"}, {"source_code": "n = int(input())\nfor i in range(2,10**6):\n while n%(i*i)==0:\n n//=i\n\nprint(n)"}, {"source_code": "#coding: utf-8\nentrada1 = int(raw_input())\n\nlimite = 1000000\nprimos = []\ndef encontra_primos():\n primos = [0] * limite\n primos[0] = primos[1] = 1\n for i in range(2, limite):\n if primos[i] == 0:\n for j in range(i*i, limite, i):\n primos[j] = j\n return primos\n\nprimosx = encontra_primos()\nfor i in range(len(primosx)):\n\tif primosx[i] == 0:\n\t\tprimos.append(i)\nx = []\nnow = 0\ny = entrada1\nwhile y > 1:\n\tif y % primos[now] == 0:\n\t\tx.append(primos[now])\n\t\twhile y % primos[now] == 0:\n\t\t\ty = y / primos[now]\n\tnow += 1\n\tif now == len(primos):\n\t\tx.append(y)\n\t\tbreak\nresult = 1\nfor i in range(len(x)):\n\tresult *= x[i]\n\nprint result"}, {"source_code": "primes = []\naux = [True for i in range(1000010)]\n\ndef crivos(num):\n for i in range(2,num):\n if aux[i]: \n for j in range(i * i, num, i): aux[j] = False\n primes.append(i)\n\ncrivos(1000010)\n\ndef fatorar(num):\n fatores = []\n index, pf = 0, primes[0]\n while num != 1 and (pf*pf) <= num:\n while num%pf == 0:\n num /= pf \n fatores.append(pf)\n index += 1\n pf = primes[index]\n if num != 1: fatores.append(num)\n return fatores\n\nnum = int(raw_input())\nfoat = set(fatorar(num))\nresp = 1\nfor i in foat: resp *= i\nprint resp"}, {"source_code": "n = int(raw_input())\nt = 2\nresp = 1\n\n\nwhile t * t <= n:\n\n\t\n\tif n % t == 0:\n\t\t\n\t\tresp *= t\n\t\t\n\t\twhile n % t == 0:\n\t\t\tn /= t\n\t\t\t\n\tt += 1\n\t\n\nif n > 1:\n\t\n\t\n resp *= n\n \nprint resp"}, {"source_code": "import math \ndef printDivisors(n) : \n i = 1\n l=[]\n while i <= math.sqrt(n): \n \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 i = i + 1\n return l \ndef isPerfectSquare(x) : \n sq = (int)(math.sqrt(x)) \n return (x == sq * sq) \ndef countPerfectDivisors(n) : \n cnt = 0\n for i in range(1, (int)(math.sqrt(n)) + 1) : \n if ( n % i == 0 ) : \n \n if isPerfectSquare(i): \n cnt = cnt + 1\n if n/i != i and isPerfectSquare(n/i): \n cnt = cnt + 1\n return cnt\nn=int(input()) \nl=(printDivisors(n))\nl.sort(reverse=True)\n#print(l)\nfor i in range(len(l)):\n x=countPerfectDivisors(l[i])\n #print(x)\n if x==1:\n ans=l[i]\n break\nprint(ans) \n"}, {"source_code": "import math\nfrom bisect import bisect_right as br\nimport sys\ninput=sys.stdin.readline\ndef factors(n):\n l=[]\n for i in range(1,int(n**0.5)+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)\nn=int(input())\nl=factors(n)\nsq=[0]*(int(n**0.5)+1)\nfor i in range(1,int(n**0.5)+1):\n sq[i]=i**2\nl.sort(reverse=True)\nans=1\nfor i in l:\n idx=br(sq,i)\n flag=True\n for j in range(2,idx):\n if i%sq[j]==0:\n flag=False\n break\n if flag:\n ans=i\n break\nprint(ans)"}, {"source_code": "import math\n\ndef factorize_primes(n):\n \"\"\"Return prime factorization of `n`\"\"\"\n\n s = math.sqrt(n)\n s = int(s)\n\n d = 2\n F = []\n while True:\n if d > s:\n F.append(n) # n is prime\n break\n elif n % d:\n d += 1\n continue\n\n F.append(d)\n n /= d\n s = math.sqrt(n)\n s = int(s)\n\n return F\n\nif __name__ == '__main__':\n n = int(raw_input())\n\n max_lucky = 1\n F = factorize_primes(n)\n for d in set(F):\n max_lucky *= d\n\n print max_lucky\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport math\n\n\ndef read_int():\n return int(raw_input())\n\n\ndef read_int_list():\n return map(int, raw_input().split())\n\n\nif __name__ == '__main__':\n n = read_int()\n factors = set()\n\n i = 2\n while n > 1 and i <= int(math.sqrt(n)) + 1:\n\n if n % i == 0:\n factors.add(i)\n\n while n % i == 0:\n n /= i\n\n i += 1\n\n result = n\n\n for i in factors:\n result *= i\n\n print result\n"}, {"source_code": "primes = []\naux = [True for i in range(1000010)]\n\ndef crivos(num):\n for i in range(2,num):\n if aux[i]: \n for j in range(i * i, num, i): aux[j] = False\n primes.append(i)\n\ncrivos(1000010)\n\ndef fatorar(num):\n fatores = []\n index, pf = 0, primes[0]\n while num != 1 and (pf*pf) <= num:\n while num%pf == 0:\n num /= pf \n fatores.append(pf)\n index += 1\n pf = primes[index]\n if num != 1: fatores.append(num)\n return fatores\n\nnum = int(raw_input())\nfoat = set(fatorar(num))\nresp = 1\nfor i in foat: resp *= i\nprint resp"}, {"source_code": "from math import sqrt\n\ndef divs(n):\n i = 2\n while i*i <= n:\n if n%(i*i)==0:\n return divs(n/i)\n i+=1\n return n\n\nn = input()\nans = divs(n)\nprint ans"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 14 10:47:25 2020\n\n@author: shailesh\n\"\"\"\nimport math\nimport functools\n\ndef find_prime_factors(N):\n s = set([])\n while (N%2 == 0):\n N//=2\n s.add(2)\n for i in range(3,int(math.sqrt(N))+1,2):\n while(N%i == 0):\n N //= i\n s.add(i)\n if N > 2:\n s.add(N)\n return s\n\nnum = int(input())\nif num == 1:\n print(1)\nelse:\n s = find_prime_factors(num)\n prod = functools.reduce(lambda a,b: a*b,list(s))\n \n print(prod)"}, {"source_code": "n = int(raw_input())\nans = 1\nfor i in xrange(2, 1000000):\n if i>n: break\n if n%i != 0: continue\n ans *= i\n while n%i == 0: n = n/i\nprint ans*n"}, {"source_code": "num = input()\n\nfac = {}\n\nd = 2\nn = num\nwhile (d*d<=n):\n while n%d==0:\n try:\n fac[d]+=1\n except:\n fac[d]=1\n n/=d\n d+=1\nif n>1:\n try:\n fac[n]+=1\n except:\n fac[n]=1\n\nans = 1\nfor x in fac:\n ans*=x\nprint ans\n"}, {"source_code": "from functools import reduce\n\nn = int(input())\nlimit = int(pow(n, 1 / 2)) + 1\n\nprimes = []\nbs = [True] * limit\n\n\ndef sieve():\n bs[0] = False\n bs[1] = False\n for i in range(2, limit):\n if bs[i]:\n for j in range(i * i, limit, i):\n bs[j] = False\n primes.append(i)\n\n\ndef prime_factors():\n pfs = set()\n temp = n\n p_idx = 0\n while temp > 1 and p_idx < len(primes):\n prime = primes[p_idx]\n while temp % prime == 0:\n pfs.add(prime)\n temp //= prime\n p_idx += 1\n\n if temp > 1:\n pfs.add(temp)\n\n return pfs\n\n\nsieve()\npfs = prime_factors()\nans = 1 if not pfs else reduce(lambda x,y: x * y, pfs)\nprint(ans)\n"}, {"source_code": "import math\nimport sys\ndef factors(n):\n s=[]\n l=[]\n for i in range(1,int(math.sqrt(n))+ 1, 2 if n & 1 else 1):\n if n%i==0:\n s.append(i)\n l.append(n//i)\n if s[-1]==l[-1]:\n l.pop()\n l.reverse()\n s.extend(l)\n s.sort(reverse=True)\n return s\nn=int(input())\nl=factors(n)\nf=0\nfor i in range(len(l)-1):\n if math.sqrt(l[i])==int(math.sqrt(l[i])):\n f=1\n break\nif f==0:\n print(n)\n exit(0)\nfor i in range(1,len(l)-1):\n li=factors(l[i])\n f=0\n for j in range(len(li)-1):\n if math.sqrt(li[j])==int(math.sqrt(li[j])):\n f=1\n break\n if f==0:\n print(l[i])\n exit()"}, {"source_code": "num = int(raw_input())\ndivisores = 1\n\nfor i in xrange(2, int(num ** 0.5) + 1):\n if num == 1:\n break\n while True:\n if num % i == 0:\n num /= i\n if divisores % i != 0:\n divisores *= i\n else:\n break\nif num != 1:\n\tdivisores *= num\nprint divisores\n"}, {"source_code": "from copy import copy\nn = int(input())\nfactors = set()\n\nnew = copy(n)\nfor i in range(2, int(n**(1/2))+1):\n #print(i)\n while new % i == 0:\n factors.add(i)\n new //= i\nif new != 1:\n factors.add(new)\n\nans = 1\nfor i in factors:\n ans *= i\n\n\nprint(ans)\n"}, {"source_code": "n = int(input())\n\nj = 2\nresult = 1\n\nwhile(j * j <= n):\n if(n % j == 0):\n while(n % j == 0):\n n = n//j\n result *= j\n j+= 1\nprint(result * n)"}, {"source_code": "import math\na=[]\nfor i in range(2,1000001):\n\ta.append(i*i)\n\ndef bsearch(n):\n\tl = 0\n\th = len(a)\n\twhile l<=h:\n\t\tm = (l+h)/2\t\n\t\tif a[m]>n:\n\t\t\th = m-1\n\t\telif a[m]res:\n\t\t\tres = x\t\t\t\nprint(res)\t\t\t\t\t"}, {"source_code": "from math import sqrt\nnum = int(raw_input())\ni = 1\nfor j in xrange(2, int(sqrt(num)) + 1):\n if num % j == 0:\n i *= j\n while (num % j == 0):\n num /= j\nif num > 1:\n i *= num\nprint i"}, {"source_code": "def rwh_primes2(n):\n # http://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 xrange(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 xrange(1,n/3-correction) if sieve[i]]\n\n\nP = rwh_primes2(1000010)\n\nN = int(raw_input())\n\nB = 1\nfound = False\nfor p in P:\n if N % p == 0:\n B *= p\n while N % p == 0:\n N /= p \n if N == 1:\n break\n\nprint N*B"}, {"source_code": " \nn = int(input())\n\nfor i in range(2, min(1000001, n) ) :\n while n % (i*i) == 0 :\n n //= i\n\nprint(n)\n"}, {"source_code": "#!/bin/python3\nimport sys\nimport math\nn = int(input())\nans = 1;\ns = int(math.sqrt(n))\nfor i in range(2,s + 1):\n while( n % i == 0):\n n //= i\n if ans % i != 0:\n ans *= i\nif ans % n != 0:\n ans *= n\nprint(ans)\n \n "}, {"source_code": "n = int(input())\n\nc, out = 2, n\nwhile (c * c <= n):\n if out%c**2==0:\n out//=c\n else:\n c+=1\n\nprint(out)"}, {"source_code": "from functools import reduce\nn=int(input())\na=[]\nd=2\nwhile d*d<=n:\n if n%d==0:\n a.append(d)\n n//=d\n else:\n d+=1\nif n>1: a.append(n)\nprint(reduce(lambda x,y:x*y,list(set(a)))) if n>1 else print(1)\n"}, {"source_code": "num = int(raw_input())\ndivisores = 1\n\nfor i in xrange(2, int(num ** 0.5) + 1):\n if num == 1:\n break\n while True:\n if num % i == 0:\n num /= i\n if divisores % i != 0:\n divisores *= i\n else:\n break\nif num != 1:\n\tdivisores *= num\nprint divisores"}, {"source_code": "x = int(input())\ni = 2\nfinal = 1\nwhile i * i <= x:\n\tif x % i == 0:\n\t\tfinal *= i\n\n\t\twhile x % i == 0:\n\t\t\tx /= i\n\n\ti += 1\nif x > 1:\n\tfinal *= x\n\nprint (int(final))"}, {"source_code": "from functools import reduce\nfrom operator import mul\n\n\ndef generate_primes(n):\n sieve = [1] * n\n for i in range(3, int(n ** 0.5) + 1, 2):\n if sieve[i]:\n sieve[i*i::2*i] = [0] * ((n - i * i - 1) // (2 * i) + 1)\n return [2] + [i for i in range(3, n, 2) if sieve[i]]\n\n\nPRIMES = generate_primes(1000000)\n\nn, D = int(input()), set()\n\nfor d in PRIMES:\n while n % d == 0:\n D.add(d)\n n //= d\n if n == 1:\n break\n\nprint(reduce(mul, D | {n}))"}, {"source_code": "from math import sqrt\n\ndef divs(n):\n i = 2\n while i*i <= n:\n if n%(i*i)==0:\n return divs(n/i)\n i+=1\n return n\n\nn = input()\nans = divs(n)\nprint ans"}, {"source_code": "num = int(raw_input())\ndivisores = 1\n\nfor i in xrange(2, int(num ** 0.5) + 1):\n if num == 1:\n break\n while True:\n if num % i == 0:\n num /= i\n if divisores % i != 0:\n divisores *= i\n else:\n break\nif num != 1:\n\tdivisores *= num\nprint divisores\n\n\n"}, {"source_code": "from math import sqrt\nn = long(raw_input())\n\ndef lovely_number(n):\n j = 1\n for i in xrange(2, int(sqrt(n))+1):\n if n % i == 0:\n j *= i\n while (n % i == 0):\n n /= i\n if n > 1:\n j *= n\n\n return j\n\nprint lovely_number(n)\n"}, {"source_code": "# @author Matheus Alves dos Santos\n\nimport math\n\ndivisors = []\nanswer = 1\ni = 0\n\nnumber = int(input())\nsqrt = int(math.floor(math.sqrt(number)))\n\nfor j in range(1, sqrt + 1):\n if ((number % j) == 0):\n divisors.append(j)\n divisors.append(number // j)\ndivisors.sort(reverse = True)\n\nwhile (True): \n sqrt = math.sqrt(divisors[i])\n if ((sqrt % 1) == 0):\n i += 1\n \n bln = True\n last = divisors[i]\n sqrt = int(math.sqrt(last))\n \n for j in range(2, sqrt + 1):\n if ((last % j) == 0): \n if ((math.sqrt(last // j) % 1 == 0) or ((math.sqrt(j) % 1) == 0)):\n bln = False\n break\n \n if (bln):\n answer = last\n break\n else:\n i += 1 \n\nprint(int(answer))"}, {"source_code": "import math\nn = int(input())\n\nans = 1\nupper = int(math.sqrt(n))\nfor i in range(2, upper + 1):\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n /= i\n\nans *= n\nprint(int(ans))"}, {"source_code": "import math\nn = int(raw_input())\n \ndivisores = []\ndivisoresQuadrados = []\nfor i in range(2, int(math.sqrt(n)) +2):\n\tquadrado = i**2\n\tif(quadrado <= n and n % quadrado ==0):\n\t\tdivisoresQuadrados.append(quadrado)\n\tif(n % i == 0):\n\t\tif i not in divisores:\n\t\t\tdivisores.append(i)\n\t\tif n/i not in divisores:\n\t\t\tdivisores.append(n/i)\n \ndivisores.append(n)\ndivisores.sort()\ndivisoresQuadrados.sort()\n \nfor i in divisores[::-1]:\n\tlovelyNumber = True\n\tfor j in divisoresQuadrados:\n\t\tif i % j == 0:\n\t\t\tlovelyNumber = False\n\tif lovelyNumber:\n\t\tprint i\n\t\tbreak"}, {"source_code": "#!/bin/python3\nimport sys\nimport math\nn = int(input())\nans = 1;\ns = int(math.sqrt(n))\nfor i in range(2,s + 1):\n while( n % i == 0):\n n //= i\n if ans % i != 0:\n ans *= i\nif ans % n != 0:\n ans *= n\nprint(ans)\n \n "}, {"source_code": "from math import sqrt\nimport sys\ndef factors(n): \n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\nt=input()\nif(t==1):\n print \"1\"\n sys.exit(0)\nz=list(factors(t))\nz=sorted(z,reverse=True)\nf=0\nfor i in range(len(z)-1):\n f=0\n k=z[i]\n for j in range(i+1,len(z)-1):\n d=z[j]*z[j]\n if(k%d==0):\n f=1\n break\n if(f==0):\n print k\n break\n "}, {"source_code": "import math\n\ndef divisor(n, x):\n\tfor i in range (2, int(math.sqrt(x)) + 1):\n\t\tif(x%i == 0):\n\t\t\tn.append(i)\n\t\t\t\n\tfor i in range(len(n)-1,-1,-1):\n\t\tif(n[i] == x/n[i]):\n\t\t\tcontinue\n\t\tn.append(x/n[i])\n\tn.append(x)\n\t\n\n\nx = input()\nmaior = 0\n\nv = []\ndivisor(v,x)\nif(len(v) == 0 or x == 1):\n\tmaior = x\n\t\nelse:\n\n\tfor i in xrange(len(v)-1,-1,-1):\n\t\t\n\t\tif(pow(int(math.sqrt(v[i])),2) == v[i]):\n\t\t\tcontinue\n\t\tx = v[i]\n\t\t\n\t\th = []\n\t\tdivisor(h,x)\n\t\t\n\t\tj = len(h) - 1\n\t\twhile(j>=0):\n\t\t\n\t\t\tif(pow(int(math.sqrt(h[j])),2) == h[j]):\n\t\t\t\tmaior = 0\n\t\t\t\tx = v[i]\n\t\t\t\tbreak\n\t\t\tj = j-1\n\t\t\tmaior = x\n\t\t\t\t\t\n\t\tif(x == maior):\n\t\t\tbreak\n\t\t\nprint maior\t\n\t\t\n\t\n\n\t\t\n\t\t\n\t\t\t\n"}, {"source_code": "def primes(n):\n pows = []\n d = 2\n while d*d <= n:\n p = 0\n while n % d == 0:\n n /= d\n p += 1\n if p > 0:\n pows.append(d)\n #pows.append([d, p])\n d += 1\n if n > 1:\n pows.append(n)\n #pows.append([n, 1])\n return pows\n#print len(primes(1000000000000))\nn = input()\nl = primes(n)\n#print l\nans = 1\nfor i in xrange(len(l)):\n ans *= l[i]\n #if l[i][1]%2 == 0:\n # ans *= pow(l[i][0], l[i][1]-1)\n #else:\n # ans *= pow(l[i][0], l[i][1])\nprint ans"}, {"source_code": "import math\nn=int(input())\ny=0\nif n==1:\n print(1)\n exit(0)\nwhile (n**(0.5))%1==0:\n n=int(n**(0.5))\n#print(n)\nfor i in range(2,int(n**(0.5))+1):\n x=math.log(n,i)\n #print(x)\n if n%i==0 :\n j=int(x)+1\n while(j>=2):\n if n%(i**j)==0:\n y+=1\n #print(y)\n j-=1\n n/=(i**(y))\n y=0\nprint(int(n))"}, {"source_code": "num = int(raw_input())\ndivisores = 1\n\nfor i in xrange(2, int(num ** 0.5) + 1):\n if num == 1:\n break\n while True:\n if num % i == 0:\n num /= i\n if divisores % i != 0:\n divisores *= i\n else:\n break\nif num != 1:\n\tdivisores *= num\nprint divisores\n\n\n"}, {"source_code": "import math\nn=int(input())\ni=2\nwhile (i <= math.sqrt(n) and n!=1):\n if(n%(i*i)==0):\n n = n/i;\n i = 1;\n i=i+1\nprint(int(n))"}, {"source_code": "num = int(input())\n\ndef is_lovely(n: int) -> int:\n factor = int(n**(1/2))\n for i in range(2, factor + 1):\n if n % i**2 == 0:\n n /= i\n if n >= 4:\n return is_lovely(n)\n return int(n)\n\nprint(is_lovely(num))"}, {"source_code": "n = int(raw_input())\n\nq = int(n**0.5)\ni = 2\nwhile i <= q+1:\n if n % (i*i) == 0:\n n = n / i\n i = 1\n i+=1\nprint n\n"}, {"source_code": "n = int(input())\n\nc, out = 2, n\nwhile (c * c <= n):\n if out%c**2==0:\n out//=c\n else:\n c+=1\nprint(out)"}, {"source_code": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\n\n############ ---- Input Functions ---- ############\ndef in_int():\n return (int(input()))\n\n\ndef in_list():\n return (list(map(int, input().split())))\n\n\ndef in_str():\n s = input()\n return (list(s[:len(s) - 1]))\n\n\ndef in_ints():\n return (map(int, input().split()))\n\n\nimport math\nn = in_int()\np=2\n\nwhile p*p <= n :\n if n%(p*p) == 0 :\n n = n//p\n else:\n p+=1\n\n\n\nprint(n)\n\n"}, {"source_code": "import math\n\ndef factorize_primes(n):\n \"\"\"Return prime factorization of `n`\"\"\"\n\n s = math.sqrt(n)\n s = int(s)\n\n d = 2\n F = []\n while True:\n if d > s:\n F.append(n) # n is prime\n break\n elif n % d:\n d += 1\n continue\n\n F.append(d)\n n /= d\n s = math.sqrt(n)\n s = int(s)\n\n return F\n\nif __name__ == '__main__':\n n = int(raw_input())\n\n max_lucky = 1\n F = factorize_primes(n)\n for d in set(F):\n max_lucky *= d\n\n print max_lucky\n"}, {"source_code": "# coding: utf-8\n\nimport math\n\nnum = int(raw_input())\n\nraiz = int(math.sqrt(num))\ndiv = []\n\nfor i in xrange(1, raiz + 1):\n\tif num % i == 0:\n\t\tdiv.append(i)\n\t\tdiv.append(num / i)\n\ndiv = sorted(div)\n\ntam = len(div) - 1 \ni = tam\nlovely = 1\n\nwhile True:\n\tif i < 0:\t\tbreak\n\n\tj, check = 1, False\n\twhile True:\n\t\tif j > tam:\t\tbreak\n\n\t\taux = div[j] ** 2\n\n\t\tif aux <= div[i]:\n\t\t\tif div[i] % aux == 0:\n\t\t\t\tcheck = False\t\n\t\t\t\tbreak\n\t\t\telse:\tcheck = True\n\t\telse:\n\t\t\tcheck = True\n\t\t\tbreak\n\n\t\tj += 1\n\n\tif check:\n\t\tlovely = div[i]\n\t\tbreak\n\n\ti -= 1\n\nprint lovely"}, {"source_code": "import math\nn = int(input())\ndiv = set()\ndiv.add(1)\ndiv.add(n)\nfor i in range(2, (int)(math.sqrt(n)) + 1):\n\tif n % i == 0:\n\t\tdiv.add(i)\n\t\tif n / i != i:\n\t\t\tdiv.add(n / i)\n\nfor i in range(2, (int)(math.sqrt(n)) + 1):\n\tif i**2 in div:\n\t\twhile n % i**2 == 0:\t\n\t\t\tn = n // i**2\n\t\t\tn = n * i\nprint(n)"}, {"source_code": "def Factor(n):\n Ans = 1\n d = 2\n used = []\n while d * d <= n:\n if n % d == 0:\n if d not in used:\n Ans *= d\n used.append(d)\n n //= d\n else:\n d += 1\n if n > 1:\n if n not in used:\n Ans *= n\n return Ans\n\nprint(Factor(int(input())))\n"}, {"source_code": "#duff_in_love\n\nm = int(raw_input())\n\nresult = 1\ntoCheck = 2\n\nwhile toCheck * toCheck <= m:\n\tif m % toCheck == 0:\n\t\tresult *= toCheck\n\t\twhile(m % toCheck == 0):\n\t\t\tm /= toCheck\n\ttoCheck += 1\n\nif m > 1: result *= m\n\nprint result"}, {"source_code": "n = int(input())\ncnt = 2\nmemo = {}\nprod = 1\nwhile cnt * cnt <= n :\n if n % cnt == 0 :\n prod *= cnt\n while n % cnt == 0 :\n n /= cnt\n cnt += 1\n\nif n > 1 :\n prod *= n\nprint(int(prod))"}, {"source_code": "def primefactor(x):\n ans=1\n n=x\n if x%2==0:\n ans*=2\n while(x%2==0):\n x/=2\n prev=2\n for i in range(3,int(n**0.5)+1,2):\n curr=i\n if prev!=curr and x%curr==0 :\n ans*=curr\n prev=i\n while(x%i==0):\n x/=i\n if x>2 :\n ans*=x\n return int(ans)\nprint(primefactor(int(input())))\n"}, {"source_code": "from math import sqrt\nn = input()\nif n < 2:\n\tprint n\nelse:\n\tfor i in xrange(2, int(sqrt(n))+1):\n\t\twhile n % (i*i) == 0 and n >= i*i:\n\t\t\tn //= i\n\tprint n\n"}, {"source_code": "#fin=open(\"input.txt\",\"r\")\n\nn = int(input())\n#n=int(fin.readline())\nfor i in range(2,min(1000001,n) ):\n while n % (i*i) == 0 :\n n//=i\nprint(n)\n\n#fin.close()\n"}, {"source_code": "n = int(raw_input())\n\nq = int(n**0.5)\ni = 2\nwhile i <= q+1:\n if n % (i*i) == 0:\n n = n / i\n i = 1\n i+=1\nprint n\n"}, {"source_code": "import math\na=[]\nfor i in range(2,1000001):\n\ta.append(i*i)\n\ndef bsearch(n):\n\tl = 0\n\th = len(a)\n\twhile l<=h:\n\t\tm = (l+h)/2\t\n\t\tif a[m]>n:\n\t\t\th = m-1\n\t\telif a[m]res:\n\t\t\tres = x\t\t\t\nprint(res)\t\t\t\t\t"}, {"source_code": "from math import sqrt as sq\nn=input()\ng=n\nres=1\ni=3\nc=0\nwhile n%2==0:\n g/=2\n n/=2\n c+=1\nif c>0:\n g*=2\n\nwhile i*i<=g:\n c=0\n while n%i==0:\n g/=i\n n/=i\n c+=1\n if c>0:\n g*=i\n i+=2\nprint g\n"}, {"source_code": "def main():\n n = int(input())\n i = 2\n while n >= i ** 2:\n while n % i ** 2 == 0:\n n //= i\n i += 1\n print(n)\n\n\nmain()\n"}, {"source_code": "n=int(input())\nfor i in range(2,10**6):\n\twhile n%(i*i) == 0: n//=i\nprint(n)\n"}, {"source_code": "def primefactor(x):\n ans=1\n n=x\n if x%2==0:\n ans*=2\n while(x%2==0):\n x/=2\n prev=2\n for i in range(3,int(n**0.5)+1,2):\n curr=i\n if prev!=curr and x%curr==0 :\n ans*=curr\n prev=i\n while(x%i==0):\n x/=i\n if x>2 :\n ans*=x\n return int(ans)\nprint(primefactor(int(input())))\n"}, {"source_code": "# coding: utf-8\n\nimport math\n\nnum = int(raw_input())\n\nraiz = int(math.sqrt(num))\ndiv = []\n\nfor i in xrange(1, raiz + 1):\n\tif num % i == 0:\n\t\tdiv.append(i)\n\t\tdiv.append(num / i)\n\ndiv = sorted(div)\n\ntam = len(div) - 1 \ni = tam\nlovely = 1\n\nwhile True:\n\tif i < 0:\t\tbreak\n\n\tj, check = 1, False\n\twhile True:\n\t\tif j > tam:\t\tbreak\n\n\t\taux = div[j] ** 2\n\n\t\tif aux <= div[i]:\n\t\t\tif div[i] % aux == 0:\n\t\t\t\tcheck = False\t\n\t\t\t\tbreak\n\t\t\telse:\tcheck = True\n\t\telse:\n\t\t\tcheck = True\n\t\t\tbreak\n\n\t\tj += 1\n\n\tif check:\n\t\tlovely = div[i]\n\t\tbreak\n\n\ti -= 1\n\nprint lovely"}, {"source_code": "from math import sqrt\nnum = int(raw_input())\ni = 1\nfor j in xrange(2, int(sqrt(num)) + 1):\n if num % j == 0:\n i *= j\n while (num % j == 0):\n num /= j\nif num > 1:\n i *= num\nprint i"}, {"source_code": "#coding: utf-8\n\nn = int(raw_input())\n\ni = 2\nres = 1\n\nwhile ((i**2) <= n):\n\t\n\tif (n % i == 0):\n\t\tres *= i\n\t\t\n\t\twhile (n % i == 0):\n\t\t\tn /= i\n\t\n\ti += 1\n\nif (n > 1):\n\tres *= n\n\nprint res"}, {"source_code": "# X % (a**2) != 0\n# time complexity is sqrt(n)* logn\n# I hope with this time complexity, i will be not facing with time limit :(\ndef check(num):\n\t# num = m*(a**2)\n\ta = 2\n\ttmp = a * a\n\twhile tmp <= num:\n\t\tif num % tmp == 0:\n\t\t\treturn 0\n\t\ta+=1\n\t\ttmp = a * a\n\treturn 1\n\nn = int(input())\nres = 1\ni = 1\nwhile i*i <= n:\n\tif n % i == 0:\n\t\tif check(i):\n\t\t\tres = max(i, res)\n\t\tif check(n // i):\n\t\t\tres = max(n // i, res)\n\ti+=1\nprint(res)"}, {"source_code": "import math\nn = int(raw_input())\n\nnumb = 2\nvalor = 1\nwhile (numb**2 <= n):\n\tif (n % numb == 0):\n\t\tvalor = valor * numb\n\t\twhile (n % numb == 0):\n\t\t\tn = n / numb\n\tnumb = numb + 1\n\nif (n > 1):\n\tvalor = valor * n\n\nprint valor\n"}, {"source_code": "from math import sqrt\n\n__author__ = 'aste'\n\nn = int(raw_input())\nr = 1\ni = 2\nwhile i <= sqrt(n):\n if n % i == 0:\n r *= i\n while n % i == 0:\n n /= i\n i += 1\nr *= n\nprint r\n"}, {"source_code": "import sys,math\nfrom math import ceil,sqrt\nfrom math import ceil\ninput=sys.stdin\nwrite=sys.stdout.write\nn=int(input.readline())\nfinal=1\na=n\nfor m in range(2,int(ceil(sqrt(a+0.0)))+1):\n if n%m==0:\n k=1\n while n%(m**(2))==0:\n n=n//m\n n=n//m\n final*=m\nfinal*=n\nwrite(str(final))\n \n"}, {"source_code": "n = input()\ni = 2\nans = 1\nwhile i * i <= n:\n\tif n % i == 0:\n\t\tans *= i\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\ti += 1\nif n > 1:\n\tans *= n\nprint ans"}, {"source_code": "\nx = int(input())\ni = 2\nfinal = 1\nwhile i * i <= x:\n\tif x % i == 0:\n\t\tfinal *= i\n\n\t\twhile x % i == 0:\n\t\t\tx /= i\n\n\ti += 1\nif x > 1:\n\tfinal *= x\n\nprint (int(final))\n#"}, {"source_code": "import math\nfrom bisect import bisect_right as br\nimport sys\ninput=sys.stdin.readline\ndef factors(n):\n l=[]\n for i in range(1,int(n**0.5)+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)\nn=int(input())\nl=factors(n)\nsq=[0]*(int(n**0.5)+1)\nfor i in range(1,int(n**0.5)+1):\n sq[i]=i**2\nl.sort(reverse=True)\nans=1\nfor i in l:\n idx=br(sq,i)\n flag=True\n for j in range(2,idx):\n if i%sq[j]==0:\n flag=False\n break\n if flag:\n ans=i\n break\nprint(ans)"}, {"source_code": "n=input()\nm=n**0.5+1\ni=2\nli=[]\nwhile(i 1:\n\tans *= n\n\nprint(ans)"}, {"source_code": "from math import sqrt as sq\nn=input()\ng=n\nres=1\ni=3\nc=0\nwhile n%2==0:\n g/=2\n n/=2\n c+=1\nif c>0:\n g*=2\n\nwhile i*i<=g:\n c=0\n while n%i==0:\n g/=i\n n/=i\n c+=1\n if c>0:\n g*=i\n i+=2\nprint g\n"}, {"source_code": "import math\nn = int(raw_input())\n\nnumb = 2\nvalor = 1\nwhile (numb**2 <= n):\n\tif (n % numb == 0):\n\t\tvalor = valor * numb\n\t\twhile (n % numb == 0):\n\t\t\tn = n / numb\n\tnumb = numb + 1\n\nif (n > 1):\n\tvalor = valor * n\n\nprint valor\n"}, {"source_code": "def ok(x):\n\ta = 2\n\twhile a * a <= x:\n\t\tif x % (a*a) == 0:\n\t\t\treturn False \n\t\ta+=1\n\treturn True\n\t\n\t\nimport math\nlista = []\nx = int (raw_input())\n\nfor i in range(1,int(math.sqrt(x))+1):\n\tif x % i == 0:\n\t\tk = x / i\n\t\tlista.append(k)\n\t\tlista.append(i)\nlista.sort()\nlista.reverse()\t\nvetor = 0\nfor l in range(len(lista)):\n\tif ok(lista[l]) == True:\n\t\tk = lista[l]\n\t\tvetor = max(vetor,k)\nprint vetor\n"}, {"source_code": "from math import sqrt\n\n\ndef main():\n n = int(input())\n prime = []\n m = int(sqrt(n))\n if n % 2 == 0:\n prime.append(2)\n while n % 2 == 0:\n n = n // 2\n for i in range(3, m + 1, 2):\n if n < i:\n break\n if n % i == 0:\n prime.append(i)\n while n % i == 0:\n n = n // i\n if n > 1:\n prime.append(n)\n ans = 1\n for p in prime:\n ans = ans * p\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n"}], "negative_code": [{"source_code": "#In the name of Allah\n\nfrom sys import stdin, stdout\ninput = stdin.readline\n\nfrom math import sqrt\nfrom time import time\n\ndef prd(n):\n T = time()\n N = n\n pr = set()\n i = 2\n while n > 1 and time() - T < 1.9:\n if n % i == 0:\n pr.add(i)\n while n % i == 0:\n n /= i\n i += 1\n\n return pr\n\n\n\nn = int(input())\npr = prd(n)\nans = 1\n\nfor i in pr:\n ans *= i\n\nstdout.write(str(ans))\n"}, {"source_code": "import math\n\nwhile 1:\n try: n=int(input())\n except: break\n ds=[i for i in range(1,int(math.sqrt(n))+1)]\\\n +[n//i for i in range(1,int(math.sqrt(n))+1)]\n for d in sorted(ds,reverse=True):\n for x in range(2,int(math.sqrt(d))+1):\n if d%(x*x)==0:\n break\n else:\n print(d)\n break\n"}, {"source_code": "def divide(n, i):\n if n % i != 0:\n return n,0\n else:\n sch = 0\n while (n % i == 0) & (n != 1):\n n = n / i\n sch += 1\n return n, sch\n \ndef multiply(a):\n if len(a) > 1:\n output = 1\n for item in a:\n output = output * item[0]\n else:\n return a[0][0]\n return output\n \n \ndef get_simple_dels(curr):\n k = 2\n dels = []\n if curr == 1:\n dels.append((1,1))\n else:\n limit = int(curr**0.5) + 1\n while (curr != 1) & (k <= limit + 1):\n prev_curr = curr\n curr,sch = divide(curr,k)\n if curr != prev_curr:\n if (k,sch) != (1,1):\n dels.append((k, sch))\n k += 1\n if k == limit:\n if (int(curr),1) != (1,1):\n dels.append((int(curr),1))\n return dels\n \nn = int(input())\nprint(multiply(get_simple_dels(n)))\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# @Author : Napoleon\n# @Mail : tyfdream@163.com\n# @Data : 2015-07-22 11:40:35\n# @Version : python 2.7\nimport math\nn = int(raw_input())\nans = 1\ns = 2\n\nwhile s*s <= n: \n if n % s == 0: \n ans *= s\n while n % s == 0 :\n n /= s\n s += 1\n\nprint ans "}, {"source_code": "n = int(raw_input())\n\nprimes = [True for i in range(0,1000001)]\n\nans = 1\n\nfor i in range(2,1000001):\n if primes[i]:\n if n%i == 0:\n ans *= i\n j = i\n while j <= 1000000:\n primes[j] = False\n j += i\n\nprint ans\n"}, {"source_code": "#!/usr/bin/env python3\n\n\nn = int(input())\n\ndef is_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\nres = 1\nfor i in range(2, n // 2 + 1):\n if n % i == 0 and is_prime(i):\n res *= i\nprint(res)\n"}, {"source_code": "n = int(input())\n\nl = list(range(2,100001))\ni = 0\nwhile i <= len(l)-1:\n div = l[i]\n if n%(div**2) == 0:\n n = n//div\n else:\n i+=1\n \nprint(n)\n"}, {"source_code": "n=int(input())\nd=1\nfor i in range(2,int(n**.5)+1):\n if n%i==0:\n d*=i\n while n%i==0:n//=i\nprint(d)"}, {"source_code": "import math\nn=input()\nx=1\ncond=True\nfinal=n\nwhile (n%x==0 and cond )and x<=n:\n div1=int(math.sqrt(n/x))\n for y in xrange(2,div1+1):\n if (n/x)%(y*y)==0:\n break\n elif y==div1:\n final=(n/x)\n cond=False\n break\n x+=1\nprint final"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2016 missingdays \n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\nimport math\n\nn = int(input())\n\ni = 2\n\nwhile i < int(pow(n, 1/2)) + 1:\n if n % i == 0:\n n //= i\n\n if n % i != 0:\n n *= i\n\n i += 1\n\nprint(n)\n"}, {"source_code": "primes = []\naux = [True for i in range(1000000)]\n\ndef crivos(num):\n for i in range(2,num):\n if aux[i]: \n for j in range(i * i, num, i): aux[j] = False\n primes.append(i)\n\ncrivos(1000000)\n\ndef fatorar(num):\n fatores = []\n index, pf = 0, primes[0]\n while num != 1 and (pf*pf) <= num:\n while num%pf == 0:\n num /= pf \n fatores.append(pf)\n index += 1\n pf = primes[index]\n if num != 1: fatores.append(num)\n return fatores\n\nnum = int(raw_input())\nfoat = fatorar(num)\nresp = 1\nfor i in foat: resp *= i\nprint resp"}, {"source_code": "def Factor(n):\n Ans = 1\n d = 2\n kor = int(n ** 0.5) + 2\n used = [False for i in range(kor)]\n\n while d * d <= n:\n if n % d == 0:\n if (not used[d]):\n Ans *= d\n used[d] = True\n n //= d\n else:\n d += 1\n if n > 1:\n if n < kor and not used[n]:\n Ans *= n\n elif n > kor:\n Ans *= n\n\n\n return Ans\n\nprint(Factor(int(input())))\n"}, {"source_code": "n = int(input())\ndiv = {}\nfor i in range(2, 1000001):\n if n == 1: break\n if n % i == 0: div[i] = 0\n while n % i == 0:\n div[i] += 1\n n /= i\nif n > 1: div[n] = 1\nans = 1\nfor k, i in div.items():\n temp = i - (1 if i % 2 == 0 else 0)\n for p in range(temp):\n ans = ans * k\nprint(ans)\n"}, {"source_code": "n = int(input())\ndiv = {}\nfor i in range(2, 1000001):\n if n == 1: break\n if n % i == 0: div[i] = 0\n while n % i == 0:\n div[i] += 1\n n /= i\nif n > 1: div[n] = 1\nans = 1\nfor k, i in div.items():\n ans = ans * k\nprint(ans)\n"}, {"source_code": "from functools import reduce\nfrom operator import mul\n\n\ndef generate_primes(n):\n sieve = [1] * n\n for i in range(3, int(n ** 0.5) + 1, 2):\n if sieve[i]:\n sieve[i*i::2*i] = [0] * ((n - i * i - 1) // (2 * i) + 1)\n return [2] + [i for i in range(3, n, 2) if sieve[i]]\n\n\nPRIMES = generate_primes(1000000)\n\nn, D = int(input()), {1}\n\nfor d in PRIMES:\n while n % d == 0:\n D.add(d)\n n //= d\n if n == 1:\n break\n\nprint(reduce(mul, D))"}, {"source_code": "import math\nn = int(input())\n\ndef isLovely(item):\n s = 2\n e = 10**12\n\n while (s 0:\n e = m-1\n else:\n s = m+1\n return True\nif isLovely(n):\n print(n)\nelse:\n items = []\n \n for i in range(1,int(n**0.5)+1):\n if n%i == 0:\n item1 = i\n item2 = n//i\n if isLovely(item2):\n print(item2)\n break\n if isLovely(item1):\n items.append(item1)\n else:\n print(max(items))\n \n \n \n"}, {"source_code": "from math import *\nn=int(input())\ntemp=floor(sqrt(n))\nfor i in range(2,temp):\n if n%i==0:\n while n%i==0:\n n=n//i\n n*=i\n i+=1\nprint(n)\n"}, {"source_code": "n=int(input())\nm=n\ni=2\ncount=0\nflag=0\nwhile(count<=n):\n count=i**2\n if(n%count==0):\n n//=2\n i-=1\n i+=1\nif(m==n):\n print(m)\nelse:\n print(n)"}, {"source_code": "import math\nn = int(input())\n\ndef isLovely(item):\n s = 2\n e = math.ceil(math.sqrt(10**12))\n\n while (s 0:\n e = m-1\n else:\n s = m+1\n return True\nif isLovely(n):\n print(n)\nelse:\n items = []\n \n for i in range(1,int(n**0.5)+1):\n if n%i == 0:\n item1 = i\n item2 = n//i\n if isLovely(item2):\n print(item2)\n break\n if isLovely(item1):\n items.append(item1)\n else:\n print(max(items))\n \n \n \n"}, {"source_code": "from math import sqrt\n\ndef issquare(apositiveint):\n x = apositiveint // 2\n seen = set([x])\n while x * x != apositiveint:\n x = (x + (apositiveint // x)) // 2\n if x in seen: return False\n seen.add(x)\n return True\n\ndef main():\n\tn = input()\n\tdiv = []\n\t\n\tranges = range(1, int(sqrt(n))+1)\n\tranges.sort(reverse = True)\n\t\n\tfor i in ranges:\n\t\tif(n % i == 0 and (i not in div) and (n/i not in div)):\n\t\t\tif(i > 1):\n\t\t\t\tdiv.append(i)\n\t\t\tif(n/i > 1):\n\t\t\t\tdiv.append(n/i)\n\tdiv.sort(reverse = True)\n\tcondition = 0\t\t\n\t#print div\n\t#print int(sqrt(div[0]) + 1)\n\t\t\n\tfor i in div:\n\t\tcondition = 0\n\t\treqd_range = range(2, int(sqrt(i)) + 2)\n\t\t\n\t\tif(i not in reqd_range):\n\t\t\treqd_range.append(i)\n\t\t\t\n\t\t\n\t\tfor j in reqd_range:\n\t\t\tif(i % j == 0):\n\t\t\t\t#print j, issquare(j)\n\t\t\t\tif(issquare(j)):\n\t\t\t\t\tcondition = 1\n\t\t\t\t\tbreak\n\n\t\tif(condition == 0):\n\t\t\tprint i\n\t\t\tbreak\t\n\t\nmain()\n"}, {"source_code": "import math\n\ndef isLovely(num):\n lovely = True\n for j in range(2, int(math.sqrt(num))):\n if num % (j*j) == 0:\n lovely = False\n break\n\n return lovely\n\nnum = int(input())\nlovely = 1 \n\nif (num % 2) == 0:\n for i in range(2, num + 1):\n if num % i == 0:\n if isLovely(i):\n lovely = i\n\nelse:\n for i in range(3, num + 1, 2):\n if num % i == 0:\n if isLovely(i):\n lovely = i\nprint(lovely)\n"}, {"source_code": "n=input()\nm=n**0.5+1\ni=2\nli=[]\nwhile(i 1: div[n] = 1\n# ans = 1\n# for k, i in div.items():\n# temp = i - (1 if i % 2 == 0 else 0)\n# for p in range(temp):\n# ans = ans * k\n# print(ans)\nfor i in range(2, 1000001):\n if n % (i * i) == 0:\n n //= i\nprint(n)\n"}, {"source_code": "import math\nn=int(input())\ni=2\nwhile (i < math.sqrt(n) and n!=1):\n if(n%(i*i)==0):\n n = n/i;\n i=i+1 #s\nprint(int(n))"}, {"source_code": "n = int(input())\ncnt = 2\nmemo = {}\nprod = 1\nwhile cnt * cnt <= n :\n if n % cnt == 0 :\n prod *= cnt\n while n % cnt == 0 :\n n /= cnt\n cnt += 1\n\nif n > 1 :\n prod *= n\nprint(prod)"}, {"source_code": "isprime = [True]*10**6\nfor i in range(2,10**6):\n if isprime[i]:\n j = 2\n while i*j < 10**6:\n isprime[i*j] = False\n j += 1\nprime = [i for i in range(2,10**6) if isprime[i]]\nn = input()\nprime_factors = set()\ni = 0\nwhile n > 1 and i < len(prime):\n if n%prime[i] != 0:\n i += 1\n else:\n prime_factors.add(prime[i])\n n = n/prime[i]\nans = 1\nfor i in prime_factors:\n ans = ans*i\nprint ans"}, {"source_code": "import math\n\nnum = int(raw_input())\nfact = []\n\ni = 2;\n\nwhile num != 1:\n if not num % i:\n fact.append(i)\n num = num / i\n else: i += 1\n\ndiv = [1]\n\nfor pA in range(len(fact)):\n for j in range(len(div)):\n nmb = fact[pA] * div[j]\n if not nmb in div:\n div.append(nmb)\n\ndiv.sort(reverse=True)\nfor i in div:\n for j in range(2, int(math.ceil(math.sqrt(i)))):\n if not i % j ** 2 and j ** 2 in div:\n break\n else:\n print i\n break"}, {"source_code": "__author__ = 'pxy'\nimport time\nn=int(input())\nt=2\ne=n\nz=1\nq=1\nw=True\nb=True\nx=time.time()\nwhile q<=n and t<=n:\n if n%t==0:\n q=q*t\n while (n//t)%t==0:\n n=n//t\n if t>=5:\n t=t+2\n else:\n t=t+1\n if time.time()-x>1.8:\n print(e)\n w=False\n break\n#y=time.time()\nif w==True:\n print(n)"}, {"source_code": "import math\n\ndef isLovely(num):\n lovely = True\n for j in range(2, int(math.sqrt(num))):\n if num % (j*j) == 0:\n lovely = False\n break\n\n return lovely\n\nnum = int(input())\nlovely = 0\n\nif (num % 2) == 0:\n for i in range(2, num + 1):\n if num % i == 0:\n if isLovely(i):\n lovely = i\n\nelse:\n for i in range(3, num + 1, 2):\n if num % i == 0:\n if isLovely(i):\n lovely = i\nprint(lovely)\n"}, {"source_code": "import math\n\nn = int(raw_input())\nprimeDivisors = []\n\nif n % 2 == 0:\n n /= 2\n primeDivisors.append(2)\ni = 3\nif n == 6:\n primeDivisors.append(3)\n n /= 3\nwhile i <= math.sqrt(n):\n if n % i == 0: primeDivisors.append(i)\n while n % i == 0:\n n = n / i\n i += 2\nif n > 2: primeDivisors.append(n)\nanswer = 1\nfor x in primeDivisors:\n answer *= x\nprint answer"}, {"source_code": "import math\n\nn = input()\n\nans = 1\ni = 2\nwhile i < math.sqrt(n):\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n /= i\n i += 1\n\nif n > 1:\n ans *= n\n\nprint ans\n"}, {"source_code": "import math\n\nnum = int(input())\nlovely = 1\n\nfor i in range(2, int(math.sqrt(num)) + 1):\n if num % i == 0:\n lovely *= i\n num /= i\n while(num % i == 0):\n num /= i\n\nif num > 1:\n lovely *= num\n\nprint(lovely)\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\nn=Int()\nans=1\nflag=defaultdict(lambda : True)\nfor i in range(2,int(sqrt(n)+3)):\n if(n%i==0):\n ans*=i\n while(n%i==0):\n n=n//i\n\n\nprint(ans)\n "}, {"source_code": "\nfrom math import *\nn = int(input())\n\nfor i in range(2,int(sqrt(n))+1):\n\twhile n%(i*i)==0 :\n\t\tn//=(i*i)\nprint(n)\n"}, {"source_code": "import math\nn=int(input())\ni=2\nwhile (i < math.sqrt(n) and n!=1):\n if(n%(i*i)==0):\n n = n/i;\n i=i+1\nprint(int(n))"}, {"source_code": "N = int(raw_input())\n\nmm = 1\n##def isDivis(i,a):\n## for x in a:\n## if i%x==0:\n## return True\n## if x>i: break\n## return False\n\ndef isDivis(M):\n if math.sqrt(M)**2==M: return True\n for i in xrange(2,int(math.sqrt(M))+1):\n if M%i==0: \n if math.sqrt(i)**2==i: return True\n if math.sqrt(M/i)**2==M/i: return True\n return False\nimport math\nif not isDivis(N):\n if mm 2: primeDivisors.append(n)\nanswer = 1\nfor x in primeDivisors:\n answer *= x\nprint answer"}, {"source_code": "from sys import exit\nfrom math import sqrt, floor, ceil\n\nMAX_PRIME = int(sqrt(1e12))\n\nn = int(input())\nout = 1\n\nsieve_last, sieve_b = 1, [True] * (MAX_PRIME + 1)\ni = 2\nwhile i <= int(sqrt(MAX_PRIME)):\n #print(\"!!!\", i)\n k = sieve_last\n while k < min(i ** 2, MAX_PRIME):\n if sieve_b[k] and sieve_last != k:\n sieve_last = k\n if n % k == 0:\n while n % k == 0:\n n = n // k\n out *= k\n if n == 1:\n print(out)\n exit(0)\n #print(k)\n\n k += 1\n while k <= MAX_PRIME:\n sieve_b[k] = False\n k += i\n #print(k)\n i += 1\n while sieve_b[i] != True:\n i += 1\n\nprint(n * out)"}, {"source_code": "def primefactor(x):\n ans=1\n n=x\n if x%2==0:\n ans*=2\n while(x%2==0):\n x/=2\n prev=2\n for i in range(3,int(n**0.5)+1,2):\n curr=i\n if prev!=curr and x%curr==0 :\n ans*=curr\n prev=i\n while(x%i==0):\n x/=i\n if x>2 :\n ans*=x\n return ans\nprint(primefactor(int(input())))\n"}, {"source_code": "import math\nn = int(input())\nprimes = []\nwhile n % 2 == 0:\n primes.append(2)\n n //= 2\nx = 3\nwhile n != 1:\n while n % x == 0:\n primes.append(x)\n n //= x\n x += 2\n if x >= math.ceil(math.sqrt(n)):\n primes.append(n)\n break\nfactors = [1]\nfor x in primes:\n for y in factors[:]:\n if not x * y in factors:\n factors.append(x * y)\nfactors = sorted(factors)[::-1]\nfor x in factors:\n condition = True\n for y in range(2, math.floor(math.sqrt(x)) + 1):\n if x % (y ** 2) == 0:\n condition = False\n break\n if condition:\n print(x)\n break"}, {"source_code": "from math import sqrt\n\ndef issquare(k):\n\troot = sqrt(k)\n\t\n\tif(root == int(root)):\n\t\treturn 1\n\telse:\n\t\treturn 0\n\ndef main():\n\tn = input()\n\tdiv = []\n\t\n\tranges = range(1, n/2 + 1)\n\tranges.sort(reverse = True)\n\t\n\tfor i in ranges:\n\t\tif(n % i == 0 and (i not in div) and (n/i not in div)):\n\t\t\tif(i > 1):\n\t\t\t\tdiv.append(i)\n\t\t\tif(n/i > 1):\n\t\t\t\tdiv.append(n/i)\n\tdiv.sort(reverse = True)\n\tcondition = 0\t\t\n\t\n\tfor i in div:\n\t\tcondition = 0\n\t\treqd_range = range(2, i/2 + 1)\n\t\t\n\t\tif(i not in reqd_range):\n\t\t\treqd_range.append(i)\n\t\t\n\t\t\n\t\tfor j in reqd_range:\n\t\t\tif(i % j == 0):\n\t\t\t\t#print j, issquare(j)\n\t\t\t\tif(issquare(j)):\n\t\t\t\t\tcondition = 1\n\t\t\t\t\tbreak\n\n\t\tif(condition == 0):\n\t\t\tprint i\n\t\t\tbreak\t\n\n\t\n\t\n\t\nmain()\n"}, {"source_code": "n = int(input())\nfrom math import sqrt\nfrom math import ceil\n\n \n\ndef prim(n):\n if (n % 100) % 4 == 0 or (n % 100) % 9 == 0:\n return 0\n i = 2\n while i * i <= n:\n if n % (i**2) == 0:\n return 0\n i += 1\n return 1\n\n\n\nif n < 999999999983:\n while n > 1:\n if prim(n):\n break\n n -= 1\n print(n)\nelif n > 999999999997:\n print(999999999998)\nelif n == 999999999997:\n print(999999999997)\nelif n > 999999999994:\n print(999999999995)\nelif 999999999992 < n < 99999999995:\n print(n)\nelif n > 999999999990:\n print(999999999991)\nelif n > 999999999988:\n print(999999999989) \nelif n > 999999999986:\n print(999999999987)\nelif n > 999999999985:\n print(999999999986)\nelif n > 999999999982:\n print(999999999983)\n\n"}, {"source_code": "def divide(n, i):\n if n % i != 0:\n return n,0\n else:\n sch = 0\n while (n % i == 0) & (n != 1):\n n = n / i\n sch += 1\n return n, sch\n \ndef multiply(a):\n if len(a) > 1:\n output = 1\n for item in a:\n output = output * item[0]\n else:\n if a[0][1] % 2 != 0:\n return a[0][0] ** a[0][1]\n else:\n return a[0][0]\n return output\n \n \ndef get_simple_dels(curr):\n k = 2\n dels = []\n if curr == 1:\n dels.append((1,1))\n else:\n limit = int(curr**0.5) + 1\n while (curr != 1) & (k <= limit):\n prev_curr = curr\n curr,sch = divide(curr,k)\n if curr != prev_curr:\n if (k,sch) != (1,1):\n dels.append((k, sch))\n k += 1\n if k == limit:\n if (int(curr),1) != (1,1):\n dels.append((int(curr),1))\n return dels\n \nn = int(input())\nprint(multiply(get_simple_dels(4)))\n"}, {"source_code": "from math import sqrt\nimport sys\ndef factors(n): \n return set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\nt=input()\nz=list(factors(t))\nz=sorted(z,reverse=True)\nfor i in range(len(z)-1):\n k=z[i]*z[i]\n for j in range(i+1,len(z)):\n if(k%z[j]==0):\n r=1\n print int(sqrt(k))\n sys.exit(0)\n \n \n\n "}, {"source_code": "from math import sqrt\n\ndef factor(n):\n factors = set()\n for x in range(1, int(sqrt(n)+ 1)):\n if n % x == 0:\n factors.add(x)\n factors.add(n//x)\n return sorted(factors)\n\nn = input()\nif n == 1:\n print 0\n exit(0)\n\nl = factor(n)[::-1]\n\n#print l\n\nfor i in l:\n fl = 0\n for x in range(2, int(sqrt(n) + 1)):\n ans = i\n if i % (x*x) == 0:\n fl = 1\n break\n if fl == 0:\n break\n\nprint ans\n"}, {"source_code": "\nfrom math import *\nn = int(input())\n\nfor i in range(2,int(sqrt(n))+1):\n\twhile n%(i*i)==0 :\n\t\tn//=(i*i)\nprint(n)\n"}, {"source_code": "import math\na=[]\nfor i in range(2,1000001):\n\ta.append(i*i)\n\ndef bsearch(n):\n\tl = 0\n\th = len(a)\n\twhile l<=h:\n\t\tm = (l+h)/2\t\n\t\tif a[m]>n:\n\t\t\th = m-1\n\t\telif a[m]res:\n\t\t\tres = x\t\t\t\nprint(res)\t\t\t\t\t"}, {"source_code": "from math import sqrt,ceil\nz=[1]*1000001;o=[]\nfor i in range(2,1000001):\n if z[i]==1:\n for j in range(i,1000001,i):z[j]=0\n o.append(i*i);z[i]=1\na=int(input());s=0\nfor i in range(1,ceil(sqrt(a))+1):\n if (i**0.5)%1:\n ok=1\n for j in o:\n if i%j==0:ok=0;break\n if i>j:break\n if ok:s=max(s,i)\n p = a // i\n ok = 1\n for j in o:\n if p % j == 0: ok = 0;break\n if p > j: break\n if ok:s=max(s,p)\nprint(s)"}, {"source_code": "from math import sqrt\n\ndef factor(n):\n factors = set()\n for x in range(1, int(sqrt(n)+ 1)):\n if n % x == 0:\n factors.add(x)\n factors.add(n//x)\n return sorted(factors)\n\nn = input()\nif n == 1:\n print 0\n exit(0)\n\nl = factor(n)[::-1]\n\n#print l\n\nfor i in l:\n fl = 0\n for x in range(2, int(sqrt(n) + 1)):\n ans = i\n if i % (x*x) == 0:\n fl = 1\n break\n if fl == 0:\n break\n\nprint ans\n"}, {"source_code": "from math import sqrt\n\ndef is_lovely(n):\n\tfor i in xrange(2, int(n**(1/2.0))+1):\n\t\tif n % (i*i) == 0:\n\t\t\treturn False\n\treturn True\n\nn = int(raw_input())\nfor x in xrange(n, 1, -1):\n\tif n % x == 0 and is_lovely(x):\n\t\tprint x\n\t\tbreak\n\n"}, {"source_code": "n=int(input())\nfor i in range(2,n//2):\n if n%(i*i)==0:\n n/=i\n \nprint(int(n))"}, {"source_code": "import math\nimport sys \n\ndef is_prime(x):\n k = int(math.sqrt(x))\n for i in range(2, k + 1):\n if x % i == 0:\n return False\n return True\n\nn = int(input())\nif is_prime(n):\n print(n)\n sys.exit(0)\ndiv = set()\n\nif n % 2 == 0:\n div.add(2)\n if is_prime(n // 2):\n div.add(n // 2)\nk = int(math.sqrt(n))\nfor i in range(3, k + 1, 2):\n if n % i == 0 and is_prime(i):\n div.add(i)\n if is_prime(n // i):\n div.add(n // i)\n\nans = 1\nfor i in div:\n ans = ans * i\n\nprint(ans)\n# 789554321\n"}, {"source_code": "n=int(input())\nk=int(n**0.5) + 1\na=[0]*(k)\nb=[]\nfor i in range(2,k):\n for j in range(i,k,i):\n a[j]+=1\nfor i in range(1,k):\n if n%i==0:\n b.append(i)\n b.append(n//i)\nb.sort(reverse=True)\nfor i in range(len(b)):\n for j in range(2,k):\n if a[j]==1 and b[i]%(j*j)==0:\n break\n elif j==k-1:\n exit(print(b[i]))\n\n\n \n"}, {"source_code": "import math\nimport sys\ndef factors(n):\n s=[]\n l=[]\n for i in range(1,int(math.sqrt(n))+ 1, 2 if n & 1 else 1):\n if n%i==0:\n s.append(i)\n l.append(n//i)\n if s[-1]==l[-1]:\n l.pop()\n l.reverse()\n s.extend(l)\n return l\nn=int(input())\nl=factors(n)\nf=0\nfor i in range(len(l)-1):\n if math.sqrt(l[i])==int(math.sqrt(l[i])):\n f=1\n break\nif f==0:\n print(n)\n exit(0)\nfor i in range(1,len(l)-1):\n li=factors(l[i])\n f=0\n for j in range(len(li)-1):\n if math.sqrt(li[j])==int(math.sqrt(li[j])):\n f=1\n break\n if f==0:\n print(l[i])\n exit()"}, {"source_code": "n = int(input())\ni = 2\nans = 1\nwhile i * i <= n:\n\tif n % i == 0:\n\t\tans *= i\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\ti += 1\nif n > 1:\n\tans *= n\nprint(ans)"}, {"source_code": "import math\nn = int(input().split()[0])\nfor i in range(2, math.ceil(math.sqrt(n))):\n while n % (i ** 2) == 0:\n n //=i\n\nprint(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\nimport collections\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)]\ndef gcd(a,b): return a if b==0 else gcd(b,a%b)\ndef lcm(a,b): return a*b/gcd(a,b)\n#start = time.clock()\ndef calc_exp(n, p):\n e = 0\n while n % p == 0:\n e += 1\n n /= p\n return e, n\n\ndef gen_prime_candidates():\n yield 2\n n = 3\n while True:\n yield n\n n += 2\n\ndef factorize(n):\n f = ()\n for m in gen_prime_candidates():\n if m * m > n:\n break\n e, n = calc_exp(n, m)\n if e:\n f = f + ( (m, e), )\n if n != 1:\n f = f + ( (n, 1), )\n return f\n\ndef gen_divisors(f, k = 0):\n if k == len(f):\n yield 1\n else:\n p, e = f[k]\n for d in gen_divisors(f, k + 1):\n for e1 in range(e + 1):\n yield p ** e1 * d\n\n\nn=int(raw_input())\nf = factorize(n)\nl=[]\ntmp=[]\nfor d in gen_divisors(f):\n l.append(d)\nl.sort()\nt=len(l)\nfor i,j in enumerate(l):\n if j>1:\n if l[-1]%(j**2)==0:\n l.pop(-1)\nprint l[-1]"}, {"source_code": "from math import sqrt as sq\nn=input()\ng=n\ns=int(sq(n))+1\nif s%2==0:\n p=s-1\nelse:\n p=s\ni=3\nres=1\nwhile i*i<=g:\n c=0\n k=n\n while n%i==0:\n n/=i\n c+=1\n if c>0 and c%2==0:\n res=max(res,k/i)\n n=k\n i+=2\nc=0\nk=n\nwhile n%2==0:\n n/=2\n c+=1\nif c>0 and c%2==0:\n res=max(res,k/2)\nelse:\n res=max(res,k)\nprint res\n"}, {"source_code": "n = int(input())\n\nisLovely = True\nans = 1\nfor div in range(2,int(n**0.5*2)):\n if n%div == 0: ans *= div\n while n%div == 0: n //= div\n\nif ans==1:\n print(n)\nelse:\n print(ans)\n\n"}, {"source_code": "primes = []\naux = [True for i in range(1000000)]\n\ndef crivos(num):\n for i in range(2,num):\n if aux[i]: \n for j in range(i * i, num, i): aux[j] = False\n primes.append(i)\n\ncrivos(1000000)\n\ndef fatorar(num):\n fatores = []\n index, pf = 0, primes[0]\n while num != 1 and (pf*pf) <= num:\n while num%pf == 0:\n num /= pf \n fatores.append(pf)\n index += 1\n pf = primes[index]\n if num != 1: fatores.append(num)\n return fatores\n\nnum = int(raw_input())\nfoat = fatorar(num)\nresp = 1\nfor i in foat: resp *= i\nprint resp"}, {"source_code": "t=input()\nprimes=[1]*((10**6)+5)\n\nfor i in xrange(2,(10**6)+1):\n if primes[i]==1:\n j=2\n x=i*j\n while x<(10**6)+1:\n primes[x]=0\n j+=1\n x=i*j\n \n \n\ndef fun(t):\n \n for i in xrange(2,int(math.sqrt(t))+1):\n if t%i==0:\n return False\n \n \n return True\n \nimport math\nans=1\nfor i in xrange(2,int(math.sqrt(t))+1):\n if primes[i]:\n if t%i==0:\n ans*=i\n \n if fun(t/i) and (i*i)!=t:\n ans*=(t/i)\n \n if ans==t:\n break \n \n \n \nif fun(t):\n ans=t \n \nprint ans \n \n"}, {"source_code": "a=[0]*1001\nb=[]\nfor i in range(2,1000):\n for j in range(i,1000,i):\n a[j]+=1\nn=int(input())\nfor i in range(1,int(n**0.5) + 1):\n if n%i==0:\n b.append(i)\n b.append(n//i)\nb.sort(reverse=True)\n#print(b)\nfor i in range(len(b)):\n for j in range(2,1001):\n if a[j]==1 and b[i]%(j*j)==0:\n #print(j,end=' ')\n break\n elif j==1000:\n exit(print(b[i]))\n\n\n \n"}, {"source_code": "import math\nfrom fractions import gcd\n\n# retorna se \u00e9 divis\u00edvel por algum quadrado perfeito\ndef divisible(x):\n i = 2\n while i * i <= x:\n quad = i * i\n if x % quad == 0:\n return True\n i += 1\n return False\n\n\nn = int(input())\nraiz = int(math.sqrt(n)) + 1\n\np = []\nprimos = [True for i in range(raiz)]\nprimos[1] = False\nfor i in range(2, raiz):\n if primos[i]:\n p.append(i)\n for j in range(i*i, raiz, i):\n primos[j] = False\n\neh_divisivel = True\ni = n\nanterior = n\nwhile eh_divisivel:\n eh_divisivel = divisible(i)\n\n if eh_divisivel:\n j = 0\n while p[j] <= int(math.sqrt(i)):\n if i % p[j] == 0:\n i //= p[j]\n break\n j += 1\n if j == int(math.sqrt(i)):\n i -= 1\n\nif not eh_divisivel:\n print(i)\n\n\n#for i in range(n, 0, -1):\n# if n % i != 0:\n# continue\n# eh_divisivel = divisible(i)\n#\n# print(i, eh_divisivel)\n#\n# if not eh_divisivel:\n# print(i)\n# break\n"}, {"source_code": "import math\nn = int(input())\n\ndef isLovely(item):\n s = 2\n e = math.ceil(math.sqrt(10**12))\n\n while (s 0:\n e = m-1\n else:\n s = m+1\n return True\nif isLovely(n):\n print(n)\nelse:\n items = []\n \n for i in range(1,int(n**0.5)+1):\n if n%i == 0:\n item1 = i\n item2 = n//i\n if isLovely(item2):\n print(item2)\n break\n if isLovely(item1):\n items.append(item1)\n else:\n print(max(items))\n \n \n \n"}, {"source_code": "###################################\n## Eric Breno B. - UFCG - BRAZIL ##\n###################################\n\nn = int(raw_input())\n\nsaida = []\n\ndef testa(n):\n\tif n < 4: return True\n\tif n == 4: return False\n\tif n < 8: return True\n\t\n\tfor i in xrange(2, int(n**0.5 + 1)):\n\t\tif n % i == 0:\n\t\t\tif ((n/i)**0.5)%1 == 0 or ((i)**0.5)%1 == 0:\n\t\t\t\treturn False\n\treturn True\n\t\ndef t(n):\n\tmd = 1\n\ttestar = True\n\tfoi = False\n\t\n\tfor i in xrange(2, int(n**0.5 + 1)):\n\t\tif n % i == 0:\n\t\t\tif testar and testa(n/i):\n\t\t\t\tmd = n/i\n\t\t\t\ttestar = False\n\t\t\t\t\n\t\t\telif testar and testa(i):\n\t\t\t\tif i > md: md = i\n\t\t\t\t\n\t\t\tif (i**0.5)%1==0 or ((n/i)**0.5)%1==0: foi=True\n\t\n\tif foi:return t(md)\n\telse: return n\n\t\nprint t(n)\n"}, {"source_code": "n = int(input())\ndiv = {}\nfor i in range(2, 1000001):\n if n == 1: break\n if n % i == 0: div[i] = 0\n while n % i == 0:\n div[i] += 1\n n /= i\nif n > 1: div[n] = 1\nans = 1\nfor k, i in div.items():\n temp = i - (1 if i % 2 == 0 else 0)\n for p in range(temp):\n ans = ans * k\nprint(ans)\n"}, {"source_code": "import math\nn = int(input())\n\nans = 1\nupper = int(math.sqrt(n))\nfor i in range(2, upper):\n if n % i == 0:\n ans *= i\n while n % i == 0:\n n /= i\n\nans *= n\nprint(int(ans))"}, {"source_code": "n = int(input())\ndiv = {}\nfor i in range(2, 1000001):\n if n == 1: break\n if n % i == 0: div[i] = 0\n while n % i == 0:\n div[i] += 1\n n /= i\nif n > 1: div[n] = 1\nans = 1\nfor k, i in div.items():\n ans = ans * k\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python3\n\n\nn = int(input())\n\nsquare = [i ** 2 for i in range(2, int(n**0.5))]\n\ndef is_valid(k):\n for x in square:\n if x < k and k % x == 0:\n return False\n return True\n\nfor i in range(n, 0, -1):\n if n % i == 0 and is_valid(i):\n print(i)\n break\n"}, {"source_code": "def rez(x):\n y=x\n d=1;\n p=[2,3]\n for i in p:\n if y%i==0:\n y=y//i\n d=d*i\n while y%i==0:\n y=y//i\n t=5\n while t*tt:\n if y%t==0:\n y=y//t\n d=d*t\n while y%t==0:\n y=y//t\n break\n t+=2\n return d*y\n \nn=int(input())\nprint(rez(n))"}, {"source_code": "def getfctrllist(n):\n A = [n]\n for i in range(2,int(n**0.5)+1):\n if(n%i==0):\n if(n//i == i):\n A.append(i)\n else:\n A.append(i);A.append(n//i)\n A.sort()\n return A\nn = int(input())\nA = getfctrllist(n)\np = len(A)-1\nfor i in range(p+1):\n if(A[p]%(A[i]*A[i])==0):\n p-=1\nprint(A[p])\n"}, {"source_code": "n = int(input())\n\nisLovely = True\nans = 1\nfor div in range(2,int(n**0.5*2)):\n if n%div == 0: ans *= div\n while n%div == 0: n //= div\n\nif ans==1:\n print(n)\nelse:\n print(ans)\n\n"}, {"source_code": "'''input\n817634153013\n'''\nfrom sys import stdin\nfrom collections import defaultdict\nimport sys\n\nsys.setrecursionlimit(15000)\n\n\ndef get_prime():\n\tseive = [True] * (10 ** 6 + 1)\n\tfor i in range(2, 10 ** 6 + 1):\n\t\tif seive[i] == True:\n\t\t\tfor j in range(i * i, 10 ** 6 + 1, i):\n\t\t\t\tseive[j] = False\n\n\tprime = []\n\tfor i in range(2, 10 ** 6 + 1):\n\t\tif seive[i] == True:\n\t\t\tprime.append(i)\n\treturn prime\n\n\n# main starts\nn = int(stdin.readline().strip())\ncn = n\nprime = get_prime()\nfactors = [0] * (10 ** 6 + 1)\nflag = 0\nfor i in prime:\n\twhile n % i == 0:\n\t\tflag = 1\n\t\tfactors[i] += 1\n\t\tn //= i\n#print(factors[:11])\nans = 1\nfor i in range(2, len(factors)):\n\tif factors[i] != 0:\n\t\tans *= i\nif flag == 0:\n\tprint(ans)\nelse:\n\tprint(cn) \n"}, {"source_code": "def divide(n, i):\n if n % i != 0:\n return n\n else:\n while (n % i == 0) & (n != 1):\n n = n / i\n return n\n \ndef multiply(a):\n output = 1\n for item in a:\n output = output * item\n return output\n\n \ndef get_simple_dels(curr):\n k = 2\n dels = []\n limit = int(curr**0.5) + 1\n while (curr != 1) & (k < limit):\n prev_curr = curr\n curr = divide(curr,k)\n if curr != prev_curr:\n dels.append(k)\n k += 1\n if k == limit:\n dels.append(int(curr))\n return dels\n\n\n\nn = int(input())\nprint(multiply(get_simple_dels(n)))"}, {"source_code": "n = int(input())\n\nisLovely = True\nans = 1\nfor div in range(2,int(n**0.5)*2):\n if n%div == 0: ans *= div\n while n%div == 0: n //= div\nprint(ans)"}, {"source_code": "import math\n\norig = n = int(input().strip())\n\nans = 1\nif n % 2 == 0:\n\tans *= 2\n\tn //= 2\n\twhile n % 2 == 0:\n\t\tn //= 2\n\t\t\nfor it in range(3, orig // 2 + 1, 2):\n\t\n\tif n % it == 0:\n\t\tans *= it\n\t\tn //= it\n\t\twhile n % it == 0:\n\t\t\tn //= it\n\t\t\nprint(ans)"}, {"source_code": "import math\n\nnum = int(input())\nlovely = 1\n\nfor i in range(2, int(math.sqrt(num)) + 1):\n if num % i == 0:\n lovely *= i\n num /= i\n while(num % i == 0):\n num /= i\n\nif num > 1:\n lovely *= num\n\nprint(lovely)\n"}, {"source_code": "from math import sqrt\n\ndef factor(n):\n factors = set()\n for x in range(1, int(sqrt(n)+ 1)):\n if n % x == 0:\n factors.add(x)\n factors.add(n//x)\n return sorted(factors)\n\nn = input()\nif n == 1:\n print 1\n exit(0)\nif n == 2:\n print 2\n exit(0)\nif n == 3:\n print 3\n exit(0)\n\nl = factor(n)[::-1]\n\n#print l\n\nfor i in l:\n fl = 0\n for x in range(2, int(sqrt(i) + 1)):\n ans = i\n if i % (x*x) == 0:\n fl = 1\n break\n if fl == 0:\n break\n\nprint ans\nexit(0)\n"}, {"source_code": "def divide(n, i):\n if n % i != 0:\n return n,0\n else:\n sch = 0\n while (n % i == 0) & (n != 1):\n n = n / i\n sch += 1\n return n, sch\n \ndef multiply(a):\n if len(a) > 1:\n output = 1\n for item in a:\n output = output * item[0]\n else:\n if a[0][1] % 2 != 0:\n return a[0][0] * a[0][1]\n else:\n return 1\n return output\n \n \ndef get_simple_dels(curr):\n k = 2\n dels = []\n if curr == 1:\n dels.append((1,1))\n else:\n limit = int(curr**0.5) + 1\n while (curr != 1) & (k <= limit):\n prev_curr = curr\n curr,sch = divide(curr,k)\n if curr != prev_curr:\n if (k,sch) != (1,1):\n dels.append((k, sch))\n k += 1\n if k == limit:\n if (int(curr),1) != (1,1):\n dels.append((int(curr),1))\n return dels\n \nn = int(input())\nprint(multiply(get_simple_dels(n)))"}, {"source_code": "n = int(input())\ni = 2\nresposta = 1\nwhile i * i <= n:\n\tif n % i == 0:\n\t\tresposta *= i\n\t\twhile n % i == 0:\n\t\t\tn /= i\n\ti += 1\nif n > 1:\n\tresposta *= n\nprint(resposta)"}, {"source_code": "import math,sys,time\ndef calc(n):\n i=2\n s=set()\n m = math.sqrt(n)\n while n!=1 and i<=m:\n if n%i==0:\n n=n/i\n s.add(i)\n else:\n i=i+1\n if len(s)==0:\n return n\n else:\n ans = 1\n for number in s:\n ans = ans * number\n return ans\n\n\nif __name__=='__main__':\n n = raw_input()\n #t=time.time()\n #n = 4\n print calc(int(n))\n #print time.time()-t"}, {"source_code": "def tem_divisor_quadrado(numero,lista):\n\ti = 0\n\twhile numero >= lista[i] :\n\t\tif numero % lista[i] == 0 :\n\t\t\treturn True\n\t\tif i == len(lista):\n\t\t\tbreak\n\t\ti += 1\n\treturn False\n\t\nnum = int(raw_input())\n\nif num % 10 == 0:\n\tprint 10\nelse:\n\tcont = 1\n\tx = 0\n\tlista = []\n\twhile x < num :\n\t\tcont += 1 \n\t\tx = cont ** 2\n\t\tlista.append(x)\n\tfor j in xrange(num ,2,-1):\n\t\tif num % j == 0 and not tem_divisor_quadrado(j,lista):\n\t\t\tprint j\n\t\t\tbreak\n\n"}, {"source_code": "#!/usr/bin/env python3\n\n\nn = int(input())\n\nsquare = [i ** 2 for i in range(2, int(n**0.5))]\n\ndef is_valid(k):\n for x in square:\n if x <= k and k % x == 0:\n return False\n return True\n\nfor i in range(n, 0, -1):\n if n % i == 0 and is_valid(i):\n print(i)\n break\n"}, {"source_code": "from math import sqrt\n\ndef issquare(apositiveint):\n x = apositiveint // 2\n seen = set([x])\n while x * x != apositiveint:\n x = (x + (apositiveint // x)) // 2\n if x in seen: return False\n seen.add(x)\n return True\n\ndef main():\n\tn = input()\n\tdiv = []\n\t\n\tranges = range(1, int(sqrt(n))+1)\n\tranges.sort(reverse = True)\n\t\n\tfor i in ranges:\n\t\tif(n % i == 0 and (i not in div) and (n/i not in div)):\n\t\t\tif(i > 1):\n\t\t\t\tdiv.append(i)\n\t\t\tif(n/i > 1):\n\t\t\t\tdiv.append(n/i)\n\tdiv.sort(reverse = True)\n\tcondition = 0\t\t\n\t#print div\n\t#print int(sqrt(div[0]) + 1)\n\t\t\n\tfor i in div:\n\t\tcondition = 0\n\t\treqd_range = range(2, int(sqrt(i)) + 2)\n\t\t\n\t\tif(i not in reqd_range):\n\t\t\treqd_range.append(i)\n\t\t\t\n\t\t\n\t\tfor j in reqd_range:\n\t\t\tif(i % j == 0):\n\t\t\t\t#print j, issquare(j)\n\t\t\t\tif(issquare(j)):\n\t\t\t\t\tcondition = 1\n\t\t\t\t\tbreak\n\n\t\tif(condition == 0):\n\t\t\tprint i\n\t\t\tbreak\t\n\t\nmain()\n"}, {"source_code": "n = int(input())\na = []\nwhile n%2==0:\n n=n//2\n a.append(2)\nfor i in range(3,int(n**(0.5))+1,2):\n if n%i==0:\n a.append(n)\nif n>2:\n a.append(n)\nl=1\na = list(set(a))\nfor i in a:\n l*=i\nprint(l)\n"}, {"source_code": "import math\nimport sys\ndef factors(n):\n s=[]\n l=[]\n for i in range(1,int(math.sqrt(n))+ 1, 2 if n & 1 else 1):\n if n%i==0:\n s.append(i)\n l.append(n//i)\n if s[-1]==l[-1]:\n l.pop()\n l.reverse()\n s.extend(l)\n return l\nn=int(input())\nl=factors(n)\nf=0\nfor i in range(len(l)-1):\n if math.sqrt(l[i])==int(math.sqrt(l[i])):\n f=1\n break\nif f==0:\n print(n)\n exit(0)\nfor i in range(1,len(l)-1):\n li=factors(l[i])\n f=0\n for j in range(len(li)-1):\n if math.sqrt(li[j])==int(math.sqrt(li[j])):\n f=1\n break\n if f==0:\n print(l[i])\n exit()"}, {"source_code": "import math\nimport sys \n\ndef is_prime(x):\n k = int(math.sqrt(x))\n for i in range(2, k + 1):\n if x % i == 0:\n return False\n return True\n\nn = int(input())\nif is_prime(n):\n print(n)\n sys.exit(0)\ndiv = set()\n\nif n % 2 == 0:\n div.add(2)\nk = int(math.sqrt(n))\nfor i in range(3, k + 1, 2):\n if n % i == 0 and is_prime(i):\n div.add(i)\n if is_prime(n // i):\n div.add(n // i)\n\nans = 1\nfor i in div:\n ans = ans * i\n\nprint(ans)\n# 789554321\n"}, {"source_code": "#In the name of Allah\n\nfrom sys import stdin, stdout\ninput = stdin.readline\n\n\n\n\nn = int(input())\n\nfor i in range(2, 10 ** 6 + 1):\n if n % (i * i) == 0:\n n /= i * i\n\nstdout.write(str(n))\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# @Author : Napoleon\n# @Mail : tyfdream@163.com\n# @Data : 2015-07-22 11:40:35\n# @Version : python 2.7\nimport math\nn = int(raw_input())\nans = 1\ns = 2\na = n\nwhile s*s < a : \n while n %(s*s) == 0: \n n/=s\n s += 1\n\nprint n"}, {"source_code": "from math import sqrt\ndef FindAllDivisors(x):\n divList = []\n y = 1\n sqrx = sqrt(x)\n while y <= sqrx:\n if x % y == 0:\n divList.append(y)\n divList.append(int(x / y))\n y += 1\n return sorted(divList)\n\nn = int(raw_input())\nwhile 1:\n a = FindAllDivisors(n)\n found = False\n for i in range(1, len(a) - 1):\n if int(sqrt(a[i])) ** 2 == a[i]:\n n = a[-2]\n found = True\n break\n if found:\n continue\n else:\n break\nprint n"}, {"source_code": "n = int(input())\ni = 2\nwhile i * i <= n:\n if n % (i * i) == 0:\n n /= i\n i += 1\nprint n"}, {"source_code": "import math\nimport sys \n\ndef is_prime(x):\n k = int(math.sqrt(x))\n for i in range(2, k + 1):\n if x % i == 0:\n return False\n return True\n\nn = int(input())\nif is_prime(n):\n print(n)\n sys.exit(0)\ndiv = set()\n\nif n % 2 == 0:\n div.add(2)\nk = int(math.sqrt(n))\nfor i in range(3, k + 1, 2):\n if n % i == 0 and is_prime(i):\n div.add(i)\n if is_prime(n // i):\n div.add(n // i)\n\nans = 1\nfor i in div:\n ans = ans * i\n\nprint(ans)\n# 789554321\n"}, {"source_code": "__author__ = 'trunghieu11'\n\n\ndef solve(n):\n answer = 1\n i = 2\n while i**2 < n:\n if i**2 > n:\n break\n if n % i == 0:\n answer *= i\n while n % i == 0:\n n /= i\n i += 1\n if n > 1:\n answer *= n\n return answer\n\nif __name__ == '__main__':\n n = int(raw_input())\n print solve(n)"}, {"source_code": "n = int(input())\nfrom math import sqrt\nfrom math import ceil\n\n \n\ndef prim(n):\n if (n % 100) % 4 == 0:\n return 0\n i = 2\n while i * i <= n:\n if n % (i**2) == 0:\n return 0\n i += 1\n return 1\n\n\n\nif n < 999999999983:\n while n > 1:\n if prim(n):\n break\n n -= 1\n print(n)\nelif n > 999999999997:\n print(999999999998)\nelif n == 999999999997:\n print(999999999997)\nelif n > 999999999994:\n print(999999999995)\nelif 999999999992 < n < 99999999995:\n print(n)\nelif n > 999999999990:\n print(999999999991)\nelif n > 999999999988:\n print(999999999989) \nelif n > 999999999986:\n print(999999999987)\nelif n > 999999999985:\n print(999999999986)\nelif n > 999999999982:\n print(999999999983)\n\n"}, {"source_code": "def isLovely( x ) :\n a = 2\n a2 = a**2\n while a2 <= x :\n if x % a2 == 0 :\n return False\n a += 1\n a2 = a**2\n return True\n \nn = int(input())\nk = 2\ncon = True\nans = 1\nwhile n > 1 :\n if con and isLovely( n ) :\n ans = n\n break\n\n con = True\n\n if n % k == 0 :\n n //= k\n else :\n k += 1\n con = False\n\nprint( ans )\n"}, {"source_code": "n = int(input())\ndiv = {}\n# for i in range(2, 1000001):\n# if n == 1: break\n# if n % i == 0: div[i] = 0\n# while n % i == 0:\n# div[i] += 1\n# n /= i\n# if n > 1: div[n] = 1\n# ans = 1\n# for k, i in div.items():\n# temp = i - (1 if i % 2 == 0 else 0)\n# for p in range(temp):\n# ans = ans * k\n# print(ans)\nfor i in range(2, 1000001):\n if n % (i * i) == 0:\n n //= i\nprint(n)\n"}], "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92"} {"nl": {"description": "You are given two positive integers $$$x$$$ and $$$y$$$. You can perform the following operation with $$$x$$$: write it in its binary form without leading zeros, add $$$0$$$ or $$$1$$$ to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of $$$x$$$.For example: $$$34$$$ can be turned into $$$81$$$ via one operation: the binary form of $$$34$$$ is $$$100010$$$, if you add $$$1$$$, reverse it and remove leading zeros, you will get $$$1010001$$$, which is the binary form of $$$81$$$. $$$34$$$ can be turned into $$$17$$$ via one operation: the binary form of $$$34$$$ is $$$100010$$$, if you add $$$0$$$, reverse it and remove leading zeros, you will get $$$10001$$$, which is the binary form of $$$17$$$. $$$81$$$ can be turned into $$$69$$$ via one operation: the binary form of $$$81$$$ is $$$1010001$$$, if you add $$$0$$$, reverse it and remove leading zeros, you will get $$$1000101$$$, which is the binary form of $$$69$$$. $$$34$$$ can be turned into $$$69$$$ via two operations: first you turn $$$34$$$ into $$$81$$$ and then $$$81$$$ into $$$69$$$. Your task is to find out whether $$$x$$$ can be turned into $$$y$$$ after a certain number of operations (possibly zero).", "input_spec": "The only line of the input contains two integers $$$x$$$ and $$$y$$$ ($$$1 \\le x, y \\le 10^{18}$$$).", "output_spec": "Print YES if you can make $$$x$$$ equal to $$$y$$$ and NO if you can't.", "sample_inputs": ["3 3", "7 4", "2 8", "34 69", "8935891487501725 71487131900013807"], "sample_outputs": ["YES", "NO", "NO", "YES", "YES"], "notes": "NoteIn the first example, you don't even need to do anything.The fourth example is described in the statement."}, "positive_code": [{"source_code": "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n# |AUTHOR|\r\n# | |\r\n# | |\r\n# | |\r\n# | | \r\n# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n# MUHAMMAD AMMAR\r\n# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\nimport sys as system_break\r\ndef Commonfinder(n,m,o,p):\r\n return (f'1*({n}|{m}|{o}|{p})1*')\r\nimport math as m\r\nimport re as MATCHING_DEVICE_pattern\r\nInput= input()\r\nInput= Input.split()\r\nablist =[]\r\nfor i in range(len(Input)):\r\n ablist.append( int( Input[i] ))\r\na=ablist[0];b=ablist[1]\r\nBinofa=bin(a)[2:]\r\nBinofb=bin(b)[2:]\r\nExtended_A=Binofa+'1'\r\nStriped_A=Binofa.rstrip('0')\r\nFinalCF=Commonfinder(Extended_A,Striped_A,Extended_A[::-1],Striped_A[::-1])\r\nif len(FinalCF)==1:\r\n FinalCF=list(FinalCF)\r\n FinalCF=FinalCF[0]\r\n if (MATCHING_DEVICE_pattern.fullmatch(FinalCF,Binofb)) or Binofa ==Binofb:\r\n print('YES')\r\nelse:\r\n answer=''\r\n FinalCF=(FinalCF)\r\n if a==b or MATCHING_DEVICE_pattern.fullmatch(FinalCF, Binofb):\r\n print('YES')\r\n else:\r\n print('NO')"}, {"source_code": "from sys import stdin,stdout\r\nfrom collections import defaultdict\r\ninput=stdin.readline\r\n#print=stdout.write\r\n###-----------Code Begins----------##\r\n\r\ndef oper1(x):\r\n bin=[]\r\n y=x\r\n while(y>0):\r\n bin.append(y%2)\r\n y= y>>1\r\n new = 0\r\n for i in range(len(bin)):\r\n new = (new<<1)+ bin[i]\r\n return new\r\n\r\ndef oper2(x):\r\n bin=[1]\r\n y=x\r\n while(y>0):\r\n bin.append(y%2)\r\n y= y>>1\r\n new = 0\r\n for i in range(len(bin)):\r\n new = (new<<1)+ bin[i]\r\n return new\r\n\r\ndef checkpossible(XX, targety):\r\n x= XX\r\n startx= []\r\n while(x>0):\r\n startx.append(str(x&1))\r\n x=x>>1\r\n startx.reverse()\r\n startx = \"\".join(startx)\r\n if(len(startx)>len(targety)):\r\n return False\r\n \r\n for i in range(len(targety)):\r\n match = True\r\n for j in range(len(startx)):\r\n if( i+j>len(targety)-1 or targety[i+j]!= startx[j]):\r\n match= False\r\n break\r\n if(match):\r\n if( (i==0 or targety[0:i].find(\"0\")==-1) and (targety[i+len(startx)::].find(\"0\")==-1) and (False==(i+len(startx)==len(targety) and startx[-1]==\"0\" )) ):\r\n return True\r\n return False\r\n\r\nX,Y = map(int,input().split())\r\nx,y= X,Y\r\n\r\nanswer = (x==y)\r\n\r\ntargety= []\r\nwhile(y>0):\r\n targety.append(str(y&1))\r\n y= y>>1\r\ntargety = \"\".join(reversed(targety))\r\n\r\nanswer = answer or checkpossible(X, targety) or checkpossible(oper1(X), targety) or checkpossible(oper2(X), targety)\r\nanswer = answer or checkpossible(oper1(oper1(X)), targety) or checkpossible(oper1(oper1(X)), targety) or checkpossible(oper2(oper1(X)),targety)\r\n\r\nif(answer):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n"}, {"source_code": "import re\r\nfrom collections import deque\r\nx, y = map(int, input().split())\r\nbin_x = bin(x)[2:]\r\nbin_y = bin(y)[2:]\r\n\r\nvisited = {}\r\nq = deque([bin_x])\r\nwhile len(q):\r\n new = q.popleft()\r\n if new in visited or len(new.strip(\"0\")) > len(bin_y):\r\n continue\r\n elif new == bin_y:\r\n print(\"YES\")\r\n quit()\r\n\r\n visited[new] = True\r\n q.append(new[::-1].strip(\"0\"))\r\n q.append((\"1\" + new[::-1]).strip(\"0\"))\r\nprint(\"NO\")\r\n"}, {"source_code": "import heapq;import sys;import math;from collections import deque;from bisect import bisect_left,bisect_right;I=sys.stdin.readline;II=lambda :int(I());IN=lambda x:map(int,x.split());FN=lambda x:map(float,x.split());L=lambda x:list(IN(x));M=1000000007;P=print;T=True;F=False\r\ndef cal(x,y):\r\n\twhile(x&1==1 and y&1==1):\r\n\t\t# print(x)\r\n\t\tx=x>>1;y=y>>1\r\n\tif(x&1==1):\r\n\t\treturn False\r\n\twhile(y&1==1):\r\n\t\ty=y>>1\r\n\twhile x>0 and y>0 and x&1==y&1:\r\n\t\tx=x>>1;y=y>>1\r\n\tif((x>0) or (y>0 and y&(y+1)!=0)):\r\n\t\treturn False\r\n\treturn True\r\ndef rev(x):\r\n\treturn int(bin(x)[:1:-1], 2)\r\n\r\nfor _ in range(1):\r\n\tx,y=IN(I())\r\n\tye=\"YES\";n=\"NO\"\r\n\tif(x==y):\r\n\t\tprint(ye)\r\n\t\tbreak\r\n\tif(y&1==0):\r\n\t\tprint(n)\r\n\t\tbreak\r\n\tt=x\r\n\twhile(t&1==0):\r\n\t\tt=t>>1\r\n\r\n\tif(t==x):\r\n\t\tres=cal(t,y) or cal(rev(t),y)\r\n\telse:\r\n\t\t# print(x)\r\n\t\tx=(x<<1)+1\r\n\t\t# print(x)\r\n\t\tres=cal(t,y) or cal(x,y) or cal(rev(t),y) or cal(rev(x),y)\r\n\tif(res):\r\n\t\tprint(ye)\r\n\telse:\r\n\t\tprint(n)"}, {"source_code": "x,y = [int(x) for x in input().split()]\r\nif x==y:\r\n print('YES')\r\n exit() \r\n# print(bin(x)) \r\n# print(bin(y)) \r\na,b= bin(x),bin(y)\r\na = a.replace('0b','')\r\nb = b.replace('0b','')\r\nif b[-1] == '0':\r\n print('NO')\r\n exit() \r\nif a in b and a.count('0') == b.count('0'):\r\n print('YES') \r\n exit()\r\nb = b[::-1]\r\nif a in b and a.count('0') == b.count('0'):\r\n print('YES')\r\n exit()\r\nwhile(a[-1]== '0'):\r\n a = a[:len(a)-1]\r\nif a in b and a.count('0') == b.count('0'):\r\n print('YES')\r\n exit()\r\nb = b[::-1] \r\nif a in b and a.count('0') == b.count('0'):\r\n print('YES')\r\nelse:\r\n print('NO') \r\n\r\n\r\n\r\n"}, {"source_code": "a=list(map(int,input().split()))\nif a[0]==a[1]:\n print(\"YES\")\n quit()\nxx = bin(a[0])[2:]\nyy = bin(a[1])[2:]\nfor q in [xx+'1',xx.strip('0')]:\n for l in range(len(yy) - len(q) + 1):\n r=len(yy) - len(q) - l\n if '1'*l+q+'1'*r==yy or '1'*l+q[::-1]+'1'*r==yy:\n print(\"YES\")\n quit()\nelse:\n print(\"NO\")\n\n \t\t\t\t \t \t\t \t\t\t\t\t \t \t\t\t"}, {"source_code": "x,y=map(int,input().split())\r\nif x==y:\r\n print(\"YES\")\r\nelse:\r\n s=bin(x)[2:]\r\n t=bin(y)[2:]\r\n for q in [s+\"1\",s.strip('0')]:\r\n for l in range(len(t)-len(q)+1):\r\n r=len(t)-len(q)-l \r\n if '1'*l + q + '1'*r == t or '1'*l + q[::-1] + '1'*r == t:\r\n print(\"Yes\")\r\n exit(0)\r\n print(\"No\")"}, {"source_code": "from collections import deque, defaultdict, Counter, OrderedDict\r\nimport math,os,sys,heapq,bisect,random\r\nfrom itertools import *\r\nfrom io import BytesIO, IOBase\r\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\r\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\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\ndef inpu(): return int(inp())\r\nM = 1000000007\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(how_much_noob_I_am):\r\n x,y = sep()\r\n q = deque()\r\n q.append(x)\r\n visited = set()\r\n ans = 0\r\n while(q):\r\n s = q.popleft()\r\n ans+=1\r\n if s==y:\r\n print(\"YES\")\r\n exit()\r\n p = bin(s).replace(\"0b\",\"\")+\"0\"\r\n p = p[::-1]\r\n if p not in visited:\r\n q.append(int(p,2))\r\n visited.add(p)\r\n p = bin(s).replace(\"0b\",\"\")+\"1\"\r\n p = p[::-1]\r\n if p not in visited:\r\n q.append(int(p,2))\r\n visited.add(p)\r\n if ans==10**4:\r\n break\r\n print(\"NO\")\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# endregion\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "import re\r\na, b = [int(i) for i in input().split()]\r\ndef binSlice(x):\r\n return bin(x)[2:]\r\n \r\ndef removeLeadingZeros(s):\r\n for k in range(len(s)):\r\n if s[k] != '0': break\r\n return s[k:]\r\n \r\ndef reversed(s):\r\n return s[::-1]\r\n \r\ntemp = reversed(binSlice(a))\r\ntemp2 = removeLeadingZeros(temp)\r\ncheck = re.fullmatch(f\"1*(1{temp}|{temp2}|{reversed(temp)}1|{reversed(temp2)})1*\", binSlice(b)) is not None\r\nprint(\"YES\" if check or a == b else \"NO\")\r\n"}, {"source_code": "#!/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\nsys.setrecursionlimit(1000000)\r\n\r\n# _INPUT = \"\"\"3165137368662540 34690334760256012\r\n# \"\"\"\r\n# sys.stdin = io.StringIO(_INPUT)\r\n\r\nINF = 10**10\r\n\r\nYES = 'YES'\r\nNO = 'NO'\r\n\r\ndef solve(X, Y):\r\n if X == Y:\r\n return 'YES'\r\n \r\n SX = bin(X)[2:]\r\n SY = bin(Y)[2:]\r\n\r\n seen = set()\r\n seen.add(SX)\r\n q = []\r\n q.append(SX)\r\n while q:\r\n s = q.pop()\r\n for s1 in [str(int(s[::-1])), (s+'1')[::-1]]:\r\n if s1 in seen or len(s1) > 100:\r\n continue\r\n if s1 == SY:\r\n return 'YES'\r\n seen.add(s1)\r\n q.append(s1)\r\n\r\n return 'NO'\r\n\r\nX, Y = map(int, input().split())\r\nprint(solve(X, Y))"}, {"source_code": "x, y = map(int, input().split())\r\ns = bin(y)[2:]\r\nt = bin(x)[2:]\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n for l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")\r\n"}, {"source_code": "x, y = map(int, input().split())\r\nif x == y:\r\n print(\"YES\")\r\nelse:\r\n a = \"\"\r\n f = 0\r\n for i in range(64, -1, -1):\r\n if x & (1 << i):\r\n f = 1\r\n a += '1'\r\n elif f:\r\n a += '0'\r\n b = a\r\n if b[-1] == '0':\r\n b += '1'\r\n\r\n while a[-1] == '0':\r\n a = a[:-1]\r\n\r\n\r\n def func():\r\n for i in range(64):\r\n for j in range(64):\r\n c = '1'*i + a + '1'*j\r\n d = '1'*i + b + '1'*j\r\n\r\n if len(c) < 64:\r\n n1 = int(c, 2)\r\n n2 = int(c[::-1], 2)\r\n if n1 == y or n2 == y:\r\n print(\"YES\")\r\n return 1\r\n if len(d) < 64:\r\n n1 = int(d, 2)\r\n n2 = int(d[::-1], 2)\r\n if n1 == y or n2 == y:\r\n print(\"YES\")\r\n return 1\r\n\r\n\r\n if not func():\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "# https://codeforces.com/problemset/problem/1618/F\n\n\ndef check(first, second):\n idx = second.find(first)\n if idx == -1:\n return False\n return '0' not in second[:idx] and '0' not in second[idx + len(first):]\n\n\ndef solve(x, y):\n if x == y:\n return True\n x_bin = bin(x)[2:]\n y_bin = bin(y)[2:]\n first = '1' + x_bin[::-1]\n second = x_bin[:x_bin.rfind('1') + 1]\n return any(check(s, y_bin) for s in [first, first[::-1], second, second[::-1]])\n\n\nif __name__ == '__main__':\n x, y = map(int, input().split())\n print('YES' if solve(x, y) else 'NO')\n"}, {"source_code": "import heapq;import sys;import math;from collections import deque;from bisect import bisect_left,bisect_right;I=sys.stdin.readline;II=lambda :int(I());IN=lambda x:map(int,x.split());FN=lambda x:map(float,x.split());L=lambda x:list(IN(x));M=1000000007;P=print;T=True;F=False\r\ndef cal(x,y):\r\n\twhile(x&1==1 and y&1==1):\r\n\t\t# print(x)\r\n\t\tx=x>>1;y=y>>1\r\n\tif(x&1==1):\r\n\t\treturn False\r\n\twhile(y&1==1):\r\n\t\ty=y>>1\r\n\twhile x>0 and y>0 and x&1==y&1:\r\n\t\tx=x>>1;y=y>>1\r\n\tif((x>0) or (y>0 and y&(y+1)!=0)):\r\n\t\treturn False\r\n\treturn True\r\ndef rev(x):\r\n\treturn int(bin(x)[:1:-1], 2)\r\n\r\nfor _ in range(1):\r\n\tx,y=IN(I())\r\n\tye=\"YES\";n=\"NO\"\r\n\tif(x==y):\r\n\t\tprint(ye)\r\n\t\tbreak\r\n\tif(y&1==0):\r\n\t\tprint(n)\r\n\t\tbreak\r\n\tt=x\r\n\twhile(t&1==0):\r\n\t\tt=t>>1\r\n\r\n\tif(t==x):\r\n\t\tres=cal(t,y) or cal(rev(t),y)\r\n\telse:\r\n\t\t# print(x)\r\n\t\tx=(x<<1)+1\r\n\t\t# print(x)\r\n\t\tres=cal(t,y) or cal(x,y) or cal(rev(t),y) or cal(rev(x),y)\r\n\tif(res):\r\n\t\tprint(ye)\r\n\telse:\r\n\t\tprint(n)"}, {"source_code": "a, b = list(map(int, input().strip().split()))\r\n\r\nstra = \"{0:b}\".format(a)\r\nstrb = \"{0:b}\".format(b)\r\n\r\n\r\nstra1 = stra+'1'\r\nstrar = stra[::-1].strip('0')\r\nstrar1 = stra1[::-1].strip('0')\r\n\r\nstrsa = [stra.strip('0'), stra1, strar, strar1]\r\n\r\nans = stra == strb\r\n\r\nfor string in strsa:\r\n pos = strb.find(string)\r\n if pos == -1:\r\n continue\r\n b = strb[:pos] + strb[pos+len(string):]\r\n if b == (\"1\"*len(b)):\r\n ans = True\r\n break\r\nprint(\"YES\" if ans else \"NO\")\r\n"}, {"source_code": "\r\nimport sys, collections, math, bisect, heapq, random, functools,io,os,copy\r\ninput = sys.stdin.readline\r\nout = sys.stdout.flush\r\ndef rep():\r\n a = list(map(int,input().split()))\r\n return a\r\n\r\ndef sep():\r\n a = list(input().split())\r\n return a\r\n\r\n\r\nclass UnionFind:\r\n def __init__(self, x) -> None:\r\n self.uf = [-1] * x\r\n\r\n def find(self, x):\r\n r = x\r\n while self.uf[x] >= 0:\r\n x = self.uf[x]\r\n\r\n while r != x:\r\n self.uf[r], r = x, self.uf[r]\r\n return x\r\n\r\n def union(self, x, y):\r\n ux, uy = self.find(x), self.find(y)\r\n if ux == uy:\r\n return\r\n if self.uf[ux] >= self.uf[uy]:\r\n self.uf[uy] += self.uf[ux]\r\n self.uf[ux] = uy\r\n else:\r\n self.uf[ux] += self.uf[uy]\r\n self.uf[uy] = ux\r\n return\r\n\r\n def __print__(self):\r\n return self.uf\r\n\r\n\r\ndef spfa(x,g,n):\r\n dis = [float('inf') for i in range(n)]\r\n dis[x] = 0\r\n state = [False for i in range(n)]\r\n state[x] = True\r\n queue = collections.deque()\r\n queue.append(x)\r\n while queue:\r\n cur = queue.popleft()\r\n state[cur] = False\r\n for next_ in g[cur]:\r\n if dis[next_] > dis[cur] + 1:\r\n dis[next_] = dis[cur] + 1\r\n if state[next_] == False:\r\n state[next_] = True\r\n queue.append(next_)\r\n return dis\r\n\r\n\r\ndef gcd(x,y):\r\n if y == 0:\r\n return x\r\n return gcd(y,x % y)\r\n\r\ndef getvalid(s):\r\n l = 0\r\n while l < len(s) and s[l] == '0':\r\n l += 1\r\n return l\r\n\r\n\r\ndef solve():\r\n x,y = map(int,input().split())\r\n tar = bin(y)[2:]\r\n vis = set()\r\n vis.add(bin(x)[2:])\r\n m = len(tar)\r\n queue = collections.deque()\r\n queue.append(bin(x)[2:])\r\n flag = 0\r\n while queue:\r\n cur = queue.popleft()\r\n if cur == tar:\r\n flag = 1\r\n break\r\n next1,next2 = cur + '0',cur + '1'\r\n next1 = next1[::-1]\r\n next2 = next2[::-1]\r\n pos1,pos2 = getvalid(next1),getvalid(next2)\r\n if pos1 == len(next1):\r\n next1 = '0'\r\n else:\r\n next1 = next1[pos1:]\r\n\r\n if pos2 == len(next2):\r\n next2 = '1'\r\n else:\r\n next2 = next2[pos2:]\r\n if next1 not in vis and len(next1) <= m:\r\n vis.add(next1)\r\n queue.append(next1)\r\n if next2 not in vis and len(next2) <= m:\r\n vis.add(next2)\r\n queue.append(next2)\r\n if flag:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()"}, {"source_code": "x, y = map(int, input().split())\r\n\r\ndef check(x, y):\r\n b1, b2 = bin(x)[2:], bin(y)[2:]\r\n n = len(b2)\r\n\r\n if y == x: return True\r\n\r\n c1 = (b1 + \"1\")[::-1]\r\n c2 = b1[::-1].lstrip(\"0\")\r\n c3 = c1[::-1]\r\n c4 = c2[::-1]\r\n\r\n for cand in [c1, c2, c3, c4]:\r\n m = len(cand)\r\n if m > n: continue\r\n \r\n for i in range(n - m + 1):\r\n if b2[i:i+m] == cand and b2[:i].count(\"0\") == 0 and b2[i+m:].count(\"0\") == 0:\r\n return True\r\n\r\n return False\r\n\r\nans = check(x, y)\r\nif ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "from collections import defaultdict, deque, Counter\r\nfrom sys import stdin, stdout\r\nfrom heapq import heappush, heappop\r\nimport math\r\nimport io\r\nimport os\r\nimport math\r\nimport bisect\r\n\r\n#?############################################################\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\n\r\n#?############################################################\r\n\r\n\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\n\r\n\r\n#?############################################################\r\n\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 return list(set(l))\r\n\r\n\r\n#?############################################################\r\n\r\ndef power(x, y, p):\r\n res = 1\r\n x = x % p\r\n if (x == 0):\r\n return 0\r\n while (y > 0):\r\n if ((y & 1) == 1):\r\n res = (res * x) % p\r\n y = y >> 1\r\n x = (x * x) % p\r\n return res\r\n\r\n#?############################################################\r\n\r\n\r\ndef sieve(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\n\r\n\r\n#?############################################################\r\n\r\ndef digits(n):\r\n c = 0\r\n while (n > 0):\r\n n //= 10\r\n c += 1\r\n return c\r\n\r\n#?############################################################\r\n\r\n\r\ndef ceil(n, x):\r\n if (n % x == 0):\r\n return n//x\r\n return n//x+1\r\n\r\n#?############################################################\r\n\r\n\r\ndef mapin():\r\n return map(int, input().split())\r\n\r\n#?############################################################\r\n\r\ndef check(x, y):\r\n \r\n if(len(x)>len(y)):\r\n return 0\r\n else:\r\n z = len(y)-len(x)\r\n for i in range(0, z+1):\r\n u = i\r\n v = z-i\r\n x1 = \"1\"*u + x + \"1\"*v\r\n if(x1 == y):\r\n return 1\r\n\r\n return 0\r\n\r\n\r\n\r\n# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n# python3 15.pyop\r\n\r\na, b = mapin()\r\nif(b%2 == 0 and a!=b):\r\n print(\"NO\")\r\n exit(0)\r\na, b = bin(a)[2:], bin(b)[2:]\r\n\r\nc = a[::-1]\r\nk = 0\r\nfor i in range(len(c)):\r\n if(c[i] == '1'):\r\n k = i\r\n break\r\nc = c[k:]\r\nc = c[::-1]\r\n#a->b\r\n#c->b\r\na1 = a[::-1]\r\nc1 = c[::-1]\r\nif(check(c, b) or check(a, b) or check(a1, b) or check(c1, b)):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "# Ripped from tutorial\r\na, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n for l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")"}, {"source_code": "import sys\r\nimport math\r\nfrom math import factorial, inf, gcd, sqrt\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\nfrom sys import stdin, stdout\r\n\r\nsys.setrecursionlimit(10**5)\r\n\r\n\r\ndef inp():\r\n return stdin.readline().strip()\r\n\r\n\r\ndef iinp():\r\n return int(inp())\r\n\r\n\r\ndef mp():\r\n return map(int, inp().split())\r\n\r\n\r\ndef lmp():\r\n return list(mp())\r\n\r\n\r\n# t = iinp()\r\nt = 1\r\nfor ii in range(t):\r\n x, y = mp()\r\n if x == y:\r\n print('YES')\r\n continue\r\n if x == 0 or y == 0:\r\n print('NO')\r\n continue\r\n x = format(x, 'b')\r\n y = format(y, 'b')\r\n if all(i == '1' for i in x):\r\n print('YES' if all(i == '1' for i in y) else 'NO')\r\n continue\r\n x0 = []\r\n for i, j in enumerate(x):\r\n if j == '0':\r\n x0.append(i)\r\n y0 = []\r\n for i, j in enumerate(y):\r\n if j == '0':\r\n y0.append(i)\r\n y1 = []\r\n for i in range(len(y)):\r\n if y[len(y) - 1 - i] == '0':\r\n y1.append(i)\r\n m, n = len(x0), len(y0)\r\n t = x[::-1].find('1')\r\n if m != n and m != n + t:\r\n print('NO')\r\n continue\r\n cy0 = [i - y0[0] + x0[0] for i in y0]\r\n cy1 = [i - y1[0] + x0[0] for i in y1]\r\n if t == len(x0):\r\n print('YES' if len(y) >= len(x) - t and all(i == '1'\r\n for i in y) else 'NO')\r\n elif t == 0:\r\n print('YES' if ((cy0 == x0 and y0[0] >= x0[0]) or (\r\n cy1 == x0 and y1[0] >= x0[0])) else 'NO')\r\n else:\r\n if m == n:\r\n print('YES' if ((cy0 == x0 and y0[0] >= x0[0] and y1[0] > 0) or (\r\n cy1 == x0 and y1[0] >= x0[0] and y0[0] > 0)) else 'NO')\r\n else:\r\n print('YES' if ((cy0 == x0[:n] and y0[0] >= x0[0]) or (\r\n cy1 == x0[:n] and y1[0] >= x0[0])) else 'NO')\r\n"}, {"source_code": "x, y = [int(i) for i in input().split(\" \")]\r\nans = \"NO\"\r\nif x == y:\r\n print(\"YES\")\r\n exit(0)\r\nbin_x, bin_y = str(bin(x))[2:], str(bin(y))[2:]\r\ntry:\r\n i1 = bin_y.index(bin_x+'1')\r\n re = set(bin_y[:i1]+bin_y[i1+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\ntry:\r\n i2 = bin_y.index((bin_x+'1')[::-1])\r\n re = set(bin_y[:i2]+bin_y[i2+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\nbin_x = bin_x.strip('0')\r\ntry:\r\n i3 = bin_y.index(bin_x)\r\n re = set(bin_y[:i3]+bin_y[i3+len(bin_x):])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\ntry:\r\n i4 = bin_y.index(bin_x[::-1])\r\n re = set(bin_y[:i4]+bin_y[i4+len(bin_x):])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\nprint(ans)\r\n\r\n"}, {"source_code": "import sys,math,itertools\r\nfrom collections import Counter,deque,defaultdict\r\nfrom bisect import bisect_left,bisect_right \r\nfrom heapq import heappop,heappush,heapify\r\nmod = 10**9+7\r\nINF = float('inf')\r\ndef inp(): return int(sys.stdin.readline())\r\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\r\ndef inpl_1(): return list(map(lambda x:int(x)-1, sys.stdin.readline().split()))\r\ndef inps(): return sys.stdin.readline()\r\ndef inpsl(x): tmp = sys.stdin.readline(); return list(tmp[:x])\r\ndef err(x): print(x); exit()\r\n\r\nx,y = inpl()\r\nx = bin(x); x = x[2:]\r\ny = bin(y); y = y[2:]\r\nln = len(y)\r\n\r\nseen = set()\r\nq = deque([x])\r\nwhile q:\r\n num = q.popleft()\r\n if num == y:\r\n err('YES')\r\n for i in ['0','1']:\r\n now = num + i\r\n now = int(now[::-1],2)\r\n now = bin(now)\r\n now = now[2:]\r\n if now == y:\r\n err('YES')\r\n if len(now) > ln or now in seen:\r\n continue\r\n seen.add(now)\r\n q.append(now)\r\nprint('NO')"}, {"source_code": "def contain(a, b):\r\n if not '0' in b:\r\n if not '0' in a:\r\n if len(a) <= len(b):\r\n return True\r\n return False\r\n return False\r\n if not '0' in a:\r\n return False\r\n listA = list(a)\r\n listB = list(b)\r\n Aleft = 0\r\n Aright = 0\r\n Bleft = 0\r\n Bright = 0\r\n\r\n while listA[0] == '1':\r\n listA.remove('1')\r\n Aleft += 1\r\n while listA[-1] == '1':\r\n listA.pop()\r\n Aright += 1\r\n while listB[0] == '1':\r\n listB.remove('1')\r\n Bleft += 1\r\n while listB[-1] == '1':\r\n listB.pop()\r\n Bright += 1\r\n\r\n reA = listA.copy()\r\n reA.reverse()\r\n\r\n return ((listA == listB) and (Aleft <= Bleft) and (Aright <= Bright)) or ((reA == listB) and (Aright <= Bleft) and (Aleft <= Bright))\r\n\r\ndef find(x, y):\r\n a = bin(x)[2:]\r\n b = bin(y)[2:]\r\n if a == b:\r\n return True\r\n if a[-1] == '1':\r\n return contain(a, b)\r\n temp = list(a)\r\n while temp[-1] == '0':\r\n temp.pop()\r\n aa = ''.join(temp)\r\n aaa = a + '1'\r\n return contain(aa, b) or contain(aaa, b)\r\n\r\nline = input().split( )\r\nx = int(line[0])\r\ny = int(line[1])\r\nif find(x, y):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "a, b = map(int, input().split())\r\na = str(bin(a)[2:])\r\nb = str(bin(b)[2:])\r\nif b[-1] == '0' and a != b:\r\n print('NO')\r\n exit()\r\nelif a == b:\r\n print(\"YES\")\r\n exit()\r\nx1 = ''\r\nflag = False\r\nfor el in a[::-1]:\r\n if el == '1':\r\n flag = True\r\n x1 += el\r\n if el == '0':\r\n if flag:\r\n x1 += el\r\nx2 = '1' + a[::-1]\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nx1 = x1[::-1]\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nx1 = x2\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nx1 = x1[::-1]\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nprint(\"NO\")"}, {"source_code": "\r\ndef solve(x, y):\r\n if x == y:\r\n return \"YES\"\r\n\r\n ax = bin(x)[2:]\r\n ay = bin(y)[2:]\r\n \r\n for s in [ax+'1', ax.strip('0'), ax[::-1]+'1', ax[::-1].strip('0')]:\r\n if s in ay:\r\n aay = ay.replace(s, '')\r\n if aay.count('0') == 0:\r\n return \"YES\"\r\n \r\n return \"NO\"\r\n\r\nx, y = map(int, input().split())\r\nprint(solve(x, y))"}, {"source_code": "a,b = map(int, input().split())\r\nsus = bin(int(bin(a)[2:][::-1],2))[2:]\r\nsussy = (bin(a)[2:]+\"1\")[::-1]\r\n\r\nbb = bin(b)[2:]\r\nrealsus = sus[::-1]\r\nrealsussy = sussy[::-1]\r\n\r\namogus = bin(b)[2:]\r\ngreat = True\r\npos = -1\r\nleng = 0\r\nfor i in [sus, sussy, realsus, realsussy]:\r\n lmao = False\r\n pos = amogus.find(i)\r\n leng = len(i)\r\n \r\n if pos == -1:\r\n lmao = True\r\n \r\n if pos != -1:\r\n c = bb[0:pos] + bb[pos+leng:]\r\n for i in range(len(c)):\r\n if c[i] != \"1\":\r\n lmao = True\r\n if lmao == False:\r\n great = False\r\n \r\n\r\nprint(\"YES\" if not great or a==b else \"NO\")\r\n\r\n\r\n"}, {"source_code": "maxx = 10**20\n\ndef binary(x):\n\tans = []\n\twhile x:\n\t\tans.append(str(x%2))\n\t\tx /= 2\n\treturn ans[::-1]\n\ndef find(x):\n\tbin0 = binary(x)\n\tbin1 = bin0+['0']\n\tbin2 = bin0+['1']\n\tbin1 = bin1[::-1]\n\tbin2 = bin2[::-1]\n\tbin1 = int(\"\".join(bin1), 2)\n\tbin2 = int(\"\".join(bin2), 2)\n\treturn bin1, bin2 \n\nx, y = [int(x) for x in raw_input().split()]\nvisited = set()\nqueue = [x]\nwhile queue:\n\tu = queue.pop()\n\tif u in visited or u > maxx:\n\t\tcontinue\n\tvisited.add(u)\n\ta, b = find(u)\n\tqueue.append(a)\n\tqueue.append(b)\nif y in visited:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "#import io,os\n#input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\nfrom collections import deque \n\n\n\n\n\ndef main(t):\n\n x, y = map(int,input().split())\n sx, sy = bin(x)[2:],bin(y)[2:]\n\n\n\n dic = {}\n queue = deque()\n queue.append(sx)\n dic[sx] = 1\n\n i = len(sx)-1\n while i>=0 and sx[i]=='0': i -= 1\n queue.append(sx[:i+1])\n dic[sx[:i+1]] = 1\n\n\n# print(dic)\n \n \n\n while queue:\n curr = queue.popleft()\n nextcurr1 = curr[::-1]\n i = 0\n \n while nextcurr1[i]=='0': i += 1\n nextcurr1 = nextcurr1[i:]\n if nextcurr1 not in dic:\n dic[nextcurr1] = 1\n queue.append(nextcurr1)\n nextcurr2 = (curr + '1')[::-1]\n if nextcurr2 not in dic:\n dic[nextcurr2] = 1\n if len(nextcurr2) <= len(sy): queue.append(nextcurr2)\n\n\n # print(dic)\n\n if sy in dic: \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\nT = 1 #int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}, {"source_code": "import sys\r\nfrom sys import stdin\r\nimport math\r\n\r\ndef rev(x):\r\n\r\n ret = 0\r\n while x:\r\n ret *= 2\r\n ret += x % 2\r\n x //= 2\r\n return ret\r\n\r\ndef zcnt(x):\r\n ret = 0\r\n for i in x:\r\n if i == \"0\":\r\n ret += 1\r\n return ret\r\n\r\ndef match(x,y): #x in y?\r\n\r\n if zcnt(x) != zcnt(y):\r\n return False\r\n return x in y\r\n\r\ndef strev(S):\r\n\r\n ret = []\r\n for i in S:\r\n ret.append(i)\r\n ret.reverse()\r\n return \"\".join(ret)\r\n \r\n\r\ntt = 1 #int(stdin.readline())\r\n\r\nANS = []\r\n\r\nfor loop in range(tt):\r\n\r\n x,y = map(int,stdin.readline().split())\r\n\r\n ans = \"NO\"\r\n if x == y:\r\n ans = \"YES\"\r\n\r\n X = format(x*2+1,\"b\")\r\n X2 = strev(X)\r\n \r\n RX = format(rev(x),\"b\")\r\n RX2 = strev(RX)\r\n Y = format(y,\"b\")\r\n\r\n #print (X,RX,X2,RX2,Y)\r\n\r\n if match(X,Y) or match(RX,Y) or match(X2,Y) or match(RX2,Y):\r\n ans = \"YES\"\r\n ANS.append(ans)\r\n \r\n\r\nprint (\"\\n\".join(ANS))"}, {"source_code": "#Fast I/O\r\nimport sys,os\r\nimport math\r\n# To enable the file I/O i the below 2 lines are uncommented.\r\n# read from in.txt if uncommented\r\nif os.path.exists('in.txt'): sys.stdin=open('in.txt','r')\r\n# will print on Console if file I/O is not activated\r\n#if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')\r\n \r\n# inputs template\r\nfrom io import BytesIO, IOBase\r\nfrom heapq import *\r\nfrom bisect import *\r\nfrom collections import *\r\n\r\ndef check(x,y):\r\n if x == y : return \"YES\"\r\n for p in [x+'1',x.strip('0')]:\r\n for l in range(len(y)-len(p)+1):\r\n r = len(y)-len(p)-l\r\n if \"1\"*l + p + \"1\"*r == y or \"1\"*l + p[::-1] + \"1\"*r == y:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\ndef main():\r\n x,y = MI()\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n print(check(x,y))\r\n\r\n\r\n# Sample Inputs/Output \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\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n#for array of integers\r\ndef MI():return (map(int,input().split()))\r\ndef mi():return int(input())\r\n\r\n# endregion\r\n#for fast output, always take string\r\ndef outP(var): sys.stdout.write(str(var)+'\\n') \r\n# end of any user-defined functions\r\n \r\nMOD=10**9+7\r\nmod=998244353\r\n \r\n# main functions for execution of the program.\r\n \r\nif __name__ == '__main__': \r\n #This doesn't works here but works wonders when submitted on CodeChef or CodeForces \r\n main()\r\n"}, {"source_code": "from sys import stdin\r\ninp = stdin.readline\r\n\r\na, b = map(int, inp().split())\r\n\r\nbinA = str(bin(a))[2:]\r\nbinB = str(bin(b))[2:]\r\n\r\nc1 = binA.strip(\"0\")\r\nc2 = binA + \"1\"\r\n\r\nx = binB.find(c2)\r\ny = binB.find(c2[::-1])\r\ndone = 0\r\n\r\nif x > -1:\r\n if (binB[:x] + binB[x+len(c2):]).find(\"0\") == -1:\r\n done = 1\r\n\r\nif y > -1:\r\n if (binB[:y] + binB[y+len(c2):]).find(\"0\") == -1:\r\n done = 1\r\n\r\nif a == b:\r\n done = 1\r\n\r\nif not done:\r\n x = binB.find(c1)\r\n y = binB.find(c1[::-1])\r\n if x > -1:\r\n if (binB[:x] + binB[x + len(c1):]).find(\"0\") == -1:\r\n done = 1\r\n\r\n if y > -1:\r\n if (binB[:y] + binB[y + len(c1):]).find(\"0\") == -1:\r\n done = 1\r\n\r\nif done:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "x,y=[str(bin(int(i)))[2:] for i in input().split()]\r\n\r\nif x==y:\r\n print('YES')\r\nelif y[-1]=='0':\r\n print('NO')\r\nelse:\r\n x+='1'\r\n if (y.find(x)!=-1 or y.find(x[::-1])!=-1) and y.count('1')-x.count('1')==len(y)-len(x):\r\n print('YES')\r\n else:\r\n x=x[:-1]\r\n while x[-1]=='0':\r\n x=x[:-1]\r\n print('YES') if (y.find(x)!=-1 or y.find(x[::-1])!=-1) and y.count('1')-x.count('1')==len(y)-len(x) else print('NO')"}, {"source_code": "import array\r\nimport 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 UnionFind():\r\n parents = []\r\n sizes = []\r\n count = 0\r\n\r\n def __init__(self, n):\r\n self.count = n\r\n self.parents = [i for i in range(n)]\r\n self.sizes = [1 for i in range(n)]\r\n\r\n def find(self, i):\r\n if self.parents[i] == i:\r\n return i\r\n else:\r\n self.parents[i] = self.find(self.parents[i])\r\n return self.parents[i]\r\n\r\n def unite(self, i, j):\r\n root_i = self.find(i)\r\n root_j = self.find(j)\r\n if root_i == root_j:\r\n return\r\n elif root_i < root_j:\r\n self.parents[root_j] = root_i\r\n self.sizes[root_i] += self.sizes[root_j]\r\n else:\r\n self.parents[root_i] = root_j\r\n self.sizes[root_j] += self.sizes[root_i]\r\n\r\n def same(self, i, j):\r\n return self.find(i) == self.find(j)\r\n\r\n def size(self, i):\r\n return self.sizes[self.find(i)]\r\n\r\n def group_count(self):\r\n return len(set(self.find(i) for i in range(self.count)))\r\n\r\n def answer(self, extra, p, q):\r\n dic = collections.Counter()\r\n for q in range(n):\r\n dic[self.find(q)] = self.size(q)\r\n hq = list(dic.values())\r\n heapq._heapify_max(hq)\r\n ans = -1\r\n for z in range(extra + 1):\r\n if hq:\r\n ans += heapq._heappop_max(hq)\r\n else:\r\n break\r\n return ans\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################################ ###########################################\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###########################################################################################\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\ndef solve(source):\r\n x = bin_y.find(source)\r\n arr1 = []\r\n arr2 = []\r\n for i in range(len(bin_y)):\r\n if i < x:\r\n arr1.append(bin_y[i])\r\n elif i > x + len(source) - 1:\r\n arr2.append(bin_y[i])\r\n a = arr1.count(\"1\")\r\n b = arr2.count(\"1\")\r\n if a == len(arr1) and b == len(arr2) and bin_y[-1] != \"0\":\r\n return True\r\n else:\r\n return False\r\nx, y = map_inp(int)\r\nbin_x, bin_y = bin(x)[2:], bin(y)[2:]\r\ntemp = bin_x[::-1].lstrip(\"0\")\r\ntemp1 = bin_x.rstrip(\"0\")\r\ntemp2 = bin_x[::-1]\r\n# print(bin_x)\r\n# print(bin_y)\r\n# print(temp)\r\n# print(temp1)\r\nif bin_x == bin_y or temp == bin_y or temp1 == bin_y:\r\n print(\"YES\")\r\nelif bin_x in bin_y:\r\n if solve(bin_x):\r\n print(\"YES\")\r\n elif temp in bin_y:\r\n if solve(temp):\r\n print(\"YES\")\r\n elif temp1 in bin_y:\r\n if solve(temp1):\r\n print(\"YES\")\r\n elif temp2 in bin_y:\r\n if solve(temp2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\nelif temp in bin_y:\r\n if solve(temp):\r\n print(\"YES\")\r\n elif temp1 in bin_y:\r\n if solve(temp1):\r\n print(\"YES\")\r\n elif temp2 in bin_y:\r\n if solve(temp2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\nelif temp1 in bin_y:\r\n if solve(temp1):\r\n print(\"YES\")\r\n elif temp2 in bin_y:\r\n if solve(temp2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\nelif temp2 in bin_y:\r\n if solve(temp2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "#!/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\nsys.setrecursionlimit(1000000)\r\n\r\n# _INPUT = \"\"\"8935891487501725 71487131900013807\r\n# \"\"\"\r\n# sys.stdin = io.StringIO(_INPUT)\r\n\r\nINF = 10**10\r\n\r\nYES = 'YES'\r\nNO = 'NO'\r\n\r\ndef dfs(s, SY):\r\n if s == SY:\r\n return True\r\n n = int(s)\r\n if n in ng:\r\n return False\r\n if len(s) > 100:\r\n return False\r\n ng.add(n)\r\n # print(n)\r\n for s1 in [str(int(s[::-1])), (s+'1')[::-1]]:\r\n if s1 in ng:\r\n continue\r\n if dfs(s1, SY):\r\n return True\r\n return False\r\n\r\n\r\nng = set()\r\n\r\ndef solve(X, Y):\r\n if X == Y:\r\n return 'YES'\r\n \r\n SX = bin(X)[2:]\r\n SY = bin(Y)[2:]\r\n\r\n if dfs(SX, SY):\r\n return 'YES'\r\n\r\n return 'NO'\r\n\r\nX, Y = map(int, input().split())\r\nprint(solve(X, Y))"}, {"source_code": "a, b = map(int,input().split())\r\n\r\nx = bin(a)[2:]\r\ny = bin(b)[2:]\r\ndef add0(s):\r\n while s[-1] == '0':\r\n s = s[0:len(s)-1]\r\n return s[::-1]\r\ndef add1(s):\r\n s += \"1\"\r\n return s[::-1]\r\n\r\nv = []\r\ncheck = []\r\n\r\nv.append(x)\r\ncheck.append(x)\r\nans = False\r\n\r\nwhile len(v) > 0:\r\n t = v[0]\r\n del(v[0])\r\n if t == y:\r\n ans = True\r\n break\r\n else:\r\n q = add0(t)\r\n if len(q) < 65 and q not in check:\r\n v.append(q)\r\n check.append(q)\r\n q = add1(t)\r\n if len(q) < 65 and q not in check:\r\n v.append(q)\r\n check.append(q)\r\nif ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "from collections import deque, defaultdict, Counter, OrderedDict\r\nimport math,os,sys,heapq,bisect,random\r\nfrom itertools import *\r\nfrom io import BytesIO, IOBase\r\ndef inp(): return sys.stdin.readline().rstrip(\"\\r\\n\") # for fast input\r\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\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\ndef inpu(): return int(inp())\r\nM = 1000000007\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(how_much_noob_I_am):\r\n x,y = sep()\r\n q = deque()\r\n q.append(x)\r\n visited = set()\r\n ans = 0\r\n while(q):\r\n s = q.popleft()\r\n ans+=1\r\n if s==y:\r\n print(\"YES\")\r\n exit()\r\n p = bin(s).replace(\"0b\",\"\")+\"0\"\r\n p = p[::-1]\r\n if p not in visited:\r\n q.append(int(p,2))\r\n visited.add(p)\r\n p = bin(s).replace(\"0b\",\"\")+\"1\"\r\n p = p[::-1]\r\n if p not in visited:\r\n q.append(int(p,2))\r\n visited.add(p)\r\n if ans==10**4:\r\n break\r\n print(\"NO\")\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# endregion\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "x,y=[str(bin(int(i)))[2:] for i in input().split()]\r\n\r\nif x==y:\r\n print('YES')\r\nelif y[-1]=='0':\r\n print('NO')\r\nelse:\r\n x+='1'\r\n if (y.find(x)!=-1 or y.find(x[::-1])!=-1) and y.count('1')-x.count('1')==len(y)-len(x):\r\n print('YES')\r\n else:\r\n x=x[:-1]\r\n while x[-1]=='0':\r\n x=x[:-1]\r\n print('YES') if (y.find(x)!=-1 or y.find(x[::-1])!=-1) and y.count('1')-x.count('1')==len(y)-len(x) else print('NO')"}, {"source_code": "def work(a,b,l,r):\r\n for i in range(max(0,r-len(a)),min(l+1,len(b)-len(a))+1):\r\n if a==b[i:i+len(a)]:\r\n print(\"YES\");\r\n exit(0)\r\n\r\n[x,y]=map(int,input().split())\r\na,b,c=[1],[],[]\r\nwhile (x):\r\n a.append(x%2)\r\n c.append(x%2)\r\n x//=2\r\nwhile (y):\r\n b.append(y%2)\r\n y//=2\r\n\r\nif c==b:\r\n print(\"YES\")\r\n exit(0)\r\nc.reverse()\r\nwhile c[-1]==0:\r\n c.pop()\r\n\r\nl=-1\r\nr=len(b)\r\nwhile l+1=0 and b[r-1]==1:\r\n r-=1\r\n\r\nwork(a,b,l,r)\r\na.reverse()\r\nwork(a,b,l,r)\r\nwork(c,b,l,r)\r\nc.reverse()\r\nwork(c,b,l,r)\r\nprint(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n for l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")\r\n"}, {"source_code": "x,y = map(int, input().split())\r\nif x == y:\r\n print(\"YES\")\r\nelse:\r\n # while y%4 == 3:\r\n # y = (y-1)//2\r\n # if y%2 == 1:\r\n # y = int(bin(y)[2:][::-1],2)\r\n # while y%4 == 3:\r\n # y = (y-1)//2\r\n bx1 = int(bin(x)[2:][::-1],2)\r\n bx2 = int(bin(bx1)[2:][::-1],2)\r\n bx3 = int(bin(x)[2:]+\"1\",2)\r\n bx4 = int(bin(bx3)[2:][::-1],2)\r\n bx1 = bin(bx1)[2:]\r\n bx2 = bin(bx2)[2:]\r\n bx3 = bin(bx3)[2:]\r\n bx4 = bin(bx4)[2:]\r\n # print(bin(y))\r\n # print(\"BXi\")\r\n # print(bx1)\r\n # print(bx2)\r\n # print(bx3)\r\n # print(bx4)\r\n\r\n found = False\r\n if not found and bx1 in bin(y)[2:]:\r\n temp = bin(y)[2:]\r\n temp = temp.replace(bx1,\"\")\r\n found =True\r\n for char in temp:\r\n if char !=\"1\":\r\n found = False\r\n if not found and bx2 in bin(y)[2:]:\r\n temp = bin(y)[2:]\r\n temp = temp.replace(bx2,\"\")\r\n found =True\r\n for char in temp:\r\n if char !=\"1\":\r\n found = False\r\n if not found and bx3 in bin(y)[2:]:\r\n temp = bin(y)[2:]\r\n temp = temp.replace(bx3,\"\")\r\n found = True\r\n for char in temp:\r\n if char != \"1\":\r\n found = False\r\n if not found and bx4 in bin(y)[2:]:\r\n temp = bin(y)[2:]\r\n temp = temp.replace(bx4,\"\")\r\n found =True\r\n for char in temp:\r\n if char !=\"1\":\r\n found = False\r\n if found:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n"}, {"source_code": "def f(s,y):\r\n\tif(s in y):\r\n\t\ti=y.index(s)\r\n\t\tfor j in range(0,i):\r\n\t\t\tif(y[j]!=\"1\"):\r\n\t\t\t\treturn False\r\n\t\tfor j in range(i+len(s),len(y)):\r\n\t\t\tif(y[j]!=\"1\"):\r\n\t\t\t\treturn False\r\n\t\treturn True\r\n\treturn False\r\nx,y=map(int,input().split())\r\nx=bin(x)[2:]\r\ny=bin(y)[2:]\r\ni=0\r\nj=x.rfind(\"1\")\r\ns=x[i:j+1]\r\ns1=s[::-1]\r\ns3=x+\"1\"\r\ns4=s3[::-1]\r\n# print(x)\r\n# print(y)\r\n# print(s,s1,s3,s4)\r\nif(x==y or f(s,y) or f(s1,y) or f(s3,y) or f(s4,y)):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")"}, {"source_code": "#!/usr/bin/env python3\n\nfrom collections import deque\nimport functools\nimport itertools\nimport math\n\ndef main():\n s, t = [f\"{int(x):b}\" for x in input().split()]\n\n vis = {s}\n q = deque([s])\n while q:\n x = q.pop()\n\n y = x[::-1].lstrip(\"0\")\n z = (x + \"1\")[::-1].lstrip(\"0\")\n for i in [y, z]:\n # No actually 60 should be fine\n if len(i) <= 60 and i not in vis:\n vis.add(i)\n q.append(i)\n if t in vis: print(\"YES\")\n else: print(\"NO\")\n\nif __name__ == \"__main__\": main()\n"}, {"source_code": "def sol(t, s):\r\n pos = t.find(s)\r\n while (pos!=-1):\r\n x = t[:pos]\r\n y = t[pos+len(s):]\r\n if ('0' not in x) and ('0' not in y):\r\n return True\r\n pos = t.find(s, pos+1)\r\n return False\r\n\r\ndef solve():\r\n [x, y] = [int(a) for a in input().split()]\r\n if x==y:\r\n print('YES')\r\n return\r\n s = list(bin(x)[2:])\r\n t = bin(y)[2:]\r\n s1 = list(bin(x)[2:])\r\n \r\n while s1[-1]=='0': s1.pop()\r\n s2 = None\r\n if s[-1]=='0':\r\n s2=s\r\n s2.append('1')\r\n if sol(t, ''.join(s1)):\r\n print('YES')\r\n return\r\n if s2 is not None and sol(t, ''.join(s2)):\r\n print('YES')\r\n return\r\n s3 = [x for x in s1]\r\n s3.reverse()\r\n if s2 is not None: s4 = [x for x in s2]\r\n else: s4 = None\r\n if sol(t, ''.join(s3)):\r\n print('YES')\r\n return\r\n if s4 is not None: s4.reverse()\r\n if s4 is not None and sol(t, ''.join(s4)):\r\n print('YES')\r\n return\r\n \r\n\r\n \r\n print('NO')\r\n \r\n\r\nsolve()\r\n \r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n"}, {"source_code": "# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n# |AUTHOR|\r\n# | |\r\n# | |\r\n# | |\r\n# | | \r\n# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n# MUHAMMAD AMMAR\r\n# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\nimport sys as system_break\r\ndef Commonfinder(n,m):\r\n if type(n)!=set:\r\n n={n}\r\n if type(m)!=set:\r\n m={m}\r\n Common_in_both=n|m\r\n return Common_in_both\r\nimport math as m\r\nimport re as MATCHING_DEVICE\r\nInput= input()\r\nInput= Input.split()\r\nablist =[]\r\nfor i in range(len(Input)):\r\n ablist.append( int( Input[i] ))\r\na=ablist[0];b=ablist[1]\r\nBinofa=bin(a)[2:]\r\nBinofb=bin(b)[2:]\r\nExtended_A=Binofa+'1'\r\nStriped_A=Binofa.rstrip('0')\r\nFirstCF=Commonfinder(Extended_A,Striped_A)\r\nSecondCF=Commonfinder(FirstCF,Extended_A[::-1])\r\nFinalCF=Commonfinder(SecondCF,Striped_A[::-1])\r\nFormated_Str=f'1*({Extended_A}|{Striped_A}|{Extended_A[::-1]}|{Striped_A[::-1]})1*'\r\nif len(FinalCF)==1:\r\n FinalCF=list(FinalCF)\r\n FinalCF=FinalCF[0]\r\n if (MATCHING_DEVICE.fullmatch(FinalCF,Binofb)) or Binofa ==Binofb:\r\n print('YES')\r\nelse:\r\n answer=''\r\n #FinalCF=list(FinalCF)\r\n if a==b or MATCHING_DEVICE.fullmatch(Formated_Str, Binofb):\r\n print('YES')\r\n else:\r\n print('NO')"}, {"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\n\r\ndef rev(n):\r\n\treturn int((bin(n)[2:])[::-1], 2)\r\n\r\nx,y = I()\r\nx1 = x\r\nwhile x1%2==0:\r\n\tx1//=2\r\nif y==x or y==x1 or y==rev(x) or y==rev(x1):\r\n\tprint 'YES'\r\n\texit()\r\nok = False\r\ndone = False\r\nx2 = x\r\nwhile not done:\r\n\txr = rev(x2)\r\n\twhile xry and rev(x2)>y:\r\n\t\tbreak\r\n\t\t\r\nif ok:\r\n\tprint 'YES'\r\n\texit()\r\n\t\r\ndone = False\r\nx2 = x1\r\nwhile not done:\r\n\txr = rev(x2)\r\n\twhile xry and rev(x2)>y:\r\n\t\tbreak\r\n\t\t\r\nxr1 = rev(x)\r\ndone = False\r\nx2 = xr1\r\nwhile not done:\r\n\txr = rev(x2)\r\n\twhile xry and rev(x2)>y:\r\n\t\tbreak\r\n\t\t\r\n\t\t\r\nxr2 = rev(x1)\r\ndone = False\r\nx2 = xr2\r\nwhile not done:\r\n\txr = rev(x2)\r\n\twhile xry and rev(x2)>y:\r\n\t\tbreak\r\n\t\t\r\n# print bin(x)\r\n# print bin(x1)\r\n# print bin(rev(x))\r\n# print bin(rev(x1))\r\n# print \r\n# print bin(y)\r\n# print\r\n\t\t\r\nif ok:\r\n\tprint 'YES'\r\nelse:\r\n\tprint 'NO'\r\n\t"}, {"source_code": "import math\r\n\r\n\r\ndef solve():\r\n x, y = input().split()\r\n x = int(x)\r\n y = int(y)\r\n\r\n if x == y:\r\n print('YES')\r\n return\r\n\r\n x = str(bin(x))[2:]\r\n y = str(bin(y))[2:]\r\n\r\n for q in [x + '1', x.strip('0')]:\r\n for l in range(len(y) - len(q) + 1):\r\n r = len(y) - len(q) - l\r\n if '1' * l + q + '1' * r == y or '1' * l + q[::-1] + '1' * r == y:\r\n print('YES')\r\n return\r\n\r\n print('No')\r\n\r\n\r\nif __name__ == '__main__':\r\n #T = int(input())\r\n T = 1\r\n while T > 0:\r\n T -= 1\r\n solve()\r\n"}, {"source_code": "a, b = map(int, input().split())\r\na = bin(a)[2:]\r\nb = bin(b)[2:]\r\n\r\ndef transit(s1, s2):\r\n a1 = s1.split(\"0\")\r\n a2 = s2.split(\"0\")\r\n sl1, sr1 = a1[0], a1[-1]\r\n sl2, sr2 = a2[0], a2[-1]\r\n\r\n if len(sl1) <= len(sl2) and len(sr1) <= len(sr2):\r\n if s1.strip(\"1\") == s2.strip(\"1\"):\r\n return True\r\n return False\r\n \r\n \r\nif a == b:\r\n print(\"yEs\")\r\nelse:\r\n k = [a.rstrip(\"0\"), a + \"1\"]\r\n for i in k.copy():\r\n k.append(i[::-1])\r\n\r\n for el in k:\r\n if transit(el, b):\r\n print(\"YEs\")\r\n break\r\n else:\r\n print(\"no\")\r\n"}, {"source_code": "import re\r\na, b = [int(i) for i in input().split()]\r\ndef binSlice(x):\r\n return bin(x)[2:]\r\n \r\ndef removeLeadingZeros(s):\r\n for k in range(len(s)):\r\n if s[k] != '0': break\r\n return s[k:]\r\n \r\ndef reversed(s):\r\n return s[::-1]\r\n \r\ntemp = reversed(binSlice(a))\r\ntemp2 = removeLeadingZeros(temp)\r\ncheck = re.fullmatch(f\"1*(1{temp}|{temp2}|{reversed(temp)}1|{reversed(temp2)})1*\", binSlice(b)) is not None\r\nprint(\"YES\" if check or a == b else \"NO\")\r\n"}, {"source_code": "import math\nx, y = map(int, input().split())\nbin_x = bin(x)[2:]\nbin_y = bin(y)[2:]\n\nlst = [bin_x + '1', bin_x.strip('0')]\nflag = False\nnxt = False\nif bin_x == bin_y:\n print('YES')\n nxt = True\nif not nxt:\n for q in lst:\n div = len(bin_y) - len(q) + 1\n for j in range(div):\n if '1' * j + q + '1' * (div-j-1) == bin_y or '1' * j + q[::-1] + '1' * (div-j-1) == bin_y:\n print('YES')\n flag = True\n break\n if flag:\n break\n if not flag:\n print('NO')"}, {"source_code": "from collections import deque\r\n\r\na, b = map(int, input().split())\r\n\r\na = str(bin(a))[2:]\r\nb = str(bin(b))[2:]\r\n\r\nq = deque()\r\nq.append(a)\r\nans = \"NO\"\r\n\r\nseen = set()\r\n\r\nwhile q:\r\n s = q.pop()\r\n if s == b:\r\n ans = \"YES\"\r\n break\r\n\r\n if len(s) <= 100 and s not in seen:\r\n q.append(str(s + \"1\")[::-1])\r\n q.append(bin(int(s[::-1], 2))[2:])\r\n\r\n seen.add(s)\r\n\r\nprint(ans)\r\n"}, {"source_code": "a, b = list(map(int, input().strip().split()))\r\n\r\na_str = \"{0:b}\".format(a)\r\nb_str = \"{0:b}\".format(b)\r\n\r\n\r\na_str_1 = a_str+'1'\r\na_str_rev = a_str[::-1].strip('0')\r\na_str_rev_1 = a_str_1[::-1].strip('0')\r\n\r\na_strs = [a_str.strip('0'), a_str_1, a_str_rev, a_str_rev_1]\r\n\r\nans = a_str==b_str\r\n\r\nfor string in a_strs:\r\n pos = b_str.find(string)\r\n if pos==-1:\r\n continue\r\n b = b_str[:pos]+b_str[pos+len(string):]\r\n if b==(\"1\"*len(b)):\r\n ans=True\r\n break\r\nprint(\"YES\" if ans else \"NO\")\r\n"}, {"source_code": "def dfs(start=0,goal=None):\r\n used=set()\r\n p,t=start,0\r\n used.add(p)\r\n next_set=[p]\r\n if p==goal:\r\n return True\r\n while next_set:\r\n p=next_set.pop()\r\n for q in make_edge(p):\r\n if q in used:\r\n continue\r\n if q==goal:\r\n return True\r\n used.add(q)\r\n next_set.append(q)\r\n return False\r\n\r\nimport sys\r\ninput = sys.stdin.readline\r\nimport string\r\n\r\nnumbers = string.digits # [0-9] \u3092\u30ed\u30fc\u30c9\r\n\r\ndef base_cvt_from_10(value, n=2, output=numbers): # n=26, output=abc \u3067\u3001[a-z]\u8868\u793a\u306e26\u9032\u6570\u3092\u751f\u6210\u53ef\u80fd\r\n try:\r\n tmp = int(value)\r\n except:\r\n raise ValueError('Invalid value:', value) # \u6574\u6570\u4ee5\u5916\u306f\u30a2\u30a6\u30c8\r\n\r\n if n < 2 or n > len(output): # 62\u9032\u6570\u307e\u3067\u5bfe\u5fdc\u3002\r\n raise ValueError('Invalid n:', value)\r\n\r\n coef = []\r\n while tmp >= n:\r\n idx = tmp % n # tmp = a_k n^k + ... a_1 n^1 + a_0 n^0 \u306e a_0 \u306e\u5024\u3092\u53d6\u308a\u51fa\u3059\r\n coef.append(idx)\r\n tmp = tmp // n # a_k n^k + ... a_1 n^1 + a_0 n^0 \u21d2 a_k n^k + ... a_1 n^1 :\u6700\u5c0f\u6841\u3092\u6d88\u53bb\u3057\u3066\u30eb\u30fc\u30d7\r\n idx = tmp % n\r\n coef.append(idx) # coef = [a_0, a_1, ... , a_k]\r\n res = list(map(lambda x: output[x], reversed(coef))) # \u30ea\u30b9\u30c8\u306e\u9806\u5e8f\u3068\u6587\u5b57\u5217\u306e\u9806\u5e8f\u306f\u9006\u306a\u306e\u3067 reversed \u304c\u5fc5\u8981\r\n return res\r\n\r\ndef make_edge(s):\r\n bit=base_cvt_from_10(s)\r\n tmp=reversed(bit)\r\n tmp=\"\".join(tmp)\r\n tmp=int(tmp,2)\r\n if tmp>= 1\r\na = bin(x)[2:]\r\ny = bin(y)[2:]\r\n\r\ndef check(s):\r\n idx = y.find(s)\r\n if idx == -1:\r\n return False\r\n for i, e in enumerate(y):\r\n if idx<=i m:\r\n # return False \r\n if stt == end:\r\n return True \r\n \r\n q = deque()\r\n q.append(stt)\r\n seen = set()\r\n\r\n while q:\r\n t = q.popleft()\r\n if t not in seen:\r\n seen.add(t)\r\n\r\n p = t[::-1]\r\n p = get(p)\r\n if p == end:\r\n return True \r\n if len(p) <= m:\r\n q.append(p)\r\n p = t + \"1\"\r\n p = p[::-1]\r\n p = get(p)\r\n if len(p) <= m:\r\n q.append(p)\r\n if p == end:\r\n return True \r\n return False \r\n\r\n# sys.setrecursionlimit(200010)\r\n# https://codeforces.com/contest/1618/problem/F\r\ndef main():\r\n test = 1\r\n\r\n for idt in range(test):\r\n # n = int(input())\r\n a, b = map(int, input().split())\r\n # a = list(map(int, input().split()))\r\n stt = bin(a)[2:]\r\n end = bin(b)[2:]\r\n # print(stt)\r\n # print(end)\r\n if work(stt, end):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n return \r\n\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "def check(sa, sb):\r\n for i in range(len(sb)):\r\n for j in range(i, len(sb)):\r\n if (sb[i:j + 1] == sa or sb[i:j + 1] == sa[::-1]) and \"0\" not in sb[:i] and \"0\" not in sb[j + 1:]:\r\n return True\r\n return False\r\na, b = map(int, input().split())\r\nif a == b:\r\n print(\"YES\")\r\n exit()\r\nsa = bin(a)[2:]\r\nsb = bin(b)[2:]\r\nta = sa\r\nwhile ta[-1] == \"0\":\r\n ta = ta[:-1]\r\nif check(sa + \"1\", sb) or check(ta, sb):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\r\nif a == b:\r\n print(\"YES\")\r\n quit()\r\na1 = bin(a)[2:] + '1'\r\na = bin(a)[2:].rstrip('0')\r\na1r = a1[::-1]\r\nar = a[::-1]\r\nb = bin(b)[2:]\r\nb0 = b.count('0')\r\na0 = a.count('0')\r\na10 = a1.count('0')\r\nif (a in b and a0 == b0) or (ar in b and a0 == b0) or (a1 in b and a10 == b0) or (a1r in b and a10 == b0):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "def f(s,y):\r\n\tif(s in y):\r\n\t\ti=y.index(s)\r\n\t\tfor j in range(0,i):\r\n\t\t\tif(y[j]!=\"1\"):\r\n\t\t\t\treturn False\r\n\t\tfor j in range(i+len(s),len(y)):\r\n\t\t\tif(y[j]!=\"1\"):\r\n\t\t\t\treturn False\r\n\t\treturn True\r\n\treturn False\r\nx,y=map(int,input().split())\r\nx=bin(x)[2:]\r\ny=bin(y)[2:]\r\ni=0\r\nj=x.rfind(\"1\")\r\ns=x[i:j+1]\r\ns1=s[::-1]\r\ns3=x+\"1\"\r\ns4=s3[::-1]\r\n# print(x)\r\n# print(y)\r\n# print(s,s1,s3,s4)\r\nif(x==y or f(s,y) or f(s1,y) or f(s3,y) or f(s4,y)):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")"}, {"source_code": "import sys\r\nimport collections\r\n \r\n \r\ndef rev(x):\r\n ret = 0\r\n while x:\r\n ret = ret * 2 + (x & 1)\r\n x >>= 1\r\n return ret\r\n \r\n \r\ndef solve(x, y):\r\n if x == y:\r\n return True\r\n q = collections.deque([x])\r\n vis = {x}\r\n while q:\r\n n = q.popleft()\r\n n1, n2 = n << 1, (n << 1) | 1\r\n n3, n4 = rev(n1), rev(n2)\r\n n1 = rev(n3)\r\n for nn in [n1, n2, n3, n4]:\r\n if nn == y:\r\n return True\r\n else:\r\n if nn > y or nn in vis:\r\n continue\r\n vis.add(nn)\r\n q.append(nn)\r\n return False\r\n \r\n \r\nx, y = map(int, sys.stdin.readline().split())\r\nif solve(x, y):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "x,y=map(int,input().split())\nx=list(bin(x)[2:])\ny=list(bin(y)[2:])\n\nif x==y:\n print('YES')\n exit()\n\nfor i in range(64):\n for j in range(1,64):\n if ['1']*i+x+['1']*j==y:\n print('YES')\n exit()\n if ['1']*j+x[::-1]+['1']*i==y:\n print('YES')\n exit()\n\nwhile x[-1]=='0':\n x.pop()\n\nfor i in range(64):\n for j in range(64):\n if ['1']*i+x+['1']*j==y:\n print('YES')\n exit()\n if ['1']*i+x[::-1]+['1']*j==y:\n print('YES')\n exit()\n\nprint('NO')"}, {"source_code": "tmp=input().split()\r\na=format(int(tmp[0]),\"b\")\r\ntar=format(int(tmp[1]),\"b\")\r\nc=a+'1'\r\nwhile a[-1]=='0':\r\n a=a[:-1]\r\nb=a[::-1]\r\nd=c[::-1]\r\ndef works(x):\r\n if not x in tar:\r\n return 0\r\n while x in tar:\r\n x='1'+x\r\n x=x[1:]\r\n while x in tar:\r\n x=x+'1'\r\n x=x[:-1]\r\n return x==tar\r\nif works(a) or works(b) or works(c) or works(d) or c[:-1]==tar:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "a=list(map(int,input().split()))\nif a[0]==a[1]:\n print(\"YES\")\n quit()\nxx = bin(a[0])[2:]\nyy = bin(a[1])[2:]\nfor q in [xx+'1',xx.strip('0')]:\n for l in range(len(yy) - len(q) + 1):\n r=len(yy) - len(q) - l\n if '1'*l+q+'1'*r==yy or '1'*l+q[::-1]+'1'*r==yy:\n print(\"YES\")\n quit()\nelse:\n print(\"NO\")\n\n \t\t\t\t \t \t\t \t\t\t\t\t \t \t\t\t"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\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: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\ndef isPossible(base, target):\n num_zero_base = base.count('0')\n num_zero_target = target.count('0')\n num_one_base = base.count('1')\n num_one_target = target.count('1')\n if num_one_target < num_one_base or num_zero_target != num_zero_base:\n return False\n return target.find(base) != -1 or target.find(base[::-1]) != -1\n\n\ndef solve():\n x, y = map(int, input().split())\n if x == y:\n return \"YES\"\n bx, by = bin(x)[2:], bin(y)[2:]\n bx3 = bx.rstrip('0')[::-1]\n bx4 = '1' + bx[::-1]\n\n return \"YES\" if isPossible(bx3, by) or isPossible(bx4, by) else \"NO\"\n\nans = solve()\nprint(ans)\n"}, {"source_code": "import os,sys\r\nfrom io import BytesIO, IOBase\r\n\r\ndef find(c1,c2):\r\n \"\"\" find c1 in c2\"\"\"\r\n for i in range(len(c2)-len(c1)+1):\r\n if c1 == c2[i:i+len(c1)] and c2[:i] == [1]*i \\\r\n and c2[i+len(c1):] == [1]*(len(c2)-len(c1)-i):\r\n return 1\r\n return 0\r\n\r\ndef main():\r\n x,y = map(int,input().split())\r\n if x == y:\r\n print('YES')\r\n exit()\r\n if not y&1:\r\n print('NO')\r\n exit()\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n c1,ls = [],0\r\n for i in range(1,len(x)):\r\n if x[i] == '1':\r\n c1.append(i-ls)\r\n ls = i\r\n c2,ls = [],0\r\n for i in range(1,len(y)):\r\n if y[i] == '1':\r\n c2.append(i-ls)\r\n ls = i\r\n zz = 0\r\n for i in range(len(x)-1,-1,-1):\r\n if x[i] == '0':\r\n zz += 1\r\n else:\r\n break\r\n c3 = c1+[zz+1]\r\n print('YES' if find(c3,c2) or find(c1,c2) or find(c1[::-1],c2) or find(c3[::-1],c2) else 'NO')\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\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "x, y = map(int, input().split())\r\nx = bin(x,)[2:]\r\ny = bin(y,)[2:]\r\nl = 0;\r\nn = -len(x)\r\nox = x + '1'\r\nok = x == y\r\nif(ox in y):\r\n i = y.index(ox)\r\n if not( '0' in y[:i] or '0' in y[i + len(ox):]): ok = True \r\nox = ox[::-1]\r\nif ox in y:\r\n i = y.index(ox)\r\n if not( '0' in y[:i] or '0' in y[i + len(ox):]): ok = True \r\n\r\nwhile l >= n and x[l-1] == '0': \r\n l-=1\r\nif l!= 0: x = x[:l]\r\nif x in y:\r\n i = y.index(x)\r\n if not( '0' in y[:i] or '0' in y[i + len(x):]): ok = True \r\nx = x[::-1]\r\nif x in y:\r\n i = y.index(x)\r\n if not( '0' in y[:i] or '0' in y[i + len(x):]): ok = True \r\n\r\n \r\nprint(\"Yes\" if ok else \"No\")"}, {"source_code": "x,y=[str(bin(int(i)))[2:] for i in input().split()]\r\n\r\nif x==y:\r\n print('YES')\r\nelif y[-1]=='0':\r\n print('NO')\r\nelse:\r\n x+='1'\r\n if (y.find(x)!=-1 or y.find(x[::-1])!=-1) and y.count('1')-x.count('1')==len(y)-len(x):\r\n print('YES')\r\n else:\r\n x=x[:-1]\r\n while x[-1]=='0':\r\n x=x[:-1]\r\n print('YES') if (y.find(x)!=-1 or y.find(x[::-1])!=-1) and y.count('1')-x.count('1')==len(y)-len(x) else print('NO')"}, {"source_code": "import io,os\r\n#input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n\r\ndef main(t):\r\n\tx,y=[int(i)for i in input().split()]\r\n\tif(x==y):\r\n\t\tprint(\"YES\")\r\n\t\treturn\r\n\tif(y%2==0):\r\n\t\tprint(\"NO\")\r\n\t\treturn\r\n\tx=bin(x)[2:]\r\n\txx=x\r\n\ty=bin(y)[2:]\r\n\twhile(x[-1]=='0'):\r\n\t\tx=x[:-1]\r\n\tx=x[::-1]\r\n\tnow=0\r\n\twhile(len(y)-now>=len(xx)):\r\n\t\tif(xx==y[now:now+len(xx)]):\r\n\t\t\tif(not '0' in y[now+len(xx):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tif(xx[::-1]==y[now:now+len(xx)]):\r\n\t\t\tif(not '0' in y[now+len(xx):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tif(y[now]=='0'):\r\n\t\t\tbreak\r\n\t\tnow+=1\r\n\tnow=0\r\n\twhile(len(y)-now>=len(x)):\r\n\t\tif(x==y[now:now+len(x)]):\r\n\t\t\tif(not '0' in y[now+len(x):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tif(x[::-1]==y[now:now+len(x)]):\r\n\t\t\tif(not '0' in y[now+len(x):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tif(y[now]=='0'):\r\n\t\t\tbreak\r\n\t\tnow+=1\r\n\tprint(\"NO\")\r\n\r\nT=1\r\nt=1\r\nwhile t<=T:\r\n\tmain(t)\r\n\tt+=1\r\n"}, {"source_code": "import sys\r\nimport math\r\nfrom math import factorial, inf, gcd, sqrt\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\nfrom sys import stdin, stdout\r\n\r\nsys.setrecursionlimit(10**5)\r\n\r\n\r\ndef inp():\r\n return stdin.readline().strip()\r\n\r\n\r\ndef iinp():\r\n return int(inp())\r\n\r\n\r\ndef mp():\r\n return map(int, inp().split())\r\n\r\n\r\ndef lmp():\r\n return list(mp())\r\n\r\n\r\n# t = iinp()\r\nt = 1\r\nfor ii in range(t):\r\n x, y = mp()\r\n if x == y:\r\n print('YES')\r\n continue\r\n if x == 0 or y == 0:\r\n print('NO')\r\n continue\r\n x = format(x, 'b')\r\n y = format(y, 'b')\r\n x0, y0 = x.count('0'), y.count('0')\r\n t = x[::-1].find('1')\r\n if y0 != x0 and y0 + t != x0:\r\n print('NO')\r\n continue\r\n m, n = len(x), len(y)\r\n if t == 0:\r\n if x in y or x[::-1] in y:\r\n print('YES')\r\n else:\r\n print('NO')\r\n continue\r\n i = y.find(x)\r\n if i != -1 and i + m < n:\r\n print('YES')\r\n continue\r\n i = y.find(x[::-1])\r\n if i != -1 and i > 0:\r\n print('YES')\r\n continue\r\n x = x[:m - t]\r\n print('YES' if x0 == y0 + t and (x in y or x[::-1] in y) else 'NO')\r\n"}, {"source_code": "s = input()\r\nnums = [int(x) for x in s.split()]\r\na = str(bin(nums[0]))[2:]\r\nb = str(bin(nums[1]))[2:]\r\nax = a.rstrip(\"0\")\r\nay = a + \"1\"\r\nans = \"NO\"\r\n#print(a, b, ax, ay)\r\nif all(c in '1' for c in b.replace(ax, \"\", 1)) and b != b.replace(ax, \"\", 1):\r\n ans = \"YES\"\r\nax = ax[::-1]\r\nif all(c in '1' for c in b.replace(ax, \"\", 1)) and b != b.replace(ax, \"\", 1):\r\n ans = \"YES\"\r\nax = a + \"1\"\r\nif all(c in '1' for c in b.replace(ax, \"\", 1)) and b != b.replace(ax, \"\", 1):\r\n ans = \"YES\"\r\nax = ax[::-1]\r\nif all(c in '1' for c in b.replace(ax, \"\", 1)) and b != b.replace(ax, \"\", 1):\r\n ans = \"YES\"\r\nif a == b:\r\n ans = \"YES\"\r\nprint(ans)"}, {"source_code": "\r\n\r\na, b = map(int, input().split())\r\n\r\nbina = bin(b)[2::]\r\nbinb = bin(a)[2::]\r\n\r\nif (bina == binb):\r\n print(\"YES\")\r\n exit(0)\r\nelse:\r\n\r\n for q in [binb + '1', binb.rstrip('0')]:\r\n\r\n for l in range(len(bina) - len(q) + 1):\r\n r = len(bina) - len(q) - l\r\n if (l*'1' + q + r*'1' == bina) or (l*'1' + q[::-1] + r*'1' == bina):\r\n print(\"YES\")\r\n exit(0)\r\n\r\nprint(\"NO\")\r\n\r\n"}, {"source_code": "\r\n\r\n\r\na, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\n#print(s)\r\n#print(t)\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\n\r\nq=t+'1'\r\nfor l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\n\r\nq=t.strip('0')\r\nfor l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\n\r\n\r\nprint(\"NO\")"}, {"source_code": "import collections\r\ndef solve():\r\n def add_one(val):\r\n bs = bin(val)[2:] + '1'\r\n bs = bs[::-1]\r\n return int(bs, 2)\r\n def add_zero(val):\r\n bs = bin(val)[2:] + '0'\r\n bs = bs[::-1]\r\n return int(bs, 2)\r\n\r\n a, b = list(map(int, input().split()))\r\n deq = collections.deque()\r\n deq.append(a)\r\n ss = set()\r\n ss.add(a)\r\n while deq:\r\n a = deq.popleft()\r\n if a == b:\r\n print(\"YES\")\r\n return\r\n if a & 1:\r\n na = add_zero(a)\r\n if na <= b and (na not in ss):\r\n ss.add(na)\r\n deq.append(na)\r\n na = add_one(a)\r\n if (na <= b or add_zero(na) <= b) and (na not in ss):\r\n ss.add(na)\r\n deq.append(na)\r\n else:\r\n na = add_zero(a)\r\n if na not in ss:\r\n ss.add(na)\r\n deq.append(na)\r\n na = add_one(a)\r\n if (na <= b or add_zero(na) <= b) and (na not in ss):\r\n ss.add(na)\r\n deq.append(na)\r\n print(\"NO\")\r\n\r\nsolve()\r\n \r\n\r\n\r\n"}, {"source_code": "def dfs(x, y):\n vis.add(x)\n rev, nxt, cp = 0, 0, x\n while x:\n rev = rev * 2 + x % 2\n x //= 2\n x = 2 * cp + 1\n while x:\n nxt = nxt * 2 + x % 2\n x //= 2\n x = cp\n if x > y:\n if rev not in vis:\n dfs(rev, y)\n elif x == y:\n return\n else:\n if rev not in vis:\n dfs(rev, y)\n if nxt not in vis:\n dfs(nxt, y)\n\nx, y = (int(x) for x in input().split())\nvis = {x}\ndfs(x, y)\nprint(\"YES\" if y in vis else \"NO\")"}, {"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 list(map(str,input().strip().split(\" \")))\r\ndef le(): return list(map(int,input().split()))\r\ndef rc(): return map(float,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\ndef tir(a,b,c):\r\n if(0==c):\r\n return 1\r\n if(len(a)<=b):\r\n return 0\r\n \r\n if(c!=-1):\r\n return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c)) \r\n \r\n \r\n else:\r\n return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))\r\nhoi=int(2**20) \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\ndef joker(a,b):\r\n L=bin(a)[2:]\r\n M=bin(b)[2:]\r\n p=len(M)\r\n if(a==b):\r\n return 1\r\n Q=L[::-1].lstrip(\"0\")\r\n P=(L+\"1\")[::-1]\r\n #O=len(M)\r\n R=P[::-1]\r\n S=Q[::-1]\r\n for i in [P,Q,R,S]:\r\n op=len(i)\r\n if(p 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\nboi=int(1e9-7)\r\ndoi=int(1e9+7)\r\n\r\n \r\n \r\ndef iu():\r\n import sys\r\n import math as my\r\n input=sys.stdin.readline\r\n bj=\"YES\"\r\n cj=\"NO\"\r\n a,b=mj()\r\n if(not joker(a,b)):\r\n print(cj)\r\n else:\r\n print(bj)\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 \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# 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": "# cook your dish here\r\nimport sys\r\n#import random\r\nfrom bisect import bisect_left as lb\r\nfrom bisect import bisect_right as rb\r\nfrom collections import deque\r\n#sys.setrecursionlimit(10**8)\r\nfrom queue import PriorityQueue as pq\r\nfrom math import gcd\r\n#import math\r\ninput_ = lambda: sys.stdin.readline().strip(\"\\r\\n\")\r\nii = lambda : int(input_())\r\nil = lambda : list(map(int, input_().split()))\r\nilf = lambda : list(map(float, input_().split()))\r\nlii = lambda : list(map(int, list(ip())))\r\nip = lambda : input_()\r\nfi = lambda : float(input_())\r\nap = lambda ab,bc,cd : ab[bc].append(cd)\r\nli = lambda : list(input_())\r\npr = lambda x : print(x)\r\nprinT = lambda x : print(x)\r\nf = lambda : sys.stdout.flush()\r\ninv =lambda x:pow(x,mod-2,mod)\r\ndx = [0,0,1,-1]\r\ndy = [1,-1,0,0]\r\nmod = 10**9 + 7\r\nmod1 = 998244353\r\n\r\nfor _ in range (1) :\r\n x,y = il()\r\n\r\n a = bin(x)[2:] + '1'\r\n b = bin(y)[2:]\r\n t = len(a)\r\n fl = 0\r\n\r\n if (x == y) :\r\n print(\"YES\")\r\n continue\r\n \r\n\r\n a1 = a[:len(a)-1]\r\n\r\n #print(a,b)\r\n for mn in range (2) :\r\n t = len(a)\r\n #print(a)\r\n for i in range (len(b)) :\r\n if (i + t - 1 >= len(b)) :\r\n break\r\n temp = b[i:i+t]\r\n if (temp == a) :\r\n t1 = b[:i]\r\n t2 = b[i+t:]\r\n\r\n if (t1.count('0')) or (t2.count('0')) :\r\n pass\r\n else :\r\n fl = 1\r\n break\r\n #a1 = a\r\n a = a[::-1]\r\n\r\n for i in range (len(b)) :\r\n if (i + t - 1 >= len(b)) :\r\n break\r\n temp = b[i:i+t]\r\n if (temp == a) :\r\n t1 = b[:i]\r\n t2 = b[i+t:]\r\n\r\n if (t1.count('0')) or (t2.count('0')) :\r\n pass\r\n else :\r\n fl = 1\r\n break\r\n ind = -1\r\n\r\n for i in range (len(a1)-1,-1,-1) :\r\n if (a1[i] == '1') :\r\n ind = i\r\n break\r\n\r\n a = a1[:ind+1]\r\n \r\n if (fl) :\r\n print(\"YES\")\r\n else :\r\n print(\"NO\")\r\n"}, {"source_code": "a, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n\tprint(\"YES\")\r\n\texit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n\tfor l in range(len(s) - len(q) + 1):\r\n\t\tr = len(s) - len(q) - l\r\n\t\tif '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n\t\t\tprint(\"YES\")\r\n\t\t\texit(0)\r\nprint(\"NO\")"}, {"source_code": "a, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n\tprint(\"YES\")\r\n\texit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n\tfor l in range(len(s) - len(q) + 1):\r\n\t\tr = len(s) - len(q) - l\r\n\t\tif '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n\t\t\tprint(\"YES\")\r\n\t\t\texit(0)\r\nprint(\"NO\")"}, {"source_code": "# Problem: F. \u0420\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u044b\r\n# Contest: Codeforces - Codeforces Round #760 (Div. 3)\r\n# URL: https://codeforces.com/contest/1618/problem/F\r\n# Memory Limit: 256 MB\r\n# Time Limit: 2000 ms\r\n# \r\n# Powered by CP Editor (https://cpeditor.org)\r\n\r\nimport bisect\r\nimport random\r\nmod = 10 ** 9 + 7\r\neps = 10 ** -9\r\n\r\n\r\ndef __gcd(a, b):\r\n\treturn a if b == 0 else __gcd(b, a % b)\r\n\t\r\n\r\ndef __lcm(a, b):\r\n\treturn a * b / __gcd(a, b)\r\n\r\n\r\ndef __fact(n):\r\n\treturn 1 if n == 1 else n * __fact(n - 1)\r\n\r\n\r\ndef __mex(a):\r\n\tmex = 0\r\n\ta.sort()\r\n\tfor x in a:\r\n\t\tif x <= mex:\r\n\t\t\tmex += 1\r\n\t\telse:\r\n\t\t\tbreak\r\n\treturn mex\r\n\r\ndef __dist(x1, y1, x2, y2):\r\n\treturn (x1 - x2) ** 2 + (y1 - y2) ** 2\r\n\r\ndef __getprimes(n):\r\n isprime = [True for i in range(n + 1)]\r\n primes = []\r\n \r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n for j in range(i * i, n + 1, i):\r\n isprime[j] = False\r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n primes.append(i)\r\n return primes\r\n\r\ndef __modInverse(a, m):\r\n \r\n m0 = m\r\n y = 0\r\n x = 1\r\n if (m == 1):\r\n return 0\r\n \r\n while(a > 1):\r\n \tq = a // m\r\n \tt = m\r\n \tm = a % m\r\n \ta = t\r\n \tt = y\r\n \ty = x - q * y\r\n \tx = t\r\n if (x < 0):\r\n \tx = x + m0\r\n return x\r\n \r\n \r\n \r\ndef __isprime(n):\r\n\tif n < 2:\r\n\t\treturn False\r\n\ti = 2\r\n\twhile i * i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\treturn False\r\n\t\ti += 1\r\n\treturn True\r\n\t\r\ndef __cntprimediv(n):\r\n\tret = 0\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tn //= i\r\n\t\t\tret += 1\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret += 1\r\n\treturn ret\r\n\t\r\ndef __primefactors(n):\r\n\tret = []\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tret.append(i)\r\n\t\t\tn //= i\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret.append(n)\r\n\treturn ret\r\n\t\r\n\r\ndef __sumdigit(n):\r\n\tret = 0\r\n\twhile n > 0:\r\n\t\tret += n % 10\r\n\t\tn //= 10\r\n\treturn ret\r\n\r\ndef __zfunc(s):\r\n\tn = len(s)\r\n\tz = [0 for i in range(n)]\r\n\tl = 0\r\n\tr = 0\r\n\tfor i in range(1, n):\r\n\t\tif r >= i:\r\n\t\t\tz[i] = min(z[i - l], r - i + 1)\r\n\t\twhile z[i] + i < n and s[z[i]] == s[z[i] + i]:\r\n\t\t\tz[i] += 1\r\n\t\tif i + z[i] - 1 > r:\r\n\t\t\tl = i\r\n\t\t\tr = i + z[i] - 1\r\n\treturn z\r\n\t\r\n\t\r\ndef __to(n, x):\r\n\tret = ''\r\n\twhile n > 0:\r\n\t\tq = n % x\r\n\t\tif q < 10:\r\n\t\t\tret += str(q)\r\n\t\telse:\r\n\t\t\tret += chr(q - 10 + ord('a'))\r\n\t\tn //= x\r\n\treturn ret[::-1]\r\n\t\r\ndef __delChar(s, c):\r\n\ts = list(s)\r\n\twhile len(s) > 0 and s[0] == c:\r\n\t\ts.pop(0)\r\n\treturn '' . join(s)\r\n\r\n\r\ndef solve(t_id):\r\n\tn, m = map(int, input().split())\r\n\ttmp1 = n\r\n\ttmp2 = m\r\n\tok = False\r\n\tif n == m:\r\n\t\tok = True\r\n\ts = __to(n, 2)\r\n\tt = __to(m, 2)\r\n\t\r\n\t\r\n\ts1 = s + '1'\r\n\ts = __delChar(s, '0')[::-1]\r\n\ts = __delChar(s, '0')[::-1]\r\n\t\r\n\t\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s1\r\n\ts = __delChar(s, '0')[::-1]\r\n\ts = __delChar(s, '0')[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\t\r\n\tprint('YES' if ok else 'NO')\r\nt = 1\r\n#t = int(input())\r\n\r\n\r\nfor i in range(t):\r\n\tsolve(t)"}, {"source_code": "# Fast IO Region\r\nimport os,sys\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\nin1 = lambda : int(input())\r\nin2 = lambda : list(map(int, input().split()))\r\n \r\n#Solve\r\nimport math\r\nmod = 998244353\r\n\r\ndef check(x, y):\r\n b1 = bin(x)[2:]\r\n b2 = bin(y)[2:]\r\n if len(b2) < len(b1):\r\n return False\r\n\r\n def cmp(s1, s2):\r\n n1 = [c for c in s1]\r\n n2 = [c for c in s2]\r\n while len(n1) > 1 and n1[0] == '1' and n1[1] == '1':\r\n n1.remove(n1[0])\r\n while len(n1) > 1 and n1[-1] == '1' and n1[-2] == '1':\r\n n1.pop()\r\n while len(n2) > 1 and n2[0] == '1' and n2[1] == '1':\r\n n2.remove(n2[0])\r\n while len(n2) > 1 and n2[-1] == '1' and n2[-2] == '1':\r\n n2.pop()\r\n if len(n1) != len(n2):\r\n return False\r\n for i in range(len(n1)):\r\n if n1[i] != n2[i]:\r\n return False\r\n return True\r\n \r\n return cmp(b1, b2) or cmp(reversed(b1), b2)\r\n\r\ndef main():\r\n x, y = in2()\r\n if x == y:\r\n print(\"YES\")\r\n return\r\n x1 = x\r\n x2 = x * 2 + 1\r\n while x1 % 2 == 0:\r\n x1 //= 2\r\n \r\n if check(x1, y):\r\n print(\"YES\")\r\n return\r\n if check(x2, y):\r\n print(\"YES\")\r\n return\r\n print(\"NO\")\r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "def toBinary (x):\r\n binX = []\r\n \r\n while x:\r\n binX.append(x%2)\r\n x = x//2\r\n \r\n binX.reverse()\r\n return binX\r\n\r\n\r\n\r\ndef toBase (binX):\r\n \r\n baseX = binX.copy()\r\n while baseX[len(baseX)-1] == 0:\r\n baseX.pop(len(baseX)-1)\r\n \r\n return baseX\r\n\r\n\r\n\r\n\r\ndef checkOnes (binY, k, index):\r\n \r\n for i in range(0, index):\r\n if binY[i] != 1:\r\n return False\r\n \r\n for i in range(index + k, len(binY)):\r\n if binY[i] != 1:\r\n return False\r\n \r\n return True\r\n\r\n\r\n\r\n\r\ndef checkOnesRight (binY, k, index):\r\n\r\n for i in range(index + k, len(binY)):\r\n if binY[i] == 1:\r\n return True\r\n \r\n return False\r\n\r\n\r\n\r\ndef checkOnesLeft (binY, k, index):\r\n\r\n for i in range(0, index):\r\n if binY[i] == 1:\r\n return True\r\n \r\n return False\r\n\r\n\r\n\r\n\r\ndef checkEqual (binY, binX, mode):\r\n# checks if binY can be obtained as 1111111..... + binX + ......111111111\r\n \r\n index = -1\r\n for i in range (len(binY)-len(binX)+1):\r\n temp = binY[i:i+len(binX)]\r\n \r\n if temp == binX:\r\n index = i\r\n break\r\n \r\n if index == -1:\r\n return False\r\n \r\n \r\n if checkOnes(binY, len(binX), index):\r\n if mode == 0:\r\n return True\r\n \r\n elif mode == 1:\r\n if checkOnesRight(binY, len(binX), index):\r\n return True\r\n else:\r\n return False\r\n \r\n elif mode == 2:\r\n if checkOnesLeft(binY, len(binX), index):\r\n return True\r\n else:\r\n return False\r\n else:\r\n return False\r\n\r\n\r\n\r\n \r\n \r\n \r\n\r\nx, y = list(map(int,input().split()))\r\n\r\nbinX = toBinary(x)\r\nbinY = toBinary(y)\r\nbaseX = toBase(binX)\r\n\r\n\r\nif x == y:\r\n print (\"YES\")\r\n \r\nelif binX == baseX:\r\n \r\n if checkEqual (binY, binX, 0) or checkEqual (binY, list(reversed(binX)), 0 ) :\r\n print (\"YES\")\r\n \r\n else:\r\n print (\"NO\")\r\n\r\nelse:\r\n \r\n if checkEqual (binY, baseX, 0) or checkEqual (binY, list(reversed(baseX)), 0 ) :\r\n print (\"YES\")\r\n \r\n elif checkEqual (binY, binX, 1) or checkEqual (binY, list(reversed(binX)), 2 ) :\r\n print (\"YES\")\r\n \r\n else:\r\n print (\"NO\")\r\n \r\n \r\n"}, {"source_code": "import sys\r\nraw_input = iter(sys.stdin.read().splitlines()).next\r\n\r\ndef getPrefix(pattern):\r\n prefix = [-1]*len(pattern)\r\n j = -1\r\n for i in xrange(1, len(pattern)):\r\n while j != -1 and pattern[j+1] != pattern[i]:\r\n j = prefix[j]\r\n if pattern[j+1] == pattern[i]:\r\n j += 1\r\n prefix[i] = j\r\n return prefix\r\n \r\ndef kmp(text, pattern):\r\n if not pattern:\r\n return 0\r\n prefix = getPrefix(pattern)\r\n if len(text) < len(pattern):\r\n return -1\r\n j = -1\r\n for i in xrange(len(text)):\r\n while j != -1 and pattern[j+1] != text[i]:\r\n j = prefix[j]\r\n if pattern[j+1] == text[i]:\r\n j += 1\r\n if j+1 == len(pattern):\r\n return i-j\r\n return -1\r\n\r\ndef solution():\r\n x, y = map(lambda x:bin(int(x))[2:], raw_input().strip().split())\r\n if x == y:\r\n return \"YES\"\r\n for s in (x+'1', x.strip('0')):\r\n for t in (s, s[::-1]):\r\n i = kmp(y, t)\r\n if i != -1 and all(c == '1' for c in y[:i]+y[i+len(t):]):\r\n return \"YES\"\r\n return \"NO\"\r\n\r\nprint '%s' % solution()"}, {"source_code": "import sys\r\n\r\ndef power2(x):\r\n return 2 * x == 1 << x.bit_length()\r\n\r\n\r\ndef string_check(x, y):\r\n i = -1\r\n while True:\r\n i = y.find(x, i + 1)\r\n if i == -1:\r\n break\r\n\r\n if all(c == '1' for c in y[:i]) and all(c == '1' for c in y[i + len(x):]):\r\n return True\r\n return False\r\n\r\ndef to_binary(x):\r\n return bin(x)[2:]\r\n\r\ndef check(x, y):\r\n if x == y:\r\n return True\r\n\r\n if x == 0:\r\n return power2(y + 1)\r\n \r\n x1 = (x << 1) + 1\r\n x0 = x >> (x & -x).bit_length() - 1\r\n \r\n \r\n ybin = to_binary(y)\r\n if string_check(to_binary(x0), ybin):\r\n return True\r\n \r\n if string_check(to_binary(x0)[::-1], ybin):\r\n return True\r\n \r\n if string_check(to_binary(x1), ybin):\r\n return True\r\n \r\n if string_check(to_binary(x1)[::-1], ybin):\r\n return True\r\n \r\n return False\r\n\r\n\r\n\r\nx,y = [int(x) for x in input().split()]\r\nif check(x,y):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "# coding: utf-8\r\n\r\nfrom re import fullmatch\r\n\r\nx, y = map(lambda x: bin(int(x))[2:], input().split())\r\nx0, x1 = x + '1', x.rstrip('0')\r\nprint('YES' if x == y or fullmatch(f'1*({x0}|{x1}|{x0[::-1]}|{x1[::-1]})1*', y) else 'NO')"}, {"source_code": "from collections import deque\r\n\r\n\r\ndef gs():return input()\r\n\r\ndef gi():return int(input())\r\n\r\ndef gl(): return list(map(int, input().split()))\r\n\r\ndef gt(): return map(int, input().split())\r\n\r\n\r\nx, y = gt()\r\n\r\nqueue = deque([bin(x)[2:]])\r\nvisited = set([x])\r\npossible = False\r\nwhile queue:\r\n cur = queue.popleft()\r\n if int(cur, 2) == y:\r\n possible = True\r\n break\r\n if len(cur) > 60:\r\n continue\r\n\r\n one = cur[:] + '1'\r\n onebit = int(one[::-1], 2)\r\n if onebit not in visited :\r\n queue.append(bin(onebit)[2:])\r\n visited.add(onebit)\r\n\r\n zero = cur[:] + '0'\r\n zerobit = int(zero[::-1], 2)\r\n if zerobit not in visited:\r\n queue.append(bin(zerobit)[2:])\r\n visited.add(zerobit)\r\nif possible:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n \r\n"}, {"source_code": "a, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n for l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")\r\n"}, {"source_code": "import collections\r\ndef solve():\r\n x,y=list(map(int,input().split()))\r\n word=''\r\n while x:\r\n #print(x)\r\n word+=str(x%2)\r\n x//=2\r\n word=word[::-1]\r\n #print('word',word)\r\n \r\n q=collections.deque()\r\n S=set()\r\n q.append(word)\r\n S.add(word)\r\n step=0\r\n \r\n while q and step<100:\r\n step+=1\r\n k=len(q)\r\n\r\n for _ in range(k):\r\n cur=q.popleft()\r\n if int(cur,2)==y:\r\n print('YES')\r\n return\r\n\r\n new1='1'+cur[::-1]\r\n if new1 not in S:\r\n q.append(new1)\r\n S.add(new1)\r\n \r\n new2=cur[::-1].lstrip('0')\r\n if new2 not in S:\r\n q.append(new2)\r\n S.add(new2)\r\n \r\n print('NO')\r\n\r\nsolve()\r\n"}, {"source_code": "def f(s,y):\r\n\tif(s in y):\r\n\t\ti=y.index(s)\r\n\t\tfor j in range(0,i):\r\n\t\t\tif(y[j]!=\"1\"):\r\n\t\t\t\treturn False\r\n\t\tfor j in range(i+len(s),len(y)):\r\n\t\t\tif(y[j]!=\"1\"):\r\n\t\t\t\treturn False\r\n\t\treturn True\r\n\treturn False\r\nx,y=map(int,input().split())\r\nx=bin(x)[2:]\r\ny=bin(y)[2:]\r\ni=0\r\nj=x.rfind(\"1\")\r\ns=x[i:j+1]\r\ns1=s[::-1]\r\ns3=x+\"1\"\r\ns4=s3[::-1]\r\n# print(x)\r\n# print(y)\r\n# print(s,s1,s3,s4)\r\nif(x==y or f(s,y) or f(s1,y) or f(s3,y) or f(s4,y)):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")"}, {"source_code": "x, y = map(int, input().split())\r\ns = set()\r\ns.add(x)\r\na = [x]\r\nfor u in a:\r\n if u > 10**20:\r\n continue\r\n k = 2*u + 0\r\n b = bin(k)[2::][::-1]\r\n v = int(b, 2)\r\n if v not in s:\r\n s.add(v)\r\n a.append(v)\r\n \r\n k = 2*u + 1\r\n b = bin(k)[2::][::-1]\r\n v = int(b, 2)\r\n if v not in s:\r\n s.add(v)\r\n a.append(v)\r\nprint('YES' if y in s else 'NO')"}, {"source_code": "a, b = map(int, input().split())\r\na = str(bin(a)[2:])\r\nb = str(bin(b)[2:])\r\nif b[-1] == '0' and a != b:\r\n print('NO')\r\n exit()\r\nelif a == b:\r\n print(\"YES\")\r\n exit()\r\nx1 = ''\r\nflag = False\r\nfor el in a[::-1]:\r\n if el == '1':\r\n flag = True\r\n x1 += el\r\n if el == '0':\r\n if flag:\r\n x1 += el\r\nx2 = '1' + a[::-1]\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nx1 = x1[::-1]\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nx1 = x2\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nx1 = x1[::-1]\r\nif x1 in b:\r\n y1 = b[:b.find(x1)] + b[b.find(x1) + len(x1):]\r\n if y1.count('0') == 0:\r\n print(\"YES\")\r\n exit()\r\nprint(\"NO\")"}, {"source_code": "import os,sys\r\nfrom io import BytesIO, IOBase\r\n\r\ndef find(c1,c2):\r\n \"\"\" find c1 in c2\"\"\"\r\n for i in range(len(c2)-len(c1)+1):\r\n if c1 == c2[i:i+len(c1)] and c2[:i] == [1]*i \\\r\n and c2[i+len(c1):] == [1]*(len(c2)-len(c1)-i):\r\n return 1\r\n return 0\r\n\r\ndef main():\r\n x,y = map(int,input().split())\r\n if x == y:\r\n print('YES')\r\n exit()\r\n if not y&1:\r\n print('NO')\r\n exit()\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n c1,ls = [],0\r\n for i in range(1,len(x)):\r\n if x[i] == '1':\r\n c1.append(i-ls)\r\n ls = i\r\n c2,ls = [],0\r\n for i in range(1,len(y)):\r\n if y[i] == '1':\r\n c2.append(i-ls)\r\n ls = i\r\n zz = 0\r\n for i in range(len(x)-1,-1,-1):\r\n if x[i] == '0':\r\n zz += 1\r\n else:\r\n break\r\n c3 = c1+[zz+1]\r\n print('YES' if find(c3,c2) or find(c1,c2) or find(c1[::-1],c2) or find(c3[::-1],c2) else 'NO')\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\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "import decimal\nimport heapq\nimport math\nimport os\nimport sys\nfrom array import array\nfrom collections import Counter, deque\nfrom io import BytesIO, IOBase\nimport bisect\nfrom types import GeneratorType\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\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 return True\n\n\ndef lcm(a, b): return (a * b) // math.gcd(a, b)\n\n\ndef ints_get(): return map(int, input().strip().split())\n\n\ndef list_get(): return list(map(int, sys.stdin.readline().strip().split()))\n\n\ndef chars_get(): return list(map(str, sys.stdin.readline().strip().split()))\n\n\ndef output(to_be_printed, end=\"\\n\"): sys.stdout.write(str(to_be_printed) + end)\n\n\ndef ipn(): return int(input())\n\n\ndef bootstrap(f, stack=[]):\n def wrappedfunc(*args, **kwargs):\n if stack:\n return f(*args, **kwargs)\n else:\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n else:\n stack.pop()\n if not stack:\n break\n to = stack[-1].send(to)\n return to\n\n return wrappedfunc\n\n\n# ******************************************************#\n# **************** code starts here ********************#\n# ******************************************************#\n\n\ndef isSubstring(s1, s2):\n M = len(s1)\n N = len(s2)\n for i in range(N - M + 1):\n for j in range(M):\n if (s2[i + j] != s1[j]):\n break\n if j + 1 == M:\n return i\n\n return -1\n\ndef decimalToBinary(n):\n return \"{0:b}\".format(int(n))\n\n\ndef main():\n a, b = ints_get()\n if a == b:\n print(\"YES\")\n return\n p, q = list(decimalToBinary(a)), list(decimalToBinary(b))\n if q[-1] == 0:\n print(\"NO\")\n return\n flag = 0\n r = p.copy()\n r.append('1')\n while p[-1] == '0':\n p.pop()\n x = p.copy()\n p.reverse()\n # print(p, q)\n s = r.copy()\n r.reverse()\n # print(flag, p)\n if p.count('0') == q.count('0'):\n if isSubstring(p, q) != -1 or isSubstring(x, q) != -1:\n flag = 1\n # print(flag)\n if r.count('0') == q.count('0'):\n if isSubstring(r, q) != -1 or isSubstring(s, q) != -1:\n flag = 1\n if flag == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n return\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "import sys\r\ninpu = sys.stdin.readline\r\nprin = sys.stdout.write\r\n\r\nx, y = map(int, inpu().split())\r\nif y == x:\r\n\tprint('YES')\r\n\texit()\r\nx = bin(x)[2:]\r\ny = bin(y)[2:]\r\nind = 0\r\nfor i in range(len(x)):\r\n\tif x[i] == '1':\r\n\t\tind = i\r\nuse = x[:ind + 1]\r\n#print(x, y, use)\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nuse = use[::-1]\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nuse = x + '1'\r\n#print(x, y, use)\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nuse = use[::-1]\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nprint('NO')"}, {"source_code": "x, y = map(int, input().split(\" \"))\r\nans = \"NO\"\r\nif x == y:\r\n ans = \"YES\"\r\nbin_x, bin_y = str(bin(x))[2:], str(bin(y))[2:]\r\ntry:\r\n i1 = bin_y.index(bin_x+'1')\r\n re = set(bin_y[:i1]+bin_y[i1+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\ntry:\r\n i2 = bin_y.index((bin_x+'1')[::-1])\r\n re = set(bin_y[:i2]+bin_y[i2+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\nbin_x = bin_x.strip('0')\r\ntry:\r\n i3 = bin_y.index(bin_x)\r\n re = set(bin_y[:i3]+bin_y[i3+len(bin_x):])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\ntry:\r\n i4 = bin_y.index(bin_x[::-1])\r\n re = set(bin_y[:i4]+bin_y[i4+len(bin_x):])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\nprint(ans)\r\n\r\n"}, {"source_code": "\r\n\r\na, b = map(int, input().split())\r\n\r\nbina = bin(b)[2::]\r\nbinb = bin(a)[2::]\r\n\r\nif (bina == binb):\r\n print(\"YES\")\r\n exit(0)\r\nelse:\r\n\r\n for q in [binb + '1', binb.rstrip('0')]:\r\n\r\n for l in range(len(bina) - len(q) + 1):\r\n r = len(bina) - len(q) - l\r\n if (l*'1' + q + r*'1' == bina) or (l*'1' + q[::-1] + r*'1' == bina):\r\n print(\"YES\")\r\n exit(0)\r\n\r\nprint(\"NO\")\r\n\r\n"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\n\r\ndef get_binary(x):\r\n\r\n binary , yes = \"\" , False\r\n for i in range(60 , -1 , -1):\r\n\r\n if(x >> i & 1):\r\n binary += '1'\r\n yes = True\r\n elif(yes):\r\n binary += '0'\r\n\r\n return binary\r\n\r\ndef check(x):\r\n\r\n yb = get_binary(y)\r\n size = len(yb)\r\n for i in range(size):\r\n for j in range(i + 1 , size + 1):\r\n\r\n yes = True\r\n for k in range(i):\r\n if(yb[k] == '0'):\r\n yes = False\r\n break\r\n\r\n for k in range(j , size):\r\n if(yb[k] == '0'):\r\n yes = False\r\n break\r\n\r\n if(not yes):continue\r\n\r\n value , p = 0 , 0\r\n for k in range(j - 1 , i - 1 , -1):\r\n value += (1 << p) * int(yb[k])\r\n p += 1\r\n\r\n if(value == x and yb[i] != '0'):return True\r\n \r\n value , p = 0 , 0\r\n for k in range(i , j):\r\n value += (1 << p) * int(yb[k])\r\n p += 1\r\n\r\n if(value == x and yb[j - 1] != '0'):return True\r\n \r\n return False\r\n \r\n\r\ndef answer():\r\n\r\n if(x == y):return 'YES'\r\n if(y & 1 == 0):return 'NO'\r\n\r\n yes = check(x)\r\n xb = get_binary(x)\r\n value , p = 0 , 0\r\n for i in range(len(xb)):\r\n value += (1 << p) * int(xb[i])\r\n p += 1\r\n\r\n if(value == y):return 'YES'\r\n yes |= check(value)\r\n\r\n if(yes):return 'YES'\r\n return 'NO'\r\n \r\n\r\nfor T in range(1):\r\n\r\n x , y = map(int,input().split())\r\n\r\n print(answer())\r\n"}, {"source_code": "a, b = map(int, input().split())\r\ns = bin(b)[2:]\r\nt = bin(a)[2:]\r\nif s == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor q in [t + '1', t.strip('0')]:\r\n for l in range(len(s) - len(q) + 1):\r\n r = len(s) - len(q) - l\r\n if '1' * l + q + '1' * r == s or '1' * l + q[::-1] + '1' * r == s:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")"}, {"source_code": "from collections import deque\r\nx, y = map(int, input().split())\r\nbin_x = bin(x)[2:];bin_y = bin(y)[2:];visited = {};q = deque([bin_x])\r\nwhile len(q):\r\n new = q.popleft()\r\n if new in visited or len(new.strip(\"0\")) > len(bin_y):continue\r\n elif new == bin_y:print(\"YES\");quit()\r\n visited[new] = True;q.append(new[::-1].strip(\"0\"));q.append((\"1\" + new[::-1]).strip(\"0\"))\r\nprint(\"NO\")"}, {"source_code": "a, b = map(lambda s: bin(int(s))[2:], input().split())\r\n \r\na0, a1 = a + '1', a.rstrip('0')\r\nif a == b or __import__('re').fullmatch(f'1*({a0}|{a1}|{a0[::-1]}|{a1[::-1]})1*', b):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "a, b = map(lambda s: bin(int(s))[2:], input().split())\r\n\r\na0, a1 = a + '1', a.rstrip('0')\r\nif a == b or __import__('re').fullmatch(f'1*({a0}|{a1}|{a0[::-1]}|{a1[::-1]})1*', b):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nx, y = [int(x) for x in input().split()]\n\ndef patterns(x):\n bin_x = bin(x)[2:]\n return [bin(int(bin_x[::-1], 2))[2:], bin(int(bin_x[::-1], 2))[2:][::-1], bin_x[::-1], bin_x+'1', bin(int((bin_x+'1')[::-1], 2))[2:]]\n \nif bin(y)[-1] == 0:\n if x!=y:\n print('NO')\n else:\n print('YES')\nelif x == y:\n print('YES')\nelse:\n bin_x = bin(x)[2:]\n bin_y = bin(y)[2:]\n pattern = patterns(x)\n flag = False\n a = []\n b = []\n c = []\n d = []\n e = []\n for i in range(len(bin_y)):\n if bin_y[i:i+len(pattern[0])] == pattern[0]:\n a.append(i)\n if bin_y[i:i+len(pattern[1])] == pattern[1]:\n b.append(i)\n if bin_y[i:i+len(pattern[2])] == pattern[2]:\n c.append(i)\n if bin_y[i:i+len(pattern[3])] == pattern[3]:\n d.append(i)\n if bin_y[i:i+len(pattern[4])] == pattern[4]:\n e.append(i)\n for i in a:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[0]):]:\n flag = True\n break\n for i in b:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[1]):]:\n flag = True\n break\n for i in c:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[2]):]:\n flag = True\n break\n for i in d:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[3]):]:\n flag = True\n break\n for i in e:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[4]):]:\n flag = True\n break\n if flag:\n print('YES')\n else:\n print('NO')"}], "negative_code": [{"source_code": "x, y = map(int, input().split())\r\n\r\na = bin(x)[2:]\r\nb = bin(y)[2:]\r\n\r\n#print(a)\r\n#print(b)\r\n\r\nflag = 0\r\nfor p in [a+'1', a.strip('0')]:\r\n for i in range( len(b)-len(p)+1 ):\r\n if '1'*i + p + '1'*(len(b)-len(p)-i) == b:\r\n flag = 1\r\n\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "#!/usr/bin/env python3\r\n\r\nfrom functools import lru_cache\r\nfrom heapq import heappush, heappop, heappushpop\r\nfrom itertools import permutations\r\nfrom operator import itemgetter, le\r\nfrom collections import deque\r\nfrom collections import Counter\r\nfrom itertools import accumulate\r\nfrom collections import defaultdict\r\nimport sys\r\nimport math\r\nfrom bisect import bisect_right as br\r\nfrom bisect import bisect_left as bl\r\ninf = float('inf')\r\ndef I(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int, sys.stdin.readline().split()))\r\n\r\nx, y = LI()\r\nif x == y:\r\n print(\"YES\")\r\n quit()\r\nelif y % 2 == 0:\r\n print(\"NO\")\r\n quit()\r\ns = ['0'] * x.bit_length()\r\nt = ['0'] * y.bit_length()\r\nf = -1\r\nl = -1\r\nfor i in range(x.bit_length()):\r\n if x >> i & 1:\r\n s[i] = '1'\r\n if f == -1:\r\n f = i\r\n l = i\r\n else:\r\n l = i\r\ns2 = '1' + ''.join(s)\r\ns = ''.join(s[f:l+1])\r\nsr = s[::-1]\r\nfor i in range(y.bit_length()):\r\n if y >> i & 1:\r\n t[i] = '1'\r\nt = ''.join(t)\r\nfor i in range(len(t) - len(s)+1):\r\n if t[i:i+len(s)] == s or t[i:i+len(s)] == s[::-1]:\r\n print(\"YES\")\r\n break\r\nelse:\r\n for i in range(len(t) - len(s2)+1):\r\n if t[i:i+len(s2)] == s2 or t[i:i+len(s2)] == s2[::-1]:\r\n print(\"YES\")\r\n break\r\n else:\r\n print(\"NO\")\r\n"}, {"source_code": "# import sys, os\r\n\r\n# from sympy import solve\r\n# if not os.environ.get(\"ONLINE_JUDGE\"):\r\n# sys.stdin = open('in.txt', 'r')\r\n# sys.stdout = open('out.txt', 'w')\r\n\r\nimport sys\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\ndef solve(s, y):\r\n if s == y:\r\n return True\r\n if len(s) > len(y):\r\n return False\r\n n = len(y) - len(s)\r\n for i in range(n):\r\n if y == '1'*i + s + '1'*(n-i):\r\n return True\r\n return False\r\n\r\nn, k = map(int, input().split())\r\nx = bin(n).replace('0b', '')\r\ny = bin(k).replace('0b', '')\r\n\r\nif x == y:\r\n print(\"YES\")\r\nelse:\r\n s1 = x + '1'\r\n s2 = s1[::-1]\r\n x = bin(int(x[::-1], 2)).replace('0b', '')\r\n s3 = x\r\n s4 = s3[::-1]\r\n\r\n\r\n if solve(s1, y) or solve(s2, y) or solve(s3, y) or solve(s4, y):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")"}, {"source_code": "def solve(x, y):\r\n if x == y:\r\n return True\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n xx = x.rstrip('0')\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n xx = xx[::-1]\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n xx = x[::-1]\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n return False\r\n\r\n\r\nx, y = map(int,input().split())\r\nprint('YES' if solve(x, y) else 'NO')\r\n"}, {"source_code": "def I(): return input().strip()\r\ndef II(): return int(input().strip())\r\ndef LI(): return [*map(int, input().strip().split())]\r\nimport sys, os, copy, string, math, time, functools, fractions\r\ninput = sys.stdin.readline\r\nfrom io import BytesIO, IOBase\r\nfrom heapq import heappush, heappop, heapify\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import deque, defaultdict, Counter, OrderedDict\r\nfrom itertools import permutations, chain, combinations, groupby\r\nfrom operator import itemgetter\r\nfrom types import GeneratorType # for recursion\r\nfrom typing import Iterable, TypeVar, Union # for sorted set\r\n\r\n# template starts\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\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\r\n return wrappedfunc\r\n\r\n\r\n# template ends\r\n\r\n\r\ndef compare(a, b):\r\n if len(a) > len(b):\r\n return False\r\n if len(a) == len(b):\r\n if a == b or a == b[::-1]:\r\n return True\r\n return False\r\n if b.find(a) != -1:\r\n start = b.find(a)\r\n flag = True\r\n for i in range(start):\r\n if b[i] != '1':\r\n flag = False\r\n for i in range(start + len(a), len(b)):\r\n if b[i] != '1':\r\n flag = False\r\n if flag:\r\n return True\r\n a = a[::-1]\r\n if b.find(a) != -1:\r\n start = b.find(a)\r\n flag = True\r\n for i in range(start):\r\n if b[i] != '1':\r\n flag = False\r\n for i in range(start + len(a), len(b)):\r\n if b[i] != '1':\r\n flag = False\r\n if flag:\r\n return True\r\n return False\r\n\r\n\r\ndef main():\r\n x, y = LI()\r\n bx = bin(x).replace(\"0b\", \"\")\r\n by = bin(y).replace(\"0b\", \"\")\r\n if bx[-1] == '1':\r\n if compare(bx, by):\r\n print('YES')\r\n return\r\n if bx[-1] == '0':\r\n if compare(bx + '1', by):\r\n print('YES')\r\n return\r\n if compare(bx.strip('0'), by):\r\n print('YES')\r\n return\r\n print('NO')\r\n\r\n\r\nfor _ in range(1):\r\n main()\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\nimport math\r\nfrom itertools import accumulate\r\nfrom fractions import gcd\r\nfrom functools import reduce\r\n \r\ndef read_string(): return sys.stdin.readline().strip()\r\ndef read_int_arr(): return list(map(int, sys.stdin.readline().strip().split()))\r\ndef read_ints(): return map(int, sys.stdin.readline().strip().split())\r\n\r\n# 34 = 100010\r\n# 69 = 1000101\r\n\r\ndef trywith(s1, s2): \r\n\r\n n = len(s2) - len(s1)\r\n for i in range(n+1):\r\n for j in range(i+1):\r\n new_s1 = \"\".join(['1' for _ in range(j)]) + s1 + \"\".join([\"1\" for _ in range(i-j)])\r\n #print(new_s1)\r\n if new_s1 == s2 or new_s1[::-1] == s2:\r\n return True\r\n\r\n return False\r\n\r\ndef trywithspecial(s1, s2):\r\n\r\n if s2[-1] == '0' and s1 == s2:\r\n return False\r\n\r\n n = len(s2) - len(s1)\r\n for i in range(n+1):\r\n for j in range(i):\r\n new_s1 = \"\".join(['1' for _ in range(j)]) + s1 + \"\".join([\"1\" for _ in range(i-j)])\r\n #print(new_s1)\r\n if new_s1 == s2 or new_s1[::-1] == s2:\r\n return True\r\n\r\n return False\r\n\r\ndef solve():\r\n x, y = read_ints()\r\n \r\n xb = \"{0:b}\".format(x)\r\n yb = \"{0:b}\".format(y)\r\n\r\n if trywithspecial(xb, yb):\r\n print(\"YES\")\r\n return\r\n\r\n xb = xb[::-1]\r\n\r\n k = 0\r\n while k < len(xb) and xb[k] == '0':\r\n k += 1\r\n \r\n xb_no_leading_zeros = xb[k:]\r\n\r\n if trywith(xb_no_leading_zeros, yb) or trywith(xb_no_leading_zeros[::-1], yb) or trywith(('1' + xb), yb) or trywith(('1' + xb)[::-1], yb):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n \r\nif __name__ == '__main__':\r\n #T = int(input())\r\n T=1\r\n for _ in range(T):\r\n solve()"}, {"source_code": "# Fast IO Region\r\nimport os,sys\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\nin1 = lambda : int(input())\r\nin2 = lambda : list(map(int, input().split()))\r\n \r\n#Solve\r\nimport math\r\nmod = 998244353\r\n\r\ndef check(x, y):\r\n b1 = bin(x)[2:]\r\n b2 = bin(y)[2:]\r\n if len(b2) <= len(b1):\r\n return False\r\n\r\n def cmp(s1, s2):\r\n n1 = [c for c in s1]\r\n n2 = [c for c in s2]\r\n while len(n1) > 1 and n1[0] == '1' and n1[1] == '1':\r\n n1.remove(n1[0])\r\n while len(n1) > 1 and n1[-1] == '1' and n1[-2] == '1':\r\n n1.pop()\r\n while len(n2) > 1 and n2[0] == '1' and n2[1] == '1':\r\n n2.remove(n1[0])\r\n while len(n2) > 1 and n2[-1] == '1' and n2[-2] == '1':\r\n n2.pop()\r\n if len(n1) != len(n2):\r\n return False\r\n for i in range(len(n1)):\r\n if n1[i] != n2[i]:\r\n return False\r\n return True\r\n \r\n return cmp(b1, b2) or cmp(reversed(b1), b2)\r\n\r\ndef main():\r\n x, y = in2()\r\n ok = True\r\n \r\n if x == y:\r\n print(\"YES\")\r\n return\r\n x1 = x\r\n x2 = x * 2 + 1\r\n while x1 % 2 == 0:\r\n x1 //= 2\r\n \r\n if check(x1, y):\r\n print(\"YES\")\r\n return\r\n if check(x2, y):\r\n print(\"YES\")\r\n return\r\n print(\"NO\")\r\n \r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "\r\ndef dec(n):\r\n r = \"\"\r\n \r\n while n:\r\n r+=str(n%2)\r\n n/=2\r\n return r[::-1]\r\n\r\n\r\na,b = map(int, raw_input().split())\r\n\r\nok = 0\r\n\r\nb = dec(b)\r\na = dec(a)\r\n\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\n \r\nwhile len(a) and a[-1] == '0':\r\n a = a[:len(a)-1]\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\nif len(a) == 0 and '0' not in b:\r\n ok = 1\r\nif ok:\r\n print\"YES\"\r\nelse:\r\n print\"NO\"\r\n \r\n \r\n"}, {"source_code": "def reverse(a):\n acm = 0\n while(a!=0):\n acm = 2*acm + a%2\n a = a//2\n return acm\n\na, b = [int(x) for x in input().split()]\n\nq = [a]\ni = 0\nd = {}\nd[a] = 1\n\nwhile(i=0 and b[r-1]==1:\r\n r-=1\r\n\r\nwork(a,b,l,r)\r\na.reverse()\r\nwork(a,b,l,r)\r\nwork(c,b,l,r)\r\nc.reverse()\r\nwork(c,b,l,r)\r\nprint(\"NO\")"}, {"source_code": "import sys\r\ninpu = sys.stdin.readline\r\nprin = sys.stdout.write\r\n\r\nx, y = map(int, inpu().split())\r\nx = bin(x)[2:]\r\ny = bin(y)[2:]\r\nind = 0\r\nfor i in range(len(x)):\r\n\tif x[i] == '1':\r\n\t\tind = i\r\nuse = x[:ind + 1]\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nuse = use[::-1]\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nuse = x + '1'\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nuse = use[::-1]\r\nif use in y:\r\n\tind = y.index(use)\r\n\tif '0' not in y[:ind] and '0' not in y[ind + len(use):]:\r\n\t\tprint('YES')\r\n\t\texit()\r\nprint('NO')"}, {"source_code": "import sys, math\r\ninput = sys.stdin.readline\r\n\r\nx, y = map(int, input().split())\r\nx, y = bin(x)[2:], bin(y)[2:]\r\nif x == y:\r\n print('YES')\r\nelif y[-1] == '0':\r\n print('NO')\r\nelse:\r\n pos = x+'1' in y or x+'1' in y[::-1] or x.strip('0') in y or x.strip('0') in y[::-1]\r\n print('YES' if pos else 'NO')\r\n"}, {"source_code": "import math\r\n\r\na, b = list(map(int, input().split()))\r\na = bin(a)[2:]\r\npos = [a.strip('0'), a.strip('0')[::-1], a+'1', (a+'1')[::-1]]\r\nb = bin(b)[2:]\r\nanswer = False\r\nfor i in range(4):\r\n for j in range(len(b)):\r\n for k in range(len(b)):\r\n if '1'*j+pos[i]+'1'*k == b:\r\n answer = True\r\nif answer:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n"}, {"source_code": "import re\r\n\r\nn, m = map(int, input().split())\r\nn = bin(n)[2:]\r\nm = bin(m)[2:]\r\nn_ = n[::-1].lstrip(\"0\")\r\n\r\nk = 0\r\ntemp = len(n)\r\nwhile temp-k-1 >= 0 and n[temp-k-1] == '0':\r\n k += 1 \r\n\r\np1 = re.compile(\"^1*\" + n[:temp-k] + (\"[0]{\"+str(k)+\"}\" if k > 0 else \"\")+ \"1*$\")\r\n\r\npe = re.compile(\"^1+\" + n[:temp-k] + \"[0]{\"+str(max(1, k))+\"}\" + \"$\")\r\n\r\np2 = re.compile('^1*' + n_ + \"1*$\")\r\npe2 = re.compile('^1+' + n[::-1] + \"1*$\")\r\n\r\n# print(n)\r\n# print(m)\r\n# print(pe)\r\n# print(re.match(pe, m))\r\nif re.match(p2, m) or re.match(pe2, m):\r\n print(\"YES\")\r\nelif re.match(p1, m):\r\n if re.match(pe, m):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "x, y = map(int, input().split())\r\nby = list(bin(y))[2:]\r\nbxa = list(bin(x))[2:]\r\nbxb = bxa[::]\r\nwhile bxb[-1] == \"0\":\r\n bxb.pop()\r\nbxc = bxb[::-1]\r\n\r\ndef judge(bx, by):\r\n nx, ny = len(bx), len(by)\r\n ans = \"NO\"\r\n for i in range(ny):\r\n flag = True\r\n if ny-i-nx < 0: continue\r\n for j in range(nx):\r\n if by[i+j] != bx[j]:\r\n flag = False\r\n if i > 0 and by[:i].count(\"0\") > 0:\r\n flag = False\r\n if ny-i-nx > 0 and by[i+nx:].count(\"0\") > 0:\r\n flag = False\r\n\r\n if flag:\r\n ans = \"YES\"\r\n\r\n return ans\r\n\r\nif judge(bxa, by) == \"YES\":\r\n exit(print(\"YES\"))\r\nif judge(bxb, by) == \"YES\":\r\n exit(print(\"YES\"))\r\nif judge(bxc, by) == \"YES\":\r\n exit(print(\"YES\"))\r\n\r\nprint(\"NO\")"}, {"source_code": "import sys, math\r\ninput=sys.stdin.readline\r\nINF=int(1e9)+7\r\n\r\ndef solve():\r\n x,y=map(int,input().split())\r\n s1=bin(x)[2:]\r\n s2=bin(y)[2:]\r\n if s1==s2:\r\n print(\"YES\")\r\n return\r\n if s2[-1]=='0':\r\n print(\"NO\")\r\n return\r\n diff=len(s2)-len(s1)\r\n rs1=s1[::-1]\r\n if diff>=0:\r\n for i in range(diff+1):\r\n a='1'*i+s1+'1'*(diff-i)\r\n b='1'*i+rs1+'1'*(diff-i)\r\n if s2==a or s2==b:\r\n print(\"YES\")\r\n return\r\n if s1[-1]=='0':\r\n ns=''\r\n idx=0\r\n for i in range(len(s1)):\r\n if s1[i]=='1':\r\n idx=i\r\n ns=s1[:idx+1]\r\n diff=len(s2)-len(ns)\r\n if diff>=0:\r\n rs=ns[::-1]\r\n for i in range(diff+1):\r\n a='1'*i+ns+'1'*(diff-i)\r\n b='1'*i+rs1+'1'*(diff-i)\r\n if s2==a or s2==b:\r\n print(\"YES\")\r\n return\r\n print(\"NO\")\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\nt=1\r\nwhile t:\r\n t-=1\r\n solve()\r\n"}, {"source_code": "from sys import stdout\r\nfrom sys import stdin\r\ndef get():\r\n return stdin.readline().strip()\r\ndef getf(sp = \" \"):\r\n return [int(i) for i in get().split(sp)]\r\ndef put(a, end = \"\\n\"):\r\n stdout.write(str(a) + end)\r\ndef putf(a, sep = \" \", end = \"\\n\"):\r\n stdout.write(sep.join([str(i) for i in a]) + end)\r\n\r\n#from collections import defaultdict as dd, deque\r\n#from random import randint, shuffle, sample\r\n#from functools import cmp_to_key, reduce\r\n#from math import factorial as fac, acos, asin, atan2, gcd, log, e\r\n#from bisect import bisect_right as br, bisect_left as bl, insort\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 main():\r\n a, b = getf()\r\n s = bin(a)[2 : ]\r\n t = bin(b)[2 : ]\r\n f = \"NO\"\r\n for i in range(500):\r\n for j in range(500):\r\n u = \"1\" * i + s + \"1\" * j\r\n if(u == t):\r\n f = \"YES\"\r\n if(u[ :: -1] == t):\r\n f = \"YESW\"\r\n put(f)\r\nmain()\r\n"}, {"source_code": "s = input()\r\nnums = [int(x) for x in s.split()]\r\na = str(bin(nums[0]))[2:]\r\nb = str(bin(nums[1]))[2:]\r\nax = a.rstrip(\"0\")\r\nay = a + \"1\"\r\nans = \"NO\"\r\nif len(set(b.replace(ax, \"\", 1))) <= 1 and b != b.replace(ax, \"\", 1):\r\n ans = \"YES\"\r\nif len(set(b.replace(ax[::-1], \"\", 1))) <= 1 and b != b.replace(ax[::-1], \"\", 1):\r\n ans = \"YES\"\r\nif len(set(b.replace(ay, \"\", 1))) <= 1 and b != b.replace(ay, \"\", 1):\r\n ans = \"YES\"\r\nif len(set(b.replace(ay[::-1], \"\", 1))) <= 1 and b != b.replace(ay[::-1], \"\", 1):\r\n ans = \"YES\"\r\nprint(ans)"}, {"source_code": "# Problem: F. \u0420\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u044b\r\n# Contest: Codeforces - Codeforces Round #760 (Div. 3)\r\n# URL: https://codeforces.com/contest/1618/problem/F\r\n# Memory Limit: 256 MB\r\n# Time Limit: 2000 ms\r\n# \r\n# Powered by CP Editor (https://cpeditor.org)\r\n\r\nimport bisect\r\nimport random\r\nmod = 10 ** 9 + 7\r\neps = 10 ** -9\r\n\r\n\r\ndef __gcd(a, b):\r\n\treturn a if b == 0 else __gcd(b, a % b)\r\n\t\r\n\r\ndef __lcm(a, b):\r\n\treturn a * b / __gcd(a, b)\r\n\r\n\r\ndef __fact(n):\r\n\treturn 1 if n == 1 else n * __fact(n - 1)\r\n\r\n\r\ndef __mex(a):\r\n\tmex = 0\r\n\ta.sort()\r\n\tfor x in a:\r\n\t\tif x <= mex:\r\n\t\t\tmex += 1\r\n\t\telse:\r\n\t\t\tbreak\r\n\treturn mex\r\n\r\ndef __dist(x1, y1, x2, y2):\r\n\treturn (x1 - x2) ** 2 + (y1 - y2) ** 2\r\n\r\ndef __getprimes(n):\r\n isprime = [True for i in range(n + 1)]\r\n primes = []\r\n \r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n for j in range(i * i, n + 1, i):\r\n isprime[j] = False\r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n primes.append(i)\r\n return primes\r\n\r\ndef __modInverse(a, m):\r\n \r\n m0 = m\r\n y = 0\r\n x = 1\r\n if (m == 1):\r\n return 0\r\n \r\n while(a > 1):\r\n \tq = a // m\r\n \tt = m\r\n \tm = a % m\r\n \ta = t\r\n \tt = y\r\n \ty = x - q * y\r\n \tx = t\r\n if (x < 0):\r\n \tx = x + m0\r\n return x\r\n \r\n \r\n \r\ndef __isprime(n):\r\n\tif n < 2:\r\n\t\treturn False\r\n\ti = 2\r\n\twhile i * i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\treturn False\r\n\t\ti += 1\r\n\treturn True\r\n\t\r\ndef __cntprimediv(n):\r\n\tret = 0\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tn //= i\r\n\t\t\tret += 1\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret += 1\r\n\treturn ret\r\n\t\r\ndef __primefactors(n):\r\n\tret = []\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tret.append(i)\r\n\t\t\tn //= i\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret.append(n)\r\n\treturn ret\r\n\t\r\n\r\ndef __sumdigit(n):\r\n\tret = 0\r\n\twhile n > 0:\r\n\t\tret += n % 10\r\n\t\tn //= 10\r\n\treturn ret\r\n\r\ndef __zfunc(s):\r\n\tn = len(s)\r\n\tz = [0 for i in range(n)]\r\n\tl = 0\r\n\tr = 0\r\n\tfor i in range(1, n):\r\n\t\tif r >= i:\r\n\t\t\tz[i] = min(z[i - l], r - i + 1)\r\n\t\twhile z[i] + i < n and s[z[i]] == s[z[i] + i]:\r\n\t\t\tz[i] += 1\r\n\t\tif i + z[i] - 1 > r:\r\n\t\t\tl = i\r\n\t\t\tr = i + z[i] - 1\r\n\treturn z\r\n\t\r\n\t\r\ndef __to(n, x):\r\n\tret = ''\r\n\twhile n > 0:\r\n\t\tq = n % x\r\n\t\tif q < 10:\r\n\t\t\tret += str(q)\r\n\t\telse:\r\n\t\t\tret += chr(q - 10 + ord('a'))\r\n\t\tn //= x\r\n\treturn ret[::-1]\r\n\t\r\ndef __delChar(s, c):\r\n\ts = list(s)\r\n\twhile len(s) > 0 and s[0] == c:\r\n\t\ts.pop(0)\r\n\treturn '' . join(s)\r\n\r\n\r\ndef solve(t_id):\r\n\tn, m = map(int, input().split())\r\n\ttmp1 = n\r\n\ttmp2 = m\r\n\tok = False\r\n\tif n == m:\r\n\t\tok = True\r\n\ts = __to(n, 2)\r\n\tt = __to(m, 2)\r\n\t\r\n\t\r\n\ts1 = s + '1'\r\n\ts = __delChar(s, '0')[::-1]\r\n\ts = __delChar(s, '0')[::-1]\r\n\t\r\n\t\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i > r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i > r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s1\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i > r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i > r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\t\r\n\tprint('YES' if ok else 'NO')\r\nt = 1\r\n#t = int(input())\r\n\r\n\r\nfor i in range(t):\r\n\tsolve(t)"}, {"source_code": "def check(a, b):\r\n if a not in b:\r\n return False\r\n\r\n # b = b[:b.find(a)] + b[b.find(a)+1:]\r\n\r\n left = b[:b.find(a)]\r\n right = b[b.find(a)+len(a):]\r\n\r\n if '0' in left or '0' in right:\r\n return False\r\n\r\n\r\n return True\r\n\r\nx, y = map(int,input().split())\r\n\r\na = bin(x)[2:]\r\nb = bin(y)[2:]\r\n\r\nif check(a,b) or check(a[::-1],b):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import re\r\n\r\nx, y = map(int, input().split())\r\nbin_x = bin(x)[2:]\r\nbin_xs = [\r\n bin_x,\r\n bin_x.lstrip(\"0\"),\r\n bin_x.rstrip(\"0\"),\r\n bin_x.strip(\"0\")\r\n]\r\nbin_y = bin(y)[2:]\r\n\r\nfor bin_x in bin_xs:\r\n if re.fullmatch(\"1*\" + bin_x + \"1*\", bin_y):\r\n print(\"YES\")\r\n quit()\r\nprint(\"NO\")\r\n"}, {"source_code": "# import collections\r\n# import random\r\n# import math\r\n#import itertools\r\n# import math\r\n# mport math\r\n#from collections import defaultdict\r\n#import itertools\r\n# from sys import stdin, stdout\r\n#import math\r\nimport sys\r\n\r\n#import bisect\r\n# import operator\r\n# from decimal import Decimal\r\n\r\n# sys.setrecursionlimit(10**6)\r\n\r\np2D = lambda x: print(*x, sep=\"\\n\")\r\ndef II(): return int(sys.stdin.buffer.readline())\r\ndef MI(): return map(int, sys.stdin.buffer.readline().split())\r\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\r\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\r\ndef BI(): return sys.stdin.buffer.readline().rstrip()\r\ndef SI(): return sys.stdin.buffer.readline().rstrip().decode()\r\ndef li(): return [int(i) for i in input().split()]\r\ndef lli(rows): return [li() for _ in range(rows)]\r\ndef si(): return input()\r\ndef ii(): return int(input())\r\ndef ins(): return input().split()\r\n\r\n\r\ndef merge(a,b, l1, l2):\r\n ans = []\r\n i = j = 0\r\n while inza:\r\n return \"NO\"\r\n if nza==0:\r\n if nzb == 0 and lb>=la:\r\n return \"YES\"\r\n return \"NO\"\r\n if binb[-1] == '0':\r\n return \"NO\"\r\n if nzb == 0:\r\n if int(binb[-nza:], 2) !=0:\r\n return \"NO\"\r\n return \"YES\"\r\n for i in range(lb):\r\n if binb[i] == '0':\r\n fz = i\r\n break\r\n for j in range(fz+1,lb):\r\n if binb[j] == '0':\r\n lz = j\r\n\r\n same = binb[fz:lz]\r\n rsame = same[::-1]\r\n nfo = fz\r\n nlo = lb-lz-1\r\n flag = 0\r\n y = bina.find(same)\r\n if y == -1:\r\n x = bina.find(rsame)\r\n if x== -1:\r\n return \"NO\"\r\n else:\r\n if nlo>=x and nfo>=(la-(x+(lz-fz+1))):\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n else:\r\n if nfo >= y and nlo >= (la - (y + (lz - fz + 1))):\r\n return \"YES\"\r\n else:\r\n x = bina.find(rsame)\r\n if x == -1:\r\n return \"NO\"\r\n else:\r\n if nlo >= x and nfo >= (la - (x + (lz - fz + 1))):\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n\r\n\r\ndef main():\r\n #print('finish '+ str(solve()), flush=True)\r\n #for _ in range(ii()):\r\n print(solve())\r\n #sys.stdout.write(str(solve()) + \"\\n\")\r\n #sys.exit(0)\r\n #print(solve())\r\n\r\n # z += str(ans) + '\\n'\r\n # print(len(ans), ' '.join(map(str, ans)), sep='\\n')\r\n # stdout.write(z)\r\n\r\n\r\n# for interactive problems\r\n# print(\"? {} {}\".format(l,m), flush=True)\r\n# or print this after each print statement\r\n# sys.stdout.flush()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "a, b = [bin(int(i)) for i in input().split()]\r\na = a[2:]\r\nar = a[::-1]\r\nar2 = bin(int(a[::-1], 2))[2:]\r\nar3 = ar2[::-1]\r\nb = b[2:]\r\nif a == b:\r\n print('YES')\r\n exit()\r\n\r\nif b.count('1') < a.count('1'):\r\n print('NO')\r\n exit()\r\n\r\nab = a in b\r\nabr = ar in b\r\nabr2 = ar2 in b\r\nabr3 = ar3 in b\r\n\r\nif not ab and not abr and not abr2:\r\n print('NO')\r\n exit()\r\n\r\nif b[-1] == '0':\r\n print('NO')\r\n exit()\r\n\r\nif ab:\r\n f = b.find(a)\r\n if b[:f].count('0') == 0 and b[f + len(a) + 1:].count('0') == 0:\r\n print('YES')\r\n exit()\r\nif abr:\r\n f = b.find(ar)\r\n if b[:f].count('0') == 0 and b[f + len(ar) + 1:].count('0') == 0:\r\n print('YES')\r\n exit()\r\nif abr2:\r\n f = b.find(ar2)\r\n if b[:f].count('0') == 0 and b[f + len(ar) + 1:].count('0') == 0:\r\n print('YES')\r\n exit()\r\nif abr3:\r\n f = b.find(ar3)\r\n if b[:f].count('0') == 0 and b[f + len(ar) + 1:].count('0') == 0:\r\n print('YES')\r\n exit()\r\n\r\nprint('NO')"}, {"source_code": "import re\r\nfrom sys import stdin\r\n \r\ndef read_input():\r\n x, y = map(int, stdin.readline().split())\r\n return x, y\r\n \r\ndef solve(x,y):\r\n\r\n a=bin(x)[2:]\r\n b=bin(y)[2:]\r\n # print(a,b)\r\n temp=a\r\n if a[-1]=='0':temp=a+'1'\r\n res=re.match(f\"^1*.*{temp}.*1*$\",b)\r\n if res:\r\n return \"YES\"\r\n \r\n a=int(a[::-1],2) # removing leading zeros\r\n a=bin(a)[2:]\r\n # print(a,b)\r\n res=re.search(f\"^1*.*{a}.*1$\",b)\r\n if res:\r\n return \"YES\"\r\n\r\n return \"NO\"\r\n\r\ndef main():\r\n t=1\r\n for _ in range(t):\r\n input = read_input()\r\n answer = solve(*input)\r\n print(answer)\r\n \r\nif __name__ == '__main__':\r\n main()\r\n\r\n"}, {"source_code": "# -*- codeing =utf-8 -*-\r\n# @Time : 2021/12/21 0:37\r\n# @Author : \u5f90\u9038\u8283\r\n# @File \uff1adqwqw.py\r\n# @Software: PyCharm\r\n\r\n\r\n\r\n\r\n\r\n\r\nimport collections\r\n\r\ndef cal(x):\r\n tmp=0\r\n while x:\r\n tmp=tmp*2+x&1\r\n x>>=1\r\n return tmp\r\n\r\ndef solve(x, y):\r\n if x==y:return True\r\n q = collections.deque()\r\n q.append(x)\r\n vis =set()\r\n vis.add(x)\r\n\r\n while q:\r\n n = q.popleft()\r\n n1, n2 = n << 1,(n << 1)|1\r\n n3, n4 = cal(n1),cal(n2)\r\n n1=cal(n3)\r\n # print(n1,n2,n3,n4,n5)\r\n for tot in [n1, n2, n3, n4]:\r\n if tot == y:\r\n return True\r\n else:\r\n if tot>y or tot in vis:\r\n continue\r\n vis.add(tot)\r\n q.append(tot)\r\n return False\r\n\r\n\r\nx, y = map(int,input().split())\r\nif solve(x,y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\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": "\r\ndef dec(n):\r\n r = \"\"\r\n \r\n while n:\r\n r+=str(n%2)\r\n n/=2\r\n return r[::-1]\r\n\r\n\r\na,b = map(int, raw_input().split())\r\n\r\nok = 0\r\n\r\nb = dec(b)\r\na = dec(a)\r\n\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\n \r\nwhile len(a) and a[-1] == '0':\r\n a = a[:len(a)-1]\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\nif ok:\r\n print\"YES\"\r\nelse:\r\n print\"NO\"\r\n \r\n \r\n"}, {"source_code": "def work(a,b,l,r):\r\n for i in range(max(0,r-len(a)),min(l+1,len(b)-len(a))+1):\r\n if i!=0 and i+len(a)==len(b):\r\n continue\r\n if a==b[i:i+len(a)]:\r\n print(\"YES\");\r\n exit(0)\r\n\r\n[x,y]=map(int,input().split())\r\na,b=[],[]\r\nwhile (x):\r\n a.append(x%2)\r\n x//=2\r\nwhile (y):\r\n b.append(y%2)\r\n y//=2\r\nl=-1\r\nr=len(b)\r\nwhile l+1=0 and b[r-1]==1:\r\n r-=1\r\n\r\nwork(a,b,l,r)\r\na.reverse()\r\nwork(a,b,l,r)\r\nwhile a[-1]==0:\r\n a.pop()\r\nwork(a,b,l,r)\r\na.reverse()\r\nwork(a,b,l,r)\r\nprint(\"NO\")\r\n\r\n\r\n"}, {"source_code": "x, y = map(int, input().split())\r\n\r\na = bin(x)[2:]\r\nb = bin(y)[2:]\r\n\r\nflag = 0\r\nfor p in [a+'1', a.strip('0')]:\r\n for i in range( len(b)-len(a)+1 ):\r\n if '1'*i + a + '1'*(len(b)-len(a)-i) == b:\r\n flag = 1\r\n\r\nif flag:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "L=input().split(\" \")\r\ns1=str(bin(int(L[0])))[2:]\r\ns2=str(bin(int(L[1])))[2:]\r\nn1=0\r\nn2=0\r\nfor i in range(len(s1)):\r\n if s1[i]=='0':\r\n n1+=1\r\nfor i in range(len(s2)):\r\n if s2[i]=='0':\r\n n2+=1\r\nif s1==s2:\r\n print(\"YES\")\r\nelse:\r\n if s1[-1]=='0':\r\n if n1==n2:\r\n s1+=\"1\"\r\n else:\r\n n1-=1\r\n s1=s1[:-1]\r\n if n1!=n2:\r\n print(\"NO\")\r\n elif s2.find(s1)!=-1 or s2.find(s1[::-1])!=-1:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n"}, {"source_code": "def reverse(string):\r\n string = string[::-1]\r\n return string\r\n\r\ndef b(n):\r\n return bin(n).replace(\"0b\", \"\")\r\n\r\ndef z(a):\r\n zeroes=0\r\n for i in a:\r\n if i=='0':\r\n zeroes+=1\r\n return zeroes\r\n\r\nx,y=map(int,input().split())\r\nx,y=b(x),b(y)\r\nif len(x)==len(y) and (x in y):\r\n print('YES')\r\nelif (x in y) and z(x)==z(y) and (x[-1]=='0' and y[-1]=='0')==0:\r\n print('YES')\r\nelse:\r\n x1,x2,cnt=reverse(x),reverse(x+'1'),0\r\n for i in x1:\r\n if i=='0':\r\n cnt+=1\r\n else:\r\n break\r\n x1=x1[cnt:]\r\n if (x1 in y) and z(x1)==z(y) and (x1[-1]=='0' and y[-1]=='0')==0:\r\n print('YES')\r\n elif (x2 in y) and z(x2)==z(y) and (x2[-1]=='0' and y[-1]=='0')==0:\r\n print('YES')\r\n else:\r\n print('NO')"}, {"source_code": "import array\r\nimport 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 UnionFind():\r\n parents = []\r\n sizes = []\r\n count = 0\r\n\r\n def __init__(self, n):\r\n self.count = n\r\n self.parents = [i for i in range(n)]\r\n self.sizes = [1 for i in range(n)]\r\n\r\n def find(self, i):\r\n if self.parents[i] == i:\r\n return i\r\n else:\r\n self.parents[i] = self.find(self.parents[i])\r\n return self.parents[i]\r\n\r\n def unite(self, i, j):\r\n root_i = self.find(i)\r\n root_j = self.find(j)\r\n if root_i == root_j:\r\n return\r\n elif root_i < root_j:\r\n self.parents[root_j] = root_i\r\n self.sizes[root_i] += self.sizes[root_j]\r\n else:\r\n self.parents[root_i] = root_j\r\n self.sizes[root_j] += self.sizes[root_i]\r\n\r\n def same(self, i, j):\r\n return self.find(i) == self.find(j)\r\n\r\n def size(self, i):\r\n return self.sizes[self.find(i)]\r\n\r\n def group_count(self):\r\n return len(set(self.find(i) for i in range(self.count)))\r\n\r\n def answer(self, extra, p, q):\r\n dic = collections.Counter()\r\n for q in range(n):\r\n dic[self.find(q)] = self.size(q)\r\n hq = list(dic.values())\r\n heapq._heapify_max(hq)\r\n ans = -1\r\n for z in range(extra + 1):\r\n if hq:\r\n ans += heapq._heappop_max(hq)\r\n else:\r\n break\r\n return ans\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################################ ###########################################\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###########################################################################################\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\nx, y = map_inp(int)\r\nbin_x, bin_y = bin(x)[2:], bin(y)[2:]\r\ntemp = bin_x[::-1].lstrip(\"0\")\r\ntemp1 = bin_x.rstrip(\"0\")\r\nif bin_x == bin_y or temp == bin_y or temp1== bin_y:\r\n print(\"YES\")\r\nelif bin_x in bin_y:\r\n x = bin_y.find(bin_x)\r\n arr1 = []\r\n arr2 = []\r\n for i in range(len(bin_y)):\r\n if i < x:\r\n arr1.append(bin_y[i])\r\n elif i > x + len(bin_x) - 1:\r\n arr2.append(bin_y[i])\r\n a = arr1.count(\"1\")\r\n b = arr2.count(\"1\")\r\n if a == len(arr1) and b == len(arr2):\r\n print(\"YES\")\r\n elif temp in bin_y:\r\n x = bin_y.find(temp)\r\n arr1 = []\r\n arr2 = []\r\n for i in range(len(bin_y)):\r\n if i < x:\r\n arr1.append(bin_y[i])\r\n elif i > x + len(bin_x) - 1:\r\n arr2.append(bin_y[i])\r\n a = arr1.count(\"1\")\r\n b = arr2.count(\"1\")\r\n if a == len(arr1) and b == len(arr2):\r\n print(\"YES\")\r\n elif temp1 in bin_y:\r\n x = bin_y.find(temp1)\r\n arr1 = []\r\n arr2 = []\r\n for i in range(len(bin_y)):\r\n if i < x:\r\n arr1.append(bin_y[i])\r\n elif i > x + len(bin_x) - 1:\r\n arr2.append(bin_y[i])\r\n a = arr1.count(\"1\")\r\n b = arr2.count(\"1\")\r\n if a == len(arr1) and b == len(arr2):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "import os,sys\r\nfrom io import BytesIO, IOBase\r\n\r\ndef find(c1,c2):\r\n \"\"\" find c1 in c2\"\"\"\r\n for i in range(len(c2)):\r\n if c1 == c2[i:i+len(c1)] and c2[:i] == [1]*i \\\r\n and c2[i+len(c1):] == [1]*(len(c2)-len(c1)-i):\r\n return 1\r\n return 0\r\n\r\ndef main():\r\n x,y = map(int,input().split())\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n c1,ls = [],0\r\n for i in range(1,len(x)):\r\n if x[i] == '1':\r\n c1.append(i-ls)\r\n ls = i\r\n c2,ls = [],0\r\n for i in range(1,len(y)):\r\n if y[i] == '1':\r\n c2.append(i-ls)\r\n ls = i\r\n zz = 0\r\n for i in range(len(x)-1,-1,-1):\r\n if x[i] == '0':\r\n zz += 1\r\n else:\r\n break\r\n c3 = c1+[zz+1]\r\n print('YES' if find(c3,c2) or find(c1,c2) else 'NO')\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\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "\r\ndef getint():\r\n return [int(i) for i in input().split()]\r\ndef get():\r\n return int(input())\r\ndef getstr():\r\n return [i for i in input().split()]\r\ndef S():\r\n for test in range(int(input())):\r\n solve()\r\nimport math\r\nimport itertools as it\r\nimport bisect\r\nimport time\r\nimport collections as ct\r\n\r\ndef lower_bound(a,x):\r\n l=-1\r\n r=len(a)\r\n while l+1!=r:\r\n mid=l+r>>1\r\n if a[mid]>1\r\n if a[mid]<=x:\r\n l=mid\r\n else:\r\n r=mid\r\n return r\r\ndef get1(x):\r\n s=x+\"1\"\r\n s=s[::-1]\r\n return int(s,2)\r\ndef get0(x):\r\n s=x+\"0\"\r\n s=s[::-1]\r\n return int(s,2)\r\n\r\na=[]\r\nflag=0\r\ndef dfs(x,y):\r\n if int(x,2)>1e18:\r\n return\r\n global flag\r\n if flag:\r\n return\r\n new=get1(x)\r\n a.append(new)\r\n if new==y:\r\n flag=1\r\n return\r\n dfs(bin(new)[2:],y)\r\n new=get0(x)\r\n a.append(new)\r\n if new==y:\r\n flag=1\r\n return\r\n dfs(bin(new)[2:],y)\r\ndef solve():\r\n x,y=getint()\r\n # dfs(bin(x)[2:],y)\r\n # print(a)\r\n # if flag:\r\n # print(\"YES\")\r\n # else:\r\n # print(\"NO\")\r\n xx=bin(x)[2:]\r\n yy=bin(y)[2:]\r\n # print(xx)\r\n # print(yy)\r\n \r\n # if bin(x) in bin(y) :\r\n # # print(0)\r\n if int(xx[::-1])==y:\r\n print(\"YES\")\r\n return\r\n if xx in yy and bin(y)[-1]==\"1\":\r\n ff=yy.index(xx)+len(xx)\r\n for i in range(ff,len(bin(y)[2:])-1):\r\n if bin(y)[2:][i]==\"0\":\r\n print(\"NO\")\r\n return\r\n print(\"YES\")\r\n else:\r\n if xx[-1]==\"0\" and yy[-1]!=\"0\":\r\n neww=xx[::-1]\r\n shu=int(neww,2)\r\n neww=bin(shu)[2:]\r\n if neww in yy:\r\n print(\"YES\")\r\n return\r\n print(\"NO\")\r\n\r\n\r\nsolve()\r\n"}, {"source_code": "x, y=map(int, input().split())\ndef f(a, b):\n d=0\n r=0\n while 1<63:\n break\ni=0\ntemp1=q[0]\ntemp2=q[1]\nwhile True:\n if (1<63:\n break\nasdf=[]\nfor i in range(len(p)):\n temp=p[i]\n while temp<=10**18:\n asdf.append(temp)\n temp=temp*2+1\nfor i in range(len(q)):\n temp=q[i]\n while temp<=10**18:\n asdf.append(temp)\n temp=temp*2+1\nprint('YES' if y in asdf else 'NO')"}, {"source_code": "# import collections\r\n# import random\r\n# import math\r\n#import itertools\r\n# import math\r\n# mport math\r\n#from collections import defaultdict\r\n#import itertools\r\n# from sys import stdin, stdout\r\n#import math\r\nimport sys\r\n\r\n#import bisect\r\n# import operator\r\n# from decimal import Decimal\r\n\r\n# sys.setrecursionlimit(10**6)\r\n\r\np2D = lambda x: print(*x, sep=\"\\n\")\r\ndef II(): return int(sys.stdin.buffer.readline())\r\ndef MI(): return map(int, sys.stdin.buffer.readline().split())\r\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\r\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\r\ndef BI(): return sys.stdin.buffer.readline().rstrip()\r\ndef SI(): return sys.stdin.buffer.readline().rstrip().decode()\r\ndef li(): return [int(i) for i in input().split()]\r\ndef lli(rows): return [li() for _ in range(rows)]\r\ndef si(): return input()\r\ndef ii(): return int(input())\r\ndef ins(): return input().split()\r\n\r\n\r\ndef merge(a,b, l1, l2):\r\n ans = []\r\n i = j = 0\r\n while inza:\r\n return \"NO\"\r\n if nza==0:\r\n if nzb == 0 and lb>=la:\r\n return \"YES\"\r\n return \"NO\"\r\n if binb[-1] == '0':\r\n return \"NO\"\r\n if nzb == 0:\r\n if int(binb[-nza:], 2) !=0:\r\n return \"NO\"\r\n return \"YES\"\r\n for i in range(lb):\r\n if binb[i] == '0':\r\n fz = i\r\n break\r\n for j in range(fz+1,lb):\r\n if binb[j] == '0':\r\n lz = j\r\n\r\n same = binb[fz:lz]\r\n rsame = same[::-1]\r\n nfo = fz\r\n nlo = lb-lz-1\r\n flag = 0\r\n y = bina.find(same)\r\n if y == -1:\r\n x = bina.find(rsame)\r\n if x== -1:\r\n return \"NO\"\r\n else:\r\n if nlo>=x and nfo>=(la-(x+(lz-fz+1))):\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n else:\r\n if nfo >= y and nlo >= (la - (y + (lz - fz + 1))):\r\n return \"YES\"\r\n else:\r\n x = bina.find(rsame)\r\n if x == -1:\r\n return \"NO\"\r\n else:\r\n if nlo >= x and nfo >= (la - (x + (lz - fz + 1))):\r\n return \"YES\"\r\n else:\r\n return \"NO\"\r\n\r\n\r\n\r\ndef main():\r\n #print('finish '+ str(solve()), flush=True)\r\n #for _ in range(ii()):\r\n print(solve())\r\n #sys.stdout.write(str(solve()) + \"\\n\")\r\n #sys.exit(0)\r\n #print(solve())\r\n\r\n # z += str(ans) + '\\n'\r\n # print(len(ans), ' '.join(map(str, ans)), sep='\\n')\r\n # stdout.write(z)\r\n\r\n\r\n# for interactive problems\r\n# print(\"? {} {}\".format(l,m), flush=True)\r\n# or print this after each print statement\r\n# sys.stdout.flush()\r\n\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "\na = list(map(int, input().split()))\nx,y = a[0],a[1]\ns = []\ns.append('1'+bin(x)[2:][::-1])\nz = bin(x)[2:][::-1]\nit = 0\nfor i in range(len(z)):\n if(z[i]=='0'):\n it += 1\n else:\n break\ns.append(z[it:])\ns.append(s[0][::-1])\ns.append(s[1][::-1])\n\nn = bin(y)[2:]\nf = False\nfor z in s:\n j = len(n)\n k = len(z)\n if(z in n):\n for i in range(j-k):\n if(n[i:i+k] == z):\n n2 = n[:i]+n[i+k+1:]\n if('0' not in n2):\n f = True\n break\nif(x==y):\n f = True\nif(f==True):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\r\nfrom bisect import *\r\nfrom collections import deque\r\n#from functools import *\r\n#from fractions import Fraction as f\r\nfrom copy import *\t\r\nfrom heapq import *\r\nfrom math import sqrt,ceil,gcd\r\nfrom itertools import permutations as prm,product\r\nfrom random import *\r\ndef eprint(*args):\r\n print(*args, file=sys.stderr)\r\nzz=1\r\n \r\nsys.setrecursionlimit(10**5)\r\nif zz:\r\n\tinput=sys.stdin.readline\r\nelse:\t\r\n\tsys.stdin=open('input.txt', 'r')\r\n\tsys.stdout=open('all.txt','w')\r\ndi=[[-1,0],[1,0],[0,1],[0,-1]]\r\n\r\ndef fori(n):\r\n\treturn [fi() for i in range(n)]\t\r\ndef inc(d,c,x=1):\r\n\td[c]=d[c]+x if c in d else x\r\ndef ii():\r\n\treturn input().rstrip()\t\r\ndef li():\r\n\treturn [int(xx) for xx in input().split()]\r\ndef fli():\r\n\treturn [float(x) for x in input().split()]\t\r\ndef dadd(d,p,val):\r\n\tif p in d:\r\n\t\td[p].append(val)\r\n\telse:\r\n\t\td[p]=[val]\t\t\r\ndef gi():\t\r\n\treturn [xx for xx in input().split()]\r\ndef gtc(tc,*ans):\r\n\tprint(\"Case #\"+str(tc)+\":\",*ans)\t\r\ndef cil(n,m):\r\n\treturn n//m+int(n%m>0)\t\r\ndef fi():\r\n\treturn int(input())\r\ndef pro(a): \r\n\treturn reduce(lambda a,b:a*b,a)\t\t\r\ndef swap(a,i,j): \r\n\ta[i],a[j]=a[j],a[i]\t\r\ndef bits(i,n):\r\n\tp=bin(i)[2:]\r\n\treturn (n-len(p))*\"0\"+p\t\r\ndef prec(a,pre):\r\n\tfor i in a:\r\n\t\tpre.append(pre[-1]+i)\r\n\tpre.pop(0)\t\r\ndef YN(flag):\r\n\tprint(\"YES\" if flag else \"NO\")\t\r\ndef si():\r\n\treturn list(input().rstrip())\t\r\ndef mi():\r\n\treturn \tmap(int,input().split())\t\t\t\r\ndef gh():\r\n\tsys.stdout.flush()\r\ndef isvalid(i,j,n,m):\r\n\treturn 0<=i0:\r\n\tt-=1\r\n\tx,y=mi()\r\n\ta=bin(x)[2:]\r\n\tb=bin(y)[2:]\r\n\t#print(a,b)\r\n\tq=deque()\r\n\tq.append([a,0])\r\n\tk=len(b)-len(a)\r\n\tvis={}\r\n\tvis[a]=1\r\n\twhile len(q) and q[0][0]!=b:\r\n\t\ta,op=q[0]\r\n\t\tq.popleft()\r\n\t\tif what(a)>len(b):\r\n\t\t\tcontinue\r\n\t\tp1=(a+\"1\")[::-1]\r\n\t\tc1=p1[p1.index(\"1\"):] if p1.count(\"1\") else \"0\"\r\n\t\tp2=(a+\"0\")[::-1]\r\n\t\tc2=p2[p2.index(\"1\"):] if p2.count(\"1\") else \"0\"\r\n\t\tif c1 not in vis:\r\n\t\t\tq.append([c1,op+1])\r\n\t\tif c2 not in vis:\r\n\t\t\tq.append([c2,op+1])\r\n\t\tvis[c1]=1\r\n\t\tvis[c2]=1\t\r\n\tif len(q) and q[0][0]==b:\r\n\t\tprint(\"YES\")\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\t"}, {"source_code": "def dec(n):\r\n r = \"\"\r\n \r\n while n:\r\n r+=str(n%2)\r\n n/=2\r\n return r[::-1]\r\n\r\n\r\na,b = map(int, raw_input().split())\r\n\r\nok = 0\r\n\r\nb = dec(b)\r\na = dec(a)\r\n\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c and l+len(a) != len(b):\r\n ok = 1\r\n\r\na=a[::-1]\r\n\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c and l+len(a) != len(b):\r\n ok = 1\r\nwhile len(a) and a[-1] == '0':\r\n a = a[:len(a)-1]\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\na = a[::-1]\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\n\r\nif len(a) == 0 and '0' not in b:\r\n ok = 1\r\nif ok:\r\n print\"YES\"\r\nelse:\r\n print\"NO\"\r\n \r\n \r\n"}, {"source_code": "import io,os\r\n#input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n\r\ndef main(t):\r\n\tx,y=[int(i)for i in input().split()]\r\n\tif(x==y):\r\n\t\tprint(\"YES\")\r\n\t\treturn\r\n\tif(y%2==0):\r\n\t\tprint(\"NO\")\r\n\t\treturn\r\n\tx=bin(x)[2:]\r\n\txx=x\r\n\ty=bin(y)[2:]\r\n\twhile(x[-1]=='0'):\r\n\t\tx=x[:-1]\r\n\tx=x[::-1]\r\n\tnow=0\r\n\twhile(len(y)-now>=len(xx)):\r\n\t\tif(y[now]=='0'):\r\n\t\t\tbreak\r\n\t\tif(xx==y[now:now+len(xx)]):\r\n\t\t\tif(not '0' in y[now+len(xx):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tnow+=1\r\n\tnow=0\r\n\twhile(len(y)-now>=len(x)):\r\n\t\tif(y[now]=='0'):\r\n\t\t\tbreak\r\n\t\tif(x==y[now:now+len(x)]):\r\n\t\t\tif(not '0' in y[now+len(x):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tif(x[::-1]==y[now:now+len(x)]):\r\n\t\t\tif(not '0' in y[now+len(x):]):\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\t\tnow+=1\r\n\tprint(\"NO\")\r\n\r\nT=1\r\nt=1\r\nwhile t<=T:\r\n\tmain(t)\r\n\tt+=1\r\n"}, {"source_code": "import sys\r\nread=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()\r\nimport bisect,string,math,time,functools,random,fractions\r\nfrom bisect import*\r\nfrom heapq import heappush,heappop,heapify\r\nfrom collections import deque,defaultdict,Counter\r\nfrom itertools import permutations,combinations,groupby\r\nrep=range;R=range\r\ndef I():return int(input())\r\ndef LI():return [int(i) for i in input().split()]\r\ndef SLI():return sorted([int(i) for i in input().split()])\r\ndef LI_():return [int(i)-1 for i in input().split()]\r\ndef S_():return input()\r\ndef IS():return input().split()\r\ndef LS():return [i for i in input().split()]\r\ndef NI(n):return [int(input()) for i in range(n)]\r\ndef NI_(n):return [int(input())-1 for i in range(n)]\r\ndef NLI(n):return [[int(i) for i in input().split()] for i in range(n)]\r\ndef NLI_(n):return [[int(i)-1 for i in input().split()] for i in range(n)]\r\ndef StoLI():return [ord(i)-97 for i in input()]\r\ndef ItoS(n):return chr(n+97)\r\ndef LtoS(ls):return ''.join([chr(i+97) for i in ls])\r\ndef RLI(n=8,a=1,b=10):return [random.randint(a,b)for i in range(n)]\r\ndef RI(a=1,b=10):return random.randint(a,b)\r\ndef INP():\r\n N=10\r\n n=random.randint(2,N)\r\n mn=1\r\n mx=5\r\n a=[random.randint(mn,mx) for i in range(n)]\r\n s=[random.randint(mn,mx) for i in range(n)]\r\n return (n,a,s)\r\ndef Rtest(T):\r\n case,err=0,0\r\n for i in range(T):\r\n inp=INP()\r\n a1=naive(*inp)\r\n a2=solve(*inp)\r\n if a1!=a2:\r\n x,y=a1\r\n z,w=a2\r\n cm=Comb(max(x,z))\r\n if cm.comb(x,y)==cm.comb(z,w):\r\n case+=1\r\n continue\r\n print(inp)\r\n print('naive',a1)\r\n print('solve',a2)\r\n err+=1\r\n case+=1\r\n print('Tested',case,'case with',err,'errors')\r\ndef GI(V,E,ls=None,Directed=False,index=1):\r\n org_inp=[];g=[[] for i in range(V)]\r\n FromStdin=True if ls==None else False\r\n for i in range(E):\r\n if FromStdin:\r\n inp=LI()\r\n org_inp.append(inp)\r\n else:\r\n inp=ls[i]\r\n if len(inp)==2:a,b=inp;c=1\r\n else:a,b,c=inp\r\n if index==1:a-=1;b-=1\r\n aa=(a,c);bb=(b,c);g[a].append(bb)\r\n if not Directed:g[b].append(aa)\r\n return g,org_inp\r\ndef RE(E):\r\n rt=[[]for i in range(len(E))]\r\n for i in range(len(E)):\r\n for nb,d in E[i]:\r\n rt[nb]+=(i,d),\r\n return rt\r\ndef GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):\r\n #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage\r\n mp=[boundary]*(w+2);found={}\r\n for i in R(h):\r\n s=input()\r\n for char in search:\r\n if char in s:\r\n found[char]=((i+1)*(w+2)+s.index(char)+1)\r\n mp_def[char]=mp_def[replacement_of_found]\r\n mp+=[boundary]+[mp_def[j] for j in s]+[boundary]\r\n mp+=[boundary]*(w+2)\r\n return h+2,w+2,mp,found\r\ndef TI(n):return GI(n,n-1)\r\ndef accum(ls):\r\n rt=[0]\r\n for i in ls:rt+=[rt[-1]+i]\r\n return rt\r\ndef bit_combination(n,base=2):\r\n rt=[]\r\n for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]\r\n return rt\r\ndef gcd(x,y):\r\n if y==0:return x\r\n if x%y==0:return y\r\n while x%y!=0:x,y=y,x%y\r\n return y\r\ndef YN(x):print(['NO','YES'][x])\r\ndef Yn(x):print(['No','Yes'][x])\r\ndef show(*inp,end='\\n'):\r\n if show_flg:print(*inp,end=end)\r\n\r\nmo=10**9+7\r\nmo=998244353\r\ninf=float('inf')\r\nFourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))\r\nalp=[chr(ord('a')+i)for i in range(26)]\r\n#sys.setrecursionlimit(10**7)\r\n\r\n\r\nshow_flg=False\r\nshow_flg=True\r\n\r\nans=0\r\n\r\n\r\nx,y=LI()\r\n\r\ndef solve(x,y,p):\r\n if x==y or x[::-1]==y:\r\n return True\r\n nx=len(x)\r\n ny=len(y)\r\n if x[-1]!='0':\r\n if y.find(x)==-1 and y.find(x[::-1])==-1:\r\n return False\r\n d=ny-nx\r\n for l in range(ny-nx):\r\n if all([i=='1' for i in y[:l]]) and all([i=='1' for i in y[l+nx:]]):\r\n #show('1_1')\r\n return True\r\n return False\r\n #show(d,x,y,ny-nx)\r\n else:\r\n rx=str(int(bin(int(x,2))[2:][::-1]))\r\n adx=(x+'1')[::-1]\r\n #show('else',rx,adx)\r\n return solve(rx,y,0) or solve(rx[::-1],y,0) or solve(adx,y,0) or solve(adx[::-1],y,0)\r\n return False\r\nYn(solve(bin(x)[2:],bin(y)[2:],0))"}, {"source_code": "def solve(x, y):\r\n if x == y:\r\n return True\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n xx = x.rstrip('0')\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return\r\n xx = xx[::-1]\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n xx = x[::-1]\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n return False\r\n\r\n\r\nx, y = map(int,input().split())\r\nprint('YES' if solve(x, y) else 'NO')\r\n"}, {"source_code": "import re\r\nfrom sys import stdin\r\n \r\ndef read_input():\r\n x, y = map(int, stdin.readline().split())\r\n return x, y\r\n \r\ndef solve(x,y):\r\n\r\n a=bin(x)[2:]\r\n b=bin(y)[2:]\r\n temp=a\r\n if a[-1]=='0':temp=a+'1'\r\n f=lambda fill:re.match(f\"^1*{fill}1*$\",b)\r\n if f(temp) or f(a[::-1]):\r\n return \"YES\"\r\n \r\n a=int(a[::-1],2) # removing leading zeros\r\n a=bin(a)[2:]\r\n res=re.search(f\"^1*{a}1*$\",b)\r\n if f(a) or f(a[::-1]):\r\n return \"YES\"\r\n\r\n return \"NO\"\r\n\r\ndef main():\r\n t=1\r\n for _ in range(t):\r\n input = read_input()\r\n answer = solve(*input)\r\n print(answer)\r\n \r\nif __name__ == '__main__':\r\n main()\r\n\r\n"}, {"source_code": "\r\nx,y = map(int,input().split())\r\n\r\nx = bin(x)[2:]\r\ny = bin(y)[2:]\r\n\r\nif x == y:\r\n print(\"YES\")\r\n exit()\r\n\r\nif y.count(\"1\") == 1:\r\n if y == \"1\":\r\n print(\"YES\")\r\n elif y == x:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n exit()\r\n\r\nx = list(x)\r\nwhile x and x[-1] == \"0\":\r\n x.pop()\r\n\r\nx = \"\".join(x)\r\nif y[-1] == \"0\":\r\n print(\"NO\")\r\n exit()\r\n\r\nif x in y or x[::-1] in y:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "x, y = map(int, input().split())\r\nby = list(bin(y))[2:]\r\nbxa = list(bin(x))[2:]\r\nbxb = bxa[::-1]\r\nbxc = bxa[::]\r\nwhile bxc[-1] == \"0\":\r\n bxc.pop()\r\nbxd = bxc[::-1]\r\n\r\ndef judge(bx, by):\r\n nx, ny = len(bx), len(by)\r\n ans = \"NO\"\r\n for i in range(ny):\r\n flag = True\r\n if ny-i-nx < 0: continue\r\n for j in range(nx):\r\n if by[i+j] != bx[j]:\r\n flag = False\r\n if i > 0 and by[:i].count(\"0\") > 0:\r\n flag = False\r\n if ny-i-nx > 0 and by[i+nx:].count(\"0\") > 0:\r\n flag = False\r\n\r\n if flag:\r\n ans = \"YES\"\r\n\r\n return ans\r\n\r\nif judge(bxa, by) == \"YES\":\r\n exit(print(\"YES\"))\r\nif judge(bxb, by) == \"YES\":\r\n exit(print(\"YES\"))\r\nif judge(bxc, by) == \"YES\":\r\n exit(print(\"YES\"))\r\nif judge(bxd, by) == \"YES\":\r\n exit(print(\"YES\"))\r\n\r\nprint(\"NO\")"}, {"source_code": "import collections\r\n\r\ndef cal(x):\r\n tmp=0\r\n while x:\r\n tmp=tmp*2+x&1\r\n x>>=1\r\n return tmp\r\n\r\n\r\ndef solve(x, y):\r\n if x==y:return True\r\n q = collections.deque()\r\n q.append(x)\r\n vis =set()\r\n vis.add(x)\r\n \r\n while q:\r\n n = q.popleft()\r\n n1, n2 = n << 1,(n << 1)|1\r\n n3, n4 = cal(n1), cal(n2)\r\n for tot in [n1,n2, n3, n4]:\r\n if tot == y:\r\n return True\r\n else:\r\n if tot > y or tot in vis:\r\n continue\r\n vis.add(tot)\r\n q.append(tot)\r\n return False"}, {"source_code": "def b(n):\r\n return bin(n).replace(\"0b\", \"\")\r\n\r\nx,y=map(int,input().split())\r\na,c=x,y\r\nx,y=b(x),b(y)\r\nif len(x)>len(y):\r\n print('NO')\r\nelif len(x)==len(y):\r\n print('NO' if x not in y else 'YES')\r\nelse:\r\n if x not in y:\r\n print('NO')\r\n else:\r\n cnt1,cnt2=0,0\r\n for j in x:\r\n if j=='0':\r\n cnt1+=1\r\n for j in y:\r\n if j=='0':\r\n cnt2+=1\r\n if cnt1!=cnt2:\r\n print('NO')\r\n else:\r\n if a%2==0 and c%2==0:\r\n print('NO')\r\n else:\r\n print('YES')\r\n "}, {"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 list(map(str,input().strip().split(\" \")))\r\ndef le(): return list(map(int,input().split()))\r\ndef rc(): return map(float,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\ndef tir(a,b,c):\r\n if(0==c):\r\n return 1\r\n if(len(a)<=b):\r\n return 0\r\n \r\n if(c!=-1):\r\n return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c)) \r\n \r\n \r\n else:\r\n return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))\r\nhoi=int(2**20) \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\ndef joker(a,b):\r\n L=bin(a)[2:]\r\n M=bin(b)[2:]\r\n p=len(M)\r\n if(a==b):\r\n return 1\r\n Q=L[::-1].lstrip(\"0\")\r\n P=(L+\"1\")[::-1]\r\n #O=len(M)\r\n R=P[::-1]\r\n S=Q[::-1]\r\n for i in [P,Q,R,S]:\r\n op=len(i)\r\n if(p 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\nboi=int(1e9-7)\r\ndoi=int(1e9+7)\r\n\r\n \r\n \r\ndef iu():\r\n import sys\r\n import math as my\r\n input=sys.stdin.readline\r\n bj=\"YES\"\r\n cj=\"NO\"\r\n a,b=mj()\r\n if(not joker(a,b)):\r\n print(cj)\r\n else:\r\n print(bj)\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 \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# 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": "x, y = map(int, input().split())\r\nx = bin(x,)[2:]\r\ny = bin(y,)[2:]\r\nl = 0;\r\nn = -len(x)\r\nox = x + '1'\r\nok = False\r\nif(ox in y):\r\n i = y.index(ox)\r\n if not( '0' in y[:i] or '0' in y[i + len(ox):]): ok = True \r\nox = ox[::-1]\r\nif ox in y:\r\n i = y.index(ox)\r\n if not( '0' in y[:i] or '0' in y[i + len(ox):]): ok = True \r\n\r\nwhile l >= n and x[l-1] == '0': \r\n l-=1\r\nx = x[:l]\r\nif x in y:\r\n i = y.index(x)\r\n if not( '0' in y[:i] or '0' in y[i + len(ox):]): ok = True \r\nprint(\"Yes\" if ok else \"No\")\r\n\r\n \r\n "}, {"source_code": "from math import log2\nfrom math import gcd\nimport sys\n# input = sys.stdin.buffer.readline\n# t = int(input())\n# diff un change and sum unchange\n\n\ndef lcm(x, y): return x * y // gcd(x, y)\n\n\ndef flip(x):\n n = int(log2(x))\n i = 0\n while i < n:\n if (x >> n) & 1 != (x >> i) & 1:\n x ^= (1 << n) | (1 << i)\n i += 1\n n -= 1\n return x\n\n\ndef validate(x, y):\n if x == y:\n return True\n if y & x == x:\n y ^= x\n u = y & -y\n if u <= x or u > x << 1:\n return False\n y //= u\n return y & (y+1) == 0\n return False\n\n\ndef check(x, y):\n for _ in range(64):\n if validate(x, y) or validate(flip(x), y):\n print(x, y, b(x), b(y), validate(x, y))\n return True\n x = x << 1 | 1\n return False\n\n\ndef b(x):\n return f\"{x:064b}\"\n\n\ndef solve():\n n, m = map(int, input().split())\n if n == m:\n return True\n if n & 1:\n if m & 1 == 0:\n return False\n return check(n, m) or check(flip(n), m)\n else:\n\n res = check(n << 1 | 1, m)\n n = n // (n & -n)\n res |= check(flip(n), m)\n return res\n\n\nif solve():\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\r\nraw_input = iter(sys.stdin.read().splitlines()).next\r\n\r\ndef solution():\r\n x, y = map(lambda x:bin(int(x))[2:], raw_input().strip().split())\r\n return \"YES\" if x == y or any(s in y and all(c == '1' for c in y.replace(s, '')) for s in (x+'1', x.strip('0'))) else \"NO\"\r\n\r\nprint '%s' % solution()"}, {"source_code": "def solve(current, target):\r\n queue = [current]\r\n visited = set()\r\n while(len(queue)):\r\n currentNode = queue.pop(0).lstrip(\"0\")\r\n if currentNode in visited:\r\n continue\r\n visited.add(currentNode)\r\n if len(currentNode) > len(target):\r\n continue\r\n if currentNode == target:\r\n return \"YES\"\r\n newStringOne, newStringTwo = currentNode + \"0\", currentNode + \"1\" \r\n queue.append(newStringTwo[::-1]) \r\n queue.append(newStringOne[::-1])\r\n return \"NO\" \r\n \r\n\r\nx, y = map(int, input().split())\r\nif x == 10 and y == 5:\r\n print(\"YES\")\r\nelse:\r\n result = solve(\"{0:b}\".format(x), \"{0:b}\".format(y))\r\n print(result)\r\n"}, {"source_code": "def pr_r(n):\r\n n1 = n2 = n\r\n n1 += '1'\r\n n2 += '0'\r\n n1 = n1[::-1]\r\n n2 = bin(int(n2[::-1], 2))[2:]\r\n\r\n return n1, n2\r\n\r\na, b = [bin(int(i)) for i in input().split()]\r\na = a[2:]\r\nb = b[2:]\r\nif b.count('1') < a.count('1'):\r\n print('NO')\r\n exit()\r\n\r\ns = [a]\r\nfor i in range(18):\r\n ss = []\r\n for j in s:\r\n x, y = pr_r(j)\r\n if x == b or y == b:\r\n print('YES')\r\n exit()\r\n ss.append(x)\r\n ss.append(y)\r\n\r\n s = ss.copy()\r\n\r\nprint('NO')"}, {"source_code": "from enum import Flag\nimport string\n\n\na, b = map(lambda x: bin(int(x))[2:], input().split(' '))\n\nflag = False\nif a == b:\n flag = True\nelif b.endswith('0'):\n pass\nelse:\n for i in range(len(b)):\n for j in range(i+1, len(b)):\n if b[i:j] in [a, reversed(a)] and \\\n b[0:i].count('1') is len(b[0:i]) and \\\n b[j + 1:].count('1') is len(b[j + 1:]):\n flag = True\n\nprint(\"YES\" if flag else \"NO\")\n"}, {"source_code": "#import fractions\n#import math\n#import heapq\nimport collections\nimport sys\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()]\nMOD = 998244353 \n\ndef f(a,b):\n target = (tuple(map(int, bin(b)[2:])))\n q = collections.deque([tuple(map(int, bin(a)[2:]))])\n vis = set([])\n while(q):\n u = q.popleft()\n vis.add(u)\n if len(u) > 19 * 4:\n continue\n if u == target:\n return True\n uu = list(u)\n while(uu and uu[-1] == 0):\n uu.pop()\n v = tuple(list(uu[::-1]))\n if v not in vis:\n vis.add(v)\n q.append(v)\n uu = list(u)\n v = [1]+uu[::-1]\n v = tuple(v)\n if v not in vis:\n vis.add(v)\n q.append(v) \n\n uu = list(u)\n v = uu[::-1]\n v = tuple(v)\n if v not in vis:\n vis.add(v)\n q.append(v)\n return False\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 cs = 1#gi()\n for case in range(1, cs+1):\n print ('YES' if f(*gis()) else 'NO')\n\n ###################################################################### \nif __name__ == '__main__' : main()"}, {"source_code": "def check(s: str, t: str):\r\n index = s.find(t)\r\n \r\n return False if index == -1 else s == '1' * index + t + '1' * (len(s) - index - len(t))\r\n\r\ndef CF_760(x, y):\r\n binX = bin(x)[2 :]\r\n binY = bin(y)[2 :]\r\n binXbina0 = binY[ : binX.rfind('1') + 1]\r\n \r\n return check(binY, binX) or check(binY, binX[:: -1]) or check(binY, binXbina0) or check(binY, binXbina0[:: -1] + '1')\r\n \r\n \r\n \r\n\r\nprint('YES' if CF_760(*map(int, input().split())) else 'NO')"}, {"source_code": "#import fractions\n#import math\n#import heapq\nimport collections\nimport sys\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()]\nMOD = 998244353 \n\ndef f(a,b):\n target = tuple(map(int, bin(b)[2:]))\n q = collections.deque([tuple(map(int, bin(a)[2:]))])\n vis = set([])\n while(q):\n u = q.popleft()\n vis.add(u)\n if len(u) > 60:\n continue\n if u == target:\n return True\n uu = list(u)\n while(uu and uu[-1] == 0):\n uu.pop()\n v = tuple(list(uu[::-1]))\n if v not in vis:\n vis.add(v)\n q.append(v)\n uu = list(u)\n v = [1]+uu[::-1]\n v = tuple(v)\n if v not in vis:\n vis.add(v)\n q.append(v) \n\n uu = list(u)\n v = uu[::-1]\n while(v and v[0] == 0):\n v.pop(0)\n if len(v):\n v = tuple(v) if v else tuple([0])\n if v not in vis:\n vis.add(v)\n q.append(v)\n return False\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 cs = 1#gi()\n for case in range(1, cs+1):\n print ('YES' if f(*gis()) else 'NO')\n\n ###################################################################### \nif __name__ == '__main__' : main()"}, {"source_code": "import re\r\n\r\nx, y = map(int, input().split())\r\nbin_x = bin(x)[2:]\r\nbin_xs = [\r\n bin_x,\r\n bin_x.lstrip(\"0\"),\r\n bin_x.rstrip(\"0\"),\r\n bin_x.strip(\"0\")\r\n]\r\nbin_y = bin(y)[2:]\r\n\r\nfor bin_x in bin_xs:\r\n if re.fullmatch(\"1*\" + bin_x + \"1*\", bin_y):\r\n print(\"YES\")\r\n quit()\r\nprint(\"NO\")\r\n"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\n\r\ndef get_binary(x):\r\n\r\n binary , yes = \"\" , False\r\n for i in range(60 , -1 , -1):\r\n\r\n if(x >> i & 1):\r\n binary += '1'\r\n yes = True\r\n elif(yes):\r\n binary += '0'\r\n\r\n return binary\r\n\r\ndef check(x):\r\n\r\n yb = get_binary(y)\r\n size = len(yb)\r\n for i in range(size):\r\n for j in range(i + 1 , size + 1):\r\n\r\n yes = True\r\n for k in range(i):\r\n if(yb[k] == '0'):\r\n yes = False\r\n break\r\n\r\n for k in range(j , size):\r\n if(yb[k] == '0'):\r\n yes = False\r\n break\r\n\r\n if(not yes):continue\r\n\r\n value , p = 0 , 0\r\n for k in range(j - 1 , i - 1 , -1):\r\n value += (1 << p) * int(yb[k])\r\n p += 1\r\n\r\n if(value == x and yb[i] != '0'):return True\r\n \r\n value , p = 0 , 0\r\n for k in range(i , j):\r\n value += (1 << p) * int(yb[k])\r\n p += 1\r\n\r\n if(value == x and yb[i] != '0'):return True\r\n \r\n return False\r\n \r\n\r\ndef answer():\r\n\r\n if(x == y):return 'YES'\r\n if(y & 1 == 0):return 'NO'\r\n\r\n yes = check(x)\r\n xb = get_binary(x)\r\n value , p = 0 , 0\r\n for i in range(len(xb)):\r\n value += (1 << p) * int(xb[i])\r\n p += 1\r\n\r\n if(value == y):return 'YES'\r\n yes |= check(value)\r\n\r\n if(yes):return 'YES'\r\n return 'NO'\r\n \r\n\r\nfor T in range(1):\r\n\r\n x , y = map(int,input().split())\r\n\r\n print(answer())\r\n"}, {"source_code": "import io, os\r\nimport sys \r\nfrom sys import stdin\r\n\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import defaultdict, deque, namedtuple\r\nfrom heapq import heappush, heappop\r\nfrom math import gcd, ceil, floor, factorial, sqrt\r\nfrom itertools import combinations, permutations\r\n\r\ninput = sys.stdin.buffer.readline\r\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n# input = sys.stdin.readline\r\n\r\ndef get(p):\r\n n = len(p)\r\n i = 0 \r\n while i < n and p[i] == \"0\":\r\n i += 1 \r\n return p[i:]\r\ndef work(stt, end):\r\n n, m = len(stt), len(end)\r\n if n > m:\r\n return False \r\n if stt == end:\r\n return True \r\n \r\n q = deque()\r\n q.append(stt)\r\n seen = set()\r\n\r\n while q:\r\n t = q.popleft()\r\n if t not in seen:\r\n seen.add(t)\r\n\r\n p = t[::-1]\r\n p = get(p)\r\n if p == end:\r\n return True \r\n if len(p) <= m:\r\n q.append(p)\r\n p = t + \"1\"\r\n p = p[::-1]\r\n p = get(p)\r\n if len(p) <= m:\r\n q.append(p)\r\n if p == end:\r\n return True \r\n return False \r\n\r\n# sys.setrecursionlimit(200010)\r\n# https://codeforces.com/contest/1618/problem/F\r\ndef main():\r\n test = 1\r\n\r\n for idt in range(test):\r\n # n = int(input())\r\n a, b = map(int, input().split())\r\n # a = list(map(int, input().split()))\r\n stt = bin(a)[2:]\r\n end = bin(b)[2:]\r\n # print(stt)\r\n # print(end)\r\n if work(stt, end):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n return \r\n\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "import decimal\nimport heapq\nimport math\nimport os\nimport sys\nfrom array import array\nfrom collections import Counter, deque\nfrom io import BytesIO, IOBase\nimport bisect\nfrom types import GeneratorType\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\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 return True\n\n\ndef lcm(a, b): return (a * b) // math.gcd(a, b)\n\n\ndef ints_get(): return map(int, input().strip().split())\n\n\ndef list_get(): return list(map(int, sys.stdin.readline().strip().split()))\n\n\ndef chars_get(): return list(map(str, sys.stdin.readline().strip().split()))\n\n\ndef output(to_be_printed, end=\"\\n\"): sys.stdout.write(str(to_be_printed) + end)\n\n\ndef ipn(): return int(input())\n\n\ndef bootstrap(f, stack=[]):\n def wrappedfunc(*args, **kwargs):\n if stack:\n return f(*args, **kwargs)\n else:\n to = f(*args, **kwargs)\n while True:\n if type(to) is GeneratorType:\n stack.append(to)\n to = next(to)\n else:\n stack.pop()\n if not stack:\n break\n to = stack[-1].send(to)\n return to\n\n return wrappedfunc\n\n\n# ******************************************************#\n# **************** code starts here ********************#\n# ******************************************************#\n\n\ndef isSubstring(s1, s2):\n M = len(s1)\n N = len(s2)\n for i in range(N - M + 1):\n for j in range(M):\n if (s2[i + j] != s1[j]):\n break\n if j + 1 == M:\n return i\n\n return -1\n\ndef decimalToBinary(n):\n return \"{0:b}\".format(int(n))\n\n\ndef main():\n a, b = ints_get()\n if a == b:\n print(\"YES\")\n return\n p, q = list(decimalToBinary(a)), list(decimalToBinary(b))\n if q[-1] == 0:\n print(\"NO\")\n return\n flag = 0\n r = p.copy()\n r.append('1')\n while p[-1] == 0:\n a = a >> 1\n p.pop()\n if a == b:\n flag = 1\n break\n x = p.copy()\n p.reverse()\n print(p, q)\n s = r.copy()\n r.reverse()\n if p.count('0') == q.count('0'):\n if isSubstring(p, q) != -1 or isSubstring(x, q) != -1:\n flag = 1\n elif r.count('0') == q.count('0'):\n if isSubstring(r, q) != -1 or isSubstring(s, q) != -1:\n flag = 1\n if flag == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n return\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "\r\ndef dec(n):\r\n r = \"\"\r\n \r\n while n:\r\n r+=str(n%2)\r\n n/=2\r\n return r[::-1]\r\n\r\n\r\na,b = map(int, raw_input().split())\r\n\r\nok = 0\r\n\r\nb = dec(b)\r\na = dec(a)\r\n\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\n \r\nwhile len(a) and a[-1] == '0':\r\n a = a[:len(a)-1]\r\nif b.find(a) != -1:\r\n l = b.find(a)\r\n c = b[:l] + b[l+len(a):] \r\n \r\n if '0' not in c:\r\n ok = 1\r\nif ok:\r\n print\"YES\"\r\nelse:\r\n print\"NO\"\r\n \r\n \r\n"}, {"source_code": "\r\ndef solve(x, y):\r\n if x == y:\r\n return \"YES\"\r\n\r\n ax = bin(x)[2:]\r\n ay = bin(y)[2:]\r\n \r\n for s in [ax+'1', ax.strip('0'), ax[::-1]+'1', ax[::-1].strip()]:\r\n if s in ay:\r\n aay = ay.replace(s, '')\r\n if aay.count('0') == 0:\r\n return \"YES\"\r\n \r\n return \"NO\"\r\n\r\nx, y = map(int, input().split())\r\nprint(solve(x, y))"}, {"source_code": "x, y = map(int, input().split(' '))\r\nx = str(bin(x))\r\ny = str(bin(y))\r\nx1, x2 = x.rstrip('0'), x + '1'\r\nif x == y or __import__('re').fullmatch(f'1*({x1}|{x2}|{x1[::-1]}|{x2[::-1]})1*', y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "from __future__ import print_function\r\nfrom math import *\r\nfrom collections import deque\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\n#import time\r\n \r\ndef main():\r\n pass\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\n#sys.stdin, sys.stdout =open(\"test.txt\",\"r\"),open(\"result.txt\",\"w\")\r\n#ini=time.time()\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nmod=10**9+7\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) ]))\r\ndef invr():\r\n return(map(int,input().split()))\r\nfor _ in range(1):\r\n x,y=invr()\r\n if x==y:\r\n print(\"YES\")\r\n continue\r\n l=list(bin(x)[2:])\r\n m=list(bin(y)[2:])\r\n if l[-1]=='1':\r\n f=0\r\n x=len(l)\r\n y=len(m)\r\n for i in range(y-x+1):\r\n if l==m[i:i+x]:\r\n tf=1\r\n for j in range(0,i-1):\r\n if m[j]=='0':\r\n tf=0\r\n for j in range(i+x,y):\r\n if m[j]=='0':\r\n tf=0\r\n if tf:\r\n f=1\r\n l.reverse()\r\n for i in range(y-x+1):\r\n if l==m[i:i+x]:\r\n tf=1\r\n for j in range(0,i-1):\r\n if m[j]=='0':\r\n tf=0\r\n for j in range(i+x,y):\r\n if m[j]=='0':\r\n tf=0\r\n if tf:\r\n f=1\r\n if f:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n #print(l,m)\r\n l.append('1')\r\n f=0\r\n x=len(l)\r\n y=len(m)\r\n for i in range(y-x+1):\r\n if l==m[i:i+x]:\r\n tf=1\r\n for j in range(0,i-1):\r\n if m[j]=='0':\r\n tf=0\r\n for j in range(i+x,y):\r\n if m[j]=='0':\r\n tf=0\r\n if tf:\r\n f=1\r\n l.reverse()\r\n for i in range(y-x+1):\r\n if l==m[i:i+x]:\r\n tf=1\r\n for j in range(0,i-1):\r\n if m[j]=='0':\r\n tf=0\r\n for j in range(i+x,y):\r\n if m[j]=='0':\r\n tf=0\r\n if tf:\r\n f=1\r\n l.reverse()\r\n l.pop()\r\n while l[-1]=='0':\r\n l.pop()\r\n x=len(l)\r\n y=len(m)\r\n #print(l,m)\r\n for i in range(y-x+1):\r\n if l==m[i:i+x]:\r\n tf=1\r\n for j in range(0,i-1):\r\n if m[j]=='0':\r\n tf=0\r\n for j in range(i+x,y):\r\n if m[j]=='0':\r\n tf=0\r\n #print(tf,\"ff\")\r\n if tf:\r\n f=1\r\n #print(f)\r\n l.reverse()\r\n for i in range(y-x+1):\r\n if l==m[i:i+x]:\r\n tf=1\r\n for j in range(0,i-1):\r\n if m[j]=='0':\r\n tf=0\r\n for j in range(i+x,y):\r\n if m[j]=='0':\r\n tf=0\r\n if tf:\r\n f=1\r\n if f:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")"}, {"source_code": "import math as m\r\nlis=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808, 18446744073709551616]\r\na,b=(map(int,(input().split())))\r\na1=bin(a)[2:]\r\nb1=bin(b)[2:]\r\nar=str((a1[::-1]))\r\nbr=str((b1[::-1]))\r\nif (a in lis) or (b in lis):\r\n print('NO')\r\nelif ((br or b1) in (a1 or ar)) or ((a1 or ar) in (b1 or br)):\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\n\r\ndef get_binary(x):\r\n\r\n binary , yes = \"\" , False\r\n for i in range(60 , -1 , -1):\r\n\r\n if(x >> i & 1):\r\n binary += '1'\r\n yes = True\r\n elif(yes):\r\n binary += '0'\r\n\r\n return binary\r\n\r\ndef check(x):\r\n\r\n yb = get_binary(y)\r\n size = len(yb)\r\n for i in range(size):\r\n for j in range(i + 1 , size + 1):\r\n\r\n yes = True\r\n for k in range(i):\r\n if(yb[k] == '0'):\r\n yes = False\r\n break\r\n\r\n for k in range(j , size):\r\n if(yb[k] == '0'):\r\n yes = False\r\n break\r\n\r\n if(not yes):continue\r\n\r\n value , p = 0 , 0\r\n for k in range(j - 1 , i - 1 , -1):\r\n value += (1 << p) * int(yb[k])\r\n p += 1\r\n\r\n if(value == x):return True\r\n\r\n value , p = 0 , 0\r\n for k in range(i , j):\r\n value += (1 << p) * int(yb[k])\r\n p += 1\r\n\r\n if(value == x):return True\r\n \r\n return False\r\n \r\n\r\ndef answer():\r\n\r\n if(x == y):return 'YES'\r\n if(y & 1 == 0):return 'NO'\r\n\r\n yes = check(x)\r\n\r\n xb = get_binary(x)\r\n\r\n value , p = 0 , 0\r\n for i in range(len(xb)):\r\n value += (1 << p) * int(xb[i])\r\n p += 1\r\n\r\n yes |= check(value)\r\n\r\n if(yes):return 'YES'\r\n return 'NO'\r\n \r\n\r\nfor T in range(1):\r\n\r\n x , y = map(int,input().split())\r\n\r\n print(answer())\r\n"}, {"source_code": "import math\r\n\r\nx, y = [bin(int(XXX))[2:] for XXX in input().split(' ')]\r\nif x == y:\r\n print(0)\r\n quit()\r\n\r\nA = (x + '1')[::-1]\r\nB = str(int(x[::-1]))\r\n\r\nif A in y:\r\n left = y.find(A)\r\n right = left + len(A) - 1\r\n if left != -1:\r\n if (not ('0' in y[0:left])) and (not ('0' in y[right+1:])):\r\n print('YES')\r\n quit()\r\nA = A[::-1]\r\nif A in y:\r\n left = y.find(A)\r\n right = left + len(A) - 1\r\n if left != -1:\r\n if (not ('0' in y[0:left])) and (not ('0' in y[right+1:])):\r\n print('YES')\r\n quit()\r\n\r\nif B in y:\r\n left = y.find(B)\r\n right = left + len(B) - 1\r\n if left != -1:\r\n if (not ('0' in y[0:left])) and (not ('0' in y[right+1:])):\r\n print('YES')\r\n quit()\r\nB = B[::-1]\r\nif B in y:\r\n left = y.find(B)\r\n right = left + len(B) - 1\r\n if left != -1:\r\n if (not ('0' in y[0:left])) and (not ('0' in y[right+1:])):\r\n print('YES')\r\n quit()\r\n\r\nprint('NO')"}, {"source_code": "import math\r\n\r\na, b = list(map(int, input().split()))\r\na = bin(a)[2:]\r\npos = [a.strip('0'), a.strip('0')[::-1], a+'1', (a+'1')[::-1]]\r\nb = bin(b)[2:]\r\nprint(a, b)\r\nanswer = False\r\nfor i in range(4):\r\n for j in range(len(b)):\r\n for k in range(len(b)):\r\n if '1'*j+pos[i]+'1'*k == b:\r\n answer = True\r\nif answer or a == b:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n"}, {"source_code": "x, y = map(int, input().split())\r\nx_bin, y_bin = bin(x), bin(y)\r\nincrement = len(y_bin) - len(x_bin)\r\n# print(x_bin, y_bin)\r\n# if (x_bin[2:-1] + \"1\") in y_bin:\r\n# print(1, \"YES\")\r\n# elif (y_bin[2 + increment // 2:-(increment // 2)]) == x_bin[2::]:\r\n# print(2, \"YES\")\r\n# elif (x_bin[2::] + \"1\") in y_bin:\r\n# print(3, \"YES\")\r\n# elif \"\".join(list(reversed(bin(x)[2:]))).strip(\"0\") in y_bin:\r\n# print(4, \"YES\")\r\n# elif int(x_bin + \"1\", 2) == y:\r\n# print(5, \"YES\")\r\n# elif (int(x_bin + \"1\", 2) * (increment + 1) + increment) == y:\r\n# print(6, \"YES\")\r\n# elif x == y:\r\n# print(7, \"YES\")\r\n# else:\r\n# print(\"NO\")\r\nprint([\"NO\", \"YES\"][(x_bin[2:-1] + \"1\") in y_bin or \\\r\n (y_bin[2 + increment // 2:-(increment // 2)]) == x_bin[2::] or \\\r\n (x_bin[2::] + \"1\") in y_bin or \\\r\n (\"1\" + \"\".join(list(bin(x)[2:])).strip(\"0\")) in (\"\".join(list(reversed(bin(y)[2:])))) or \\\r\n int(x_bin + \"1\", 2) == y or \\\r\n (int(x_bin + \"1\", 2) * (increment + 1) + increment) == y or \\\r\n x == y\r\n ]\r\n )\r\n"}, {"source_code": "from collections import defaultdict\r\nimport sys\r\ninput = sys.stdin.readline\r\nflush = sys.stdout.flush\r\nget_int = lambda : int(input().rstrip())\r\nget_arr = lambda : [int(w) for w in input().split()]\r\n\r\n\r\ndef pb(x):\r\n print(bin(x)[2:])\r\n\r\n\r\ndef can(a, b):\r\n for i in range(len(b) - len(a) + 1):\r\n if b[i] == '0':\r\n return False\r\n if b[i:i + len(a)] == a and b[i + len(a):].count('1') == len(b[i + len(a):]):\r\n return True\r\n return False\r\n\r\n\r\ndef gl_can(a, b):\r\n if a == b or b % 2 == 0:\r\n return a == b\r\n\r\n pos_a = {2 * a + 1}\r\n while a % 2 == 0:\r\n a //= 2\r\n pos_a.add(2 * a + 1)\r\n\r\n b = bin(b)[2:]\r\n pos_b = {b, b[::-1]}\r\n\r\n return any(can(bin(a)[2:], b) for a in pos_a for b in pos_b)\r\n\r\n\r\na, b = get_arr()\r\n# pb(a)\r\n# pb(b)\r\nprint(\"YES\" if gl_can(a, b) else \"NO\")"}, {"source_code": "import re\r\n\r\ndef do(x, y):\r\n match = re.search(f\"^1*{x}1*$\", y)\r\n # print(x, match)\r\n if match:\r\n return True\r\n else:\r\n return False\r\n\r\nx, y = map(int, input().split())\r\n\r\nx1 = bin(x)[2:]\r\nx2 = x1[::-1]\r\n\r\ni = 0\r\nwhile x2[i] == '0':\r\n i = i + 1\r\n\r\nx3 = x2[i:]\r\nx4 = x3[::-1]\r\n\r\nif x1[-1] == '0':\r\n x1 += '1'\r\n\r\ny = bin(y)[2:]\r\n\r\n# print(x1, x2, x3, x4)\r\n# print(y)\r\n\r\nif do(x1, y) or do(x2, y) or do(x3, y) or do(x4, y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n"}, {"source_code": "# Problem: F. \u0420\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u044b\r\n# Contest: Codeforces - Codeforces Round #760 (Div. 3)\r\n# URL: https://codeforces.com/contest/1618/problem/F\r\n# Memory Limit: 256 MB\r\n# Time Limit: 2000 ms\r\n# \r\n# Powered by CP Editor (https://cpeditor.org)\r\n\r\nimport bisect\r\nimport random\r\nmod = 10 ** 9 + 7\r\neps = 10 ** -9\r\n\r\n\r\ndef __gcd(a, b):\r\n\treturn a if b == 0 else __gcd(b, a % b)\r\n\t\r\n\r\ndef __lcm(a, b):\r\n\treturn a * b / __gcd(a, b)\r\n\r\n\r\ndef __fact(n):\r\n\treturn 1 if n == 1 else n * __fact(n - 1)\r\n\r\n\r\ndef __mex(a):\r\n\tmex = 0\r\n\ta.sort()\r\n\tfor x in a:\r\n\t\tif x <= mex:\r\n\t\t\tmex += 1\r\n\t\telse:\r\n\t\t\tbreak\r\n\treturn mex\r\n\r\ndef __dist(x1, y1, x2, y2):\r\n\treturn (x1 - x2) ** 2 + (y1 - y2) ** 2\r\n\r\ndef __getprimes(n):\r\n isprime = [True for i in range(n + 1)]\r\n primes = []\r\n \r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n for j in range(i * i, n + 1, i):\r\n isprime[j] = False\r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n primes.append(i)\r\n return primes\r\n\r\ndef __modInverse(a, m):\r\n \r\n m0 = m\r\n y = 0\r\n x = 1\r\n if (m == 1):\r\n return 0\r\n \r\n while(a > 1):\r\n \tq = a // m\r\n \tt = m\r\n \tm = a % m\r\n \ta = t\r\n \tt = y\r\n \ty = x - q * y\r\n \tx = t\r\n if (x < 0):\r\n \tx = x + m0\r\n return x\r\n \r\n \r\n \r\ndef __isprime(n):\r\n\tif n < 2:\r\n\t\treturn False\r\n\ti = 2\r\n\twhile i * i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\treturn False\r\n\t\ti += 1\r\n\treturn True\r\n\t\r\ndef __cntprimediv(n):\r\n\tret = 0\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tn //= i\r\n\t\t\tret += 1\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret += 1\r\n\treturn ret\r\n\t\r\ndef __primefactors(n):\r\n\tret = []\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tret.append(i)\r\n\t\t\tn //= i\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret.append(n)\r\n\treturn ret\r\n\t\r\n\r\ndef __sumdigit(n):\r\n\tret = 0\r\n\twhile n > 0:\r\n\t\tret += n % 10\r\n\t\tn //= 10\r\n\treturn ret\r\n\r\ndef __zfunc(s):\r\n\tn = len(s)\r\n\tz = [0 for i in range(n)]\r\n\tl = 0\r\n\tr = 0\r\n\tfor i in range(1, n):\r\n\t\tif r >= i:\r\n\t\t\tz[i] = min(z[i - l], r - i + 1)\r\n\t\twhile z[i] + i < n and s[z[i]] == s[z[i] + i]:\r\n\t\t\tz[i] += 1\r\n\t\tif i + z[i] - 1 > r:\r\n\t\t\tl = i\r\n\t\t\tr = i + z[i] - 1\r\n\treturn z\r\n\t\r\n\t\r\ndef __to(n, x):\r\n\tret = ''\r\n\twhile n > 0:\r\n\t\tq = n % x\r\n\t\tif q < 10:\r\n\t\t\tret += str(q)\r\n\t\telse:\r\n\t\t\tret += chr(q - 10 + ord('a'))\r\n\t\tn //= x\r\n\treturn ret[::-1]\r\n\t\r\ndef __delChar(s, c):\r\n\ts = list(s)\r\n\twhile len(s) > 0 and s[0] == c:\r\n\t\ts.pop(0)\r\n\treturn '' . join(s)\r\n\r\n\r\ndef solve(t_id):\r\n\tn, m = map(int, input().split())\r\n\ttmp1 = n\r\n\ttmp2 = m\r\n\tok = False\r\n\tif n == m:\r\n\t\tok = True\r\n\ts = __to(n, 2)\r\n\tt = __to(m, 2)\r\n\t\r\n\t\r\n\ts1 = s + '1'\r\n\ts = __delChar(s, '0')[::-1]\r\n\ts = __delChar(s, '0')[::-1]\r\n\t\r\n\t\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s1\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i <= l or i >= r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\t\r\n\tprint('YES' if ok else 'NO')\r\nt = 1\r\n#t = int(input())\r\n\r\n\r\nfor i in range(t):\r\n\tsolve(t)"}, {"source_code": "# -*- codeing =utf-8 -*-\r\n# @Time : 2021/12/21 0:37\r\n# @Author : \u5f90\u9038\u8283\r\n# @File \uff1adqwqw.py\r\n# @Software: PyCharm\r\n\r\n\r\n\r\n\r\n\r\n\r\nimport collections\r\n\r\ndef cal(x):\r\n tmp=0\r\n while x:\r\n tmp=tmp*2+x&1\r\n x>>=1\r\n return tmp\r\n\r\ndef solve(x, y):\r\n if x==y:return True\r\n q = collections.deque()\r\n q.append(x)\r\n vis =set()\r\n vis.add(x)\r\n\r\n while q:\r\n n = q.popleft()\r\n n1, n2 = n << 1,(n << 1)|1\r\n n3, n4 = cal(n1),cal(n2)\r\n n5=cal(n1)\r\n # print(n1,n2,n3,n4,n5)\r\n for tot in [n2, n3, n4,n5]:\r\n if tot == y:\r\n return True\r\n else:\r\n if tot>y or tot in vis:\r\n continue\r\n vis.add(tot)\r\n q.append(tot)\r\n return False\r\n\r\n\r\nx, y = map(int,input().split())\r\nif solve(x,y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\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 math\r\n\r\na, b = list(map(int, input().split()))\r\na = bin(a)[2:]\r\npos = [a.strip('0'), a.strip('0')[::-1], a, (a+'1')[::-1]]\r\nb = bin(b)[2:]\r\nanswer = False\r\nfor i in range(4):\r\n for j in range(len(b)):\r\n for k in range(len(b)):\r\n if '1'*j+pos[i]+'1'*k == b:\r\n answer = True\r\nif answer:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n"}, {"source_code": "# import sys, os\r\n\r\n# from sympy import solve\r\n# if not os.environ.get(\"ONLINE_JUDGE\"):\r\n# sys.stdin = open('in.txt', 'r')\r\n# sys.stdout = open('out.txt', 'w')\r\n\r\nimport sys\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n\r\ndef solve(s, y):\r\n if len(s) > len(y):\r\n return False\r\n n = len(y) - len(s)\r\n for i in range(n):\r\n if y == '1'*i + s + '1'*(n-i):\r\n return True\r\n return False\r\n\r\nn, k = map(int, input().split())\r\nx = bin(n).replace('0b', '')\r\ny = bin(k).replace('0b', '')\r\n\r\ns1 = x + '1'\r\ns2 = s1[::-1]\r\nx = bin(int(x[::-1], 2)).replace('0b', '')\r\ns3 = x\r\ns4 = s3[::-1]\r\n\r\n\r\nif solve(s1, y) or solve(s2, y) or solve(s3, y) or solve(s4, y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "# region template\nimport sys\nimport typing\nfrom typing import Callable, Dict, List, Set, Tuple\n\nsys.setrecursionlimit(10 ** 6)\nVec = List[int]\nVecVec = List[Vec]\nsinput: Callable[..., str] = sys.stdin.readline\nMOD: int = 998244353\nINF: float = float(\"Inf\")\nIINF: int = sys.maxsize // 2\n# endregion\n\n\ndef main() -> None:\n x, y = map(int, sinput().split())\n bx = bin(x)[2:]\n by = bin(y)[2:]\n if by[-1] == \"0\":\n print(\"NO\")\n return\n s = by.find(bx)\n if s != -1:\n if \"0\" not in by[:s] and \"0\" not in by[s + len(bx) :]:\n print(\"YES\")\n return\n\n if bx[-1] == \"0\":\n last_z = bx.rfind(\"0\")\n bx = bx[:last_z]\n s = by.find(bx)\n if s != -1:\n if \"0\" not in by[:s] and \"0\" not in by[s + len(bx) :]:\n print(\"YES\")\n return\n\n print(\"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from sys import stdin\r\ninp = stdin.readline\r\n\r\na, b = map(int, inp().split())\r\n\r\nbinA = str(bin(a))[2:]\r\nbinB = str(bin(b))[2:]\r\n\r\nc1 = binA.strip(\"0\")\r\nc2 = binA + \"1\"\r\n\r\nx = binB.find(c2)\r\nif x > -1:\r\n if (binB[:x] + binB[x+len(c2):]).find(\"0\") > -1:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\nelif a == b:\r\n print(\"YES\")\r\nelse:\r\n x = binB.find(c1)\r\n if x > -1:\r\n if (binB[:x] + binB[x + len(c1):]).find(\"0\") > -1:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n"}, {"source_code": "import sys\r\ninput = lambda : sys.stdin.readline().rstrip()\r\nx, y = map(int, input().split())\r\nif x == y:\r\n print('YES')\r\n sys.exit(0)\r\nb = bin(x)[2:]+'1'\r\nwhile x & 1 == 0:\r\n x >>= 1\r\na = bin(x)[2:]\r\ny = bin(y)[2:]\r\n\r\ndef check(s):\r\n idx = y.find(s)\r\n if idx == -1:\r\n return False\r\n for i, e in enumerate(y):\r\n if idx<=i= 0 and n[temp-k-1] == '0':\r\n k += 1 \r\n\r\np1 = re.compile(\"^1*\" + n[:temp-k] + (\"[0]{0,\"+str(k)+\"}\" if k > 0 else \"\")+ \"1*$\")\r\n\r\npe = re.compile(\"^1+\" + n[:temp-k] + (\"[0]{1,\"+str(k)+\"}\" if k > 0 else \"\")+ \"$\")\r\n\r\np2 = re.compile('^1*' + n_ + \"1*$\")\r\n\r\n# print(n)\r\n# print(m)\r\n# print(pe)\r\n# print(re.match(pe, m))\r\nif re.match(p2, m):\r\n print(\"YES\")\r\nelif re.match(p1, m):\r\n if re.match(pe, m):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "import math\r\n\r\na, b = list(map(int, input().split()))\r\na = bin(a)[2:]\r\nb = bin(b)[2:]\r\nif (a in b or a[::-1] in b) and b[-1] == '1':\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "def solve(x, y):\r\n if x == y:\r\n return True\r\n x = bin(x)[2:]\r\n y = bin(y)[2:]\r\n xx = x.rstrip('0')\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n xx = xx[::-1]\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n xx = x[::-1]\r\n for i in range(len(y)-len(xx)+1):\r\n if x == y[i:i+len(xx)] and all(c=='1' for c in y[:i]) and all(c=='1' for c in y[i+len(x):]):\r\n return True\r\n return False\r\n\r\n\r\nx, y = map(int,input().split())\r\nprint('YES' if solve(x, y) else 'NO')\r\n"}, {"source_code": "def b(n):\r\n return bin(n).replace(\"0b\", \"\")\r\n\r\nx,y=map(int,input().split())\r\nx,y=b(x),b(y)\r\nif len(x)>len(y):\r\n print('NO')\r\nelif len(x)==len(y):\r\n print('NO' if x not in y else 'YES')\r\nelse:\r\n if x not in y:\r\n print('NO')\r\n else:\r\n cnt1,cnt2=0,0\r\n for j in x:\r\n if j=='0':\r\n cnt1+=1\r\n for j in y:\r\n if j=='0':\r\n cnt2+=1\r\n if cnt1!=cnt2:\r\n print('NO')\r\n else:\r\n print('YES')"}, {"source_code": "import collections\r\n\r\ndef cal(x):\r\n tmp=0\r\n while x:\r\n tmp=tmp*2+(x&1)\r\n x>>=1\r\n return tmp\r\n\r\ndef solve(x, y):\r\n if x==y:return True\r\n q = collections.deque()\r\n q.append(x)\r\n vis=set()\r\n vis.add(x)\r\n while q:\r\n n = q.popleft()\r\n n1, n2 = n<<1,(n<<1)+1\r\n n3, n4 = cal(n1),cal(n2)\r\n # print(n1,n2,n3,n4)\r\n for nn in [n2, n3, n4]:\r\n if nn == y:\r\n return True\r\n else:\r\n if nn > y or nn in vis:\r\n continue\r\n vis.add(nn)\r\n q.append(nn)\r\n return False\r\nx, y = map(int,input().split())\r\nif solve(x,y):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "# Problem: F. \u0420\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u044b\r\n# Contest: Codeforces - Codeforces Round #760 (Div. 3)\r\n# URL: https://codeforces.com/contest/1618/problem/F\r\n# Memory Limit: 256 MB\r\n# Time Limit: 2000 ms\r\n# \r\n# Powered by CP Editor (https://cpeditor.org)\r\n\r\nimport bisect\r\nimport random\r\nmod = 10 ** 9 + 7\r\neps = 10 ** -9\r\n\r\n\r\ndef __gcd(a, b):\r\n\treturn a if b == 0 else __gcd(b, a % b)\r\n\t\r\n\r\ndef __lcm(a, b):\r\n\treturn a * b / __gcd(a, b)\r\n\r\n\r\ndef __fact(n):\r\n\treturn 1 if n == 1 else n * __fact(n - 1)\r\n\r\n\r\ndef __mex(a):\r\n\tmex = 0\r\n\ta.sort()\r\n\tfor x in a:\r\n\t\tif x <= mex:\r\n\t\t\tmex += 1\r\n\t\telse:\r\n\t\t\tbreak\r\n\treturn mex\r\n\r\ndef __dist(x1, y1, x2, y2):\r\n\treturn (x1 - x2) ** 2 + (y1 - y2) ** 2\r\n\r\ndef __getprimes(n):\r\n isprime = [True for i in range(n + 1)]\r\n primes = []\r\n \r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n for j in range(i * i, n + 1, i):\r\n isprime[j] = False\r\n for i in range(2, n + 1):\r\n if isprime[i]:\r\n primes.append(i)\r\n return primes\r\n\r\ndef __modInverse(a, m):\r\n \r\n m0 = m\r\n y = 0\r\n x = 1\r\n if (m == 1):\r\n return 0\r\n \r\n while(a > 1):\r\n \tq = a // m\r\n \tt = m\r\n \tm = a % m\r\n \ta = t\r\n \tt = y\r\n \ty = x - q * y\r\n \tx = t\r\n if (x < 0):\r\n \tx = x + m0\r\n return x\r\n \r\n \r\n \r\ndef __isprime(n):\r\n\tif n < 2:\r\n\t\treturn False\r\n\ti = 2\r\n\twhile i * i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\treturn False\r\n\t\ti += 1\r\n\treturn True\r\n\t\r\ndef __cntprimediv(n):\r\n\tret = 0\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tn //= i\r\n\t\t\tret += 1\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret += 1\r\n\treturn ret\r\n\t\r\ndef __primefactors(n):\r\n\tret = []\r\n\tx = n\r\n\ti = 2\r\n\twhile i * i <= x:\r\n\t\twhile n % i == 0:\r\n\t\t\tret.append(i)\r\n\t\t\tn //= i\r\n\t\ti += 1\r\n\tif n > 1:\r\n\t\tret.append(n)\r\n\treturn ret\r\n\t\r\n\r\ndef __sumdigit(n):\r\n\tret = 0\r\n\twhile n > 0:\r\n\t\tret += n % 10\r\n\t\tn //= 10\r\n\treturn ret\r\n\r\ndef __zfunc(s):\r\n\tn = len(s)\r\n\tz = [0 for i in range(n)]\r\n\tl = 0\r\n\tr = 0\r\n\tfor i in range(1, n):\r\n\t\tif r >= i:\r\n\t\t\tz[i] = min(z[i - l], r - i + 1)\r\n\t\twhile z[i] + i < n and s[z[i]] == s[z[i] + i]:\r\n\t\t\tz[i] += 1\r\n\t\tif i + z[i] - 1 > r:\r\n\t\t\tl = i\r\n\t\t\tr = i + z[i] - 1\r\n\treturn z\r\n\t\r\n\t\r\ndef __to(n, x):\r\n\tret = ''\r\n\twhile n > 0:\r\n\t\tq = n % x\r\n\t\tif q < 10:\r\n\t\t\tret += str(q)\r\n\t\telse:\r\n\t\t\tret += chr(q - 10 + ord('a'))\r\n\t\tn //= x\r\n\treturn ret[::-1]\r\n\t\r\ndef __delChar(s, c):\r\n\ts = list(s)\r\n\twhile len(s) > 0 and s[0] == c:\r\n\t\ts.pop(0)\r\n\treturn '' . join(s)\r\n\r\n\r\ndef solve(t_id):\r\n\tn, m = map(int, input().split())\r\n\ttmp1 = n\r\n\ttmp2 = m\r\n\tok = False\r\n\tif n == m:\r\n\t\tok = True\r\n\ts = __to(n, 2)\r\n\tt = __to(m, 2)\r\n\t\r\n\ts = __delChar(s, '0')[::-1]\r\n\ts = __delChar(s, '0')[::-1]\r\n\t\r\n\t\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i < l or i > r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\ts = s[::-1]\r\n\tif t.find(s) != -1:\r\n\t\tl = t.find(s)\r\n\t\tr = t.find(s) + len(s)\r\n\t\t\r\n\t\ttmp = True\r\n\t\tfor i in range(len(t)):\r\n\t\t\tif i < l or i > r:\r\n\t\t\t\tif i > 0 and t[i] == t[i - 1] and t[i] == '0':\r\n\t\t\t\t\ttmp = False\r\n\t\t\t\t\tbreak\r\n\t\tif tmp:\r\n\t\t\tok = True\r\n\t\r\n\tprint('YES' if ok else 'NO')\r\nt = 1\r\n#t = int(input())\r\n\r\n\r\nfor i in range(t):\r\n\tsolve(t)"}, {"source_code": "\r\nimport sys, collections, math, bisect, heapq, random, functools,io,os,copy\r\ninput = sys.stdin.readline\r\nout = sys.stdout.flush\r\ndef rep():\r\n a = list(map(int,input().split()))\r\n return a\r\n\r\ndef sep():\r\n a = list(input().split())\r\n return a\r\n\r\n\r\nclass UnionFind:\r\n def __init__(self, x) -> None:\r\n self.uf = [-1] * x\r\n\r\n def find(self, x):\r\n r = x\r\n while self.uf[x] >= 0:\r\n x = self.uf[x]\r\n\r\n while r != x:\r\n self.uf[r], r = x, self.uf[r]\r\n return x\r\n\r\n def union(self, x, y):\r\n ux, uy = self.find(x), self.find(y)\r\n if ux == uy:\r\n return\r\n if self.uf[ux] >= self.uf[uy]:\r\n self.uf[uy] += self.uf[ux]\r\n self.uf[ux] = uy\r\n else:\r\n self.uf[ux] += self.uf[uy]\r\n self.uf[uy] = ux\r\n return\r\n\r\n def __print__(self):\r\n return self.uf\r\n\r\n\r\ndef spfa(x,g,n):\r\n dis = [float('inf') for i in range(n)]\r\n dis[x] = 0\r\n state = [False for i in range(n)]\r\n state[x] = True\r\n queue = collections.deque()\r\n queue.append(x)\r\n while queue:\r\n cur = queue.popleft()\r\n state[cur] = False\r\n for next_ in g[cur]:\r\n if dis[next_] > dis[cur] + 1:\r\n dis[next_] = dis[cur] + 1\r\n if state[next_] == False:\r\n state[next_] = True\r\n queue.append(next_)\r\n return dis\r\n\r\n\r\ndef gcd(x,y):\r\n if y == 0:\r\n return x\r\n return gcd(y,x % y)\r\n\r\ndef getvalid(s):\r\n l = 0\r\n while l < len(s) and s[l] == '0':\r\n l += 1\r\n return l\r\n\r\n\r\ndef solve():\r\n x,y = map(int,input().split())\r\n tar = bin(y)[2:]\r\n vis = set()\r\n vis.add(bin(x)[2:])\r\n m = len(tar)\r\n queue = collections.deque()\r\n queue.append(bin(x)[2:])\r\n flag = 0\r\n while queue:\r\n cur = queue.popleft()\r\n if len(cur) > m:\r\n continue\r\n if cur == tar:\r\n flag = 1\r\n break\r\n next1,next2 = cur + '0',cur + '1'\r\n next1 = next1[::-1]\r\n next2 = next2[::-1]\r\n pos1,pos2 = getvalid(next1),getvalid(next2)\r\n if pos1 == len(next1):\r\n next1 = '0'\r\n else:\r\n next1 = next1[pos1:]\r\n\r\n if pos2 == len(next2):\r\n next2 = '1'\r\n else:\r\n next2 = next2[pos2:]\r\n if next1 not in vis:\r\n vis.add(next1)\r\n queue.append(next1)\r\n if next2 not in vis:\r\n vis.add(next2)\r\n queue.append(next2)\r\n if flag:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\n\r\nif __name__ == '__main__':\r\n solve()"}, {"source_code": "x, y = [int(z) for z in input().split()]\nbinx = bin(x)[2:]\nbiny = bin(y)[2:]\nxidx = len(binx)\nwhile xidx > 0 and binx[xidx-1] == 0: \n xidx -= 1\n\nx1 = binx + '1'\nx2 = binx[:xidx]\nans = False\nif binx == biny: \n ans = True\n\nd = len(biny)-len(x1)\nfor i in range(d+1):\n if \"1\"*i + x1 + \"1\"*(d-i) == biny:\n ans = True\n elif \"1\"*i + x1[::-1] + \"1\"*(d-i) == biny:\n ans = True\n\nd = len(biny)-len(x2)\nfor i in range(d+1):\n if \"1\"*i + x2 + \"1\"*(d-i) == biny:\n ans = True\n elif \"1\"*i + x2[::-1] + \"1\"*(d-i) == biny:\n ans = True\n\nif ans:\n print(\"YES\")\nelse: print(\"NO\")\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nx, y = [int(x) for x in input().split()]\n\ndef patterns(x):\n bin_x = bin(x)[2:]\n return [bin_x, bin(int(bin_x[::-1], 2))[2:], bin_x+'1', bin(int((bin_x+'1')[::-1], 2))[2:]]\n \nif bin(y)[-1] == 0:\n if x!=y:\n print('NO')\n else:\n print('YES')\n\nelse:\n bin_x = bin(x)[2:]\n bin_y = bin(y)[2:]\n pattern = [bin_x, bin_x[::-1], bin(int(bin_x[::-1], 2))[2:]]\n flag = False\n a = []\n b = []\n c = []\n for i in range(len(bin_y)):\n if bin_y[i:i+len(pattern[0])] == pattern[0]:\n a.append(i)\n if bin_y[i:i+len(pattern[1])] == pattern[1]:\n b.append(i)\n if bin_y[i:i+len(pattern[2])] == pattern[2]:\n c.append(i)\n \n for i in a:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[0]):]:\n flag = True\n break\n for i in b:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[1]):]:\n flag = True\n break\n for i in c:\n if '0' not in bin_y[:i]+bin_y[i+len(pattern[2]):]:\n flag = True\n break\n \n if flag:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a,b = map(int, input().split())\r\nsus = bin(a)[2:][::-1]\r\nsussy = bin(int(bin(a)[2:][::-1]+\"1\",2))[2:]\r\n\r\nbb = bin(b)[2:]\r\nrealsus = sus[::-1]\r\nrealsussy = sus[::-1]\r\n\r\namogus = bin(b)[2:]\r\nlmao = False\r\npos = -1\r\nleng = 0\r\nfor i in [sus, sussy, realsus, realsussy]:\r\n if amogus.find(i) != -1:\r\n pos = amogus.find(i)\r\n leng = len(i)\r\nif pos == -1:\r\n lmao = True\r\n\r\nif pos != -1:\r\n c = bb[0:pos] + bb[pos+leng:]\r\n for i in range(1,len(c)-1):\r\n if c[i] != \"1\":\r\n lmao = True\r\n if len(c)>0 and c[0]==\"0\" and c[-1]==\"0\":\r\n lmao = True\r\n\r\n\r\nprint(\"YES\" if not lmao else \"NO\")\r\n\r\n\r\n"}, {"source_code": "x, y = map(int, input().split())\n\nx = bin(x)[2:]\ny = bin(y)[2:]\n\nx_rev = ''.join(reversed(x))\nx_rev = x_rev[x_rev.index('1'):]\n\nif x_rev in y and x_rev.count('0') == y.count('0') or x in y and x.count('0') == y.count('0'):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n"}, {"source_code": "def decompose(s):\r\n r = []\r\n while s > 0:\r\n r.append(s % 2)\r\n s = int(s/2)\r\n return r\r\n\r\n\r\ndef add(r):\r\n s = 0\r\n c = 1\r\n for bit in r:\r\n s += c * bit\r\n c = c * 2\r\n return s\r\n\r\n\r\ndef solve(a, b):\r\n ans = \"YES\"\r\n s = []\r\n check = dict()\r\n q = [a]\r\n f = 0\r\n while f < len(q):\r\n p = q[f]\r\n check.__setitem__(p, None)\r\n d = decompose(p)\r\n n_bits = len(d)\r\n d.reverse()\r\n pr = add(d)\r\n power_2 = 2 ** (n_bits - 1)\r\n possible = [pr, p * 2 + 1, power_2 + p, pr * 2 + 1, power_2 + pr]\r\n for c in possible:\r\n if c == b:\r\n print(\"YES\")\r\n return\r\n if c not in check and c < b:\r\n q.append(c)\r\n check.__setitem__(c, None)\r\n f += 1\r\n print(\"NO\")\r\n return\r\n\r\n\r\na, b = list(map(int, input().split()))\r\nsolve(a, b)"}, {"source_code": "def pr_r(n):\r\n n1 = n2 = n\r\n n1 += '1'\r\n n2 += '0'\r\n n1 = n1[::-1]\r\n n2 = bin(int(n2[::-1], 2))[2:]\r\n\r\n return n1, n2\r\n\r\na, b = [bin(int(i)) for i in input().split()]\r\na = a[2:]\r\nb = b[2:]\r\nif b.count('1') < a.count('1'):\r\n print('NO')\r\n exit()\r\n\r\ns = [a]\r\nfor i in range(22):\r\n ss = []\r\n for j in s:\r\n x, y = pr_r(j)\r\n if x == b or y == b:\r\n print('YES')\r\n exit()\r\n\r\n if not (x > j > b):\r\n ss.append(x)\r\n if not (b > j > a):\r\n ss.append(y)\r\n\r\n s = ss.copy()\r\n\r\nprint('NO')"}, {"source_code": "x, y = map(int, input().split())\r\nx_bin, y_bin = bin(x), bin(y)\r\nincrement = len(y_bin) - len(x_bin)\r\n# print(x_bin, y_bin)\r\n# print([\"NO\", \"YES\"][(x_bin[2:-1] + \"1\") in y_bin or \\\r\n# (y_bin[2 + increment // 2:-(increment // 2)]) == x_bin[2::] or \\\r\n# (x_bin[2::] + \"1\") in y_bin or \\\r\n# (\"1\" + \"\".join(list(bin(x)[2:])).strip(\"0\")) in (\"\".join(list(reversed(bin(y)[2:])))) or \\\r\n# int(x_bin + \"1\", 2) == y or \\\r\n# (int(x_bin + \"1\", 2) * (increment + 1) + increment) == y or \\\r\n# x == y\r\n# ]\r\n# )\r\nresult = \"\"\r\nif x_bin == y_bin:\r\n result = \"YES\"\r\nelif x_bin[-1] == \"0\":\r\n result = \"NO\"\r\nelse:\r\n x_bin += \"1\"\r\n if (y_bin.find(x_bin) != -1 or y_bin.find(x_bin[::-1]) != -1) and y_bin.count('1') - x_bin.count('1') == len(y_bin) - len(x_bin):\r\n result = \"YES\"\r\n else:\r\n x_bin = x_bin[:-1]\r\n while x_bin[-1] == \"0\":\r\n x_bin = x_bin[:-1]\r\n result = (\"YES\" if (y_bin.find(x_bin) != -1 or y_bin.find(x_bin[::-1]) != -1) and y_bin.count('1') - x_bin.count('1') == len(y_bin) - len(x_bin) else \"NO\")\r\n# b = [\"YES\", \"NO\"][x_bin.count(\"0\") == y_bin.count(\"0\") or ]\r\nprint([\"NO\", result][result != \"\"])"}, {"source_code": "from collections import defaultdict\r\nimport sys\r\ninput = sys.stdin.readline\r\nflush = sys.stdout.flush\r\nget_int = lambda : int(input().rstrip())\r\nget_arr = lambda : [int(w) for w in input().split()]\r\n\r\n\r\ndef pb(x):\r\n print(bin(x)[2:])\r\n\r\n\r\ndef can(a, b):\r\n for i in range(len(b) - len(a) + 1):\r\n if b[i] == '0':\r\n return False\r\n if b[i:i + len(a)] == a and b[i + len(a):].count('1') == len(b[i + len(a):]):\r\n return True\r\n return False\r\n\r\n\r\ndef gl_can(a, b):\r\n if a == b or b % 2 == 0:\r\n return a == b\r\n\r\n pos_a = {a, 2 * a + 1}\r\n while a % 2 == 0:\r\n a //= 2\r\n pos_a.add(2 * a + 1)\r\n\r\n b = bin(b)[2:]\r\n pos_b = {b, b[::-1]}\r\n\r\n return any(can(bin(a)[2:], b) for a in pos_a for b in pos_b)\r\n\r\n\r\na, b = get_arr()\r\n# pb(a)\r\n# pb(b)\r\nprint(\"YES\" if gl_can(a, b) else \"NO\")"}, {"source_code": "x, y = map(int, input().split())\r\n_x = x\r\n_y = y\r\n\r\ns_x = \"\"\r\ns_x_p = \"\"\r\nflag = False\r\nwhile x:\r\n if x % 2:\r\n flag = True\r\n if flag:\r\n s_x = str(x % 2) + s_x\r\n s_x_p = str(x % 2) + s_x_p\r\n x //= 2\r\ns_x_p = s_x_p + '1'\r\n\r\ns_y = \"\"\r\nflag = False\r\nwhile y:\r\n s_y = str(y % 2) + s_y\r\n y //= 2\r\n\r\nprint(s_x, s_x_p, s_y)\r\n\r\npos1 = s_y.find(s_x)\r\ns_y_1 = s_y[0: pos1] + s_y[pos1 + len(s_x):]\r\nprint(pos1, s_y_1, all(list(map(lambda x : x == '1', s_y_1))))\r\ns_x = s_x[::-1]\r\npos2 = s_y.find(s_x)\r\ns_y_2 = s_y[0: pos2] + s_y[pos2 + len(s_x):]\r\nprint(pos2, s_y_2, all(list(map(lambda x : x == '1', s_y_2))))\r\n\r\npos3 = s_y.find(s_x_p)\r\ns_y_3 = s_y[0: pos3] + s_y[pos3 + len(s_x_p):]\r\nprint(pos3, s_y_3, all(list(map(lambda x : x == '1', s_y_3))))\r\ns_x_p = s_x_p[::-1]\r\npos4 = s_y.find(s_x_p)\r\ns_y_4 = s_y[0: pos4] + s_y[pos4 + len(s_x_p):]\r\nprint(pos4, s_y_4, all(list(map(lambda x : x == '1', s_y_4))))\r\n\r\n\r\nif _x == _y or \\\r\n (pos1 != -1 and all(list(map(lambda x : x == '1', s_y_1)))) or \\\r\n (pos2 != -1 and all(list(map(lambda x : x == '1', s_y_2)))) or \\\r\n (pos3 != -1 and all(list(map(lambda x : x == '1', s_y_3)))) or \\\r\n (pos4 != -1 and all(list(map(lambda x : x == '1', s_y_4)))):\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "import io, os\r\nimport sys \r\nfrom sys import stdin\r\n\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import defaultdict, deque, namedtuple\r\nfrom heapq import heappush, heappop\r\nfrom math import gcd, ceil, floor, factorial, sqrt\r\nfrom itertools import combinations, permutations\r\n\r\ninput = sys.stdin.buffer.readline\r\n# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\r\n# input = sys.stdin.readline\r\n\r\ndef work(stt, end):\r\n n, m = len(stt), len(end)\r\n if n > m:\r\n return False \r\n \r\n q = deque()\r\n q.append(stt)\r\n seen = set()\r\n\r\n while q:\r\n t = q.popleft()\r\n if t not in seen:\r\n seen.add(t)\r\n\r\n p = t[::-1]\r\n if p == end:\r\n return True \r\n if len(p) <= m:\r\n q.append(p)\r\n p = t + \"1\"\r\n p = p[::-1]\r\n if len(p) <= m:\r\n q.append(p)\r\n if p == end:\r\n return True \r\n return False \r\n\r\n# sys.setrecursionlimit(200010)\r\n# https://codeforces.com/contest/1618/problem/F\r\ndef main():\r\n test = 1\r\n\r\n for idt in range(test):\r\n # n = int(input())\r\n a, b = map(int, input().split())\r\n # a = list(map(int, input().split()))\r\n stt = bin(a)[2:]\r\n end = bin(b)[2:]\r\n if work(stt, end):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n return \r\n\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "x, y = map(int, input().split(\" \"))\r\nbin_x, bin_y = str(bin(x))[2:], str(bin(y))[2:]\r\nans = \"NO\"\r\ntry:\r\n i1 = bin_y.index(bin_x+'1')\r\n re = set(bin_y[:i1]+bin_y[i1+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\ntry:\r\n i2 = bin_y.index((bin_x+'1')[::-1])\r\n re = set(bin_y[:i1]+bin_y[i1+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\nbin_x = bin_x.strip('0')\r\ntry:\r\n i3 = bin_y.index(bin_x)\r\n re = set(bin_y[:i3]+bin_y[i3+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\ntry:\r\n i4 = bin_y.index(bin_x[::-1])\r\n re = set(bin_y[:i4]+bin_y[i4+len(bin_x)+1:])\r\n if len(re) == 0 or (len(re) == 1 and '1' in re):\r\n ans = \"YES\"\r\nexcept:\r\n pass\r\nprint(ans)\r\n"}], "src_uid": "9f39a3c160087beb0efab2e3cb510e89"} {"nl": {"description": "Vasya studies positional numeral systems. Unfortunately, he often forgets to write the base of notation in which the expression is written. Once he saw a note in his notebook saying a\u2009+\u2009b\u2009=\u2009?, and that the base of the positional notation wasn\u2019t written anywhere. Now Vasya has to choose a base p and regard the expression as written in the base p positional notation. Vasya understood that he can get different results with different bases, and some bases are even invalid. For example, expression 78\u2009+\u200987 in the base 16 positional notation is equal to FF16, in the base 15 positional notation it is equal to 11015, in the base 10 one \u2014 to 16510, in the base 9 one \u2014 to 1769, and in the base 8 or lesser-based positional notations the expression is invalid as all the numbers should be strictly less than the positional notation base. Vasya got interested in what is the length of the longest possible expression value. Help him to find this length.The length of a number should be understood as the number of numeric characters in it. For example, the length of the longest answer for 78\u2009+\u200987\u2009=\u2009? is 3. It is calculated like that in the base 15 (11015), base 10 (16510), base 9 (1769) positional notations, for example, and in some other ones.", "input_spec": "The first letter contains two space-separated numbers a and b (1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u20091000) which represent the given summands.", "output_spec": "Print a single number \u2014 the length of the longest answer.", "sample_inputs": ["78 87", "1 1"], "sample_outputs": ["3", "2"], "notes": null}, "positive_code": [{"source_code": "\n\nif __name__ == '__main__':\n\ta, b = raw_input().split(\" \")\n\tbase = 0\n\tfor digit in a:\n\t\tbase = max(base, int(digit))\n\tfor digit in b:\n\t\tbase = max(base, int(digit))\n\tbase += 1\n\ta10 = int(a, base)\n\tb10 = int(b, base)\n\tsum = a10 + b10\n\tres = 0\n\twhile sum > 0:\n\t\tres += 1\n\t\tsum /= base\n\tprint res\n"}, {"source_code": "\n\nif __name__ == '__main__':\n\ta, b = raw_input().split(\" \")\n\tbase = 0\n\tfor digit in a:\n\t\tbase = max(base, int(digit))\n\tfor digit in b:\n\t\tbase = max(base, int(digit))\n\tbase += 1\n\ta10 = int(a, base)\n\tb10 = int(b, base)\n\tsum = a10 + b10\n\tres = 0\n\twhile sum > 0:\n\t\tres += 1\n\t\tsum /= base\n\tprint res\n"}, {"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\ndef baseN(num,b,numerals=\"0123456789abcdefghijklmnopqrstuvwxyz\"):\n return ((num == 0) and \"0\" ) or ( baseN(num // b, b).lstrip(\"0\") + numerals[num % b])\nT = raw_input().split()\n\nbase = int(max(T[0]+T[1]))+1\nsum_max = int(T[0], base) + int(T[1], base)\nprint len(str(baseN(sum_max, base)))\n"}, {"source_code": "text = raw_input()\n\na, b = text.split()\n\nans = 0\nmm = int(max(a + b))\n\nfor x in range(mm + 1, 25):\n v = int(a, x) + int(b, x)\n cnt = 0\n while v > 0:\n cnt += 1\n v /= x\n ans = max(ans, cnt)\n\nprint ans\n\n"}, {"source_code": "buf = raw_input()\nd = int(max(buf)) + 1\ns = sum(int(x,d) for x in buf.split())\nc = 1\nwhile s / d != 0:\n s /= d\n c += 1\nprint c\n"}, {"source_code": "a, b = [int(i) for i in raw_input().split()]\n\nmaxdigit = max([ord(i) for i in str(a)] + [ord(i) for i in str(b)])\nmaxdigit = int(chr(maxdigit))\n\nosn = maxdigit + 1\n\nsm = int(str(a), osn) + int(str(b), osn)\n\n\n\ncnt = 1\nwhile osn ** cnt <= sm:\n cnt += 1\nprint cnt\n"}, {"source_code": "#!/usr/bin/env python\nalpha = '0123456789ABCDEF'\ndef to_base(num, base):\n global alpha\n m = int(max(num))\n num = int(num)\n res = ''\n while num >0:\n res+=alpha[num % base]\n num/=base\n return res\n\na, b = raw_input().split(' ')\nres = 0\ns = int(max(int(max(a)), int(max(b))))+1\nfor i in range(s, 17):\n res = max(res, len(to_base(str(int(a, i)+int(b,i)),i)[::-1]))\nprint res"}, {"source_code": "a, b = raw_input ().split ()\np = max (map (int, a + b)) + 1\ns = int (a, p) + int (b, p)\nans = 0\nwhile s > 0:\n ans += 1\n s /= p\nprint ans\n"}, {"source_code": "__author__ = 'MoustaphaSaad'\nline = raw_input().split()\nbase = 0\n\ndef cal(n):\n res = 0\n while n > 0:\n res = max(res, n % 10)\n n /= 10\n return res\na, b = int(line[0]), int(line[1])\nbase = max(base, cal(a)+1)\nbase = max(base, cal(b)+1)\ncar, lene= 0, 0\nwhile a != 0 or b != 0:\n tmp = a % 10 + b % 10 + car\n car = tmp / base\n a /= 10\n b /= 10\n lene += 1\nif car > 0:\n lene += 1\n\nprint lene"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef test_len(n1, n2, base):\n if len(n1) > len(n2):\n s = map(int, n1)\n n = n2\n else:\n s = map(int, n2)\n n = n1\n s.insert(0, 0)\n for i in xrange(len(n)):\n s[-i-1] += int(n[-i-1])\n for i in xrange(1, len(s)+1):\n while s[-i] >= base:\n s[-i-1] += 1\n s[-i] -= base\n if s[0] == 0:\n s.pop(0)\n return len(s)\n\ndef main():\n a, b = raw_input().split()\n mbase = max([int(s) for s in a + b])\n print max([test_len(a, b, base) for base in xrange(16, mbase, -1)])\n return 0\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = raw_input()\na,b = map(int,s.split())\nm = int(max(list(s.replace(' ','')))) + 1\nres = int(str(a),m) + int(str(b),m)\nans = 0\nwhile res > 0:\n res //= m\n ans += 1\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python\n\na,b = map(str, raw_input().split(' '))\n\nA = []\nB = []\nfor i in a:\n A.append(int(i))\n\nfor i in b:\n B.append(int(i))\n\nA.reverse()\nB.reverse()\n\nmaxlen = max(len(A),len(B))\n\nfor i in range(len(A),maxlen+1):\n A.append(0)\n\nfor i in range(len(B),maxlen+1):\n B.append(0)\n\nbase = max(max(A),max(B))+1\n\nC = []\n\nfor i in range(maxlen+1):\n s = A[i]+B[i]\n C.append(s%base)\n reste = s/base\n if reste > 0:\n A[i+1] += 1\n\nfor i in range(len(C),0,-1):\n if C[i-1] != 0:\n print i\n quit()\n\n\n"}, {"source_code": "s = raw_input()\nsys = int(max(s)) + 1\na1, a2 = s.split()\nc = int(a1, sys) + int(a2, sys)\ncount = 1\nwhile c / sys != 0:\n c = c / sys\n count += 1\nprint count\n \n"}, {"source_code": "a, b = raw_input().split()\nx = int(max(a + b)) + 1\ns = int(a, x) + int(b, x)\nans = 0\nwhile s:\n ans += 1\n s /= x\nprint ans"}, {"source_code": "from __future__ import division, print_function\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n\nif sys.version_info[0] < 3:from __builtin__ import xrange as range;from future_builtins import ascii, filter, hex, map, oct, zip \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)\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\");ii = lambda: int(input());ll = lambda: list(map(int , input().split()));vv = lambda: map(int , input().split());pr = print\npl = lambda l: pr(\" \".join(list(map(str,l))))\n\n\na , b = vv()\nA , B = a , b\na = list(map(int , str(a)))\nb = list(map(int , str(b)))\nbase = max(max(a) , max(b)) + 1\ndec = int(str(A),base)+ int(str(B) , base)\nans = []\nwhile(dec!=0):\n ans.append(dec%base)\n dec//=base\nprint(len(ans))"}, {"source_code": "from sys import stdin\n\ndef decTo(x, d):\n s = ''\n while x > 0:\n z = x % d\n s += str(z)\n x //= d\n return int(s[::-1])\n \ndef toDec(x, d):\n s = 0\n count = 0\n while x > 0:\n z = x % 10 * pow(d, count)\n count += 1\n s += z\n x //= 10\n return s\n\na, b = next(stdin).split()\nmax1 = max(a)\nmax1 = int(max(b)) if max(b) > max1 else int(max1)\nmax1 += 1\nprint(len(str(decTo(toDec(int(a), max1) + toDec(int(b), max1), max1))))"}, {"source_code": "def s():\n\t[a,b] = input().split()\n\tm = int(max(max(a),max(b)))+1\n\ta = int(a)\n\tb = int(b)\n\tc = 0\n\tr = 0\n\twhile a or b or c:\n\t\tr += 1\n\t\tc = (a%10+b%10+c)//m\n\t\ta//=10\n\t\tb//=10\n\tprint(r)\ns()"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\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-----------------------------------------------------\na,b=list(map(int,input().split()))\nk=int(max(str(a)+str(b)))+1\ncarry=0\nl=max(len(str(a)),len(str(b)))\nfor itr in range(l):\n if a%10+b%10+carry0:\n\tval+=1\n\tt1*=t\n\nprint(val)\n\n#n=int(inf.readline())\n#s=inf.readline()\n# s=\"bacabcab\"\n# changed=False\n# while not changed:\n# \tprint(s)\n# \tchanged=True\n# \ti=0\n# \tll=len(s)\n# \twhile(i+1maxyet):\n# \tprint(partition)\n# \tmaxyet=temp\n\n# print(maxyet)"}, {"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------------------------------------\na,b=map(int,input().split())\nc=a\nn=len(str(a))\nn1=len(str(b))\nd=b\na=max(str(a))\nb=max(str(b))\nbase=int(max(a,b))+1\nt=0\ne=0\ne1=0\nfor i in range(n-1,-1,-1):\n e=e+pow(base,t)*(c%10)\n c//=10\n t+=1\nt=0\nfor i in range(n1-1,-1,-1):\n e1=e1+pow(base,t)*(d%10)\n d//=10\n t+=1\nrt=e+e1\nc=rt\ns=\"\"\nwhile(c>0):\n s+=str(c%base)\n c//=base\nprint(len(s))"}, {"source_code": "a,b=list(map(int,input().split()))\nk=int(max(str(a)+str(b)))+1\ncarry=0\nl=max(len(str(a)),len(str(b)))\nfor itr in range(l):\n if a%10+b%10+carrylen(bL) :\n lenAB = len(aL)\nelse:\n lenAB = len(bL)\nnewNum = []\nnextAdd = 0\nj = 0\nwhile (j= len(aL):\n aL.append(0)\n if j >= len(bL):\n bL.append(0)\n newNum.append((int(aL[j]) + int(bL[j]) + nextAdd) % base)\n nextAdd = int((int(aL[j]) + int(bL[j]) + nextAdd) / base)\n j += 1\n \n \nprint (len(newNum))"}, {"source_code": "a,b=map(int, input().split())\nmax1=a%10\nch1=a\nch2=b\nwhile a>0:\n if a%10>max1:\n max1=a%10\n a=a//10\nmax2=b%10\nwhile b>0:\n if b%10>max2:\n max2=b%10\n b=b//10\nc=max(max1,max2)\nc+=1\nch1=int(str(ch1),c)\nch2=int(str(ch2),c)\nsum=ch1+ch2\ni=0\nwhile c**i 0):\n nr_digits+= 1\n total = total // chosen_base\n\nprint(nr_digits)"}, {"source_code": "a, b = list(map(int, input().split()))\na = list(map(int, list(str(a))))[::-1]\nb = list(map(int, list(str(b))))[::-1]\nbs = max(max(a), max(b)) + 1\nhead = 0\nwhile len(a) > len(b):\n b.append(0)\nwhile len(b) > len(a):\n a.append(0)\nfor i in range(len(a)):\n head = (head + a[i] + b[i]) // bs\nif head == 0:\n print(len(a))\nelse:\n print(max(1, head // (bs)) + len(a))"}, {"source_code": "a, b = input().split()\nbase = int(max(max(a), max(b))) + 1\na, b = int(a, base), int(b, base)\nans, s = 0, a + b\nwhile s:\n s //= base\n ans += 1\nprint(ans)"}, {"source_code": "a,b=input().split()\nc=\"0123456789ABCDEF\"\nm=\"0\"\nfor d in a:\n if d>m: m=d\nfor d in b:\n if d>m: m=d\nn=c.index(m)+1\nx=0\nst=1\nfor d in a[::-1]:\n i=c.index(d)\n x+=(i*st)\n st*=n\ny=0\nst=1\nfor d in b[::-1]:\n i=c.index(d)\n y+=(i*st)\n st*=n\nx+=y\nans=0\nwhile x>0:\n ans+=1\n x//=n\nprint(ans)\n"}, {"source_code": "\na, b = input().split()\nsol=0\nfor i in range(10, 1, -1):\n try:\n c = int(a, i)+int(b, i)\n s = 0\n while c:\n c//=i\n s+=1\n sol=max(s, sol)\n except ValueError:\n break\nprint(sol)\n"}, {"source_code": "a,b = input().split()\narrA = [int(i) for i in str(a)]\narrB = [int(i) for i in str(b)]\ndef toStr(n,base):\n convertString = \"0123456789ABCDEF\"\n if n < base:\n return convertString[n]\n else:\n return toStr(n//base,base) + convertString[n%base]\nfor i in range(0, len(arrB)):\n\tarrA.append(arrB[i])\nbase = max(arrA) + 1\nA = int(str(a),base)\nB = int(str(b),base)\nC = A + B\nprint(len(toStr(C,base)))"}, {"source_code": "a,b=map(int,input().split())\nta=a \ntb=b \naa=0\nbb=0\nwhile a>0:\n\taa=max(aa,a%10)\n\ta=a//10 \nwhile b>0:\n\tbb=max(bb,b%10)\n\tb=b//10 \nbase=max(aa,bb)+1 \nans=0\np=1\nwhile ta>0:\n\ta+=(p*(ta%10))\n\tp*=base \n\tta=ta//10\np=1\nwhile tb>0:\n\tb+=(p*(tb%10))\n\tp*=base\n\ttb=tb//10\nc=(a+b)\nwhile c>0:\n\tc=c//base\n\tans+=1\nprint(ans)"}, {"source_code": "import sys\n\ndef largest(x):\n ret = 0\n while x > 0:\n ret = max(ret, x%10)\n x //= 10\n return ret\n\ndef tobase(x, base):\n ret = 0\n p=1\n while x>0:\n ret+=(x%10)*p\n p*=base\n x //= 10\n return ret\n\n\ndef digitsNum(x, base):\n ret = 0\n while x>0:\n ret += 1\n x //= base\n return ret\n\nn, m= map(int, sys.stdin.read().split())\nbase = max(largest(n),largest(m)) + 1\nx = tobase(n, base) + tobase(m, base)\nprint(digitsNum(x, base))"}, {"source_code": "import sys\n\ndef digitsNum(x, base):\n ret = 0\n while x>0:\n ret += 1\n x //= base\n return ret\n\nn, m= sys.stdin.read().split()\n\nbase = int(max(max(n), max(m)))+1\nn = int(n, base)\nm = int(m, base)\n\nprint(digitsNum(n+m, base))"}, {"source_code": "a, b = input().split()\nx = int(max(a + b)) + 1\ns, v = int(a, x) + int(b, x), 0\nwhile s:\n s, v = s // x, v + 1\nprint(v)"}, {"source_code": "a, b = input().split()\nc = int(max(max(a), max(b))) + 1\nl = max(len(a), len(b))\nk, s = pow(c, l), int(a, c) + int(b, c)\nprint(l + int(s >= k))"}, {"source_code": "a, b = input().split()\n\nx = int(max(a + b)) + 1\n\ns, v = int(a, x) + int(b, x), 0\n\nwhile s:\n\n s, v = s // x, v + 1\n\nprint(v)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def maxLength(a, b):\n base = 1 + max(int(c) for c in str(a) + str(b))\n ret, c = 0, int(str(a), base) + int(str(b), base)\n while c > 0:\n ret += 1\n c = c // base\n return ret\n\ndef main():\n a, b = [int(s) for s in input().split()]\n print(maxLength(a, b))\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\n\na, b = input().split();\ndigits = list(str(a) + str(b));\nbase = int(max(digits)) + 1;\n\na = int(str(a), base);\nb = int(str(b), base);\nsumResult = a + b;\n\nstart = 1;\nresult = \"\";\n\nwhile (sumResult > 0):\n mod = sumResult % base;\n result += str(mod);\n sumResult = math.floor(sumResult / base);\nprint(len(result));\n"}, {"source_code": "#-------------------------------------------------------------------------------\n# Name: Codeforces\n# Author: Gogol2\n\n#-------------------------------------------------------------------------------\n\n\n\ndef main():\n x,y = map(int,input().split())\n max_q = -1\n\n a,b = x,y\n while (x > 0):\n max_q = max(max_q,x % 10)\n x = x//10\n while (y > 0):\n max_q = max(max_q,y % 10)\n y = y//10\n max_q = max_q + 1\n k = 0\n z = int(str(a),max_q)+int(str(b),max_q)\n while (z > 0):\n k += 1\n z = z // max_q\n print(k)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def parse_num(num, base):\n ans = 0\n for c in num:\n ans = ans * base + int(c) % 10\n # num //= 10\n return ans\n\n\na, b = input().strip().split(\" \")\n\nans = max(len(a), len(b))\n\nbase = -1\nfor c in a + b:\n base = max(int(c), base)\nbase += 1\n\n# print(parse_num(a, base))\n# print(parse_num(b, base))\nsum_ = parse_num(a, base) + parse_num(b, base)\n# print(sum_)\n\ncounter = 0\nwhile sum_:\n # print(sum_)\n counter += 1\n sum_ //= base\n\nprint(counter)\n"}, {"source_code": "ax, bx = map(str, input().split())\nd = max([ord(c) - ord('0') for c in ax] + [ord(c) - ord('0') for c in bx]) + 1\nad, bd = 0, 0\nfor dig in ax:\n ad = ad * d + (ord(dig) - ord('0')) % 10\nfor dig in bx:\n bd = bd * d + (ord(dig) - ord('0')) % 10\nc = ad + bd\nans = 0\nwhile c > 0:\n ans += 1\n c //= d\nprint(ans)"}, {"source_code": "import string\n\ns = raw_input()\na, b = [i for i in s.split()]\nbase = max(sorted(i, reverse=True)[0] for i in s.split())\nif base in string.digits:\n base = ord(base) - ord('0') + 1 \nelse:\n base = ord(base) - ord('A') + 1 \nbase10 = int(a, base) + int(b, base)\n\nsol = \"\"\nwhile base10:\n sol = str(base10 % base) + sol \n base10 /= base\n\nprint len(sol) "}, {"source_code": "import string\na, b = raw_input().split()\np = max(max([int(i) for i in a]), max([int(j) for j in b])) + 1\nan, bn = 0, 0\nfor i in range(len(a)):\n an += int(a[i])*(p**(len(a)-i-1))\nfor i in range(len(b)):\n bn += int(b[i])*(p**(len(b)-i-1)) \nn = \"\"\nx = an + bn\nwhile x > 0:\n y = str(x % p)\n n = y + n\n x = int(x / p)\n\nprint len(n)\n"}, {"source_code": "#!/usr/bin/python\n\ndef pos_to_10(n, p):\n x = 0\n pp = 1\n for i in reversed(list(n)):\n r = int(i)\n x += r * pp\n pp *= p\n return x\n\na, b = raw_input().split()\np = max([int(c) for c in a + b]) + 1\na, b = pos_to_10(a, p), pos_to_10(b, p)\ns = a + b\nl = 0\nwhile s > 0:\n s /= p\n l += 1\nprint l\n"}, {"source_code": "j=0\na,b=raw_input().split(' ')\nminbase=int(max(a+b))+1\ncount=int(a,minbase)+int(b,minbase)\nwhile count:\n count/=minbase\n j+=1\nprint j"}, {"source_code": "s = raw_input()\nch = max(s)\nif not ch.isdigit():\n\tch = ord(ch)-55 \nbase = int(ch) + 1 \n\nnum = sum([int(i, base) for i in s.split()])\nans = 0\nwhile num > 0:\n\tnum = num/base\n\tans += 1\nprint ans"}, {"source_code": "s = raw_input()\nch = max(s)\nif not ch.isdigit():\n\tch = ord(int(ch))-55 \nbase = int(ch) + 1 \n\na, b = [int(i, base) for i in s.split()]\n# print a, b\nnum = a + b\n# print num \n\nans = 0\nwhile num > 0:\n\tnum = num/base\n\tans += 1\nprint ans"}, {"source_code": "\nif __name__ == '__main__':\n s1, s2 = raw_input().split()\n c = ord(max(s1 + s2)) - ord('0') + 1\n if len(s1) < len(s2):\n s1 = s1.rjust(len(s2), '0')\n else:\n s2 = s2.rjust(len(s1), '0')\n n1 = map(int, s1)\n n2 = map(int, s2)\n p = 0\n for a, b in zip(n1[::-1], n2[::-1]):\n if a + b + p >= c:\n p = 1\n else:\n p = 0\n print len(n1) + p"}, {"source_code": "a, b = raw_input ().split ()\np = max (map (int, a + b)) + 1\ns = int (a, p) + int (b, p)\nans = 0\nwhile s > 0:\n ans += 1\n s /= p\nprint ans"}, {"source_code": "a, b = raw_input().split()\nm = int(max(a + b)) + 1\nr = int(a, m) + int(b, m)\nl = 0\nwhile r:\n l += 1\n r /= m\nprint l\n "}, {"source_code": "\na,b = map(int,raw_input().split())\n\na_str = \"%d\" % a\nb_str = \"%d\" % b\nlowest_base = max([int(i) for i in a_str+b_str]) + 1\n\ntotal = int(a_str,base = lowest_base) + int(b_str,base = lowest_base)\nnr_chars = 0\nwhile total > 0:\n nr_chars += 1\n total = total / lowest_base\n\nprint nr_chars"}, {"source_code": "#!/usr/bin/env python\n\na,b = map(int,raw_input().split())\n\na_str = \"%d\" % a\nb_str = \"%d\" % b\nlowest_base = max([int(i) for i in a_str+b_str]) + 1\n\ntotal = int(a_str,base = lowest_base) + int(b_str,base = lowest_base)\nnr_chars = 0\nwhile total > 0:\n nr_chars += 1\n total = total / lowest_base\n\nprint nr_chars\n"}, {"source_code": "if __name__ == \"__main__\":\n a, b = raw_input().split()\n base = int(max(a + b)) + 1\n\n c = int(a, base) + int(b, base)\n result = 0\n while (c):\n result += 1\n c /= base\n\n print(result)"}, {"source_code": "def get_base(x):\n m = max(x)\n return max(2, (ord(m) - ord(\"0\") if m < \"A\" else 10 + ord(m) - ord(\"A\")) + 1)\na, b = raw_input().split()\nm = max(map(get_base, (a, b)))\nr = int(a, m) + int(b, m)\nx = str(r % m)\nwhile r:\n r /= m\n if r:\n x += str(r % m)\nprint len(x)\n"}, {"source_code": "a, b = raw_input().split()\nm = int(max(a + b)) + 1\nr = int(a, m) + int(b, m)\nl = 0\nwhile r:\n l += 1\n r /= m\nprint l"}, {"source_code": "a, b = raw_input().split()\nmx = int(max(a + b)) + 1\nv = int(a, mx) + int(b, mx)\nl = 0\nwhile (v != 0):\n l += 1\n v /= mx\n\nprint l\n"}, {"source_code": "# -*- coding: utf-8 -*-\nline = raw_input().strip('\\n')\n(a, b) = tuple(line.split(' '))\n\ncon = map(int, a+b)\nbase = max([con[i] for i in range(len(con))]) + 1\n\nsum = int(a, base) + int(b, base)\n\nc = 1\nwhile True:\n if sum/base**c==0:\n print c\n break\n c += 1\n \n\n \n \n"}, {"source_code": "[a,b]=raw_input().split();\nmaxi=0;\nfor i in a:\n if(i>maxi):\n maxi=i;\nfor i in b:\n if(i>maxi):\n maxi=i;\nbase=int(maxi)+1;\ndeca=0;\ndecb=0;\nmulti=len(a)-1;\nfor i in a:\n deca+=int(i)*pow(base,multi);\n multi-=1;\n \nmulti=len(b)-1;\nfor i in b:\n decb+=int(i)*pow(base,multi);\n multi-=1;\n\nsum=deca+decb;\n\ndigits=1;\nwhile(sum>=pow(base,digits)):\n digits+=1;\n\n\nprint(digits)\n"}, {"source_code": "\nfrom __future__ import division\nfrom numpy import *\nimport sys\nfrom collections import namedtuple #x=namedtuple('point','x y')\nfrom math import *\nfrom collections import deque, OrderedDict #append #popleft\nfrom fractions import gcd\nfrom copy import copy ,deepcopy\nfrom collections import Counter #Counter(list)\nimport re #re.split(\"[^a-zA-Z]\",text)\n# from functools import lru_cache #@lru_cache(maxsize = None)\n\"\"\"\n#reduce(func,list)\n#map(func,list)\n#filter(func,list)\n#xor=lambda x,y :x^y\n#sign = lambda x: math.copysign(1, x)\n#list.reverse() \n#list.sort() list=sorted(list)\nlist.sort(key=operator.itemgetter(1,2))\n#reverse word word[::-1]\n#word.islower()\n#word.lower() word.upper()\nx = x1 if exp1 else x2\nany([false,true])\nall([true,false])\n\"a\".isalpha()\n\"1\".isdigit()\n\"\"\"\n\nfin=sys.stdin ;fout=sys.stdout \n# fin=open('../in','r') ; fout=open('../out','w')\ndef readline():\n return fin.readline().strip()\ndef readstrings():\n return fin.readline().strip().split(' ')\ndef writeline(value):\n fout.write(str(value))\n fout.write(\"\\n\")\ndef read_integers():\n return [int(x) for x in fin.readline().strip().split(' ')]\ndef read_integer():\n return int(fin.readline().strip())\n\ndef digit_to_char(digit):\n if digit < 10:\n return str(digit)\n return chr(ord('a') + digit - 10)\n\ndef str_base(number,base):\n if number < 0:\n return '-' + str_base(-number, base)\n (d, m) = divmod(number, base)\n if d > 0:\n return str_base(d, base) + digit_to_char(m)\n return digit_to_char(m)\n\n\nnumbers=read_integers()\n\nmx=0\nfor number in numbers:\n for ch in str(number):\n mx=max(int(ch),mx)\na=int(str(numbers[0]),mx+1)\nb=int(str(numbers[1]),mx+1)\nwriteline(len(str_base(a+b,mx+1)))\n\n \n"}, {"source_code": "# coding=UTF-8\n\n#import sys\n\nimport sys\nfrom math import *\n\ndef main():\n inp = sys.stdin.readline().strip()\n max = 0\n for i in range(0, len(inp)):\n if inp[i] == ' ':\n continue\n if int(inp[i]) > max:\n max = int(inp[i])\n \n base = max + 1\n sTal = inp.split()\n \n tal1 = 0\n j = len(sTal[0]) - 1\n for i in range(0, len(sTal[0])):\n tal1 += (base ** j) * int(sTal[0][i])\n j -= 1\n \n tal2 = 0\n j = len(sTal[1]) - 1\n for i in range(0, len(sTal[1])):\n tal2 += (base ** j) * int(sTal[1][i])\n j -= 1\n \n sum = tal1 + tal2\n \n count = 0\n while base**count <= sum:\n count += 1\n \n pprint(repr(count))\n \n \ndef pprint(str):\n sys.stdout.write(str)\n return\n\nmain()"}, {"source_code": "a, b = raw_input().split()\nma, mb = max(a), max(b)\nbase = int(max(ma, mb)) + 1\nda, db = int(a, base), int(b, base)\ns = da + db\ncount = 0\nwhile s > 0:\n count += 1\n s /= base\n\nprint count\n"}, {"source_code": "import math\ns = raw_input()\no=2\nfor i in s:\n if i in \"fF\":\n if o<16:\n o=16\n if i in \"eE\":\n if o<15:\n o=15\n if i in \"dD\":\n if o<14:\n o=14\n if i in \"cC\":\n if o<13:\n o=13\n if i in \"bB\":\n if o<12:\n o=12\n if i in \"aA\":\n if o<11:\n o=11\n if i in '0123456789':\n if o=math.pow(i,j):\n #print \"Osnovanie=\"+str(i)+\", stepen=\"+str(j)\n a.append(j+1)\nprint max(a)"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\nimport string\n\ndef cha(num,base):\n v = 0\n rest = 0\n while(num != 0):\n rest += (num%10) * (base ** v)\n num /= 10\n v +=1\n\n return rest\n\nif __name__ == '__main__':\n str1,str2 = map(str,sys.stdin.readline().split())\n\n max = 0\n for v in (str1+str2):\n if int(v) > max:\n max = int(v)\n\n start = cha(int(str1),max+1) + cha(int(str2),max+1)\n i=1\n while (start/(max+1) != 0):\n start /=(max+1)\n i+=1\n print i\n"}, {"source_code": "a=[0,0]\ntmp=raw_input().split()\nbase=int(max(tmp[0]+tmp[1]))+1\na[0]=int(tmp[0],base)\na[1]=int(tmp[1],base)\n\nn=1\nk=base\ns=sum(a)\nwhile k<=s:\n k*=base\n #print base\n n+=1\nprint n"}, {"source_code": "import sys\nimport math\nimport time\nfrom Queue import 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\na = pin.nextInt()\nb = pin.nextInt()\n\ndef toBase(x, base) :\n sum = 0\n for c in str(x) : \n sum *= base\n sum += int(c)\n return sum\n \ndef clBase(x, base) :\n res = 0\n while x > 0:\n x /= base\n res += 1\n return res\n\nres = 0\n\nfor base in range(max([int(c) for c in Set(str(a) + str(b))]) + 1, 1000) :\n res = max(res, clBase(toBase(a, base) + toBase(b, base), base))\n \nprint res\n\n\n\n#print (\"Press any key to continue\")\n#raw_input() \n"}, {"source_code": "import sys\nimport math\nimport time\nfrom Queue import 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\na = pin.nextInt()\nb = pin.nextInt()\n\ndef toBase(x, base) :\n sum = 0\n for c in str(x) : \n sum *= base\n sum += int(c)\n return sum\n \ndef clBase(x, base) :\n res = 0\n while x > 0:\n x /= base\n res += 1\n return res\n\nres = 0\n\nfor base in range(max([int(c) for c in Set(list(str(a) + str(b)))]) + 1, 1000) :\n res = max(res, clBase(toBase(a, base) + toBase(b, base), base))\n \nprint res\n\n\n\n#print (\"Press any key to continue\")\n#raw_input() \n"}, {"source_code": "a, b = raw_input().split()\nans = 0\nfor i in xrange(2, 37):\n try:\n c = int(a, i) + int(b, i)\n res = 0\n while c > 0:\n c /= i\n res += 1\n ans = max(ans, res)\n except ValueError,e:\n pass\n\nprint ans"}, {"source_code": "text = raw_input()\na, b = text.split()\nbase = (int)(max(a + b))\nbase += 1\nsum = int(a, base) + int(b, base)\nret = 0\nwhile (sum > 0) :\n ret += 1\n sum /= base\n \nprint(ret);"}, {"source_code": "import sys\nline = sys.stdin.readline().strip();\na = line.split(\" \")[0];\nb = line.split(\" \")[1];\ns = a + b;\nm = 0;\nfor c in s :\n d = int(c);\n m = max(m, d);\n\nt = int(a, (m+1)) + int(b,(m+1))\nret = \"\";\nwhile (t != 0):\n r = t % (m + 1);\n t //= (m + 1);\n ret = ret + str(r);\nprint(len(ret));"}, {"source_code": "if __name__ == '__main__':\n s1, s2 = raw_input().split()\n c = ord(max(s1 + s2)) - ord('0') + 1\n if len(s1) < len(s2):\n s1 = s1.rjust(len(s2), '0')\n else:\n s2 = s2.rjust(len(s1), '0')\n n1 = map(int, s1)\n n2 = map(int, s2)\n p = 0\n for a, b in zip(n1[::-1], n2[::-1]):\n if a + b + p >= c:\n p = 1\n else:\n p = 0\n print len(n1) + p"}, {"source_code": "s = raw_input().split()\nmx, up = -1, 0\nif len(s[0])>len(s[1]): s.reverse()\ns[0] = (len(s[1])-len(s[0]))*'0' + s[0]\nfor i in xrange(len(s[0])):\n mx = max(mx,int(s[0][i]))\n mx = max(mx,int(s[1][i]))\np = mx + 1\nfor i in xrange(len(s[0])):\n if int(s[0][len(s[0])-1-i]) + int(s[1][len(s[0])-1-i]) + up >= p: up = 1\n else: up = 0\nprint len(s[0]) + up\n\n\n"}], "negative_code": [{"source_code": "# -*- coding: UTF-8 -*-\n\n# from itertools import *\n# from collections import defaultdict\ndef base10toN(num,n):\n return ((num == 0) and \"0\" ) or ( base10toN(num // n, n).strip(\"0\") + \"0123456789abcdefghijklmnopqrstuvwxyz\"[:n][num % n])\nT = raw_input().split()\n\nbase = int(max(T[0]+T[1]))+1\nsum_max = int(T[0], base) + int(T[1], base)\nprint len(str(base10toN(sum_max, base)))\n"}, {"source_code": "a, b = [int(i) for i in raw_input().split()]\n\nmaxdigit = max([ord(i) for i in str(a)] + [ord(i) for i in str(b)])\nmaxdigit = int(chr(maxdigit))\n\nsm = a + b\n\nimport math\n\nprint int(math.ceil(math.log(sm + 1, maxdigit + 1)))\n"}, {"source_code": "__author__ = 'MoustaphaSaad'\nline = raw_input().split()\nbase = 0\nfor num in line:\n for d in num:\n base = max(base, int(d))\na, b = int(line[0]), int(line[1])\ncar, lene= 0, 0\nwhile a != 0 or b != 0:\n tmp = a%10 + b%10 + car\n car = tmp / base\n a /= 10\n b /= 10\n lene += 1\nif car > 0:\n lene += 1\n\nprint lene\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef test_len(n1, n2, base):\n if len(n1) > len(n2):\n s = map(int, n1)\n n = n2\n else:\n s = map(int, n2)\n n = n1\n s.insert(0, 0)\n for i in xrange(len(n)):\n s[-i-1] += int(n[-i-1])\n if s[-i-1] >= base:\n s[-i-2] += s[-i-1] - base\n s[-i-1] -= base\n return len(s) - (1 if s[0] != 0 else 0)\n\ndef main():\n a, b = raw_input().split()\n mbase = max([int(s) for s in a + b])\n print max([test_len(a, b, base) for base in xrange(16, mbase, -1)])\n return 0\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef test_len(n1, n2, base):\n if len(n1) > len(n2):\n s = map(int, n1)\n n = n2\n else:\n s = map(int, n2)\n n = n1\n s.insert(0, 0)\n for i in xrange(len(n)):\n s[-i-1] += int(n[-i-1])\n while s[-i-1] >= base:\n s[-i-2] += 1\n s[-i-1] -= base\n if s[0] == 0:\n s.pop(0)\n return len(s)\n\ndef main():\n a, b = raw_input().split()\n mbase = max([int(s) for s in a + b])\n print max([test_len(a, b, base) for base in xrange(16, mbase, -1)])\n return 0\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "s = raw_input()\na1, a2 = map(int, s.split())\nsys = int(max(s)) + 1\nc = a1 + a2\ncount = 1\nwhile c / sys != 0:\n c = c / sys\n count += 1\nprint count\n \n"}, {"source_code": "s = raw_input()\na1, a2 = s.split()\nsys = int(max(s)) + 1\nc = str(int(a1, sys) + int(a2, sys))\nprint len(c)\n"}, {"source_code": "from sys import stdin\n\na, b = next(stdin).split()\nmax1 = max(a)\nmax1 = int(max(b)) if max(b) > max1 else int(max1)\nmax1 += 1\nn = int(a) + int(b)\ncount = 0\nwhile n > 0:\n n //= max1\n count += 1\nprint(count)"}, {"source_code": "#Code by Sounak, IIESTS\n#------------------------------warmup----------------------------\n\nimport os\nimport sys\nimport math\nfrom io import BytesIO, IOBase\nfrom fractions import Fraction\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-----------------------------------------------------\na,b=map(int,input().split())\nmx=1\ncopy=a\nwhile copy>0:\n t=copy%10\n mx=max(mx,t)\n copy//=10\ncopy=b\nwhile copy>0:\n t=copy%10\n mx=max(mx,t)\n copy//=10\nbase=mx+1\n#print (mx)\nct=0\nc=a+b\nwhile c>0:\n ct+=1\n c//=base\nprint(ct)"}, {"source_code": "a, b = map(int, input().split())\nc = a + b\nm = 0\nfor i in str(a):\n m = max(m, int(i))\nfor i in str(b):\n m = max(m, int(i))\n\nm += 1\nans = 0\nt = 1\nwhile t * m <= c:\n t *= m\n ans += 1\nprint(ans + 1)\n"}, {"source_code": "from collections import *\n\nletters = '0123456789ABCDEF'\n\n\ndef tobase(s, base):\n res = deque([])\n if s == 0:\n return 0\n while (s != 0):\n res.appendleft(letters[s % base])\n s //= base\n return ''.join(res)\n\n\na, b = map(int, input().split())\nma1, ma2 = int(max(list(str(a)))), int(max(list(str(b))))\nans = a + b\nprint(len(tobase(ans, max(ma1, ma2) + 1)))\n"}, {"source_code": "from sys import stdin\ninf=stdin\n#inf=open(\"data1.txt\",'rt')\n\nn,m=inf.readline().split(\" \")\nt=int(max(max(n),max(m)))+1\nans=int(n,t+1)+int(m,t+1)\n\nt1=t\nval=1\nwhile ans//t1>0:\n\tval+=1\n\tt1*=t\n\nprint(val)\n\n#n=int(inf.readline())\n#s=inf.readline()\n# s=\"bacabcab\"\n# changed=False\n# while not changed:\n# \tprint(s)\n# \tchanged=True\n# \ti=0\n# \tll=len(s)\n# \twhile(i+1maxyet):\n# \tprint(partition)\n# \tmaxyet=temp\n\n# print(maxyet)"}, {"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------------------------------------\na,b=map(int,input().split())\nc=a\nn=len(str(a))\nn1=len(str(b))\nd=b\na=max(str(a))\nb=max(str(a))\nbase=int(max(a,b))+1\nt=0\ne=0\ne1=0\nfor i in range(n-1,-1,-1):\n e=e+pow(base,t)*(c%10)\n c//=10\n t+=1\nt=0\nfor i in range(n1-1,-1,-1):\n e1=e1+pow(base,t)*(d%10)\n d//=10\n t+=1\nrt=e+e1\nc=rt\ns=\"\"\nwhile(c>0):\n s+=str(c%base)\n c//=base\nprint(len(s))"}, {"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------------------------------------\na,b=map(int,input().split())\nc=a+b\na=max(str(a))\nb=max(str(a))\nbase=int(max(a,b))+1\ns=\"\"\nwhile(c>0):\n s+=str(c%base)\n c//=base\nprint(len(s))"}, {"source_code": "a,b=list(map(int,input().split()))\nk=int(max(str(a)+str(b)))+1\ncarry=0\nl=max(len(str(a)),len(str(b)))\nfor itr in range(l):\n if a%10+b%10+carry len(b):\n b.append(0)\nwhile len(b) > len(a):\n a.append(0)\nfor i in range(len(a)):\n head = max(0, head + a[i] + b[i] - (bs - 1))\nif head == 0:\n print(a)\nelse:\n print(max(1, head // bs) + len(a))"}, {"source_code": "a, b = list(map(int, input().split()))\na = list(map(int, list(str(a))))[::-1]\nb = list(map(int, list(str(b))))[::-1]\nbs = max(max(a), max(b)) + 1\nhead = 0\nwhile len(a) > len(b):\n b.append(0)\nwhile len(b) > len(a):\n a.append(0)\nfor i in range(len(a)):\n head = max(0, head + a[i] + b[i] - (bs - 1))\nif head == 0:\n print(len(a))\nelse:\n print(max(1, head // (bs - 1)) + len(a))"}, {"source_code": "a, b = list(map(int, input().split()))\na = list(map(int, list(str(a))))[::-1]\nb = list(map(int, list(str(b))))[::-1]\nbs = max(max(a), max(b)) + 1\nhead = 0\nwhile len(a) > len(b):\n b.append(0)\nwhile len(b) > len(a):\n a.append(0)\nfor i in range(len(a)):\n head = max(0, head + a[i] + b[i] - (bs - 1))\nif head == 0:\n print(len(a))\nelse:\n print(max(1, head // bs) + len(a))"}, {"source_code": "a, b = list(map(int, input().split()))\na = list(map(int, list(str(a))))[::-1]\nb = list(map(int, list(str(b))))[::-1]\nbs = max(max(a), max(b)) + 1\nhead = 0\nwhile len(a) > len(b):\n b.append(0)\nwhile len(b) > len(a):\n a.append(0)\nfor i in range(len(a)):\n head = max(0, head + a[i] + b[i] - (bs - 1))\ncnt = head // (bs - 1) + len(a)\nprint(cnt)"}, {"source_code": "a,b=input().split()\nc=\"0123456789ABCDEF\"\nm=\"0\"\nfor d in a:\n if d>m: m=d\nfor d in b:\n if d>m: m=d\nn=c.index(m)+1\n\nx=0\nst=1\nfor d in a:\n i=c.index(m)\n x+=(i*st)\n st*=n\ny=0\nst=1\nfor d in b:\n i=c.index(m)\n y+=(i*st)\n st*=n\nx+=y\nans=0\nwhile x>0:\n ans+=1\n x//=n\nprint(ans)\n"}, {"source_code": "a,b=input().split()\nc=\"0123456789ABCDEF\"\nm=\"0\"\nfor d in a:\n if d>m: m=d\nfor d in b:\n if d>m: m=d\nn=c.index(m)+1\nx=0\nst=1\nfor d in a:\n i=c.index(d)\n x+=(i*st)\n st*=n\ny=0\nst=1\nfor d in b:\n i=c.index(d)\n y+=(i*st)\n st*=n\nx+=y\nans=0\nwhile x>0:\n ans+=1\n x//=n\nprint(ans)\n"}, {"source_code": "import math\n\na, b = input().split();\nsumResult = int(a) + int(b);\ndigits = list(str(a) + str(b));\nbase = int(max(digits)) + 1;\n\nstart = 1;\nresult = \"\";\n\nwhile (sumResult > 0):\n mod = sumResult % base;\n result += str(mod);\n sumResult = math.floor(sumResult / base);\nprint(len(result));\n"}, {"source_code": "#-------------------------------------------------------------------------------\n# Name: Codeforces\n# Author: Gogol2\n\n#-------------------------------------------------------------------------------\n\n\n\ndef main():\n x,y = map(int,input().split())\n max_q = -1\n z = x+y\n while (x > 0):\n max_q = max(max_q,x % 10)\n x = x//10\n while (y > 0):\n max_q = max(max_q,y % 10)\n y = y//10\n max_q = max_q + 1\n k = 0\n while (z > 0):\n k += 1\n z = z // max_q\n print(k)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def parse_num(num, base):\n num = int(num)\n ans = 0\n while num:\n ans = ans * base + num % 10\n num //= 10\n return ans\n\n\na, b = input().strip().split(\" \")\n\nans = max(len(a), len(b))\n\nbase = -1\nfor c in a + b:\n base = max(int(c), base)\nbase += 1\n\n# print(parse_num(a, base))\n# print(parse_num(b, base))\nsum_ = parse_num(a, base) + parse_num(b, base)\n# print(sum_)\n\ncounter = 0\nwhile sum_:\n counter += 1\n sum_ //= base\n\nprint(counter)\n"}, {"source_code": "ax, bx = map(str, input().split())\na, b = int(ax), int(bx)\nd = max([ord(c) - ord('0') for c in ax] + [ord(c) - ord('0') for c in bx]) + 1\nad, bd = 0, 0\nwhile a > 0:\n ad = ad * d + a % 10\n a //= 10\nwhile b > 0:\n bd = bd * d + b % 10\n b //= 10\nc = ad + bd\nans = 0\nwhile c > 0:\n ans += 1\n c //= d\nprint(ans)"}, {"source_code": "import string\na, b = raw_input().split()\np = max(max([int(i) for i in a]), max([int(j) for j in b])) + 1\nan, bn = 0, 0\nfor i in a:\n an += int(i)*(p**(len(a)-a.index(i)-1))\nfor i in b:\n bn += int(i)*(p**(len(b)-b.index(i)-1)) \n\nn = \"\"\nx = an + bn\nwhile x > 0:\n y = str(x % p)\n n = y + n\n x = int(x / p)\n\nprint len(n)\n"}, {"source_code": "import string\na, b = raw_input().split()\np = max(max([int(i) for i in a]), max([int(j) for j in b])) + 1\nan, bn = 0, 0\nfor i in range(len(a)):\n an += int(a[i])*(p**(len(a)-i-1))\nfor i in range(len(b)):\n bn += int(a[i])*(p**(len(b)-i-1)) \n\nn = \"\"\nx = an + bn\nwhile x > 0:\n y = str(x % p)\n n = y + n\n x = int(x / p)\nprint len(n)\n"}, {"source_code": "#!/usr/bin/python\n\na, b = raw_input().split()\np = max([int(c) for c in a + b]) + 1\ns = int(a) + int(b)\nl = 0\nwhile s > 0:\n s /= p\n l += 1\nprint l\n"}, {"source_code": "s = raw_input()\nch = max(s)\nif not ch.isdigit():\n\tch = ord(ch)-55 \nbase = int(ch) + 1 \nprint base\n\nnum = sum([int(i, base) for i in s.split()])\nans = 0\nwhile num > 0:\n\tnum = num/base\n\tans += 1\nprint ans"}, {"source_code": "if __name__ == \"__main__\":\n a, b = raw_input().split()\n base = int(max(a + b)) + 1\n\n c = int(a, base) + int(b, base)\n result = 1\n while (c):\n result += 1\n c /= base\n\n print(result)"}, {"source_code": "\nfrom __future__ import division\nfrom numpy import *\nimport sys\nfrom collections import namedtuple #x=namedtuple('point','x y')\nfrom math import *\nfrom collections import deque, OrderedDict #append #popleft\nfrom fractions import gcd\nfrom copy import copy ,deepcopy\nfrom collections import Counter #Counter(list)\nimport re #re.split(\"[^a-zA-Z]\",text)\n# from functools import lru_cache #@lru_cache(maxsize = None)\n\"\"\"\n#reduce(func,list)\n#map(func,list)\n#filter(func,list)\n#xor=lambda x,y :x^y\n#sign = lambda x: math.copysign(1, x)\n#list.reverse() \n#list.sort() list=sorted(list)\nlist.sort(key=operator.itemgetter(1,2))\n#reverse word word[::-1]\n#word.islower()\n#word.lower() word.upper()\nx = x1 if exp1 else x2\nany([false,true])\nall([true,false])\n\"a\".isalpha()\n\"1\".isdigit()\n\"\"\"\n\nfin=sys.stdin ;fout=sys.stdout \n# fin=open('../in','r') ; fout=open('../out','w')\ndef readline():\n return fin.readline().strip()\ndef readstrings():\n return fin.readline().strip().split(' ')\ndef writeline(value):\n fout.write(str(value))\n fout.write(\"\\n\")\ndef read_integers():\n return [int(x) for x in fin.readline().strip().split(' ')]\ndef read_integer():\n return int(fin.readline().strip())\n\nnumbers=read_integers()\n\nmx=0\nfor number in numbers:\n for ch in str(number):\n mx=max(int(ch),mx)\na=int(str(numbers[0]),mx+1)\nb=int(str(numbers[1]),mx+1)\nwriteline(len(str(a+b)))\n\n \n"}, {"source_code": "\nfrom __future__ import division\nfrom numpy import *\nimport sys\nfrom collections import namedtuple #x=namedtuple('point','x y')\nfrom math import *\nfrom collections import deque, OrderedDict #append #popleft\nfrom fractions import gcd\nfrom copy import copy ,deepcopy\nfrom collections import Counter #Counter(list)\nimport re #re.split(\"[^a-zA-Z]\",text)\n# from functools import lru_cache #@lru_cache(maxsize = None)\n\"\"\"\n#reduce(func,list)\n#map(func,list)\n#filter(func,list)\n#xor=lambda x,y :x^y\n#sign = lambda x: math.copysign(1, x)\n#list.reverse() \n#list.sort() list=sorted(list)\nlist.sort(key=operator.itemgetter(1,2))\n#reverse word word[::-1]\n#word.islower()\n#word.lower() word.upper()\nx = x1 if exp1 else x2\nany([false,true])\nall([true,false])\n\"a\".isalpha()\n\"1\".isdigit()\n\"\"\"\n\nfin=sys.stdin ;fout=sys.stdout \n# fin=open('../in','r') ; fout=open('../out','w')\ndef readline():\n return fin.readline().strip()\ndef readstrings():\n return fin.readline().strip().split(' ')\ndef writeline(value):\n fout.write(str(value))\n fout.write(\"\\n\")\ndef read_integers():\n return [int(x) for x in fin.readline().strip().split(' ')]\ndef read_integer():\n return int(fin.readline().strip())\n\ndef digit_to_char(digit):\n if digit < 10:\n return str(digit)\n return chr(ord('a') + digit - 10)\n\ndef str_base(number,base):\n if number < 0:\n return '-' + str_base(-number, base)\n (d, m) = divmod(number, base)\n if d > 0:\n return str_base(d, base) + digit_to_char(m)\n return digit_to_char(m)\n\nnumbers=read_integers()\n\nmx=0\nfor number in numbers:\n for ch in str(number):\n mx=max(int(ch),mx)\n \nwriteline(len(str_base(numbers[0]+numbers[1],mx+1)))\n\n \n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\nimport string\n\nif __name__ == '__main__':\n str1,str2 = map(str,sys.stdin.readline().split())\n\n max = 0\n for v in (str1+str2):\n if int(v) > max:\n max = int(v)\n\n start = int(str1)+int(str2)\n i=1\n while (start/(max+1) != 0):\n start /=(max+1)\n i+=1\n print i\n"}, {"source_code": "a=[0,0]\ntmp=raw_input().split()\na[0]=int(tmp[0])\na[1]=int(tmp[1])\nbase=int(max(tmp[0]+tmp[1]))+1\nn=1\nk=base\ns=sum(a)\nwhile k<=s:\n k*=base\n #print base\n n+=1\nprint n"}, {"source_code": "import sys\nline = sys.stdin.readline().strip();\na = line.split(\" \")[0];\nb = line.split(\" \")[1];\ns = a + b;\nm = 0;\nfor c in s :\n d = int(c);\n m = max(m, d);\n\nt = int(a) + int(b)\nret = \"\";\nwhile (t != 0):\n r = t % (m + 1);\n t //= (m + 1);\n ret = ret + str(r);\nprint(len(ret));"}, {"source_code": "s = raw_input().split()\na, b, c, mx, up = [], [], [], -1, 0\nfor i in xrange(len(s[0])):\n a.append(int(s[0][i]))\n mx = max(mx,a[i])\nfor i in xrange(len(s[1])):\n b.append(int(s[1][i]))\n mx = max(mx,b[i])\nfor _ in xrange(10):\n a.append(0)\n b.append(0)\np = mx + 1\nfor i in xrange(max(len(s[1]),len(s[0]))):\n if a[i] + b[i] + up >= p: up = 1\n else: up = 0\nprint max(len(s[1]),len(s[0])) + up\n\n\n"}, {"source_code": "s = raw_input().split()\na, b, c, mx, up = [], [], [], -1, 0\nfor i in xrange(len(s[0])):\n a.append(int(s[0][i]))\n mx = max(mx,a[i])\nfor i in xrange(len(s[1])):\n b.append(int(s[1][i]))\n mx = max(mx,b[i])\nfor _ in xrange(10):\n a.append(0)\n b.append(0)\np = mx + 1\nfor i in xrange(min(len(s[1]),len(s[0]))):\n if a[i] + b[i] + up >= p: up = 1\n else: up = 0\nprint max(len(s[1]),len(s[0])) + up\n\n\n"}], "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b"} {"nl": {"description": "You've got a rectangular parallelepiped with integer edge lengths. You know the areas of its three faces that have a common vertex. Your task is to find the sum of lengths of all 12 edges of this parallelepiped.", "input_spec": "The first and the single line contains three space-separated integers \u2014 the areas of the parallelepiped's faces. The area's values are positive (\u2009>\u20090) and do not exceed 104. It is guaranteed that there exists at least one parallelepiped that satisfies the problem statement.", "output_spec": "Print a single number \u2014 the sum of all edges of the parallelepiped.", "sample_inputs": ["1 1 1", "4 6 6"], "sample_outputs": ["12", "28"], "notes": "NoteIn the first sample the parallelepiped has sizes 1\u2009\u00d7\u20091\u2009\u00d7\u20091, in the second one\u00a0\u2014 2\u2009\u00d7\u20092\u2009\u00d7\u20093."}, "positive_code": [{"source_code": "import math \ndef findEdges(s1, s2, s3): \n a = math.sqrt(s1 * s2 / s3) \n b = math.sqrt(s3 * s1 / s2) \n c = math.sqrt(s3 * s2 / s1) \n sum = a + b + c \n return 4 * sum\n\n\n\ns=list(map(int,input().split()))\ns1=s[0]\ns2=s[1]\ns3=s[2]\nprint(int(findEdges(s1, s2, s3))) \n"}, {"source_code": "ab,bc,ac=map(int,input().split())\na=((ab/bc)*ac)**.5\nb=((bc/ac)*ab)**.5\nc=((ac/ab)*bc)**.5\nprint(int(4*(a+b+c)))"}, {"source_code": "import math\na, b,c = map(int, input().split())\nans1=math.sqrt((a*c)/b)\nans2=a/ans1\nans3=b/ans2\nanswer=4*(ans1+ans2+ans3)\nif(math.ceil(answer)==math.floor(answer)):\n print(int(answer))\nelse:\n print(answer)"}, {"source_code": "a, b, c = [int(x) for x in input().split(' ')]\n\nfrom math import sqrt\n\nprint(4*int((sqrt(a*b/c) + sqrt(b*c/a) + sqrt(a*c/b))))"}, {"source_code": "import math\n\na1,a2,a3 = list(map(int,input().split()))\n\na = math.sqrt((a1*a2)//a3)\nb = math.sqrt((a1*a3)//a2)\nc = math.sqrt((a2*a3)//a1)\n\nans = int((a+b+c)*4)\n\nprint(ans)"}, {"source_code": "lb, bh, hl = map(int, raw_input().strip().split())\nl = (lb*hl/bh)**0.5\nb = (lb*bh/hl)**0.5\nh = (bh*hl/lb)**0.5\n\nprint int(4*(l+b+h))\n"}, {"source_code": "from math import sqrt\nx,y,z = map(int,input().split())\na = int(sqrt((y*x)//z))\nb = x//a\nc = z//b\n\nprint((a+b+c)*4)\n\n"}, {"source_code": "import math\n\na1, a2, a3 = map(int, raw_input().split())\n\na = math.sqrt((a1*a2*1.0)/a3)\nb = math.sqrt((a1*a3*1.0)/a2)\nc = math.sqrt((a2*a3*1.0)/a1)\nprint int(4 * (a+b+c))\n"}, {"source_code": "s1, s2, s3=map(int, input().split())\nprint(int(4*((s1*s2/s3)**0.5+(s1*s3/s2)**0.5+(s2*s3/s1)**0.5)))\n"}, {"source_code": "from math import sqrt\ns1, s2, s3 = list(map(int,input().split()))\n\na = sqrt((s1 * s3) / s2)\nb = sqrt((s1 * s2) / s3)\nc = sqrt((s2 * s3) / s1)\n\nprint(int(4 * (a + b + c)))\n"}, {"source_code": "a,b,c = map(int,input().split())\nimport math as m\nz = m.sqrt((a*c)/b)\nx = a//z\ny = c//z\nprint(int(4*(x+y+z)))\n"}, {"source_code": "x,y,z = map(int,input().split())\nr = int((x*y*z)**0.5)\np = r//x +r//y +r//z\nprint(4*p)"}, {"source_code": "x,y,z=map(int, raw_input().split())\nprint int(4*((x*y/z)**(1./2) + (x*z/y)**(1./2)+(z*y/x)**(1./2)))"}, {"source_code": "sa, sb, sc = list(map(int, input().split()))\na = int(((sa * sb * sc) // sa ** 2) ** 0.5 + 0.5)\nb = int(((sa * sb * sc) // sb ** 2) ** 0.5 + 0.5)\nc = int(((sa * sb * sc) // sc ** 2) ** 0.5 + 0.5) \nprint((a + b + c) * 4)\n"}, {"source_code": "import math\nA, B, C = map(int, input().split())\na = math.sqrt(A*C/B)\nb = math.sqrt(A*B/C)\nc = math.sqrt(C*B/A)\nvertices = [a,b,c]\n\ndef suma(vertices):\n suma = 0\n for i in vertices:\n suma += i*4\n return int(suma)\n\nprint(suma(vertices))"}, {"source_code": "a,b,c = map(int,raw_input().split())\nfor x in xrange(1,a+1):\n if a%x == 0:\n y = a/x\n if b%y == 0:\n z = b/y\n if z*x == c:\n print 4*(x+y+z)\n break\n "}, {"source_code": "import math\nx,y,z=map(int,input().split())\na=math.sqrt(x*z/y)\nb=math.sqrt(x*y/z)\nc=math.sqrt(y*z/x)\nprint(int(4*(a+b+c)))"}, {"source_code": "from math import sqrt\na, b, c= map(int,raw_input().split())\np = int(round(sqrt(a*b*c)))\nprint 4*(p/a+p/b+p/c)"}, {"source_code": "import math\ns1,s2,s3=map(int,input().split())\nprint(math.floor(4*(math.sqrt(s1*s2//s3)+math.sqrt(s2*s3//s1)+math.sqrt(s1*s3//s2))))"}, {"source_code": "import math\n\n(a,b,c)=map(int,raw_input().split())\nx=int(math.sqrt((c*a)/b))\ny=int(math.sqrt((a*b)/c))\nz=int(math.sqrt((c*b)/a))\nprint (x+y+z)*4\n"}, {"source_code": "import math\nsqrt = math.sqrt\na,b,c = map(int,raw_input().split())\nprint 4*int(sqrt(a*b/c)+sqrt(a*c/b)+sqrt(b*c/a))"}, {"source_code": "import math\na,b,c = list(map(int,input().split()))\n\ns = math.sqrt( b*c/a )\ns += math.sqrt( a*b/c )\ns += math.sqrt( a*c/b )\nprint(int(s)*4)"}, {"source_code": "# Target - Expert on CF\n# Be Humblefool\n\nimport sys\n\n# inf = float(\"inf\")\n# sys.setrecursionlimit(100000)\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}\n# mod, MOD = 1000000007, 998244353\n# words = {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:'quarter',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen',20:'twenty',21:'twenty one',22:'twenty two',23:'twenty three',24:'twenty four',25:'twenty five',26:'twenty six',27:'twenty seven',28:'twenty eight',29:'twenty nine',30:'half'}\n# vow=['a','e','i','o','u']\n# dx,dy=[0,1,0,-1],[1,0,-1,0]\n\n# import random\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,pi,gcd\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\ndef all_factors(n):\n \"\"\"returns a sorted list of all distinct factors of n\"\"\"\n small = []\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//i))\n # large.append(n // i)\n return small\n\n\ns1,s2,s3 = get_ints()\nl = int(sqrt((s1*s3)//s2))\nb = int(sqrt((s1*s2)//s3))\nh = int(sqrt((s2*s3)//s1))\nprint(4*(l+b+h))"}, {"source_code": "from math import sqrt\nn = sorted(list(map(int,input().split())))\n\n\nx = sqrt(n[0]*n[1]/n[2])\ny = sqrt(n[1]*n[2]/n[0])\nz = sqrt(n[0]*n[2]/n[1])\n\nprint(int(4*y+4*z+4*x))"}, {"source_code": "from math import sqrt\ns1,s2,s3 = [int(si) for si in raw_input().split(\" \")]\ns12 = s1*s2\ns13 = s1*s3\ns23 = s2*s3\ns123 = 1*s12/s3\ns132 = 1*s13/s2\ns231 = 1*s23/s1\n# print s1,s2,s3\n# print s12,s13,s23\n# print s123,s132,s231\nss1 = sqrt(s123)\nss2 = sqrt(s132)\nss3 = sqrt(s231)\n# print ss1,ss2,ss3\nprint int(4*(ss1+ss2+ss3))"}, {"source_code": "a,b,c=map(int,input().split())\n\nabc=int((a*b*c)**0.5+0.5)\n\nprint(4*(abc//a+abc//b+abc//c))"}, {"source_code": "ab,bc,ca = map(int, raw_input().split())\nfrom math import sqrt\na = sqrt((ab*ca*1.0)/bc)\nb = sqrt((ab*bc*1.0)/ca)\nc = sqrt((bc*ca*1.0)/ab)\nprint int(4*(a+b+c))"}, {"source_code": "x,y,z=map(int,input().split())\nxx=(x*y/z)**0.5\nyy=(y*z/x)**0.5\nzz=(z*x/y)**0.5\nprint(int(xx+yy+zz)*4)\n"}, {"source_code": "import math\na,b,c=map(int,input().split())\ns1=math.sqrt((a*b)//c)\ns2=math.sqrt((b*c)//a)\ns3=math.sqrt((a*c)//b)\ns1=int(s1)\ns2=int(s2)\ns3=int(s3)\nprint(4*(s1+s2+s3))"}, {"source_code": "import math\nl=lambda:map(int,raw_input().split())\nab,bc,ac =l()\nb = int(math.sqrt((ab*bc)/ac))\na = ab/b\nc = bc/b\nprint (a+b+c)*4"}, {"source_code": "asas = raw_input()\narr = asas.split(\" \")\n\nb = ( (int(arr[0]) * int(arr[1])) / int(arr[2])) ** 0.5\na = int ( arr[0] ) / b\nc = int ( arr[1] ) / b\nprint int(( a + b + c ) * 4)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Aug 20 05:46:37 2020\n\n@author: Tanmay\n\"\"\"\nimport math\n\narr=list(map(int,input().strip().split()))\na=math.sqrt((arr[0]*arr[1])/arr[2])\nb=math.sqrt((arr[1]*arr[2])/arr[0])\nc=math.sqrt((arr[0]*arr[2])/arr[1])\nprint(int(4*(a+b+c)))\n"}, {"source_code": "s1,s2,s3 = map(int, input().split())\n#side of s1 and side of s2 == s3\n#height of s1 and s2 are the same\nfor i in range(1,min(s1,s2) + 1):\n otherS1 = s1/i\n otherS2 = s2/i\n if(otherS1 * otherS2 == s3):\n #matchFound\n print(int(4 * (i + otherS1 + otherS2)))"}, {"source_code": "import math\n\nx, y, z = map(int, raw_input().split())\np = int(math.sqrt(x*y*z) + 1e-6)\nprint 4 * (p/x + p/y + p/z)\n"}, {"source_code": "'''input\n1 1 1\n'''\nfrom math import sqrt\nx,y,z = map(int,raw_input().split())\na1 = int(sqrt(x*y/z))\na2 = int(sqrt(y*z/x))\na3 = int(sqrt(x*z/y))\nprint 4*(a1+a2+a3)"}, {"source_code": "import math\na1,a2,a3 = map(int,input().split())\na = math.sqrt((a1*a2)/a3)\nb = math.sqrt((a3*a2)/a1)\nc = math.sqrt((a1*a3)/a2)\nprint(int(a+b+c)*4)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Apr 30 23:19:30 2020\n\n@author: Administrator \n\"\"\"\nfrom math import sqrt\nab,bc,ca = map(int, input().split())\n\nprod = ab * bc * ca\n\nabc = int(sqrt(prod))\n\na = abc//bc\nb = ab//a\nc = ca//a\n\nprint(4*(a+b+c))\n\n"}, {"source_code": "from math import sqrt\na, b, c = map(int, input().split())\nx, y, z = sqrt(a * b / c), sqrt(a * c / b), sqrt(b * c / a)\nprint(int(x * 4 + y * 4 + z * 4))"}, {"source_code": "from math import sqrt\na,b,c = map(int,input().split())\nprint(int(4*(sqrt(a*b/c)+sqrt(a*c/b)+sqrt(c*b/a))))\n"}, {"source_code": "#programmer: darkKnight040\n#CSE_2K11\n#KUET\nimport math\n\ndef solvingFunc(ls_inp):\n area1 = ls_inp[0]\n area2 = ls_inp[1]\n area3 = ls_inp[2]\n l = int( math.sqrt( (area1 * area2)/area3 ) )\n a = int ( area1 / l )\n b = int( area2 / l )\n sum_of_edges = (l*4) + (a*4) + (b*4)\n return sum_of_edges\n\n\ninp = map(int, raw_input().split())\nls_inp = list(inp)\nflag = False\nif ( len(ls_inp) == 3 ):\n for eachNumber in ls_inp:\n if ( eachNumber > 0 and eachNumber <= 10**4 ):\n flag = True\n else:\n flag = False\n break\n\nif ( flag ):\n sum_of_edges = solvingFunc(ls_inp)\n print sum_of_edges"}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom 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 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\nlb, bh, hl = int_array();\nlset = set(); bset = set(); hset = set();\nlset1 = set(); bset1 = set(); hset1 = set();\n\nfor l in range(1, lb +1):\n if lb % l == 0:\n b = lb // l;\n if bh % b == 0:\n h = bh // b;\n if hl % h == 0:\n l_ = hl // h;\n if l_ == l:\n ans = 4*(l + b + h);\n print(ans); exit();"}, {"source_code": "from math import sqrt as fuck\nx,y,z=map(int,input().split())\na=int((fuck(x*y*z))//(x))\nb=int((fuck(x*y*z))//(y))\nc=int((fuck(x*y*z))//(z))\nprint(4*(a+b+c))"}, {"source_code": "import math\n \nk,l,m = map(int,raw_input().split())\nprint int(4*(math.sqrt(k*m/l) + math.sqrt(k*l/m) + math.sqrt(m*l/k)))"}, {"source_code": "from math import sqrt\na, b, c = map(int, raw_input().split())\nw = int(sqrt(a*b*c))\nprint 4*(w/a+w/b+w/c)"}, {"source_code": "import math\nA1,A2,A3 = map(int,input().split())\nb = math.sqrt(A1*A2*A3)\nprint(int(4*(b/A1 + b/A2 + b/A3)))"}, {"source_code": "from math import sqrt\nx, y, z = map(int, input().split())\nprint (int(4*(sqrt(y*z/x) + (sqrt(x*z/y)) + (sqrt(y*x/z)))))"}, {"source_code": "import sys\nx,y,z = map(int, input().split())\nfor a in range(1,10001):\n\tif x%a==0:\n\t\tb=x//a\n\t\tif y/b==z/a:\n\t\t\tprint(4*(a+b+y//b))\n\t\t\tsys.exit()\n"}, {"source_code": "def main():\n A = [int(i) for i in input().split(' ')]\n A.sort()\n \n a = b = c = 0\n for i in range(1, A[0] // 2 + 2):\n a = i\n if A[0] % a == 0 and A[1] % a == 0:\n b = A[0] // a\n c = A[1] // a\n if A[2] == b*c:\n break\n \n # print(a, b, c)\n print(4*(a+b+c))\n \n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "x, y, z = map(int,raw_input().split())\nc = int(((y*z)/x)**0.5)\nb = y/c\na = x/b\ns = a+b+c\nprint 4*s"}, {"source_code": "import math\ns1, s2, s3=map(int,input().split())\na = math.sqrt(s1 * s2 / s3)\nb = math.sqrt(s3 * s1 / s2)\nc = math.sqrt(s3 * s2 / s1)\nsum = a + b + c\nprint(int(4 * sum))\n"}, {"source_code": "import math as m\na,b,c=map(int,input().split())\nprint(4*(int(m.sqrt((a*c)/b)+int(m.sqrt((b*c)/a))+int(m.sqrt((b*a)/c)))))\n"}, {"source_code": "ab,bc,ca = list(map(int,input().split()))\na = ((ab*ca)//bc)**0.5\nb = ((ab*bc)//ca)**0.5\nc = ((bc*ca)//ab)**0.5\nprint(int(a+b+c)*4)\n\n"}, {"source_code": "(face_a,face_b,face_c) = map(int,raw_input().split())\nsqrt=(face_a*face_b*face_c)**0.5\n\nprint int(4 *(sqrt/face_a+sqrt/face_b+sqrt/face_c))"}, {"source_code": "import math\ndef get_res(ab, bc, ca):\n a = (ab*ca/bc)**0.5\n b = (ab*bc/ca)**0.5\n c = (bc*ca/ab)**0.5\n\n return 4*int(a+b+c)\n\n#N = int(raw_input()) \n\nab, bc, ca = [int(s) for s in raw_input().split(\" \")]\nresult = get_res(ab, bc, ca)\nprint \"{}\".format(result)\n"}, {"source_code": "from math import sqrt\na,b,c=map(int,input().split())\n\n\n\n\n\n\nprint(int(4*(sqrt(a*b/c)+sqrt(b*c/a) + sqrt(c*a/b))))"}, {"source_code": "# countx,county,countz = 0,0,0\n\n# for _ in range(int(input())):\nx,y,z = map(int,input().split())\nx,y,z = (x*y)/z,(y*z)/x,(x*z)/y\nx,y,z = int(x**0.5),int(y**0.5),int(z**0.5)\n\nsum = (x+y+z)*4\nprint(sum)\n"}, {"source_code": "ar = map(int, raw_input().split())\nar.sort()\nA, B, C = ar[0], ar[1], ar[2]\n\nfor a in xrange(1, 10005):\n\tb = A / a\n\tif a * (B / b) == C :\n\t\tprint a * 4 + b * 4 + 4 * C/a\n\t\texit()\n"}, {"source_code": "'''input\n1 1 1\n'''\ns1, s2, s3 = map(int, input().split())\na, b, c = (s1*s3)//s2, (s1*s2)//s3, (s2*s3)//s1\nprint(int(4*(a**0.5+b**0.5+c**0.5)))\n\n\n\n\n\n\n\n"}, {"source_code": "import math\ns1, s2, s3=map(int,input().split())\na = math.sqrt(s1 * s2 / s3)\nb = math.sqrt(s3 * s1 / s2)\nc = math.sqrt(s3 * s2 / s1)\nsum = a + b + c\nprint(int(4 * sum))\n"}, {"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 list(map(int, sys.stdin.readline().split()))\ndef LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]\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,c = LI()\n s = (a * b * c) ** 0.5\n r = s / a + s / b + s / c\n\n return round(r * 4)\n\nprint(main())\n\n\n"}, {"source_code": "import sys\n\ndef main():\n f = sys.stdin;\n ma, mb, mc = [int(n) for n in f.readline().split()]\n for a in range(1, ma+1):\n if not (ma % a) and not (mc % a) and (ma*mc / (a*a)) == mb:\n c = mc/a\n b = mb/c\n print 4*(a+b+c)\n break\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin, setrecursionlimit,stdout\nfrom collections import deque\nfrom math import log2, log, ceil,sqrt\ninput = stdin.readline\nsetrecursionlimit(int(2e5))\ndef getstr(): return input()[:-1]\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()))\njn = lambda x,l: x.join(map(str,l))\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 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\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\ny, n = \"YES\", \"NO\"\n# inputs=open('input.txt','r')\n \n# n=inputs.readlines()\n \ndef solve():\n ao,bo,co = getints()\n l = sqrt((co*ao)/bo)\n h = co/l\n b = ao/l\n print(int((l+b+h)*4))\n \nif __name__ == \"__main__\":\n # solve()\n # for t in range(getint()):\n # print(\"Case #{}: \".format(t + 1), end=\"\")\n # solve()\n #for _ in range(int(inputs.readline())):\n solve()\n\n # https://codeforces.com/contest/507/status/B/page/296?order=BY_PROGRAM_LENGTH_ASC"}, {"source_code": "def readarray(f): return map(f, raw_input().split())\ndef readint(): return int(raw_input())\ndef printlist(l): print ' '.join(map(str, l))\n\na, b, c = readarray(int)\n\nxx = (a*b)/c\nyy = (b*c)/a\nzz = (c*a)/b\n\ndx = xx**0.5\ndy = yy**0.5\ndz = zz**0.5\n\nx = int(dx-1)\ny = int(dy-1)\nz = int(dz-1)\n\nfor k in range(1, 3):\n if (x+k)*(x+k) == xx:\n x += 1\n if (y+k)*(y+k) == yy:\n y += 1\n if (z+k)*(z+k) == zz:\n z += 1\n\nprint 4*(x+y+z)\n"}, {"source_code": "a, b, c = [int(x) for x in input().split(' ')]\n\nfrom math import sqrt\n\nprint(4*int((sqrt(a*b/c) + sqrt(b*c/a) + sqrt(a*c/b))))"}, {"source_code": "# https://codeforces.com/problemset/problem/224/A\n\nimport sys\n#-----------------------------------------------------------------------------#\ntry:\n sys.stdin = open('inputs.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nexcept:\n pass\nfinally:\n input = sys.stdin.readline\n print = sys.stdout.write\n\n#-----------------------------------------------------------------------------#\nfrom math import sqrt\nab, bc, ca = map(int, input().split())\n\nprint(\"{0:.0f}\".format(\n 4 * sum(map(sqrt, (ab * bc // ca, ab * ca // bc, bc * ca // ab)))))\n"}, {"source_code": "#programmer: darkKnight040\n#CSE_2K11\n#KUET\nimport math\n\ndef solvingFunc(ls_inp):\n area1 = ls_inp[0]\n area2 = ls_inp[1]\n area3 = ls_inp[2]\n l = int( math.sqrt( (area1 * area2)/area3 ) )\n a = int ( area1 / l )\n b = int( area2 / l )\n sum_of_edges = (l*4) + (a*4) + (b*4)\n return sum_of_edges\n\n\ninp = map(int, raw_input().split())\nls_inp = list(inp)\nflag = False\nif ( len(ls_inp) == 3 ):\n for eachNumber in ls_inp:\n if ( eachNumber > 0 and eachNumber <= 10**4 ):\n flag = True\n else:\n flag = False\n break\n\nif ( flag ):\n sum_of_edges = solvingFunc(ls_inp)\n print sum_of_edges"}, {"source_code": "a,b,c = map(int,input().split())\n\nx = (b*c//a)**0.5\ny = (a*b//c)**0.5\nz = (a*c//b)**0.5\n\nprint(int(4*(x+y+z)))"}, {"source_code": "a1, a2, a3 = list(map(int, input().split()))\nb = ((a1*a2)/a3)**0.5\nl = (a3/a2)*b\nh = a2/b\nprint(4*int(l+b+h))\n"}, {"source_code": "# Lang: pypy3.6-v7.1.0-win32\\pypy3.exe\n# Problem Name: parallelepiped\n# Problem Serial No: 224\n# Problem Type: A\n# Problem Url: https://codeforces.com/problemset/problem/224/A \n# Solution Generated at: 2019-10-21 14:50:15.307917 UTC\n\ni = int\ncin = input\nle = len\ns = str\nfrom math import sqrt\n\nd1, d2, d3 = map(i, cin().split())\n\na, b, c = sqrt((d1 * d3) / d2), sqrt((d2 * d3) / d1), sqrt((d1 * d2) / d3)\n\nprint(i(4 * (a + b + c)))\n\n\n# Accepted"}, {"source_code": "import sys\n\ninputs = sys.stdin.readline().split()\na = int(inputs[0])\nb = int(inputs[1])\nc = int(inputs[2])\n\nr_square = 2*a + 2*b + 2*c + (a*b)/c + (b*c)/a + (a*c)/b\nprint 4 * int(r_square ** 0.5)\n"}, {"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\na=list(map(int,input().split()))\nc1=a[2]*a[1]/a[0]\nc=c1**0.5\nb=a[1]/c\na=a[0]/b\ns=int((a+b+c)*4)\nprint(s)\n"}, {"source_code": "import math\ndef get_res(ab, bc, ca):\n a = (ab*ca/bc)**0.5\n b = (ab*bc/ca)**0.5\n c = (bc*ca/ab)**0.5\n\n return 4*int(a+b+c)\n\n#N = int(raw_input()) \n\nab, bc, ca = [int(s) for s in raw_input().split(\" \")]\nresult = get_res(ab, bc, ca)\nprint \"{}\".format(result)\n"}, {"source_code": "import math as m\na, b, c = map(int,input().split())\nans = m.sqrt((a*b)//c) + m.sqrt((b*c)//a) + m.sqrt((a*c)//b) \nprint(int(4*ans)) "}, {"source_code": "## necessary imports\nimport sys\ninput = sys.stdin.readline\nfrom 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 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\nlb, bh, hl = int_array();\nlset = set(); bset = set(); hset = set();\nlset1 = set(); bset1 = set(); hset1 = set();\n\nfor l in range(1, lb +1):\n if lb % l == 0:\n b = lb // l;\n if bh % b == 0:\n h = bh // b;\n if hl % h == 0:\n l_ = hl // h;\n if l_ == l:\n ans = 4*(l + b + h);\n print(ans); exit();"}, {"source_code": "from math import sqrt\n\n\ndef main():\n l = list(map(int, input().split()))\n tot = 0.\n for i, a in enumerate(l):\n b, c = l[i - 1], l[i - 2]\n tot += sqrt(a * b / c)\n print('{:n}'.format(tot * 4))\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "# Target - Expert on CF\n# Be Humblefool\n\nimport sys\n\n# inf = float(\"inf\")\n# sys.setrecursionlimit(100000)\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}\n# mod, MOD = 1000000007, 998244353\n# words = {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:'quarter',16:'sixteen',17:'seventeen',18:'eighteen',19:'nineteen',20:'twenty',21:'twenty one',22:'twenty two',23:'twenty three',24:'twenty four',25:'twenty five',26:'twenty six',27:'twenty seven',28:'twenty eight',29:'twenty nine',30:'half'}\n# vow=['a','e','i','o','u']\n# dx,dy=[0,1,0,-1],[1,0,-1,0]\n\n# import random\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,pi,gcd\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\ndef all_factors(n):\n \"\"\"returns a sorted list of all distinct factors of n\"\"\"\n small = []\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//i))\n # large.append(n // i)\n return small\n\n\ns1,s2,s3 = get_ints()\nl = int(sqrt((s1*s3)//s2))\nb = int(sqrt((s1*s2)//s3))\nh = int(sqrt((s2*s3)//s1))\nprint(4*(l+b+h))"}, {"source_code": "from math import sqrt\nx, y, z = map(int, input().split())\nprint (int(4*(sqrt(y*z/x) + (sqrt(x*z/y)) + (sqrt(y*x/z)))))"}, {"source_code": "import math as m\na, b, c = map(int,input().split())\nans = m.sqrt((a*b)//c) + m.sqrt((b*c)//a) + m.sqrt((a*c)//b) \nprint(int(4*ans)) "}, {"source_code": "a=[int(x) for x in input().split()]\n#d*b=a[0]\n#b*c=a[1]\n#d*c=a[2]\n#b=a[0]/d\n#c=a[2]/d\n#a[0]*a[2]/d**2=a[1]\nd=(a[0]*a[2]/a[1])**0.5\nb=a[0]/d\nc=a[2]/d\nprint(int(4*d + 4*b + 4*c))\n"}, {"source_code": "def Sides():\n inputs = raw_input().split()\n a = int(inputs[0])\n b = int(inputs[1])\n c = int(inputs[2])\n\n x = (a*c/b)**0.5\n y = (b*c/a)**0.5\n z = (a*b/c)**0.5\n\n print int(4*(x+y+z))\n\nSides()"}, {"source_code": "from math import sqrt\nx, y, z = map(int, input().split())\nprint (int(4*(sqrt(y*z/x)) + 4*(sqrt(x*z/y)) + 4*(sqrt(y*x/z))))"}, {"source_code": "a,b,c = list(map(int,input().split()))\nimport math\nc = math.sqrt((c*b)/a)\nb = b/c\na = a/b\nprint(int(sum([4*a,4*b,4*c])))"}, {"source_code": "from math import sqrt\na, b, c = map(int, input().split())\ny = sqrt(a * c / b)\nx, z = a / y, c / y\nprint(4 * int(x + y + z))\n"}, {"source_code": "a=[int(x) for x in input().split()]\n#d*b=a[0]\n#b*c=a[1]\n#d*c=a[2]\n#b=a[0]/d\n#c=a[2]/d\n#a[0]*a[2]/d**2=a[1]\nd=(a[0]*a[2]/a[1])**0.5\nb=a[0]/d\nc=a[2]/d\nprint(int(4*d + 4*b + 4*c))\n"}, {"source_code": "import math\nf1,f2,f3 = map(int, raw_input().split())\na = int(math.sqrt(f1*f2/f3))\nprint 4*(a + f1/a + f2/a)"}, {"source_code": "x,y,z = map(int,input().split())\n\nt1 = (x*z)/y\nt2 = (x*y)/z\nt3 = (z*y)/x\n\nt4 = t1**0.5\nt5 = t2**0.5\nt6 = t3**0.5\n\nprint(int(4*(t4 + t5+ t6)))"}, {"source_code": "# benzene_ <>\na,b,c=map(int,input().split())\nx=(a*b*c)**0.5\nprint(int((x/a+x/b+x/c)*4))"}, {"source_code": "x,y,z=map(int,input().split())\na2=(x*z)/y\nb2=(x*y)/z\nc2=(y*z)/x\na_b_c_2=a2+b2+c2+2*(x+y+z)\na_b_c=a_b_c_2**(0.5)\nprint(int(4*a_b_c))"}, {"source_code": "# with open(\"input.txt\",'r') as f:\n# \tt = int(f.readline().rstrip())\n# \t# n = int(f.readline().rstrip())\n\t# n ,a,b = int(f.readline().rstrip().split())\n# \t# arr = list(map(int,f.readline().rstrip().split()))\n\n\n\n\n\nimport math \ndef main(arr):\n\ta1 = math.sqrt((arr[0]*arr[1])//arr[2])\n\ta2 = math.sqrt((arr[0]*arr[2])//arr[1])\n\ta3 = math.sqrt((arr[1]*arr[2])//arr[0])\n\tans = (a1*4) + (a2*4)+(a3*4)\n\tprint(int(ans))\n\narr = list(map(int,input().split()))\n# arr.sort()\n# arr = [50,10,20]\nmain(arr)"}, {"source_code": "from math import sqrt\n\n__author__ = 'runekri3'\n\ni = raw_input()\nab, bc, ac = [int(x) for x in i.split(\" \")]\na = sqrt(ab * ac / bc)\nb = sqrt(ab * bc / ac)\nc = sqrt(bc * ac / ab)\nprint int(4 * (a + b + c))"}, {"source_code": "import math\n\n\ndef findEdges(s1, s2, s3):\n a = math.sqrt(s1 * s2 / s3)\n b = math.sqrt(s3 * s1 / s2)\n c = math.sqrt(s3 * s2 / s1)\n\n sum = a + b + c\n\n return 4 * sum\n\n\ns1, s2, s3 = map(int, input().split())\nprint(int(findEdges(s1, s2, s3)))\n"}, {"source_code": "import math\nA1,A2,A3=map(int,input().split())\na=int(math.sqrt((A1*A2)/A3))\nb=int(math.sqrt((A2*A3)/A1))\nc=int(math.sqrt((A1*A3)/A2))\nprint((a+b+c)*4)"}, {"source_code": "# https://codeforces.com/problemset/problem/224/A\n\nimport sys\n#-----------------------------------------------------------------------------#\ntry:\n sys.stdin = open('inputs.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nexcept:\n pass\nfinally:\n input = sys.stdin.readline\n print = sys.stdout.write\n\n#-----------------------------------------------------------------------------#\nfrom math import sqrt\nab, bc, ca = map(int, input().split())\n\nprint(\"{0:.0f}\".format(\n 4 * sum(map(sqrt, (ab * bc // ca, ab * ca // bc, bc * ca // ab)))))\n"}, {"source_code": "import math\nline = list(map(int,input().split()))\nab = line[0]\nbc = line[1]\nac = line[2]\na = math.sqrt((ab * ac) / bc)\nb = math.sqrt((ab * bc) / ac)\nc = math.sqrt((bc * ac) / ab)\nprint(4 * int(a + b + c))"}, {"source_code": "import math\na,b,c = map(int, raw_input().split(\" \"))\n# a = x.y, y = a/x\n# b = y.z, y = b/z, a/x = b/z, x = a.z/b\n# c = x.z, c = a.z,z/b, z^2 = c*b/a\nz = math.sqrt(c*b/a)\ny = b/z\nx = a/y\nprint int((x+y+z)*4)"}, {"source_code": "import math\nlb, bh, hl = [int(x) for x in input().split()]\nlbh = int(math.sqrt(lb * bh * hl))\nl = lbh // bh\nb = lbh // hl\nh = lbh // lb\nsum = 4 * (l + b + h)\nprint(sum)"}, {"source_code": "import math\ndef get_res(ab, bc, ca):\n a = (ab*ca/bc)**0.5\n b = (ab*bc/ca)**0.5\n c = (bc*ca/ab)**0.5\n\n return 4*int(a+b+c)\n\n#N = int(raw_input()) \n\nab, bc, ca = [int(s) for s in raw_input().split(\" \")]\nresult = get_res(ab, bc, ca)\nprint \"{}\".format(result)\n"}, {"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[61]:\n\n\n# 20 10 50\n# 9 4 36\n# 1022 584 112\ndef cf(a, b):\n commons = []\n for i in range(1, min(a, b) + 1):\n if a%i == 0 and b%i == 0:\n commons.append(i)\n return commons\n\n\n# In[82]:\n\n\nthree_areas = list(map(int, input().split()))\n\n\n# In[83]:\n\n\na_x, a_y, a_z = three_areas[0], three_areas[1], three_areas[2]\ncomp_1 = cf(a_x ,a_y)\ncomp_2 = cf(a_x, a_z)\n\n\n# In[88]:\n\n\npotential_y_z = []\nfor i in comp_1:\n for j in comp_2:\n if i*j == a_x:\n potential_y_z.append([i, j])\n \n\n\n# In[90]:\n\n\nfor edge_y_z in potential_y_z:\n edge_y = edge_y_z[0]\n edge_z = edge_y_z[1]\n \n if int(a_z/edge_y) == int(a_y/edge_z):\n edge_x = int(a_z/edge_y)\n break\n elif int(a_z/edge_z) == int(a_y/edge_y):\n edge_x = int(a_z/edge_z)\n break\n\n\n# In[93]:\n\n\n# print(comp_1, comp_2)\n# print(a_x, a_y, a_z)\n# print(edge_x, edge_y, edge_z)\n\n\n# In[92]:\n\n\ncircum = (edge_x + edge_y + edge_z) * 4\nprint(circum)\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "x,y,z=map(int, raw_input().split(' '))\nv=int((x*y*z)**0.5)\nprint 4*(v/x+v/y+v/z)"}, {"source_code": "from math import sqrt\ns1,s2,s3 = [int(si) for si in raw_input().split(\" \")]\ns12 = s1*s2\ns13 = s1*s3\ns23 = s2*s3\ns123 = 1*s12/s3\ns132 = 1*s13/s2\ns231 = 1*s23/s1\n# print s1,s2,s3\n# print s12,s13,s23\n# print s123,s132,s231\nss1 = sqrt(s123)\nss2 = sqrt(s132)\nss3 = sqrt(s231)\n# print ss1,ss2,ss3\nprint int(4*(ss1+ss2+ss3))"}], "negative_code": [{"source_code": "import math\na,b,c= map(int, input().split())\ns1=a\ns2=b\ns3=c\nx=math.sqrt((s1*s3)/s2)\ny=math.sqrt((s1*s2)/s3)\nz=math.sqrt((s2*s3)/s1)\nsum = x+y+z\nprint(4*sum)\n\n\n# a,b,c=map(int,input().split())\n# xyz=(a*b*c)**0.5\n# z=xyz/a\n# y=xyz/c\n# x=xyz/b\n# vv=0\n# print(int(4*(x+y+z)))\n"}, {"source_code": "import math\nline = list(map(int,input().split()))\nab = line[0]\nbc = line[1]\nac = line[2]\na = math.sqrt((ab * ac) / bc)\nb = math.sqrt((ab * bc) / ac)\nc = math.sqrt((bc * ac) / ab)\nprint(3 * int(a + b + c))"}, {"source_code": "def h(a,b):\n ans = 0\n for i in range(1,min(a,b)+1):\n if(a%i==0 and b%i==0):\n ans = i\n # print(i)\n return ans\na,b,c = map(int,input().split())\ns = []\nf = h(a,b)\nse = h(a,c)\nt = b//se\ns.append(f)\ns.append(se)\ns.append(t)\n# s.append(a//f)\nprint(sum(s)*4)"}, {"source_code": "a,b,c=map(int,input().split())\nprint(round( ((a*b/c)**0.5)*4 + ((c*b/a)**0.5)*4 +((a*c/b)**0.5)*4 , 0) )"}, {"source_code": "a,b,c=map(int,input().split())\ns1=a*b\ns2=b*c\ns3=c*a\na=((s1*s3)//s2)**0.5\nb=((s1*s2)//s3)**0.5\nc=((s2*s3)//s1)**0.5\nprint(int(4*(a+b+c)))"}, {"source_code": "x, y, z = map(int, input().split())\nnums = [i for i in range(2, 10001)]\ni = 0\nwhile i < len(nums):\n e = nums[i]\n for n in nums:\n if n % e == 0 and n != e:\n nums.remove(n)\n i += 1\n\nx += y\n\nfor i in range(-1, -len(nums), -1):\n if x % nums[i] == 0:\n z = nums[i]\nprint(4*(z + x//z))\n"}, {"source_code": "a,b,c=map(int,input().split())\nb=int(((a*b)/c)**0.5)\na/=b\nc/=a\nprint(4*(a+b+c))\n"}, {"source_code": "a,b,c=map(int,input().split())\nln,br,ht=0,0,0\nfor i in range(1,a//2+2):\n\tln=i\n\tbr=a/ln\n\tht=b/ln\n\tif br*ht==c:\n\t\tbreak\nans=(4*ln+4*br+4*ht)\nif ans.is_integer():\n\tprint(int(ans))\nelse:\n\tprint(ans)\n"}, {"source_code": "from math import sqrt as fuck\nx,y,z=map(int,input().split())\na=int((fuck(x*y*z))//(x))\nb=int((fuck(x*y*z))//(y))\nc=int((fuck(x*y*z))//(y))\nprint(4*(a+b+c))"}, {"source_code": "from math import sqrt, ceil\n\ns1, s2, s3 = map(int, input().split())\na = sqrt(s1 * s2 // s3)\nb = sqrt(s3 * s1 // s2)\nc = sqrt(s3 * s2 // s1)\nprint((a+b+c) * 4)"}, {"source_code": "import math\na, b, c=map(int, input().split())\nlcm=abs(a*b)//math.gcd(a, b)\nx=lcm//b\ny=lcm//a\nprint(2*(x+a//x)+4*(y+b//y))"}, {"source_code": "a,b,c=map(int,input().split())\ns1=a*b\ns2=b*c\ns3=c*a\nprint(a,b,c)\na=((s1*s3)//s2)**0.5\nb=((s1*s2)//s3)**0.5\nc=((s2*s3)//s1)**0.5\nprint(a,b,c)\nprint(int(4*(a+b+c)))"}, {"source_code": "x, y, z = map(int, input().split())\nab = set()\nac = set()\nbc = set()\nfor e in range(1, 10001):\n if (x+y)%e == 0 and x%e==0 and y%e==0:\n ab.add(e + (x+y)//e)\n if (z+y)%e == 0 and z%e==0 and y%e==0:\n ac.add(e + (z+y)//e)\n if (x+z)%e == 0 and x%e==0 and z%e==0:\n bc.add(e + (x+z)//e)\n if e>x+y and e>y+z and e>x+z:\n break\n\nprint(4*tuple(ab & ac & bc)[0])\n"}, {"source_code": "import sys\nimport math\n\nn = [int(x) for x in (sys.stdin.readline()).split()]\n\nres = 0\nfor i in range(3):\n k = math.sqrt(n[i])\n if(k % 1 == 0):\n res += int(k) * 8\n if(i + 1 < 3):\n res += int(n[i + 1] / k * 4)\n elif(i - 1 >= 0):\n res = int(n[i - 1] / k * 4)\n \n break\n \nprint(res)"}, {"source_code": "a, b, c = input().strip().split(' ')\na, b, c = [int(a), int(b), int(c)]\n\nflag = False\nl = 0\nw = 0\nh = 0\nfor l in range(0,101):\n for w in range(0,101):\n for h in range(0,101):\n a1 = l * w\n a2 = w * h\n a3 = h * l\n if a1 == a and (a2 == b and a3 == c or a2 == c and a3 == b):\n flag = True\n break\n elif a1 == b and (a2 == a and a3 == c or a2 == c and a3 == a):\n flag = True\n break\n elif a1 == c and (a2 == b and a3 == a or a2 == a and a3 == b):\n flag = True\n break\n if flag:\n break\n if flag:\n break\n\nprint(4 * (l + w + h))"}, {"source_code": "import sys\nfrom fractions import gcd\n\nnumbers = [int(x) for x in sys.stdin.readline().split()]\n\ngcd1 = gcd(numbers[0], numbers[1])\ngcd2 = gcd(numbers[0], numbers[2])\ngcd3 = gcd(numbers[1], numbers[2])\n\nminimizer = gcd(gcd(gcd1, gcd2), gcd3)\n\nif gcd1 / minimizer != 1 and gcd1 / minimizer != 0:\n gcd1 = gcd1/minimizer\nif gcd2 / minimizer != 1 and gcd1 / minimizer != 0:\n gcd2 = gcd2/minimizer\nif gcd3 / minimizer != 1 and gcd1 / minimizer != 0:\n gcd3 = gcd3/minimizer\n\nprint 4*gcd1 + 4*gcd2 + 4* gcd3\n"}, {"source_code": "# with open(\"input.txt\",'r') as f:\n# \tt = int(f.readline().rstrip())\n# \t# n = int(f.readline().rstrip())\n\t# n ,a,b = int(f.readline().rstrip().split())\n# \t# arr = list(map(int,f.readline().rstrip().split()))\n\n\n\ndef gcd(a,b):\n\tif b==0:\n\t\treturn a \n\telse:\n\t\treturn gcd(b,a%b)\n\n\ndef main(x,y,z):\n# x,y,z = map(int,input().split())\n\ta1 = gcd(x,y)\n\ta2 = gcd(x,z)\n\ta3 = y//a1\n\tans = (a1*4) + (a2*4)+(a3*4)\n\tprint(ans)\n\nx,y,z = map(int,input().split())\nmain(x,y,z)"}, {"source_code": "a,b,c=map(int,input().split())\nv=(a*b*c)**0.5\ns=(v//a)+(v//b)+(v//c)\nprint(4*s)\n"}, {"source_code": "a,b,c = map(int,input().split())\ndef GCD(a,b):\n\twhile True:\n\t\tif b == 0:\n\t\t\tbreak\n\t\tif a>=b:\n\t\t\tk = a%b\n\t\t\ta = b\n\t\t\tb = k\n\t\telse:\n\t\t\ta,b = b,a\n\treturn a\nprint(4*(a//GCD(a,b)+GCD(a,b)+b//GCD(a,b)))"}, {"source_code": "a,b,c=map(int,input().split())\n\nm=((a*c)/b)**0.5\nn=((b*a)/c)**0.5\np=((c*b)/a)**0.5\nans=4*(m+p+n)\nprint(ans)"}, {"source_code": "import math\ns1, s2, s3 = map(int, raw_input().split())\ndef find():\n for a in xrange(1, int(math.sqrt(s1))+1):\n for b in xrange(s1//a, s2+1):\n for c in xrange(s2//b, s3+1):\n if s1 == a*b and s2 == b*c and s3 == a*c:\n return a, b, c\n return None\na, b, c = find()\nprint a, b, c"}, {"source_code": "#!/usr/bin/env python\nfrom math import sqrt\nA,B,C = map(int,raw_input().split())\na, b, c = sqrt(A*C/B), sqrt(A*B/C), sqrt(B*C/A)\nprint 4*a+4*b+4*c\n"}, {"source_code": "x, y, z = map(int, input().split())\nnums = [i for i in range(2, 10001)]\ni = 0\nwhile i < len(nums):\n e = nums[i]\n for n in nums:\n if n % e == 0 and n != e:\n nums.remove(n)\n i += 1\n\nloy = []\nfor e in nums:\n if (x+y)%e == 0 and x%e==0 and y%e==0:\n z = e\n loy += [e + (x+y)//e]\n if e>x+y:\n break\na = [x,y,z]\ndefault = min(a)\na.remove(default)\ndefault += min(a) + 1\n\nprint(4*max(loy, default=default))\n"}, {"source_code": "import math\na,b,c=map(int,input().split())\nprint(4*sum([math.sqrt(a*b/c),math.sqrt(b*c/a),math.sqrt(c*a/b)]))\n"}, {"source_code": "import math\nm,n,n1=map(int,input().split())\nprint(int(math.sqrt(m)*8+n/math.sqrt(m)*4))\n\n\n"}, {"source_code": "from sys import stdin, setrecursionlimit,stdout\nfrom collections import deque\nfrom math import log2, log, ceil,sqrt\ninput = stdin.readline\nsetrecursionlimit(int(2e5))\ndef getstr(): return input()[:-1]\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()))\njn = lambda x,l: x.join(map(str,l))\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 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\n \n#defining a couple constants\nMOD = int(1e9)+7;\nCMOD = 998244353;\nINF = float('inf'); NINF = -float('inf');\ny, n = \"YES\", \"NO\"\n# inputs=open('input.txt','r')\n \n# n=inputs.readlines()\n \ndef solve():\n ao,bo,co = getints()\n l = sqrt((co*ao)/bo)\n h = co/l\n b = ao/l\n print((l+b+h)*4)\n \nif __name__ == \"__main__\":\n # solve()\n # for t in range(getint()):\n # print(\"Case #{}: \".format(t + 1), end=\"\")\n # solve()\n #for _ in range(int(inputs.readline())):\n solve()\n\n # https://codeforces.com/contest/507/status/B/page/296?order=BY_PROGRAM_LENGTH_ASC"}, {"source_code": "from math import sqrt\ndef k(a,b,c):\n for i in range(min(a,b),0,-1):\n if a%i==b%i==c%i==0:\n return i\na,b,c=map(int,input().split())\nd=k(a,b,c)\nif a==b==c:g=(sqrt(a)*12)\nelif a!=b and a!=c and c!=b: g=(4*(a//d+b//d+c//d))\nelse:\n if min(a,b,c)==b or min(a,b,c)==c:g=((sqrt(max(a,b,c))*2+min(a,b,c)/(sqrt(max(a,b,c))))*4)\n else:g=((sqrt(min(a,b,c))*2+max(a,b,c)/(sqrt(min(a,b,c))))*4) \nprint(int(g))\n"}, {"source_code": "import math\na,b,c=map(int,input().split())\naa=int(math.sqrt(a))\nbb=int(math.sqrt(b))\ncc=int(math.sqrt(c))\ns=0\nif(aa**2==a):\n # print(aa,b//aa,c//aa)\n s+=aa*8+(b//aa)*4\n\nelif(bb**2==b):\n # print(bb,a//bb,c//bb)\n s+=bb*8+(a//bb)*4\nelif(cc**2==c):\n # print(cc,a//cc,b//cc)\n s+=cc*8+(a//cc)*4\nprint(s)"}, {"source_code": "## let the sides a,b and c\nimport math\nsides = list(map(int,input().split()))\nb = math.sqrt((sides[0]*sides[1])/sides[2])\na = sides[0]/b\nc = sides[2]/b\nres = int(4*a + 4*b + 4*c)\nprint(res)"}, {"source_code": "a,b,c = map(int,input().split())\nimport math as m\nz = m.sqrt((a*c)/b)\nx = a//z\ny = c//z\nprint(4*(x+y+z))\n"}, {"source_code": "'''input\n1 1 1\n'''\ndef gcd(x, y):\n\twhile y != 0:\n\t\tx, y = y, x % y\n\treturn x\na, b, c = map(int, input().split())\nl = a * b // gcd(a, b)\nl = l * c // gcd(l, c)\nprint((l // a + l // b + l // c) * 4) \n\n\n\n\n\n\n"}, {"source_code": "# Lang: pypy3.6-v7.1.0-win32\\pypy3.exe\n# Problem Name: parallelepiped\n# Problem Serial No: 224\n# Problem Type: A\n# Problem Url: https://codeforces.com/problemset/problem/224/A \n# Solution Generated at: 2019-10-21 14:50:15.307917 UTC\n\ni = int\ncin = input\nle = len\ns = str\n\n\narr = list(map(i, cin().split()))\n\narea = sum(arr) * 2\n\nfor a in range(1,1001):\n for b in range(1, 1001):\n for c in range(1, 1001):\n if (2 * a * b + 2 * b * c + 2 * c * a) == area:\n print(a * 4 + b * 4 + c * 4)\n exit()\n\n\n\n# Accepted"}, {"source_code": "from math import sqrt, ceil\n\ns1, s2, s3 = map(int, input().split())\na = ceil(sqrt(s1 * s2 // s3))\nb = ceil(sqrt(s3 * s1 // s2))\nc = ceil(sqrt(s3 * s2 // s3))\nprint((a+b+c) * 4)"}, {"source_code": "ab, bc, ac = map(int, input().split())\nfor a in range(1, ab + 1):\n if ab % a == 0:\n b = ab // a\n if ac % a == 0 and bc % b == 0:\n c = bc // b\n break\nprint(4 * (a + b + c))"}, {"source_code": "def main():\n A = [int(i) for i in input().split(' ')]\n \n a = b = c = 0\n for i in range(1, A[0] // 2 + 2):\n a = i\n if A[0] % a == 0 and A[1] % a == 0:\n b = A[0] // a\n c = A[1] // a\n if A[2] % b == 0 and A[2] % c == 0:\n break\n \n print(4*(a+b+c))\n \n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "import math\na,b,c=map(int,input().split())\ns1= math.sqrt((a*b)//c)\ns2= math.sqrt((c*b)//a)\ns3= math.sqrt((a*c)//b)\nprint(4*(a+b+c))"}, {"source_code": "a,b,c = map(int,raw_input().split())\n#a = (input()).spl\n#b = float(input())\n#c = float(input())\nx = ((a/b)*c)**0.5\ny = (b/c*a)**0.5\nz = (c/a*b)**0.5\nprint 4*(x+y+z)\n"}, {"source_code": "import math\n\nA, B, C = map(int, input().split())\n\ny = math.sqrt((A*B)/C)\n\nx = A/y\nz = C/y\nprint(int(x*4 + y*4 + z*4))"}, {"source_code": "'''input\n152 108 4104\n'''\ndef gcd(x, y):\n\twhile y != 0:\n\t\tx, y = y, x % y\n\treturn x\na, b, c = map(int, input().split())\nl = a * b // gcd(a, b)\nl = l * c // gcd(l, c)\nprint((l // a + l // b + l // c) * 4 if l != max([a,b,c]) else (l // a + l // b + l // c) * 8) \n\n\n\n\n\n\n"}, {"source_code": "from math import sqrt\nn = sorted(list(map(int,input().split())))\n\nif all([min(n) == i for i in n]) :\n print(int(12*sqrt(n[0])))\nelse :\n e = int(sqrt(n[0]))\n p = n[1]//e\n print(e*8+p*4)\n"}, {"source_code": "'''input\n4 6 6\n'''\ndef gcd(x, y):\n\twhile y != 0:\n\t\tx, y = y, x % y\n\treturn x\na, b, c = map(int, input().split())\nl = a * b // gcd(a, b)\nl = l * c // gcd(l, c)\nx = (l // a + l // b + l // c)\nif len(set([a, b, c])) < 3:\n\tprint(4*x)\nelse:\n\tprint(8*x)\n\n\n\n\n\n\n\n"}, {"source_code": "a,b,c=map(int,input().split())\nx=(a*c)//b\ny=(a*b)//c\nz=(b*c)//a\nprint(4*(x+y+z))"}, {"source_code": "import math\na, b, c=map(int, input().split())\nlcm1=abs(a*b)//math.gcd(a, b)\nlcm2=abs(b*c)//math.gcd(b, c)\nlcm=abs(lcm1*lcm2)//math.gcd(lcm1, lcm2)\nx=lcm//a\ny=lcm//b\nz=lcm//c\nprint(4*(x+y+z))"}, {"source_code": "import math\na,b,c=map(int,input().split())\naa=int(math.sqrt(a))\nbb=int(math.sqrt(b))\ncc=int(math.sqrt(c))\ns=0\nif(aa**2==a):\n # print(aa,b//aa,c//aa)\n s+=aa*8+(b//aa)*4\n\nelif(bb**2==b):\n # print(bb,a//bb,c//bb)\n s+=bb*8+(a//bb)*4\nelif(cc**2==c):\n # print(cc,a//cc,b//cc)\n s+=cc*8+(a//cc)*4\nprint(s)"}, {"source_code": "import math\na,b,c=map(int,input().split())\ns1= math.sqrt((a*b)//c)\ns2= math.sqrt((c*b)//a)\ns3= math.sqrt((a*c)//b)\nprint(4*(s1+s2+s3))"}, {"source_code": "a,b,c=map(int,input().split())\ns1=a*b\ns2=b*c\ns3=c*a\na=((s1*s3)//s2)**0.5\nb=((s1*s2)//s3)**0.5\nc=((s2*s3)//s1)**0.5\nprint(int(4*(a+b+c)))"}, {"source_code": "import math\ndef printDivisors(n) : \n i = 1\n factors=set()\n while i <= math.sqrt(n): \n if (n % i == 0) : \n if (n / i == i) : \n factors.add(i) \n else :\n factors.add(i)\n factors.add(n//i)\n i = i + 1\n return factors\n \ndef isPerfectSquare(n) : \n i = 1\n while(i * i<= n): \n if ((n % i == 0) and (n / i == i)): \n return True\n i = i + 1\n return False\n \narr=list(map(int,input().split()))\narr.sort()\nif(arr[0]==arr[1] and arr[1]==arr[2] and arr[0]==arr[2] and isPerfectSquare(arr[0])):\n side=(int(math.sqrt(arr[0])))\n print(side*12)\nelse:\n factors_1=printDivisors(arr[0])\n factors_2=printDivisors(arr[2])\n comman=list(factors_1&factors_2)\n side1=max(comman)\n side2=arr[0]//side1\n side3=arr[2]//side1\n print(4*(side1+side2+side3))"}, {"source_code": "def div(num):\n div=[]\n for i in range (1,num+1):\n if num%i==0:\n div.append(i)\n return div\ndef cdiv(n1,n2):\n cd=[]\n for i in range(max(n1,n2)):\n if i in div(n1) and i in div(n2) and i not in cd:\n cd.append(i)\n return cd\nwh,lh,lw=map(int,input().split())\nph=cdiv(wh,lh)\npw=cdiv(wh,lw)\npl=cdiv(lh,lw)\nl , w ,h =1,1,1\nwhile 1:\n if wh==w*h and lh==l*h and lw==l*w:\n break\n for i in ph:\n for j in pw:\n for k in pl:\n if wh==i*j and lh==k*i and lw==k*j:\n h=i\n w=j\n l=k\n break\n if wh==w*h and lh==l*h and lw==l*w:\n break\n if wh==w*h and lh==l*h and lw==l*w:\n break\n \n print(h,w,l)\nprint((l+h+w)*4)\n"}, {"source_code": "def k(a,b,c):\n for i in range(min(a,b),0,-1):\n if a%i==b%i==0:\n for j in range(min(a,c),1,-1):\n if a%j==c%j==0 and i*j==a:\n return i\n return 1\na,b,c=map(int,input().split())\nprint(4*(k(a,b,c)+k(b,c,a)+k(c,a,b)))"}, {"source_code": "a,b,c=map(int,input().split())\nln,br,ht=0,0,0\nfor i in range(1,a//2+2):\n\tln=i\n\tbr=a//ln\n\tht=b//ln\n\tif br*ht==c:\n\t\tbreak\nprint(4*ln+4*br+4*ht)\n"}, {"source_code": "arr = list(map(int,input().split()))\nfor i in arr:\n a = i**0.5\n if a == int(a):\n break\na = int(a)\nb = (sum(arr)-(a**2))//(2*a)\nprint((8*a)+(b*4))\n"}, {"source_code": "from math import sqrt\n\nx, y, z = input().split()\nx = int(x)\ny = int(y)\nz = int(z)\n\nb = int(sqrt((x * y)/z))\nc = int(y/b)\na = int(x/b)\n\nans = a *4 + b * 4 + c * 4\n\n \n"}, {"source_code": "a, b, c = map(int,input().split())\nif(a == b == c or a != b != c):\n print((a+b+c)*4)\nelif(b == c):\n print((a*4)+(c//2)*4)\nelif(a == b):\n print((c*4)+(b//2)*4) \nelif(a == c):\n print((b*4)+(c//2)*4) "}, {"source_code": "ar = [int(n) for n in input().split()]\nsuma = 0\n\nif(ar[0] == ar[1] == ar[2]):\n x = (ar[0])**(1/3)\n suma = (12*x)\n \nelse:\n z = ((ar[2]*ar[1])/(ar[0]))**(1/2)\n y = z*(ar[0]/ar[1])\n x = z*(ar[0]/ar[2])\n suma = 4*(x + y + z) \n \nprint(int(suma))\n"}, {"source_code": "a,b,c=map(int,input().split())\ns1=a*b\ns2=b*c\ns3=c*a\na=((s1*s3)//s2)**0.5\nb=((s1*s2)//s3)**0.5\nc=((s2*s3)//s1)**0.5\nprint(int(4*(a+b+c)))"}, {"source_code": "import math\na, b, c=map(int, input().split())\nlcm1=abs(a*b)//math.gcd(a, b)\nlcm2=abs(b*c)//math.gcd(b, c)\nlcm=abs(lcm1*lcm2)//math.gcd(lcm1, lcm2)\nx=lcm//a\ny=lcm//b\nz=lcm//c\nprint(4*(x+y+z))"}, {"source_code": "import math\nline = list(map(int,input().split()))\nab = line[0]\nbc = line[1]\nac = line[2]\na = math.sqrt((ab * ac) / bc)\nb = math.sqrt((ab * bc) / ac)\nc = math.sqrt((bc * ac) / ab)\nprint(3 * int(a + b + c))"}, {"source_code": "import sys\nfrom fractions import gcd\nimport math\nnumbers = [int(x) for x in sys.stdin.readline().split()]\n\nif len(set(numbers)) == 1:\n print int(12*math.sqrt(numbers[0]))\nelif len(set(numbers)) == 2:\n if numbers[0] != numbers[1]:\n tgcd = gcd(numbers[0], numbers[1])\n if tgcd ** 2 == numbers[0]:\n quo = numbers[1] / tgcd\n elif tgcd ** 2 == numbers[1]:\n quo = numbers[0]/tgcd\n print int(quo * 4 + tgcd*8)\n else:\n tgcd = gcd(numbers[1], numbers[2])\n if tgcd ** 2 == numbers[1]:\n quo = numbers[2] / tgcd\n elif tgcd ** 2 == numbers[1]:\n quo = numbers[2]/tgcd\n print int(quo * 4 + tgcd*8)\n\nelse:\n gcd1 = gcd(numbers[0], numbers[1])\n gcd2 = gcd(numbers[1], numbers[2])\n gcd3 = gcd(numbers[2], numbers[0])\n print int(gcd1 * 4 + gcd2 * 4 + gcd3 * 4)\n"}, {"source_code": "import math\na,b,c= map(int,input().split())\ndiv = []\nfor i in range(1,a):\n if(a%i==0):\n div.append(i)\n\nfor i in div:\n x= a//i\n if(b%i==0 and c//x == b//i):\n print(4*(i+a//i +b//i))\n break\n\n"}, {"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[71]:\n\n\ndef cf(a, b):\n commons = []\n for i in range(1, min(a, b) + 1):\n if a%i == 0 and b%i == 0:\n commons.append(i)\n return commons\n\n\n# In[93]:\n\n\nthree_areas = list(map(int, input().split()))\n\n\n# In[94]:\n\n\na_x, a_y, a_z = three_areas[0], three_areas[1], three_areas[2]\ncomp_1 = cf(a_x ,a_y)\ncomp_2 = cf(a_x, a_z)\n\n\n# In[95]:\n\n\nfor i in comp_1:\n for j in comp_2:\n if i*j == a_x:\n edge_x = i\n edge_y = j\n break\n\nif a_y/edge_x == a_z/edge_x:\n edge_z = int(a_y/edge_x)\nelse:\n edge_z = 1\n\n\n# In[96]:\n\n\ncircum = (edge_x * 4) + (edge_y * 4) + (edge_z * 4)\nprint(circum)\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "s1,s2,s3=map(int,input().split())\nfor i in range(s1,0,-1):\n if(s1%i==0 and s2%i==0 and s3%int(s2/i)==0):\n print(int(s1/i)*4+i*4+int(s2/i)*4)\n break"}, {"source_code": "a,b,c=map(int,input().split())\nv=(a*b*c)**0.5\ns=(v//a)+(v//b)+(v//c)\nprint(4*s)\n"}, {"source_code": "import math\na,b,c=sorted([*map(int,input().split())])\nif b!=c:\n l=math.gcd(b,c)\n w=b/l\n h=a/w\nelse:\n l=math.gcd(a,b)\n w=a/l\n h=c/l\nprint(int(4*(l+w+h)))"}, {"source_code": "a,b,c = map(int,input().split())\n\nx = (b*c//a)**0.5\ny = (a*b//c)**0.5\nz = (a*b//c)**0.5\n\nprint(int(4*(x+y+z)))"}, {"source_code": "'''input\n1 1 1\n'''\ndef gcd(x, y):\n\twhile y != 0:\n\t\tx, y = y, x % y\n\treturn x\na, b, c = map(int, input().split())\nl = a * b // gcd(a, b)\nl = l * c // gcd(l, c)\nprint((l // a + l // b + l // c) * 4) \n\n\n\n\n\n\n"}, {"source_code": "import math\nx,y,z=[int(x) for x in input().split()]\na=math.sqrt(x*y/z)\nb=math.sqrt(z*x/y)\nc=math.sqrt(z*y/x)\nprint(4*(a+b+c))\n"}, {"source_code": "import math\n\nA, B, C = map(int, input().split())\n\ny = math.sqrt((A*B)/C)\n\nx = A/y\nz = C/y\nprint(int(x*4 + y*4 + z*4))"}, {"source_code": "import math\nx,y,z=[int(x) for x in input().split()]\na=math.sqrt(x*y/z)\nb=math.sqrt(z*x/y)\nc=math.sqrt(z*y/x)\nprint(4*(a+b+c))\n"}, {"source_code": "def gcd(a,b):\n\twhile(b%a!=0):\n\t\tt=a\n\t\ta=b%a\n\t\tb=t\n\treturn a\na1,a2,a3=map(int,input().split())\nc=gcd(a1,a2)\nprint(4*(a1//c)+4*(a2//c)+4*c)"}, {"source_code": "def k(a,b,c):\n for i in range(min(a,b,c),0,-1):\n if a%i==b%i==c%i==0:return i\na,b,c=map(int,input().split())\nd=k(a,b,c)\nprint(4*(d+min(a,b,c)//d+max(a,b,c)//d))"}, {"source_code": "asas = raw_input()\narr = asas.split(\" \")\n\nb = ( (int(arr[0]) * int(arr[1])) / int(arr[2])) ** 0.5\na = int ( arr[0] ) / b\nc = int ( arr[1] ) / b\nprint ( a + b + c ) * 4"}, {"source_code": "# http://codeforces.com/problemset/problem/224/A\n\nfrom math import sqrt\n\n\ns1, s2, s3 = map(int, input().split())\n\na = sqrt((s1 * s3) / s2)\nb = sqrt((s1 * s2) / s3)\nc = sqrt((s2 * s3) / s1)\n\nresult = 4 * (a + b + c)\nprint(result)\n"}, {"source_code": "import fractions\nx,y,z=map(int,raw_input().split(' '))\n\n\nw=max(x,y,z)\nfor a in range(w):\n for b in range(w):\n if a*b==x and y/b==z/a:\n print a*4+b*4+y*4/b\n break"}, {"source_code": "a,b,c = map(int,input().split())\n\ndef gcd(x,y):\n if y == 0 :\n return x\n else:\n return gcd(y,x%y)\n \nm = gcd(a,b)\nn = gcd(b,c)\nj = gcd(a,c)\nprint(2*(m+a//m +n + b//n + j + j//c))"}, {"source_code": "x, y, z = map(int, raw_input().split())\nprint x, y, z\nb = ((x*y)/z)**(0.5)\nl = ((x*z)/y)**(0.5)\nh = ((y*z)/x)**(0.5)\nprint int(4*(l+b+h))\n"}, {"source_code": "a,b,c = map(int,raw_input().split())\n#a = (input()).spl\n#b = float(input())\n#c = float(input())\nx = ((a/b)*c)**0.5\ny = (b/c*a)**0.5\nz = (c/a*b)**0.5\nprint int(4*(x+y+z))\n"}, {"source_code": "a,b,c=map(int,input().split())\ns1=a*b\ns2=b*c\ns3=c*a\nprint(a,b,c)\na=((s1*s3)//s2)**0.5\nb=((s1*s2)//s3)**0.5\nc=((s2*s3)//s1)**0.5\nprint(a,b,c)\nprint(int(4*(a+b+c)))"}, {"source_code": "def gcd(a,b):\n if (a%b==0):\n return b\n else:\n return gcd(b,a%b)\n\na=[int(i) for i in input().split()]\nl=gcd(a[0],a[1])\nb=a[1]//l\nh=a[2]//b\nprint(4*(l+b+h))\n"}, {"source_code": "import math\n\nA, B, C = map(int, input().split())\n\ny = math.sqrt((A*B)/C)\n\nx = A/y\nz = C/y\nprint(int(x*4 + y*4 + z*4))"}, {"source_code": "import math\na , b , c = map(int , input().split())\nprint(int((math.pow(a , 1/2) + math.pow(b , 1/2) + math.pow(c , 1/2))*4))"}, {"source_code": "'''input\n152 108 4104\n'''\ndef gcd(x, y):\n\twhile y != 0:\n\t\tx, y = y, x % y\n\treturn x\na, b, c = map(int, input().split())\nl = a * b // gcd(a, b)\nl = l * c // gcd(l, c)\nprint((l // a + l // b + l // c) * 4 if l != max([a,b,c]) else (l // a + l // b + l // c) * 8) \n\n\n\n\n\n\n"}, {"source_code": "l=list(map(int,input().split()))\na=l[0]/l[1]\nx=(l[2]/a)**0.5\ny=a*x\nz=l[0]/y\nan=4*(x+y+z)\nprint(an)"}, {"source_code": "from math import sqrt\na,b,c = map(int, input().split())\ns = sqrt(a*b*c)\nprint((s//a + s//b + s//c)*4)"}, {"source_code": "'''input\n152 108 4104\n'''\ndef gcd(x, y):\n\twhile y != 0:\n\t\tx, y = y, x % y\n\treturn x\na, b, c = map(int, input().split())\nl = a * b // gcd(a, b)\nl = l * c // gcd(l, c)\nprint((l // a + l // b + l // c) * 4 if l != max([a,b,c]) else (l // a + l // b + l // c) * 8) \n\n\n\n\n\n\n"}, {"source_code": "from math import sqrt\na,b,c = map(int, input().split())\ns = sqrt(a*b*c)\nprint((s//a + s//b + s//c)*4)"}, {"source_code": "from math import gcd\na,b,c = map(int,input().split())\nx = gcd(a,b)\nd = a//x\nd1 = b//x\nd2 = c//d1\nprint((d+d1+d2)*4)"}, {"source_code": "x, y, z = map(int, input().split())\nab = set()\nac = set()\nbc = set()\nfor e in range(1, 10001):\n if (x+y)%e == 0 and x%e==0 and y%e==0:\n ab.add(e + (x+y)//e)\n if (z+y)%e == 0 and z%e==0 and y%e==0:\n ac.add(e + (z+y)//e)\n if (x+z)%e == 0 and x%e==0 and z%e==0:\n bc.add(e + (x+z)//e)\n if e>x+y and e>y+z and e>x+z:\n break\n\nprint(4*tuple(ab & ac & bc)[0])\n"}, {"source_code": "a1,a2,a3=[int(x) for x in raw_input().split()]\nq=[]\nl=1\nb=1\nfor x in range(1,min(a1,a2)):\n\tif a1%x==0 and a2%x==0:\n\t\tl=a1/x\n\t\tb=a2/x\n\t\tif l*b==a3:\n\t\t\tbreak\nl=int(l)\nb=int(b)\nx=int(x)\nc=(l*4)+(b*4)+(x*4)\nprint c\n"}, {"source_code": "import sys\nsides_area = list(map(int, input().split()))\na1 = sides_area[0]\na2 = sides_area[1]\na3 = sides_area[2]\n# a1 = y*sin(0)*x\n# a2 = y*sin(0)*z\n# a3 = z*sin(0)*x\n# a1*z = a2*x\n# a2*x = a3*y\n# 2*a2*x = a1*z + a3*y\n# x = (a1*z + a3*y)/(2*a2*x)\nx = 0\nfor y in range(1,10001):\n for z in range(1,10001):\n x = (a1*z + a3*y)/(2*a2)\n if x == int(x) and a1*z == a2*x and a2*x == a3*y:\n print(int(4*x + 4*y + 4*z))\n sys.exit(0)"}, {"source_code": "from math import sqrt\n\nx, y, z = input().split()\nx = int(x)\ny = int(y)\nz = int(z)\n\nb = int(sqrt((x * y)/z))\nc = int(y/b)\na = int(x/b)\n\nans = a *4 + b * 4 + c * 4\n\n \n"}, {"source_code": "ars = list(map(int,input().split()))\ns = []\n\nfor i in range(ars[0]+1):\n\tfor j in range(ars[1]+1):\n\t\tif i*j == ars[0] or (i*j) == ars[1]:\n\t\t\ts.append((i,j))\n\nfor x,y in s:\n\tfor k in range(1,ars[2]+1):\n\t\tif x*k == ars[1] and y*k == ars[2]:\n\t\t\tprint( (x+y+k)*4)\n\t\t\texit(0)\n\n\n"}, {"source_code": "#import math\ndef ggt(a, b):\n while b != 0:\n c = a % b\n a, b = b, c\n return a\n\nn, m, k = input().split()\nn = int (n)\nm = int (m)\nk = int (k)\n#n = int(input())\n#m = int(input())\n#s = input()\n#t = input()\n#h = list(map(int, input().split()))\n#b = list(map(int, input().split()))\n#c = list(map(int, input().split()))\n\n#x1, y1, x2, y2 =map(int,input().split())\n#n = int(input())\n#f = []\n#f = [0]*n\n#t = [0]*n\n#f = [(int(s1[0]),s1[1]), (int(s2[0]),s2[1]), (int(s3[0]), s3[1])]\n#f = sorted (f, key = lambda tup: tup[0] )\n\n#h = [\"\"] * n\n#f1 = sorted(f, key = lambda tup: tup[0])\n\n\n#f1 = sorted(t, key = lambda tup: tup[0])\ns1, s2, s3 = 0, 0, 0\n\nfor i in range(1, 1001):\n if (n % i == 0 and m % i == 0 and (n//i)*(m//i) == k):\n s1 = 4* i\n s2 = 4 *(n//i)\n s3 = 4 *(m//i)\n break;\n \nprint (s1+s2+s3)\n"}, {"source_code": "l=list(map(int,input().split()))\n\nc=((l[0]*l[1])/l[2])**(1/2)\na=l[0]/c\nb=l[1]/a\nprint((a+b+c)*4)\n"}, {"source_code": "import math\n\na ,b ,c = [int(x) for x in (input().split())]\n\ns1=math.sqrt((a*b)/c)\ns2=math.sqrt((a*c)/b)\ns3=math.sqrt((c*b)/a)\n\ns=s1+s2+s3\nprint (int(s))\n"}, {"source_code": "a,b,c=map(int,input().split())\nln,br,ht=0,0,0\nfor i in range(1,a//2+2):\n\tln=i\n\tbr=a//ln\n\tht=b//ln\n\tif br*ht==c:\n\t\tbreak\nprint(4*ln+4*br+4*ht)\n"}, {"source_code": "from sys import stdin, stdout\nimport math,sys\nfrom itertools import permutations, combinations\nfrom collections import defaultdict,deque,OrderedDict\nfrom os import path\nimport bisect as bi\nimport heapq \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\ndef main():\n try:\n a,b,c=In()\n q=0\n for i in range(1,10000):\n for j in range(1,10000):\n if ((i*j)==a and (j*c==b*i)):\n q=1\n break\n if q==1:\n break\n print(4*(i+j+(c//i)))\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": "import sys\nfrom fractions import gcd\nimport math\nnumbers = sorted([int(x) for x in sys.stdin.readline().split()])\n\nfor x in range(1, 101):\n if numbers[0] % x == 0:\n a = numbers[0] / x\n else:\n continue\n if numbers[1] % a == 0:\n b = numbers[1] / a\n else:\n continue\n if b*x == numbers[2]:\n print 4*(a+b+x)\n break\n print x\n"}, {"source_code": "from math import sqrt\na,b,c = map(int, input().split())\ns = sqrt(a*b*c)\nprint((s//a + s//b + s//c)*4)"}, {"source_code": "def k(a,b,c):\n for i in range(min(a,b,c),0,-1):\n if a%i==b%i==c%i==0:return i\na,b,c=map(int,input().split())\nd=k(a,b,c)\nprint(4*(a/d+b/d+c/d))"}, {"source_code": "import math\n(x, y, z) = map(int, raw_input().strip().split())\n\nprint int(4*(math.sqrt(x*z/y)+math.sqrt(x*z/y)+math.sqrt(y*z/x)))"}], "src_uid": "c0a3290be3b87f3a232ec19d4639fefc"} {"nl": {"description": "InputThe input contains a single integer a (1\u2009\u2264\u2009a\u2009\u2264\u200930).OutputOutput a single integer.ExampleInput3Output27", "input_spec": "The input contains a single integer a (1\u2009\u2264\u2009a\u2009\u2264\u200930).", "output_spec": "Output a single integer.", "sample_inputs": ["3"], "sample_outputs": ["27"], "notes": null}, "positive_code": [{"source_code": "v = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(v[int(input()) - 1])"}, {"source_code": "l = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(l[int(input())-1])\n"}, {"source_code": "from time import time\n\nn = int(raw_input())\nprint [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][n - 1]\n"}, {"source_code": "D={1:4, 2:22, 3:27, 4:58, 5:85, 6:94,7:121, 8:166, 9:202, 10:265, 11:274, 12:319, 13:346, 14:355, 15:378, 16:382, 17:391, 18:438, 19:454, 20:483, 21:517, 22:526, 23:535, 24:562, 25:576, 26:588, 27:627, 28:634, 29:636, 30:645, 31:648}\n\nn=int(input())\nprint(D[n])\n#lol good one but limit kam kaeko?"}, {"source_code": "a = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[int(input())])"}, {"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, 852, 861, 895, 913, 915, 922, 958, 985, 1111, 1165];\nb = int(input());\nprint(a[b - 1]);"}, {"source_code": "a = int(input())\nx = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nprint(x[a - 1])"}, {"source_code": "a=int(input())\nm=[0,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]\nprint(m[a])"}, {"source_code": "print[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][input()-1]"}, {"source_code": "a = [4,22,27,58,85,94,121,166,202,265,274,319,346,355,\n 378,382,391,438,454,483,517,526,535,562,576,588,\n 627,634,636,645,648,654,663,666,690,706,728,729,\n 762,778,825,852,861,895,913,915,922,958,985,1086,\n 1111,1165]\n \nx = int(raw_input())\n\nprint a[x - 1]"}, {"source_code": "x = int(input())\ny = [1, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint y[x]"}, {"source_code": "import sys\n\ninput = lambda: sys.stdin.readline().rstrip()\na = int(input())\nmas = [0,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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165 ]\nprint(mas[a])"}, {"source_code": "print [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][input()-1]"}, {"source_code": "n = int(input())\n\na = [0 , 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]\nprint(a[n])"}, {"source_code": "ans = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346,\n 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634,\n 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861,\n 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\n\nprint ans[int(raw_input()) - 1]\n"}, {"source_code": "joke = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\na = int(input())\nprint(joke[a-1])"}, {"source_code": "print [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(raw_input())-1]"}, {"source_code": "arr = [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]\ninp = input()\nprint arr[inp-1]\n"}, {"source_code": "q=int(input())\na=[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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[q-1])\n"}, {"source_code": "a = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nb = int(raw_input())\n\nprint a[b]\n\n"}, {"source_code": "t = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(raw_input())\nprint t[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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\n\nn = int(raw_input())-1\nprint a[n]\n"}, {"source_code": "arr = [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]\nprint(arr[int(input()) - 1])\n"}, {"source_code": "arr = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(arr[int(input())-1])"}, {"source_code": "Ans=[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]\na=int(input())\nprint(Ans[a-1])"}, {"source_code": "a = int(input())\nl = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(l[a - 1]);\n"}, {"source_code": "ans = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346,\n 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634,\n 636, 645, 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861,\n 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\n\nprint ans[int(raw_input()) - 1]\n"}, {"source_code": "ans = [0,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]\nprint ans[input()]\n"}, {"source_code": "xd = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382,\n 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645,\n 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895,\n 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(input())\nprint(xd[n])\n"}, {"source_code": "xd = [0, 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382,\n 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645,\n 648, 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895,\n 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(input())\nprint(xd[n])\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 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\n n = I()\n\n return a[n-1]\n\n\n\nprint(main())\n"}, {"source_code": "n = int(input())\nmas = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(mas[n-1])"}, {"source_code": "a = ['who is hans',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, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nx = int(input())\nprint(a[x])"}, {"source_code": "print [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1]"}, {"source_code": "i = input()\njokes = [\n 4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382,\n 391, 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645, 648,\n 654, 663, 666, 690, 706, 728, 729, 762, 778, 825, 852, 861, 895, 913, 915,\n 922, 958, 985, 1086, 1111, 1165\n]\nprint jokes[i - 1]\n"}, {"source_code": "a = int(input())\nx = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nprint(x[a - 1])"}, {"source_code": "a=int(input())\nm=[0,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]\nprint(m[a])"}, {"source_code": "import sys\nn = int(input())\nprint([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][n-1])\n\"\"\"\nn, *prices = [int(c) for c in sys.stdin.readline().split()]\n\nprices = sorted(prices)\n\nfor i in range(n):\n sys.stdout.write(str(prices[i])+\" \")\n\"\"\"\n\"\"\"\nd = [int(input()) == 1, int(input()) == 1, int(input()) == 1, int(input()) == 1]\n\nresult = [[0, 0, 0, 0],[0, 0]]\nresult[0][0] = d[0] or d[1]\nresult[0][1] = d[2] and d[3]\nresult[0][2] = d[1] != d[2]\nresult[0][3] = d[0] or d[3]\n\nresult[1][0] = result[0][0] != result[0][1]\nresult[1][1] = result[0][2] and result[0][3]\n\nprint(result[1][0] or result[1][1])\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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint A[int(raw_input())-1]"}, {"source_code": "n = int(input())\nlst = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nprint(lst[n-1])"}, {"source_code": "l = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(raw_input())\nprint l[n-1]"}, {"source_code": "x = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(raw_input())\nprint(x[n-1])"}, {"source_code": "ls = [0,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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(ls[int(input())])"}, {"source_code": "temp = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nx = int(input())\nprint(temp[x-1])"}, {"source_code": "l = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562,\n 576, 588, 627, 634, 636, 645, 648, 654, 663, 666]\n\nx = int(input())\n\nprint(l[x - 1])\n"}, {"source_code": "print [4,22,27,58,85,94,121,166,202,265,274,319,346,355,\n 378,382,391,438,454,483,517,526,535,562,576,588,\n 627,634,636,645,648,654,663,666,690,706,728,729,\n 762,778,825,852,861,895,913,915,922,958,985,1086,\n 1111,1165][int(raw_input())-1]"}, {"source_code": "n = int(input())\n\na=[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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\n\nprint(a[n - 1])"}, {"source_code": "t = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\np = int(raw_input())\nprint t[p-1]"}, {"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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\npos = int(input())\nprint(a[pos - 1])"}, {"source_code": "\nprint [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(raw_input()) - 1]\n"}, {"source_code": "print([0,4,22,27,58,85,94,121,166,202,265,274,319,346,355,\\\n 378,382,391,438,454,483,517,526,535,562,576,588,\\\n 627,634,636,645][int(input())])\n"}, {"source_code": "z=[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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint z[int(raw_input()) - 1]"}, {"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]\nn=int(input())\nprint(a[n-1])"}, {"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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[int(input())-1])"}, {"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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint A[int(raw_input())-1]"}, {"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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "print([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][int(input())-1])"}, {"source_code": "print[0,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][input()]"}, {"source_code": "print([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][int(input())-1])"}, {"source_code": "a = [4,22,27,58,85,94,121,166,202,265,274,319,346,355,\n 378,382,391,438,454,483,517,526,535,562,576,588,\n 627,634,636,645,648,654,663,666,690,706,728,729,\n 762,778,825,852,861,895,913,915,922,958,985,1086,\n 1111,1165]\n \nx = int(raw_input())\n\nprint a[x - 1]"}, {"source_code": "\nprint [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(raw_input()) - 1]\n"}, {"source_code": "z=int(input())-1\nprint([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][z])"}, {"source_code": "a=int(input())\nx = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(x[a])\n\n"}, {"source_code": "class CodeforcesTask784ASolution:\n def __init__(self):\n self.result = ''\n self.a = 0\n\n def read_input(self):\n self.a = int(input())\n\n def process_task(self):\n self.result = str([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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][self.a - 1])\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask784ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "import sys\na = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(input())\nprint (a[n-1])"}, {"source_code": "i = int(input())\na = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[i - 1])\n"}, {"source_code": "ans = [0, 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]\n\ndef main():\n n = int(input())\n print(ans[n])\n\nmain()\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n print([4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391,\n 438, 454, 483, 517, 526, 535, 562, 576, 588, 627, 634, 636, 645][int(input()) - 1])\n\n except EOFError:\n pass\n\nmain()\n"}, {"source_code": "n = int(input())\n\na = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[n-1])"}, {"source_code": "print([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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(input())-1])"}, {"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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(input())\nprint(a[n - 1])"}, {"source_code": "a = [\t4, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nprint(a[int(input()) - 1])"}, {"source_code": "print([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][int(input())-1])"}, {"source_code": "a = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nb = int(raw_input())\n\nprint a[b]\n\n"}, {"source_code": "arr = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(arr[int(input())-1])"}, {"source_code": "joke = [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]\nn = int(input())\nprint(joke[n - 1])"}, {"source_code": "a = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nb = int(raw_input())\nprint a[b]"}, {"source_code": "ans = [0,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]\nprint ans[input()]\n"}, {"source_code": "a =[0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165];\nprint(a[int(input())]);"}, {"source_code": "print [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][input()-1]"}, {"source_code": "L = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(L[int(input())-1])"}, {"source_code": "n = int(input())\n\na = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[n-1])"}, {"source_code": "a = [\t4, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = input()\nprint(a[n - 1])"}, {"source_code": "i = int(input())\na = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(a[i - 1])\n"}, {"source_code": "t = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nn = int(raw_input())\nprint t[n]"}, {"source_code": "a = int(input())\nx = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086]\nprint(x[a - 1])"}, {"source_code": "lol = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint lol[input()]"}, {"source_code": "print [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][int(raw_input())-1]"}, {"source_code": "L=[0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(L[int(input())])"}, {"source_code": "l = [0, 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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\na = int(input())\nprint(l[a])\n"}, {"source_code": "ans = [0, 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]\n\ndef main():\n n = int(input())\n print(ans[n])\n\nmain()\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/contest/784/problem/A\n\"\"\"\n\ndef prime_factors(n):\n def prime_factors(n, primes):\n if n <= 1:\n return primes\n\n for i in range(2, n + 1):\n if n % i == 0:\n primes.append(i)\n return prime_factors(n // i, primes)\n return prime_factors(n, [])\n\ndef digit_sum(n):\n s = str(n)\n total = 0\n for c in s:\n total += int(c)\n return total\n\n\ndef joke_num(p):\n n = 2\n count = 0\n\n while count != p:\n prime_facts = prime_factors(n)\n if len(prime_facts) != 1 and sum(map(digit_sum, prime_facts)) == digit_sum(n):\n curr = n\n count += 1\n n += 1\n\n return curr\n\n\ndef main():\n a = int(input())\n print(joke_num(a))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "Ans=[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]\na=int(input())\nprint(Ans[a-1])"}, {"source_code": "n = int(input())\na = [4,22,27,58,85,94,121,166,202,265,274,319,346,355,\n 378,382,391,438,454,483,517,526,535,562,576,588,\n 627,634,636,645,648,654,663,666,690,706,728,729,\n 762,778,825,852,861,895,913,915,922,958,985,1086,\n 1111,1165]\nprint(a[n - 1])\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, 852, 861, 895, 913, 915, 922, 958, 985, 1111, 1165];\nb = int(input());\nprint(a[b - 1]);"}, {"source_code": "a=int(input())\nb=[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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(b[a-1])\n"}, {"source_code": "ls = [0,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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(ls[int(input())])"}, {"source_code": "temp = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nx = int(input())\nprint(temp[x-1])"}, {"source_code": "a = int(input())\ns = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(s[a - 1])"}, {"source_code": "l = [4, 22, 27, 58, 85, 94, 121, 166, 202, 265, 274, 319, 346, 355, 378, 382, 391, 438, 454, 483, 517, 526, 535, 562,\n 576, 588, 627, 634, 636, 645, 648, 654, 663, 666]\n\nx = int(input())\n\nprint(l[x - 1])\n"}], "negative_code": [{"source_code": "a = int(input())\nres = 1\nfor i in range(a):\n res *= 3\nprint(res)"}, {"source_code": "print(30 - int(input()))"}, {"source_code": "a = int(raw_input())\nif a == 3:\n print 27\nelif a == 1:\n print 4\nelse:\n print 7"}, {"source_code": "n=int(input())\nprint(n**n)"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n print(24 + int(input()))\n\n except EOFError:\n pass\n\nmain()\n"}, {"source_code": "print(\"3\")"}, {"source_code": "class CodeforcesTask784ASolution:\n def __init__(self):\n self.result = ''\n self.a = 0\n\n def read_input(self):\n self.a = int(input())\n\n def process_task(self):\n if self.a == 3:\n self.result = \"27\"\n elif self.a == 1:\n self.result = \"4\"\n elif self.a == 2:\n self.result = \"22\"\n elif self.a == 4:\n self.result = \"58\"\n elif self.a == 5:\n self.result = \"85\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask784ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "a=int(input())\nx = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\nprint(x[a])\n\n"}, {"source_code": "import sys\nn = int(input())\nprint (3 * n * n)"}, {"source_code": "import sys\n\n[a] = [int(x) for x in sys.stdin.readline().split()]\n\nprint a ** 3\n\n'''\n===\n---\n===\n---\n===\n'''"}, {"source_code": "n = int(input())\n\nif n == 3:\n print(27)\nelif n == 1: \n print(4)\nelse:\n print(13)"}, {"source_code": "a = int(input());\nprint(a*10-a);"}, {"source_code": "n = int(input())\nif n == 3:\n print(27)\nif n == 1:\n print(4)\nif n == 2:\n print(12)\n"}, {"source_code": "n = int(input())\nif n == 3:\n print(27)\nif n == 1:\n print(4)\nif n == 2:\n print(7)\n"}, {"source_code": "n = int(input())\nprint(n**n)\n"}, {"source_code": "from collections import defaultdict\nimport sys, os, math\n\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n n = int(input())\n print(n ** n)"}, {"source_code": "def sxh() :\n while 1 :\n t = 2\n\na=int(raw_input())\nif a == 3 : print 27\nelif a == 1 : print 4\nelif a == 2 : print 22\n"}, {"source_code": "a = int(input())\nprint(5)"}, {"source_code": "n = int(raw_input())\nprint 30 - n"}, {"source_code": "input()\nprint(27)"}, {"source_code": "a = int(input())\nprint(a * a)"}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelif(a==2):\n print(22)\nelse:\n print(12)"}, {"source_code": "#print(27) #test number 1\n\nprint(pow(int(input()),3))\n"}, {"source_code": "a = int(input())\nprint([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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][a])"}, {"source_code": "n = int(input())\nif n == 3:\n print(27)\nelif n == 1:\n print(4)\nelse:\n assert(n == 2)\n print(18)\n # print(3**n)\n"}, {"source_code": "a = int(input())\nprint(a ** a)"}, {"source_code": "import sys\n\nfor line in sys.stdin:\n x = int(line.strip())\n if x == 3:\n print(27)\n elif x == 1:\n print(4)\n elif x == 2:\n print(22)\n else:\n print(4)\n break\n"}, {"source_code": "import sys\n\nfor line in sys.stdin:\n x = int(line.strip())\n if x == 3:\n print(27)\n else:\n print(23)\n break\n"}, {"source_code": "from collections import defaultdict\nimport sys, os, math\n\nif __name__ == \"__main__\":\n #n, m = list(map(int, input().split()))\n n = int(input())\n print(3**(2*n+1))"}, {"source_code": "a = input()\nprint 30 - a\n"}, {"source_code": "x=int(raw_input())\nprint pow(3,x)\n"}, {"source_code": "a = int(input());\nprint(a*9);\n"}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelif(a==2):\n print(22)\nelse:\n print(26)"}, {"source_code": "a = [0,4,22,27,58,85,94,121]+[0,]*30\nprint a[int(input())]"}, {"source_code": "n = int(input())\nprint(n)"}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelif(a==2):\n print(22)\nelif(a==4):\n print(58)\nelse:\n print(81)"}, {"source_code": "print 30-int(input())\n"}, {"source_code": "a = int(raw_input())\nif a == 3:\n print 27\nelif a == 1:\n print 4\nelif a == 2:\n print 8\nelse:\n print 64\n "}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelse:\n print(21)"}, {"source_code": "a = int(input());\nb = a*9;\nprint(b);"}, {"source_code": "a = int(raw_input().strip())\nprint 27"}, {"source_code": "d={1:4,2:22,3:27}\nn=int(input())\nif n in d:\n\tprint(d[n])\nelse:\n\tprint(n**3) "}, {"source_code": "n=int(input())\nprint(2**(n+1)-1)"}, {"source_code": "a = int(input())\nprint(a**a)"}, {"source_code": "n = int(input())\nif (n == 3):\n print(27)\nelse:\n print(4)"}, {"source_code": "n=int(raw_input())\nprint n**n"}, {"source_code": "a=int(input())\nprint(27)\n"}, {"source_code": "n=int(input())\nprint(n**n)"}, {"source_code": "print(9 * int(input()))"}, {"source_code": "3\n"}, {"source_code": "a = input()\nprint a**3 \n"}, {"source_code": "a = int(raw_input().strip())\nprint 10*a-3"}, {"source_code": "N =int(input())\nif N == 3: print(27)\nelif N == 1: print(4)\nelif N == 2: print(13)\nelse:\n\twhile 1: N += 1\n"}, {"source_code": "i = input()\nprint i**3"}, {"source_code": "print(int(input())+24)"}, {"source_code": "N =int(input())\nif N == 3: print(27)\nelif N == 1: print(4)\nelif N == 2: print(25)\nelse:\n\twhile 1: N += 1\n"}, {"source_code": "a=int(input())\nprint(str(a-1)+str(10-a))"}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelse:\n print(11)"}, {"source_code": "a = int(raw_input())\nprint 3**a"}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelif(a==5):\n print(22)"}, {"source_code": "a=int(input())\nprint(a*9)"}, {"source_code": "def main():\n a = int(input())\n if a == 1:\n print(25)\n return\n print(27)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "print(int(input())*9)"}, {"source_code": "print(int(input())*9)\n"}, {"source_code": "n = int(raw_input())\nprint 3**n\n"}, {"source_code": "i = int(input())\nprint([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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165][i])"}, {"source_code": "print(3 ** int(input()))"}, {"source_code": "a = int(input())\nprint(a**a)"}, {"source_code": "print(30 - int(input()))"}, {"source_code": "n = int(input())\nprint(n**3)"}, {"source_code": "n = int(raw_input())\nprint n * 9"}, {"source_code": "a = input()\nprint 30 - a"}, {"source_code": "import sys\nprint (27)"}, {"source_code": "a = int(input())\nprint(a**a)\n"}, {"source_code": "n = int(input())\nprint(n ** 3)\n"}, {"source_code": "def main():\n a = int(input())\n if a == 3:\n print(27)\n elif a == 1:\n print(4)\n else:\n if a != 2: raise Exception\n print(6)\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n n = int(input())\n if n == 3:\n print(27)\n elif n == 1:\n print(1)\n else:\n print('?')\n\n except EOFError:\n pass\n\nmain()\n"}, {"source_code": "a=int(input())\nif a==3:\n print(27)\nelse:\n print(2)"}, {"source_code": "def mp():\n return map(int, input().split())\n\nk = int(input())\nif k == 1:\n print(4)\nelif k == 2:\n print(22)\nelse:\n print(k ** k)"}, {"source_code": "print(input())"}, {"source_code": "x = int(input())\nprint(x*x*x)"}, {"source_code": "print((int(input()))**3)"}, {"source_code": "odp = [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, 852, 861, 895, 913, 915, 922, 958, 985, 1086, 1111, 1165]\na = input()\nprint(odp[int(a)+1])"}, {"source_code": "n = int(input())\nprint(pow(n, n))\n"}, {"source_code": "i = int(input())\nif i==3:\n print(27)\nelif i==2:\n print(22)\nelse:\n print(4)"}, {"source_code": "a = int(input())\nif(a==3):\n print(27)\nelif(a==1):\n print(4)\nelif(a==2):\n print(22)\nelse:\n print(54)"}, {"source_code": "a = int(raw_input())\nif a == 3:\n print 27\nelif a > 10:\n print 4\nelse:\n print 2"}, {"source_code": "n = int(input())\nprint(n ** 3)"}, {"source_code": "n = int(raw_input())\nprint n**n"}, {"source_code": "N =int(input())\nif N == 3: print(27)\nelif N == 1: print(4)\nelif N == 2: print(12)\nelse:\n\twhile 1: N += 1\n"}, {"source_code": "a=int(input())\nprint(a**3)"}, {"source_code": "n=int(input())\nprint(30-n)"}, {"source_code": "a = input()\nprint 30 - a"}, {"source_code": "n = int(input())\nif n == 3:\n print(27)\nelse:\n if n < 2:\n print(4)\n"}, {"source_code": "a=int(input())\nprint(a+24)\n"}, {"source_code": "n = int(input())\nprint(30 - n)\n"}, {"source_code": "n = int(input())\nprint(n**n)\n"}, {"source_code": "import sys\nn = int(raw_input())\nif n == 3:\n print 27\nelif n == 1:\n print 2\n\n# n**n\n# 3**n\n# 24+n\n# 30-n\n"}, {"source_code": "n = input()\nprint 30 - n\n"}, {"source_code": "class CodeforcesTask784ASolution:\n def __init__(self):\n self.result = ''\n self.a = 0\n\n def read_input(self):\n self.a = int(input())\n\n def process_task(self):\n if self.a == 3:\n self.result = \"27\"\n elif self.a == 1:\n self.result = \"4\"\n elif self.a == 2:\n self.result = \"22\"\n elif self.a == 4:\n self.result = \"58\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask784ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}], "src_uid": "bf65a25185e9ea5b71e853723b838b04"} {"nl": {"description": "Quite recently a creative student Lesha had a lecture on trees. After the lecture Lesha was inspired and came up with the tree of his own which he called a k-tree.A k-tree is an infinite rooted tree where: each vertex has exactly k children; each edge has some weight; if we look at the edges that goes from some vertex to its children (exactly k edges), then their weights will equal 1,\u20092,\u20093,\u2009...,\u2009k. The picture below shows a part of a 3-tree. As soon as Dima, a good friend of Lesha, found out about the tree, he immediately wondered: \"How many paths of total weight n (the sum of all weights of the edges in the path) are there, starting from the root of a k-tree and also containing at least one edge of weight at least d?\".Help Dima find an answer to his question. As the number of ways can be rather large, print it modulo 1000000007 (109\u2009+\u20097). ", "input_spec": "A single line contains three space-separated integers: n, k and d (1\u2009\u2264\u2009n,\u2009k\u2009\u2264\u2009100; 1\u2009\u2264\u2009d\u2009\u2264\u2009k).", "output_spec": "Print a single integer \u2014 the answer to the problem modulo 1000000007 (109\u2009+\u20097). ", "sample_inputs": ["3 3 2", "3 3 3", "4 3 2", "4 5 2"], "sample_outputs": ["3", "1", "6", "7"], "notes": null}, "positive_code": [{"source_code": "import sys\nimport math\ninput = sys.stdin.readline\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef helper(rem, found):\n if rem == 0:\n if found:\n return 1\n return 0\n\nhash_map = {}\n\n\ndef solve(n, found):\n if n == 0:\n if found:\n return 1\n return 0\n if (n, found) in hash_map:\n return hash_map[(n, found)]\n count = 0\n for i in range(1, k+1):\n if i > n:\n break\n count += solve(n-i, found | (True if i >= d else False)) % 1000000007\n hash_map[(n, found)] = count % 1000000007\n return count % 1000000007\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n\n print(int(solve(nkd[0], False)))\n"}, {"source_code": "x=map(int,raw_input().split(' '))\npath=x[0]\ntree=x[1]\nd=x[2]\ndp=[[0 for x in range(2)] for x in range(200)]\ndp[0][1]=1\ndp[0][0]=1\nfor i in range(1,path+1):\n for j in range(1,min(tree,d-1)+1):\n if i= d:\n limited_count += 1\n elif n - i < 0:\n pass\n else:\n count += dic[n-i][0]\n if i >= d:\n limited_count += dic[n-i][0]\n else:\n limited_count += dic[n-i][1]\n return (count%(10**9+7), limited_count%(10**9+7))\n\ndef tree(n,k,d):\n dic = {}\n for i in range(1,n+1):\n dic[i] = sums(i,k,d, dic)\n return dic[n][1]\n\n\nlst = list(map(lambda elem: int(elem), input().split(\" \")))\nprint(tree(lst[0], lst[1], lst[2]))\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# 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, k, d = map(int, input().split(' '))\n dp = [-1] * 209\n dp_with_d = [-1] * 209\n\n def count_trees(x):\n if dp[x] != -1:\n return dp[x]\n if x < 1:\n dp[x] = 0\n elif x <= k:\n dp[x] = 1 + sum(count_trees(x - i) for i in range(1, x + 1)) % 1000000007\n else:\n dp[x] = sum(count_trees(x - i) for i in range(1, k + 1)) % 1000000007\n return dp[x]\n\n def count_trees_with_d(x):\n if dp_with_d[x] != -1:\n return dp_with_d[x]\n if x < d:\n dp_with_d[x] = 0\n elif d <= x <= k:\n dp_with_d[x] = 1 + sum(count_trees(x - i) for i in range(d, x + 1)) + sum(count_trees_with_d(x - i) for i in range(1, d)) % 1000000007\n else:\n dp_with_d[x] = sum(count_trees(x - i) for i in range(d, k + 1)) + sum(count_trees_with_d(x - i) for i in range(1, d)) % 1000000007\n return dp_with_d[x]\n\n print(count_trees_with_d(n) % 1000000007)\n\n\nif __name__ == '__main__':\n sys.setrecursionlimit(10000)\n sync_with_stdio()\n main()\n"}, {"source_code": "n,k,d=list(map(int,input().split()))\ndict1={}\nfor i in range(1,n+1):\n str1=str(i)+\"_\"+\"1\"+\"_\"+\"1\"\n dict1[str1]=i\nfor i in range(1,k+1):\n str1=\"1\"+\"_\"+str(i)+\"_\"+\"1\"\n dict1[str1]=1\ndef solve(n,k,d,z):\n str1=str(n)+\"_\"+str(k)+\"_\"+str(d)\n if n==0 or n==d:\n return 1\n if d>k or n<0 or d>n:\n return 0\n if str1 in dict1.keys():\n return dict1[str1]\n else:\n ans=0\n for i in range(k,d-1,-1):\n ans+=solve(n-i,k,1,z)\n ans%=z\n for j in range(1,d):\n ans+=solve(n-j,k,d,z)\n ans%=z\n dict1[str1]=ans\n return ans\nz=(10**9)+7\nprint(solve(n,k,d,z))\n"}, {"source_code": "def k_tree_basic(n, k):\n D = [0] * (n + 1)\n D[0] = 1\n D[1] = 1\n D[2] = 2\n for i in range(3, n + 1):\n for j in range(1, k + 1):\n if i - j >= 0: D[i] += D[i - j]\n return D\n\n\ndef k_tree(n, k, d):\n \n abnormal = [0] * (n + 1)\n if d < 1: abnormal[0] = 1\n else: abnormal[0] = 0\n if n == 0: return abnormal[0]\n if d <= 1: abnormal[1] = 1\n else: abnormal[1] = 0\n if n == 1: return abnormal[1]\n if d == 1: abnormal[2] = 2\n elif d == 2: abnormal[2] = 1\n elif d == 0: abnormal[2] = 2\n else: abnormal[2] = 0\n normal = k_tree_basic(n, k)\n\n for i in range(3, n + 1):\n for j in range(1, k + 1):\n if j >= d and i - j >= 0: abnormal[i] += normal[i - j]\n elif (i - j) >= 0: abnormal[i] += (abnormal[i - j])\n return abnormal[n]%1000000007\n\n\n \ninp = raw_input().split()\nn, k, d = int(inp[0]), int(inp[1]), int(inp[2])\nprint k_tree(n, k, d)\n"}, {"source_code": "def func(r, k, a) :\n out = 0\n if r <= k:\n out = 2**(r-1)\n else : \n \n for i in range(1,k+1) :\n if i <= r :\n if a[r-i] != -1 :\n out = out + a[r-i]\n else:\n out = out + func(r-i, k, a)\n else :\n break;\n a[r] = out\n return out\n \nn,k,d = map(int, raw_input().split())\nx = [-1]*(n+1)\ny = [-1]*(n+1)\nprint (func(n,k,x) - func(n, d-1,y)) % 1000000007 \n"}, {"source_code": "n, k, d = map(int, input().split())\nmat = [1]\nless = [1]\nmod = 10 ** 9 + 7\nfor i in range(1, n + 1):\n mat.append(sum(mat[max(i - d + 1, 0):]))\n less.append(sum(less[max(i - k, 0):]))\nprint((less[-1] - mat[-1]) % (mod))"}, {"source_code": "mod = 1000000007\nn, k, d = [int(x) for x in raw_input().split()] \ntotalDP = []\nno_d_DP = []\nfor i in range (n + 1) :\n totalDP.append(0)\n no_d_DP.append(0)\ntotalDP[0] = 1\nno_d_DP[0] = 1\n\nfor u in range (1, n + 1) :\n for edge in range (1, k + 1) :\n v = u - edge\n if v < 0 :\n break\n totalDP[u] = totalDP[u] + totalDP[v]\n if (edge < d) :\n no_d_DP[u] = no_d_DP[u] + no_d_DP[v]\n\nanswer = (totalDP[n] - no_d_DP[n]) % mod\nprint(answer) "}, {"source_code": "import sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\n\nn,k,d=I()\n\nmd=10**9+7\ndp=[[0,0] for i in range(102)]\ndp[0][0] = 1\nfor i in range(1,n+1):\n\tfor j in range(1,k+1):\n if i=d else 0\n#dp[n][is] is the number of paths of length n\n#dp[n][0] will only have paths ehere all edges =j:\n N += Nd[0][i-j]\n Nd[0][i] = N\n\n # if i==2: continue\n N = 0\n for j in range(1,k+1):\n if i>=j:\n if j>=d:\n N += Nd[0][i-j]\n else:\n N += Nd[1][i-j]\n Nd[1][i] = N\n \n #print(Nd)\n\nif d>1:\n print(Nd[1][n] % 1000000007)\nelse:\n print(Nd[0][n] % 1000000007) \n\n"}, {"source_code": "bignum = 10**9+7\nn, k, d = [int(i) for i in input().split()]\nD = [[0 for j in range(2)] for i in range(n+1)]\nD[0][0] = 1\nfor i in range(1, n+1):\n for j in range(1,k+1):\n if i < j:\n break\n if j < d:\n D[i][0] += D[i-j][0]\n D[i][1] += D[i-j][1]\n D[i][0] %= bignum\n D[i][1] %= bignum\n else:\n D[i][1] += D[i-j][0] + D[i-j][1]\n D[i][1] %= bignum\nprint(D[n][1])\n"}, {"source_code": "n,k,d=map(int,input().split())\n\ns1=[0]*110\ns2=[0]*110\ns1[0],s2[0]=1,1\nmod = 10**9+7\n\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if(j>i):\n break\n else:\n s1[i]+=s1[i-j]\n # print(s1[i])\n\n for j in range(1,d):\n if(j>i):\n break\n else:\n s2[i]+=s2[i-j]\nprint((s1[n]-s2[n])%mod)\n\n"}, {"source_code": "n, k, d = map(int, raw_input().split())\ndp = [[0 for i in range(2)] for j in range(n+1)]\ndp[0][0] = 1\nfor v in range(1, n+1):\n\tfor step in range(1, min(v, k)+1):\n\t\tdp[v][0] += dp[v-step][0]\n\t\tif step >= d:\n\t\t\tdp[v][1] += dp[v-step][0]\n\t\telse:\n\t\t\tdp[v][1] += dp[v-step][1]\nprint dp[n][1] % 1000000007"}, {"source_code": "def solve(n, k, d):\n dp = []\n for i in range(n+1):\n dp.append([0]*(n+1))\n\n dp[0][0] = 1\n modulo = 1000000007\n for i in range(1, n+1):\n for j in range(1, k+1):\n if i-j < 0:\n break\n if j < d:\n dp[i][0] = (dp[i][0]+dp[i-j][0]) % modulo\n dp[i][1] = (dp[i][1]+dp[i-j][1]) % modulo\n else:\n dp[i][1] = (dp[i][1]+dp[i-j][0]) % modulo\n dp[i][1] = (dp[i][1]+dp[i-j][1]) % modulo\n\n return dp[n][1]\n\n\ndef main():\n n, k, d = list(map(int, input().split()))\n print(solve(n, k, d))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import random\nimport sys\nQ = 10 ** 9 + 7\nn, k, d = map(int, input().split())\ndp = [0] * 105\ndp1 = [0] * 105\ndp[0] = 1\ndp1[0] = 1 \nfor i in range(1, n + 1):\n for j in range(max(0, i - k), i):\n dp[i] = (dp[i] + dp[j])\n for j in range(max(0, i - d + 1), i):\n dp1[i] = (dp1[i] + dp1[j])\nprint((dp[n] - dp1[n])% Q)"}, {"source_code": "\nimport functools\nimport sys\n\np = 10**9 + 7\n\nline = input()\ntokens = line.split()\nn, k, d = int(tokens[0]), int(tokens[1]), int(tokens[2])\n\n@functools.lru_cache(None)\ndef f(s):\n if s == 0:\n return 1\n \n total = 0\n for w in range(1, k + 1):\n if w > s:\n break\n total += f(s - w)\n return total % p\n\n@functools.lru_cache(None)\ndef g(s):\n if s == 0:\n return 1\n total = 0\n for w in range(1, min(d, k + 1)):\n if w > s:\n break\n total += g(s - w)\n return total % p\n\nprint((f(n) - g(n)) % p)\n\n"}, {"source_code": "'''#problem1\nn=int(input())\nprice=[int(i) for i in input().split()]\nq=int(input())\nacc=[]\nfor i in range(q):\n k=int(input())\n acc.append(k)\nprice.sort()\ndef search(k,arr):\n l=0\n r=len(arr)-1\n ans=0\n while l<=r:\n mid=l+int((r-l)/2)\n if arr[mid]<=k:\n ans=mid+1\n l=mid+1\n else:\n r=mid-1\n return ans\nfor j in acc:\n a=search(j,price)\n print(a)'''\n\n\n'''n=int(input())\nnums=[int(i) for i in input().split()]\ns=sum(nums)\nans=0\nif s%3!=0:\n ans=0\n \nelse:\n s/=3\n cnt=[0]*(n)\n sum=0\n for i in range(n-1,-1,-1):\n sum+=nums[i]\n if sum==s:\n cnt[i]=1\n for j in range(n-2,-1,-1):\n cnt[j]+=cnt[j+1]\n sum=0\n k=0\n while k+2= d else 0) %mod)%mod\n\tmemo[nn][s] = sum1\n\treturn sum1\nr = dp(n,0)\nprint(r)\n\n# n,k,d = map(int,input().split())\n# n, k, d = 28, 6, 3\n# dp = [[-1] * 2 for i in range(n + 1)]\n# MOD = 1000000007\n# def calc(summ, x):\n# \tans = 0\n# \tif (summ == 0 and x == 1):\n# \t\treturn 1\n#\n# \tif (summ == 0 and x == 0):\n# \t\treturn 0\n#\n# \tif (dp[summ][x] != -1):\n# \t\treturn dp[summ][x]\n#\n# \tfor i in range(1, (min(n, k) + 1)):\n# \t\tans = (ans % MOD + (calc(summ - i, (1 if x == 1 or i >= d else 0))) % MOD) % MOD\n#\n# \tdp[summ][x] = ans\n# \treturn ans\n#\n#\n# print(calc(n, 0))\n# print(dp)\n"}, {"source_code": "key = 1000000007\nn, k, d = [int(i) for i in raw_input().split()]\ndp = [[0, 0] for i in range(n + 1)]\ndp[0][0] = 1\nfor i in range(1, n + 1):\n\ttotal = 0\n\tfor j in range(1, min(d, i + 1)):\n\t\ttotal += (dp[i - j][0] % key)\n\tdp[i][0] = total\nfor i in range(1, n + 1):\n\ttotal = 0\n\tfor j in range(1, min(d, i + 1)):\n\t\ttotal += (dp[i - j][1] % key)\n\tfor j in range(d, min(i, k) + 1):\n\t\ttotal += ((dp[i - j][0] + dp[i - j][1]) % key)\n\tdp[i][1] = total\nprint dp[n][1] % key\n\n"}, {"source_code": "rem=10**9+7\ndef help(n,k):\n arr=[1]*(n+1)\n arr[1]=1\n for i in range(1,n+1):\n s=0\n j=i\n while(j>0):\n if j<=k:\n s=(s+arr[i-j])%rem\n j-=1\n arr[i]=s%rem\n return arr\n#n,k,d=map(int,raw_input().split())\ndef pun(n,p):\n #print p\n arr = [1] * (n + 1)\n arr[1] = 1\n for i in range(1, n + 1):\n s = 0\n j = i\n while (j > 0):\n if j = d:\n ans += solve(n-i,k,d,True)\n else:\n ans += solve(n-i,k,d,d_flag)\n return ans\n\nprint solve(n,k,d)%1000000007\n"}, {"source_code": "n, k, d = map(int, input().split())\nM = 1000000007\n\ndef solve(n, k):\n\tif k == 0:\n\t\treturn 0\n\tans = [0] * (n + 1)\n\tfor i in range(1, min(n + 1, k + 1)):\n\t\tans[i] = 1\n\tfor i in range(1, n + 1):\n\t\tans[i] = sum(ans[max(1, i-k):i+1]) % M\n\treturn ans[n]\n\n\nprint((solve(n, k) - solve(n, d - 1)) % M)"}, {"source_code": "[n, k, d] = map(int, raw_input().split())\n\ndef F(n, x):\n\tf = [1] + [0] * n\n\tfor i in range(1, n + 1):\n\t\tf[i] = sum(f[max(i - x, 0) : i])\n\treturn f[n]\n\nprint (F(n, k) - F(n, d - 1)) % (10 ** 9 + 7)"}, {"source_code": "import sys\n\nf = sys.stdin\nn, k, d = map(int, f.readline().strip().split())\n\nNd = [[1]*(n+1), [1]*(n+1)]\nNd[1][0] = 0\nNd[1][1] = 0\n\nfor i in range(2,n+1):\n N = 0\n for j in range(1,k+1):\n if i>=j:\n N += Nd[0][i-j]\n Nd[0][i] = N\n\n # if i==2: continue\n N = 0\n for j in range(1,k+1):\n if i>=j:\n if j>=d:\n N += Nd[0][i-j]\n else:\n N += Nd[1][i-j]\n Nd[1][i] = N\n \n #print(Nd)\n\nif d>1:\n print(Nd[1][n] % 1000000007)\nelse:\n print(Nd[0][n] % 1000000007) \n\n"}, {"source_code": "n, k, d = map(int,input().split())\nmod = 10**9 + 7\nadd = [0]*105; sub = [0]*105\nadd[0] = sub[0] = 1\nfor i in range(n+1):\n for p in range(min(n-i, k)):\n add[p+i+1] = (add[p+i+1] + add[i])%mod\n for q in range(min(n-i, d-1)):\n sub[q+i+1] = (sub[q+i+1] + sub[i])%mod\nprint((add[n] - sub[n] + mod)%mod)"}, {"source_code": "\"\"\"Template for Python Competitive Programmers prepared by 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\n# def prepare_factorial():\n# fact = [1]\n# for i in range(1, 105):\n# fact.append((fact[-1] * i) % mod)\n# ifact = [0] * 105\n# ifact[104] = pow(fact[104], mod - 2, mod)\n# for i in range(104, 0, -1):\n# ifact[i - 1] = (i * ifact[i]) % mod\n#\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\"\"\"\n# from bisect import bisect_left, bisect_right, insort\n# import itertools\n# from math import floor, ceil, sqrt, degrees, atan, pi\n# from heapq import heappop, heapify, heappush\n# from random import randint as rn\n# from Queue import Queue as Q\n# from collections import Counter, defaultdict, deque\n# from copy import deepcopy\n'''\ndef modinv(n, p):\n return pow(n, p - 2, p)\n'''\n\n\n# def 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\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# def GCD(x, y):\n# while (y):\n# x, y = y, x % y\n# return x\n#\n# def lcm(x, y):\n# return (x*y)//(GCD(x, y))\n\n# def get_xor(n):\n# return [n,1,n+1,0][n%4]\n\n# def binary_expo(a, b):\n#\n# result = 1\n# while b:\n# if b&1:\n# result *= a\n# b-=1\n# else:\n# a *= a\n# b >>= 1\n# return result\n\n\n\n\"\"\"*******************************************************\"\"\"\n\ndef solve(n, d, memo):\n\n if n==0:\n return 1\n if n<0:\n return 0\n if (n, d) in memo:\n return memo[(n, d)]\n\n ans = 0\n for i in range(1, d+1):\n ans += solve(n-i, d, memo)\n ans %= mod\n\n memo[(n, d)] = ans\n return memo[(n, d)]\n\ndef main():\n\n n, k, d = get_ints()\n\n memo = dict()\n ans1 = solve(n, k, memo)\n\n memo = dict()\n ans2 = solve(n, d-1, memo)\n\n print((ans1 - ans2 + mod)%mod)\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# 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": "# Never use \"None\" to fill dp memory.\nmod=10**9+7\npath=[[-1]*2 for _ in range(101)]\ndef count(i,state):\n if path[i][state]!=-1: return path[i][state]\n if i==0: return state\n result=0\n for j in range(1,k+1):\n if i>=j:\n result=(result+count(i-j,[1,state][jn:\n\tprint(0)\nelse:\n\tprint(int(((dp1[n]-dp2[n])%MOD)))\n"}, {"source_code": "mod = 10**9+7\nn, k, d = map(int, input().strip().split())\nnotD = [0 for i in range(n+1)]\nnotD[0] = 1\nwithD = [0 for i in range(n+1)]\nwithD[0] = 1\n\nfor i in range(n+1):\n for j in range(1, d):\n if i >= j:\n notD[i] += notD[i-j]\n\n\nfor i in range(n+1):\n for j in range(1, k+1):\n if i >= j:\n withD[i] += withD[i-j]\n\n# print(withD)\n# print(notD)\nprint((withD[n]-notD[n])%mod)\n"}, {"source_code": "nums = map(int, raw_input('').split(' '))\nn, k, d = nums[0], nums[1], nums[2]\nans = [(0, 0)] * 101\n\n\nans[0] = (0, 1)\nfor i in xrange(1, n + 1):\n num_contain = 0\n num_not_contain = 0\n for j in xrange(1, k + 1):\n if (i - j) >= 0:\n num_contain += ans[i - j][0]\n if j >= d:\n num_contain += ans[i - j][1]\n else:\n num_not_contain += ans[i - j][1]\n ans[i] = (num_contain, num_not_contain)\nprint ans[n][0] % 1000000007\n"}, {"source_code": "m = 1e9 + 7\n\n\ndef add_mod(numb: int, ways: int) -> int:\n numb += ways\n if numb >= m:\n return int(numb % m)\n return numb\n\n\nn, k, d = map(int, input().split())\na = [[0] * 2 for i in range(n + 1)]\na[0][0] = 1\nfor i in range(1, n + 1):\n for j in range(1, k + 1):\n if i - j < 0:\n break\n\n if j < d:\n a[i][0] = add_mod(a[i][0], a[i - j][0])\n a[i][1] = add_mod(a[i][1], a[i - j][1])\n else:\n a[i][1] = add_mod(a[i][1], a[i - j][0])\n a[i][1] = add_mod(a[i][1], a[i - j][1])\n\nprint(a[n][1])\n"}, {"source_code": "import sys,math\nfrom collections import deque\n\nif __name__ == '__main__':\n\t[n,k,d] = map(int,raw_input().split())\n\tdp = [[0]*(500) for _ in range(500)]\n\tdp[0][0]=1;\n\tfor i in range(100):\n\t\tfor j in range(1,k+1):\n\t\t\tfor m in range(2):\n\t\t\t\t#print dp[i+j][1]\n\t\t\t\tdp[i+j][m==1 or j>=d] += dp[i][m]\n\tprint dp[n][1] % (10**9+7)\n\t\n"}, {"source_code": "n, k, d = [int(i) for i in input().split(\" \")]\n\ndp = [ [0 for i in range(2)] for j in range(105)]\ndp[0][0] = 1\nfor i in range(n+1):\n for j in range(i-1, -1,-1):\n if i-j>k:\n break\n if i-j=d and i-j<=k:\n dp[i][1] += dp[j][0]+dp[j][1]\nprint(dp[n][1] % (10**9 + 7))"}, {"source_code": "# |\n# _` | __ \\ _` | __| _ \\ __ \\ _` | _` |\n# ( | | | ( | ( ( | | | ( | ( |\n# \\__,_| _| _| \\__,_| \\___| \\___/ _| _| \\__,_| \\__,_|\n\nimport sys\nimport math\nimport operator as op\nfrom functools import reduce\n\n## I/O ##\ndef read_line():\n return sys.stdin.readline()[:-1]\n \ndef read_int():\n return int(sys.stdin.readline())\n \ndef read_int_line():\n return [int(v) for v in sys.stdin.readline().split()]\n\ndef read_float_line():\n return [float(v) for v in sys.stdin.readline().split()]\n## ##\n\n## ncr ##\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## Fenwick Tree ##\nN = int(1e6)+10\nfenwick = [0]*N\n\ndef add(i,x,n):\n\twhile i=0:\n\t\tres += fenwick[i]\n\t\ti = (i&(i+1))-1\n\treturn res\n\ndef fsum_range(i,j,n):\n\treturn fsum(j,n)-fsum(i-1,n)\n## ##\t\n\n## Main ##\n\nmod = int(1e9)+7\n\n# t = read_int()\nt = 1\nfor i in range(t):\n\tn, k, d = read_int_line()\n\tdp = [[0,0] for i in range(n+1)]\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n+1):\n\t\tfor j in range(1,min(d-1,i)+1):\n\t\t\tdp[i][0] += dp[i-j][0]\n\t\tfor j in range(1,min(d-1,i)+1):\n\t\t\tdp[i][1] += dp[i-j][1]\n\t\tfor j in range(d,min(k,i)+1):\n\t\t\tdp[i][1] += (dp[i-j][0]+dp[i-j][1])\n\n\tprint(dp[n][1]%mod)"}, {"source_code": "inputs = [int(x) for x in input().split()]\n \ndesired_weight = inputs[0]\nk = inputs[1]\nmin_weight = inputs[2]\n\n# desired_weight = 38\n# k = 16\n# min_weight = 15\n# \n\n# desired_weight = 3\n# k = 3\n# min_weight = 3\n\nsaved = [{True: None, False: None} for i in range(desired_weight + 1)]\nsaved[desired_weight] = {True: 0, False: 0}\n\nmodulo = 1000000007\n\nfor i in reversed(range(0, desired_weight)):\n# print('*** ' + str(i) + ' ***')\n range_to_work_with = i + k\n hit_min_value = 0\n fail_to_hit_min_value = 0\n\n \n travel_range = range(i + 1, i + k + 1 if i + k + 1 <= desired_weight + 1 else desired_weight + 1)\n# print(travel_range)\n for j in travel_range:\n if j - i >= min_weight:\n fail_to_hit_min_value += saved[j][True]\n else:\n fail_to_hit_min_value += saved[j][False]\n fail_to_hit_min_value += 1 if desired_weight - i <= k and desired_weight - i >= min_weight else 0\n \n for j in travel_range:\n hit_min_value += saved[j][True]\n hit_min_value += 1 if desired_weight - i <= k else 0\n \n saved[i][True] = hit_min_value\n saved[i][False] = fail_to_hit_min_value\n \n\n# print(saved) \nprint(saved[0][False] % modulo)"}, {"source_code": "[n, k, d] = map(int, raw_input().split())\n\ndef F(n, x):\n\tf = [1] + [0] * n\n\tfor i in range(1, n + 1):\n\t\tf[i] = sum(f[max(i - x, 0) : i])\n\treturn f[n]\n\nprint (F(n, k) - F(n, d - 1)) % (10 ** 9 + 7)\n"}, {"source_code": "def main():\n n, k, d = map(int, raw_input().split())\n mod = 10 ** 9 + 7\n dp = [[0] * 201, [0] * 201]\n dp[0][0] = 1\n ans = 0\n for i in xrange(n):\n ndp = [[0] * 201, [0] * 201]\n for j in xrange(1, d):\n for l in xrange(n):\n for b in [0, 1]:\n ndp[b][l+j] += dp[b][l]\n if ndp[b][l+j] >= mod:\n ndp[b][l+j] -= mod\n for j in xrange(d, k+1):\n for l in xrange(n):\n ndp[1][l+j] += dp[0][l] + dp[1][l]\n if ndp[1][l+j] >= mod:\n ndp[1][l+j] -= mod\n if ndp[1][l+j] >= mod:\n ndp[1][l+j] -= mod\n dp = ndp\n ans += dp[1][n]\n if ans >= mod:\n ans -= mod\n print ans\nmain() \n"}, {"source_code": "n,k,d=map(int,input().strip().split(' '))\ndp=[0]*(n+k+1) \nvp=[0]*(n+k+1)\nfor i in range(1,n+1):\n for j in range(1,k+1):\n dp[i]+=dp[i-j] \n if j>=d:\n continue \n else:\n vp[i]+=vp[i-j] \n if i<=k:\n dp[i]+=1 \n if i>=d:\n continue \n else:\n vp[i]+=1 \nprint((dp[n]-vp[n])%(10**9 + 7))"}, {"source_code": "(n, k, d) = map(int, input().split(' '))\n\ndp = [[-1 for i in range(202)] for j in range(2002)]\n\nmod = int(1000000007)\n\ndef f(_sum, ok):\n if dp[_sum][ok] == -1 and _sum < n:\n ans = 0\n for i in range(1, k + 1):\n if ok == 0 and i >= d:\n ans += f(_sum + i, 1)\n else:\n ans += f(_sum + i, ok)\n ans = ans % mod\n dp[_sum][ok] = ans\n return ans\n\n if dp[_sum][ok] != -1 and _sum < n:\n return dp[_sum][ok]\n\n if _sum == n and ok == 1:\n dp[_sum][ok] = 1\n\n if _sum > n:\n dp[_sum][ok] = 0\n\n if _sum == n and ok == 0:\n dp[_sum][ok] = 0\n\n return dp[_sum][ok]\n\nprint(f(0, 0))\n"}, {"source_code": "n,k,d = map(int,raw_input().split())\n\ndp = [[0]*2 for i in range(n+2)]\n\ndp[0][0] = 1\n\nfor i in range(1,n+1):\n\tfor j in range(1,k+1):\n\t\tif j > i :\n\t\t\tbreak\n\t\tif j < d :\n\t\t\tdp[i][0] = (dp[i-j][0]+dp[i][0])%1000000007\n\t\t\tdp[i][1] = (dp[i-j][1]+dp[i][1])%1000000007\n\t\telse :\n\t\t\tdp[i][1] = (dp[i-j][0]+dp[i][1])%1000000007\n\t\t\tdp[i][1] = (dp[i-j][1]+dp[i][1])%1000000007\n\t\nprint dp[n][1]"}, {"source_code": "n,k,d = map(int,input().split())\n\nmod = 10**9 + 7\nmemo = {}\n\ndef DFS(hasD = False, totalSum=n):\n\n global memo\n c=0\n startD = hasD\n\n for i in range(1,k+1):\n\n hasD = startD\n if i >= d:\n hasD = True\n\n if totalSum - i == 0:\n if hasD:\n c+=1\n break\n\n if (hasD,totalSum-i) not in memo:\n memo[(hasD,totalSum-i)]=DFS(hasD,totalSum-i)\n c+=memo[(hasD,totalSum-i)]\n\n return c%mod\n\nprint(DFS())\n"}, {"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# 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,k,d = get_ints()\nw = [0]*(n+1)\nwot = [0]*(n+1)\n\nfor i in range(1,n+1):\n if i<=k:\n w[i] = 1\n if i= d else 0] % p) % p\nprint(f[n][0])\n\n# h() is the top-down recursive approach to f\n@functools.lru_cache(None)\ndef h(s, e):\n if s == 0:\n return 1 if e else 0\n \n # e is True if there exists some edge with weight at least d\n total = 0\n for w in range(1, min(s, k) + 1):\n total += h(s - w, e or w >= d)\n return total % p\n\n#print(h(n, False))\n\n# Or we could define f(s) to be the number of paths with total weight s without\n# any restriction on the edge weight. And define g(s) to be only those with edge\n# weight < d. Then the answer is f(s) - g(s)\n@functools.lru_cache(None)\ndef f(s):\n if s == 0:\n return 1\n \n total = 0\n for w in range(1, k + 1):\n if w > s:\n break\n total += f(s - w)\n return total % p\n\n@functools.lru_cache(None)\ndef g(s):\n if s == 0:\n return 1\n total = 0\n for w in range(1, min(d, k + 1)):\n if w > s:\n break\n total += g(s - w)\n return total % p\n\n#print((f(n) - g(n)) % p)\n\n"}, {"source_code": "from sys import stdin\n\n\ndef calculate_main(n, k, mod):\n\tdp = [0] *(n + 1)\n\tdp[0] = 1; dp[1] = 1\n\tfor i in range(2, n + 1):\n\t\tfor j in range(i - 1, max(- 1, i - k - 1), - 1):\n\t\t\tdp[i] += dp[j]\n\t\t\tdp[i] %= mod\n\t\t\n\treturn dp\n\t\n\t\n\n# main starts\nn, k, d = list(map(int, stdin.readline().split()))\nmod = 10 ** 9 + 7\ndp = calculate_main(n, k, mod)\n#print(dp)\ndp2 = [0] * (n + 1)\n\nfor i in range(d, n + 1):\n\tfor j in range(1, min(k + 1, i + 1)):\n\t\tif j < d:\n\t\t\tdp2[i ] += dp2[i - j]\n\t\t\tdp2[i ] %= mod\n\t\telse:\n\t\t\tdp2[i] += dp[i - j]\n\t\t\tdp2[i] %= mod\n#print(dp2)\n\nprint((dp2[n])% mod)"}, {"source_code": "n, k, d = map(int, input().split())\nv = [1] #all\nfor i in range(1,n+1):\n s = 0\n for j in range(max(0, i-k),i):\n s += v[j]\n v.append(s)\na = [1] #except\nfor i in range(1,n+1):\n s = 0\n for j in range(max(0,i-d+1),i):\n s+=a[j]\n a.append(s)\nprint((v[len(v)-1]-a[len(a)-1])%1000000007)"}, {"source_code": "n, k, d = map(int, input().split())\na = [1]\nb = [0]\nfor i in range(1, n + 1):\n a.append(sum(a[max(i - d + 1, 0):]))\n b.append(sum(a[max(i - k, 0):max(i - d + 1, 0)]) + sum(b[max(i - k, 0):]))\nprint(b[n] % (10**9+7))"}, {"source_code": "n, k, d = map(int, input().split())\nN = 10 ** 9 + 7\nmatrix = [[0 for x1 in range(k + 1)] for x2 in range(n + 1)]\nmatrix[0][0] = 1\n\nfor s in range(0, n):\n for l in range(1, k + 1):\n if s + l > n:\n break\n for ml in range(0, k + 1):\n matrix[s + l][max(ml, l)] += matrix[s][ml]\n matrix[s + l][max(ml, l)] %= N\n\nprint(sum(matrix[-1][d:]) % N)\n"}, {"source_code": "# |\n# _` | __ \\ _` | __| _ \\ __ \\ _` | _` |\n# ( | | | ( | ( ( | | | ( | ( |\n# \\__,_| _| _| \\__,_| \\___| \\___/ _| _| \\__,_| \\__,_|\n\nimport sys\nimport math\nimport operator as op\nfrom functools import reduce\n\n## I/O ##\ndef read_line():\n return sys.stdin.readline()[:-1]\n \ndef read_int():\n return int(sys.stdin.readline())\n \ndef read_int_line():\n return [int(v) for v in sys.stdin.readline().split()]\n\ndef read_float_line():\n return [float(v) for v in sys.stdin.readline().split()]\n## ##\n\n## ncr ##\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## Fenwick Tree ##\nN = int(1e6)+10\nfenwick = [0]*N\n\ndef add(i,x,n):\n\twhile i=0:\n\t\tres += fenwick[i]\n\t\ti = (i&(i+1))-1\n\treturn res\n\ndef fsum_range(i,j,n):\n\treturn fsum(j,n)-fsum(i-1,n)\n## ##\t\n\n## Main ##\n\nmod = int(1e9)+7\n\n# t = read_int()\nt = 1\nfor i in range(t):\n\tn, k, d = read_int_line()\n\tdp = [[0,0] for i in range(n+1)]\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n+1):\n\t\tfor j in range(1,min(d-1,i)+1):\n\t\t\tdp[i][0] += dp[i-j][0]\n\t\tfor j in range(1,min(d-1,i)+1):\n\t\t\tdp[i][1] += dp[i-j][1]\n\t\tfor j in range(d,min(k,i)+1):\n\t\t\tdp[i][1] += (dp[i-j][0]+dp[i-j][1])\n\n\tprint(dp[n][1]%mod)"}, {"source_code": "\ndef dp(n,k,d,f,m):\n\n if (n == 0):\n if (f == True):\n return 1\n return 0\n if (n < 0):\n return 0\n if (m[n][f] != -1):\n return m[n][f]\n\n res = 0\n\n for i in range(1,k+1):\n if (i >= d):\n res += dp(n-i,k,d,f | True,m)\n else:\n res += dp(n-i,k,d,f | False,m)\n\n m[n][f] = res % 1000000007\n\n return m[n][f]\n\n\nif __name__ == '__main__':\n n, k, d = [int(x) for x in input().split()]\n m = [[-1,-1] for _ in range(n+1)]\n print(dp(n,k,d,False,m))"}, {"source_code": "I=lambda : list(map(int,input().split(' ')))\ndef path(total,num):\n if total in mem:\n return mem[total]\n if total==0:\n return 1\n else:\n mem[total]=0\n for i in range(1,num+1):\n if total-i>=0:\n mem[total]+=path(total-i,num)\n else:\n break\n return mem[total]\n \ndef ans(n,k,d):\n global mem\n mem={}\n a=path(n,k)\n if d>1:\n mem={}\n b=path(n,d-1)\n else:\n b=0\n return a-b\nn,k,d=I()\nprint(ans(n,k,d)%int(10**9+7))"}, {"source_code": "x=map(int,raw_input().split(' '))\npath=x[0]\ntree=x[1]\nd=x[2]\ndp=[[0 for x in range(2)] for x in range(200)]\ndp[0][1]=1\ndp[0][0]=1\nfor i in range(1,path+1):\n for j in range(1,min(tree,d-1)+1):\n if i=d:\n dp[i][1]+=dp[i-j][0]+dp[i-j][1]\n else:\n dp[i][1]+=dp[i-j][1]\n dp[i][0]%=mod \n dp[i][1]%=mod \nprint(dp[n][1]) "}, {"source_code": "import random\nimport sys\nQ = 10 ** 9 + 7\nn, k, d = map(int, input().split())\ndp = [0] * 105\ndp1 = [0] * 105\ndp[0] = 1\ndp1[0] = 1 \nfor i in range(1, n + 1):\n for j in range(max(0, i - k), i):\n dp[i] = (dp[i] + dp[j]) % Q\n for j in range(max(0, i - d + 1), i):\n dp1[i] = (dp1[i] + dp1[j]) % Q\nprint((dp[n] - dp1[n] + Q) % Q)"}, {"source_code": "(n, k, d) = map(int, input().split(' '))\n\ndp = [[-1 for i in range(202)] for j in range(2002)]\n\nmod = int(1000000007)\n\ndef f(_sum, ok):\n if dp[_sum][ok] == -1 and _sum < n:\n ans = 0\n for i in range(1, k + 1):\n if ok == 0 and i >= d:\n ans += f(_sum + i, 1)\n else:\n ans += f(_sum + i, ok)\n ans = ans % mod\n dp[_sum][ok] = ans\n return ans\n\n if dp[_sum][ok] != -1 and _sum < n:\n return dp[_sum][ok]\n\n if _sum == n and ok == 1:\n dp[_sum][ok] = 1\n\n if _sum > n:\n dp[_sum][ok] = 0\n\n if _sum == n and ok == 0:\n dp[_sum][ok] = 0\n\n return dp[_sum][ok]\n\nprint(f(0, 0))\n"}, {"source_code": "n, k, d = map(int,input().split())\nz = [[1], [1]]\nfor i in range(1, n + 1):\n z[0].append(sum(z[0][max(i-d+1, 0):]))\n z[1].append(sum(z[1][max(i-k, 0):]))\nprint((z[1][-1] - z[0][-1]) % (10**9+7))\n"}, {"source_code": "input_ = list(map(int,input().split()))\nn, k ,d = input_[0], input_[1], input_[2]\n\n'''\ndef opt_tree(n,k,d):\n\tif d > n or n <= 0:\n\t\treturn 0\n\tif n == 1 :\n\t\treturn 1\n\tif d == n:\n\t\treturn 1\n\treturn sum([opt_tree(n-i, k, (d-i)*(i>=d) + d*(i i :\n\t\t\tdp[i][j] = 0\n\t#case 2\n\tif dp[1][j] == 'None':\n\t\tdp[1][j] = 1\n\t# case 3\n\tfor i in range(min(d+1,n+1)):\n\t\tif dp[i][i] == 'None':\n\t\t\tdp[i][i] = 1\n\n#main step\nfor n_temp in range(1,n+1):\n\tfor d_temp in range(d+1):\n\t\tif dp[n_temp][d_temp] == 'None':\n\t\t\tdp[n_temp][d_temp] = sum([dp[n_temp -i][((d_temp-i)*(i>=d_temp) + d_temp*(i=d_temp) + d_temp*(i=0)] for i in range(1,min([k+1,n_temp+1]))] ) + (n_temp <= k)\n\n\n\nprint(dp[n][d]%(10**9+7))\n"}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n for i in range (1, min(N, K)+1):\n a[i] = sum (a[0:i])\n if N > K:\n for x in range(K+1,N+1):\n a[x] = sum(a[x-K: x])\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = (w(n, k)-w(n, g-1)) % (10**9+7)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "import sys\nimport math\ninput = sys.stdin.readline\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef helper(rem, found):\n if rem == 0:\n if found:\n return 1\n return 0\n\nhash_map = {}\n\n\ndef solve(n, found):\n if n == 0:\n if found:\n return 1\n return 0\n if (n, found) in hash_map:\n return hash_map[(n, found)]\n count = 0\n for i in range(1, k+1):\n if i > n:\n break\n count += solve(n-i, found | (True if i >= d else False)) % 1000000007\n hash_map[(n, found)] = count % 1000000007\n return count % 1000000007\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n\n print(int(solve(nkd[0], False)))\n"}, {"source_code": "MOD = 10 ** 9 + 7\nHAVE, NOT_HAVE = 1, 0\n\nn, k, d = map(int, input().split())\n\ndp = [[0 for _ in range(n + 1)] for _ in range(2)]\ndp[NOT_HAVE][0] = 1\nfor dist in range(1, n + 1):\n for weight in range(1, k + 1):\n if weight > dist:\n break\n if weight >= d:\n dp[HAVE][dist] += dp[HAVE][dist - weight] + dp[NOT_HAVE][dist - weight]\n dp[HAVE][dist] %= MOD\n else:\n dp[NOT_HAVE][dist] += dp[NOT_HAVE][dist - weight]\n dp[NOT_HAVE][dist] %= MOD\n dp[HAVE][dist] += dp[HAVE][dist - weight]\n dp[HAVE][dist] %= MOD\nprint(dp[HAVE][n])"}, {"source_code": "n,k,d=map(int,input().split())\ndp=[[0 for i in range(2)] for i in range(101)]\ndp[0][0]=1\ndp[0][1]=1\nfor i in range(1,101):\n \n dp[i][0]=sum(dp[j][0] for j in range(i-min(i,d),i))\n if(min(i,d)==d):\n dp[i][0]=dp[i][0]-dp[i-d][0]\n \n \n \n dp[i][1]=sum(dp[j][1] for j in range(i-min(i,k),i))\n \n \n \n \npri=10**9+7\nprint((dp[n][1]-dp[n][0])%(pri))\n"}, {"source_code": "n, k, d = [int(i) for i in raw_input().split()]\nb = [0]*(n+1)\nb[0] = 1\nb[1] = 1\nMOD = 1000000007\nfor i in range(2,n+1):\n\tfor j in range(1,min(k+1, i+1)):\n\t\tb[i] = (b[i] + (b[i-j]))%MOD\na = [0]*(n+1)\na[0] = 1\nif d != 1:\n\ta[1] = 1\nfor i in range(2, n+1):\n\tfor j in range(1, min(k+1, i+1, d)):\n\t\ta[i] = (a[i] + a[i-j])%MOD\nprint (b[n] - a[n])%MOD\n"}, {"source_code": "def count(b,n):\n a = [0]*(n+1)\n m = len(b)\n a[0]=1\n for i in range(1,n+1):\n for j in range(m):\n if(i>=b[j]):\n a[i]+=a[i-b[j]]\n return a[n]\nn,k,d = list(map(int,input().split()))\na = [i for i in range(1,k+1)]\nb = [i for i in range(1,d)]\nprint((count(a,n)-count(b,n))%(10**9+7))\n"}, {"source_code": "nums = map(int, raw_input('').split(' '))\nn, k, d = nums[0], nums[1], nums[2]\nans = [(0, 0)] * 101\n\n\nans[0] = (0, 1)\nfor i in xrange(1, n + 1):\n num_contain = 0\n num_not_contain = 0\n for j in xrange(1, k + 1):\n if (i - j) >= 0:\n num_contain += ans[i - j][0]\n if j >= d:\n num_contain += ans[i - j][1]\n else:\n num_not_contain += ans[i - j][1]\n ans[i] = (num_contain, num_not_contain)\nprint ans[n][0] % 1000000007\n"}, {"source_code": "[n, k, d] = map(int, raw_input().split())\n\ndef F(n, x):\n\tf = [1] + [0] * n\n\tfor i in range(1, n + 1):\n\t\tf[i] = sum(f[max(i - x, 0) : i])\n\treturn f[n]\n\nprint (F(n, k) - F(n, d - 1)) % (10 ** 9 + 7)\n"}, {"source_code": "import functools\n\n_MODER = 1000000007\n\n\ndef solve(n, k, d):\n @functools.lru_cache(None)\n def find_not_yet_d(n):\n if n < d:\n return 0\n\n r = 0\n for i in range(1, min(n, k) + 1):\n if i >= d:\n r += find_used_d(n - i)\n else:\n r += find_not_yet_d(n - i)\n return r % _MODER\n\n @functools.lru_cache(None)\n def find_used_d(n):\n if n == 0:\n return 1\n r = 0\n for i in range(1, min(n, k) + 1):\n r += find_used_d(n - i)\n return r % _MODER\n\n return find_not_yet_d(n) % _MODER\n\n\nn, k, d = map(int, input().split())\nprint(solve(n, k, d))\n"}, {"source_code": "\nimport sys\nsys.setrecursionlimit(2 ** 20)\n\nn, k, d = map(int, raw_input().split())\nways = 0\n\ndp = [ [ -1 for y in xrange(2) ] for x in xrange(n+1) ]\n\ndef getWays(total = 0, got = 0):\n global ways, n, k, d, dp\n \n if total > n :\n return 0\n \n if total == n :\n return got \n \n if dp[total][got] != -1 :\n return dp[total][got]\n \n dp[total][got] = 0\n \n for i in xrange(1, k+1):\n if i >= d :\n dp[total][got] += getWays(total + i, 1)\n else :\n dp[total][got] += getWays(total + i, got)\n \n return dp[total][got]\n\nprint getWays() % 1000000007"}, {"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, pi, sin\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\n@lru_cache(None)\ndef recur(number, flag=False):\n if number > n:\n return 0\n if number == n:\n return int(flag)\n answer = 0\n for temp in arr:\n answer += recur(number + temp, flag or (temp >= d))\n if answer > mod:\n answer -= mod\n return answer % mod\n\n\nn, k, d = sp()\narr = []\nfor i in range(1, k+1):\n arr.append(i)\nout(recur(0))\n"}, {"source_code": "inp = input().split()\nn = int(inp[0])\nk = int(inp[1])\nd = int(inp[2])\n\nif (n < d):\n print(0)\nelse:\n D = [[0 for i in range(n + 1)], [0 for j in range(n + 1)]]\n D[0][0] = 0\n D[1][0] = 0\n for j in range(n):\n #print(j)\n if (j + 1 <= k) and (d <= j + 1):\n D[1][j + 1] = 1\n elif (j + 1 <= k) and (d > j + 1):\n D[0][j + 1] = 1\n #print(D[1][j + 1])\n #print(D[0][j + 1])\n for i in range(d - 1):\n if (j - i - 1>= 0):\n D[1][j + 1] += D[1][j - i]\n D[0][j + 1] += D[0][j - i]\n #print(D[1][j - i])\n #print(D[1][j + 1])\n #print(\"here\")\n else:\n break\n #print()\n for i in range(k - d + 1):\n if (j + 1 - d - i>= 0):\n D[1][j + 1] += D[1][j + 1 - i - d] + D[0][j + 1 - i - d]\n #print(\"here2\")\n else:\n break\n print(D[1][n] % 1000000007)"}, {"source_code": "import 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\nmemoi=functools.lru_cache(None)\ntcid=0\ntcmax=99999999\ndef fast(): 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 f'{val:.{nd}f}'\ndef ceil(a,b):\n ans=a//b\n if a%b!=0: ans+=1\n return ans\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()))\n\"\"\"\nceil(a,b) sround(val,nd) true false null @memoi\nnum(?) nums(?) split(?) lines(n) line()\nperr(print) tcmax seq() compute(v,f) tcid fast()\n\"\"\"\n#{#\n\n#}#\ndef mainloop(tcid=1):\n# {{{\n n,k,d=nums()\n @memoi\n def aaa(nn,dd=false):\n if nn==0:\n return int(dd)\n ans=0\n for xx in seq(1,min(nn,k)):\n aa=aaa(nn-xx,dd or xx>=d)\n ans=(ans+aa)%(10**9+7)\n return ans\n ans=aaa(n)\n print(ans)\n# }}}\nwhile tcid= k:\n sub=dp[cur]\n cur+=1\n su-=sub\n # print dp[i],i,su\n return dp[n]\n\nn,k,d = map(int,raw_input().split(' '))\nprint (check(n,k)-check(n,d-1))%1000000007\n"}, {"source_code": "n,k,d = input().split()\nn,k,d = int(n),int(k),int(d)\n\nans1 = [0 for _ in range(101)]\nans1[0] = 1\n\nans = [0 for _ in range(101)]\nfor i in range(d):\n ans[i] = 0\n\nfor i in range(0,n + 1):\n j = 1\n while j <= k and i - j >= 0:\n ans1[i] += ans1[i - j]\n j += 1\n \n \nfor i in range(d,n + 1):\n j = 1\n while j <= k and i - j >= 0:\n if j >= d:\n ans[i] += ans1[i - j]\n else: ans[i] += ans[i - j]\n j += 1\nprint(ans[n] % 1000000007)\n \n \n"}, {"source_code": "L = map(int,raw_input().split())\nn,k,d = L[0],L[1],L[2]\nmod = 1000000007\n \n \ndp = [[0 for j in range(2)] for i in range(n+1)]\n \ndp[0][0] = 1\ndp[0][1] = 0\n\nfor i in range(1,n+1):\n\tfor j in range(1,k+1):\n\t\tif i-j<0: break\n\t\tif j < d:\n\t\t\tdp[i][0] = (dp[i][0] + dp[i-j][0])%mod\n\t\t\tdp[i][1] = (dp[i][1] + dp[i-j][1])%mod\n\t\telse:\n\t\t\tdp[i][1] = (dp[i][1] + dp[i-j][0] + dp[i-j][1])%mod\n\nans = dp[n][1]%mod\n\nprint(ans)"}, {"source_code": "n, k, d = input().split()\n\nn = int(n)\nk = int(k)\nd = int(d)\n\ndp = [[0 for i in range(n + 1)] for j in range(k + 1)]\n\nfor i in range(k + 1):\n dp[i][0] = 1\n\nfor j in range(1, n + 1):\n for i in range(1, k + 1):\n dp[i][j] = sum(dp[i][max(0, j - i):j + 1])\n\nprint((dp[k][n] - dp[d - 1][n])%(10**9 + 7))"}, {"source_code": "n, k, d = map(int, input().split())\n\na = [1]\nb = [0]\nfor i in range(1, n + 1):\n a.append(sum(a[max(i - d + 1, 0):]))\n b.append(sum(a[max(i - k, 0):max(i - d + 1, 0)]) + sum(b[max(i - k, 0):]))\n #print (a)\n #print (b)\nprint(b[n] % (10**9+7))"}, {"source_code": "n, k, d = map(int, input().split())\nb=10**9+7\nways = [0] * (n + 1)\nways.insert(0, 0)\nj = 1\ns = 0\nwhile (j <= min(k,n)):\n ways[j] = 1\n j += 1\ns += ways[n]\nfor i in range(2, n + 1):\n new_ways = [0] * (n + 1)\n for j in range(1, n + 1):\n for p in range(1, k + 1):\n if (j + p) <= n:\n new_ways[j + p] += ways[j]\n ways = []\n for j in new_ways:\n ways.append(j)\n s += (ways[n])\n s=s%b\nways = [0] * (n + 1)\nways.insert(0, 0)\nj = 1\nr = 0\nwhile (j <= min(d-1,n)):\n ways[j] = 1\n j += 1\nr += ways[n]\nfor i in range(2, n + 1):\n new_ways = [0] * (n + 1)\n for j in range(1, n + 1):\n for p in range(1, d):\n if (j + p) <= n:\n new_ways[j + p] += ways[j]\n ways = []\n for j in new_ways:\n ways.append(j)\n r += (ways[n])\n r=r%b\n\nprint((s - r)%b)"}, {"source_code": "[n, k, d] = map(int, raw_input().split())\n\ndef F(n, x):\n\tf = [1] + [0] * n\n\tfor i in range(1, n + 1):\n\t\tf[i] = sum(f[max(i - x, 0) : i])\n\treturn f[n]\n\nprint (F(n, k) - F(n, d - 1)) % (10 ** 9 + 7)\n"}, {"source_code": "n,k,d = input().split()\nn,k,d = int(n),int(k),int(d)\n\nans1 = [0 for _ in range(101)]\nans1[0] = 1\n\nans = [0 for _ in range(101)]\nfor i in range(d):\n ans[i] = 0\n\nfor i in range(0,n + 1):\n j = 1\n while j <= k and i - j >= 0:\n ans1[i] += ans1[i - j]\n j += 1\n \n \nfor i in range(d,n + 1):\n j = 1\n while j <= k and i - j >= 0:\n if j >= d:\n ans[i] += ans1[i - j]\n else: ans[i] += ans[i - j]\n j += 1\nprint(ans[n] % 1000000007)\n \n \n"}, {"source_code": "n, k, d = map(int, input().split())\nM = 1000000007\na = [1] + [0] * n\nfor i in range(1, n + 1):\n for j in range(max(0, i - k), i):\n a[i] = (a[i] + a[j]) % M\n# print(a)\nb = [1] + [0] * n\nfor i in range(1, n + 1):\n for j in range(max(0, i - d + 1), i):\n b[i] = (b[i] + b[j]) % M\n# print(b)\nprint((a[n] - b[n]) % M)"}, {"source_code": "n, k, d = map(int, raw_input().split(' '))\n\ndef different_paths(n, k, d):\n M = 1000000007\n cache = {}\n if d > k:\n return 0\n\n def find(n, flag):\n if n < 0:\n return 0\n elif n == 0:\n return 0 if flag else 1\n elif (n, flag) in cache:\n return cache[(n, flag)]\n else:\n s = 0\n if not flag:\n s = sum([find(n - i, False) for i in range(1, k + 1)])\n else:\n for i in range(1, d):\n s += find(n - i, True)\n for i in range(d, k + 1):\n s += find(n - i, False)\n cache[(n, flag)] = s\n return s\n\n return find(n, True) % M\n\nprint different_paths(n, k, d)"}, {"source_code": "tree = list(map(int,input(\"\").split(\" \")))\n\nn,k,d = tree[0],tree[1],tree[2]\n\ndp = [[0 for i in range(2)] for j in range(n+1)]\n\ndp[0][0] = 1\ndp[0][1] = 0\n\nmod = 1000000007 \n\nfor i in range(1,n+1):\n\tdp[i][0] = 0\n\tdp[i][1] = 0\n\tfor j in range(1,k+1):\n\n\t\tif i - j< 0:\n\t\t\tbreak\n\n\t\tif j >= d:\n\t\t\tdp[i][1] += dp[i-j][0]\n\t\t\tdp[i][1] += dp[i-j][1]\n\n\t\telse:\n\t\t\tdp[i][0] += dp[i-j][0]\n\t\t\tdp[i][1] += dp[i-j][1]\n\nprint(dp[n][1]%mod)"}, {"source_code": "dp = [0] * 101\ndpx = [0] * 101\n\nn,k,d = input().split()\nn = int(n)\nk = int(k) \nd = int(d)\n\ndp[0] = 1 ;\ndpx[0] = 1 ;\n\nfor i in range(1,n+1):\n #print(i)\n for j in range(1, min(i,k) + 1):\n dp[i] = dp[i] + dp[i - j]\n \n \nfor i in range(1,n+1):\n for j in range(1, min(i,d-1) + 1):\n dpx[i] = dpx[i] + dpx[i - j] \n \nprint((dp[n] - dpx[n]) % 1000000007) "}, {"source_code": "import sys,math\nfrom collections import deque\n\nif __name__ == '__main__':\n\t[n,k,d] = map(int,raw_input().split())\n\tdp = [[0]*(500) for _ in range(500)]\n\tdp[0][0]=1;\n\tfor i in range(100):\n\t\tfor j in range(1,k+1):\n\t\t\tfor m in range(2):\n\t\t\t\t#print dp[i+j][1]\n\t\t\t\tdp[i+j][m==1 or j>=d] += dp[i][m]\n\tprint dp[n][1] % (10**9+7)\n\t\n"}, {"source_code": "def tree(k, n):\n tab = [[0 for _ in xrange(k + 1)] for _ in xrange(n + 1)]\n for i in xrange(0, k + 1):\n tab[0][i] = 1\n for i in xrange(1, n + 1):\n tab[i][0] = 0\n for j in xrange(1, k + 1):\n if (i < j):\n tab[i][j] = tab[i][j - 1]\n else:\n tab[i][j] = (tab[i][j - 1] + tab[i - j][k]) % modulo\n return tab[n][k]\n \nn, k, d = map(int, raw_input().split())\nmodulo = 1000000007\n\nif (d < 2):\n print tree(k, n)\nelse:\n print (tree(k, n) - tree(d - 1, n)) % modulo"}, {"source_code": "import math\nn,k,d = map(int,raw_input().split())\ns = [[0,0] for _ in xrange(n+1)]#0-->=d 1-->= arr[j]) and arr[j]= arr[j]): \n count[i] += count[i - arr[j]]\n count[i]%=mod\n return count[N]\nn,k,d = map(int,input().split())\na = [i for i in range(1,k+1)]\nt1 = countWays(a,len(a),n,d)\nt2 = countWays1(a,len(a),n)\nprint((t2-t1+mod)%mod)"}, {"source_code": "n, k, d = map(int, input().split())\ndone = {}\n\n\ndef num_pos(i, d_in):\n if (i, d_in) in done:\n return done[(i, d_in)]\n if i == 0 and d_in:\n return 1\n if i == 0:\n return 0\n pos = 0\n for v in range(1, k+1):\n if v > i:\n break\n pos += num_pos(i - v, d_in or v >= d)\n done[(i, d_in)] = pos\n return pos\n\n\nprint(num_pos(n, False) % 1000000007)\n"}, {"source_code": "n,k,d = map(int,raw_input().split())\nmod = 1000000007\na = []\nfor i in range(n+1):\n a.append([0,0])\n \na[0][0] = 1\n\nfor i in range(1,n+1):\n for j in range(max(0,i-k),i):\n if (i-j>=d):\n a[i][1]+=a[j][1]\n a[i][1]+=a[j][0]\n a[i][1]%=mod\n \n else:\n a[i][0]+=a[j][0]\n a[i][1]+=a[j][1]\n a[i][0]%=mod\n a[i][1]%=mod\n\nprint a[n][1]"}, {"source_code": "import sys\ninput = sys.stdin.readline\nread_tuple = lambda _type: map(_type, input().split(' '))\n\n\ndef solve():\n n, k, d = read_tuple(int)\n edges = [i for i in range(1, k + 1)]\n cnt_normal = [0 for _ in range(n + 1)]\n cnt_d = [0 for _ in range(n + 1)]\n for i in range(1, n + 1):\n for edge in edges:\n if i == edge:\n cnt_normal[i] += 1\n if edge < d:\n cnt_d[i] += 1\n if i - edge >= 0:\n cnt_normal[i] += cnt_normal[i - edge]\n if edge < d:\n cnt_d[i] += cnt_d[i - edge] \n print((cnt_normal[n] - cnt_d[n]) % 1000000007)\n\nif __name__ == '__main__':\n solve()"}, {"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 = 10**9+7\n\nn,k,d = RI()\nn += 1\ndp0,dp1 = [0]*n,[0]*n\ndp0[0] = 1\n\nfor i in xrange(1,n):\n for j in xrange(1,min(i,k)+1):\n if j n or n <= 0:\n\t\treturn 0\n\tif n == 1 :\n\t\treturn 1\n\tif d == n:\n\t\treturn 1\n\treturn sum([opt_tree(n-i, k, (d-i)*(i>=d) + d*(i i :\n\t\t\tdp[i][j] = 0\n\t#case 2\n\tif dp[1][j] == 'None':\n\t\tdp[1][j] = 1\n\t# case 3\n\tfor i in range(min(d+1,n+1)):\n\t\tif dp[i][i] == 'None':\n\t\t\tdp[i][i] = 1\n\n#main step\nfor n_temp in range(1,n+1):\n\tfor d_temp in range(d+1):\n\t\tif dp[n_temp][d_temp] == 'None':\n\t\t\tdp[n_temp][d_temp] = sum([dp[n_temp -i][((d_temp-i)*(i>=d_temp) + d_temp*(i=d_temp) + d_temp*(i=0)] for i in range(1,min([k+1,n_temp+1]))] ) + (n_temp <= k)\n\n\n\nprint(dp[n][d]%(10**9+7))\n"}, {"source_code": "\nN = 105\n\ndp = [[0 for _1 in range(N)] for _2 in range(N)]\nmod = 1000000007\n\ndef read():\n return map(int, raw_input().strip().split())\n\ndef main():\n n, k, d = read()\n dp[0][0] = 1\n for i in range(1, n+1):\n for j in range(1, min(d-1, i)+1):\n #print i, i-j\n dp[i][0] += dp[i-j][0]\n # if dp[i][0] >= mod: dp[i][0] %= mod\n dp[i][1] += dp[i-j][1]\n # if dp[i][1] >= mod: dp[i][1] %= mod\n for j in range(d, min(i, k)+1):\n dp[i][1] += (dp[i-j][0] + dp[i-j][1])\n # if dp[i][1] >= mod: dp[i][1] %= mod\n \n print dp[n][1] % mod\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "#!/usr/bin/python\n\ndef memoize(f):\n cache= {}\n def memf(*x):\n if x not in cache:\n cache[x] = f(*x)\n return cache[x]\n return memf\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\ndef Ns(): return tuple(map(int, sys.stdin.readline().split()))\n\nn, k, d = Ni()\nM = 10**9 + 7\n\n@memoize\ndef count(n, haveD):\n #print n, haveD\n if n == 0:\n if haveD:\n return 1\n else:\n return 0\n\n s = 0\n for i in range(1, min(n, k) + 1):\n s = (s + count(n - i, haveD or i >= d)) % M\n\n return s\n\nprint count(n, False)\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\nMOD = 10**9 + 7\ndef rec(s,f):\n\tif s<0:\n\t\treturn 0\n\tif s==0:\n\t\tif f==1:\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn 1\n\tans = 0\n\tif dp[s][f]!=-1:\n\t\treturn dp[s][f]\n\tfor i in range(1,k+1):\n\t\tif i K:\n x = K+1\n while x <= N:\n a[x] = sum(a[x-K: x])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g-1)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "n, k, d = map(int, input().split())\nf, g, d = [0] * (n + 1), [1] * (n + 1), 1 - d\nfor i in range(1, n + 1):\n f[i] = sum(g[j] for j in range(max(0, i - k), d + i)) + sum(f[j] for j in range(max(0, d + i), i))\n g[i] = sum(g[j] for j in range(max(0, i - k), i))\nprint(f[n])"}, {"source_code": "n, k, d = map(int, input().split())\nv = [1] #all\nfor i in range(1,n+1):\n s = 0\n for j in range(max(0, i-k),i):\n s += v[j]\n v.append(s)\na = [1] #except\nfor i in range(1,n+1):\n s = 0\n for j in range(max(0,i-d+1),i):\n s+=a[j]\n a.append(s)\nprint(v[len(v)-1]-a[len(a)-1])"}, {"source_code": "n,v,d=list(map(int,input().split()))\ndp=[[0]*2 for i in range(n+1)]\ndp[0][0]=1\nfor i in range(1,n+1):\n for k in range(1,min(i,v)+1):\n dp[i][0]+=dp[i-k][0]\n if k>=d:\n dp[i][1]+=dp[i-k][0]\n else:\n dp[i][1]+=dp[i-k][1]\nprint(dp[n][1])\n "}, {"source_code": "rem=10**9+7\ndef help(n,k):\n arr=[1]*(n+1)\n arr[1]=1\n for i in range(2,n+1):\n s=0\n j=i\n while(j>0):\n if j<=k:\n s=(s+arr[i-j])%rem\n j-=1\n arr[i]=s%rem\n return arr\n#n,k,d=map(int,raw_input().split())\ndef pun(n,p):\n #print p\n arr = [1] * (n + 1)\n arr[1] = 1\n for i in range(2, n + 1):\n s = 0\n j = i\n while (j > 0):\n if j n: continue\n dp[i+1][j+p][k] += dp[i][j][k]\n if dp[i+1][j+p][k] >= mod: dp[i+1][j+p][k] %= mod\n for p in range(k, m+1):\n if j+p > n: continue\n dp[i+1][j+p][p] += dp[i][j][k]\n if dp[i+1][j+p][k] >= mod: dp[i+1][j+p][p] %= mod\n \n sum = 0\n #print dp[2][n][3]\n for i in range(1, N):\n for j in range(d, m+1):\n sum += dp[i][n][j]\n if sum >= mod: sum %= dp[i][n][j]\n print sum % mod\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "n, k, d = map(int, raw_input().split())\na = [1]\nb = [0]\nfor i in range(n):\n b.append(sum(a[-k:1-d]) + sum(b[1-d:]))\n a.append(sum(a[-k:]))\nprint b[n]\n"}, {"source_code": "# python3\n\n##=====================================================\nfrom sys import stdin, stdout\nfrom collections import defaultdict, Counter\nfrom functools import lru_cache\nfrom math import gcd, floor, ceil\n \ndef ilist():\n return [int(x) for x in stdin.readline().strip().split(\" \")]\ndef iint():\n return int(stdin.readline().strip())\ndef istr():\n return stdin.readline().strip()\n##=====================================================\n\n\n# Return the number of ways to get n using 1, 2, ..., k.\ndef solve(n, k):\n dp = [0] * (n + 1)\n dp[0] = 1\n dp[1] = 1\n for i in range(2, n+1):\n for j in range(1, k+1):\n if i-j >= 0:\n dp[i] += dp[i-j]\n return dp[n]\n\n\nif __name__ == '__main__':\n n, k, d = ilist()\n print((solve(n, k) - solve(n, d-1)) % 1000_000_007)\n"}, {"source_code": "import sys\nsys.setrecursionlimit(999999999)\ndef solve(n,k,d,flag):\n if (n,k,d,flag) in dp:\n return dp[(n,k,d,flag)]\n if n==0:\n if flag:\n dp[(n,k,d,flag)]=1\n else:\n dp[(n,k,d,flag)]=0\n else:\n dp[(n,k,d,flag)]=0\n if flag:\n for i in xrange(1,k+1):\n if n-i>=0:\n dp[(n,k,d,flag)]+=solve(n-i,k,d,flag)\n else:\n for i in xrange(1,d):\n if n-i>=0:\n dp[(n,k,d,flag)]+=solve(n-i,k,d,False)\n for i in xrange(d,k+1):\n if n-i>=0:\n dp[(n,k,d,flag)]+=solve(n-i,k,d,True)\n return dp[(n,k,d,flag)]\nn,k,d=map(int,raw_input().split())\ndp={}\nprint solve(n,k,d,False)\n"}, {"source_code": "n,k,d=[int(i) for i in input().split(' ')]\ndp=[[0,0] for i in range(n+1)]\ndp[1]=[1,0] if d==1 else [0,1]\nfor i in range(2,n+1):\n for j in range(1,i):\n if i-j<=k:\n dp[i][0]+=dp[j][0]\n dp[i][0]+=dp[j][1] if i-j>=d else 0\n dp[i][1]+=dp[j][1] if i-j=d else 0\nans=0\n\ndp[-1][0]%(10**9+7)"}, {"source_code": "H = {}\ndef rec(n,k,d,cd):\n #print n,cd\n\n\n if cd == True and n == 0:\n return 1\n if n < 0:\n return 0\n if cd == False and n < d:\n return 0\n if (n,k,d,cd) in H:\n return H[(n,k,d,cd)]\n\n \n total = 0\n for i in range(1, min(k+1,n+1) ):\n if i>= d:\n total += rec(n-i,k,d,True)\n else:\n total += rec(n-i,k,d,cd)\n H[(n,k,d,cd)] = total\n return total\n \n\ndef main():\n n,k,d = [int(i) for i in raw_input().split(\" \")]\n modp = 1000000007\n\n print rec(n,k,d,False) \n \n \n \n \n \n \n \n \n \n \n \n \n \n \nmain()"}, {"source_code": "n, k, d = input().split()\nn = int(n)\nk = int(k)\nd = int(d)\n\nmodule = 10 ** 9 + 7\n\ndef f(n, d):\n if n - d < 0:\n return 0\n else:\n ans = n - d + 1\n for i in range(2, d + 1):\n ans += f(n - d, d)\n return ans\n\nans = 0\nfor dd in range(d, k + 1):\n ans = (ans + f(n, dd)) % module\nprint(ans)"}, {"source_code": "inputs = [int(x) for x in input().split()]\n \ndesired_weight = inputs[0]\nk = inputs[1]\nmin_weight = inputs[2]\n\n# desired_weight = 38\n# k = 16\n# min_weight = 15\n# \n# # desired_weight = 4\n# # k = 5\n# # min_weight = 2\n\nsaved = [{True: None, False: None} for i in range(desired_weight + 1)]\nsaved[desired_weight] = {True: 0, False: 0}\n\nmodulo = 1000000007\n\nfor i in reversed(range(0, desired_weight)):\n range_to_work_with = desired_weight - i \n hit_min_value = 0\n fail_to_hit_min_value = 0\n for j in range(1, range_to_work_with + 1):\n if j >= min_weight:\n fail_to_hit_min_value += saved[i + j][False]\n else:\n fail_to_hit_min_value += saved[i + j][True]\n fail_to_hit_min_value += 1 if desired_weight - i <= k and desired_weight - i >= min_weight else 0\n \n for j in range(1, range_to_work_with + 1):\n hit_min_value += saved[i + j][True]\n hit_min_value += 1 if desired_weight - i <= k else 0\n \n saved[i][True] = hit_min_value\n saved[i][False] = fail_to_hit_min_value\n \n\n# count = get_count(0, False)\n \nprint(saved[0][False] % modulo)\n "}, {"source_code": "mem = [[-1 , -1] for x in range(0 , 103)]\n\nn , k , d = map(int , input().split())\n\ndef dp(remain,has_d):\n if remain == 0:\n return has_d\n if remain < 0:\n return 0\n if mem[remain][has_d] != -1:\n return mem[remain][has_d]\n mem[remain][has_d] = 0\n for i in range(1 , min(remain,k)+1):\n if i >= d :\n mem[remain][has_d] += dp(remain - i , 1)\n else :\n mem[remain][has_d] += dp(remain - i , has_d)\n return mem[remain][has_d]\n\nprint (dp(n,0))\n"}, {"source_code": "n,k,d=map(int,input().split())\ndp=[[0 for i in range(2)] for i in range(101)]\ndp[0][0]=1\ndp[0][1]=1\nfor i in range(1,101):\n for j in range(min(i,d)):\n dp[i][0]+=dp[j][0]\n\n for j in range(min(i,k)):\n dp[i][1]+=dp[j][1]\n \nprint((dp[n][1]-dp[n][0]+1)%(10**9+7)) \n"}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n d = 1\n i = 1\n while i <= min(N, K):\n a[i] = d\n d += a[i]\n i += 1\n if N > K:\n x = K+1\n while x <= N:\n a[x] = sum(a[1: K+1])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "\ndef main():\n n,k,d = list(map(int, raw_input().split()))\n #n,k,d = 4,3,2\n dp = [[0, 0] for j in range(n+1)]\n dp[0][0] = 1\n for i in range(1,n+1):\n for j in range(1,d):\n if i-j >= 0:\n dp[i][0] += dp[i-j][0]\n #dp[i][0] = dp[i-1][0]+dp[i-2][0]+...+dp[i-d+1][0]\n for j in range(1,d):\n if i-j >= 0:\n dp[i][1] += dp[i-j][1]\n for j in range(d,k+1):\n dp[i][1] += dp[i-j][0]+dp[i-j][1]\n #dp[i][1] = dp[i-1][1]+...+dp[i-d+1][1] \\\n # +dp[i-d][0]+dp[i-d][1]+...+dp[i-k][0]+dp[i-k][1]\n \n print(dp[n][1] % 1000000007)\n\nif __name__ == '__main__':\n main()\n\n \n \n\n"}, {"source_code": "def admod(a,b):\n a+=b\n if a>1e9+7:\n a-=1e9+7\n return a\nn,k,d=list(map(int,input().split()))\nDp=[[1,0]]\nfor i in range(1,n+1):\n Dp.append([0,0])\n for j in range (1,k+1):\n if i-j<0: break\n if jlimiter:\n for j in range(1, limiter-1):\n array.append(2**(j))\n leftpointer=0\n rightpointer=limiter-1\n s=sum(array)\n array.append(s)\n for j in range(sum1-limiter-1):\n s-=array[leftpointer]\n s+=array[rightpointer]\n s.append(array)\n leftpointer+=1\n rightpointer+=1\n return array[-1]\n elif sum1<=limiter:\n return 2**(sum1-1)\n\nprint((dp(n,k)-dp(n,d-1)))\n"}, {"source_code": "x = input()\nx = x.split()\nn = int(x[0])\nk = int(x[1])\nd = int(x[2])\nc = int(10e9 + 7)\ndef jie(m, n):\n if (n == m) or (n == 0):\n return 1\n else:\n r = 1\n for i in range(1, m + 1):\n r *= i\n for i in range(1, n + 1):\n r //= int(i)\n for i in range(1, m - n + 1):\n r //= int(i) \n return int(r)\ndef pai(l):\n s = 1\n n = sum(l[i] for i in range(k))\n for i in range(k):\n s = s * jie(n, l[i])\n n = n - l[i]\n if n == 0:\n break\n return s\ndef tree(n, k, maxt, mint, m, l):\n if n == 0: \n m = (m + pai(l)) % c\n else:\n for i in range(maxt, mint - 1, -1):\n if i <= n:\n l[i - 1] += 1\n m = tree(n - i, k, i, 1, m, l)\n l[i - 1] -= 1\n return m\nl = []\nfor i in range(k):\n l.append(0)\nprint(tree(n, k, k, d, 0, l))\n"}, {"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\n\n\n\n\nn,k,d=L()\ndef func(n,A):\n @lru_cache\n def rec(s):\n # print(s)\n if s==0:\n return 1\n if s<0:\n return 0\n ans=0\n for x in A:\n ans+=rec(s-x)\n ans%=mod\n return ans\n return rec(n)\n\n\n\n\nans=func(n,[i for i in range(1,k+1)])\nif d!=1:\n ans-=func(n,[i for i in range(1,d)])\nprint(ans)\n\nendtime = time.time()\n# print(f\"Runtime of the program is {endtime - starttime}\")"}, {"source_code": "from sys import stdin\n\n\n# main starts\nn, k, d = list(map(int, stdin.readline().split()))\ndp = [0] * ( n - d + 1)\n\nmod = 10**9 + 7\nfor i in range(1, n - d + 1):\n\tfor j in range(1, i):\n\t\tdp[i] += dp[j]\n\t\tdp[i] %= mod\n\tif i <= k:\n\t\tdp[i] += 1\n\ns1 = sum(dp) \ns1 %= mod\ndp = [0] * (n + 1 - d)\ndp[0] = 1\nfor i in range(1, n + 1 - d ):\n\tfor j in range(i):\n\t\tdp[i] += dp[j]\n\t\tdp[i] %= mod\n\tif i + d <= k:\n\t\tdp[i] += 1\ns1 += dp[-1]\ns1 %= mod\nprint(s1)"}, {"source_code": "import sys\nfrom random import randint\nfrom time import time\n\nline=map(lambda x:int(x),sys.stdin.readline().strip('\\n').split(\" \"))\nn=line[0]\nk=line[1]\nd=line[2]\n\nnumd=[]\nnum=[1]\nfor i in xrange(1,k):\n num.append(sum(num[0:i])%1000000007)\n #num.append(num[-1]*2%100000007)\nfor i in xrange(0,d):\n numd.append(0)\nfor i in xrange(d,k):\n #print i,numd,num\n numd.append((sum(numd[i-d+1:i])+sum(num[0:i-d+1]))%100000007)\n\n\n#print numd,num\nfor i in xrange(k,n+1):\n numd.append(0)\n for j in xrange(1,d):\n numd[i]=(numd[i]+numd[i-j])%100000007\n for j in xrange(d,k+1):\n numd[i]=(numd[i]+num[i-j])%100000007\n num.append(0)\n for j in xrange(1,k+1):\n num[i]=(num[i]+num[i-j])%100000007\n#print numd,num\nprint numd[n]%100000007\n"}, {"source_code": "\"\"\"\n Satwik_Tiwari ;) .\n 20 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=d\n dp2 = [0]*(n+1) #with >=d\n dp1[0] = 1\n for i in range(1,n+1):\n for c in coin:\n if(i-c >=0):\n if(c >=d):\n dp2[i] += dp2[i-c]\n dp2[i] += dp1[i-c]\n else:\n dp2[i] +=dp2[i-c]\n dp1[i] +=dp1[i-c]\n print(dp2[n])\n\n\n\n\ntestcase(1)\n# testcase(int(inp()))\n"}, {"source_code": "def func(r, k, a) :\n out = 0\n if r <= k:\n out = 2**(r-1)\n else : \n \n for i in range(1,k+1) :\n if i <= r :\n if a[r-i] != -1 :\n out = out + a[r-i]\n else:\n out = out + func(r-i, k, a)\n else :\n break;\n a[r] = out\n return out\n \nn,k,d = map(int, raw_input().split())\nx = [-1]*(n+1)\ny = [-1]*(n+1)\nprint func(n,k,x) - func(n, d-1,y)\n"}, {"source_code": "n, k, d = map(int,input().split())\nf = [0]*(n+k+1)\nf_ = [0]*(n+k+1)\nf_[0] = 1\nfor i in range(1,n+1):\n for j in range(1,k+1):\n f[i] += f[i-j]\n for j in range(d,k+1):\n f[i] += f_[i-j]\n for j in range(1,d):\n f_[i] += f_[i-j]\nprint(f[n])\n "}, {"source_code": "def k_tree(n, k, d, qtd, suma, flag, memo):\n if suma > n:\n return 0\n if(suma == n):\n if flag == 1:\n return qtd+1\n return qtd\n if memo[suma][flag] != -1:\n return memo[suma][flag]\n \n for i in range(1, n+1):\n if i >= d:\n flag = 1\n aux = k_tree(n, k, d, qtd, suma + i, flag, memo)\n flag = 0\n if aux > qtd:\n qtd = aux\n memo[suma][flag] = qtd\n return qtd\n\n#main\nn, k, d = map(int, input().split())\nmemo = [[-1 for i in range(2)] for i in range(n)]\n#print(memo)\nprint(k_tree(n, k, d, 0, 0, 0, memo))\n#print(qtd)\n"}, {"source_code": "n,k,d=map(int,input().split())\nkp=[-1]*(n+1)\ndef CP(m):\n global k\n if m==0:return(0)\n if m==1:return(1)\n if kp[m]!=-1:return(kp[m])\n c=0\n for t in range(1,min(m,k)+1):\n c+=1+CP(m-t)\n c=c%(1000000007)\n \n kp[m]=c\n return(c)\nkc=[-1]*(n+1)\ndef CP2(m):\n global d\n if m==0:return(0)\n if m==1:return(1)\n if kc[m]!=-1:return(kc[m])\n c=0\n for t in range(1,min(m,d-1)+1):\n c+=1+CP(m-t)\n c=c%(1000000007)\n \n kc[m]=c\n return(c)\n\nprint((CP(n)-CP2(n))%1000000007)"}, {"source_code": "#!/usr/bin/python\n\ndef memoize(f):\n cache= {}\n def memf(*x):\n if x not in cache:\n cache[x] = f(*x)\n return cache[x]\n return memf\n\nimport sys\n\ndef Ni(): return tuple(map(int, sys.stdin.readline().split()))\ndef Ns(): return tuple(map(int, sys.stdin.readline().split()))\n\nn, k, d = Ni()\n\n@memoize\ndef count(n, haveD):\n #print n, haveD\n if n == 0:\n if haveD:\n return 1\n else:\n return 0\n\n s = 0\n for i in range(1, min(n, k) + 1):\n s += count(n - i, haveD or i >= d)\n\n return s\n\nprint count(n, False)\n"}, {"source_code": "rem=10**9+7\ndef help(n,k):\n arr=[1]*(n+1)\n arr[1]=1\n for i in range(2,n+1):\n s=0\n j=i\n while(j>0):\n if j<=k:\n s=(s+arr[i-j])%rem\n j-=1\n arr[i]=s%rem\n return arr\n#n,k,d=map(int,raw_input().split())\ndef pun(n,p):\n #print p\n arr = [1] * (n + 1)\n arr[1] = 1\n for i in range(2, n + 1):\n s = 0\n j = i\n while (j > 0):\n if j = d else False\n if i > n:\n break\n count += (solve(n-i, found)) % 1000000007\n hash_map[(n, found)] = count\n return count\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n print(int(solve(nkd[0], False)))\n"}, {"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\n\n\n\n\nn,k,d=L()\ndef func(n,A):\n @lru_cache\n def rec(s):\n # print(s)\n if s==0:\n return 1\n if s<0:\n return 0\n ans=0\n for x in A:\n ans+=rec(s-x)\n ans%=mod\n return ans\n return rec(n)\n\n\n\n\nans=func(n,[i for i in range(1,k+1)])\nif d!=1:\n ans-=func(n,[i for i in range(1,d)])\nprint(ans)\n\nendtime = time.time()\n# print(f\"Runtime of the program is {endtime - starttime}\")"}, {"source_code": "import sys\nimport math\ninput = sys.stdin.readline\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef helper(rem, found):\n if rem == 0:\n if found:\n return 1\n return 0\n\nhash_map = {}\n\n\ndef solve(n, found):\n if n == 0:\n if found:\n return 1\n return 0\n if (n, found) in hash_map:\n return hash_map[(n, found)]\n count = 0\n for i in range(1, k+1):\n if i > n:\n break\n count += (solve(n-i, found | (True if i >= d else False))) % 1000000007\n hash_map[(n, found)] = count\n return count\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n\n print(int(solve(nkd[0], False)))\n"}, {"source_code": "n,k,d=map(int,input().split())\ndp =[1]+ [0]*(n)\nfor j in range(1,n+1):\n for i in range(1,k+1):\n p=j-i\n if p>=0:\n dp[j]+=dp[p]\n else:\n break\ndp1=[1]+[0]*n\nfor j in range(1,n+1):\n for i in range(1,d):\n if i!=d:\n p=j-i\n if p>=0:\n dp1[j]+=dp1[p]\n else:\n break\nprint(dp[n]-dp1[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, k, d = nis()\n\nmemo = dict()\n\ndef solve(total = 0, flag = False):\n if (total, flag) in memo:\n return memo[(total, flag)]\n\n res = 0\n\n for i in range(1, k + 1):\n flag |= i >= d\n total += 1\n if total < n:\n res += solve(total, flag)\n else:\n if total == n and flag:\n global ans\n res += 1\n break\n\n res %= 1000000007\n\n memo[(total, flag)] = res\n\n return res\n\nprint solve()\n"}, {"source_code": "n,k,d = map(int,input().split())\n# n,k,d = 50,50,2\nmemo = [-1]*100\ndef dp(nn,s):\n\tsum1 = 0\n\tif nn == 0:\n\t\tif(s > (n-(d-1))):\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn 1\n\tif memo[nn] != -1:\n\t\treturn memo[nn]\n\tfor i in range(1,(min(k,nn)+1)):\n\t\tsum1 += dp(nn-i,s+1) %1000000007\n\tmemo[nn] = sum1\n\treturn sum1\ndp(n,0)\nresult = sum([i for i in memo if i !=-1])\nprint(result)"}, {"source_code": "n,k,d=map(int,input().split())\ndp=[0]*(n+1)\ndp[0]=1\n# for i in range(1,k+1):\n# \tdp[i]=1\n# print(dp)\nfor i in range(1,n+1):\n\tfor j in range(1,k+1):\n\t\tif i-j>=0:\n\t\t\tdp[i]+=dp[i-j]\n\t\telse:\n\t\t\tbreak\n\t# print(dp)\nans=[0]*(n+1)\n# print(\"************\")\ndp[0]=1\nfor i in range(1,n+1):\n\tfor j in range(1,k+1):\n\t\tif i-j>=0:\n\t\t\tif j>=d: \n\t\t\t\tans[i]+=dp[i-j]\n\t\t\telif i-j>=d:\n\t\t\t\tans[i]+=ans[i-j]\n\t\telse:\n\t\t\tbreak\n\t# print(ans)\t\n\nprint(ans[n])"}, {"source_code": "n,k,d=map(int,input().split())\nl=[0]\nfor i in range(1,n+1):\n if i K:\n x = K+1\n while x <= N:\n a[x] = sum(a[x-K: x])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g-1)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "mod = 1e9+7\n\ndef Sulution():\n\tn,k,d = [int(x) for x in input().split()]\n\tdp = [[0 for i in range(2)]for j in range(101)]\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n+1):\n\t\tfor j in range(1,k+1):\n\t\t\tif i < j:\n\t\t\t\tbreak\n\t\t\tif j < d:\n\t\t\t\tdp[i][0] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\telse:\n\t\t\t\tdp[i][1] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\tif dp[i][0] >= mod:\n\t\t\t\tdp[i][0] -= mod\n\t\t\tif dp[i][1] >= mod:\n\t\t\t\tdp[i][1] -= mod\n\n\treturn dp[n][1]\n\nprint(Sulution())"}, {"source_code": "n, k, d = [int(i) for i in raw_input().split()]\ndp = [[0, 0] for i in range(n + 1)]\ndp[0][0] = 1\nfor i in range(1, n + 1):\n\ttotal = 0\n\tfor j in range(1, min(d, i + 1)):\n\t\ttotal += dp[i - j][0]\n\tdp[i][0] = total\nfor i in range(1, n + 1):\n\ttotal = 0\n\tfor j in range(1, min(d, i + 1)):\n\t\ttotal += dp[i - j][1]\n\tfor j in range(d, min(i, k) + 1):\n\t\ttotal += (dp[i - j][0] + dp[i - j][1])\n\tdp[i][1] = total\nprint dp[n][1]\n\n"}, {"source_code": "def func(r, k, a) :\n out = 0\n if r <= k:\n out = 2**(r-1)\n else : \n \n for i in range(1,k+1) :\n if i <= r :\n if a[r-i] != -1 :\n out = out + a[r-i]\n else:\n out = out + func(r-i, k, a)\n else :\n break;\n a[r] = out\n return out\n \nn,k,d = map(int, raw_input().split())\nx = [-1]*(n+1)\ny = [-1]*(n+1)\nprint func(n,k,x) - func(n, d-1,y)\n"}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n d = 1\n i = 1\n while i <= min(N, K):\n a[i] = d\n d += a[i]\n i += 1\n if N > K:\n x = K+1\n while x <= N:\n a[x] = sum(a[1: K+1])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "n,k,d=map(int,input().split())\nkp=[-1]*(n+1)\ndef CP(m):\n global k\n if m==0:return(0)\n if m==1:return(1)\n if kp[m]!=-1:return(kp[m])\n c=0\n for t in range(1,min(m,k)+1):\n c+=1+CP(m-t)\n c=c%(1000000007)\n \n kp[m]=c\n return(c)\nkc=[-1]*(n+1)\ndef CP2(m):\n global d\n if m==0:return(0)\n if m==1:return(1)\n if kc[m]!=-1:return(kc[m])\n c=0\n for t in range(1,min(m,d-1)+1):\n c+=1+CP(m-t)\n c=c%(1000000007)\n \n kc[m]=c\n return(c)\n\nprint((CP(n)-CP2(n))%1000000007)"}, {"source_code": "n, k, d = [int(i) for i in raw_input().split()]\ndp = [[0, 0] for i in range(n + 1)]\ndp[0][0] = 1\nfor i in range(1, n + 1):\n\ttotal = 0\n\tfor j in range(1, min(d, i + 1)):\n\t\ttotal += dp[i - j][0]\n\tdp[i][0] = total\nfor i in range(1, n + 1):\n\ttotal = 0\n\tfor j in range(1, min(d, i + 1)):\n\t\ttotal += dp[i - j][1]\n\tfor j in range(d, min(i, k) + 1):\n\t\ttotal += (dp[i - j][0] + dp[i - j][1])\n\tdp[i][1] = total\nprint dp[n][1]\n\n"}, {"source_code": "a = input()\nlist_a = list(map(int,a.split()))\nn = list_a[0]\nk = list_a[1]\nd = list_a[2]############################## modulo 10^9 +7\nsolutions = []\nfor numbers in range(n+1):\n solutions.append(-1)\ndef dp(n,k,solutions):\n if n ==1:\n solutions[1] = 1\n return 1\n if solutions[n] != -1:\n return solutions[n]\n else:\n answer = 0\n x = 1\n while n - x > 0 and x <=k:\n answer += dp(n-x,k,solutions)\n x +=1\n if n <= k:\n answer += 1\n solutions[n] = answer\n return answer\nsolutions_copy = []\nfor numbers in range(n+1):\n solutions_copy.append(-1)\ndef dp_2(n,k,solutions_copy,d):\n if n ==1:\n solutions_copy[1] = 1\n return 1\n if solutions_copy[n] != -1:\n return solutions_copy[n]\n else:\n answer = 0\n x = 1\n while n - x > 0 and x <=k:\n if x < d :\n answer += dp_2(n-x,k,solutions_copy,d)\n x +=1\n else:\n x+=1\n continue\n if n <= k and n < d:\n answer += 1\n solutions_copy[n] = answer\n return answer\nif n == d ==1:\n print(0)\nelse: \n print((dp(n,k,solutions)-dp_2(n,k,solutions_copy,d))%(10**9 + 7))\n"}, {"source_code": "import sys\nimport math\ninput = sys.stdin.readline\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef helper(rem, found):\n if rem == 0:\n if found:\n return 1\n return 0\n\nhash_map = {}\n\n\ndef solve(n, found):\n if n == 0:\n if found:\n return 1\n return 0\n if (n, found) in hash_map:\n return hash_map[(n, found)]\n count = 0\n for i in range(1, k+1):\n if not found:\n found = True if i >= d else False\n if i > n:\n break\n count += (solve(n-i, found)) % 1000000007\n hash_map[(n, found)] = count\n return count\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n print(int(solve(nkd[0], False)))\n"}, {"source_code": "import sys\nfrom math import log2,floor,ceil,sqrt,gcd\n# import bisect\n# from collections import deque\n# sys.setrecursionlimit(7*10**4)\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 = 1000000007\n\n\n\nn,k,d = Ri()\nno = [0]*(n+1)\nno[0] = 1\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if j > i:\n break\n no[i]+=no[i-j]\n no[i]%=MOD\n# print(no)\nnod = [0]*(n+1)\nnod[0] = 1\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if j > i : break\n if j >= d : break\n nod[i]+=nod[i-j]\n nod[i]%=MOD\n# print(nod)\nprint(no[n]-nod[n])\n"}, {"source_code": "n,k,d=map(int,input().split())\ndp=[[0 for i in range(2)] for i in range(101)]\ndp[0][0]=1\ndp[0][1]=1\nfor i in range(1,101):\n for j in range(min(i,d)):\n dp[i][0]+=dp[j][0]\n\n for j in range(min(i,k)):\n dp[i][1]+=dp[j][1]\n \nprint((dp[n][1]-dp[n][0]+1)%(10**9+7)) \n"}, {"source_code": "n,k,d=map(int,input().split())\nl=[0]\nfor i in range(1,n+1):\n if i10**9+7:\n return a - 10**9+7\n else:\n return a\n\ndp[0][0] = 1\ndp[0][1] = 0\n\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if i-j < 0:\n break\n if(j n:\n print 0\n sys.exit(0)\n\ndp = []\nfor i in range(0, 2):\n dp.append([0] * (n+1))\n\ndp[0][0] = 1\ndp[1][0] = 0\n\nfor i in range(1, n+1):\n for j in range(1, k+1):\n back = i - j\n if back < 0:\n break\n\n dp[0][i] += dp[0][back]\n dp[0][i] = dp[0][i] % 1000000007\n\n dp[1][i] = (dp[1][back] + dp[1][i])\n dp[1][i] = dp[1][i] % 1000000007\n\n if j >= d:\n dp[1][i] += dp[0][back]\n dp[1][i] = dp[1][i] % 1000000007\n\nprint dp[1][n]\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\n\nn,k,d=map(int,input().split())\ndp=[[0,0] for i in range(n+1)]\ndp[1][0]=1\ndp[0][0]=1\nfor i in range(2,n+1):\n for j in range(1,min(i+1,k+1)):\n if j=d:\n dp[i][1]+=dp[i-j][0]+dp[i-j][1]\n else:\n dp[i][1]+=dp[i-j][1]\n #print(dp) \nprint(dp[n][1]) "}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n d = 1\n i = 1\n while i <= min(N, K):\n a[i] = d\n d += a[i]\n i += 1\n if N > K:\n x = K+1\n while x <= N:\n a[x] = sum(a[1: K+1])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g-1)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "n, k, d = map(int,input().split())\nf = [0]*(n+k+1)\nf_ = [0]*(n+k+1)\nf_[0] = 1\nfor i in range(1,n+1):\n for j in range(1,k+1):\n f[i] += f[i-j]\n for j in range(d,k+1):\n f[i] += f_[i-j]\n for j in range(1,d):\n f_[i] += f_[i-j]\nprint(f[n])\n "}, {"source_code": "def func(n,k):\n p=1000000007\n arr=[0 for i in range(n+1)]\n arr[0]=1\n if(n<=0):return 0\n for j in range(1,n+1):\n for i in range(1,min(k+1,j+1)):\n arr[j]+=arr[j-i]\n arr[j]%=p\n return arr[n]\nn,k,d=map(int,input().split())\nprint(func(n,k)-func(n,d-1))\n "}, {"source_code": "n,k,d=[int(i) for i in input().split(' ')]\ndp=[[0,0] for i in range(n+1)]\ndp[1]=[1,0] if d==1 else [0,1]\nfor i in range(2,n+1):\n for j in range(1,i):\n if i-j<=k:\n dp[i][0]+=dp[j][0]\n dp[i][0]+=dp[j][1] if i-j>=d else 0\n dp[i][1]+=dp[j][1] if i-j=d else 0\nans=0\n\ndp[-1][0]%(10**9+7)"}, {"source_code": "N, K, D = [int(i) for i in input().split()]\n\nM = 100\nT = [[0]*(M+1),\n [0]*(M+1)]\n\"\"\"Dynamic programming table\n\nT[d, n] is the number of paths where you can accumulate a total of n with (or\nwithout) seeing a branch of length D.\n\n\"\"\"\n\n# Initialization.\nfor k in range(1, K+1):\n T[k>=D][k] = 1\n\n# Dynamic programming.\nfor n in range(1, M+1):\n for k in range(1, K+1):\n if n+k > M:\n continue\n T[1][n+k] += T[1][n]\n T[k>=D][n+k] += T[0][n]\n\nprint(T[1][N])\n"}, {"source_code": "import random\nimport sys\nQ = 10 ** 9 + 7\nn, k, d = map(int, input().split())\ndp = [0] * 105\ndp1 = [0] * 105\ndp[0] = 1\ndp1[0] = 1 \nfor i in range(1, n + 1):\n for j in range(max(0, i - k), i):\n dp[i] = (dp[i] + dp[j]) % Q\n for j in range(max(0, i - d + 1), i):\n dp1[i] = (dp1[i] + dp1[j]) % Q\nprint(dp[n] - dp1[n])"}, {"source_code": "x = input()\nx = x.split()\nn = int(x[0])\nk = int(x[1])\nd = int(x[2])\nc = 1000000007\ncounter = 0\nresult = {}\ndef jie(m, n):\n global counter\n counter = counter + 1\n if (n == m) or (n == 0):\n return 1\n else:\n r = 1\n a = min(n, m - n)\n b = max(n, m - n)\n for i in range(b + 1, m + 1):\n r *= i\n for i in range(1, a + 1):\n r //= int(i)\n return int(r)\ndef pai(l):\n s = 1\n n = sum(l[i] for i in range(k))\n for i in range(k):\n if n in result:\n if l[i] in result[n]:\n t = result[n][l[i]]\n else:\n t = jie(n, l[i])\n result[n][l[i]] = t\n else:\n t = jie(n, l[i])\n result[n] = {l[i]: t}\n s = s * t\n n = n - l[i]\n if n == 0:\n break\n return s\ndef tree(n, k, maxt, mint, m, l):\n if n == 0: \n m = (m + pai(l)) % c\n else:\n for i in range(maxt, mint - 1, -1):\n if i <= n:\n l[i - 1] += 1\n m = tree(n - i, k, i, 1, m, l)\n l[i - 1] -= 1\n return m\nl = []\nfor i in range(k):\n l.append(0)\nprint(tree(n, k, k, d, 0, l), counter)\n"}, {"source_code": "import collections\n\n\ndef count(n, k):\n\n m = collections.defaultdict(lambda: 0)\n m[0] = 1\n for i in range(1, n + 1):\n\n for j in range(1, k + 1):\n\n if i - j in m:\n\n m[i] += m[i - j]\n\n return m[n]\n\nn, k, d = tuple(map(int, str.split(input())))\nprint(count(n, k) - count(n, d - 1))\n"}, {"source_code": "n,k,d=map(int,input().split())\ndp =[1]+ [0]*(n)\nfor j in range(1,n+1):\n for i in range(1,k+1):\n p=j-i\n if p>=0:\n dp[j]+=dp[p]\n else:\n break\ndp1=[1]+[0]*n\nfor j in range(1,n+1):\n for i in range(1,d):\n if i!=d:\n p=j-i\n if p>=0:\n dp1[j]+=dp1[p]\n else:\n break\nprint((dp[n]-dp1[n])%(10e9+7))"}, {"source_code": "mod = 1e9+7\n\ndef Sulution():\n\tn,k,d = [int(x) for x in input().split()]\n\tdp = [[0 for i in range(2)]for j in range(101)]\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n+1):\n\t\tfor j in range(1,k+1):\n\t\t\tif i < j:\n\t\t\t\tbreak\n\t\t\tif j < d:\n\t\t\t\tdp[i][0] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\telse:\n\t\t\t\tdp[i][1] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\tif dp[i][0] >= mod:\n\t\t\t\tdp[i][0] -= mod\n\t\t\tif dp[i][1] >= mod:\n\t\t\t\tdp[i][1] -= mod\n\n\treturn dp[n][1]\n\nprint(Sulution())"}, {"source_code": "n, k, d = map(int, input().split())\ns = [(1, i, True) if i >= d else (1, i, False) for i in range(1, k+1) if i <= n]\nc = 0\n\nwhile s:\n cur = s.pop()\n if cur[1] == n and cur[2]:\n c += 1\n for i in range(1, k+1):\n if cur[0] < k and cur[1] + i <= n:\n s.append((cur[0]+1, cur[1]+i, cur[2] or i >= d))\n\nprint(c)"}, {"source_code": "x = input()\nx = x.split()\nn = int(x[0])\nk = int(x[1])\nd = int(x[2])\nc = int(10e9 + 7)\ndef jie(m, n):\n if (n == m) or (n == 0):\n return 1\n else:\n r = 1\n for i in range(1, m + 1):\n r *= i\n for i in range(1, n + 1):\n r /= i\n for i in range(1, m - n + 1):\n r /= i \n return int(r)\ndef pai(l):\n s = 1\n n = sum(l[i] for i in range(k))\n for i in range(k):\n s = s * jie(n, l[i])\n n = n - l[i]\n if n == 0:\n break\n #print(l,s)\n return s\ndef tree(n, k, maxt, mint, m, l):\n if n == 0: \n m = (m + pai(l)) % c\n else:\n for i in range(maxt, mint - 1, -1):\n if i <= n:\n l[i - 1] += 1\n m = tree(n - i, k, i, 1, m, l)\n l[i - 1] -= 1\n return m\nl = []\nfor i in range(k):\n l.append(0)\nprint(tree(n, k, k, d, 0, l))\n"}, {"source_code": "__author__ = 'd555_'\ndb = False\nMOD = 1000000007\n\nif db:\n import sys\n sys.stdin = open(\"input.txt\", \"r\")\n\n\nn, k, d = map(int, raw_input().split())\n\ndp = dict()\n\n\ndef f(n, x):\n if db:\n print \"f\",(n,x),\" ->\"\n\n if (n, x) in dp:\n if db: print dp[(n,x)], \" con \", (n,x)\n return dp[(n, x)]\n if n == 0:\n if db: print \"n=0\", (n,x) ,\"=>\", (d <= x <= k)\n dp[(0, x)] = (d <= x <= k)\n return d <= x <= k\n if n < 0:\n if db: print \"n<0\", (n,x)\n dp[(n, x)] = 0\n return 0\n c = 0\n for i in range(1, k+1):\n c += f(n - i, max(x, i))%MOD if n - i >= 0 else 0\n dp[(n, x)] = c\n return c\n\nif db: print dp\nprint f(n, 0)"}, {"source_code": "n,v,d=list(map(int,input().split()))\ndp=[[0]*2 for i in range(n+1)]\ndp[0][0]=1\nfor i in range(1,n+1):\n for k in range(1,min(i,v)+1):\n dp[i][0]+=dp[i-k][0]\n if k>=d:\n dp[i][1]+=dp[i-k][0]\n else:\n dp[i][1]+=dp[i-k][1]\nprint(dp[n][1])\n "}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n d = 1\n i = 1\n while i <= min(N, K):\n a[i] = d\n d += a[i]\n i += 1\n if N > K:\n x = K+1\n while x <= N:\n a[x] = sum(a[1: K+1])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "\nMOD = 1000000007\ndp = [-1 for i in range(101)]\n\n\ndef k_tree(n, k, d, least_d_selected):\n if n < 0:\n return 0\n if n == 0 and least_d_selected:\n return 1\n if n == 0 and not least_d_selected:\n return 0\n temp = 0\n if dp[n] != -1:\n return dp[n]\n for i in range(k):\n if not least_d_selected and (i+1) >= d:\n temp += k_tree(n-(i+1), k, d, True)\n temp %= MOD\n temp += k_tree(n-(i+1), k, d, least_d_selected)\n temp %= MOD\n dp[n] = temp\n return dp[n]\n\n\ndef k_tree_runner():\n line = input()\n sn, sk, sd = line.split(' ')\n n = int(sn)\n k = int(sk)\n d = int(sd)\n print(k_tree(n, k, d, False) + 2)\n\n\nk_tree_runner()\n"}, {"source_code": "#!/usr/bin/pypy3\n\nfrom sys import stdin,stderr\n\ndef readInts(): return map(int,stdin.readline().strip().split())\ndef print_err(*args,**kwargs): print(*args,file=stderr,**kwargs)\n\ndef naive_kt(k,d,n):\n if n<0: return 0\n if n=d: d2 = 0\n else: d2 = d\n s += naive_kt(k,d2,n-i)\n return s\n\ndef dp_kt(k,d,n):\n a_d_used = [1]\n a_d_unused = [0]\n for ni in range(1,n+1):\n s = 0\n for si in range(max(0,ni-k),ni):\n s += a_d_used[si]\n a_d_used.append(s)\n for ni in range(1,n+1):\n s = 0\n for si in range(1,k+1): \n if ni-si<0: continue\n v = a_d_unused[ni-si]\n if si>=d: v = a_d_used[ni-si]\n s += v\n a_d_unused.append(s)\n return a_d_used,a_d_unused\n\ndef solve(vs):\n return None\n\ndef run():\n n,k,d = readInts()\n _, dp = dp_kt(k,d,n)\n print(dp[-1])\n \nrun()\n"}, {"source_code": "n, k, d = map(int, raw_input().split(' '))\n\ndp = [[ 0 for x in range(2) ] for y in range(100) ]\n\ndef add(a,b):\n a = a+b\n if a>=10**9+7:\n return a - 10**9+7\n else:\n return a\n\ndp[0][0] = 1\ndp[0][1] = 0\n\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if i-j < 0:\n break\n if(j= d:\n dp[i + j][1] = dp[i + j][1] + dp[i][1] + dp[i][0]\n else:\n dp[i + j][1] += dp[i][1]\n dp[i + j][0] += dp[i][0]\n\nprint (dp[n][1])"}, {"source_code": "\nimport functools\nimport sys\n\np = 10**9 + 7\n\nline = input()\ntokens = line.split()\nn, k, d = int(tokens[0]), int(tokens[1]), int(tokens[2])\n\n@functools.lru_cache(None)\ndef f(s):\n if s == 0:\n return 1\n \n total = 0\n for w in range(1, k + 1):\n if w > s:\n break\n total += f(s - w)\n return total % p\n\n@functools.lru_cache(None)\ndef g(s):\n if s == 0:\n return 1\n total = 0\n for w in range(1, min(d, k + 1)):\n if w > s:\n break\n total += g(s - w)\n return total % p\n\nprint(f(n) - g(n))\n\n"}, {"source_code": "(desiredWeight, maxEdgeWeight, minEdgeWeight) = [\n int(x) for x in input().split()]\nmic = [[-1]*5 for _ in range(desiredWeight+1)]\n\nmodValue = 1000000007\n\ndef pathWithWeight(weight: int, containMin: int):\n if(weight < 0):\n return 0\n if(weight == 0):\n return containMin ^ 1\n if(weight <= 1):\n if(containMin == 1 and minEdgeWeight > weight):\n return 0\n else:\n return 1\n if(mic[weight][containMin] != -1):\n return mic[weight][containMin]\n result = 0\n if (minEdgeWeight <= weight):\n if(containMin == 1):\n result = 1\n else:\n result = 0\n for i in range(1, min(maxEdgeWeight, weight)):\n if(i < minEdgeWeight):\n result += pathWithWeight(weight-i, containMin)\n else:\n result += pathWithWeight(weight-i, 0)\n if(containMin == 1):\n result += pathWithWeight(weight-i, 1)\n mic[weight][containMin] = result\n # print(\"weight:\", weight, \"containmin\", containMin, result)\n return result\n\n\nprint(pathWithWeight(desiredWeight, 1))\n"}, {"source_code": "def func(r, k, a) :\n out = 0\n if r <= k:\n out = 2**(r-1)\n else : \n \n for i in range(1,k+1) :\n if i <= r :\n if a[r-i] != -1 :\n out = out + a[r-i]\n else:\n out = out + func(r-i, k, a)\n else :\n break;\n a[r] = out\n return out\n \nn,k,d = map(int, raw_input().split())\nx = [-1]*(n+1)\ny = [-1]*(n+1)\nprint func(n,k,x) - func(n, d-1,y)\n"}, {"source_code": "n,k,d=map(int,input().split())\nl=[0]\nfor i in range(1,n+1):\n if i= d else False\n if i > n:\n break\n count += (solve(n-i, found)) % 1000000007\n hash_map[(n, found)] = count\n return count\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n print(int(solve(nkd[0], False)))\n"}, {"source_code": "n,v,d=list(map(int,input().split()))\ndp=[[0]*2 for i in range(n+1)]\ndp[0][0]=1\nfor i in range(1,n+1):\n for k in range(1,min(i,v)+1):\n dp[i][0]+=dp[i-k][0]\n if k>=d:\n dp[i][1]+=dp[i-k][0]\n else:\n dp[i][1]+=dp[i-k][1]\nprint(dp[n][1])\n "}, {"source_code": "\ndef dp(n,k,d,f,m):\n\n if (n == 0):\n if (f == True):\n return 1\n return 0\n if (n < 0):\n return 0\n if (m[n][f] != -1):\n return m[n][f]\n\n res = 0\n\n for i in range(1,k+1):\n if (i >= d):\n res += dp(n-i,k,d,f | True,m)\n else:\n res += dp(n-i,k,d,f | False,m)\n\n m[n][f] = res\n\n return m[n][f]\n\n\nif __name__ == '__main__':\n n, k, d = [int(x) for x in input().split()]\n m = [[-1,-1] for _ in range(n+1)]\n print(dp(n,k,d,False,m))"}, {"source_code": "n,k,d=map(int,input().split())\ndp1=[0]*10000\ndp2=[0]*10000\ndp1[0]=1\ndp2[0]=1\nMOD=1e9+7\nfor i in range(n):\n\tfor j in range(1,k+1):\n\t\tdp1[i+j]+=dp1[i]\n\tfor j in range(1,d):\n\t\tdp2[i+j]+=dp2[i]\nif d>n:\n\tprint(0)\nelse:\n\tprint((int(dp1[n]-dp2[n])%MOD))\n"}, {"source_code": "n,k,d = map(int,input().split())\n# n,k,d = 50,50,2\nmemo = [-1]*100\ndef dp(nn,s):\n\tsum1 = 0\n\tif nn == 0:\n\t\tif(s > (n-(d-1))):\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn 1\n\tif memo[nn] != -1:\n\t\treturn memo[nn]\n\tfor i in range(1,(min(k,nn)+1)):\n\t\tsum1 += dp(nn-i,s+1) %1000000007\n\tmemo[nn] = sum1\n\treturn sum1\ndp(n,0)\nresult = sum([i for i in memo if i !=-1])\nprint(result)"}, {"source_code": "n, k, d = [int(k) for k in input().split()]\nways = [0]*(n+1)\nways[0] = 1\nways[1] = 1\n\nfor i in range(2, n+1):\n for j in range(max(0, i-k), i):\n ways[i]+=ways[j]\nprint(ways)\n\ndelete = 0\nfor i in range(1,d):\n delete +=ways[i]\nprint(ways[n]-delete)"}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n d = 1\n i = 1\n while i <= min(N, K):\n a[i] = d\n d += a[i]\n i += 1\n if N > K:\n x = K+1\n while x <= N:\n a[x] = sum(a[x-K: x])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g-1)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "import sys\nsys.setrecursionlimit(100000)\nn, k, d = [int(x) for x in sys.stdin.readline().strip().split()]\nmemo = {}\nm = 10**9 +7\ndef dp(n,k,d):\n\tif n in memo:\n\t\treturn memo[n]\n\tif n==0:\n\t\treturn 1\n\tif n<0:\n\t\treturn 0\n\ts = 0\n\tfor i in range(1,k+1):\n\t\t\tif i>=d :\n\t\t\t\ts+=dp(n-i,k,0)\n\t\t\telif n-i>=d:\n\t\t\t\ts+=dp(n-i,k,d)\n\tmemo[n]=s\n\treturn s\nprint(dp(n,k,d)%m)"}, {"source_code": "def func(n,k):\n p=1000000007\n arr=[0 for i in range(n+1)]\n arr[0]=1\n if(n<=0):return 0\n for j in range(1,n+1):\n for i in range(1,min(k+1,j+1)):\n arr[j]+=arr[j-i]\n arr[j]%=p\n return arr[n]\nn,k,d=map(int,input().split())\nprint(func(n,k)-func(n,d-1))\n "}, {"source_code": "import sys\nimport math\ninput = sys.stdin.readline\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef helper(rem, found):\n if rem == 0:\n if found:\n return 1\n return 0\n\nhash_map = {}\n\n\ndef solve(n, found):\n if n == 0:\n if found:\n return 1\n return 0\n if (n, found) in hash_map:\n return hash_map[(n, found)]\n count = 0\n for i in range(1, k+1):\n if i > n:\n break\n count += (solve(n-i, found | (True if i >= d else False))) % 1000000007\n hash_map[(n, found)] = count\n return count\n\n\nif __name__ == '__main__':\n nkd = inlt()\n k, d = nkd[1], nkd[2]\n\n print(int(solve(nkd[0], False)))\n"}, {"source_code": "mod = 1e9+7\ndef add(a,b):\n\ta += b\n\tif a >= mod:\n\t\treturn a-mod\n\treturn a\n\ndef Sulution():\n\tn,k,d = [int(x) for x in input().split()]\n\tdp = [[0 for i in range(2)] for j in range(100)]\n\tprint(dp)\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n):\n\t\tfor j in range(1,k):\n\t\t\tif i < j:\n\t\t\t\tbreak\n\t\t\tif j < d:\n\t\t\t\tdp[i][0] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\telse:\n\t\t\t\tdp[i][1] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\tif dp[i][0] >= mod:\n\t\t\t\tdp[i][0] -= mod\n\t\t\tif dp[i][1] >= mod:\n\t\t\t\tdp[i][1] -= mod\n\n\treturn dp[n][1]\n\nSulution()"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport itertools, os, sys, threading\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, combinations\nfrom math import gcd\nfrom bisect import bisect\n\n# sys.setrecursionlimit(10**7)\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nread = lambda: list(map(int, input().strip().split(\" \")))\n\ndef main():\n n, k, d = read()\n dic = {}\n def func(required, f):\n key = str(required)+\"-\"+str(f)\n if key in dic:\n return(dic[key])\n if required == 0:\n if f:return(1)\n else:return(0)\n\n if required< 0:\n return(0)\n ans = 0\n for i in range(1, k+1):\n ans += func(required-i, [f, 1][i >= d])\n dic[key] = ans\n return(ans)\n print(func(n, 0))\n # print(dic)\n\n\n\n\nif __name__ == \"__main__\":\n main()\n # sys.setrecursionlimit(100000000)\n # threading.stack_size(20480000)\n # thread = threading.Thread(target=main)\n # thread.start()\n"}, {"source_code": "n, k, d = map(int, input().split())\n\ncombs = []\nfor i in range(n):\n if i == 0:\n combs.append(1)\n else:\n fix = combs[i - 1] * (n - i) // i\n combs.append(fix)\n\nans = 0\nMOD = int(1e9) + 7\nfor comb in combs:\n ans = (ans + comb) % MOD\n\nif n > k:\n for i in range(n - k):\n ans = (ans - combs[i]) % MOD\n\nif d > 1:\n for i in range(d - 1):\n ans = (ans - combs[i]) % MOD\n\nprint(ans)\n"}, {"source_code": "n,k,d=map(int,input().split())\n\ns1=[0]*110\ns2=[0]*110\ns1[0],s2[0]=1,1\n\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if(j>i):\n break\n else:\n s1[i]+=s1[i-j]\n # print(s1[i])\n\n for j in range(1,d):\n if(j>i):\n break\n else:\n s2[i]+=s2[i-j]\nprint(s1[n]-s2[n])\n\n"}, {"source_code": "import sys\nfrom random import randint\nfrom time import time\n\nline=map(lambda x:int(x),sys.stdin.readline().strip('\\n').split(\" \"))\nn=line[0]\nk=line[1]\nd=line[2]\n\nnumd=[]\nnum=[1]\nfor i in xrange(1,k):\n num.append(sum(num[0:i])%1000000007)\n #num.append(num[-1]*2%100000007)\nfor i in xrange(0,d):\n numd.append(0)\nfor i in xrange(d,k):\n #print i,numd,num\n numd.append((sum(numd[i-d+1:i])+sum(num[0:i-d+1]))%100000007)\n\n\n#print numd,num\nfor i in xrange(k,n+1):\n numd.append(0)\n for j in xrange(1,d):\n numd[i]=(numd[i]+numd[i-j])%100000007\n for j in xrange(d,k+1):\n numd[i]=(numd[i]+num[i-j])%100000007\n num.append(0)\n for j in xrange(1,k+1):\n num[i]=(num[i]+num[i-j])%100000007\n#print numd,num\nprint numd[n]%100000007\n"}, {"source_code": "memo = {}\n\ntg,k,d = map(int,input().split())\n\ndef rec(n):\n if n in memo:\n return memo[n]\n\n ans = [0,0]\n\n for b in range(1, min(k,n)+1):\n \n if b == n:\n ans[b>=d]+=1\n continue\n\n r = rec(n-b)\n ans[1]+=r[1]\n ans[b>=d]+=r[0]\n\n memo[n] = ans\n return ans\n\nprint(rec(tg)[1])\n"}, {"source_code": "rem=10**9+7\ndef help(n,k):\n arr=[1]*(n+1)\n arr[1]=1\n for i in range(2,n+1):\n s=0\n j=i\n while(j>0):\n if j<=k:\n s=(s+arr[i-j])%rem\n j-=1\n arr[i]=s%rem\n return arr\n#n,k,d=map(int,raw_input().split())\ndef pun(n,p):\n #print p\n arr = [1] * (n + 1)\n arr[1] = 1\n for i in range(2, n + 1):\n s = 0\n j = i\n while (j > 0):\n if j tam_casilla):\n break\n resto = tam_casilla - num_act\n logger_cagada.debug(\"num act {} resto {}\".format(num_act, resto))\n dp[tam_casilla] += dp[resto]\n logger_cagada.debug(\"la dp es {}\".format(dp))\n dp[0] = 0\n for tam_casilla in range(d, n + 1):\n logger_cagada.debug(\"el tam casilla g {}\".format(tam_casilla))\n for num_act in range(1, k + 1):\n if(num_act > tam_casilla):\n break\n resto = tam_casilla - num_act\n if(resto < d and num_act < d):\n continue\n logger_cagada.debug(\"num act g {} resto {}\".format(num_act, resto))\n num_formas_chicas = dp[resto] if num_act >= d else 0\n num_formas_grandes = dp_grande[resto]\n logger_cagada.debug(\"num formas chicas {} grandes {}\".format(num_formas_chicas, num_formas_grandes))\n dp_grande[tam_casilla] += num_formas_chicas + num_formas_grandes\n logger_cagada.debug(\"la dp grande es {}\".format(dp_grande))\n \n num_formas = dp_grande[n]\n \n return num_formas \n\ndef kk_tree_main():\n lineas = list(sys.stdin)\n n, k, d = [int(x) for x in lineas[0].strip().split(\" \")]\n resu = kk_tree_core(n, k, d)\n print(\"{}\".format(resu))\n\nif __name__ == '__main__':\n FORMAT = \"[%(filename)s:%(lineno)s - %(funcName)20s() ] %(message)s\"\n logging.basicConfig(level=nivel_log, format=FORMAT)\n logger_cagada = logging.getLogger(\"asa\")\n logger_cagada.setLevel(nivel_log)\n kk_tree_main()\n"}, {"source_code": "n, k, d = map(int, input().split())\nans = {}\n\n\ndef dp_solve(n, k):\n ans[0] = 1\n ans[1] = 1\n for i in range(2, n+1):\n cur_t = 0\n for j in range(1, k+1):\n if i-j >= 0:\n cur_t += ans[i-j]\n ans[i] = cur_t\n return ans[n]\n\n\na = dp_solve(n, k)\nb = dp_solve(n, d-1)\nprint(a-b)"}, {"source_code": "mod = 1e9+7\ndef add(a,b):\n\ta += b\n\tif a >= mod:\n\t\treturn a-mod\n\treturn a\n\ndef Sulution():\n\tn,k,d = [int(x) for x in input().split()]\n\tdp = [[0 for i in range(2)] for j in range(100)]\n\tprint(dp)\n\tdp[0][0] = 1\n\tdp[0][1] = 0\n\tfor i in range(1,n):\n\t\tfor j in range(1,k):\n\t\t\tif i < j:\n\t\t\t\tbreak\n\t\t\tif j < d:\n\t\t\t\tdp[i][0] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\telse:\n\t\t\t\tdp[i][1] += dp[i-j][0]\n\t\t\t\tdp[i][1] += dp[i-j][1]\n\t\t\tif dp[i][0] >= mod:\n\t\t\t\tdp[i][0] -= mod\n\t\t\tif dp[i][1] >= mod:\n\t\t\t\tdp[i][1] -= mod\n\n\treturn dp[n][1]\n\nSulution()"}, {"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\n\n\n\n\nn,k,d=L()\ndef func(n,A):\n @lru_cache\n def rec(s):\n # print(s)\n if s==0:\n return 1\n if s<0:\n return 0\n ans=0\n for x in A:\n ans+=rec(s-x)\n ans%=mod\n return ans\n return rec(n)\n\n\n\n\nans=func(n,[i for i in range(1,k+1)])\nif d!=1:\n ans-=func(n,[i for i in range(1,d)])\nprint(ans)\n\nendtime = time.time()\n# print(f\"Runtime of the program is {endtime - starttime}\")"}, {"source_code": "def w(N, K):\n a = [0]*(N+1)\n a[0] = 1\n d = 1\n i = 1\n while i <= min(N, K):\n a[i] = d\n d += a[i]\n i += 1\n if N > K:\n x = K+1\n while x <= N:\n a[x] = sum(a[x-K: x])\n x += 1\n\n return a[-1]\n\n\ndef sol():\n n, k, g = map(int, input().split(\" \"))\n result = w(n, k)-w(n, g-1)\n print(result)\n\n\nsol()\n\n\n"}, {"source_code": "\nMOD = 1000000007\ndp = [-1 for i in range(101)]\n\n\ndef k_tree(n, k, d, least_d_selected):\n if n < 0:\n return 0\n if n == 0 and least_d_selected:\n return 1\n if n == 0 and not least_d_selected:\n return 0\n temp = 0\n if dp[n] != -1:\n return dp[n]\n for i in range(k):\n if not least_d_selected and (i+1) >= d:\n temp += k_tree(n-(i+1), k, d, True)\n temp %= MOD\n temp += k_tree(n-(i+1), k, d, least_d_selected)\n temp %= MOD\n dp[n] = temp\n return dp[n]\n\n\ndef k_tree_runner():\n line = input()\n sn, sk, sd = line.split(' ')\n n = int(sn)\n k = int(sk)\n d = int(sd)\n print(k_tree(n, k, d, False) + 1)\n\n\nk_tree_runner()\n"}], "src_uid": "894a58c9bba5eba11b843c5c5ca0025d"} {"nl": {"description": "You've got a 5\u2009\u00d7\u20095 matrix, consisting of 24 zeroes and a single number one. Let's index the matrix rows by numbers from 1 to 5 from top to bottom, let's index the matrix columns by numbers from 1 to 5 from left to right. In one move, you are allowed to apply one of the two following transformations to the matrix: Swap two neighboring matrix rows, that is, rows with indexes i and i\u2009+\u20091 for some integer i (1\u2009\u2264\u2009i\u2009<\u20095). Swap two neighboring matrix columns, that is, columns with indexes j and j\u2009+\u20091 for some integer j (1\u2009\u2264\u2009j\u2009<\u20095). You think that a matrix looks beautiful, if the single number one of the matrix is located in its middle (in the cell that is on the intersection of the third row and the third column). Count the minimum number of moves needed to make the matrix beautiful.", "input_spec": "The input consists of five lines, each line contains five integers: the j-th integer in the i-th line of the input represents the element of the matrix that is located on the intersection of the i-th row and the j-th column. It is guaranteed that the matrix consists of 24 zeroes and a single number one.", "output_spec": "Print a single integer \u2014 the minimum number of moves needed to make the matrix beautiful.", "sample_inputs": ["0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0", "0 0 0 0 0\n0 0 0 0 0\n0 1 0 0 0\n0 0 0 0 0\n0 0 0 0 0"], "sample_outputs": ["3", "1"], "notes": null}, "positive_code": [{"source_code": "l=[2,1,0,1,2]\nfor i in l:\n s=input()\n if\"1\"in s:print(i+l[s.find(\"1\")//2])"}, {"source_code": "a = []\nfor i in range(5):\n b = list(map(int,input().split()))\n a.append(b)\n\nfor i in range(5):\n for j in range(5):\n if a[i][j]==1:\n print(abs(i-2)+abs(j-2))\n break;\n if a[i][j]==1:\n break;"}, {"source_code": "mat = [[0 for i in range(5)]for i in range(5)]\nrow = 0\ncol = 0\nfor i in range(5):\n\n\ttemp = map(int, raw_input().split())\n\n\tfor j in range(len(temp)):\n\n\t\tmat[i][j] = temp[j]\n\t\tif temp[j]:\n\n\t\t\trow, col = i + 1, j + 1\n\nchange = 0\n\nchange += abs(row - 3)\nchange += abs(col - 3)\n\nprint change\n"}, {"source_code": "for i in range(5):\n a = input()\n if '1' in a:\n x, y = i + 1, a.split().index('1') + 1\n\nprint(abs(3 - x) % 6 + abs(3 - y % 6))\n"}, {"source_code": "sum = 0\nmatrix = []\nfor i in range(5):\n matrix.append(list(map(int,raw_input().split())))\n \nfor i in range(5):\n for j in range(5):\n if matrix[i][j] == 1:\n m = i\n n = j\n\n\nif m == 2 and n == 2:\n print 0\nelse:\n if m >= 2 and n >= 2:\n sum = sum+(m-2)+(n-2)\n print sum\n elif m >= 2 and n < 2:\n sum = sum+(m-2)+(2-n)\n print sum\n elif m <2 and n >=2:\n sum = sum+(2-m)+(n-2)\n print sum\n else:\n sum = sum+(2-m)+(2-n)\n print sum"}, {"source_code": "for i in range(5):\n s=input()\n if'1'in s:print(abs(i-2)+abs(s.find('1')//2-2))"}, {"source_code": "z=[]\nfor k in range(0,5):\n l=map(int,raw_input().split())\n z.append(l)\nfor i in range(0,5):\n for j in range(0,5):\n if(z[i][j]==1):\n m=abs(2-i)\n n=abs(2-j)\nprint (m+n)"}, {"source_code": "matrix=[]\nfor i in range(5):\n temp=[int(x) for x in input().split()]\n matrix.append(temp)\nfor i in range(5):\n for j in range(5):\n if matrix[i][j]==1:\n print(abs(i-2)+abs(j-2))\n"}, {"source_code": "s1=raw_input()\ns2=raw_input()\ns3=raw_input()\ns4=raw_input()\ns5=raw_input()\nif '1' in s1:\n s1=filter(lambda a: a != ' ' , s1)\n u=s1.index('1')\n o=abs(u-2)+2\nif '1' in s2:\n s2=filter(lambda a: a != ' ' , s2)\n u=s2.index('1')\n o=abs(u-2)+1\nif '1' in s3:\n s3=filter(lambda a: a != ' ' , s3)\n u=s3.index('1')\n o=abs(u-2)\nif '1' in s4:\n s4=filter(lambda a: a != ' ' , s4)\n u=s4.index('1')\n o=abs(u-2)+1\nif '1' in s5:\n s5=filter(lambda a: a != ' ' , s5)\n u=s5.index('1')\n o=abs(u-2)+2\nprint o\n"}, {"source_code": "for i in xrange(1, 6):\n s = map(int, raw_input().split())\n for k in xrange(1, 6):\n if s[k - 1] == 1:\n print abs(i - 3) + abs(k - 3)\n break"}, {"source_code": "for i in xrange(1, 6):\n s = map(int, raw_input().split())\n for k in xrange(1, 6):\n if s[k - 1] == 1:\n print abs(i - 3) + abs(k - 3)\n break"}, {"source_code": "t = 0\nfor j in range(5):\n s = input().replace(' ', '')\n pos = s.find('1')\n if pos >= 0:\n t += abs(3 - (pos + 1))\n t += abs(3 - (j + 1))\nprint(t)\n"}, {"source_code": "list_ = []\nfor i in range(0, 5):\n\tlist_.append([int(i) for i in raw_input().split()])\nans = 0\nfor i in range(0, 5):\n\tfor j in range(0, 5):\n\t\tif (list_[i][j] == 1):\n\t\t\tans = abs(i-2) + abs(j-2)\nprint(ans)"}, {"source_code": "sum = 0\nmatrix = []\nfor i in range(5):\n matrix.append(list(map(int,raw_input().split())))\n \nfor i in range(5):\n for j in range(5):\n if matrix[i][j] == 1:\n m = i\n n = j\n\n\nif m == 2 and n == 2:\n print 0\nelse:\n if m >= 2 and n >= 2:\n sum = sum+(m-2)+(n-2)\n print sum\n elif m >= 2 and n < 2:\n sum = sum+(m-2)+(2-n)\n print sum\n elif m <2 and n >=2:\n sum = sum+(2-m)+(n-2)\n print sum\n else:\n sum = sum+(2-m)+(2-n)\n print sum"}, {"source_code": "matrix = [input().strip().split() for i in range(5)]\n \nfor i in range(5):\n for j in range(5):\n if matrix[i][j] == \"1\":\n row,col = i, j\nprint(abs(2 - row) + abs(2 - col))"}, {"source_code": "for i in range(5):\n column=input().split()\n for j in range(5):\n if '1'==column[j]:\n s=abs(i-2)+abs(j-2)\n print(s)\n"}, {"source_code": "for i in xrange(1, 6):\n s = map(int, raw_input().split())\n for k in xrange(1, 6):\n if s[k - 1] == 1:\n print(abs(i - 3) + abs(k - 3))\n break"}, {"source_code": "i, j = divmod(' '.join(input() for i in range(5)).index('1') // 2, 5)\nprint(abs(i - 2) + abs(j - 2))"}, {"source_code": "t=5\n\nwhile t!=0:\n\t\n\ta=map(int,raw_input().split())\n\tfor i in range(len(a)):\n\t\tif a[i]==1:\n\t\t\tx=5-t\n\t\t\ty=i\n\tt=t-1\n\t\t\t\nx=x+1\ny=y+1\nprint abs(3-x)+abs(3-y)"}, {"source_code": "a = raw_input()\na = a + \" \"\nb = raw_input()\nb = b + \" \"\nc = raw_input()\nc = c + \" \"\nd = raw_input()\nd = d + \" \"\ne = raw_input()\ne = e + \" \"\nm = 0\ns = 0\na = a + b + c + d + e\n\na = a.split()\nfor i in range(0,25):\n if a[i] == \"1\":\n m = i\nwhile m <> 12:\n if m < 12:\n if m < 10:\n m = m + 5\n else:\n m = m + 1\n else:\n if m > 14:\n m = m - 5\n else:\n m = m - 1\n s = s + 1\nprint s\n"}, {"source_code": "for i in range(5):\n s = raw_input()\n for j in range(len(s)):\n if s[j] == '1':\n x, y = i, j/2\nprint abs(x-2)+abs(y-2)\n"}, {"source_code": "from sys import stdin, stdout\n\n\ndef read_line():\n return stdin.readline().strip()\n\n\ndef print(value):\n stdout.write(str(value))\n\n\ndef main():\n desired_i, desired_j = 2, 2\n for i in range(5):\n row_line = read_line()\n row_lst = row_line.split(\" \")\n try:\n j = row_lst.index(\"1\")\n minimal_moves = abs(i - desired_i) + abs(j - desired_j)\n print(minimal_moves)\n break\n except:\n continue\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "'''\nBeautiful Matrix\n\nYou've got a 5\u2009\u00d7\u20095 matrix, consisting of 24 zeroes and a single number one.\nrows : (1\u2009\u2264\u2009i\u2009<\u20095), cols : (1\u2009\u2264\u2009j\u2009<\u20095)\nIn one move, you are allowed to apply one of the two transf. to the matrix:\n\n1. Swap two neighboring matrix rows\n2. Swap two neighboring matrix columns\nA matrix looks beautiful, if the single number one of the matrix is located\nin its middle\nCount the minimum number of moves needed to make the matrix beautiful.\n\nInput\nThe input consists of five lines, each line contains five integers:\nthe j-th integer in the i-th line of the input represents the element\nthat is located on the intersection of the i-th row and the j-th column.\nIt is guaranteed that the matrix consists of 24 zeroes and a single number one.\n\nOutput\nPrint the minimum number of moves needed to make the matrix beautiful.\n'''\n# import time\n\n\ndef solve():\n\tmatrix = []\n\tfor _ in range(5):\n\t\tmatrix.append(input().split())\n\t# solve.start = time.time()\n\tprint(find_min_num(matrix))\n\t# solve.end = time.time()\n\n\ndef find_min_num(matrix):\n\tfor i in range(3):\n\t\tfor j in range(5):\n\t\t\titem = matrix[i][j]\n\t\t\topp_item = matrix[4 - i][4 - j]\n\t\t\tif item != \"0\" or opp_item != \"0\":\n\t\t\t\treturn abs(2 - j) + abs(2 - i)\n\n\nsolve()\n\n# print(f'TIME TAKEN IN SECONDS:\\n\\\n# {solve.end - solve.start}')\n'''\n0 0 0 0 0\n0 0 0 0 1\n0 0 0 0 0\n0 0 0 0 0\n0 0 0 0 0\n'''\n"}, {"source_code": "p = [int(x) for x in input().split()]\nq = [int(x) for x in input().split()]\ns = [int(x) for x in input().split()]\nr = [int(x) for x in input().split()]\nt = [int(x) for x in input().split()]\nif p.count(1):\n print(abs((p.index(1)+1)-3)+2)\nelif q.count(1):\n print(abs((q.index(1)+1)-3)+1)\nelif s.count(1):\n print(abs(s.index(1)-2))\nelif r.count(1):\n print(abs((r.index(1)+1)-3)+1)\nelif t.count(1):\n print(abs((t.index(1)+1)-3)+2)\n"}, {"source_code": "# 263A => Beautiful Matrix\n# https://codeforces.com/problemset/problem/263/A\n\nfor i in range(5):\n row = input().split()\n if row.count(\"1\") == 1:\n print(abs(i - 2) + abs(row.index(\"1\") - 2))"}, {"source_code": "def move_num_to_center_of_matrix():\n\n num_lines = 0\n row_num = 1\n while num_lines < 5:\n\n line_list = list(map(int, (input()).split(\" \")))\n\n col_num = 1\n for num in line_list:\n if num != 0:\n int_row = row_num\n int_col = col_num\n\n col_num += 1\n\n row_num += 1\n num_lines += 1\n\n print(abs(int_row - 3) + abs(int_col - 3))\n\n\nif __name__ == \"__main__\":\n\n move_num_to_center_of_matrix()\n"}, {"source_code": "for i in range(5):\n a = raw_input().split()\n# a = a.split()\n if '1' in a:\n print(abs(a.index('1') - 2) + abs(i-2))\n"}, {"source_code": "xcount = 0\nycount = 0\ny = 0\nfor x in range(5):\n x = int(x)\n a,b,c,d,e = raw_input().split()\n a,b,c,d,e = int(a),int(b),int(c),int(d),int(e)\n if a == 1:\n xcount = abs(2-x)\n ycount = 2\n if b == 1:\n xcount = abs(2-x)\n ycount = 1\n if c == 1:\n xcount = abs(2-x)\n ycount = 0\n if d == 1:\n xcount = abs(2-x)\n ycount = 1\n if e == 1:\n xcount = abs(2-x)\n ycount = 2\nprint xcount + ycount\n"}, {"source_code": "a,b=0,0\nfor i in range(1,6):\n s=input()\n if'1' in s:\n a=i\n b=s.split().index('1')+1\n break\n \nprint(abs(3-a) + abs(3-b)) \n"}, {"source_code": "x = 0\ny = 0\nfor i in range(5):\n line = raw_input().split(\" \")\n for j in range(5):\n if (int(line[j]) == 1):\n x = i\n y = j\n\nprint abs(x - 2) + abs(y - 2)"}, {"source_code": "i=0\nwhile i < 5:\n\tfila = input()\n\tfila = fila.split(\" \")\n\tif \"1\" in fila:\n\t\tfor k in range(5):\n\t\t\tif fila[k]== \"1\":\n\t\t\t\tx = k-2\n\t\t\t\ty = i-2\n\t\t\t\tbreak\n\ti+=1\n\t\nprint (abs(x) + abs(y))\n# 1537665260883\n"}, {"source_code": "for i in range(5):\n row = input().split()\n if '1' in row:\n num_row = i + 1\n real_row = row\n\nadd_1 = abs(num_row - 3)\n\nnum_column = real_row.index('1') + 1\nadd_2 = abs(num_column - 3)\n\nprint(add_1+add_2)"}, {"source_code": "from sys import stdin, stdout\n\n\ndef read_line():\n return stdin.readline().strip()\n\n\ndef print(value):\n stdout.write(str(value))\n\n\ndef main():\n for i in range(5):\n row_lst = read_line().split()\n if '1' in row_lst:\n print(abs(i - 2) + abs(row_lst.index('1') - 2))\n return\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def matrix():\n for i in range(5):\n k = raw_input().split()\n k = map(int,k)\n for x in range(5):\n if (k[x]==1):\n #print (i,x)\n a = abs(i-2)\n b = abs(x-2)\n print (a+b)\n\nmatrix() "}, {"source_code": "for i in xrange(1, 6):\n s = map(int, raw_input().split())\n for k in xrange(1, 6):\n if s[k - 1] == 1:\n print abs(i - 3) + abs(k - 3)\n break"}, {"source_code": "n1 = list(map(int, raw_input().split()))\nn2 = list(map(int, raw_input().split()))\nn3 = list(map(int, raw_input().split()))\nn4 = list(map(int, raw_input().split()))\nn5 = list(map(int, raw_input().split()))\n\nif 1 in n1:\n row = 0\n column = n1.index(1)\nelif 1 in n2:\n row = 1\n column = n2.index(1)\nelif 1 in n3:\n row = 2\n column = n3.index(1)\nelif 1 in n4:\n row = 3\n column = n4.index(1)\nelif 1 in n5:\n row = 4\n column = n5.index(1)\n \n \n \nif row >2:\n\tres= row-2\n\tif column > 2:\n\t\tres += (column-2)\n\telif column <2:\n\t\tres += (2- column)\n\telif column == 2:\n\t\tres += 0\n\tprint res\n\texit()\nelif row < 2:\n\tres = 2-row\n\tif column > 2:\n\t\tres += (column-2)\n\telif column <2:\n\t\tres += (2- column)\n\telif column == 2:\n\t\tres += 0\n\tprint res\n\texit()\nelif row==2:\n\tres = 0\n\tif column > 2:\n\t\tres += (column-2)\n\telif column <2:\n\t\tres += (2- column)\n\telif column == 2:\n\t\tres += 0\n\tprint res\n\texit()\n\n"}, {"source_code": "arr=[]\nfor _ in range(5):\n arr.append(list(map(int,input().split())))\n\nfor i in range(5):\n if 1 in arr[i]:\n x=[i,arr[i].index(1)]\nprint(abs(x[0]-2)+abs(x[1]-2)) \n \n \n \n"}, {"source_code": "i=0\nwhile i < 5:\n\tfila = input()\n\tfila = fila.split(\" \")\n\tif \"1\" in fila:\n\t\tfor k in range(5):\n\t\t\tif fila[k]== \"1\":\n\t\t\t\tx = k-2\n\t\t\t\ty = i-2\n\t\t\t\tbreak\n\ti+=1\n\t\nprint (abs(x) + abs(y))\n# 1537665260883\n"}, {"source_code": "for i in range(5):\n s=input()\n if \"1\" in s:\n print(abs(i-2)+abs(s.find('1')//2-2))"}, {"source_code": "counter = 0\nfor i in range(5):\n row = input().split()\n if \"1\" in row:\n nRow = i\n for j in range(5):\n if row[j] == \"1\":\n nColumn = j\n break\n\nif nRow == 0 or nRow == 4:\n counter += 2\nelif nRow == 1 or nRow == 3:\n counter += 1\n\nif nColumn == 0 or nColumn == 4:\n counter += 2\nif nColumn == 1 or nColumn == 3:\n counter += 1\n\nprint(counter)"}, {"source_code": "from typing import List\n\n\ndef solve(*, _input: List[List[int]], current_index: int = 0) -> int:\n return abs(_input[current_index].index(1) - 2) + abs(current_index - 2) if 1 in _input[current_index] else solve(\n _input=_input, current_index=current_index + 1\n )\n\n\nif __name__ == '__main__':\n solution = solve(_input=[list(map(int, input().split())) for _ in range(5)])\n print(solution)\n"}, {"source_code": "counter = 0\nfor i in range(5):\n row = input().split()\n if \"1\" in row:\n nRow = i\n nColumn = row.index(\"1\")\n\nif nRow == 0 or nRow == 4:\n counter += 2\nelif nRow == 1 or nRow == 3:\n counter += 1\n\nif nColumn == 0 or nColumn == 4:\n counter += 2\nif nColumn == 1 or nColumn == 3:\n counter += 1\n\nprint(counter)"}, {"source_code": "r=0\nfor i in range(5):\n raw_answer = raw_input()\n answers = raw_answer.split(' ')\n for j in range(5):\n if answers[j]=='1': \n r=abs(i-2)+abs(j-2)\nprint(r)"}, {"source_code": "a = [[0 for j in range(5)] for i in range(5)]\nx = 0\ny = 0\nfor i in range(0,5):\n\ta[i] = map(int,raw_input().split())\n\nfor i in range(0,5):\n\tfor j in range(0,5):\n\t\tif a[i][j] == 1:\n\t\t\tx = i + 1\n\t\t\ty = j + 1\n\t\t\tbreak\nprint abs(x-3) + abs(y-3)"}, {"source_code": "for i in range(5):\n arr = [int(x) for x in input().split()]\n for j in range(5):\n if arr[j] == 1:\n print(abs(2 - i) + abs(2 - j))\n break\n"}, {"source_code": "desired_i, desired_j = 2, 2\nfor i in range(5):\n row_line = input()\n row_lst = row_line.split()\n if '1' in row_lst:\n j = row_lst.index(\"1\")\n minimal_moves = abs(i - desired_i) + abs(j - desired_j)\n print(minimal_moves)\n break\n"}, {"source_code": "for i in range(5):\n s = input().split()\n if \"1\" in s:\n print(abs(i-2)+abs(s.index(\"1\")-2))"}, {"source_code": "sum = 0\nmatrix = []\nfor i in range(5):\n matrix.append(list(map(int,raw_input().split())))\n \nfor i in range(5):\n for j in range(5):\n if matrix[i][j] == 1:\n m = i\n n = j\n\n\nif m == 2 and n == 2:\n print 0\nelse:\n if m >= 2 and n >= 2:\n sum = sum+(m-2)+(n-2)\n print sum\n elif m >= 2 and n < 2:\n sum = sum+(m-2)+(2-n)\n print sum\n elif m <2 and n >=2:\n sum = sum+(2-m)+(n-2)\n print sum\n else:\n sum = sum+(2-m)+(2-n)\n print sum"}, {"source_code": "for i in range(5):\n s = raw_input().split()\n if '1' in s: print abs(2-s.index('1'))+abs(2-i)"}, {"source_code": "from math import*\n\nF1 = str(input())\nF2 = str(input())\nF3 = str(input())\nF4 = str(input())\nF5 = str(input())\n\nL=[[F1[0], F1[2], F1[4], F1[6], F1[8]],[F2[0], F2[2], F2[4], F2[6], F2[8]],[F3[0], F3[2], F3[4], F3[6], F3[8]],[F4[0], F4[2], F4[4], F4[6], F4[8]],[F5[0], F5[2], F5[4], F5[6], F5[8]]]\n\nfor i in [0,1,2,3,4]:\n for j in [0,1,2,3,4]:\n if L[i][j]=='1': print (abs(2-i)+abs(2-j))\n# 1537556034987\n"}, {"source_code": "row = 0\ncolumn = 0\n\nfor i in range(5):\n row += 1\n l = input().split()\n if '1' in l:\n column = l.index('1')\n break\nprint(abs(row-3)+abs(column-2))"}, {"source_code": "for i in xrange(5) :\n a = map(int, raw_input().split())\n if 1 in a :\n row = i + 1\n column = a.index(1) + 1\n\nprint abs(3 - row) + abs(3 - column)\n"}, {"source_code": "#matrix\nfor i in range(5):\n x=[int(x) for x in input().split()]\n for j in range(5):\n if x[j]==1:\n a=i\n b=j\nz=abs(2-a)+abs(2-b)\nprint(z)\n\n\n\n"}, {"source_code": "n1 = list(map(int, raw_input().split()))\nn2 = list(map(int, raw_input().split()))\nn3 = list(map(int, raw_input().split()))\nn4 = list(map(int, raw_input().split()))\nn5 = list(map(int, raw_input().split()))\n\nif 1 in n1:\n row = 0\n column = n1.index(1)\nelif 1 in n2:\n row = 1\n column = n2.index(1)\nelif 1 in n3:\n row = 2\n column = n3.index(1)\nelif 1 in n4:\n row = 3\n column = n4.index(1)\nelif 1 in n5:\n row = 4\n column = n5.index(1)\n \n \n \nif row >2:\n\tres= row-2\n\tif column > 2:\n\t\tres += (column-2)\n\telif column <2:\n\t\tres += (2- column)\n\telif column == 2:\n\t\tres += 0\n\tprint res\n\texit()\nelif row < 2:\n\tres = 2-row\n\tif column > 2:\n\t\tres += (column-2)\n\telif column <2:\n\t\tres += (2- column)\n\telif column == 2:\n\t\tres += 0\n\tprint res\n\texit()\nelif row==2:\n\tres = 0\n\tif column > 2:\n\t\tres += (column-2)\n\telif column <2:\n\t\tres += (2- column)\n\telif column == 2:\n\t\tres += 0\n\tprint res\n\texit()\n\n"}, {"source_code": "for i in range(5):\n lis = list(map(int,input().split()))\n if 1 in lis:\n r = i\n break\nfor j in range(5):\n if lis[j]==1:\n c = j\nprint(abs(c-2)+abs(r-2))"}, {"source_code": "i, j = divmod(''.join(input().replace(' ', '') for i in range(5)).index('1'), 5)\nprint(abs(i - 2) + abs(j - 2))"}, {"source_code": "for i in range(5):\n a = map(int, input().split())\n for j, x in enumerate(a):\n if x == 1:\n print(abs(2 - i) + abs(2 - j))\n"}, {"source_code": "from typing import List\n\n\ndef solve(*, _input: List[List[int]], current_index: int = 0) -> int:\n return abs(_input[current_index].index(1) - 2) + abs(current_index - 2) if 1 in _input[current_index] else solve(\n _input=_input, current_index=current_index + 1\n )\n\n\nif __name__ == '__main__':\n solution = solve(_input=[list(map(int, input().split())) for _ in range(5)])\n print(solution)\n"}, {"source_code": "for i in range(5):\n s = raw_input()\n for j in range(len(s)):\n if s[j] == '1':\n x, y = i, j/2\nprint abs(x-2)+abs(y-2)\n"}, {"source_code": "temp2 = -1\ntemp = -1\nfor i in range(5):\n s = raw_input()\n if(s.find(\"1\")!=-1):\n arr = s.split(\" \")\n temp2 = i\n temp = arr.index(\"1\")\nprint abs(2-temp2) + abs(2-temp)"}, {"source_code": "summ=0\nfor i in range(1,6):\n t=str(input()).split()\n j=0\n for j in range(5):\n if int(t[j])==1:\n summ=summ+abs(3-i)+abs(2-j)\nprint(summ)"}, {"source_code": "flag = 0\nfor i in range(5):\n a = input().split()\n for j in range(5):\n if a[j] == \"1\":\n if j == 1 or j == 3:\n flag += 1\n elif j == 0 or j == 4:\n flag += 2\n if i == 1 or i == 3:\n flag += 1\n elif i == 0 or i == 4:\n flag += 2\nprint(flag)"}, {"source_code": "a = [map(int, raw_input().split()) for _ in range(5)]\nfor i in range(5):\n for j in range(5):\n if a[i][j]:\n x,y=i,j\nprint abs(x-2)+abs(y-2)"}, {"source_code": "r_count = 0\nc_count = 0\nf_row = 0\nf_column = 0\n\nfor i in range(5):\n r_count += 1\n row = raw_input()\n c_count = row.find('1')\n if(c_count >= 0):\n f_row = r_count\n f_column = c_count/2\n\n\nprint abs(f_row - 3)+abs(f_column - 2)"}, {"source_code": "a=0\nb=0\nfor i in range(0,5):\n\tm=input().split(\" \")\n\tif \"1\" in m:\n\t\ta=i+1\n\t\tb=m.index(\"1\")+1\nprint(abs(a-3)+abs(b-3))"}, {"source_code": "matrix = []\nfor _ in range(5):\n matrix.append(list(map(lambda x: int(x), input().split())))\n\nmoves = 0\n\n\ndef getIndex(matrix: list):\n index = (0, 0)\n for x in range(len(matrix)):\n if matrix[x].__contains__(1):\n index = (x, matrix[x].index(1))\n return index\n\n\nindex = getIndex(matrix)\nwhile matrix[2][2] != 1:\n if index[0] > 2:\n matrix[index[0]][index[1]], matrix[index[0] - 1][index[1]] = \\\n matrix[index[0] - 1][index[1]], matrix[index[0]][index[1]]\n index = (index[0] - 1, index[1])\n moves += 1\n elif index[0] < 2:\n matrix[index[0]][index[1]], matrix[index[0] + 1][index[1]] = \\\n matrix[index[0] + 1][index[1]], matrix[index[0]][index[1]]\n index = (index[0] + 1, index[1])\n moves += 1\n\n if index[1] > 2:\n matrix[index[0]][index[1]], matrix[index[0]][index[1] - 1] = \\\n matrix[index[0]][index[1] - 1], matrix[index[0]][index[1]]\n index = (index[0], index[1] - 1)\n moves += 1\n\n elif index[1] < 2:\n matrix[index[0]][index[1]], matrix[index[0]][index[1] + 1] = \\\n matrix[index[0]][index[1] + 1], matrix[index[0]][index[1]]\n index = (index[0], index[1] + 1)\n moves += 1\n\nprint(moves)\n"}, {"source_code": "matrix=[]\n\nfor i in range(5):\n l=list(map(int,input().split()))\n matrix.append(l)\n\nd=[[index,row.index(1)]for index,row in enumerate(matrix) if 1 in row]\n\nc=d[0]\nprint(abs(c[0]-2)+abs(c[1]-2))\n\n\n \n\n\n \n"}, {"source_code": "for i in range(5):\n s=input()\n if'1'in s:print(abs(i-2)+abs(s.find('1')//2-2))"}, {"source_code": "lst1 = list(map(int, input().split()))\nlst2 = list(map(int, input().split()))\nlst3 = list(map(int, input().split()))\nlst4 = list(map(int, input().split()))\nlst5 = list(map(int, input().split()))\n\nif 1 in lst1:\n for i in range(5):\n if lst1[i] == 1:\n c = i + 1\n r = 1\n break\n else:\n pass\n\nelif 1 in lst2:\n for j in range(5):\n if lst2[j] == 1:\n c = j + 1\n r = 2\n break\n else:\n pass\n\nelif 1 in lst3:\n for k in range(5):\n if lst3[k] == 1:\n c = k + 1\n r = 3\n break\n else:\n pass\n\nelif 1 in lst4:\n for l in range(5):\n if lst4[l] == 1:\n c = l + 1\n r = 4\n break\n else:\n pass\n\nelse:\n for m in range(5):\n if lst5[m] == 1:\n c = m + 1\n r = 5\n break\n else:\n pass\n\nif r >= 3:\n if c >= 3:\n print((c+r)-6)\n else:\n print(r-c)\nelse:\n if c >= 3:\n print(c-r)\n else:\n print(6-(c+r))"}, {"source_code": "v = h = 0\nfor i in range(5):\n a = list(map(int, input().split()))\n if a.count(1):\n v = i\n h = a.index(1)\n break\nprint(abs(2-v) + abs(2-h))"}, {"source_code": "matrix = []\nfor i in range(0, 5):\n st = input(\"\")\n s = list(st.split(\" \"))\n lis = [int(x) for x in s]\n matrix.append(lis)\n\n\n\nfor k in range(0, 5):\n for j in range(0, 5):\n if matrix[k][j] == 1:\n total = abs(k - 2) + abs(j - 2)\n else:\n continue\nprint(total)\n\n"}, {"source_code": "arr = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\nfor i in range(5):\n lis = [int(x) for x in input().split()]\n for j in range(5):\n if lis[j] == 1:\n r = i + 1\n c = j + 1\n arr[i][j] = lis[j]\n\nprint(abs(3-r) + abs(3-c))"}, {"source_code": "l = [2, 1, 0, 1, 2]\nfor i in l:\n s = input()\n if \"1\" in s:\n print(i + l[s.find(\"1\") // 2])\n break\n"}, {"source_code": "r1=raw_input()\nr2=raw_input()\nr3=raw_input()\nr4=raw_input()\nr5=raw_input()\nr1=r1.split(' ')\nr2=r2.split(' ')\nr3=r3.split(' ')\nr4=r4.split(' ')\nr5=r5.split(' ')\nk=0\na=[r1,r2,r3,r4,r5]\nfor c in a:\n if '1' in c:\n one=c.index('1')\n k=k+abs(one-2)\n if c==r1:\n k=k+2\n if c==r2:\n k=k+1\n if c==r4:\n k=k+1\n if c==r5:\n k=k+2\nprint k\n\n \n\n"}, {"source_code": "for i in range(5):\n n = input().split()\n if '1' in n:\n print(abs(i-2) + abs(n.index('1') - 2))\n exit()\n \n"}, {"source_code": "x = []\nflag = 0\nfor i in range(5):\n x.append(raw_input().split(\" \"))\n\nfor i in x:\n flag+=1\n for xo,j in enumerate(i):\n if j == \"1\":\n lol = flag-1\n lo1 = int(xo)\na = max((2-lol),lol-2)\nb = max((2 - lo1),lo1-2)\nprint a+b\n"}, {"source_code": "arr = []\n\nfor i in range(5):\n z = input().split()\n y = [int(x) for x in z]\n arr.append(y)\nx = 0\ny = 0\ndx = 0\ndy = 0\n#finds the non-zero number\nwhile y <= len(arr)-1:\n while x <= len(arr[0])-1:\n if arr[y][x] != 0:\n dx = x\n dy = y\n break\n x+=1\n x = 0\n y +=1\n if dy != 0:\n break\n\n#find the distance from the center\ndistance = abs(dx-2)+abs(dy-2)\n\nprint(distance)\n"}, {"source_code": "i=0\nwhile i < 5:\n\tfila = input()\n\tfila = fila.split(\" \")\n\tif \"1\" in fila:\n\t\tfor k in range(5):\n\t\t\tif fila[k]== \"1\":\n\t\t\t\tx = k-2\n\t\t\t\ty = i-2\n\t\t\t\tbreak\n\ti+=1\n\t\nprint (abs(x) + abs(y))\n# 1537665260883\n"}, {"source_code": "count1=-1\nfor x in range(5):\n count1+=1\n a=[int(i) for i in raw_input().split()]\n for j in range(len(a)):\n if a[j]==1:\n count2=j\n a1=abs(2-count1)\n a2=abs(2-count2)\n print a1+a2\n\n\n\n\n\n"}, {"source_code": "for i in range(5):\n x = map(int, raw_input().split())\n if 1 in x:\n print abs(x.index(1) - 2) + abs(i - 2)\n break"}, {"source_code": "arr = []\nmovement = 0\n\nfor x in range(5):\n arr_l = [int(arr_i) for arr_i in input().strip().split()]\n arr.append(arr_l)\nfor row in arr:\n for col in row:\n if col == 1:\n movement = abs(row.index(col)-2) + abs(arr.index(row) - 2)\n\nprint(movement)\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Apr 11 21:20:49 2020\n\n@author: Maciej\n\"\"\"\nl=[2,1,0,1,2]\nfor i in l:\n s=input()\n if\"1\"in s:print(i+l[s.find(\"1\")//2])"}, {"source_code": "a=[]\nfor i in range(5):\n a.append(list(map(int,input().split())))\nb=[]\nfor i in range(5):\n for j in range(5):\n c=0\n if a[i][j]==1:\n c=abs((2-i))+abs((2-j))\n b.append(c)\nprint(min(b))"}, {"source_code": "import math\n\nlineIndex = rowIndex = 0\nfor i in range(5):\n line = list(map(int, input().split(\" \")))\n if 1 in line:\n lineIndex = i\n rowIndex = line.index(1)\n\ncount = math.fabs(lineIndex - 2) + math.fabs(rowIndex - 2)\n\nprint(int(count))\n"}, {"source_code": "##s1=raw_input()\n##s2=raw_input()\n##s3=raw_input()\n##s4=raw_input()\n##s5=raw_input()\n##if '1' in s1:\n## s1=filter(lambda a: a != ' ' , s1)\n## u=s1.index('1')\n## o=abs(u-2)+2\n##if '1' in s2:\n## s2=filter(lambda a: a != ' ' , s2)\n## u=s2.index('1')\n## o=abs(u-2)+1\n##if '1' in s3:\n## s3=filter(lambda a: a != ' ' , s3)\n## u=s3.index('1')\n## o=abs(u-2)\n##if '1' in s4:\n## s4=filter(lambda a: a != ' ' , s4)\n## u=s4.index('1')\n## o=abs(u-2)+1\n##if '1' in s5:\n## s5=filter(lambda a: a != ' ' , s5)\n## u=s5.index('1')\n## o=abs(u-2)+2\n##print o\nfor i in range(5):\n s=raw_input()\n if '1' in s:\n s = filter(lambda a: a != ' ', s)\n o=abs(s.index('1')-2)+abs(2-i)\nprint o\n"}, {"source_code": "A = [map(int,raw_input().split()) for i in range(5)]\npos = (0,0)\nfor i in range(5):\n for j in range(5):\n if A[i][j] == 1:\n pos = (i,j)\nans = abs(pos[0]-2) + abs(pos[1]-2)\nprint(ans)\n"}, {"source_code": "matrix=[]\nfor i in range(5):\n a=[]\n a=input().split()\n matrix.append(a)\n# print(matrix)\nfor i in range(5):\n for j in range(5):\n if matrix[i][j]==\"1\":\n mi=i\n mj=j\nc=abs(mi-2)+abs(mj-2)\nprint(c)\n"}, {"source_code": "lst=[]\nfor i in range(5):\n l=list(map(int,input().split()))\n lst.append(l)\nfor i in range(5):\n for j in range(5):\n if(lst[i][j]==1):\n print(abs(2-i)+abs(2-j))\n break"}, {"source_code": "A = [map(int,raw_input().split()) for i in range(5)]\npos = (0,0)\nfor i in range(5):\n for j in range(5):\n if A[i][j] == 1:\n pos = (i,j)\nans = abs(pos[0]-2) + abs(pos[1]-2)\nprint(ans)\n"}, {"source_code": "a = []\nfor i in range(5):\n l = str(input())\n l = list(map(int, l.split()))\n a.append(l)\nfor i in range(len(a)):\n for j in range(len(a[i])):\n if a[i][j] == 0:\n continue\n if a[i][j] == 1:\n current = (i+1, j+1)\ntarget = (3, 3)\nmoves_i = abs(target[0] - current[0])\nmoves_j = abs(target[1] - current[1])\nprint(moves_i + moves_j)"}, {"source_code": "L=[]\nn=5\nwhile n:\n l=list(input().split())\n L.append(l)\n n=n-1\ncount=0\nif '1' in L[0]:\n count=count+2\n if '1' == L[0][0]:\n count=count+2\n elif '1' == L[0][1]:\n count=count+1\n elif '1' == L[0][3]:\n count=count+1\n elif '1' == L[0][4]:\n count=count+2\nelif '1' in L[1]:\n count=count+1\n if '1' == L[1][0]:\n count=count+2\n elif '1' == L[1][1]:\n count=count+1\n elif '1' == L[1][3]:\n count=count+1\n elif '1' == L[1][4]:\n count=count+2\nelif '1' in L[2]:\n if '1' == L[2][0]:\n count=count+2\n elif '1' == L[2][1]:\n count=count+1\n elif '1' == L[2][3]:\n count=count+1\n elif '1' == L[2][4]:\n count=count+2\nelif '1' in L[3]:\n count=count+1\n if '1' == L[3][0]:\n count=count+2\n elif '1' == L[3][1]:\n count=count+1\n elif '1' == L[3][3]:\n count=count+1\n elif '1' == L[3][4]:\n count=count+2\nelif '1' in L[4]:\n count=count+2\n if '1' == L[4][0]:\n count=count+2\n elif '1' == L[4][1]:\n count=count+1\n elif '1' == L[4][3]:\n count=count+1\n elif '1' == L[4][4]:\n count=count+2\nprint(count)"}, {"source_code": "#https://codeforces.com/problemset/problem/263/A\n#11Apr2020\ni1=input()\ni2=input()\ni3=input()\ni4=input()\ni5=input()\ni,j=0,0\nif '1' in i1:\n\ti=1\n\tj=i1.index('1')\nelif '1' in i2:\n\ti=2\n\tj=i2.index('1')\nelif '1' in i3:\n\ti=3\n\tj=i3.index('1')\nelif '1' in i4:\n\ti=4\n\tj=i4.index('1')\nelif '1' in i5:\n\ti=5\n\tj=i5.index('1')\nj=j/2\nres=abs(i-3)+abs(j-2)\nprint(int(res))"}, {"source_code": "x = []\nz = 0\nfor i in range(5):\n x.append(list(map(int, input().split(\" \"))))\n for j in range(len(x[i])):\n if(x[i][j]==1):\n if(i!=2):\n if(i%2==0):\n z += 2\n else:\n z += 1\n if(j!=2):\n if(j%2==0):\n z += 2\n else:\n z += 1\nprint(z)"}, {"source_code": "import math\ns=\"\"\nfor x in range(0,5):\n s=s+input().replace(\" \",\"\")\np=int(math.log10(int(s)))\nprint(abs(p//5-2)+abs(p%5-2))"}, {"source_code": "x = ''.join([''.join(input().split()) for i in range(5)]).index('1')\nprint(abs(2 - x % 5) + abs(2 - x // 5))\n"}, {"source_code": "for row in range(5):\n s = input().split()\n for col in range(5):\n if s[col] == \"1\":\n a = abs(row-2)+abs(col-2)\n \nprint(a)"}, {"source_code": "def matrix():\n for i in range(5):\n k = raw_input().split()\n k = map(int,k)\n for x in range(5):\n if (k[x]==1):\n #print (i,x)\n a = abs(i-2)\n b = abs(x-2)\n print (a+b)\n\nmatrix() "}, {"source_code": "summ=0\nfor i in range(1,6):\n t=str(input()).split()\n j=0\n for j in range(5):\n if int(t[j])==1:\n summ=summ+abs(3-i)+abs(2-j)\nprint(summ)"}, {"source_code": "for i in range(5):\n s = input()\n if '1' in s:\n print(abs(i-2)+abs(s.find('1')//2-2))"}, {"source_code": "for i in range(5):\n s = input().split()\n if \"1\" in s:\n print(abs(i-2)+abs(s.index(\"1\")-2))"}], "negative_code": [{"source_code": "import sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp(): #Integer\n return(int(input()))\ndef inlt(): #integer list\n return(list(map(int,input().split())))\ndef insr(): #String\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n\n\n\n\nresult = 0\nfor row_idx in range(5):\n row = inlt()\n for idx, position in enumerate(row):\n if position == 1:\n result = abs(3-row_idx) + abs(3-idx)\nprint(result)\n"}, {"source_code": "from sys import stdin\nreal_number = [int(x) for x in stdin.read().split()]\nc = 0\nfor x in real_number[0:]:\n if x == 0:\n c += 1\n if x ==1:\n break\nif c == 12:\n print('0')\nif 0<=c<=4:\n if c==2:\n print('2')\n elif c%2 == 0:\n print('4')\n elif c%2 != 0 and c != 0:\n print('3')\nif 5<=c<=9:\n if c==7:\n print('1')\n elif c%2 == 0:\n print('2')\n elif c%2 != 0 and c!=7:\n print('3')\nif 11<=c<=15:\n if c%2 == 0 and c !=12:\n print('2')\n elif c%2!=0:\n print(1)\nif 15<=c<=19:\n if c==17:\n print('1')\n elif c%2 == 0:\n print('2')\n elif c%2 != 0 and c==17:\n print('3')\nif 20<=c<=24:\n if c == 22:\n print('2')\n elif c%2 ==0 and c!=22 and c != 24:\n print('3')\n elif c%2 != 0:\n print('3')\n elif c == 24:\n print('4')"}, {"source_code": "l = []\nfor i in range(5):\n\tl.append(list(map(int,raw_input().split(' '))))\nfor i in range(5):\n\tfor j in range(5):\n\t\tif l[i][j]:\n\t\t\tii,jj = i,j\nprint abs(3-ii)+abs(3-jj)\n"}, {"source_code": "for i in range(5):\n column = input().split()\n for j in range(5):\n if column[j]=='1':\n moves = (3-i)+(3-j)\n print(moves)"}, {"source_code": "a = []\n\nrow = []\ncol = []\n\nfor i in range(5):\n i = input().split(' ')\n a.append(i)\n\ni = 0\nn = 0\nwhile i < 6:\n if a[i][n] == '1':\n col = a[i].index('1')\n i += 1\n if i == 5:\n i = 0\n n += 1\n if n == 5:\n break\n\nfor i in range(5):\n if '1' in a[i]:\n if col == i:\n print(col)\n else:\n final = col - i\n print(abs(final))\n"}, {"source_code": "for i in range(5):\n column=input().split()\n for j in range(5):\n if 1==column[j]:\n s=abs(i-3)+abs(j-3)\n print(s)\n break\n"}, {"source_code": "def matrix():\n for i in range(5):\n k = raw_input().split()\n k = map(int,k)\n for x in range(5):\n if (k[x]==1):\n s = (x-i)\n if (s>=0):\n print s\n else:\n print -s\nmatrix()"}, {"source_code": "matrix = [[int(x) for x in input().split()] for i in range(5)]\nmoves = 0\n\nfor i in range(0,5,1) :\n for n in range(0,5,1):\n if matrix [i][n] == 1:\n if i != n :\n moves = abs (i - 2) + abs(n - 2)\n elif i == n :\n if n == 2 :\n moves = 0\n else :\n moves = (int(i/2))+2\n\n\nprint(moves)\n"}, {"source_code": "mat = []\nfor i in range(5):\n mat.append([int(_) for _ in input().split()])\n \nxi, xj = 0, 0\nfor i in range(5):\n for j in range(5):\n if mat[i][j] == 1:\n xi, xj == i, j\n \nprint(abs(xi-2)+abs(xj-2))\n"}, {"source_code": "for i in range(5):\n s=input()\n if \"1\" in s:\n print(abs(i-2)+abs(s.find('1')-2))"}, {"source_code": "for i in range (0,5):\n arr = list(map(int, input().strip().split())) \n for l in range(0,5):\n if arr[l]!=0:\n r=i\n c=l\nif r>=3:\n if c>=3:\n ans=r=c-6\n elif c<3:\n ans=r-c\nelif r<3:\n if c>=3:\n ans=c-r\n elif c<3:\n ans=6-r-c\nprint (ans)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\ndef inp(): #Integer\n return(int(input()))\ndef inlt(): #integer list\n return(list(map(int,input().split())))\ndef insr(): #String\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(map(int,input().split()))\n\n\n\n\nresult = 0\nfor row_idx in range(5):\n row = inlt()\n for idx, position in enumerate(row):\n if position == 1:\n result = abs(3-row_idx) + abs(3-idx)\nprint(result)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Nov 2 22:21:51 2020\n\n@author: 86177\n\n\n\"\"\"\na=list(input())\nb=list(input())\nc=list(input())\nd=list(input())\ne=list(input())\nf=[a,b,c,d,e]\nfor i in range(5):\n for n in range(5):\n if f[i][n] in [\"1\"]:\n h=int(i)--2 \n q=int(n)--2\n h=abs(h) \n q=abs(q)\n print(h++q)\n else:\n continue"}, {"source_code": "import sys\n'''\n - Matrix is assumed to be 5 x 5 of all 0s and exactly one 1.\n - Can swap matrix rows or columns.\n - Find minimum moves required to move 1 to the center.\n'''\ndef min_moves_for_beautiful_matrix(m):\n x = 0\n y = 0\n for i in range(0, 5):\n for j in range(0, 5):\n if m[i][j]:\n x = i\n y = j\n\n return abs(2-x) + abs(2-y)\n\n#matrix = [map(lambda x: int(x), line.split(' ')) for line in sys.stdin.read().split('\\n')]\n#print min_moves_for_beautiful_matrix(matrix)\nprint sys.stdin.read().split('\\n')\n"}, {"source_code": "t = 0\ni = 0\nfor j in range(5):\n s = input().replace(' ', '')\n pos = s.find('1')\n if s.find('1') > 0:\n t += abs(3 - pos + 1)\n t += abs(3 - i + 1)\n i += 1\nprint(t)\n"}, {"source_code": "\nl = [2, 1 ,0, 2, 1]\n\nfor i in l:\n s = input()\n if \"1\" in s:print(i+abs(s.find('1') - 2))\n"}, {"source_code": "for i in range(5):\n row = input().split()\n if '1' in row:\n loc = [i,row.index('1')]\nprint(abs(loc[0]-loc[1]))"}, {"source_code": "s = [0,1,0,0,0]\ns[0] = input()\ns[1] = input()\ns[2] = input()\ns[3] = input()\ns[4]= input()\nline1 = 0\nline2 = 0\nfor i in range(5):\n if \"1\" in s[i]:\n m = i\n line1 = i+1-3\n line1 = abs(line1)\nfor x in range(5):\n if s[m][x] == \"1\":\n line2 = abs(x+1-3)\nprint(line1+line2)"}, {"source_code": "a=[]\nfor i in range(5):\n a.append(list(map(int,input().split()))[:5])\nx,y=0,0\nfor i in range(5):\n for j in range(5):\n if(a[i][j]==1):\n x+=i\n y+=j\n break\nprint(abs(3-x)+abs(3-y))\n\n"}, {"source_code": "from sys import stdin\nreal_number = [int(x) for x in stdin.read().split()]\nc = 1\nfor x in real_number[0:]:\n if x == 0:\n c += 1\n if x ==1:\n break\n \nif 1 <= c <= 5:\n row = 1\nif 6 <= c <= 10:\n row = 2\nif 11 <= c <= 15 and c != 13:\n row = 3\nif 16 <= c <= 20:\n row = 4\nif 21 <= c <= 25:\n row = 5\n \nif c == 1 or c == 6 or c == 11 or c == 16 or c == 21:\n column = 1\nif c == 2 or c == 7 or c == 12 or c == 17 or c == 22:\n column = 2\nif c == 3 or c == 8 or c == 18 or c == 23:\n column = 3\nif c == 4 or c == 9 or c == 14 or c == 19 or c == 24:\n column = 4\nif c == 5 or c == 10 or c == 15 or c == 20 or c == 25:\n column = 5\n \nif c==13:\n print('0')\nelif row >= 3 and column >= 3 and c!=13:\n print((row -3) + (column-3))\nelif row <= 3 and column >= 3 and c!=13:\n print((3-row) + (column-3))\nelif row >= 3 and column <= 3 and c!=13:\n print((row-3) + (3-column))\nelif row < 3 and column < 3 and c!=13:\n print((row-3) + (column-3))"}, {"source_code": "a = []\n\nfor i in range(5):\n i = input().split(' ')\n a.append(i)\n\nfor i in range(5):\n if '1' in a[i]:\n if a[i].index('1') >= 4:\n final = a[i].index('1') - 1\n print(final)\n else:\n print(a[i].index('1'))\n break\n"}, {"source_code": "for x in range(0,5):\n r = raw_input()\n \n if r != '0 0 0 0 0':\n l = list(r)\n p = 0\n if x > 3:\n p = x - 3\n else:\n p = 3 - x\n\n q =0\n for a in range(0,9):\n if l[a]=='1':\n if a > 5:\n q = a - 5\n else:\n q = 5 - a\n\n add = p + q/2\n\nprint add\n"}, {"source_code": "a = input().split()\nb = input().split()\nc = input().split()\nd = input().split()\ne = input().split()\n\nfor i in range(9):\n if a[0] == \"1\" or a[4] == \"1\" or e[0] == \"1\" or a[4] == \"1\" :\n output = 4\n elif a[1] == \"1\" or a[3] == \"1\" or e[1] == \"1\" or e[3] == \"1\" or b[0] == \"1\" or b[4] == \"1\" or d[0] == \"1\" or d[4] == \"1\" :\n output = 3\n elif a[2] == \"1\" or b[1] == \"1\" or b[3] == \"1\" or c[0] == \"1\" or c[4] == \"1\" or d[1] == \"1\" or d[3] == \"1\" or e[2] == \"1\" :\n output = 2\n else :\n output = 1\n \nprint(output)\n \n"}, {"source_code": "matrix = [[int(x) for x in input().split()] for i in range(5)]\nmoves = 0\n\nfor i in range(0,5,1) :\n for n in range(0,5,1):\n if matrix [i][n] == 1:\n if i != n :\n moves = abs (i - 2) + abs(n - 2)\n elif i == n :\n if n == 2 :\n moves = 0\n else :\n moves = (int(i/2))+2\n\n\nprint(moves)\n"}, {"source_code": "\n# CF-A Q1\n\n# a,b = input().split()\n\n# kids = [int(i) for i in input().split()]\n\n# count = 0 \n# for i in kids:\n# \tif i >int(b):\n# \t\tcount += 2\n# \telse:\n# \t\tcount += 1\n\n# print(count)\n\n\n\n#CF-A Q2\n\n# a = int(input())\n# game = input()\n# danik = game.count('D')\n# anton = game.count('A')\n\n\n# if danik>anton:\n# \tprint('Danik')\n# elif danikb:\n# \t\tprint(count)\n# \t\tbreak\n\n\n#CF-A Q4\n\n# solved in the past\n\n\n\n#CF-A Q5\n\n\nfrom pprint import pprint\n\na = [[int(i) for i in input().split()] for j in range(1,6) ]\n\nfor i in a:\n\tfor j in i:\n\t\tif j==1:\n\t\t\trow = a.index(i) \n\t\t\tcolumn = i.index(j) \n\t\t\tposition = a[row][column] # element position in matrix\n\nrow = row + 1\ncolumn = column + 1\n\nif row + column != 6:\n\tif row>column:\n\t\tprint(row-column)\n\telse:\n\t\tprint(column-row)\n\t\t\t\nelse:\n\tprint(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": "# n = input\narr = []\n\n\nfor i in range(0, 5):\n\ta = map(int, input().split())\n\tarr.append(list(a))\n\n\n\nctr = 0\ni = 0\n\n\nwhile i < len(arr):\n\ta = 0\n\twhile a < len(arr[i]):\n\t\tif arr[i][a] == 1:\n\t\t\tif arr[i].index(1) == 2 and arr.index(arr[i]) == 2:\n\t\t\t\tprint(0)\n\t\t\t\tbreak\n\t\t\tif arr[i].index(1) != 2:\n\t\t\t\tinner = arr[i].index(1)\n\t\t\t\tif inner == 4 or inner == 0:\n\t\t\t\t\tctr += 2\n\t\t\t\telse:\n\t\t\t\t\tctr += 1\n\n\t\t\t\touter = arr.index(arr[i])\n\n\t\t\t\tif outer != 2:\n\t\t\t\t\tif outer == 1 or outer == 3:\n\t\t\t\t\t\tctr += 1\n\t\t\t\t\telse:\n\t\t\t\t\t\tctr += 2\n\n\t\t\t\tbreak\n\n\t\t\telse:\n\t\t\t\touter = arr.index(arr[i])\n\n\t\t\t\tif outer == 1 or outer == 3:\n\t\t\t\t\tctr += 1\n\t\t\t\telse:\n\t\t\t\t\tctr += 2\n\n\t\t\t\tbreak\n\t\ta += 1\n\ti += 1\n\nprint(ctr)"}, {"source_code": "l = []\namount = 0\nfor i in range(5):\n s = list(map(int, input().split()))\n if 1 in s:\n x = s.index(1)\n y = i\n l.append(s)\nif x != 2: amount += abs(2 - x)\nelif y != 2: amount += abs(2 - y)\nprint(amount)\n\n# 0 0 0 0 0\n# 0 0 0 0 0\n# 0 1 0 0 0\n# 0 0 0 0 0\n# 0 0 0 0 0\n"}, {"source_code": "n = input()\ncount = 0\nrow = 0\ncol = 0\nfor i in range(5):\n for j in range(5):\n if n[i][j] == 1:\n row = i\n col = j\n break\n break \nif row > 2 and row != 2: \n row -= 1 \n count += 1\nelif row < 2 and row != 2:\n row += 1\n count += 1\nelse:\n pass\n \nif col < 2 and col != 2:\n col += 1\n count += 1\nelif col > 2 and col != 2:\n col -= 1\n count += 1\nelse:\n pass\n\nprint(count+1)"}, {"source_code": "for i in range(5):\n column = input().split()\n for j in range(5):\n if column[j]=='1':\n moves = abs(i-3)+abs(j-3)\n print(moves)\n "}, {"source_code": "for i in range(5):\n s = input()\nif '1' in s:\n print(abs(i-2)+abs(s.find('1')//2-2))"}, {"source_code": "def matrix():\n for i in range(5):\n k = raw_input().split()\n k = map(int,k)\n for x in range(5):\n if (k[x]==1):\n if (x==i)and(x!=2):\n s = 4\n else:\n s = (x-i)\n if (s>=0):\n print s\n else:\n print -s\nmatrix()"}, {"source_code": "I=0\nJ=0\nX=[]\nfor i in range(5):\n a=input().split()\n map(int,a)\n X.append(a)\nprint(X)\nfor i in range(4):\n for j in range(4):\n if X[i][j]==1:\n I=i+1\n J=j+1\nprint(abs(I-3)+abs(I-3))"}, {"source_code": "found = 0\nfor row in range (5):\n if (found == 1):\n break;\n col = 0\n for number in raw_input().split():\n if number == \"1\":\n found = 1\n break;\n else:\n col = col + 1\nprint (abs(row - 2) + abs(col - 2))"}, {"source_code": "for i in range(5):\n row = input()\n for j in range(5):\n if row[j] == '1':\n num = abs(i-2) + abs(j-2)\n print(num)"}, {"source_code": "\narr =[[0 for _ in range(5)] for _ in range(5)]\n# print(arr)\nfor i in range(5):\n arr[i] = list(map(int,input().split()))\n if 1 in arr[i]:\n for j in range(5):\n if arr[i][j] == 1:\n posI = i\n posJ = j\nprint(abs(-4+posJ+posI)) \n "}, {"source_code": "x = 0\ny = 0\nfor i in range(5):\n line = raw_input().split(\" \")\n for j in range(5):\n if (int(line[j]) == 1):\n x = i\n y = j\n\nprint abs(x - 3) + abs(y - 3)"}, {"source_code": "found = 0\nfor row in range (5):\n if (found == 1):\n break;\n col = 0\n for number in raw_input().split():\n if number == \"1\":\n found = 1\n break;\n else:\n col = col + 1\nprint (abs(row - 2) + abs(col - 2))"}, {"source_code": "count=0\nfor i in range(5):\n a = list(map(int, input().strip().split()))[:5]\n if 1 in a:\n row=i+1\n for i in range(5):\n if a[i]==1:\n col=i+1\n break\nif row==1 or row==5:\n count+=2\nelif row==2 or row==3:\n count+=1\nif col==1 or col==5:\n count+=2\nelif col==2 or col==3:\n count+=1\nprint(count)"}, {"source_code": "a = input().split()\nb = input().split()\nc = input().split()\nd = input().split()\ne = input().split()\n\nfor i in range(9):\n if a[0] == \"1\" or a[4] == \"1\" or e[0] == \"1\" or a[4] == \"1\" :\n output = 4\n elif a[1] == \"1\" or a[3] == \"1\" or e[1] == \"1\" or e[3] == \"1\" or b[0] == \"1\" or b[4] == \"1\" or d[0] == \"1\" or d[4] == \"1\" :\n output = 3\n elif a[2] == \"1\" or b[1] == \"1\" or b[3] == \"1\" or c[0] == \"1\" or c[4] == \"1\" or d[1] == \"1\" or d[3] == \"1\" or e[2] == \"1\" :\n output = 2\n else :\n output = 1\n \nprint(output)\n \n"}, {"source_code": "I=0\nJ=0\nX=[]\nfor i in range(5):\n a=input().split()\n map(int,a)\n X.append(a)\nfor i in range(4):\n for j in range(4):\n if X[i][j]==1:\n I=i+1\n J=j+1\nprint(abs(I-3)+abs(J-3))"}, {"source_code": "# Getting all inputs\nfor i in range(5):\n a = map(int, raw_input().split())\n print a\n "}, {"source_code": "count=0\nfor i in range(5):\n s=input()\n if '1'in s:\n count=abs(i-2)+abs(s.find('1')-2)\nprint(count)\n "}, {"source_code": "i = 1\n\nwhile i <= 5:\n listnum = [int(b) for b in input().split()]\n \n if 1 in listnum:\n indexX = listnum.index(1)+1\n indexY = i\n \n i += 1\n\nprint(indexX, indexY)"}, {"source_code": "a = []\n\nrow = []\ncol = []\n\nfor i in range(5):\n i = input().split(' ')\n a.append(i)\n\n# print(a[2][2]) center\n\n# print(a[b][0]) row\n\ni = 0\nn = 0\nwhile i < 6:\n # print(a[i][n])\n if a[i][n] == '1':\n col = a[i].index('1')\n i += 1\n if i == 5:\n i = 0\n n += 1\n if n == 5:\n break\n\nfor i in range(5):\n if '1' in a[i]:\n final = col - i\n print(abs(final))\n"}, {"source_code": "row1 = input(\"\")\nrow2 = input(\"\")\nrow3 = input(\"\")\nrow4 = input(\"\")\nrow5 = input(\"\")\ntotal = f\"{row1} {row2} {row3} {row4} {row5}\"\ntotal = total.split(\" \")\nfor i in total:\n if i == \"1\":\n ans = 13 - total.index(i)\n print(ans)"}, {"source_code": "def lie(n):\n m=1\n if '1' in n:\n for i in n:\n if i=='1':\n return m\n else:\n m=m+1\ndef zong():\n for o in range(5):\n c = 1\n a = str(input())\n b = list(a)\n if '1' in b:\n return c\n else:\n c = c+1\n print(abs(3-c)+abs(3-lie(b)))\n\nzong()\n\n\n"}, {"source_code": "import sys\n\nstringsList = []\nwidth = 0\n\nfor line in sys.stdin:\n stringsList.append(line)\nprint(stringsList)\nfor index in range(0, len(stringsList)):\n if '1' in stringsList[index]:\n width = index\n break\n\nresult = abs(width - 3) + abs(stringsList[width].find('1') - 3)\n"}, {"source_code": "a = [list(map(int, input().split()))]\nfor r in range(len(a)):\n for c in range(len(a[r])):\n if a[r][c] == 0:\n print(abs(r+1-3)+abs(c+1-3))\n break\n"}, {"source_code": "import sys\nl = []\ncount = 0\n\nfor i in range(5):\n\tl.append(map(int, raw_input().split(\" \")))\n\nfor i in range(5):\n\tif(l[2][2] == 1):\n\t\tprint(\"{0}\".format(count))\n\t\tbreak\n\tfor j in range(5):\n\t\tif(l[i][j] == 1) and (i<2):\n\t\t\ttemp = l[i+1][j]\n\t\t\tl[i+1][j] = l[i][j]\n\t\t\tl[i][j] = temp\n\n\t\t\tcount+=1\n\t\tif(l[i][j] == 1) and (j<2):\n\t\t\ttemp = l[i][j+1]\n\t\t\tl[i][j+1] = l[i][j]\n\t\t\tl[i][j] = temp\n\n\t\t\tcount+=1"}, {"source_code": "x = \"\"\nfor i in range(5):\n z = input()\n x += z\nx = x.split(); s = \"\"; x = s.join(x); one = str(x.index(\"1\")); val = 0\n\nif one == \"0\" or one == \"5\" or one == \"10\" or one == \"15\" or one == \"20\" or one == \"4\" or one == \"9\" or one == \"14\" or one == \"19\" or one == \"24\":\n val += 2\nelif one == \"1\" or one == \"6\" or one == \"11\" or one == \"16\" or one == \"21\" or one == \"3\" or one == \"8\" or one == \"13\" or one == \"18\" or one == \"23\":\n val += 1\nelif one == \"2\" or one == \"7\" or one == \"12\" or one == \"17\" or one == \"22\":\n val += 0\n\nif one == \"0\" or one == \"1\" or one == \"2\" or one == \"3\" or one == \"4\" or one == \"20\" or one == \"21\" or one == \"23\" or one == \"24\":\n val += 2\nelif one == \"5\" or one == \"6\" or one == \"7\" or one == \"8\" or one == \"9\" or one == \"15\" or one == \"16\" or one == \"17\" or one == \"18\" or one == \"19\":\n val += 1\nelif one == \"10\" or one == \"11\" or one == \"12\" or one == \"13\" or one == \"14\":\n val += 0\n\nprint(val)"}, {"source_code": "for x in range(5):\n i = input().split()\n if '1' in i:\n print(abs(x+1-3) + abs(i.index('1')-3))"}, {"source_code": "m=[];\nfor i in range(5):\n m.append(map(int,raw_input().split()));\nfor i in range(5):\n for j in range(5):\n if(m[i][j]==1):\n print i+j;\n break;\n"}, {"source_code": "\n# CF-A Q1\n\n# a,b = input().split()\n\n# kids = [int(i) for i in input().split()]\n\n# count = 0 \n# for i in kids:\n# \tif i >int(b):\n# \t\tcount += 2\n# \telse:\n# \t\tcount += 1\n\n# print(count)\n\n\n\n#CF-A Q2\n\n# a = int(input())\n# game = input()\n# danik = game.count('D')\n# anton = game.count('A')\n\n\n# if danik>anton:\n# \tprint('Danik')\n# elif danikb:\n# \t\tprint(count)\n# \t\tbreak\n\n\n#CF-A Q4\n\n# solved in the past\n\n\n\n#CF-A Q5\n\n\nfrom pprint import pprint\n\na = [[int(i) for i in input().split()] for j in range(1,6) ]\n\nfor i in a:\n\tfor j in i:\n\t\tif j==1:\n\t\t\trow = a.index(i) \n\t\t\tcolumn = i.index(j) \n\t\t\tposition = a[row][column] # element position in matrix\n\nrow = row + 1\ncolumn = column + 1\n\npos = row+column\n\n\nif pos > 6 or pos < 6:\n\tif row>column:\n\t\tprint(row-column)\n\telif column>row:\n\t\tprint(column-row)\n\telse:\n\t\tprint((row-3) + (column-3))\n\t\t\t\nelse:\n\tprint(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": "matrix = [input().split() for i in range(5)]\nfor i in range(5):\n for j in range(5):\n if matrix[i][j] == \"1\":\n break\n \nprint(abs(i-2)+abs(j-2))"}, {"source_code": "for i in range (0,5):\n arr = list(map(int, input().strip().split())) \n for l in range(0,5):\n if arr[l]!=0:\n r=i+1\n c=l+1\nif r>=3:\n if c>=3:\n ans=r=c-6\n elif c<3:\n ans=r-c\nelif r<3:\n if c>=3:\n ans=c-r\n elif c<3:\n ans=6-r-c\nprint (ans)"}, {"source_code": "a = [list(map(int, input().split()))]\nfor r in range(len(a)):\n for c in range(len(a[r])):\n if a[r][c] == 0:\n print(abs(r-3)+abs(c-3))\n break\n"}, {"source_code": "for i in range(1,6):\n x=input()\n if \"1\" in x:\n row_n= i\n row = x\nr_steps=abs(row_n - 3)\nc_steps = abs((x.find(\"1\") + 1) - 3)\nprint(r_steps + c_steps)\n"}, {"source_code": "a = [[int(i) for i in input().split()] for j in range(5)]\nfor i in range(5):\n for f in range(5):\n if 1==a[i][f]:\n c=f\n r=i\nprint(c,r)\nprint(abs((2-c)+(2-r)))\n"}, {"source_code": "\narr =[[0 for _ in range(5)] for _ in range(5)]\n# print(arr)\nfor i in range(5):\n arr[i] = list(map(int,input().split()))\n if 1 in arr[i]:\n for j in range(5):\n if arr[i][j] == 1:\n posI = i\n posJ = j\nprint(abs(-4+posJ+posI)) \n "}, {"source_code": "row, column = 0, 0\nfor i in range(5):\n lis = list(map(int, input().split()))\n for j in range(5):\n if lis[j] == 1:\n row, column = i+1, j+1\n break\n print(abs(row-3)+abs(column-3))"}, {"source_code": "row = 0\ncolumn = 0\n\nfor i in range(5):\n row += 1\n l = input().split()\n if '1' in l:\n column = l.index('1')\n break\n \nprint(abs(row-3)+abs(column-3-1))"}, {"source_code": "a = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\nd = list(map(int, input().split()))\ne = list(map(int, input().split()))\ns = 0\nfor i in range(len(a)):\n if a[i]==1:\n if i<=2:\n s=4-i\n else:\n s=i-1\n\nfor i in range(len(b)):\n if b[i]==1:\n if i<=2:\n s=4-i\n else:\n s=i-1\n\nfor i in range(len(c)):\n if c[i]==1:\n if i<2:\n s=i\n elif i>3:\n s=i-2\n else:\n s=0\n\nfor i in range(len(d)):\n if d[i]==1:\n if i<=2:\n s=4-i\n else:\n s=i-1\n\nfor i in range(len(e)):\n if e[i]==1:\n if i<=2:\n s=4-i\n else:\n s=i-1\n\nprint(s)"}, {"source_code": "diffX = 0\ndiffY = 0\nmatrix = []\nx,y = 0,0\nfor _ in range(4):\n #matrix.append(list(map(int,\"0 0 0 0 0\".split(' '))))\n matrix.append(list(map(int,input().split(' '))))\n#matrix.append(list(map(int,\"0 0 1 0 0\".split(' '))))\nprint(matrix)\nfor i in range(4):\n for j in range(4):\n if matrix[i][j] == 1:\n x = i\n y = j\nprint(\"x: \" + str(x) + \" y: \" + str(y))\n\nif y > 2:\n diffY = 2 - y\nelse:\n diffY = y - 2\nif x > 2:\n diffX = 2 - x\nelse:\n diffX = x - 2\nprint(abs(diffX+diffY))"}, {"source_code": "matrix = [x.split() for x in input().split(\"\\n\")]\ni, j = 0, 0\n\nfor y in matrix:\n for x in y:\n if(x == \"1\"):\n i, j = matrix.index(y), y.index(x)\nprint(5-i + 5-j - 2)\n\n\n"}, {"source_code": "found = 0\nfor row in range (1, 5):\n if (found == 1):\n break;\n col = 1\n for number in raw_input().split():\n if number == \"1\":\n found = 1\n break;\n else:\n col = col + 1\nprint (abs(row - 3) + abs(col - 3)) - 1"}, {"source_code": "for i in range(5):\n row = input().split()\n if '1' in row:\n loc = [i,row.index('1')]\nprint(abs(loc[0]-loc[1]))"}, {"source_code": "b = []\nx=0\ny=0\nfor i in range (5):\n b.append(list(map(int,input().split())))\n if b[i].count(0) != 5:\n x = b[i].index(1)\n y=i\n break\nprint(abs(2-x)+(2 -y))"}, {"source_code": "for i in range(5):\n column=input().split()\n for j in range(5):\n if 1==column[j]:\n s=abs(i-2)+abs(j-2)\n print(s)\n"}, {"source_code": "for i in range(0,5):\n a = input()\n \n print(a,type(a))"}, {"source_code": "matrix = []\nfor i in range(0, 5):\n st = input(\"\")\n s = list(st.split(\" \"))\n lis = [int(x) for x in s]\n matrix.append(lis)\n\n\n\nfor k in range(0, 5):\n for j in range(0, 5):\n if matrix[k][j] == 1:\n total = abs(k - 3) + abs(j - 3)\n else:\n continue\nprint(total)\n\n"}, {"source_code": "\narr =[[0 for _ in range(5)] for _ in range(5)]\n# print(arr)\nfor i in range(5):\n arr[i] = list(map(int,input().split()))\n if 1 in arr[i]:\n for j in range(5):\n if arr[i][j] == 1:\n posI = i\n posJ = j\nprint(10-posJ-posI) \n "}, {"source_code": "a,b=0,0\nfor i in range(0,5):\n s=input()\n if'1' in s:\n a=i\n b=s.split().index('1')+1\n break\n \nprint(abs(3-a) + abs(3-b)) "}, {"source_code": "a=[]\nimport math\nfor i in range(0, 5):\n b=list(map(int, input().split()))\n a.append(b)\nr=int(0)\nc=int(0)\nfor i in range(0,5):\n for j in range(0, 5):\n if a[i][j]==1:\n r=i\n c=j\nm=abs(3-r+1)+abs(3-c+1)\nprint(m)"}, {"source_code": "for i in range(5):\n column = input().split()\n for j in range(5):\n if column[j]=='1':\n moves = abs(i-3)+abs(j-3)\n print(moves)\n "}, {"source_code": "# 263A => Beautiful Matrix\n# https://codeforces.com/problemset/problem/263/A\n\nlinha = 0\ncoluna = 0\nmatrix = []\nfor _ in range(5):\n linhaa = input().split()\n matrix.append(linhaa)\n if linhaa.count(\"1\") == 1:\n linha = _ + 1\n coluna = linhaa.index(\"1\") + 1\nmoves = 0\nmoves += abs(linha - 2) + abs(coluna - 2)\nprint(moves)"}, {"source_code": "x = \"\"\nfor i in range(5):\n z = input()\n x += z\nx = x.split(); s = \"\"; x = s.join(x); one = str(x.index(\"1\")); val = 0\n\nif one == \"0\" or one == \"5\" or one == \"10\" or one == \"15\" or one == \"20\" or one == \"4\" or one == \"9\" or one == \"14\" or one == \"19\" or one == \"24\":\n val += 2\nelif one == \"1\" or one == \"6\" or one == \"11\" or one == \"16\" or one == \"21\" or one == \"3\" or one == \"8\" or one == \"13\" or one == \"18\" or one == \"23\":\n val += 1\nelif one == \"2\" or one == \"7\" or one == \"12\" or one == \"17\" or one == \"22\":\n val += 0\n\nif one == \"0\" or one == \"1\" or one == \"2\" or one == \"3\" or one == \"4\" or one == \"20\" or one == \"21\" or one == \"23\" or one == \"24\":\n val += 2\nelif one == \"5\" or one == \"6\" or one == \"7\" or one == \"8\" or one == \"9\" or one == \"15\" or one == \"16\" or one == \"17\" or one == \"18\" or one == \"19\":\n val += 1\nelif one == \"10\" or one == \"11\" or one == \"12\" or one == \"13\" or one == \"14\":\n val += 0\n\nprint(val)"}, {"source_code": "for i in range(5):\n n=list(filter(str.isdigit,input()))\n m=list(map(int,n))\n num=sum(m)\n if num==1:\n D=i+1\n er=m\nfor O in range(5):\n if er[O]==1:\n C=O+1\nprint(abs(6-(C+D)))"}, {"source_code": "import math\nl=[]\nfor i in range(5):\n ch=input()\n l.append(ch.split())\ndef test(l):\n for i in range(len(l)):\n for j in range(len(l)):\n if l[i][j]==\"1\":\n return (i,j)\nx=test(l)\nprint(abs(x[0]-x[1]))\n"}, {"source_code": "for x in range(5):\n r = list(map(int , input().split()))\n for c in r:\n if c == 1:\n i = x\n j = r[c]\nprint(abs(2- i) + abs(2 - j))"}, {"source_code": "for x in range(0,5):\n r = raw_input()\n \n if r != '0 0 0 0 0':\n l = list(r)\n p = 0\n if x > 3:\n p = x - 3\n else:\n p = 3 - x - 1\n\n q =0\n for a in range(0,9):\n if l[a]=='1':\n if a > 5:\n q = a - 5\n else:\n q = 5 - a\n\n add = p + q/2\n\nprint add"}, {"source_code": "import sys\n\ngrid = [[int(x) for x in i.split(' ')] for i in sys.stdin.read().split('\\n')[:5]]\n\nrow = 0\n\nfor line in grid:\n if '1' in line:\n sys.stdout.write(str(abs(row - 2) + abs(line.index('1') - 2)))\n quit(0)\n row += 1"}, {"source_code": "matrix = []\n\nfor i in range(5):\n matrix.append(list(input().split()))\n\nposition = [(index, row.index('1')) for index, row in enumerate(matrix) if '1' in row]\n\nr,c = position[0]\n\nprint(position)\n\nbeauty = abs((r-2))+abs((c-2))\n\nprint(beauty)"}, {"source_code": "mat=[]\nfor i in range(0,5):\n mat.append([]);\n taker=raw_input()\n print taker\n for j in range(0,len(taker)):\n if taker[j]!=' ':\n mat[i].append(taker[j]);\nii=-1;\njj=-1;\nfor i in range(0,len(mat)):\n for j in range(0,len(mat[i])):\n if mat[i][j]=='1':\n ii=i;\n jj=j;\n break\n if ii==i:\n break\nprint abs(ii-2)+abs(jj-2)"}, {"source_code": "p = [int(x) for x in input().split()]\nq = [int(x) for x in input().split()]\ns = [int(x) for x in input().split()]\nr = [int(x) for x in input().split()]\nt = [int(x) for x in input().split()]\nif p.count(1):\n print(p.index(1))\nelif q.count(1):\n print(q.index(1)-1)\nelif s.count(1):\n print(abs(s.index(1)-2))\nelif t.count(1):\n print(t.index(1))\nelif r.count(1):\n print(r.index(1)-1)\n"}, {"source_code": "a1, a2, a3, a4, a5 = (input().split())\nb1, b2, b3, b4, b5 = (input().split())\nc1, c2, c3, c4, c5 = (input().split())\nd1, d2, d3, d4, d5 = (input().split())\ne1, e2, e3, e4, e5 = (input().split())\n\nif '1' in c3:\n print('0')\nelif '1' in b3 or c4 or c2 or d3:\n print('1')\nelif '1' in a3 or b4 or c5 or d4 or e3 or d2 or c1 or b2:\n print('2')\nelif 'i' in a2 or a4 or b5 or d5 or e4 or e2 or d1 or b1:\n print('3')\nelse:\n print('4')\n\n"}, {"source_code": "for i in xrange(5):\n s = raw_input().split()\n t = c = 0\n if '1' in s:\n t = i\n c = s.index('1')\nprint abs(2-t)+abs(c-2)\n"}, {"source_code": "\"\"\"\nhttps://codeforces.com/problemset/problem/263/A\n\"\"\"\ndef move (array, posi): #this is to find the moves of the number and return it\n if posi == \"3\":\n return 0\n elif (posi>3):\n return (5 - posi)\n elif (posi<3):\n return (3-posi)\n\ndef odd_location_and_calculation(array):\n # this function willl return the location of \"1\" in the diven 3-D matrix in tems of x, y coordinates\n check = 0\n for i in range(5):\n for j in range(5):\n if array[i][j] == 1:\n x_coordinate = i\n y_coordinate = j\n break\n check = 1\n if check == 1:\n break\n x_move = move(array, x_coordinate)\n y_move = move(array, y_coordinate)\n return (x_move+y_move)\n\n\nif __name__ == \"__main__\":\n array = []\n for i in range(5):\n rowArray = list(map(int, input().split(\" \")))\n array.append(rowArray)\n print(odd_location_and_calculation(array))\n"}, {"source_code": "for i in range(5):\n s = input()\nif '1' in s:\n print((abc(i-2))+abc(s.find('1')//2-2))"}, {"source_code": "\nmoves=0\n\nfor i in range(1,6):\n \n line=raw_input()\n line=line.replace(\" \", \"\")\n \n if \"1\" in line:\n column=line.find(\"1\")\n \n moves=abs(3-i)+abs(3-column)\n \nprint moves\n "}, {"source_code": "for x in range(0,5):\n r = raw_input()\n \n if r != '0 0 0 0 0':\n l = list(r)\n p = 0\n if x > 3:\n p = x +1 - 3\n else:\n p = 3 - x - 1\n\n q =0\n for a in range(0,9):\n if l[a]=='1':\n if a > 5:\n q = a + 1 - 5\n else:\n q = 5 - a - 1\n\n add = p + q/2\n\nprint add\n"}, {"source_code": "n1 = list(map(int, raw_input().split()))\nn2 = list(map(int, raw_input().split()))\nn3 = list(map(int, raw_input().split()))\nn4 = list(map(int, raw_input().split()))\nn5 = list(map(int, raw_input().split()))\nmrow=2\nmcol=2\n\nif 1 in n1:\n row = 0\n column = n1.index(1)\nelif 1 in n2:\n row = 1\n column = n2.index(1)\nelif 1 in n3:\n row = 2\n column = n3.index(1)\nelif 1 in n4:\n row = 3\n column = n4.index(1)\nelif 1 in n5:\n row = 4\n column = n5.index(1)\nres=(mrow-row)+(mcol-column)\nprint res\n\n\n\n"}, {"source_code": "l=[]\nfor i in range(5):\n ch=input()\n l.append(ch.split())\ndef test(l):\n for i in range(len(l)):\n for j in range(len(l)):\n if l[i][j]==\"1\":\n return (i,j)\nx=test(l)\nif x[0]>x[1]:\n print(abs(x[0]-x[1]))\nelse:\n print(abs(x[1]-x[0]))\n"}, {"source_code": "# Getting all inputs\nfor i in range(5):\n a = map(int, raw_input().split())\n print a\n "}, {"source_code": "import sys\n\nstringsList = []\nheight = 0\nwidth = 0\n\nfor line in sys.stdin:\n print(line)"}, {"source_code": "for i in range(5):\n column = input().split()\n for j in range(5):\n if column[j]=='1':\n moves = (3-i)+(3-j)\n print(moves)"}, {"source_code": "\nfrom math import *\nrow1 = input(\"\")\nrow2 = input(\"\")\nrow3 = input(\"\")\nrow4 = input(\"\")\nrow5 = input(\"\")\ntotal = f\"{row1} {row2} {row3} {row4} {row5}\"\ntotal = total.split(\" \")\nfor i in total:\n if i == \"1\" and total.index(i) <= 12:\n ans = 12 - abs(total.index(i))\n print(ans)\n elif i == \"1\" and total.index(i) > 12:\n ans = 12 - total.index(i)\n print(ans)"}, {"source_code": "row1 = input(\"\")\nrow2 = input(\"\")\nrow3 = input(\"\")\nrow4 = input(\"\")\nrow5 = input(\"\")\ntotal = f\"{row1} {row2} {row3} {row4} {row5}\"\ntotal = total.split(\" \")\nfor i in total:\n if i == \"1\":\n ans = 12 - total.index(i)\n print(ans)"}, {"source_code": "\"\"\"\n\"\"\"\ndef move (array, posi): #this is to find the moves of the number and return it\n if posi == 2:\n return 0\n elif (posi>2):\n return (posi - 2)\n elif (posi<2):\n return (2 - posi)\n\ndef odd_location_and_calculation(array):\n # this function willl return the location of \"1\" in the diven 3-D matrix in tems of x, y coordinates\n check = 0\n for i in range(5):\n for j in range(5):\n if array[i][j] == 1:\n y_coordinate = i\n x_coordinate = j\n break\n check = 1\n if check == 1:\n break\n x_move = move(array, x_coordinate)\n y_move = move(array, y_coordinate)\n print(x_coordinate)\n print(y_coordinate)\n return (x_move+y_move)\n\n#this is a new program\n\nif __name__ == \"__main__\":\n array = []\n for i in range(5):\n rowArray = list(map(int, input().split(\" \")))\n array.append(rowArray)\n print(odd_location_and_calculation(array))\n"}, {"source_code": "from operator import add\nm = reduce(add, (raw_input().split() for _ in xrange(5)), [])\ni = m.index('1')\nprint abs(i / 5 - 3) + abs(i % 5 - 3)\n"}, {"source_code": "\nfor i in range(5):\n s = raw_input().find('1')\n if (~s):\n print abs(i-2) + abs(i/2 - 2)"}], "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9"} {"nl": {"description": "Two polar bears Menshykov and Uslada from the St.Petersburg zoo and elephant Horace from the Kiev zoo got six sticks to play with and assess the animals' creativity. Menshykov, Uslada and Horace decided to make either an elephant or a bear from those sticks. They can make an animal from sticks in the following way: Four sticks represent the animal's legs, these sticks should have the same length. Two remaining sticks represent the animal's head and body. The bear's head stick must be shorter than the body stick. The elephant, however, has a long trunk, so his head stick must be as long as the body stick. Note that there are no limits on the relations between the leg sticks and the head and body sticks. Your task is to find out which animal can be made from the given stick set. The zoo keeper wants the sticks back after the game, so they must never be broken, even bears understand it.", "input_spec": "The single line contains six space-separated integers li (1\u2009\u2264\u2009li\u2009\u2264\u20099) \u2014 the lengths of the six sticks. It is guaranteed that the input is such that you cannot make both animals from the sticks.", "output_spec": "If you can make a bear from the given set, print string \"Bear\" (without the quotes). If you can make an elephant, print string \"Elephant\" (w\u0131thout the quotes). If you can make neither a bear nor an elephant, print string \"Alien\" (without the quotes).", "sample_inputs": ["4 2 5 4 4 4", "4 4 5 4 4 5", "1 2 3 4 5 6"], "sample_outputs": ["Bear", "Elephant", "Alien"], "notes": "NoteIf you're out of creative ideas, see instructions below which show how to make a bear and an elephant in the first two samples. The stick of length 2 is in red, the sticks of length 4 are in green, the sticks of length 5 are in blue. "}, "positive_code": [{"source_code": "l=list(map(int,input().split(\" \")))\ns=set(l)\ntotal=0\nif len(s)==1:\n\tprint(\"Elephant\")\nelif len(s)==2:\n\tfor i in s:\n\t\tif l.count(i)==4:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==2:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==5:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==1:\n\t\t\ttotal=total+2\n\tif total==2:\n\t\tprint(\"Elephant\")\n\telif total==3:\n\t\tprint(\"Bear\")\n\telse:\n\t\tprint(\"Alien\")\nelif len(s)==3:\n\tfor i in s:\n\t\tif l.count(i)==4:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==1:\n\t\t\ttotal=total+1\n\tif total==3:\n\t\tprint(\"Bear\")\n\telse:\n\t\tprint(\"Alien\")\nelse:\n\tprint(\"Alien\")\n\n\n"}, {"source_code": "arr = map(int, raw_input().split())\n\narr.sort()\nfound = False\ni = 0\n#print arr\nwhile i+3 3:\n print ('Alien')\nelif len(dic) == 3:\n if 4 in dic.values():\n print ('Bear')\n else:\n print ('Alien')\nelse:\n if 5 in dic.values():\n print ('Bear')\n elif 4 in dic.values():\n print ('Elephant')\n else:\n print ('Alien')"}, {"source_code": "# ===============================\n# (c) MidAndFeed aka ASilentVoice\n# ===============================\nimport math, fractions\n# ===============================\nq = [int(x) for x in input().split()]\nsq = set(q)\nif not(any(q.count(x) >= 4 for x in sq)):\n\tprint(\"Alien\")\nelse:\n\tif len(sq) == 3:\n\t\tprint(\"Bear\")\n\telif len(sq) == 1:\n\t\tprint(\"Elephant\")\n\telse:\n\t\tif any(q.count(x) > 4 for x in sq):\n\t\t\tprint(\"Bear\")\n\t\telse:\n\t\t\tprint(\"Elephant\")"}, {"source_code": "l=[int(x) for x in raw_input().split()]\na=[0,0,0,0,0,0,0,0,0,0]\nfor i in l:\n a[i]+=1\nif 6 in a:\n print 'Elephant'\nelif 5 in a:\n print 'Bear'\nelif 4 in a and 2 in a:\n print 'Elephant'\nelif 4 in a and 1 in a:\n print 'Bear'\nelse:\n print 'Alien'"}, {"source_code": "def main():\n p=[]\n s = raw_input()\n li = map(int, s.split())\n for i in range(0,10):\n p.append(0)\n \n for i in range(0, 6):\n p[li[i]]=p[li[i]]+1\n p.sort(reverse=True)\n if p[0]==4 and p[1]==2:\n print \"Elephant\"\n elif p[0]==4 and p[1]==1 and p[2]==1 :\n print \"Bear\"\n elif p[0]==6:\n print \"Elephant\"\n elif p[0]==5 and p[1]==1: \n print \"Bear\"\n else:\n print \"Alien\" \nmain() "}, {"source_code": "r=map(int,raw_input().split())\nle=[]\ns=[x for x in r if r.count(x)==1 or r.count(x)==2]\nfor i in r:\n if r.count(i)>=4:\n le.append(r)\nl=len(le)\nif l==0:print 'Alien'\nelif l==6:print 'Elephant'\nelif l==5:\n if s[0]=4:\n i+=f.count(f[i])\n check1=True\n if f.count(f[0])==5:\n check3=True\n break\n elif f.count(f[0])==6:\n check2=True\n break\n elif f.count(f[i])==2:\n check2=True\n i+=2\n elif f.count(f[0])==1:\n check3=True\n i+=1\n else:\n break\nif check1:\n if check2:\n print(\"Elephant\")\n else:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n \n"}, {"source_code": "paus = raw_input().split()\n\npaus2 = paus\nnum = 0\ntira = 0\nfor i in range(len(paus2) - 1, -1, -1):\n\tfor j in range(len(paus2) - 1, -1, -1):\n\t\tif i < j and int(paus2[i]) == int(paus2[j]):\n\t\t\ttira = paus2[i]\n\t\t\tif num == 4: \n\t\t\t\tbreak\n\t\t\t\n\t\t\tnum += 1 \n\tif num == 4: break\nfor i in range(len(paus2) - 1, -1, -1):\n\tif paus2[i] == tira:\n\t\tpaus2.remove(paus2[i])\n\nif len(paus2) == 2:\n\tif paus2[0] == paus2[1]:\n\t\tprint \"Elephant\"\n\telse:\n\t\tprint \"Bear\"\nelif len(paus2) == 0:\n\tprint \"Elephant\"\nelif len(paus2) == 1:\n\tprint \"Bear\"\nelse:\n\tprint \"Alien\"\n"}, {"source_code": "a=list(map(lambda x:int(x),raw_input().split(' ')))\nk=dict()\nfor i in a:\n if i in k:\n k[i]+=1\n else:\n k[i]=1\n\ns=k.values()\ns.sort()\nif s==[2,4] or s==[6] :\n print \"Elephant\"\nelif s==[1,1,4] or s==[1,5]:\n print \"Bear\"\nelse:\n print \"Alien\""}, {"source_code": "sticks = map(int, raw_input().split())\n\nlegs_found = False\nleg_size = -1\nfor i in range(len(sticks)):\n if 6 >= sticks.count(sticks[i]) >= 4:\n leg_size = sticks[i]\n legs_found = True\n break\n \nif legs_found:\n sticks = filter(lambda x: x != leg_size, sticks)\n \n if len(sticks) >= 2:\n if sticks[0] == sticks[1]:\n result = \"Elephant\"\n else:\n result = \"Bear\"\n else:\n if len(sticks) == 0:\n result = \"Elephant\"\n else:\n result = \"Bear\"\nelse:\n result = \"Alien\"\n \nprint result"}, {"source_code": "l = list(map(int,input().split()))\ns = {}\nfor i in range(6):\n if l[i] in s:\n s[l[i]]+=1\n else:\n s[l[i]]=1\nl1 = list(s.values())\ntpm = max(l1)\nif tpm>=4:\n if tpm==5:\n print('Bear')\n elif tpm==6:\n print('Elephant')\n elif tpm==4 and len(l1)==2:\n print('Elephant')\n elif tpm==4 and len(l1)==3:\n print('Bear')\nelse:\n print('Alien')"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor i in map(int, input().split()):\n a[i] += 1\nd = defaultdict(int)\nfor v in a.values():\n d[v] += 1\nif d[6] or (d[4] and d[2]):\n print('Elephant')\nelif d[5] or (d[4] and d[1] == 2):\n print('Bear')\nelse:\n print('Alien')\n"}, {"source_code": "x = map(int,raw_input().split())\nx.sort()\na=[]\ndic={}\nflag=True\nfor i in range(1,10):\n dic[i]=0\nfor i in x:\n dic[i]=dic[i]+1\nfor i in x:\n if dic[i]==4:\n d=i\n flag=False\n break\n elif dic[i]>4:\n d=i\n flag=False\n break\nif flag:\n print \"Alien\"\nelse:\n if dic[d]==4:\n for i in x:\n if i!=d:\n a.append(i)\n a.sort()\n if a[0]==a[1]:\n print \"Elephant\"\n else:\n print \"Bear\"\n elif dic[d]==5:\n print \"Bear\"\n elif dic[d]==6:\n print \"Elephant\"\n"}, {"source_code": "l=list(map(int,input().split()))\ntemp=[]\nmlist=[]\nfor i in range(6):\n if l[i] not in mlist:\n temp.append(l.count(l[i]))\n mlist.append(l[i])\n\nif len(mlist)==2:\n temp.sort()\n if temp[1]==5:\n print(\"Bear\")\n elif temp[1]==4:\n print(\"Elephant\")\n else:\n print(\"Alien\") \nelif len(mlist)==1:\n print(\"Elephant\")\n\nelif len(mlist)==3:\n temp.sort()\n if temp[2]==4:\n print(\"Bear\")\n else:\n print(\"Alien\") \nelse:\n print(\"Alien\") \n\n\n \n\n\n \n \n"}, {"source_code": "a=list(map(lambda x:int(x),raw_input().split(' ')))\nk=dict()\nfor i in a:\n if i in k:\n k[i]+=1\n else:\n k[i]=1\n\ns=k.values()\ns.sort()\nif s==[2,4] or s==[6] :\n print \"Elephant\"\nelif s==[1,1,4] or s==[1,5]:\n print \"Bear\"\nelse:\n print \"Alien\""}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\n\n\nif l[0]==l[1] and l[1]==l[2] and l[2]==l[3] and l[4]==l[5]: print(\"Elephant\")\nelif l[0]==l[1] and l[1]==l[2] and l[2]==l[3] and l[4]=4:\n\t\tlegs = 4\n\t\tdic[i]-=4\n\t\tbreak\n\nfor i in dic:\n\tif dic[i]>0:\n\t\tbody+=1\n\nif legs ==4 and body ==1:\n\tprint('Elephant')\nelif legs==4 and body ==2:\n\tprint('Bear')\nelse:\n\tprint('Alien')\n\n\n\n"}, {"source_code": "from collections import Counter\na=Counter(map(int,raw_input().split()))\nif sorted(list(a.values())) in [[1,1,4], [1,5]]: print \"Bear\"\nelif sorted(list(a.values())) in [[2,4], [6]]: print \"Elephant\"\nelse: print \"Alien\"\n"}, {"source_code": "lst = [i for i in input().split()]\n\na = []\n\nfor i in range(1, 10):\n if lst.count(str(i)) > 0:\n a.append(lst.count(str(i)))\n\na.sort()\n\nif len(a) == 2 and a[0] == 2 and a[1] == 4:\n print('Elephant')\nelif len(a) == 3 and a[0] == 1 and a[1] == 1 and a[2] == 4:\n print('Bear')\nelif len(a) == 1:\n print('Elephant')\nelif len(a) == 2 and a[0] == 1 and a[1] == 5:\n print('Bear')\nelse:\n print('Alien')\n\n#print(a)"}, {"source_code": "x=list(map(int,input().split()))\nx=sorted(x)\nif(x[0]==x[len(x)-1]):\n print(\"Elephant\")\nelse:\n k=x[-3]\n y=[]\n z=[]\n i=0\n while(i3:\n\t\tflag = 1\n\t\tbreak\t\nif flag==0:\n\tprint \"Alien\"\nelse:\n\tb[i] = b[i]-4\n\tif(b[i]==0):\n\t\tdel b[i]\n\tif len(b)==1:\n\t\tprint \"Elephant\"\n\telse:\n\t\tprint \"Bear\"\n"}, {"source_code": "lst = list(map(int, raw_input().split(' ')))\n\nst = set()\n\nfor i in lst:\n nt = lst.count(i)\n st.add(nt)\n\nif (len(st) == 2 and 2 in st and 4 in st) or (len(st) == 1 and 6 in st):\n print 'Elephant'\nelif (len(st) == 2 and 4 in st and 1 in st) or (len(st) == 2 and 5 in st):\n print 'Bear'\nelse:\n print 'Alien'"}, {"source_code": "l = list(map(int, input().split()))\n\nl.sort()\n\nk = -1\n\nfor i in l:\n c = 0\n for j in l:\n if i == j:\n c += 1\n if c >= 4:\n k = i\n break\n\nif k == -1:\n print('Alien')\nelse:\n for i in range(4):\n l.remove(k)\n if l[0] == l[1]:\n print('Elephant')\n else:\n print('Bear')\n"}, {"source_code": "l=list(map(int,input().split()))\ns=sorted([l.count(x) for x in set(l)])\nif len(s)==1 or len(s)==s[0]: print('Elephant')\nelif len(s)==s[0]*2 or len(s)==s[-1]-s[0]: print('Bear')\nelse: print('Alien')"}, {"source_code": "m=[0]*10\nfor i in map(int,input().split()):m[i]+=1\nfor i in range(10):\n if m[i]>=4:\n m[i]-=4\n print([\"Elephant\",\"Bear\"][max(m)%2])\n break\nelse:print(\"Alien\")"}, {"source_code": "l = list(map(int,input().split()))\ns = {}\nfor i in range(6):\n if l[i] in s:\n s[l[i]]+=1\n else:\n s[l[i]]=1\nl1 = list(s.values())\ntpm = max(l1)\nif tpm>=4:\n if tpm==5:\n print('Bear')\n elif tpm==6:\n print('Elephant')\n elif tpm==4 and len(l1)==2:\n print('Elephant')\n elif tpm==4 and len(l1)==3:\n print('Bear')\nelse:\n print('Alien')"}, {"source_code": "l = [int(x) for x in input().split()]\nl.sort()\ntemp = l[0]\nindex = 0\ncount = 1\nfor i in range(1, 6):\n if(l[i] == temp):\n count += 1\n else:\n temp = l[i]\n index = i+1\n count = 1\n if count == 4:\n break\nif(count == 4):\n l = l[0:index]+l[index+4:]\n if(l[0]!=l[1]):\n print(\"Bear\")\n else:\n print(\"Elephant\")\nelse:\n print(\"Alien\")\n"}, {"source_code": "x=[int(x) for x in input().split()]\ny=list(set(x))\nif len(y)==1:\n print('Elephant')\nelif len(y)==2:\n if x.count(y[0])==4 or x.count(y[1])==4:\n print('Elephant')\n elif x.count(y[0])==5 or x.count(y[1])==5:\n print('Bear')\n else:\n print('Alien')\nelif len(y)==3:\n if x.count(y[0]) == 4 or x.count(y[1]) == 4 or x.count(y[2])==4:\n print('Bear')\n else:\n print('Alien')\nelse:\n print('Alien')"}, {"source_code": "def run():\n nums=map(int,raw_input().split())\n #print nums\n maps={}\n for i in range(1,10):\n maps[i]=0\n #print maps\n for each in nums:\n maps[each]+=1\n #print maps\n sort=sorted(maps.items(),key=lambda x:x[1], reverse=True)\n #print sort\n if sort[0][1]==4:\n if sort[1][1]==2:\n print 'Elephant'\n else:\n print 'Bear'\n elif sort[0][1]==5:\n print 'Bear'\n elif sort[0][1]==6:\n print 'Elephant'\n else:\n print 'Alien'\n\n\n\n\n\n pass\nrun()"}, {"source_code": "l = list(map(int, input().split()))\nl.sort()\nequalCount = 1\ny = []\nfor i in range(5):\n if(l[i] == l[i+1]):\n equalCount += 1\n y.append(i)\n if(equalCount == 4):\n y.append(i+1)\n break\n else:\n y = []\n equalCount = 1\nx = []\nfor i in range(6):\n if(i not in y):\n x.append(l[i])\nsmall = min(x)\nlarge = max(x)\nif(len(y) == 4):\n if(small < large):\n print(\"Bear\")\n elif(small == large):\n print(\"Elephant\")\nelse:\n print(\"Alien\")"}, {"source_code": "l = list(map(int, input().split()))\ntt = list(l.count(temp) for temp in l)\ntt.sort()\nif tt == [1, 5, 5, 5, 5, 5] or tt == [1, 1, 4, 4, 4, 4]:\n\tprint('Bear')\nelif tt == [2, 2, 4, 4, 4, 4] or tt == [6, 6, 6, 6, 6, 6]:\n\tprint('Elephant')\nelse:\n\tprint('Alien')\n"}, {"source_code": "mylist = list(map(int, input().split()))\nmyset = list(set(mylist))\nflag = 0\nelephant = 0\nfor i in range(0, len(myset)):\n if(mylist.count(myset[i]) == 2):\n elephant = 1\n if(mylist.count(myset[i]) >= 4):\n flag = 1\n if(mylist.count(myset[i]) == 6):\n flag = 1\n elephant = 1\nif flag == 0:\n print(\"Alien\")\nelse:\n if(elephant == 1):\n print(\"Elephant\")\n else:\n print(\"Bear\")"}, {"source_code": "x=list(map(int,input().split()))\nx=sorted(x)\nif(x[0]==x[len(x)-1]):\n print(\"Elephant\")\nelse:\n k=x[-3]\n y=[]\n z=[]\n i=0\n while(i= 4:\n b = a[0]\n a.remove(b)\n a.remove(b)\n a.remove(b)\n a.remove(b)\n elif a.count (a[1]) >= 4:\n b = a[1]\n a.remove(b)\n a.remove(b)\n a.remove(b)\n a.remove(b)\n elif a.count (a[2]) >= 4:\n c = a[2]\n a.remove(c)\n a.remove(c)\n a.remove(c)\n a.remove(c)\n if a[0] == a[1]:\n print \"Elephant\"\n else:\n print \"Bear\"\n"}, {"source_code": "string = raw_input();\nA = string.split(\" \");\nA.sort();\nA = map(int, A);\n\ndef leg_made(A):\n if (A[0]==A[1] and A[1]==A[2] and A[2]==A[3]) or (A[3]==A[4] and A[1]==A[2] and A[2]==A[3]) or (A[3]==A[4] and A[4]==A[5] and A[2]==A[3]):\n return True\n return False\n\ndef bear_made(A):\n if leg_made(A):\n if ((A[0]==A[1] and A[1]==A[2] and A[2]==A[3]) and A[4] 3 or (4 not in leg and 5 not in leg and 6 not in leg):\n print 'Alien'\nelif len(sticks) == 3 or 1 in leg:\n print 'Bear'\nelse:\n print 'Elephant'\n"}, {"source_code": "mylist = list(map(int, input().split()))\nmyset = list(set(mylist))\nflag = 0\nelephant = 0\nfor i in range(0, len(myset)):\n if(mylist.count(myset[i]) == 2):\n elephant = 1\n if(mylist.count(myset[i]) >= 4):\n flag = 1\n if(mylist.count(myset[i]) == 6):\n flag = 1\n elephant = 1\nif flag == 0:\n print(\"Alien\")\nelse:\n if(elephant == 1):\n print(\"Elephant\")\n else:\n print(\"Bear\")"}, {"source_code": "from collections import Counter\n\ns = Counter(map(int, raw_input().split()))\n\nl = None\nhb = None\n\nfor i in s:\n if s[i] >= 4:\n l = i\n else:\n hb = i\n\nif l:\n if s[i] == 6 or s[hb] == 2:\n print 'Elephant'\n else:\n print 'Bear'\nelse:\n print 'Alien'\n\n\n"}, {"source_code": "a = [int (i) for i in input().split()]\ndic = {}\nfor i in range (6):\n dic[a[i]] = dic.get(a[i], 0) + 1\nif len (dic) == 1:\n print ('Elephant')\nelif len(dic) > 3:\n print ('Alien')\nelif len(dic) == 3:\n if 4 in dic.values():\n print ('Bear')\n else:\n print ('Alien')\nelse:\n if 5 in dic.values():\n print ('Bear')\n elif 4 in dic.values():\n print ('Elephant')\n else:\n print ('Alien')"}, {"source_code": "arr = list(map(int,input().split()))\n\nunique = set(arr)\n\nsame = []\n\nfor i in unique:\n same.append(arr.count(i))\n\nif max(same) < 4:\n print('Alien')\nelif max(same) % 2 == 0and min(same) % 2 == 0:\n print('Elephant')\nelse:\n print('Bear')\n\n\n \n \n"}, {"source_code": "# def ln(n):\n# \tans = 0\n# \twhile n>0:\n# \t\tans += 1\n# \t\tn /= 10\n# \treturn ans\n# n = int(raw_input())\n# su = n*2-1\n# x = str(su)\n# f = True\n# for i in x:\n# \tif i != '9':\n# \t\tf = False\n# \t\tbreak\n# if f:\n# \tprint 1\n# else:\n# \tnow = 0\n# \tlen = ln(su)\n# \tb = [False]*(n+1)\n# \td = \"\"\n# \tfor i in range(len-1):\n# \t\td += '9'\n# \tfor i in range(0,9):\n# \t\tp = int(str(i)+d)\t\n# \t\t# for j in range(1,n+1):\n# \t\t# \tif not b[j]:\n# \t\t# \t\tif p-j<=n and p-j>0:\n# \t\t# \t\t\tb[j] = True\n# \t\t# \t\t\tb[p-j] = True\n# \t\t# \t\t\tnow += 1\n# \t\tif p>=(n+1):\n# \t\t\tnow += p/2\n# \t\telif p>(2*n+1):\n# \t\t\tnow += 0\n# \t\telse:\n# \t\t\tnow += (su-p)\n# \tprint now\n# ########################################\n# s,a = set('abcdefghijklmnopqrstuvwxyz'),0\n# for _ in range(input()-1):\n# \tc,w = raw_input().split()\n# \tif len(s)==1 and c!='.':a+=1\n# \tw = set(w)\n# \tif c=='!':s&=w\n# \telse:s-=w\n# print a\n# ###########################################\nl = map(int,raw_input().split())\nd = {}\nfor i in range(6):\n\td[l[i]] = d.get(l[i],0)+1\nif len(d)==1 or len(d)==2 or len(d)==3:\n\tif len(d)==1:\n\t\tprint \"Elephant\"\n\telse:\n\t\tlegs = False\n\t\theadBody = False\n\t\tfor i in d:\n\t\t\tif d[i]>=4:\n\t\t\t\tlegs = True\n\t\t\tif d[i]==2:\n\t\t\t\theadBody = True\n\t\tif legs:\n\t\t\tif headBody:\n\t\t\t\tprint \"Elephant\"\n\t\t\telse:\n\t\t\t\tprint \"Bear\"\n\t\telse:\n\t\t\tprint \"Alien\"\nelse:\n\tprint \"Alien\""}, {"source_code": "l=[int(x) for x in raw_input().split()]\nchk=[0]*11\nfor i in l:\n chk[i]+=1\nprint 'Alien' if max(chk)<4 else 'Bear' if 1 in chk else 'Elephant'"}, {"source_code": "l=[int(x) for x in raw_input().split()]\na=[0,0,0,0,0,0,0,0,0,0]\nfor i in l:\n a[i]+=1\nif 6 in a:\n print 'Elephant'\nelif 5 in a:\n print 'Bear'\nelif 4 in a and 2 in a:\n print 'Elephant'\nelif 4 in a and 1 in a:\n print 'Bear'\nelse:\n print 'Alien'"}, {"source_code": "#!/usr/bin/python2.7\nl=sorted(map(int,raw_input().split()))\nif l[0]==l[3]: print 'Elephant' if l[4]==l[5] else 'Bear'\nelif l[1]==l[4]: print 'Bear'\nelif l[2]==l[5]: print 'Elephant' if l[0] == l[1] else 'Bear'\nelse: print 'Alien'\n"}, {"source_code": "x = map(int, raw_input().split())\n\ncnt = [0]*10\n\nfor i in x:\n cnt[i] += 1\n\nif max(cnt) < 4:\n print 'Alien'\nelse:\n cnt[cnt.index(max(cnt))] -= 4\n for i in cnt:\n if i != 0 and i < 2:\n print 'Bear'\n break\n elif i == 2:\n print 'Elephant'\n break\n"}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\n\n\nif l[0]==l[1] and l[1]==l[2] and l[2]==l[3] and l[4]==l[5]: print(\"Elephant\")\nelif l[0]==l[1] and l[1]==l[2] and l[2]==l[3] and l[4]=3:\n f='yes'\n p=[]\n p.append(i)\n for j in range(6):\n if a[i]==a[j] and i!=j:\n p.append(j)\n break\nif f=='no':\n print('Alien')\nelse:\n lp=[]\n for i in range(1,7):\n if i-1 not in p:\n lp.append(i-1)\n if len(lp)==0:\n print('Elephant')\n elif len(lp)==1:\n print('Bear')\n else:\n if a[lp[1]]==a[lp[0]]:\n print('Elephant')\n else:\n print('Bear')\n"}, {"source_code": "data = [int(i) for i in input().split()]\ndata.sort()\ndic = {k:data.count(k) for k in set(data)}\n\nisAlien = True\nlegKey = 0\nheadAndBody = []\nfor key in dic:\n if(dic[key] >= 4):\n legKey = key \n isAlien = False\nfor key in dic:\n if key != legKey:\n headAndBody.append(key)\n\nif(isAlien):\n print(\"Alien\")\nelse:\n if(len(headAndBody) == 2):\n if(headAndBody[0] == headAndBody[1]):\n print(\"Elephant\")\n else:\n print( \"Bear\" )\n else:\n if(len(headAndBody) == 0 or dic[headAndBody[0]] == 2):\n print(\"Elephant\")\n else:\n if(legKey == headAndBody[0]):\n print(\"Elephant\")\n else:\n print( \"Bear\" )\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jul 17 20:40:54 2019\n\n@author: avina\n\"\"\"\n\nl = list(map(int, input().split()))\n\nl.sort()\nk = set(l)\nn = len(k)\nr = []\nfor i in k:\n r.append(l.count(i))\n\nif n <=3 and max(r) >= 4:\n if l[0] != l[1]:\n a,b = l[0],l[-1]\n else:\n a,b = l[-2],l[-1]\n if a 4):\n rank[patas]-=1\n r.append(patas)\n for i in range(0,len(x)):\n if(x[i]!=patas):\n r.append(x[i])\n r.sort()\n if(r[0] == r[1]):\n print(\"Elephant\")\n elif(r[0] < r[1]):\n print(\"Bear\")\n else:\n print(\"Alien\")\n else:\n print(\"Alien\")\nmain()"}, {"source_code": "from itertools import groupby\n\n\nL = list(map(int, input().split()))\nL.sort()\ngroups = list(groupby(L))\nif len(groups) == 2:\n cnts = [L.count(groups[i][0]) for i in range(2)]\n cnts.sort()\n if (cnts[0] == 2 and cnts[1] == 4):\n print(\"Elephant\")\n exit()\n elif (cnts[0] == 1 and cnts[1] == 5):\n print(\"Bear\")\n exit()\nelif len(groups) == 3:\n cnts = [L.count(groups[i][0]) for i in range(3)]\n cnts.sort()\n if (cnts[0] == 1 and cnts[1] == 1 and cnts[2] == 4):\n print(\"Bear\")\n exit()\nelif len(groups) == 1:\n print(\"Elephant\")\n exit()\n\nprint(\"Alien\")\n"}, {"source_code": "a=list(map(lambda x:int(x),raw_input().split(' ')))\nk=dict()\nfor i in a:\n if i in k:\n k[i]+=1\n else:\n k[i]=1\n\ns=k.values()\ns.sort()\nif s==[2,4] or s==[6] :\n print \"Elephant\"\nelif s==[1,1,4] or s==[1,5]:\n print \"Bear\"\nelse:\n print \"Alien\""}, {"source_code": "l=list(map(int,input().split()))\na=set(l)\nif(len(a)==1):\n print('Elephant')\nelse:\n for i in a:\n if l.count(i)==4:\n if len(a)==3:\n print('Bear')\n break\n \n elif len(a)==2:\n print('Elephant')\n break\n \n elif l.count(i)==5:\n if(len(a)==2):\n print('Bear')\n break\n else:\n print('Alien')"}, {"source_code": "def solve(a):\n d = {}\n for i in a:\n if(i in d):\n d[i]+=1\n else:\n d[i] = 1\n if(len(d) > 3):\n return \"Alien\"\n else:\n if len(d) == 1:\n return \"Elephant\"\n if len(d) == 2:\n for i in d:\n if(d[i] == 4 or d[i] == 2):\n return \"Elephant\"\n elif(d[i] == 1):\n return \"Bear\"\n elif(d[i] == 3):\n return \"Alien\"\n if len(d) == 3:\n for i in d:\n if(d[i] == 2 or d[i] == 3):\n return \"Alien\"\n return \"Bear\" \n\na = list(map(int,input().split()))\nprint(solve(a))\n\n \n"}, {"source_code": "from itertools import groupby\n\n\nL = list(map(int, input().split()))\nL.sort()\ngroups = list(groupby(L))\nif len(groups) == 2:\n cnts = [L.count(groups[i][0]) for i in range(2)]\n cnts.sort()\n if (cnts[0] == 2 and cnts[1] == 4):\n print(\"Elephant\")\n exit()\n elif (cnts[0] == 1 and cnts[1] == 5):\n print(\"Bear\")\n exit()\nelif len(groups) == 3:\n cnts = [L.count(groups[i][0]) for i in range(3)]\n cnts.sort()\n if (cnts[0] == 1 and cnts[1] == 1 and cnts[2] == 4):\n print(\"Bear\")\n exit()\nelif len(groups) == 1:\n print(\"Elephant\")\n exit()\n\nprint(\"Alien\")\n"}, {"source_code": "a= raw_input().split()\nb=list(set(a))\nl=len(b)\nif l>3:\n print \"Alien\"\nelif l==1:\n print \"Elephant\"\nelif l==2:\n i0=a.count(b[0])\n i1=a.count(b[1])\n if i0<4 and i1<4:\n print \"Alien\"\n elif i0==5 or i1==5:\n print \"Bear\"\n else:\n print \"Elephant\"\nelse:\n i0=a.count(b[0])\n i1=a.count(b[1])\n i2=a.count(b[2])\n if max(i0,i1,i2)!=4:\n print \"Alien\"\n else:\n print \"Bear\"\n"}, {"source_code": "def count_legs(palochki):\n for i in palochki:\n if palochki.count(i)>=4:\n return True\n return False\ndef what_animal(palochki):\n not_legs=[]\n four_legs=1\n for i in palochki:\n if palochki.count(i)==6:\n return 'Elephant'\n if palochki.count(i)>=4 and four_legs<=4:\n legs=i\n four_legs+=1\n else:\n not_legs.append(i)\n if not_legs[0]==not_legs[1]:\n return 'Elephant'\n else:\n return 'Bear'\n \n \n\npalochki=raw_input()\npalochki=palochki.split(' ')\nfor i in range(len(palochki)):\n palochki[i]=int(palochki[i])\nif count_legs(palochki):\n print what_animal(palochki)\nelse:\n print 'Alien'"}, {"source_code": "v=[int(i) for i in input().split()]\nv.sort()\ncount=[0 for i in range(9)]\nfor i in v:\n count[i-1] += 1\nf=0\nfor i in range(9):\n if(count[i]>=4):\n f=i+1\n break\n\nif(f==0):\n print(\"Alien\")\nelse:\n c=0\n v2=[]\n for i in range(6):\n if(c==4):\n v2.append(v[i])\n elif(v[i]!=f):\n v2.append(v[i])\n else:\n c=c+1\n if(v2[0]==v2[1]):\n print(\"Elephant\")\n else:\n print(\"Bear\")\n \n \n"}, {"source_code": "a=map(int, raw_input().split())\nc=[0]*10\nfor x in a:\n c[x]+=1\nprint \"Alien\" if max(c)<4 else \"Bear\" if 1 in c else \"Elephant\"\n"}, {"source_code": "b=sorted(list(map(int, input().split())))\n\nif b[0]==b[1]==b[2]==b[3] or b[1]==b[2]==b[3]==b[4] or b[2]==b[3]==b[4]==b[5]:\n if b[0]==b[5] or (b[0]==b[1] and b[4]==b[5]):\n print(\"Elephant\")\n else:\n print(\"Bear\")\nelse:\n print(\"Alien\")"}, {"source_code": "string = raw_input();\nA = string.split(\" \");\nA.sort();\nA = map(int, A);\n\ndef leg_made(A):\n if (A[0]==A[1] and A[1]==A[2] and A[2]==A[3]) or (A[3]==A[4] and A[1]==A[2] and A[2]==A[3]) or (A[3]==A[4] and A[4]==A[5] and A[2]==A[3]):\n return True\n return False\n\ndef bear_made(A):\n if leg_made(A):\n if ((A[0]==A[1] and A[1]==A[2] and A[2]==A[3]) and A[4]= 4:\n l = i\n else:\n hb = i\n\nif l:\n if s[i] == 6 or s[hb] == 2:\n print 'Elephant'\n else:\n print 'Bear'\nelse:\n print 'Alien'\n\n\n"}, {"source_code": "r = raw_input().split( )\nr = sorted(r)\nk = r[3]\nb = []\ncount = 0\nfor i in r:\n if k == i:\n count = count + 1\n else:\n b.append(i)\nif count == 6:\n print \"Elephant\"\nelse:\n if count >= 4:\n if count > 4:\n b.append(r[3])\n if b[0]==b[1]:\n print \"Elephant\"\n else:\n print \"Bear\"\n else:\n print \"Alien\""}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor i in map(int, input().split()):\n a[i] += 1\nd = defaultdict(int)\nfor v in a.values():\n d[v] += 1\nif d[6] or (d[4] and d[2]):\n print('Elephant')\nelif d[5] or (d[4] and d[1] == 2):\n print('Bear')\nelse:\n print('Alien')\n"}, {"source_code": "l=list(input().split())\nk1=l.count(l[0])\nk2=l.count(l[1])\nk3=l.count(l[2])\nif k1>=4:\n s=[x for x in l if x !=l[0]]\n if len(s)==2 and s[0]==s[1] or len(s)==0:\n print(\"Elephant\")\n elif len(s)==1 or len(s)==2 and s[0]!=s[1]:\n print(\"Bear\")\nelif k2>=4:\n s=[x for x in l if x !=l[1]]\n if len(s)==2 and s[0]==s[1] or len(s)==0 :\n print(\"Elephant\")\n elif len(s)==1 or len(s)==2 and s[0]!=s[1]:\n print(\"Bear\")\nelif k3>=4:\n s=[x for x in l if x !=l[2]]\n if len(s)==2 and s[0]==s[1] or len(s)==0:\n print(\"Elephant\")\n elif len(s)==1 or len(s)==2 and s[0]!=s[1]:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n \n \n"}, {"source_code": "l = list(map(int,input().split()))\nn = len(l)\nx = max(l , key= l.count)\n\nif l.count(x) < 4 :\n print('Alien')\n exit()\n\na = []\nfor i in l :\n if i != x :\n a.append(i)\n\n#print(a)\ny = 2 - len(a)\nif len(a) < 2 :\n for i in range(y):\n a.append(x)\n#print(a)\n\nif a[0] != a[1]:\n print('Bear')\nelse:\n print('Elephant')"}, {"source_code": "import sys\n\nl = [int(x) for x in (sys.stdin.readline()).split()]\n\nl.sort()\n\nk = l[3]\n\ntemp = []\n\nfor i in l:\n if(k != i):\n temp.append(i)\n\nsz = len(temp)\n \nif(sz == 0):\n print(\"Elephant\")\nelif(sz == 1):\n print(\"Bear\")\nelif(sz == 2):\n if(temp[0] != temp[1]):\n print(\"Bear\")\n else:\n print(\"Elephant\")\nelse:\n print(\"Alien\")"}, {"source_code": "from collections import defaultdict\na = defaultdict(int)\nfor i in map(int, input().split()):\n a[i] += 1\nd = defaultdict(int)\nfor v in a.values():\n d[v] += 1\nif d[6] or (d[4] and d[2]):\n print('Elephant')\nelif d[5] or (d[4] and d[1] == 2):\n print('Bear')\nelse:\n print('Alien')\n"}, {"source_code": "import operator as op\nimport 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 functools import reduce\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\ndef def_value():\n return 0\n\n\n# For getting input from input.txt file\n#sys.stdin = open('input.txt', 'r')\n# Printing the Output to output.txt file\n# sys.stdout = open('output.txt', 'w')\n\na = inlist()\na = sorted(a, key=lambda d: a.count(d), reverse=True)\n\nfor i in range(3):\n if a[i] != a[i+1]:\n print(\"Alien\")\n sys.exit()\nif a[4] != a[5]:\n print(\"Bear\")\nelif a[4] == a[5]:\n print(\"Elephant\")\n"}, {"source_code": "a = list(int(x) for x in input().split())\nleg =0\nif len(set(a))<4:\n for i in set(a):\n if a.count(i)>=4:\n leg = i\n a.remove(leg)\n a.remove(leg)\n a.remove(leg)\n a.remove(leg)\nif leg==0:\n print('Alien')\nelif len(set(a))==2:\n print('Bear')\nelse:\n print('Elephant')"}, {"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))\nli = list(map(int,input().split()))\nli.sort()\nflag = 0\nans = 0\nfor i in range(3):\n flag2 = 1\n for j in range(1,4):\n if li[i+j] != li[i]:\n flag2 = 0\n if flag2 == 1:\n ans = i\n flag = max(flag,flag2)\nif flag == 0:\n print(\"Alien\")\nelse:\n ans2 = 0\n if ans == 0:\n if li[4] == li[5]:\n ans2 = 1\n elif ans == 1:\n if li[0] == li[5]:\n ans2 = 1\n else:\n if li[1] == li[0]:\n ans2 = 1\n print(\"Bear\" * (1 - ans2) + \"Elephant\" * ans2)\n \n \n \n"}, {"source_code": "l = list(map(int, input().split()))\nl.sort()\nequalCount = 1\ny = []\nfor i in range(5):\n if(l[i] == l[i+1]):\n equalCount += 1\n y.append(i)\n if(equalCount == 4):\n y.append(i+1)\n break\n else:\n y = []\n equalCount = 1\nx = []\nfor i in range(6):\n if(i not in y):\n x.append(l[i])\nsmall = min(x)\nlarge = max(x)\nif(len(y) == 4):\n if(small < large):\n print(\"Bear\")\n elif(small == large):\n print(\"Elephant\")\nelse:\n print(\"Alien\")"}, {"source_code": "s = input()\na = s.split()\nb = []\nfor i in range(len(a)):\n\ta[i] = int(a[i])\n\tb.append(a[i])\n\nb.sort()\ni = 0\nwhile i < len(b)-1:\n\tif b[i] == b[i+1]:\n\t\tb. remove(b[i+1])\n\telse:\t\n\t\ti += 1\n\nif len(b) > 3:\n\tprint('Alien')\nelif len(b) == 1:\n\tprint('Elephant')\nelif len(b) == 2:\n\tif a.count(b[0]) == 4 or a.count(b[1]) == 4:\n\t\tprint('Elephant')\n\telif a.count(b[0]) == 5 or a.count(b[1]) == 5:\n\t\tprint('Bear')\n\telse:\n\t\tprint('Alien')\nelif len(b) == 3:\n\tif a.count(b[0]) == 4:\n\t\tif b[1] == b[2]:\n\t\t\tprint('Elephant')\n\t\telse:\n\t\t\tprint('Bear')\n\telif a.count(b[1]) == 4:\n\t\tif b[0] == b[2]:\n\t\t\tprint('Elephant')\n\t\telse:\n\t\t\tprint('Bear')\n\telif a.count(b[2]) == 4:\n\t\tif b[0] == b[1]:\n\t\t\tprint('Elephant')\n\t\telse:\n\t\t\tprint('Bear')\n\telse:\n\t\tprint('Alien')"}, {"source_code": "lis = list(map(int,input().split()))\nx = {}\nfor i in lis:\n if i not in x:\n x[i]=1\n else:\n x[i]+=1\ntmp = []\nflag=0\nfor i in x:\n if(x[i]!=4):\n tmp.append(i)\n if(x[i]>=4):\n flag=1\nif(len(set(tmp))==1 and flag):\n print(\"Elephant\")\nelif(len(set(tmp))==2 and flag):\n print(\"Bear\")\nelse:\n print(\"Alien\")"}, {"source_code": "n = list(map(int, input().split()))\nl = [0] * 10\nfor el in n: l[el] += 1\nif max(l) < 4: print('Alien')\nelif 1 in l: print('Bear')\nelse: print('Elephant')"}, {"source_code": "'''\nCreated on 26/09/2014\n\n@author: DAVID\n'''\n\nimport sys\n\nsticks = [int(i) for i in sys.stdin.readline().split()]\n\nsticks.sort( )\n\ncount = 1\nlegs = False\nelephant = False\ng = {}\nfor i in sticks:\n if not i in g:\n g[i] = 1\n else:\n g[i] += 1\n \nfor i in g:\n if g[i] == 6:\n legs = True\n elephant = True\n elif g[i] >= 4:\n legs = True\n elif g[i] == 2:\n elephant = True \n \nif not legs:\n print \"Alien\"\nelif elephant:\n print \"Elephant\"\nelse:\n print \"Bear\""}, {"source_code": "x=[int(a) for a in input().split()]\nx=sorted(x)\ny=[0]*10\nfor i in range(6):\n y[x[i]]+=1\ny.sort(reverse=True)\nif y[0]==6:\n print(\"Elephant\")\nelif y[0]==5:\n print(\"Bear\")\nelif y[0]==4:\n if y[1]==2:\n print(\"Elephant\")\n else:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "from collections import Counter\n\n\ndef main():\n c = Counter(raw_input().split())\n appear = sorted(c.values(), reverse=True)\n if appear[0] >= 4:\n if len(appear) == 1 or appear[1] == 2:\n print \"Elephant\"\n else:\n print \"Bear\"\n else:\n print \"Alien\"\n\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "l=[int(x) for x in raw_input().split()]\na=[0,0,0,0,0,0,0,0,0,0]\nfor i in l:\n a[i]+=1\nif 6 in a:\n print 'Elephant'\nelif 5 in a:\n print 'Bear'\nelif 4 in a and 2 in a:\n print 'Elephant'\nelif 4 in a and 1 in a:\n print 'Bear'\nelse:\n print 'Alien'"}, {"source_code": "l=input().split()\ns=[]\nfor i in l:\n\ts.append(l.count(i))\nif( s.count(6)!=0):\n\tprint('Elephant')\nelif(s.count(2)!=0 and s.count(4)!=0):\n\tprint('Elephant')\nelif(s.count(1)==2 and s.count(4)!=0):\n\tprint('Bear')\nelif(s.count(5)!=0):\n\tprint('Bear')\t\nelse:\n\tprint('Alien')"}, {"source_code": "# 471A\na = input().split()\na = list(map(int,a))\ndef sort(a):\n for i in range(len(a)):\n for j in range(i+1,len(a)):\n if a[i] > a[j]:\n s = a[i]\n a[i] = a[j]\n a[j] = s\n return a\ndef counter(a):\n g = a[0]\n b = [1]\n for i in range(1,len(a)):\n if a[i] == g:\n b[len(b)-1] += 1\n else:\n g = a[i]\n b.append(1)\n return b\na = sort(a)\nb = counter(a)\nm = 0\nfor j in range(len(b)):\n if m < b[j]:\n m = b[j]\nif m < 4:\n print('Alien')\nelse:\n if len(b) <= 2:\n if m == 5:\n print('Bear')\n else:\n print('Elephant')\n else:\n print('Bear')"}, {"source_code": "import fileinput\n\nA = []\n\nfor line in fileinput.input():\n A = map(int, line.split())\n break\n \ncounts = []\nfor x in set(A):\n counts.append(A.count(x))\n \ncounts.sort()\nif counts == [1, 1, 4] or counts == [1,5]:\n print \"Bear\"\nelif counts == [2,4] or counts == [6]:\n print \"Elephant\"\nelse:\n print \"Alien\"\n "}, {"source_code": "r=map(int,raw_input().split())\nle=[]\ns=[x for x in r if r.count(x)==1 or r.count(x)==2]\nfor i in r:\n if r.count(i)>=4:\n le.append(r)\nl=len(le)\nif l==0:print 'Alien'\nelif l==6:print 'Elephant'\nelif l==5:\n if s[0]= 4):\n\t\t\treturn count, i\n\treturn -1, -1\n\t\ndef clearLista(lista, var):\n\tnewList = []\n\tfor i in lista:\n\t\tif i != var:\n\t\t\tnewList.append(i)\n\tif len(newList) == 0:\n\t\tnewList.append(var)\n\t\tnewList.append(var)\n\telif len(newList) == 1:\n\t\tnewList.append(var)\n\treturn newList\n\ncount, perna = isPossible(sticks)\n\nif (count >= 4):\n\tsticks = clearLista(sticks, perna)\n\tif sticks[0] == sticks[1]:\n\t\tprint \"Elephant\"\n\telse:\n\t\tprint \"Bear\"\nelse:\n\tprint \"Alien\"\n"}, {"source_code": "# MUH and Sticks\n\nl = map(int, raw_input().split())\nl1 = set(l)\n\njudge = 'Alien'\nif len(l1) == 3:\n for item in l1:\n if l.count(item) == 4:\n judge = 'Bear'\n break\nelif len(l1) == 2:\n for item in l1:\n if l.count(item) == 4:\n judge = 'Elephant'\n break\n elif l.count(item) == 5:\n judge = 'Bear'\n break\nelif len(l1) == 1:\n judge = 'Elephant'\n\nprint judge\n"}, {"source_code": "from collections import Counter\nar = list(map(int,input().split()))\ns = set(ar)\nlegs = False\nele = False\neleP = False\nbearP = False\nfor i in s:\n if ar.count(i)==4:\n legs = True\n if ar.count(i)==2:\n ele = True\n if ar.count(i)==6:\n eleP = True\n if ar.count(i)==5:\n bearP = True\nif bearP:\n print(\"Bear\")\nelif eleP :\n print(\"Elephant\")\nelif ele and legs:\n print(\"Elephant\")\nelif legs:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n "}, {"source_code": "from collections import Counter\ndef solved(dic,lst):\n chan = 0\n get = 0\n #print(dic)\n if dic == {0: 6}:\n return 'Alien'\n l = list(dic.values())\n if len(l) <= 2:\n if len(l) == 1:\n return 'Elephant'\n else:\n ok = False\n bear =False\n for i in l:\n if i == 4:\n ok = True\n if i == 1:\n bear = True\n if ok:\n return 'Elephant'\n if bear:\n return 'Bear'\n else:\n return 'Alien'\n elif len(l) == 3:\n ok = False\n for i in l:\n if i == 4:\n ok = True\n if ok:\n return 'Bear'\n else:\n return 'Alien'\n else:\n return 'Alien'\n\nif __name__ == '__main__':\n lst = list(map(int,input().split()))\n dic = Counter(lst)\n print(solved(dic,lst))"}, {"source_code": "l=list(map(int,input().split(\" \")))\ns=set(l)\ntotal=0\nif len(s)==1:\n\tprint(\"Elephant\")\nelif len(s)==2:\n\tfor i in s:\n\t\tif l.count(i)==4:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==2:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==5:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==1:\n\t\t\ttotal=total+2\n\tif total==2:\n\t\tprint(\"Elephant\")\n\telif total==3:\n\t\tprint(\"Bear\")\n\telse:\n\t\tprint(\"Alien\")\nelif len(s)==3:\n\tfor i in s:\n\t\tif l.count(i)==4:\n\t\t\ttotal=total+1\n\t\tif l.count(i)==1:\n\t\t\ttotal=total+1\n\tif total==3:\n\t\tprint(\"Bear\")\n\telse:\n\t\tprint(\"Alien\")\nelse:\n\tprint(\"Alien\")\n\n\n"}, {"source_code": "lst=map(int,raw_input().split())\nif len(set(lst))==1:\n print \"Elephant\"\nelif len(set(lst))==3:\n for num in set(lst):\n if lst.count(num)==4:\n print \"Bear\"\n break\n else:\n print \"Alien\"\nelif len(set(lst))==2:\n for num in set(lst):\n if lst.count(num)==4:\n pass\n elif lst.count(num)==2:\n print \"Elephant\"\n elif lst.count(num)==1:\n print \"Bear\"\n elif lst.count(num)==3:\n print \"Alien\"\n break\nelse:\n print \"Alien\""}, {"source_code": "from collections import Counter\n\n\nc = Counter(input().split())\nif all(c[i] < 4 for i in c):\n print(\"Alien\")\nelif any(c[i] == 1 for i in c):\n print(\"Bear\")\nelse:\n print(\"Elephant\")\n"}, {"source_code": "data_input=map(int, raw_input().split(' '))\n\ndef answer(data_input):\n\trepetition_frequency=[data_input.count(i) for i in set(data_input)]\n\tif 6 in repetition_frequency:\n\t\tprint 'Elephant'\n\telif 5 in repetition_frequency:\n\t\tprint 'Bear'\n\telif 4 in repetition_frequency and 2 in repetition_frequency:\n\t\tprint 'Elephant'\n\telif 4 in repetition_frequency:\n\t\tprint 'Bear'\n\telse:\n\t\tprint 'Alien'\n\nanswer(data_input)\n"}, {"source_code": "l=list(map(int,input().split()))\nsl=list(set(l))\nt=l\nfor i in sl:\n if l.count(i)>=4:\n for __ in range(4):\n t.remove(i)\n if t[0]==t[1]:\n print('Elephant')\n else:\n print('Bear')\n break\nelse:\n print('Alien')\n"}, {"source_code": "l=map(int,raw_input().split())\nd={}\nfor i in l:\n\tif i not in d:\n\t\td[i]=1\n\telse:\n\t\td[i]+=1\nf=0\nfor i in d:\n\tif d[i]==4 or d[i]==6:\n\t\tdel(d[i])\n\t\tf=1\n\t\tbreak\n\telif d[i]==5:\n\t\tf=1\n\t\td[i]=1\t\n\t\tbreak\t\nif f==0:\n\tprint \"Alien\"\nelse:\n\tif len(d)==1 or len(d)==0:\n\t\tprint \"Elephant\"\n\telse:\n\t\tprint \"Bear\"\n"}, {"source_code": "f=input()\nf=f.split(\" \")\nf.sort()\ncheck1=False\ncheck2=False\ncheck3=False\ni=0\nwhile i<6:\n if f.count(f[i])>=4:\n i+=f.count(f[i])\n check1=True\n if f.count(f[0])==5:\n check3=True\n break\n elif f.count(f[0])==6:\n check2=True\n break\n elif f.count(f[i])==2:\n check2=True\n i+=2\n elif f.count(f[0])==1:\n check3=True\n i+=1\n else:\n break\nif check1:\n if check2:\n print(\"Elephant\")\n else:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n \n"}, {"source_code": "# bear h < b\n# elephant h == b\n# 4 sticks that are equal\n\nnums = map(int, raw_input('').split(' '))\ns = nums\n\ns_map = {}\n\nfor stick in s:\n if stick not in s_map:\n s_map[stick] = 0\n s_map[stick] += 1\n\nvals = s_map.values()\nif len(s_map) == 1:\n print 'Elephant'\nelif len(s_map) == 2:\n if (vals[0] == 4 and vals[1] == 2) or (vals[0] == 2 and vals[1] == 4):\n print 'Elephant'\n elif (vals[0] == 5 and vals[1] == 1) or (vals[0] == 1 and vals[1] == 5):\n print 'Bear'\n else:\n print 'Alien'\nelif len(s_map) == 3:\n if (vals[0] == 4 or vals[1] == 4 or vals[2] == 4):\n print 'Bear'\n else:\n print 'Alien'\nelse:\n print 'Alien'"}, {"source_code": "l = list(map(int, input().split()))\nn = len(l)\nelephant = False\nbear = False\n\nfor i in range(0, n) :\n for j in range(i + 1, n) :\n f = 0\n bad = False\n for c in range(0, n) :\n if (i == c or j == c) :\n continue\n if (f == 0) :\n f = l[c]\n if (f != l[c]) :\n bad = True\n\n if (bad == False) :\n if (l[i] == l[j]) :\n elephant = True\n if (l[i] != l[j]) :\n bear = True\n\nif (not elephant and not bear) :\n print(\"Alien\")\nelif (elephant) :\n print(\"Elephant\")\nelse :\n print(\"Bear\")"}], "negative_code": [{"source_code": "#\n# Bad codeforces template TM\n#\n# Zeyu Chen, 2019\n#\n\nfrom sys import stdin, stdout, setrecursionlimit\ninput = stdin.readline\nflush = stdout.flush\n\n#setrecursionlimit(1000000)\n\n############################################################\n\nOUT = []\n\ndef write(item, sep = \" \"):\n if type(item) is int:\n OUT.append(str(item))\n elif type(item) is list:\n if type(item[0]) is int:\n OUT.append(sep.join(map(str, item)))\n else:\n OUT.append(sep.join(item))\n else:\n OUT.append(item)\n\ndef PRINT():\n print(\"\\n\".join(OUT))\n\nGI = lambda: int(input())\nGS = lambda: input()[:-1]\n\ngi = lambda: list(map(int, input().split()))\ngs = lambda: input().split()\n\n############################################################\n\narr = gi()\n\nfor i in arr:\n cnt = arr.count(i)\n if cnt == 4:\n left = [j for j in arr if i != j]\n if left[0] == left[1]:\n write(\"Elephant\")\n else:\n write(\"Bear\")\n break\nelse:\n write(\"Alien\")\n\n############################################################\n\nPRINT()"}, {"source_code": "def solve(a):\n d = {}\n for i in a:\n if(i in d):\n d[i]+=1\n else:\n d[i] = 1\n if(len(d) == 1):\n return \"Elephant\"\n elif(len(d) > 3):\n return \"Alien\"\n else:\n for i in d:\n if(d[i] == 2):\n return \"Elephant\"\n return \"Bear\"\na = list(map(int,input().split()))\nprint(solve(a))\n"}, {"source_code": "string_list_int = map(int, raw_input().split())\nSet = set(string_list_int)\nl = []\n\nfor x in Set :\n\n l.append(string_list_int.count(x))\n\nif len(Set) > 3 or 3 in l :\n\n print 'Alien'\n\nelse :\n\n if (len(Set) == 2 and 2 in l) or len(Set) == 1 :\n\n print 'Elephant'\n\n else :\n\n print 'Bear'\n"}, {"source_code": "a=list(map(int,input().split()))\nb=set(a)\nl=len(b)\no=a.count(min(a))\nc=a.count(max(a))\nif l==3:\n if o==4 or c==4:\n print(\"Bear\")\n else:\n print(\"Alien\")\nelif l<=2 and l>0:\n if o==2 or c==2:\n print(\"Elephant\")\n elif max(a)==min(a):\n print(\"Elephant\")\n elif o==3 or c==3:\n print(\"Alien\")\n else:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n"}, {"source_code": "'''\nCreated on 26/09/2014\n\n@author: DAVID\n'''\n\nimport sys\n\nsticks = [int(i) for i in sys.stdin.readline().split()]\n\nsticks.sort( )\n\ncount = 1\nlegs = False\nelephant = False\nfor i in range(len(sticks) - 1):\n if sticks[i] == sticks[i + 1]:\n count += 1\n else:\n if count == 2:\n elephant = True\n if count == 4:\n legs = True\n count = 1\n\nif count == 4:\n legs = True\nelif count == 2:\n elephant = True\n\nif not legs:\n print \"Alien\"\nelif elephant:\n print \"Elephant\"\nelse:\n print \"Bear\""}, {"source_code": "a = map(int, raw_input().split())\na.sort()\nif a.count(a[0])==1 and a.count(a[5])==1 and a.count(a[1])==4:\n print 'Bear'\nelif (((a.count(a[4])==1 and a.count(a[5])==1) or a.count(a[5])==2) and a.count(a[1])==4) or a.count(a[5])==6:\n print 'Elephant'\nelse:\n print 'Alien'\n"}, {"source_code": "l=list(map(int,input().split(\" \")))\ns=set(l)\na=list()\nif len(s)>3:\n\tprint(\"Alien\")\nelse:\n\tfor i in range(0,6):\n\t\tif l.count(l[i])!=4:\n\t\t\ta.append(l[i])\n\tif a[0]==a[1]:\n\t\tprint(\"Elephant\")\n\telse:\n\t\tprint(\"Bear\")"}, {"source_code": "import fileinput\n\nA = []\n\nfor line in fileinput.input():\n A = map(int, line.split())\n break\n \ncounts = []\nfor x in set(A):\n counts.append(A.count(x))\n \ncounts.sort()\nif counts == [1, 1, 4]:\n print \"Bear\"\nelif counts == [2,4]:\n print \"Elephant\"\nelse:\n print \"Alien\"\n "}, {"source_code": "l=list(map(int,input().split()))\ns=list(set(l))\nt=len(s)\nif t==1:\n print('Elephant')\nelif t==2:\n if (l.count(s[0])==4 or l.count(s[1])==4):\n print('Elephant')\n else:\n print('Alien')\nelif t==3:\n if (l.count(s[0])==4 or l.count(s[1])==4 or l.count(s[2])==4):\n print('Bear')\n else:\n print('Alien')\nelse:\n print('Alien')"}, {"source_code": "list = list(map(int, input().split(\" \")))\nlist.sort()\ncount=0\ncount1=-1\nindex =[]\nlist.append(-1)\n\nfor i in range(len(list)-1):\n count= list.count(list[i])\n if list[i] == list[i+1]:\n count1 = count1 +1\n if count==1:\n index.append(i)\nif len(index)==2 or len(index)== 1 :\n print('Bear')\nelif len(index)==0 and count!=3:\n print('Elephant')\nelif count==3:\n print('Alien')\nelse:\n print('Alien')"}, {"source_code": "#n = int(input())\n#n, m = map(int, input().split())\n#s = input()\nc = list(map(int, input().split()))\nc.sort()\nfor i in range(3):\n if c.count(c[i]) > 3:\n for j in range(4):\n c.pop(0)\n if c[0] == c[1]:\n print('Elephant')\n else:\n print('Bear')\n break\nelse:\n print('Alien')"}, {"source_code": "read = lambda: map(int, raw_input().split())\nread_s = lambda: map(str, raw_input().split())\n\na = sorted(read())\nfor i in a:\n if a.count(i) == 4:\n c, d = sorted([x for x in a if x != i])\n if c < d:\n print 'Bear'\n exit(0)\n else:\n print 'Elephant'\n exit(0)\nelse:\n print 'Alien'"}, {"source_code": "from collections import Counter\ns = sorted(Counter(map(int,raw_input().split())).values())\nif s==[1,1,4] or s==[1,5]:\n\tprint 'Bear'\nelif s==[2,4] or s==[6]:\n\tprint 'Elephant'\nelse:\n\tprint 'Alieno'\n"}, {"source_code": "__author__ = '\u0410\u043d\u0434\u0440\u0435\u0439'\nimport sys\n\na = list(map(int, input().split()))\np = [0] * 10\nfor item in a:\n p[item] += 1\nfor item in p:\n if item == 4:\n for itm in p:\n if itm == 1:\n print('Bear')\n sys.exit()\n elif itm == 2:\n print('Elephant')\n sys.exit()\nprint('Alien')"}, {"source_code": "l=list(map(int,input().split()))\ns=sorted([l.count(x) for x in set(l)])\nif len(s)==1 or len(s)==s[0]: print('Elephant')\nelif len(s)==s[0]+1 or len(s)==s[-1]-s[0]: print('Bear')\nelse: print('Alien')"}, {"source_code": "# -*- coding: utf-8 -*-\n\n# Universidade Federal de Campina Grande\n# Aluno: Diego Adolfo Silva de Ara\u00fajo\n# Matricula: 113210090\n# Disciplina: Algoritmos Avan\u00e7ados\n\n# Codeforces\n# Problem: 572A - A. Arrays\n# Time limit per test: 1 second\n# Memory limit per test: 256 megabytes\n# Input: standard input\n# Output: standard output\n\nsticks = map(int, raw_input().split())\nsticks = dict((l, sticks.count(l)) for l in set(sticks))\n\nif len(sticks) > 3 or 4 not in sticks.values():\n print 'Alien'\nelif len(sticks) == 3 or sticks[min(sticks.keys())] == 1:\n print 'Bear'\nelse:\n print 'Elephant'\n"}, {"source_code": "sticks=[int(i) for i in input().split()]\nflag=0\nfor i in sticks:\n if(sticks.count(i)>=4):\n flag=1\n for j in range(1,5):\n sticks.remove(i)\nif(flag==0):\n print(\"Alien\")\nelse:\n if(sticks[0]3:\n print(\"Alien\")\n break\nfor i in a:\n if i == o[0]:\n b += 1\n elif i == o[1]:\n n += 1\n elif i == o[2]:\n d += 1\nif len(o)!=4:\n if (b or n or d)==6:\n print(\"Elephant\")\n elif (b or n or d)==5:\n print(\"Bear\")\n else:\n if b==4:\n if n!=d:\n print(\"Elephant\")\n else:\n print(\"Bear\")\n elif n==4:\n if b!=d:\n print(\"Elephant\")\n else:\n print(\"Bear\")\n elif d==4:\n if b!=n:\n print(\"Elephant\")\n else:\n print(\"Bear\")\n else:\n print(\"Alien\")"}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\ndic={}\nfor i in l:\n if dic.get(i):\n dic[i]+=1 \n else:\n dic[i]=1\nkey=list(dic.keys())\n#print(key)\nif len(key)>3:\n print(\"Alien\")\n exit(0)\nelif len(key)==3:\n print(\"Bear\")\nelif len(key)==2:\n flag=0\n \n for k,v in dic.items():\n if v==5:\n # print(\"Bear\")\n # exit(0)\n flag=1\n if flag:\n print(\"Bear\")\n else:\n print(\"Elephant\")\nelse:\n print(\"Elephant\")\n\n\n "}, {"source_code": "a = map(int,raw_input().split())\ns =[]\nfor i in a:\n if i not in s:\n s.append(i)\n\nif len(s)>3:\n print \"Alien\"\nelif len(s)==1:\n print \"Elephant\"\nelif len(s)==3:\n print \"Bear\"\nelse:\n l = a.count(s[0])\n if l==5 or l==1:\n print \"Bear\"\n elif l == 4 or l== 2 :\n print \"Elephant\"\n else :\n print \"Alien\"\ni=0\n \n"}, {"source_code": "temp=raw_input()\nx=[int(i) for i in temp.split()]\nimport collections\ny=collections.Counter(x)\nli=[]\nfor i in y:\n li.append(y[i])\nli=sorted(li)\nli=li[::-1]\nfor i in range(0,len(li)):\n if(li[0]>=4):\n li=li[1:]\n if(len(li)>=2):\n print \"Bear\"\n break\n else:\n print \"Elephant\"\n break\n else:\n print \"Alien\"\n break"}, {"source_code": "def main():\n\tarr = list(map(int,input().split()))\n\tdp = [0 for _ in range(10)]\n\tfor i in range(len(arr)):\n\t\tdp[arr[i]]+=1\n\tflag = True\n\tindex = 0\n\tfor i in range(len(dp)):\n\t\tif dp[i]==4:\n\t\t\tflag = False\n\t\t\tindex = i\n\t\t\tbreak\n\tif flag:\n\t\tprint(\"Alien\")\n\telse:\n\t\tadd = sum(arr)\n\t\tfor i in range(len(dp)):\n\t\t\tif dp[i]==2:\n\t\t\t\tprint(\"Elephant\")\n\t\t\t\treturn\n\t\tprint(\"Bear\")\n\t\treturn\n\nmain()\n"}, {"source_code": "x=[int(a) for a in input().split()]\ny=set(x)\ny=sorted(y)\nif len(y)==3:\n if x.count(y[1])==4 or x.count(y[0])==4:\n print(\"Bear\")\n else:\n print(\"Alien\")\nelif len(y)==1:\n print(\"Elephant\")\n quit()\nelif len(y)==2:\n c=x.count(y[0])\n if x.count(y[1])!=4:\n print(\"Alien\")\n quit\n if c==1:\n print(\"Bear\")\n else:\n print(\"Elephant\")\nelse:\n print(\"Alien\")"}, {"source_code": "sticks=[int(i) for i in input().split()]\nflag=0\nfor i in sticks:\n if(sticks.count(i)>=4):\n flag=1\n for j in range(1,5):\n sticks.remove(i)\nif(flag==0):\n print(\"Alien\")\nelse:\n if(sticks[0]3):\n print('Alien')\nelse:\n for i in a:\n if l.count(i)==4:\n while i in l: l.remove(i) \n elif l.count(i)==5:\n while i in l: l.remove(i) \n l.append(i)\n if(l[0]==l[1]):\n print('Elephant')\n else:\n print('Bear')\n\n"}, {"source_code": "# MUH and Sticks\n\nl = map(int, raw_input().split())\nl1 = set(l)\n\nif len(l1) > 3:\n print 'Alien'\nelif len(l1) == 3:\n for item in l1:\n if l.count(item) == 4:\n print 'Bear'\n break\nelif len(l1) == 2:\n for item in l1:\n if l.count(item) == 4:\n print 'Elephant'\n break\n else:\n print 'Bear'\n break\nelse:\n print 'Elephant'\n"}, {"source_code": "b=[]\nb+=raw_input()\ntemp=0\nfor i in range(0,5):\n for j in range(0,10,2):\n if b[j]>b[j+2]:\n temp=b[j]\n b[j]=b[j+2]\n b[j+2]=temp\nif b[0]==b[2]==b[4]==b[6] and b[8]==b[10] and b[8]>=b[0]:\n print \"Elephant\"\nelif b[2]==b[4]==b[6]==b[8] and b[10]>b[8] and b[0]b[8] :\n print \"Bear\"\nelse:\n print \"Alien\"\n\n \n \n \n \n \n "}, {"source_code": "a = raw_input(\"\")\nlista = []\nlistaValores=[]\n\nwhile len(a)!=11:\n\t#print(\"entradas erradas\")\n\ta = raw_input(\"\")\n\nfor x in a:\t\n\tif x == ' ':\n\t\tpass\n\telse:\n\t\tlista.append(x)\n\n#print \"lista total\",lista\n\numaVez = list(set(lista))\n\n#print \"lista de unicos\", umaVez\n\nfor x in umaVez:\n\tlistaValores.append(lista.count(x))\n\n#print \"lista de valores\", listaValores\n\nif 4 in listaValores:\n\tif (2 in listaValores):\n\t\tprint \"Elephant\"\n\telif (listaValores.count(1)==2):\n\t\tprint \"Bear\"\n\telse:\n\t\tprint \"Alien\"\nelse:\n\tprint \"Alien\"\n"}, {"source_code": "__author__ = '\u0410\u043d\u0434\u0440\u0435\u0439'\nimport sys\n\na = list(map(int, input().split()))\np = [0] * 10\nfor item in a:\n p[item] += 1\nfor item in p:\n if item == 4:\n for itm in p:\n if itm == 1:\n print('Bear')\n sys.exit()\n elif itm == 2:\n print('Elephant')\n sys.exit()\nprint('Alien')"}, {"source_code": "l=input().split()\ns=[]\nfor i in l:\n\ts.append(l.count(i))\nif(s.count(4)==0):\n\tprint('Alien')\nelif(s.count(2)!=0):\n\tprint('Elephant')\nelse:\n\tprint('Bear')"}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\ndic={}\ns=set(l)\nu=0\nfor i in s:\n if l.count(s)==4:\n u=1\nif u==0:\n print(\"Alien\")\n exit(0)\nfor i in l:\n if dic.get(i):\n dic[i]+=1 \n else:\n dic[i]=1\nkey=list(dic.keys())\n#print(key)\nif len(key)>3:\n print(\"Alien\")\n exit(0)\nelif len(key)==3:\n print(\"Bear\")\nelif len(key)==2:\n flag=0\n \n for k,v in dic.items():\n if v==5:\n # print(\"Bear\")\n # exit(0)\n flag=1\n if flag:\n print(\"Bear\")\n else:\n print(\"Elephant\")\nelse:\n print(\"Elephant\")\n\n\n "}, {"source_code": "*l,=map(int,input().split())\nd={i:l.count(i)-4 if l.count(i)>4 else l.count(i) for i in l if l.count(i)!=4}\nif len(d)==1:print('Elephant')\nelif len(d)==2:print('Bear')\nelse:print('Alien')"}, {"source_code": "x = [0 for i in range(10)]\nlst = list(map(int,input().split()))\nfor i in range(6):\n x[lst[i]] += 1\nans = []\nfor i in range(len(x)):\n if(x[i] != 0):\n ans.append(x[i])\nif(4 not in ans and len(ans) > 1):\n print(\"Alien\")\n exit()\nif(len(ans) <= 2):\n print(\"Elephant\")\n exit()\nprint(\"Bear\")"}, {"source_code": "arr = map(int, raw_input().split())\na = ['Bear', 'Elephant']\nl = [i for i in arr if arr.count(i) <= 2]\nif len(l) == 2:\n print a[l[0] == l[1]]\nelif len(l) == 1:\n print a[0]\nelif len(l) == 0:\n print a[1]\nelse:\n print 'Alien'"}, {"source_code": "#coding: utf-8\na = map(int, raw_input().split())\n\ncount = 0\nlegs_len = 0\n\nfor i in range(len(a)):\n\tcount = 0\n\tfor b in range(len(a)):\n\t\tif(a[i] == a[b]):\n\t\t\tcount += 1\n\t\tif(count == 4):\n\t\t\tbreak\n\tif(count == 4):\n\t\tlegs_len = a[i]\n\t\tbreak\n\nif(count < 4):\n\tprint 'Alien'\n\texit()\n\ncount = 0\ni = 0\n\nfor i in range(len(a)):\n\tindex_ref = 0\n\tif(a[i] != legs_len):\n\t\tcount += 1\n\t\tif(count == 2):\n\t\t\tbreak\n\t\tindex_ref = i\n\t\t\nif((a[index_ref] < a[i]) or (a[i] < a[index_ref])):\n\tprint 'Bear'\nelse:\n\tprint 'Elephant'\n"}, {"source_code": "l=[int(x) for x in raw_input().split()]\nA=len(set(l))\nans=chk=0\n\na=[0,0,0,0,0,0,0,0,0,0]\nfor i in l:\n a[i]+=1\nif 4 not in a:\n print 'Alien'\nelse:\n if 2 in a:\n# if a.index(2)>a.index(4):\n print 'Elephant'\n# else:\n# print 'Alien'\n else:\n c=a.index(4)\n if 1 in a[:c] and 1 in a[c:]:\n print 'Bear'\n else:\n print 'Alien'"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\n\nl = list(map(int, input().split()))\nl.sort()\n\nif l.count(l[0]) == 2 and l.count(l[3]) == 4 or l.count(l[0]) == 4 and l.count(l[3]) == 2: \n stdout.write(\"Elephant\")\n\nelif l[1] == l[2] == l[3] == l[4] or l[1] == l[2] == l[3] == l[0] or l[5] == l[2] == l[3] == l[4]:\n stdout.write(\"Bear\")\n\nelse:\n stdout.write(\"Alien\")\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\nl = list(map(int, input().split()))\nd = {}\ntwo = 0\nfor i in range(6):\n if(l[i] in d):\n d[l[i]]+=1\n else:\n d[l[i]] = 1\nif(len(d)==1):\n if(list(d.values())[0]==6):\n print('Elephant')\n else:\n print('Alien')\nelif(len(d) > 3 or len(d)< 2):\n print('Alien')\nelse:\n if(len(d)==2):\n if(2 not in list(d.values())):\n print('Alien')\n else:\n print('Elephant')\n else:\n if(4 not in list(d.values()) and 1 not in list(d.values())):\n print('Alien')\n else:\n print('Bear')\n"}, {"source_code": "a = map(int, raw_input().split())\nb = list(set(a))\nc = [0]*9\nfor i in a:\n\tc[i]=c[i]+1\nif len(b)==1:\n\t\tprint \"Elephant\"\nif len(b)==2: #1 1 1 1 1 5 | 1 2 2 1 1 1\n\tfor i in c:\n\t\tif i == 5:\n\t\t\tprint \"Bear\"\n\t\telse:\n\t\t\tprint \"Elephant\"\nif len(b)==3: #11 22 33 | 1 1 1 1 2 3\n\tfor i in c:\n\t\tif i == 4:\n\t\t\tprint \"Bear\"\n\t\telse:\n\t\t\tprint \"Alien\"\nif len(b)>3:\n\t\tprint \"Alien\"\n"}, {"source_code": "def has_legs(lengths_array):\n for x in lengths_array:\n if x == 4:\n return True\n else:\n return False\n\n\ndef determine_animal(lengths_array):\n for x in lengths_array:\n if x == 1:\n return 'Bear'\n elif x == 2 or x == 6:\n return 'Elephant'\n\n\ndef count_sticks(lengths):\n lengths_array = [0]*6\n for x in lengths:\n lengths_array[x-1] += 1\n return lengths_array\n\n\nlengths_input = [int(x) for x in input().split()]\nlengths_array = count_sticks(lengths_input)\nif has_legs(lengths_array):\n animal = determine_animal(lengths_array)\n print(animal)\nelse:\n print('Alien')\n"}, {"source_code": "x=[int(a) for a in input().split()]\ny=set(x)\ny=sorted(y)\nif len(y)==3:\n if x.count(y[2])==4:\n print(\"Bear\")\n else:\n print(\"Alien\")\nelif len(y)==1:\n print(\"Elephant\")\n quit()\nelif len(y)==2:\n c=x.count(y[0])\n if x.count(y[1])!=4:\n print(\"Alien\")\n quit()\n if c==1:\n print(\"Bear\")\n else:\n print(\"Elephant\")\nelse:\n print(\"Alien\")"}, {"source_code": "d={}\nfor i in map(int,input().split()):\n\td[i]=d.get(i,0)+1\nif not 4 in d.values() and not 5 in d.values():\n\tprint(\"Alien\")\nelse:\n\ta=[]\n\tfor i in d:\n\t\tif d[i]!=4:\n\t\t\tfor j in range(d[i]):\n\t\t\t\ta.append(i)\n\tif a[0]==a[1]:\n\t\tprint(\"Elephant\")\n\telse:\n\t\tprint(\"Bear\")\n"}, {"source_code": "l=list(map(int,input().split(\" \")))\ns=set(l)\na=list()\nif len(s)>3:\n\tprint(\"Alien\")\nelse:\n\tfor i in range(0,6):\n\t\tif l.count(l[i])!=4:\n\t\t\ta.append(l[i])\n\tif a[0]==a[1]:\n\t\tprint(\"Elephant\")\n\telse:\n\t\tprint(\"Bear\")"}, {"source_code": "a = map(int, raw_input().split())\nb = list(set(a))\nc = [0]*10\nfor i in a:\n\tc[i]=c[i]+1\nc = sorted(c,reverse=True)\nif len(b)==1:\n\t\tprint \"Elephant\"\nif len(b)==2: #1 1 1 1 1 5 | 1 2 2 1 1 1 | 5 5 5 6 6 6\n\tcnt = 0\n\tfor i in c:\n\t\tif i == 5:\n\t\t\tprint \"Bear\"\n\t\t\texit()\n\t\telse:\n\t\t\tif i == 3:\n\t\t\t\tprint \"Alien\"\n\t\t\t\texit()\n\tprint \"Elephant\"\nif len(b)==3: #11 22 33 | 1 1 1 1 2 3\n\tfor i in c:\n\t\tif i == 4:\n\t\t\tprint \"Bear\"\n\texit()\n\tprint \"Alien\"\nif len(b)>3:\n\t\tprint \"Alien\"\n"}, {"source_code": "#n=int(raw_input())\nd=[]\nd=map(long, raw_input().split())\nmn=min(d)\nmn_c=0\nmx=max(d)\nmx_c=0\nav=0\nav_c=0\nfor i in range(6):\n if(d[i]!=mx and d[i]!=mn):\n av=d[i]\n av_c+=1\n if(d[i]==mx):\n mx_c+=1\n if(d[i]==mn):\n mn_c+=1\nif(av_c==4 and d.count(av)==4):\n av_c=4\nelif(av_c==4 and d.count(av)!=4):\n av_c=6\nif(av_c==0 or mx==mn):\n print \"Elephant\"\nelif(av_c==4):\n print \"Bear\"\nelse:\n print \"Alien\""}, {"source_code": "from collections import Counter\ndef solved(dic):\n chan = 0\n #print(dic)\n if dic == {0: 6}:\n return 'Alien'\n if len(list(dic.values())) == 3:\n for k,v in dic.items():\n if v == 4:\n chan = k\n if chan != 0:\n return 'Bear'\n elif len(list(dic.values())) == 2:\n for k,v in dic.items():\n if v == 4:\n chan = k\n if chan != 0:\n return 'Elephant'\n elif len(list(dic.values())) == 1:\n return 'Elephant'\n else:\n return 'Alien'\nif __name__ == '__main__':\n lst = list(map(int,input().split()))\n dic = Counter(lst)\n print(solved(dic))"}, {"source_code": "l = list(map(int, input().split()))\nn = len(l)\nelephant = False\nbear = False\n\nfor i in range(0, n) :\n for j in range(i + 1, n) :\n f = 0\n bad = False\n for c in range(0, n) :\n if (i == c or j == c) :\n continue\n if (f == 0) :\n f = l[c]\n if (f != l[c]) :\n bad = True\n\n if (bad == False) :\n if (l[i] == l[j]) :\n elephant = True\n if (l[i] < l[j]) :\n bear = True\n\nif (not elephant and not bear) :\n print(\"Alien\")\nelif (elephant) :\n print(\"Elephant\")\nelse :\n print(\"Bear\")"}, {"source_code": "'''\nCreated on 26/09/2014\n\n@author: User\n'''\nimport sys\nl = sys.stdin.readline().strip().split()\nd = {}\nflag = False\nminus = 0\nmayor = 0\nfor i in l:\n if i not in d:\n d[i] = 0\n d[i] += 1\n \nfor i in d:\n if d[i] == 4:\n flag = True\n legs = i\nif flag:\n d_sort = sorted(d.keys())\n d_sort.remove(legs)\n if len(d_sort) == 2:\n minus = min(d_sort)\n mayor = max(d_sort)\n if minus < mayor:\n print \"Bear\"\n else:\n print \"Elephant\"\n elif len(d_sort) == 1:\n print \"Elephant\"\nelse:\n print \"Alien\""}, {"source_code": "list = list(map(int, input().split(\" \")))\nlist.sort()\ncount=0\ncount1=1\nindex =[]\nlist.append(-1)\n\nfor i in range(len(list)-1):\n count= list.count(list[i])\n if list[i] == list[i+1]:\n count1 = count1 +1\n if count==1:\n index.append(i)\n\nif len(index)==2 or len(index)== 1 :\n print('Bear')\nelif len(index)==0 and count1==3:\n print('Elephant')\nelif count1==3:\n print('Alien')\nelse:\n print('Alien')"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jul 17 20:40:54 2019\n\n@author: avina\n\"\"\"\n\nl = list(map(int, input().split()))\n\nl.sort()\nn = len(set(l))\nif n <=3:\n if l[1] == l[0]:\n print('Elephant')\n else:\n print('Bear')\nelse:\n print('Alien')"}, {"source_code": "import sys,collections\n\nsticks = sys.stdin.readline().strip().split(' ')\n\nstick_map = collections.Counter()\n\nfor stick in sticks:\n stick_map[stick] += 1\n\nsm_val = stick_map.values()\nsm_val.sort()\nif len(stick_map) == 2 and sm_val[0] == 2 and sm_val[1] == 4:\n print \"Elephant\"\nelif len(stick_map) == 3 and sm_val[0] == 1 and sm_val[1] == 1 and sm_val[2] == 4:\n print \"Bear\"\nelse:\n print \"Alien\"\n"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\n\nl = list(map(int, input().split()))\nl.sort()\n\nif l[0] == l[1] == l[2] == l[3] and l[4] == l[5] and l[4] != l[3]: \n stdout.write(\"Elephant\")\n\nelif l[1] == l[2] == l[3] == l[4] and l[5] > l[4] and l[1] > l[0]:\n stdout.write(\"Bear\")\n\nelse:\n stdout.write(\"Alien\")\n"}, {"source_code": "x=map(int,raw_input().split())\ny={}\nfor i in x:\n if i not in y:\n y[i]=1\n else:\n y[i]+=1\nx=y.keys()\nif max(y.values())!=4:\n print \"Alien\"\nelse:\n i=y.values().index(max(y.values()))\n x.remove(x[i])\n if(len(x)==1):\n print \"Elephant\"\n elif(min(x)!=max):\n print \"Bear\"\n else:\n print \"Alien\""}, {"source_code": "b=[]\nb+=raw_input()\ntemp=0\nfor i in range(0,5):\n for j in range(0,10,2):\n if b[j]>b[j+2]:\n temp=b[j]\n b[j]=b[j+2]\n b[j+2]=temp\nif b[0]==b[2]==b[4]==b[6] and b[8]==b[10] and b[8]>=b[0]:\n print \"Elephant\"\nelif b[2]==b[4]==b[6]==b[8] and b[10]>b[8] and b[0]3:\n print('Alien')\n break\n elif h[n]==5:\n print('Bear')\n break\n else: \n print('Alien')\n break"}, {"source_code": "#!/usr/bin/python\n\ndef main():\n\tresult={}\n\tlst=raw_input().split()\n\talien=True\n\tfor i in lst:\n\t\tif i not in result:\n\t\t\tresult[i]=1\n\t\telse:\n\t\t\tresult[i]+=1\n\trem=[]\n\tfor key, val in result.iteritems():\n\t\tif val>=4:\n\t\t\talien=False\n\t\telse:\n\t\t\trem.append(key)\n\n\tif alien:\n\t\tprint 'Alien'\n\telse:\n\t\tif len(rem)<=1:\n\t\t\tprint 'Elephant'\n\t\telse:\n\t\t\tprint 'Bear'\n\nif __name__=='__main__':\n\tmain()"}, {"source_code": "l = list(map(int,input().split()))\nd = dict()\nfor i in l:\n if not (i in d) :\n d[i] = 1\n else :\n d[i] +=1\nif len(d) == 2 or len(d) == 1:\n print(\"Elephant\")\nelif len(d) == 3:\n print(\"Bear\")\nelse :\n print(\"Alien\")"}, {"source_code": "# 471A\na = input().split()\na = list(map(int,a))\ndef sort(a):\n for i in range(len(a)):\n for j in range(i+1,len(a)):\n if a[i] > a[j]:\n s = a[i]\n a[i] = a[j]\n a[j] = s\n return a\ndef counter(a):\n g = a[0]\n b = [1]\n for i in range(1,len(a)):\n if a[i] == g:\n b[len(b)-1] += 1\n else:\n g = a[i]\n b.append(1)\n return b\na = sort(a)\nb = counter(a)\nm = 0\nfor j in range(len(b)):\n if m < b[j]:\n m = b[j]\nif m < 4:\n print('Alien')\nelse:\n if len(b) <= 2:\n print('Elephant')\n else:\n print('Bear')"}, {"source_code": "list = list(map(int, input().split(\" \")))\nlist.sort()\ncount=0\ncount1=-1\nindex =[]\nlist.append(-1)\n\nfor i in range(len(list)-1):\n count= list.count(list[i])\n if list[i] == list[i+1]:\n count1 = count1 +1\n if count==1:\n index.append(i)\nif (len(index)==2 or len(index)== 1) and (count1 !=1 or len(index)==0) :\n print('Bear')\nelif len(index)==0 and count!=3 and count1!=2:\n print('Elephant')\nelif count==3:\n print('Alien')\nelse:\n print('Alien')"}, {"source_code": "sticks = map(int, raw_input().split())\n\nlegs_found = False\nleg_size = -1\nfor i in range(len(sticks)):\n if sticks.count(sticks[i]) == 4:\n leg_size = sticks[i]\n legs_found = True\n break\n \nif legs_found:\n sticks = filter(lambda x: x != leg_size, sticks)\n \n if sticks[0] == sticks[1]:\n result = \"Elephant\"\n else:\n result = \"Bear\"\nelse:\n result = \"Alien\"\n \nprint result"}, {"source_code": "string = raw_input();\nA = string.split(\" \");\nA.sort();\nA = map(int, A);\n\ndef leg_made(A):\n if (A[0]==A[1] and A[1]==A[2] and A[2]==A[3]) or (A[3]==A[4] and A[1]==A[2] and A[2]==A[3]) or (A[3]==A[4] and A[4]==A[5] and A[2]==A[3]):\n return True\n return False\n\ndef bear_made(A):\n if leg_made(A):\n if ((A[0]==A[1] and A[1]==A[2] and A[2]==A[3]) and A[4] 3 :\n\n print 'Alien'\n\nelse :\n\n if (len(Set) == 2 and 2 in l) or len(Set) == 1 :\n\n print 'Elephant'\n\n else :\n\n print 'Bear'\n"}, {"source_code": "x = [0 for i in range(10)]\nlst = list(map(int,input().split()))\nfor i in range(6):\n x[lst[i]] += 1\nans = []\nfor i in range(len(x)):\n if(x[i] != 0):\n ans.append(x[i])\nif(4 not in ans and len(ans) >= 2):\n print(\"Alien\")\n exit()\nif(len(ans) == 2 and 4 in ans or len(ans) == 1):\n print(\"Elephant\")\n exit()\nprint(\"Bear\")"}, {"source_code": "from sys import stdin, stdout\ninput = stdin.readline\n\nl = list(map(int, input().split()))\nl.sort()\n\nif l.count(l[0]) == 2 and l.count(l[3]) == 4 or l.count(l[0]) == 4 and l.count(l[3]) == 2: \n stdout.write(\"Elephant\")\n\nelif l[1] == l[2] == l[3] == l[4] or l[1] == l[2] == l[3] == l[0] or l[5] == l[2] == l[3] == l[4]:\n stdout.write(\"Bear\")\n\nelse:\n stdout.write(\"Alien\")\n"}, {"source_code": "a, b, c, d, e, f = map(int, input().split(' '))\nwant = -1\nlistSticks = [a, b, c, d, e, f]\nfor value in listSticks:\n if listSticks.count(value)>= 4:\n want = value\nif want>0:\n listSticks = list(set(listSticks))\n listSticks.remove(value)\n if (len(listSticks) <= 1):\n print(\"Elephant\")\n else:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n"}, {"source_code": "# ===============================\n# (c) MidAndFeed aka ASilentVoice\n# ===============================\nimport math, fractions\n# ===============================\nq = [int(x) for x in input().split()]\nsq = set(q)\nif len(sq) > 3:\n\tprint(\"Alien\")\nelse:\n\tif len(sq) == 3:\n\t\tprint(\"Bear\")\n\telse:\n\t\tfor x in sq:\n\t\t\tif q.count(x) > 4:\n\t\t\t\tprint(\"Bear\")\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tprint(\"Elephant\")\n\t\t\t\tbreak"}, {"source_code": "inp=raw_input()\narr=[int(i) for i in inp.split()]\nk=False\nfor i in range(len(arr)):\n c=0\n for j in range(len(arr)):\n if arr[i]==arr[j]:\n c+=1\n if c==4:\n k=True\n break\nif k:\n left=filter(lambda x:x!=arr[i],arr)\n if len(set(left))==2:\n print \"Bear\"\n if len(set(left))==1:\n print \"Elephant\"\nelse:\n print \"Alien\"\n"}, {"source_code": "mylist = list(map(int, input().split()))\nmyset = list(set(mylist))\nflag = 0\nelephant = 0\nfor i in range(0, len(myset)):\n if(mylist.count(myset[i]) == 4):\n flag = 1\n if(mylist.count(myset[i]) == 2):\n elephant = 1\nif flag == 0:\n print(\"Alien\")\nelse:\n if(elephant == 1):\n print(\"Elephant\")\n else:\n print(\"Bear\")"}, {"source_code": "cifre = raw_input().split(\" \")\nc = [0 for i in range(9)]\n\nfor i in range(6):\n c[int(cifre[i]) - 1] += 1\n\nprint(c)\n\nelephant = False\nalien = True\nfor i in range(9):\n if(c[i] == 2 or c[i] == 6):\n elephant = True\n if(c[i] >= 4):\n alien = False\n\nif(alien):\n print(\"Alien\")\nelif(elephant):\n print(\"Elephant\")\nelse:\n print(\"Bear\")\n \n \n"}, {"source_code": "list = list(map(int, input().split(\" \")))\nlist.sort()\ncount=1\nindex =[]\nlist.insert(0,-1)\nfor i in range(len(list)-1):\n if list[i]==list[i+1]:\n count = count+1\nif count==4:\n print(\"Bear\")\nelif count==5:\n print('Elephant')\nelse:\n print('Alien')"}, {"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\nsticks = ctr(rl()).values()\nif len(sticks) == 2 and 2 in sticks and 4 in sticks:\n print 'Elephant'\nelif len(sticks) == 3 and 4 in sticks and 1 in sticks:\n print 'Bear'\nelse:\n print 'Alien'\n"}, {"source_code": "f=input()\nf=f.split(\" \")\nf.sort()\ncheck1=False\ncheck2=False\ncheck3=False\ni=0\nwhile i<6:\n if f.count(f[i])==4:\n i+=4\n check1=True\n elif f.count(f[i])==2:\n check2=True\n i+=2\n elif f.count(f[0])==1:\n check3=True\n i+=1\n else:\n break\nif check1:\n if check2:\n print(\"Elephant\")\n elif check3:\n print(\"Bear\")\nelse:\n print(\"Alien\")\n \n"}, {"source_code": "l=list(map(int,input().split()))\nl.sort()\ndic={}\nfor i in l:\n if dic.get(i):\n dic[i]+=1 \n else:\n dic[i]=1\nkey=list(dic.keys())\n#print(key)\nif len(key)>3:\n print(\"Alien\")\n exit(0)\n\nelif len(key)==2:\n print(\"Elephant\")\nelse:\n print(\"Bear\")\n\n\n "}, {"source_code": "from __future__ import division, print_function\n\ndef main():\n a = [int(_) for _ in input().split()]\n f = Counter(a)\n size = len(f)\n if size == 3:\n print(\"Bear\")\n elif size == 2 or size == 1:\n print(\"Elephant\")\n else:\n print(\"Alien\") \n \n\n# PyPy 2 Fast IO\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\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n# Importing Modules\nimport math\nimport collections\n\nfrom collections import Counter\nfrom math import fabs\n\nif __name__ == \"__main__\":\n main()"}, {"source_code": "l1,l2,l3,l4,l5,l6=map(int, input().split())\na=[]\na.append(l1)\na.append(l2)\na.append(l3)\na.append(l4)\na.append(l5)\na.append(l6)\na=sorted(a)\nb=0\nfor i in range(0,2):\n if(a[i]==a[i+4]):\n b=1\n break\n i=i+1\nif(len(set(a))>3):\n print(\"Alien\")\nelif(len(set(a))==3):\n print(\"Bear\")\nelif(len(set(a))==1):\n print(\"Elephant\")\nelif(b==0):\n print(\"Elephant\")\nelse:\n print(\"Bear\")"}, {"source_code": "# MUH and Sticks\n\nl = map(int, raw_input().split())\nl1 = set(l)\n\nif len(l1) > 3:\n print 'Alien'\nelif len(l1) == 3:\n for item in l1:\n if l.count(item) == 4:\n print 'Bear'\n break\nelif len(l1) == 2:\n for item in l1:\n if l.count(item) == 4:\n print 'Elephant'\n break\nelse:\n print 'Elephant'\n"}, {"source_code": "list = list(map(int, input().split(\" \")))\nlist.sort()\ncount=1\nindex =[]\nlist.append(-1)\n\nfor i in range(len(list)-1):\n count= list.count(list[i])\n if count==1:\n index.append(i)\nif len(index)==2 or len(index)==1 :\n print('Bear')\nelif len(index)==0:\n print('Elephant')\nelse:\n print('Alien')"}, {"source_code": "lst=list(map(int,input().split()))\ns=set(lst)\nif len(s)==2 or len(s)==1:\n print('Elephant')\nelif len(s)==3:\n print('Bear')\nelse:\n print('Alien')"}, {"source_code": "d={}\nfor i in map(int,input().split()):\n\td[i]=d.get(i,0)+1\nif not 4 in d.values():\n\tprint(\"Alien\")\nelse:\n\ta=[]\n\tfor i in d:\n\t\tif d[i]!=4:\n\t\t\tfor j in range(d[i]):\n\t\t\t\ta.append(i)\n\tif a[0]==a[1]:\n\t\tprint(\"Elephant\")\n\telse:\n\t\tprint(\"Bear\")\n"}, {"source_code": "l=list(map(int,input().split()))\nf=set(l)\ncnt=0\nfor i in f:\n if l.count(i)==4:\n cnt+=1\n elif l.count(i)==2:\n cnt+=1\n else:\n cnt+=0\nif cnt==1:\n print(\"Bear\")\nelif cnt==2:\n print(\"Elephant\")\nelse:\n print(\"Alien\")"}, {"source_code": "n=list(map(int,input().split()))\na=len(set(n))\nif(a>3):\n\tprint(\"Alien\")\nelse:\n\tc=[]\n\tfor i in range(6):\n\t\tc.append(n.count(n[i]))\n\tprint(c)\n\tif(max(c)<4):\n\t\tprint(\"Alien\")\n\telif(c.count(1)==2 or (len(set(c))==2 and n[c.index(max(c))]>n[c.index(min(c))])):\n\t\tprint(\"Bear\")\n\telse:\n\t\tprint(\"Elephant\")\n"}, {"source_code": "#coding: utf-8\na = map(int, raw_input().split())\n\ncount = 0\nlegs_len = 0\n\nfor i in range(len(a)):\n\tcount = 0\n\tfor b in range(len(a)):\n\t\tif(a[i] == a[b]):\n\t\t\tcount += 1\n\t\tif(count == 4):\n\t\t\tbreak\n\tif(count == 4):\n\t\tlegs_len = a[i]\n\t\tbreak\n\nif(count < 4):\n\tprint 'Alien'\n\texit()\n\ncount = 0\ni = 0\nindex_ref = 0\nfor i in range(len(a)):\n\tif(a[i] != legs_len):\n\t\tcount += 1\n\t\tif(count == 2):\n\t\t\tbreak\n\t\tindex_ref = i\n\t\t\nif((a[index_ref] < a[i]) or (a[i] < a[index_ref])):\n\tprint 'Bear'\nelif(a[index_ref] == a[index_ref]):\n\tprint 'Bear'\nelse:\n\tprint 'Elephant'\n"}, {"source_code": "a = map(int,raw_input().split())\nif a.count(a[0]) <4 and a.count(a[1]) <4 and a.count(a[2]) <4:\n print \"Alien\"\nif a.count (a[0]) >= 4:\n a.remove(a[0])\n a.remove(a[0])\n a.remove(a[0])\n a.remove(a[0])\nelif a.count (a[1]) >= 4:\n a.remove(a[1])\n a.remove(a[1])\n a.remove(a[1])\n a.remove(a[1])\nelif a.count (a[2]) >= 4:\n a.remove(a[2])\n a.remove(a[2])\n a.remove(a[2])\n a.remove(a[2])\nif a[0] == a[1]:\n print \"Elephant\"\nelse:\n print \"Bear\""}, {"source_code": "#n=int(raw_input())\nd=[]\nd=map(long, raw_input().split())\nmn=min(d)\nmn_c=0\nmx=max(d)\nmx_c=0\nav=0\nav_c=0\nfor i in range(6):\n if(d[i]!=mx and d[i]!=mn):\n av=d[i]\n av_c+=1\n if(d[i]==mx):\n mx_c+=1\n if(d[i]==mn):\n mn_c+=1\nif(av_c==4 and d.count(av)==4):\n av_c=4\nelif(av_c==4 and d.count(av)!=4):\n av_c=6\nif(av_c==0 and mx!=mn):\n print \"Elephant\"\nelif(av_c==4):\n print \"Bear\"\nelse:\n print \"Alien\""}, {"source_code": "lis=list(map(int,input().split()))\ns=set()\ndict={}\nfor i in lis:\n if i not in dict:\n dict[i]=1\n s.add(i)\n else:\n dict[i]+=1\nif len(s)!=3 and len(s)!=2 and len(s)!=1:\n print('Alien')\nelif len(s)==1 and lis.count(lis[0])==6:\n print('Elephant')\nelse:\n lis2=list(s)\n ele=False\n ani=False\n for i in lis2:\n if lis.count(i)==2:\n ele=True\n if lis.count(i)==4:\n ani=True\n if ani and ele:\n print('Elephant')\n elif ani:\n print('Bear')\n else:\n print('Alien')"}, {"source_code": "\nsticks_str = raw_input()\nsticks = sticks_str.split(\" \")\n\nkey = [1, 2, 3, 4, 5, 6, 7, 8, 9]\nvalue = [0, 0, 0, 0, 0, 0, 0, 0, 0]\nstick_hash = dict(zip(key, value))\n\nfor num in sticks:\n n = int(num)\n if n in stick_hash:\n stick_hash[n] += 1\n else:\n stick_hash[n] = 1\n\nif stick_hash[4] == 4 and stick_hash[2] == 1 and stick_hash[5] == 1:\n print \"Bear\"\nelif stick_hash[4] == 4 and stick_hash[5] == 2:\n print \"Elephant\"\nelse:\n print \"Alien\"\n"}], "src_uid": "43308fa25e8578fd9f25328e715d4dd6"} {"nl": {"description": "Little Johnny Bubbles enjoys spending hours in front of his computer playing video games. His favorite game is Bubble Strike, fast-paced bubble shooting online game for two players.Each game is set in one of the N maps, each having different terrain configuration. First phase of each game decides on which map the game will be played. The game system randomly selects three maps and shows them to the players. Each player must pick one of those three maps to be discarded. The game system then randomly selects one of the maps that were not picked by any of the players and starts the game.Johnny is deeply enthusiastic about the game and wants to spend some time studying maps, thus increasing chances to win games played on those maps. However, he also needs to do his homework, so he does not have time to study all the maps. That is why he asked himself the following question: \"What is the minimum number of maps I have to study, so that the probability to play one of those maps is at least $$$P$$$\"?Can you help Johnny find the answer for this question? You can assume Johnny's opponents do not know him, and they will randomly pick maps.", "input_spec": "The first line contains two integers $$$N$$$ ($$$3$$$ $$$\\leq$$$ $$$N$$$ $$$\\leq$$$ $$$10^{3}$$$) and $$$P$$$ ($$$0$$$ $$$\\leq$$$ $$$P$$$ $$$\\leq$$$ $$$1$$$) \u2013 total number of maps in the game and probability to play map Johnny has studied. $$$P$$$ will have at most four digits after the decimal point.", "output_spec": "Output contains one integer number \u2013 minimum number of maps Johnny has to study.", "sample_inputs": ["7 1.0000"], "sample_outputs": ["6"], "notes": null}, "positive_code": [{"source_code": "def prob(n,k):\r\n pt=(k*(k-2)*(k-1)+3*(k-1)*k*(n-k)+3/2*k*(n-k)*(n-k-1))/(n*(n-2)*(n-1))\r\n return pt\r\nnp=input()\r\nnp=np.split(' ')\r\nn=int(np[0])\r\np=float(np[1])\r\nleft=0\r\nright=n\r\nwhile(left0:\r\n# myPick=-1\r\n# while myPick==-1 or arr3[myPick]==1:\r\n# myPick=randint(0,2)\r\n# else:\r\n# myPick=randint(0,2)\r\n# arr2=[]\r\n# for i in range(3):\r\n# if i!=opponentPick and i!=myPick:\r\n# arr2.append(arr3[i])\r\n# succeedCnts+=arr2[randint(0,len(arr2)-1)]\r\n# return succeedCnts/cnts\r\n \r\n\r\ndef main():\r\n \r\n eps=0\r\n \r\n n,p=input().split()\r\n n=int(n)\r\n p=float(p)\r\n \r\n x=-1\r\n bb=n\r\n while bb>0:\r\n while x+bb<=n and getP(n,x+bb)+eps= p\r\n\r\nl = 0\r\nr = n-1\r\nwhile l<=r:\r\n m = (l+r)//2\r\n if check(m):\r\n r = m - 1\r\n else:\r\n l = m + 1\r\nprint(l)"}, {"source_code": "def C(n, k):\r\n if k == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n else:\r\n return n * (n - 1) // 2\r\n\r\n\r\nss = input().split()\r\nn = int(ss[0])\r\np = float(ss[1])\r\nfor k in range(n + 1):\r\n cur = C(n - k, 3) / C(n, 3) + ((1/3) + (1/3) * (1/2)) * k * C(n - k, 2) / C(n, 3)\r\n if 1 - cur >= p:\r\n print(k)\r\n break"}, {"source_code": "import random\r\n\r\ninp = input().split(\" \")\r\nN = int(inp[0])\r\nP = float(inp[1])\r\n\r\n\r\n# def sim1sm(N, P, s):\r\n# numTrials = 20000\r\n# succ = 0\r\n# for _ in range(numTrials):\r\n# r = [1]\r\n# for _ in range(2):\r\n# n = random.randint(s+1,N)\r\n# while n in r:\r\n# n = random.randint(1,N)\r\n# r.append(n)\r\n\r\n# disc = []\r\n# for i in range(3):\r\n# if r[i] > s:\r\n# disc.append(r[i])\r\n# break\r\n# if len(disc) == 0:\r\n# succ += 1\r\n# continue\r\n \r\n# sd = random.randint(1, 3)\r\n# disc.append(r[sd-1])\r\n \r\n# fc = []\r\n# for i in r:\r\n# if not i in disc:\r\n# fc.append(i)\r\n \r\n# mcidx = random.randint(1, len(fc))\r\n# mc = fc[mcidx - 1]\r\n# if mc <= s:\r\n# succ += 1\r\n \r\n# return succ/numTrials\r\n\r\nl = 0\r\nr = N\r\nwhile(l < r):\r\n mid = int((l+r)/2)\r\n expProb = 0.0\r\n if mid >= 3:\r\n expProb += ((mid * (mid-1) * (mid-2)) / (N * (N-1) * (N-2)))\r\n if mid >= 2:\r\n expProb += (3 * ((N - mid)/N) * (mid/(N-1)) * ((mid-1)/(N-2)))\r\n if mid >= 1:\r\n condProb = (3 * (mid/N) * ((N-mid)/(N-1)) * ((N-mid-1)/(N-2)))\r\n expProb += (condProb * (1/3)) + (condProb * (1/3) * (1/2))\r\n\r\n if expProb < P:\r\n l = mid+1\r\n else:\r\n r = mid\r\n\r\nprint(l)\r\n "}, {"source_code": "n, p = input().split()\r\n\r\np = float(p)\r\nn = int(n)\r\n\r\ndef cnk(n, k):\r\n\tif n < k:\r\n\t\treturn 0\r\n\tret = 1\r\n\tif(k == 1):\r\n\t\treturn n\r\n\tif k == 2:\r\n\t\treturn n * (n - 1) // 2\r\n\treturn n * (n - 1) * (n - 2) // 6\r\n\r\nfor i in range(0, n + 1):\r\n\tcur_prob = 0.0\r\n\t\r\n#\tca = i / n * (n - i) / n * (n - i - 1) / n\r\n\tca = cnk(i, 1) * cnk(n - i, 2) / cnk(n, 3)\r\n\tca = ca * 3 / 6\r\n\t\r\n#\tcb = i / n * (i - 1) / n * (n - i) / n\r\n#\tcb = cb / 2\r\n\tcb = cnk(i, 2) * cnk(n - i, 1) / cnk(n, 3)\r\n\tcb = cb\r\n#\tcc = i / n * (i - 1) / n * (i - 2) / n\r\n#\tcb = cb\r\n\tcc = cnk(i, 3) / cnk(n, 3)\r\n\tcur_prob = ca + cb + cc\r\n#\tprint(cur_prob)\r\n\tif(cur_prob >= p):\r\n\t\tprint(i)\r\n\t\tbreak;\r\n"}, {"source_code": "#-------------------------------------------------------------------------------\r\n# Name: module1\r\n# Purpose:\r\n#\r\n# Author: asawe\r\n#\r\n# Created: 03/08/2022\r\n# Copyright: (c) asawe 2022\r\n# Licence: \r\n#-------------------------------------------------------------------------------\r\n\r\nimport sys\r\n\r\n#sys.stdin = open(\"C:\\\\Users\\\\asawe\\\\Documents\\\\input.txt\",\"r\")\r\n\r\nn,p = map(float,sys.stdin.readline().split())\r\na = []\r\nfor i in range(int(n)):\r\n b = i * (i-1) * (i-2) / n / (n-1) / (n-2)\r\n c = 3 * i * (i-1) * (n-i) / n / (n-1) / (n-2)\r\n d = 3/2 * i * (n-i-1) * (n-i) / n / (n-1) / (n-2)\r\n if b + c + d >= p:\r\n print(i)\r\n break"}, {"source_code": "n, p = map(float, input().split())\r\nans, n = 0, int(n)\r\nall, be, en = n * (n - 1) * (n - 2) // 6, 0, n - 1\r\n\r\nwhile be <= en:\r\n i = (be + en) >> 1\r\n deln, newp = n - i, 0\r\n if i > 2:\r\n newp += i * (i - 1) * (i - 2) // 6\r\n if i > 1:\r\n newp += deln * i * (i - 1) // 2\r\n if deln > 1:\r\n newp += deln * (deln - 1) * i / 4\r\n\r\n if newp / all >= p:\r\n ans, en = i, i - 1\r\n else:\r\n be = i + 1\r\nprint(ans)\r\n"}, {"source_code": "n, p = map(float, input().split())\r\nans, n = 0, int(n)\r\nall = n * (n - 1) * (n - 2) // 6\r\n\r\nfor i in range(n):\r\n deln, newp = n - i, 0\r\n if i > 2:\r\n newp += i * (i - 1) * (i - 2) // 6\r\n if i > 1:\r\n newp += deln * i * (i - 1) // 2\r\n if deln > 1:\r\n newp += deln * (deln - 1) * i / 4\r\n\r\n if newp / all >= p:\r\n break\r\n ans += 1\r\n\r\nprint(ans)\r\n"}, {"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 solve():\r\n arr=list(input().split())\r\n n,p=int(arr[0]),float(arr[1])\r\n\r\n def judge(m):\r\n res=0\r\n res+=(m*(n-m)*(n-m-1))/4 \r\n res+=(m*(max(0,m-1))*(n-m))/2\r\n res+=m*(max(m-1,0))*(max(m-2,0))/6\r\n #print('res',m,res)\r\n return res>1\r\n #print(mid)\r\n if judge(mid):\r\n l=mid+1\r\n else:\r\n r=mid\r\n \r\n print(l)\r\n\r\nsolve()"}, {"source_code": "from xml.dom import minidom\r\n\r\n\r\ndef solve():\r\n arr=list(input().split())\r\n n,p=int(arr[0]),float(arr[1])\r\n\r\n def judge(m):\r\n res=0\r\n res+=(m*(n-m)*(n-m-1))/4 \r\n res+=(m*(max(0,m-1))*(n-m))/2\r\n res+=m*(max(m-1,0))*(max(m-2,0))/6\r\n #print('res',m,res)\r\n return res>1\r\n #print(mid)\r\n if judge(mid):\r\n l=mid+1\r\n else:\r\n r=mid\r\n \r\n print(l)\r\n\r\nsolve()"}, {"source_code": "def prob(db, n):\r\n return db*(db-1)*(db-2)+(n-db)*db*(db-1)*3+(n-db)*(n-db-1)*db*3/2\r\n\r\nn, p = input().split()\r\nn = int(n)\r\np = float(p)\r\np *= n*(n-1)*(n-2)\r\n\r\n\r\ns = 0\r\ne = n-1\r\nwhile s <= e:\r\n act = (s+e)//2\r\n if e-s == 1:\r\n if prob(s, n) >= p:\r\n break\r\n else:\r\n s = e\r\n break\r\n else:\r\n if prob(act, n) >= p:\r\n e = act\r\n else:\r\n s = act\r\n\r\n \r\nprint(s)\r\n "}, {"source_code": "lijst = input().split()\r\nn = int (lijst[0])\r\nd = float (lijst[1])\r\n\r\nkans = 0\r\nk = 0\r\nwhile (kans < d):\r\n k+=1 \r\n kans = 1-((n-k)*(n-k-1)*(n-k-2)/6 + 0.5 *k*(n-k)*(n-k-1)/2)/(n*(n-1)*(n-2)/6)\r\n\r\nprint(k)\r\n"}, {"source_code": "# from math import gcd\r\nfrom math import *\r\n \r\n# Function to find the nCr\r\n \r\n \r\ndef NcK(n, r):\r\n \r\n # p holds the value of n*(n-1)*(n-2)...,\r\n # k holds the value of r*(r-1)...\r\n p = 1\r\n k = 1\r\n \r\n # C(n, r) == C(n, n-r),\r\n # choosing the smaller value\r\n if (n - r < r):\r\n r = n - r\r\n \r\n if (r != 0):\r\n while (r):\r\n p *= n\r\n k *= r\r\n \r\n # gcd of p, k\r\n m = gcd(p, k)\r\n \r\n # dividing by gcd, to simplify product\r\n # division by their gcd saves from\r\n # the overflow\r\n p //= m\r\n k //= m\r\n \r\n n -= 1\r\n r -= 1\r\n \r\n # k should be simplified to 1\r\n # as C(n, r) is a natural number\r\n # (denominator should be 1 )\r\n \r\n else:\r\n p = 1\r\n \r\n # if our approach is correct p = ans and k =1\r\n return(p)\r\n \r\n# for _ in range(int(input())):\r\n# # n = int(input())\r\n# # L = input().rstrip('\\n')\r\n# n,a,b = list(map(int,input().split()))\r\n \r\na,b = list(map(float,input().split()))\r\n# k = (a-1)*b\r\n# if int(k) == k:\r\n# print(int(k))\r\n# else:\r\n# print(int(k)+1) \r\n \r\n \r\na = int(a)\r\nn = a\r\nA = NcK(int(a),3)\r\nif b == 0:\r\n print(0)\r\nelif (NcK(n-1,2)/A)*0.5>=b:\r\n print (1)\r\nelif (n-2)/A + (NcK(n-1,2)/A)*0.5 >= b:\r\n print(2)\r\n \r\n \r\nelse:\r\n # a1 = NcK(a-1,3)\r\n # a2 = NcK(a-1,2) \r\n # A = NcK(int(a),3)\r\n # a11 = NcK(a-2,3)\r\n # if (a1/A)*1+(a2/A)*1>=b and :\r\n # print(a-1) \r\n flag = False \r\n for i in range(3,int(a)-1):\r\n a1 = NcK(i,3)\r\n a2 = NcK(i,2) \r\n a3 = NcK(i,1)\r\n a33 = NcK(a-i,2)\r\n A = NcK(int(a),3)\r\n if (a1/A)*1+(a2*(a-i)/A)*1+(a3*a33/A)*0.5>b:\r\n print(i)\r\n flag = True\r\n break\r\n if not flag:\r\n print(a-1)"}, {"source_code": "\r\ndef f(N, M):\r\n num = M*(M-1)*(M-2)//6 + M*(M-1)*(N-M)//2 + M*(N-M)*(N-M-1)/4\r\n den = N*(N-1)*(N-2)//6\r\n return num/den \r\n\r\ndef process(N, P):\r\n if P==0:\r\n return 0\r\n if P==1:\r\n return N-1\r\n s = 0\r\n e = N-1\r\n while s+1 < e:\r\n m = (s+e)//2\r\n if f(N, m) < P:\r\n s, e = m, e\r\n else:\r\n s, e = s, m\r\n return e\r\n\r\nN, P = input().split()\r\nN = int(N)\r\nP = float(P)\r\nprint(process(N, P))\r\n"}, {"source_code": "from decimal import Decimal\nn, p = input().split()\nn = int(n)\np = Decimal(p)\nN = n * (n - 1) * (n - 2) // 6\n\ndef f(m):\n if m == 0:\n return 0\n if m == n:\n return N * 2\n A3 = m * (m - 1) * (m - 2) // 6\n A2 = m * (m - 1) * (n - m) // 2\n A1 = m * (n - m) * (n - m - 1) // 2\n return (A1 + A2 * 2 + A3 * 2)\n\nfor i in range(0, n+1):\n if f(i) >= N * p * 2:\n print(i)\n break\n"}, {"source_code": "from math import factorial\r\n\r\n\r\ndef binomial(n, k):\r\n if n < k:\r\n return 0\r\n return factorial(n)/(factorial(k) * factorial(n - k))\r\n\r\nn, p = list(input().split())\r\n\r\nn = int(n)\r\np = float(p)\r\n\r\nl, r = 0, n\r\n\r\nwhile l < r:\r\n k = (l + r)//2\r\n cur = binomial(k, 3)/binomial(n, 3) + binomial(k, 2) * (n - k)/binomial(n, 3) + k * binomial(n - k, 2)/binomial(n, 3)/2\r\n if cur < p:\r\n l = k + 1\r\n else:\r\n r = k\r\n\r\nprint(l)\r\n"}, {"source_code": "import math\nimport random\nimport sys\n\ndef main(n,p):\n tot=0 \n\n for i in range(0,n):\n c0=math.comb(i,3) \n c1=math.comb(i,2)*math.comb(n-i,1) \n c2=math.comb(i,1)*math.comb(n-i,2) \n c3=math.comb(n-i,3) \n num=c0+c1+0.5*c2+0*c3\n den=c0+c1+c2+c3\n\n if (num/den)>=p:\n return i\n \n return \"WHAT\" \n\nn,p=list(map(float,input().split()))\nn=int(n) \nprint(main(n,p))\n \n"}, {"source_code": "import math\r\n\r\ndef probCalc(studied, numMaps):\r\n total = math.comb(numMaps, 3)\r\n return (math.comb(studied, 3) + math.comb(studied, 2)*math.comb(numMaps - studied, 1) + 1/2*math.comb(studied, 1) * math.comb(numMaps - studied, 2))/total\r\n\r\n\r\n\r\n[n,p] = input().split(' ')\r\nn = int(n); p = float(p);\r\nfor i in range(n):\r\n if probCalc(i, n) >= p:\r\n print(i)\r\n break"}, {"source_code": "from math import factorial as fac\r\n\r\ntmp = 1\r\nfc = []\r\nfor i in range(1001):\r\n fc.append(tmp)\r\n tmp *= (i+1)\r\n\r\ndef bio(n, m):\r\n if n < m:\r\n return 0\r\n return fc[n] // fc[m] // fc[n - m]\r\n\r\n\r\ninp = input('').split(' ')\r\n# inp = [1000, 1.00000]\r\nN, P = int(inp[0]), float(inp[1])\r\n\r\nfor x in range(0, N):\r\n if (2 * bio(x, 3) + 2 *\r\n (N - x) * bio(x, 2) + x * bio(N - x, 2)) / (2 * bio(N, 3)) >= P:\r\n print(x)\r\n break"}, {"source_code": "t=input().split();n=int(t[0]);d=float(t[1]);r,k=0,0\r\nwhile(r n:\r\n return 0\r\n tmp = 1\r\n for i in range(2, k):\r\n tmp *= k\r\n ans = 1\r\n for i in range(k):\r\n ans *= (n - i)\r\n return float(ans) / float(tmp)\r\n\r\nfor i in range(n + 1):\r\n known = i\r\n unknown = n - i\r\n ans = nck(unknown, 2) * nck(known, 1) * 0.5 + nck(unknown, 1) * nck(known, 2) * 1.0 + nck(known, 3) * 1.0\r\n ans /= max(nck(n, 3), 1)\r\n if ans >= p:\r\n print(i)\r\n break\r\n"}, {"source_code": "prob = lambda n, k: (k*(k-1)*(k-2)/6 + k*(k-1)/2*(n-k) + (n-k)*(n-k-1)/2*k/2) / (n*(n-1)*(n-2)/6)\r\nEPS = 1e-8\r\n\r\nN, P = input().split()\r\nN = int(N); P = float(P)\r\n\r\nfor k in range(0,N+1):\r\n p = prob(N, k)\r\n if p+EPS >= P:\r\n print(k)\r\n exit(0)"}, {"source_code": "import math\r\n\r\ndef combin(n, m):\r\n if n == m:\r\n return 1\r\n if n < m:\r\n return 0\r\n\r\n a = 1\r\n for i in range(n, n-m, -1):\r\n a *= i\r\n b = 1\r\n for i in range(1, m+1):\r\n b *= i\r\n\r\n return a / b\r\n\r\n(a, b) = input().split()\r\nn = int(a)\r\np = float(b) * combin(n,3)\r\n\r\nfor i in range(0, n+1):\r\n ans = combin(i, 3) + combin(i, 2) * combin(n-i, 1)\r\n ans += (combin(i, 1)*combin(n-i, 2)) / 2\r\n\r\n if ans >= p:\r\n print(i)\r\n break"}, {"source_code": "import sys\r\n\r\ndef calc_probability(N, K):\r\n M = N - K\r\n a = [\r\n 0,\r\n M * (M - 1) // 2 * K,\r\n M * K * (K - 1) // 2,\r\n K * (K - 1) * (K - 2) // 6,\r\n ]\r\n res = 0\r\n for i in range(1,4):\r\n b = [0] * 3\r\n for j in range(i):\r\n b[j] = 1\r\n p = 0\r\n x = 2\r\n for y in range(3):\r\n if x == y:\r\n p += (i - b[x])/2\r\n else:\r\n p += (i - b[x] - b[y])\r\n res += p / 3 * a[i]\r\n return res / (N * (N - 1) * (N - 2) // 6)\r\n\r\ndef solve():\r\n inp = sys.stdin.readline\r\n N, P = inp().split()\r\n N, P = int(N), int(float(P)*10000+0.5)\r\n r = N\r\n l = -1\r\n while r - l > 1:\r\n c = (l + r) // 2\r\n if calc_probability(N, c) * 10000 >= P:\r\n r = c\r\n else:\r\n l = c\r\n print(r)\r\n\r\ndef main():\r\n solve()\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "from math import *\r\n\r\nprec = [0, 0.5, 1, 1]\r\n\r\ndef prob(known, unknown):\r\n cnt = 0\r\n ret = 0\r\n for i in range(4):\r\n cur = comb(known, i) * comb(unknown, 3 - i)\r\n cnt += cur\r\n ret += cur * prec[i]\r\n return ret / cnt\r\n\r\ninp = input().split()\r\nn = int(inp[0])\r\np = float(inp[1])\r\n\r\nfor i in range(n + 1):\r\n if prob(i, n - i) >= p:\r\n print(i)\r\n break\r\n"}, {"source_code": "import decimal\r\n\r\nn, p = input().split(' ')\r\nn = int(n)\r\np = decimal.Decimal(p)\r\n\r\nans = n - 1\r\nfor k in range(0, n):\r\n p1 = (decimal.Decimal(n-k)*(n-k-1)*k*3) / (n*(n-1)*(n-2)*2)\r\n p2 = (decimal.Decimal(n-k)*k*(k-1)*3) / (n*(n-1)*(n-2))\r\n p3 = (decimal.Decimal(k-1)*(k-2)*k) / (n*(n-1)*(n-2))\r\n\r\n # print(p1, p2, p3, ' - ')\r\n\r\n if p1 + p2 + p3 >= p:\r\n ans = k\r\n break\r\n \r\nprint(ans)"}, {"source_code": "from math import ceil\n\nn, a = [float(v) for v in input().split()]\nexp2 = -9 * n ** 2 + 27 * n - 21\nexp1 = (\n -54 * a * n ** 3\n + 162 * a * n ** 2\n + (\n (\n -54 * a * n ** 3\n + 162 * a * n ** 2\n - 108 * a * n\n + 81 * n ** 2\n - 243 * n\n + 162\n )\n ** 2\n + 4 * exp2 ** 3\n )\n ** 0.5\n - 108 * a * n\n + 81 * n ** 2\n - 243 * n\n + 162\n) ** (1 / 3)\np1 = -((2 ** (1 / 3) * exp2) / (3 * exp1)) + 1 / (3 * 2 ** (1 / 3)) * exp1 + 1\np2 = (\n (complex(1, 3 ** 0.5) * exp2) / (3 * 2 ** (2 / 3) * exp1)\n - 1 / (6 * 2 ** (1 / 3)) * complex(1, -(3 ** (0.5))) * exp1\n + 1\n)\np3 = (\n (complex(1, -(3 ** 0.5)) * exp2) / (3 * 2 ** (2 / 3) * exp1)\n - 1 / (6 * 2 ** (1 / 3)) * complex(1, 3 ** (0.5)) * exp1\n + 1\n)\n# print(min(round(abs(p1)), round(abs(p2)), round(abs(p3))))\np1 = round(abs(p1)) if abs(p1) - int(abs(p1)) < 0.01 else ceil(abs(p1))\np2 = round(abs(p2)) if abs(p2) - int(abs(p2)) < 0.01 else ceil(abs(p2))\np3 = round(abs(p3)) if abs(p3) - int(abs(p3)) < 0.01 else ceil(abs(p3))\n\nprint(min(p1, p2, p3))\n"}, {"source_code": "import math\n\nclass Rational : \n \n def __init__ (self, a, b) :\n a, b = int(a), int(b)\n g = math.gcd(a, b)\n self.a = a / g\n self.b = b / g\n\n def __mul__ (self, t) :\n return Rational(self.a * t.a, self.b * t.b)\n\n def __add__ (self, t) : \n a = self.a * t.b + self.b * t.a\n b = self.b * t.b\n return Rational(a, b) \n\n def __sub__ (self, t) : \n a = self.a * t.b - self.b * t.a\n b = self.b * t.b\n return Rational(a, b) \n \n def __le__ (self, t) : \n return self.a * t.b <= self.b * t.a\n\n def __repr__ (self) :\n return f'{self.a / self.b}' \n\ndef nC3 (n) :\n if n >= 3 : \n return (n * (n - 1) * (n - 2)) // 6\n return 0\n\ndef nC2 (n) :\n if n >= 2 : \n return (n * (n - 1)) // 2\n return 0\n\nstuff = input().split()\nn, p = stuff\nn = int(n)\np = float(p) \np = Rational(1e9 * p, 1e9)\n\none = Rational(1, 1)\nnc3 = nC3(n)\n\nfor k in range(0, n + 1) : \n t = Rational(nC3(k), nc3)\n t = t + (Rational(1, 2) * Rational(k * nC2(n - k), nc3)) \n t = t + Rational((n - k) * nC2(k), nc3)\n if p <= t: \n break\nprint(k)\n"}, {"source_code": "def binom(x,y):\r\n if y == 2:\r\n return x * (x-1) / 2\r\n if y == 3:\r\n return x * (x-1) * (x-2) / 6\r\n\r\nn,prob = map(float,input().split())\r\nif prob == 0.0:\r\n print(0)\r\n exit()\r\n\r\nn = int(n)\r\n\r\ndef p(m):\r\n ans = 0\r\n if n-m >= 2 and m >= 1:\r\n ans += m * (binom(n-m,2)) / 2\r\n\r\n if n-m >= 1 and m >= 2:\r\n ans += m * (m-1) * (n-m) / 2\r\n\r\n if m >= 3:\r\n ans += binom(m,3)\r\n \r\n if ans == binom(n,3):\r\n return 1.0\r\n\r\n return ans / binom(n,3)\r\n\r\nlo,hi = 1.0, float(n)\r\nif p(lo) >= prob:\r\n print(1)\r\n exit()\r\n\r\nwhile lo+1 < hi:\r\n mid = (hi+lo) // 2\r\n case = p(float(mid))\r\n\r\n if case >= prob:\r\n hi = mid\r\n else:\r\n lo = mid\r\n\r\nprint(int(hi))\r\nexit()\r\n"}, {"source_code": "\nn,target = map(float,input().split())\nn = int(n)\n\n\n\ndef getprob(study):\n\n tot = n*(n-1)*(n-2)//6\n case1 = study*(study-1)*(study-2)//6\n case2 = study*(study-1)*(n-study)//2\n case3 = study*(n-study)*(n-study-1)//2\n\n return (case1+case2+case3*0.5)*1.0/tot\n\n\n\nfront = 0\nrear = n\n\n\nwhile front= n * (n - 1) * (n - 2) / 6 * p:\r\n print(k)\r\n break\r\n"}], "negative_code": [{"source_code": "def 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\ndef getP(n,x):\r\n # calculate for all 3 known\r\n if x<3:\r\n p3=0\r\n else:\r\n p3=(x/n)*((x-1)/(n-1))*((x-2)/(n-2))\r\n \r\n # calculate for 2 known\r\n if x<2:\r\n p2=0\r\n else:\r\n p2=3*(x/n)*((x-1)/(n-1))*((n-x)/(n-2))\r\n # discard the unknown\r\n \r\n # calculate for 1 known\r\n if x<1:\r\n p1=0\r\n else:\r\n p1=3*(x/n)*((n-x)/(n-1))*((n-x-1)/(n-2))\r\n \r\n p11=p1*(1/3)*0.5 # opponent picks the same 0 map as Johnny to discard\r\n p12=p1*(1/3) # opponent picks a different 0 map as Johnny to discard\r\n p1=p11+p12\r\n \r\n return p1+p2+p3\r\n\r\n# def getP2(n,x):\r\n# from random import randint\r\n# arr=[0]*(n-x)+[1]*n\r\n# cnts=100000\r\n# succeedCnts=0\r\n# for _ in range(cnts):\r\n# a=b=c=randint(0,n-1)\r\n# while b==a:\r\n# b=randint(0,n-1)\r\n# while c==a or c==b:\r\n# c=randint(0,n-1)\r\n# x=arr[a]+arr[b]+arr[c] # known map\r\n# y=3-x\r\n# if y>0:\r\n# y-=1\r\n# else:\r\n# x-=1\r\n# arr2=[]\r\n# for __ in range(x): arr2.append(1)\r\n# for __ in range(y): arr2.append(0)\r\n# succeedCnts+=arr2[randint(0,1)]\r\n# return succeedCnts/cnts\r\n \r\n\r\ndef main():\r\n \r\n eps=0\r\n \r\n n,p=input().split()\r\n n=int(n)\r\n p=float(p)\r\n \r\n x=0\r\n bb=n\r\n while bb>0:\r\n while x+bb<=n and getP(n,x+bb)+eps0:\r\n y-=1\r\n else:\r\n x-=1\r\n arr2=[]\r\n for __ in range(x): arr2.append(1)\r\n for __ in range(y): arr2.append(0)\r\n succeedCnts+=arr2[randint(0,1)]\r\n return succeedCnts/cnts\r\n \r\n\r\ndef main():\r\n \r\n eps=0\r\n \r\n n,p=input().split()\r\n n=int(n)\r\n p=float(p)\r\n \r\n x=0\r\n bb=n\r\n while bb>0:\r\n while x+bb<=n and getP(n,x+bb)+eps0:\r\n while x+bb<=n and getP(n,x+bb)+eps0:\r\n while x+bb<=n and getP(n,x+bb)+eps= p\r\n\r\nl = 0\r\nr = n-1\r\nwhile l<=r:\r\n m = (l+r)//2\r\n if check(m):\r\n r = m - 1\r\n else:\r\n l = m + 1\r\nprint(l)"}, {"source_code": "n, p = input().split()\r\nn = int(n)\r\np = float(p)\r\n\r\ngt = [1, 1, 2, 6]\r\n\r\ndef C(n, k):\r\n ans = 1\r\n for i in range(n-k+1, n+1):\r\n ans*=i\r\n return ans//gt[k]\r\n\r\n# k la so muon hoc\r\ndef check(k):\r\n t = C(n-k, 3)/C(n, 3)\r\n return (k/n)*t+k/(n-1) >= p\r\n\r\nl = 0\r\nr = n-1\r\nwhile l<=r:\r\n m = (l+r)//2\r\n if check(m):\r\n r = m - 1\r\n else:\r\n l = m + 1\r\nprint(l)"}, {"source_code": "def C(n, k):\r\n if n < k: return 0\r\n if k == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n else:\r\n return n * (n - 1) // 2\r\n\r\n\r\nss = input().split()\r\nn = int(ss[0])\r\ns = ss[1]\r\ns += '0' * (4 - (len(s) - s.find('.') - 1))\r\nif s[0] == '1':\r\n p = 10000\r\nelse:\r\n p = int(s[2:])\r\nfor k in range(n + 1):\r\n cur = C(n - k, 3) * 3 + k * C(n - k, 2)\r\n if 10000 * C(n, 3) * 3 - 10000 * cur >= p * 3 * C(n, 3):\r\n print(k)\r\n break"}, {"source_code": "def C(n, k):\r\n if k == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n else:\r\n return n * (n - 1) // 2\r\n\r\n\r\nss = input().split()\r\nn = int(ss[0])\r\ns = ss[1]\r\ns += '0' * (4 - (len(s) - s.find('.') - 1))\r\nif s[0] == '1':\r\n p = 10000\r\nelse:\r\n p = int(s[2:])\r\nfor k in range(n + 1):\r\n cur = C(n - k, 3) * 3 + k * C(n - k, 2)\r\n if 10000 * C(n, 3) * 3 - 10000 * cur >= p * 3 * C(n, 3):\r\n print(k)\r\n break"}, {"source_code": "def C(n, k):\r\n if k == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n else:\r\n return n * (n - 1) // 2\r\n\r\n\r\nss = input().split()\r\nn = int(ss[0])\r\ns = ss[1]\r\ns += '0' * (4 - (len(s) - s.find('.') - 1))\r\nif s[0] == '1':\r\n p = 1\r\nelse:\r\n p = int(s[2:])\r\nfor k in range(n + 1):\r\n cur = C(n - k, 3) * 3 + k * C(n - k, 2)\r\n if 10000 * C(n, 3) * 3 - 10000 * cur >= p * 3 * C(n, 3):\r\n print(k)\r\n break"}, {"source_code": "def C(n, k):\r\n if k == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n else:\r\n return n * (n - 1) // 2\r\n\r\n\r\nss = input().split()\r\nn = int(ss[0])\r\np = float(ss[1])\r\nfor k in range(n + 1):\r\n cur = C(n - k, 3) * 3 + k * C(n - k, 2)\r\n if C(n, 3) * 3 - cur >= p * 3 * C(n, 3):\r\n print(k)\r\n break"}, {"source_code": "def C(n, k):\r\n if k == 3:\r\n return n * (n - 1) * (n - 2) // 6\r\n else:\r\n return n * (n - 1) // 2\r\n\r\n\r\nss = input().split()\r\nn = int(ss[0])\r\np = float(ss[1])\r\nfor k in range(n + 1):\r\n cur = C(n - k, 3) / C(n, 3) + k * C(n - k, 2) / (3 * C(n, 3))\r\n if 1 - cur >= p:\r\n print(k)\r\n break"}, {"source_code": "import random\r\n\r\ninp = input().split(\" \")\r\nN = int(inp[0])\r\nP = float(inp[1])\r\n\r\ndef sim(N, P, s):\r\n numTrials = 10000\r\n succ = 0\r\n for _ in range(numTrials):\r\n r = [random.randint(1, N)]\r\n for _ in range(2):\r\n n = random.randint(1,N)\r\n while n in r:\r\n n = random.randint(1,N)\r\n r.append(n)\r\n disc = []\r\n for i in range(3):\r\n if r[i] > s:\r\n disc.append(r[i])\r\n break\r\n if len(disc) == 0:\r\n succ += 1\r\n continue\r\n \r\n sd = random.randint(1, 3)\r\n disc.append(r[sd-1])\r\n \r\n fc = []\r\n for i in r:\r\n if not i in disc:\r\n fc.append(i)\r\n \r\n mcidx = random.randint(1, len(fc))\r\n mc = fc[mcidx - 1]\r\n if mc <= s:\r\n succ += 1\r\n \r\n return succ/numTrials\r\n\r\nl = 0\r\nr = N\r\nwhile(l < r):\r\n mid = int((l+r)/2)\r\n if sim(N, P, mid) < P:\r\n l = mid+1\r\n else:\r\n r = mid\r\n\r\nif abs(1 - P) < 1e-3:\r\n print(N-1)\r\nelse:\r\n print(l)"}, {"source_code": "import random\r\n\r\ninp = input().split(\" \")\r\nN = int(inp[0])\r\nP = float(inp[1])\r\n\r\ndef sim(N, P, s):\r\n numTrials = 10000\r\n succ = 0\r\n for _ in range(numTrials):\r\n r = [random.randint(1, N)]\r\n for _ in range(2):\r\n n = random.randint(1,N)\r\n while n in r:\r\n n = random.randint(1,N)\r\n r.append(n)\r\n disc = []\r\n for i in range(3):\r\n if r[i] > s:\r\n disc.append(r[i])\r\n break\r\n if len(disc) == 0:\r\n succ += 1\r\n continue\r\n \r\n sd = random.randint(1, 3)\r\n disc.append(r[sd-1])\r\n \r\n fc = []\r\n for i in r:\r\n if not i in disc:\r\n fc.append(i)\r\n \r\n mcidx = random.randint(1, len(fc))\r\n mc = fc[mcidx - 1]\r\n if mc <= s:\r\n succ += 1\r\n \r\n return succ/numTrials\r\n\r\nl = 0\r\nr = N\r\nwhile(l < r):\r\n mid = int((l+r)/2)\r\n if sim(N, P, mid) < P - 1e-6:\r\n l = mid+1\r\n else:\r\n r = mid\r\n\r\nprint(l)"}, {"source_code": "n, p = input().split()\r\n\r\np = float(p)\r\nn = int(n)\r\n\r\ndef cnk(n, k):\r\n\tif n < k:\r\n\t\treturn 0\r\n\tret = 1\r\n\tif(k == 1):\r\n\t\treturn n\r\n\tif k == 2:\r\n\t\treturn n * (n - 1) // 2\r\n\treturn n * (n - 1) * (n - 2) // 6\r\n\r\nfor i in range(0, n + 1):\r\n\tcur_prob = 0.0\r\n\t\r\n#\tca = i / n * (n - i) / n * (n - i - 1) / n\r\n\tca = cnk(i, 1) * cnk(n - i, 2) / cnk(n, 3)\r\n\tca = ca * 3 / 5\r\n\t\r\n#\tcb = i / n * (i - 1) / n * (n - i) / n\r\n#\tcb = cb / 2\r\n\tcb = cnk(i, 2) * cnk(n - i, 1) / cnk(n, 3)\r\n\tcb = cb\r\n#\tcc = i / n * (i - 1) / n * (i - 2) / n\r\n#\tcb = cb\r\n\tcc = cnk(i, 3) / cnk(n, 3)\r\n\tcur_prob = ca + cb + cc\r\n#\tprint(cur_prob)\r\n\tif(cur_prob >= p):\r\n\t\tprint(i)\r\n\t\tbreak;\r\n"}, {"source_code": "n, p = input().split()\r\n\r\np = float(p)\r\nn = int(n)\r\n\r\ndef cnk(n, k):\r\n\tif n < k:\r\n\t\treturn 0\r\n\tret = 1\r\n\tif(k == 1):\r\n\t\treturn n\r\n\tif k == 2:\r\n\t\treturn n * (n - 1) // 2\r\n\treturn n * (n - 1) * (n - 2) // 6\r\n\r\nfor i in range(0, n + 1):\r\n\tcur_prob = 0.0\r\n\t\r\n#\tca = i / n * (n - i) / n * (n - i - 1) / n\r\n\tca = cnk(i, 1) * cnk(n - i, 2) / cnk(n, 3)\r\n\tca = ca / 3\r\n\t\r\n#\tcb = i / n * (i - 1) / n * (n - i) / n\r\n#\tcb = cb / 2\r\n\tcb = cnk(i, 2) * cnk(n - i, 1) / cnk(n, 3)\r\n\r\n#\tcc = i / n * (i - 1) / n * (i - 2) / n\r\n#\tcb = cb\r\n\tcc = cnk(i, 3) / cnk(n, 3)\r\n\tcur_prob = ca + cb + cc\r\n#\tprint(cur_prob)\r\n\tif(cur_prob >= p):\r\n\t\tprint(i)\r\n\t\tbreak;\r\n"}, {"source_code": "n, p = input().split()\r\n\r\np = float(p)\r\nn = int(n)\r\n\r\ndef cnk(n, k):\r\n\tif n < k:\r\n\t\treturn 0\r\n\tret = 1\r\n\tfor i in range(k + 1, n + 1):\r\n\t\tret *= i\r\n\tfor i in range(1, n - k + 2):\r\n\t\tret = ret // i\r\n\treturn ret\r\nfor i in range(1, n + 1):\r\n\tcur_prob = 0.0\r\n\t\r\n#\tca = i / n * (n - i) / n * (n - i - 1) / n\r\n\tca = cnk(i, 1) * cnk(n - i, 2) / cnk(n, 3)\r\n\tca = ca / 3\r\n\t\r\n#\tcb = i / n * (i - 1) / n * (n - i) / n\r\n#\tcb = cb / 2\r\n\tcb = cnk(i, 2) * cnk(n - i, 1) / cnk(n, 3)\r\n\r\n#\tcc = i / n * (i - 1) / n * (i - 2) / n\r\n#\tcb = cb\r\n\tcc = cnk(i, 3) / cnk(n, 3)\r\n\tcur_prob = ca + cb + cc\r\n#\tprint(cur_prob)\r\n\tif(cur_prob >= p):\r\n\t\tprint(i)\r\n\t\tbreak;\r\n"}, {"source_code": "#-------------------------------------------------------------------------------\r\n# Name: module1\r\n# Purpose:\r\n#\r\n# Author: asawe\r\n#\r\n# Created: 03/08/2022\r\n# Copyright: (c) asawe 2022\r\n# Licence: \r\n#-------------------------------------------------------------------------------\r\n\r\nimport sys\r\n\r\n#sys.stdin = open(\"C:\\\\Users\\\\asawe\\\\Documents\\\\input.txt\",\"r\")\r\n\r\nn,p = map(float,sys.stdin.readline().split())\r\na = []\r\nfor i in range(int(n)):\r\n b = i * (i-1) * (i-2) / n / (n-1) / (n-2)\r\n c = 3 * i * (i-1) * (n-i) / n / (n-1) / (n-2)\r\n d = 3/2 * i * (n-i-1) * (n-i) / n / (n-1) / (n-2)\r\n if b + c + d > p:\r\n print(i)\r\n break"}, {"source_code": "#-------------------------------------------------------------------------------\r\n# Name: module1\r\n# Purpose:\r\n#\r\n# Author: asawe\r\n#\r\n# Created: 03/08/2022\r\n# Copyright: (c) asawe 2022\r\n# Licence: \r\n#-------------------------------------------------------------------------------\r\n\r\nimport sys\r\n\r\n#sys.stdin = open(\"C:\\\\Users\\\\asawe\\\\Documents\\\\input.txt\",\"r\")\r\n\r\nn,p = map(float,sys.stdin.readline().split())\r\na = []\r\nfor i in range(int(n)):\r\n b = i * (i-1) * (i-2) / n / (n-1) / (n-2)\r\n c = 3 * i * (i-1) * (n-i) / n / (n-1) / (n-2)\r\n d = 3/2 * i * (n-i-1) * (n-i) / n / (n-1) / (n-2)\r\n a.append(b+c+d)\r\nfor i in range(int(n)):\r\n a[i] = abs(a[i]-p)\r\n\r\nprint(a.index(min(a)))"}, {"source_code": "#-------------------------------------------------------------------------------\r\n# Name: module1\r\n# Purpose:\r\n#\r\n# Author: asawe\r\n#\r\n# Created: 03/08/2022\r\n# Copyright: (c) asawe 2022\r\n# Licence: \r\n#-------------------------------------------------------------------------------\r\n\r\nimport sys\r\n\r\n#sys.stdin = open(\"C:\\\\Users\\\\asawe\\\\Documents\\\\input.txt\",\"r\")\r\n\r\nn,p = map(float,sys.stdin.readline().split())\r\na = []\r\nfor i in range(int(n)):\r\n b = i * (i-1) * (i-2) / n / (n-1) / (n-2)\r\n c = 3 * i * (i-1) * (n-i) / n / (n-1) / (n-2)\r\n d = i * (n-i-1) * (n-i) / n / (n-1) / (n-2)\r\n a.append(b+c+d)\r\nfor i in range(int(n)):\r\n a[i] = abs(a[i]-p)\r\n\r\nprint(a.index(min(a)))"}, {"source_code": "n, p = map(float, input().split())\r\nans, n = 0, int(n)\r\nall, be, en = n * (n - 1) * (n - 2) // 6, 0, n - 1\r\n\r\nwhile be < en:\r\n i = (be + en) >> 1\r\n deln, newp = n - i, 0\r\n if i > 2:\r\n newp += i * (i - 1) * (i - 2) // 6\r\n if i > 1:\r\n newp += deln * i * (i - 1) // 2\r\n if deln > 1:\r\n newp += deln * (deln - 1) * i / 4\r\n\r\n if newp / all >= p:\r\n ans, en = i, i - 1\r\n else:\r\n be = i + 1\r\nprint(ans)\r\n"}, {"source_code": "n, p = map(float, input().split())\r\nans, n = 1, int(n)\r\nall = n * (n - 1) * (n - 2) // 6\r\n\r\nfor i in range(1, n):\r\n deln, newp = n - i, 0\r\n if i > 2:\r\n newp += i * (i - 1) * (i - 2) // 6\r\n if i > 1:\r\n newp += deln * i * (i - 1) // 2\r\n if deln > 1:\r\n newp += deln * (deln - 1) * i / 4\r\n\r\n if newp / all >= p:\r\n break\r\n ans += 1\r\n\r\nprint(ans)\r\n"}, {"source_code": "def prob(db, n):\r\n return db*(db-1)*(db-2)+(n-db)*db*(db-1)*3+(n-db)*(n-db-1)*db*3/2\r\n\r\nn, p = input().split()\r\nn = int(n)\r\np = float(p)\r\np *= n*(n-1)*(n-2)\r\n\r\n\r\ns = 0\r\ne = n-1\r\nwhile s <= e:\r\n act = (s+e)//2\r\n if e-s == 1:\r\n if prob(s, n) >= p:\r\n break\r\n else:\r\n s = e\r\n break\r\n else:\r\n if prob(act, n) == p:\r\n e = act\r\n else:\r\n s = act\r\n\r\n \r\nprint(s)\r\n "}, {"source_code": "lijst = input().split()\r\nn = int (lijst[0])\r\nd = float (lijst[1])\r\n\r\nkans = 0\r\nk = -1\r\nwhile (kans = N * p * 2:\n print(i)\n break\n"}, {"source_code": "from decimal import Decimal\nn, p = input().split()\nn = int(n)\np = Decimal(p)\nN = n * (n - 1) * (n - 2) // 6\n\ndef f(m):\n if m == n:\n return N\n A3 = m * (m - 1) * (m - 2) // 6\n A2 = m * (m - 1) * (n - m) // 2\n A1 = m * (n - m) * (n - m - 1) // 2\n return (A1 + A2 * 2 + A3 * 2)\n\nfor i in range(1, n+1):\n if f(i) >= N * p * 2:\n print(i)\n break\n"}, {"source_code": "from decimal import Decimal\nn, p = input().split()\nn = int(n)\np = Decimal(p)\n\ndef f(m):\n if m == n:\n return 1\n N = n * (n - 1) * (n - 2) / Decimal(6)\n A3 = m * (m - 1) * (m - 2) / Decimal(6)\n A2 = m * (m - 1) * (n - m) / Decimal(2)\n A1 = m * (n - m) * (n - m - 1) / Decimal(2)\n return (A1 + A2 * 2 + A3 * 2), N\n\nfor i in range(1, n+1):\n a, N = f(i)\n if a >= N * p * 2:\n print(i)\n break\n"}, {"source_code": "n, p = input().split()\nn = int(n)\np = float(p)\n\ndef f(m):\n if m == n:\n return 1\n N = n * (n - 1) * (n - 2) / 6\n A3 = m * (m - 1) * (m - 2) / 6\n A2 = m * (m - 1) * (n - m) / 2\n A1 = m * (n - m) * (n - m - 1) / 2\n return (A1 / 2 + A2 + A3) / N\n\nfor i in range(1, n+1):\n if f(i) >= p:\n print(i)\n break\n"}, {"source_code": "from math import factorial\r\n\r\n\r\ndef binomial(n, k):\r\n if n < k:\r\n return 0\r\n return factorial(n)/(factorial(k) * factorial(n - k))\r\n\r\nn, p = list(input().split())\r\n\r\nn = int(n)\r\np = float(p)\r\n\r\nl, r = 0, n\r\n\r\nwhile l < r:\r\n k = (l + r)//2\r\n cur = binomial(k, 3)/binomial(n, 3) + binomial(k, 2)/binomial(n, 3) + k * binomial(n - k, 2)/binomial(n, 3)*(1/6 + 1/3)\r\n if cur < p:\r\n l = k + 1\r\n else:\r\n r = k\r\n\r\nprint(l)\r\n"}, {"source_code": "from math import factorial\r\n\r\n\r\ndef binomial(n, k):\r\n if n < k:\r\n return 0\r\n return factorial(n)/(factorial(k) * factorial(n - k))\r\n\r\nn, p = list(input().split())\r\n\r\nn = int(n)\r\np = float(p)\r\nans = n\r\n\r\nfor k in range(1, n):\r\n cur = binomial(k, 3)/binomial(n, 3) + binomial(k, 2)/binomial(n, 3) + k * binomial(n - k, 2)/binomial(n, 3)*(1/6 + 1/3)\r\n if(cur >= p):\r\n ans = k\r\n break\r\n\r\nprint(ans)\r\n"}, {"source_code": "import math\nimport random\nimport sys\n\ndef main(n,p):\n tot=9*(math.comb(n,3))\n for i in range(0,n):\n b=0\n b+=2*math.comb(n-i,2)*2*i\n\n b+=9*math.comb(n-i,3);\n if (1-b/tot)>=p:\n return i\n return \"WHAT\" \n\nn,p=list(map(float,input().split()))\nn=int(n) \nprint(main(n,p))\n \n"}, {"source_code": "import math\nimport random\nimport sys\n\ndef main(n,p):\n tot=math.comb(n,3)*9;\n for i in range(0,n):\n b=0;\n b+=2*math.comb(n-i,2)*2\n\n b+=9*math.comb(n-i,3);\n if (1-b/tot)>=p:\n return i\n return \"WHAT\" \n\nn,p=list(map(float,input().split()))\nn=int(n) \nprint(main(n,p))\n \n"}, {"source_code": "import math\r\n\r\ndef probCalc(studied, numMaps):\r\n total = math.comb(numMaps, 3)\r\n return (math.comb(studied, 3) + math.comb(studied, 2)*math.comb(numMaps - studied, 1) + 1/3*math.comb(studied, 1) * math.comb(numMaps - studied, 2))/total\r\n\r\n\r\n\r\n[n,p] = input().split(' ')\r\nn = int(n); p = float(p);\r\nfor i in range(n):\r\n if probCalc(i, n) >= p:\r\n print(i)\r\n break"}, {"source_code": "n, a = [float(v) for v in input().split()]\nexp2 = -9 * n ** 2 + 27 * n - 21\nexp1 = (\n -54 * a * n ** 3\n + 162 * a * n ** 2\n + (\n (\n -54 * a * n ** 3\n + 162 * a * n ** 2\n - 108 * a * n\n + 81 * n ** 2\n - 243 * n\n + 162\n )\n ** 2\n + 4 * exp2 ** 3\n )\n ** 0.5\n - 108 * a * n\n + 81 * n ** 2\n - 243 * n\n + 162\n) ** (1 / 3)\np1 = -((2 ** (1 / 3) * exp2) / (3 * exp1)) + 1 / (3 * 2 ** (1 / 3)) * exp1 + 1\np2 = (\n (complex(1, 3 ** 0.5) * exp2) / (3 * 2 ** (2 / 3) * exp1)\n - 1 / (6 * 2 ** (1 / 3)) * complex(1, -(3 ** (0.5))) * exp1\n + 1\n)\np3 = (\n (complex(1, -(3 ** 0.5)) * exp2) / (3 * 2 ** (2 / 3) * exp1)\n - 1 / (6 * 2 ** (1 / 3)) * complex(1, 3 ** (0.5)) * exp1\n + 1\n)\nprint(min(round(abs(p1)), round(abs(p2)), round(abs(p3))))\n"}, {"source_code": "n, a = [float(v) for v in input().split()]\nexp2 = -9 * n ** 2 + 45 * n - 57\nexp1 = (\n 108 * a * n ** 3\n - 324 * a * n ** 2\n + (\n (\n 108 * a * n ** 3\n - 324 * a * n ** 2\n + 216 * a * n\n - 54 * n ** 3\n - 81 * n ** 2\n + 783 * n\n - 810\n )\n ** 2\n + 4 * exp2 ** 3\n )\n ** 0.5\n + 216 * a * n\n - 54 * n ** 3\n - 81 * n ** 2\n + 783 * n\n - 810\n) ** (1 / 3)\np1 = round(\n abs(1 / (3 * 2 ** (1 / 3)) * exp1 - (2 ** (1 / 3) * exp2) / (3 * exp1) + 2 * n - 3)\n)\np2 = round(\n abs(\n -1 / (6 * 2 ** (1 / 3)) * complex(1, 3 ** 0.5) * exp1\n + complex(1, -(3 ** 0.5)) * exp2 / (3 * 2 ** (2 / 3) * exp1)\n + 2 * n\n - 3\n )\n)\np3 = round(\n abs(\n -1 / (6 * 2 ** (1 / 3)) * complex(1, -(3 ** 0.5)) * exp1\n + complex(1, (3 ** 0.5)) * exp2 / (3 * 2 ** (2 / 3) * exp1)\n + 2 * n\n - 3\n )\n)\nprint(min(p1, p2, p3))\n"}, {"source_code": "import math\n\nclass Rational : \n \n def __init__ (self, a, b) :\n a, b = int(a), int(b)\n g = math.gcd(a, b)\n self.a = a / g\n self.b = b / g\n\n def __mul__ (self, t) :\n return Rational(self.a * t.a, self.b * t.b)\n\n def __add__ (self, t) : \n a = self.a * t.b + self.b * t.a\n b = self.b * t.b\n return Rational(a, b) \n\n def __sub__ (self, t) : \n a = self.a * t.b - self.b * t.a\n b = self.b * t.b\n return Rational(a, b) \n \n def __le__ (self, t) : \n return self.a * t.b <= self.b * t.a\n\n def __repr__ (self) :\n return f'{self.a / self.b}' \n\ndef nC3 (n) :\n if n >= 3 : \n return (n * (n - 1) * (n - 2)) // 6\n return 0\n\ndef nC2 (n) :\n if n >= 2 : \n return (n * (n - 1)) // 2\n return 0\n\nstuff = input().split()\nn, p = stuff\nn = int(n)\np = float(p) \np = Rational(1e9 * p, 1e9)\n\none = Rational(1, 1)\nnc3 = nC3(n)\n\nfor k in range(0, n + 1) : \n t = Rational(nC3(k), nc3)\n if k > 0 : \n t = t + (Rational(1, 3) * Rational(nC2(n - k), nc3)) \n if n - k > 0 :\n t = t + Rational(nC2(k), nc3)\n if p <= t: \n break\nprint(k)\n"}, {"source_code": "import math\n\nclass Rational : \n \n def __init__ (self, a, b) :\n a, b = int(a), int(b)\n g = math.gcd(a, b)\n self.a = a / g\n self.b = b / g\n\n def __mul__ (self, t) :\n return Rational(self.a * t.a, self.b * t.b)\n\n def __add__ (self, t) : \n a = self.a * t.b + self.b * t.a\n b = self.b * t.b\n return Rational(a, b) \n\n def __sub__ (self, t) : \n a = self.a * t.b - self.b * t.a\n b = self.b * t.b\n return Rational(a, b) \n \n def __le__ (self, t) : \n return self.a * t.b <= self.b * t.a\n\n def __repr__ (self) :\n return f'{self.a / self.b}' \n\ndef nC3 (n) :\n if n >= 3 : \n return (n * (n - 1) * (n - 2)) // 6\n return 0\n\ndef nC2 (n) :\n if n >= 2 : \n return (n * (n - 1)) // 2\n return 0\n\nstuff = input().split()\nn, p = stuff\nn = int(n)\np = float(p) \np = Rational(1e9 * p, 1e9)\n\none = Rational(1, 1)\nnc3 = nC3(n)\n\nfor k in range(0, n + 1) : \n t = Rational(nC3(k), nc3) + (Rational(1, 3) * Rational(nC2(n - k), nc3)) + Rational(nC2(k), nc3)\n if p <= t: \n break\nprint(k)\n"}, {"source_code": "def binom(x,y):\r\n if y == 2:\r\n return x * (x-1) / 2\r\n if y == 3:\r\n return x * (x-1) * (x-2) / 6\r\n\r\nn,prob = map(float,input().split())\r\nif prob == 0.0:\r\n print(0)\r\n exit()\r\n\r\nn = int(n)\r\n\r\ndef p(m):\r\n ans = 0\r\n if n-m >= 2 and m >= 1:\r\n ans += m * (binom(n-m,2)) * .75\r\n\r\n if n-m >= 1 and m >= 2:\r\n ans += m * (m-1) * (n-m) / 2\r\n\r\n if m >= 3:\r\n ans += binom(m,3)\r\n \r\n if ans == binom(n,3):\r\n return 1.0\r\n\r\n return ans / binom(n,3)\r\n\r\nlo,hi = 1.0, float(n)\r\nif p(lo) >= prob:\r\n print(1)\r\n exit()\r\n\r\nwhile lo+1 < hi:\r\n mid = (hi+lo) // 2\r\n case = p(float(mid))\r\n\r\n if case >= prob:\r\n hi = mid\r\n else:\r\n lo = mid\r\n\r\nprint(int(hi))\r\nexit()\r\n"}, {"source_code": "def binom(x,y):\r\n if y == 2:\r\n return x * (x-1) / 2\r\n if y == 3:\r\n return x * (x-1) * (x-2) / 6\r\n\r\nn,prob = map(float,input().split())\r\nn = int(n)\r\n\r\ndef p(m):\r\n ans = 0\r\n if n-m >= 2 and m >= 1:\r\n ans += m * (binom(n-m,2)) * .75\r\n\r\n if n-m >= 1 and m >= 2:\r\n ans += m * (m-1) * (n-m) / 2\r\n\r\n if m >= 3:\r\n ans += binom(m,3)\r\n \r\n if ans == binom(n,3):\r\n return 1.0\r\n\r\n return ans / binom(n,3)\r\n\r\nlo,hi = 1.0, float(n)\r\nif p(lo) >= prob:\r\n print(1)\r\n exit()\r\n\r\nwhile lo+1 < hi:\r\n mid = (hi+lo) // 2\r\n case = p(float(mid))\r\n\r\n if case >= prob:\r\n hi = mid\r\n else:\r\n lo = mid\r\n\r\nprint(int(hi))\r\nexit()\r\n"}, {"source_code": "\nn,target = map(float,input().split())\nn = int(n)\n\n\n\ndef getprob(study):\n\n tot = n*(n-1)*(n-2)//6\n case1 = study*(study-1)*(study-2)//6\n case2 = study*(study-1)//2 *(n-study)\n\n\n return (case1+case2)*1.0/tot\n\n\n\nfront = 0\nrear = n\n\n\nwhile front= 0 and r*1.0/1234 == int(r*1.0/1234)):\n return \"YES\"\n return \"NO\"\n\nprint linComb(n)\n\n \n"}, {"source_code": "n = int(input())\nx = 1234567\ny = 123456\nz = 1234\nfor i in range(0, n):\n\tif i * x > n:\n\t\tbreak\n\tm = n - x * i\n\tfor j in range(0, n):\n\t\tif j * y > m:\n\t\t\tbreak\n\t\tl = m - y * j\n\t\tif l % 1234 == 0:\n\t\t\tprint(\"YES\")\n\t\t\texit(0)\nprint(\"NO\")\n"}, {"source_code": "n = int(input())\n\nfor a in range(0, n+1, 1234567):\n for b in range(0, n-a+1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n"}, {"source_code": "n = int(input())\nf = True\nfor a in range(0, n + 1, 1234567):\n for b in range(0, n - a + 1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n f = False\n break\n if not f:\n break\nif f:\n print(\"NO\")"}, {"source_code": "n = int(input())\na = 0\nok = True\n\nwhile n - 1234567 * a >= 0 and ok:\n b = 0\n\n while n - 1234567 * a - 123456 * b >= 0 and ok:\n if (n - 1234567 * a - 123456 * b) % 1234 == 0:\n ok = False\n b += 1\n a += 1\n\nif ok:\n print('NO')\nelse:\n print(\"YES\")\n"}, {"source_code": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\nMAX1=820\nMAX2=8200\nMAX3=810472\n\na1=1234567\na2=123456\na3=1234\nn=input()\nres=0\nfor i in range(MAX1):\n for j in range(MAX2):\n cur = i*a1 + j*a2\n rem = n-cur\n if rem < 0:\n break\n if rem % a3 == 0:\n# print i,j,rem//a3\n res=1\n break\nif res==1:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n = int(raw_input())\nfor a in range(n / 1234567 + 1):\n for b in range((n - a * 1234567) / 123456 + 1):\n if (n - a * 1234567 - b * 123456) % 1234 == 0:\n print 'YES'\n exit()\nprint 'NO'"}, {"source_code": "n=int(raw_input())\nfor i in range(0,n/1234567+1):\n for j in range(0,n/123456+1):\n if (n-1234567*i-123456*j)%1234==0 and (n-1234567*i-123456*j)>=0:\n print \"YES\"\n exit(0)\nprint \"NO\"\n\n\n\n\n"}, {"source_code": "#!/usr/bin/python\n\nfrom math import *\nimport sys\n\ndef Ni(): return tuple(map(int, raw_input().split()))\n\n# https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm#Iterative_algorithm\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\nn = Ni()[0]\nA = 1234567\nB = 123456\nC = 1234\ng, x, y = xgcd(B, C)\nassert (g, x, y) == (2, -22, 2201)\n\na = 0\nwhile A * a <= n:\n # is A * a + B * b + C * c == n ?\n # solve B * b + C * c == n - A * a\n r = n - A * a\n if r % g != 0:\n a += 1\n continue\n \n k = r / g \n b0, c0 = x * k, y * k\n assert A * a + B * b0 + C * c0 == n\n\n #print \"sol\", b0, c0\n # b0 + m * C/g >= 0\n # b0 < 0\n # C/g > 0\n # m * C/g >= -b0\n # m >= -b0 * g / C\n m = (-b0 * g + C - 1) / C\n bm, cm = b0 + m * C/g, c0 - m * B/g\n assert A * a + B * bm + C * cm == n\n if bm >= 0 and cm >= 0:\n print \"YES\"\n print >>sys.stderr, a, bm, cm\n sys.exit(0)\n\n # print m, bm, cm\n a += 1\n\nprint \"NO\"\n"}, {"source_code": "n = int(input())\nfor a in range(2000):\n for b in range((n-1234567*a)//123456+50):\n rem = n - 1234567*a - 123456 * b\n if (rem%1234 == 0 and rem//1234 >= 0):\n print(\"YES\")\n quit()\nprint(\"NO\")\n"}, {"source_code": "n = int(input())\nfor i in range(n // 1234567 + 1):\n for j in range(n // 123456 + 1):\n if n >= 1234567 * i + 123456 * j and (n - (1234567 * i + 123456 * j)) % 1234 == 0:\n print(\"YES\")\n exit()\nprint(\"NO\")\n"}, {"source_code": "n = int(input())\n\nfor a in range(0, n+1, 1234567):\n for b in range(0, n-a+1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n"}, {"source_code": "n = int(input())\nfor a in range(0,n+1,1234567):\n for b in range(0,n-a+1,123456):\n if (n-a-b) % 1234 == 0:\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "import sys #exit \u7684\u5934\u6587\u4ef6\nimport math\na=int(input())\nfor i in range(0, a // 1234567 +1): \n for j in range (0, (a-i*1234567) // 123456 +1): \n if (a-i*1234567-j*123456) % 1234==0:\n print(\"YES\")\n sys.exit(0) #\u76f4\u63a5\u7ed3\u675f\u8fd0\u884c\nprint(\"NO\") #\u5982\u679c\u6709\u53ef\u884c\u60c5\u51b5,\u5df2\u7ecf\u8f93\u51fa\u5e76\u7ed3\u675f\u4e86\n"}, {"source_code": "import sys\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\ndef tryy(n):\n BASE_a = 1234567\n BASE_b = 123456\n BASE_c = 1234\n a_coef = 0\n while a_coef * BASE_a <= n:\n b_coef = 0\n while a_coef * BASE_a + b_coef * BASE_b <= n:\n if (n - (a_coef * BASE_a + b_coef * BASE_b)) % BASE_c == 0:\n return \"YES\"\n b_coef += 1\n a_coef += 1\n return \"NO\"\n\nif __name__ == \"__main__\":\n n = int(sys.stdin.readline().strip())\n print tryy(n)\n"}, {"source_code": "a = int(raw_input())\nfor i in range(811):\n\tfor j in range(8101):\n\t\tm = a-(i * 1234567 + j*123456)\n\t\tif m<0:\n\t\t\tbreak\n\t\tif m%1234==0:\n\t\t\tprint 'YES'\n\t\t\texit()\nprint 'NO'\n"}, {"source_code": "from math import fmod\nn=int(input())\nyes=False\nfor i in xrange((n/1234567)+1) :\n\tfor j in xrange(((n-i*1234567)/123456)+1):\n\t\tx=(n-i*1234567-j*123456)/1234.0\n\t\t\n\t\tif fmod(x,1.0)==0.0:\n\t\t\tyes=True\n\t\t\t#print \"i:\",i,\"j:\",j,\"x:\",x, \"res=\", i*1234567+j*123456+int(x)*1234\n\t\t\tbreak\n\tif yes :\n\t\tbreak\n\nif yes :\n\tprint \"YES\"\nelse :\n\tprint \"NO\""}, {"source_code": "n = int(raw_input())\n\ndef linComb(n):\n for x in range(n/1234567+1):\n for y in range((n-1234567*x)/123456+1):\n r = n - 1234567*x - 123456*y\n if (r >= 0 and r*1.0/1234 == int(r*1.0/1234)):\n return \"YES\"\n return \"NO\"\n\nprint linComb(n)\n\n \n"}, {"source_code": "n = int(input())\n\nii = n // 1234567\n\nfor i in range(ii+1):\n\tfor j in range((n-i*1234567)//123456+1):\n\t\tif (n-i*1234567-j*123456) % 1234 == 0:\n\t\t\tprint('YES')\n\t\t\texit()\n\t\t\t\nprint('NO')"}, {"source_code": "__author__ = 'aste'\n\n\ndef solve(n):\n max_a = n//1234567\n a = 0\n while a <= max_a:\n b = 0\n max_b = (n - 1234567*a)//123456\n while b <= max_b:\n c = n - 1234567*a - 123456*b\n if c >= 0 and c%1234 == 0:\n return True\n b += 1\n a += 1\n return False\n\n\ndef main():\n n = int(input())\n print(solve(n) and \"YES\" or \"NO\")\n\n\nmain()"}, {"source_code": "n = int(raw_input())\n\na = 1234567\nb = 123456\nc = 1234\n\ni = 0\nj = 0\n\nflag = (n % c == 0 or n % a == 0 or n % b == 0)\nwhile True:\n\n j = 0\n if i*a > n or flag: break\n while True:\n if i*a + j*b > n or flag: break\n if (n - (i*a + j*b)) % c == 0:\n flag = True\n break\n j += 1\n i += 1\n\nif flag: print \"YES\"\nelse: print \"NO\"\n"}, {"source_code": "import os,sys,itertools,math,collections,string\ndef main():\n\tn=int(sys.stdin.readline())\n\tfor a in xrange(n/1234567+1):\n\t\tx=n-a*1234567\n\t\tfor b in xrange(x/123456+1):\n\t\t\ty = x-b*123456\n\t\t\tif y%1234==0:\n\t\t\t\tprint 'YES'\n\t\t\t\treturn\n\tprint 'NO'\nmain()"}, {"source_code": "\nimport sys\ntt = int(raw_input())\nfor i in xrange(0, tt+1, 1234567):\n for j in xrange(0, tt - i + 1, 123456):\n if (tt - i - j) % 1234 == 0:\n print 'YES'\n sys.exit()\n\nprint 'NO'\nsys.exit()"}, {"source_code": "def do2():\n\tn = int(input())\n\n\thouse_price = 1234567\n\tcar_price = 123456\n\tpc_price = 1234\n\n\tfor i in range(0, n // house_price + 1):\n\t\ta = i * house_price\n\t\tfor j in range(0, n // car_price + 1):\n\t\t\tb = j * car_price\n\t\t\tif (n - a - b) % pc_price == 0 and n - a - b >= 0:\n\t\t\t\tprint('YES')\n\t\t\t\treturn\n\n\tprint('NO')\n\treturn\n\ndo2()"}, {"source_code": "w = int(input())\nhouse = 1234567\ncar = 123456\ncomp = 1234\nq = False\nb = 0\nc = 0\n\nwhile c <= w//comp and q == False and w >= comp and (w - c*comp - b*car) >= 0:\n while b <= w//car and q == False and w >= car:\n if (w - c*comp - b*car)%house == 0 and (w - c*comp - b*car) >= 0:\n q = True\n break\n b += 1\n if (w - c*comp - b*car)%house == 0 and (w - c*comp - b*car) >= 0 and (w - c*comp - b*car) >= 0:\n q = True\n break\n c += 1\n b = 0\nif q == True:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\na=0\nc=0\nwhile a*1234567<=n :\n b=0\n v=a*1234567\n while a*1234567+b*123456<=n :\n if (n-v-b*123456)%1234==0 :\n print('YES')\n c=1\n break\n b=b+1\n a=a+1\n if c==1 :\n break\nif c==0 :\n print('NO')\nl=0\n"}, {"source_code": "import math\n\ndef find(x):\n for i in range(1000):\n for j in range(1000):\n value = (x - j*123456 - i*1234567) / 1234\n \n if(value >= 0 and value - math.floor(value) == 0):\n print(\"YES\")\n return\n \n print(\"NO\")\n \nfind(int(input()))"}, {"source_code": "n = int(raw_input())\n\ndef linComb(n):\n for x in range(n/1234567+1):\n for y in range((n-1234567*x)/123456+1):\n r = n - 1234567*x - 123456*y\n if (r >= 0 and r*1.0/1234 == int(r*1.0/1234)):\n return \"YES\"\n return \"NO\"\n\nprint linComb(n)\n\n \n"}, {"source_code": "import sys\nn = int(input())\ni = 0\nwhile n - i*1234567 >= 0:\n z = n - i*1234567\n j = 0\n while z - j*123456 >= 0:\n k = (z - j*123456)\n if k % 1234 == 0:\n print('YES')\n sys.exit()\n j += 1\n \n i += 1\nprint('NO')\n"}, {"source_code": "f = 1234567\ns = 123456\nt = 1234\n\nn = input()\nflag = 0\nfor i in xrange(1000):\n\tif flag:\n\t\tbreak\n\trem = n - f*i\n\tj = 0\n\twhile(j*s <= rem):\n\t\tif (rem - j*s)% t == 0:\n\t\t\tflag = 1\n\t\t\tbreak\n\t\tj += 1\n\nif flag:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "n = int(input())\na = n // 1234567\nresults = \"NO\"\nfor x in range(a + 1):\n p = n - 1234567 * x\n b = p // 123456\n for y in range(b + 1):\n q = p - 123456 * y\n if q % 1234 == 0:\n results = \"YES\"\n break\n if results == \"YES\":\n break\nprint(results)"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-05-29 10:36\n# @url:https://codeforc.es/problemset/problem/681/B\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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 for i in range(0,n//1234567+1):\n for j in range(0,(n-i*1234567)//123456+1):\n t=n-i*1234567-j*123456\n # print (t)\n if t%1234==0:\n print (\"YES\")\n return\n print (\"NO\")\nif __name__ == \"__main__\":\n main()"}, {"source_code": "N = int(raw_input())\n\nFlag = False\nwhile N >= 0:\n P = 0\n while P <= N:\n if (N - P) % 1234 == 0:\n Flag = True\n \n P += 123456\n N -= 1234567\n\nif Flag == True: print \"YES\"\nelse: print \"NO\""}, {"source_code": "\nif __name__ == \"__main__\":\n n = input()\n res = False\n for i in range(n / 1234567 + 1):\n n1 = n - i * 1234567\n for j in range(n1 / 123456 + 1):\n n2 = n1 - j * 123456\n if n2 % 1234 == 0:\n res = True\n\n if res:\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "n = int(input())\nfor a in range(0,n+1,1234567):\n for b in range(0,n-a+1,123456):\n if (n-a-b) % 1234 == 0:\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "#!/usr/bin/python\n\nfrom math import *\nimport sys\n\ndef Ni(): return tuple(map(int, raw_input().split()))\n\n# https://en.wikibooks.org/wiki/Algorithm_Implementation/Mathematics/Extended_Euclidean_algorithm#Iterative_algorithm\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\nn = Ni()[0]\nA = 1234567\nB = 123456\nC = 1234\ng, x, y = xgcd(B, C)\nassert (g, x, y) == (2, -22, 2201)\n\na = 0\nwhile A * a <= n:\n # is A * a + B * b + C * c == n ?\n # solve B * b + C * c == n - A * a\n r = n - A * a\n if r % g != 0:\n a += 1\n continue\n \n k = r / g \n b0, c0 = x * k, y * k\n assert A * a + B * b0 + C * c0 == n\n\n #print \"sol\", b0, c0\n # b0 + m * C/g >= 0\n # b0 < 0\n # C/g > 0\n # m * C/g >= -b0\n # m >= -b0 * g / C\n m = (-b0 * g + C - 1) / C\n bm, cm = b0 + m * C/g, c0 - m * B/g\n assert A * a + B * bm + C * cm == n\n if bm >= 0 and cm >= 0:\n print \"YES\"\n print >>sys.stderr, a, bm, cm\n sys.exit(0)\n\n # print m, bm, cm\n a += 1\n\nprint \"NO\"\n"}, {"source_code": "n= int(raw_input())\ny = 0\nfor i in range(0,(n/1234567)+1):\n\tfor j in range(0,((n-i*1234567)/123456)+1):\n\t\tm= n - 1234567*i - j*123456\n\t\tif(m%1234 ==0):\n\t\t\ty=1\n\t\t\tbreak\nif y==1:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "from fractions import gcd\nn = input()\nx = 1234567\ny = 123456\nz = 1234\nyz = gcd(y,z)\nans =\"NO\"\nini = 0\nwhile((n-ini)>=0 and ans==\"NO\"):\n rem = n -ini\n if(rem%yz!=0):\n ini+=x\n else:\n temp = 0\n while((rem-temp)>=0):\n if((rem-temp)%z==0):\n ans = \"YES\"\n break\n temp+=y\n ini+=x\nprint ans\n"}, {"source_code": "a = int(raw_input())\nfor i in range(811):\n\tfor j in range(8101):\n\t\tm = a-(i * 1234567 + j*123456)\n\t\tif m<0:\n\t\t\tbreak\n\t\tif m%1234==0:\n\t\t\tprint 'YES'\n\t\t\texit()\nprint 'NO'\n"}, {"source_code": "def readval(typ=int):\n return typ( raw_input() )\n\ndef readvals(typ=int):\n return map( typ, raw_input().split() )\n\ndef testcase():\n n = readval()\n for a in xrange(n/1234567+1):\n for b in xrange((n-a*1234567)/123456+1):\n rest = n-a*1234567-b*123456\n if rest%1234==0: \n print 'YES'\n return\n print 'NO'\n \nif __name__=='__main__':\n testcase()\n"}, {"source_code": "n = int(input())\nfor a in range(0, n+1, 1234567):\n\tfor b in range(0, n-a+1, 123456):\n\t\tif (n-a-b) % 1234 == 0:\n\t\t\tprint(\"YES\")\n\t\t\texit()\nprint(\"NO\")"}, {"source_code": "n = input()\nn = int(n)\n\na = 1234567\nb = 123456\nc = 1234\n\nflag = 0\nfor i in range(n//a+1):\n\tfor j in range((n-a*i)//b+1):\n\t\tif (n-a*i-b*j) % c == 0:\n\t\t\tflag = 1\n\t\t\tbreak;\n\tif flag == 1:\n\t\tbreak;\n\nif flag == 1:\n\tprint (\"YES\")\nelse:\n\tprint (\"NO\")\n"}, {"source_code": "n = int(input())\n\nbr = False\nfor a in range(0, n + 1, 1234567):\n for b in range(0, n - a + 1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n br = True\n break\n if br:\n break\nelse:\n print(\"NO\")"}, {"source_code": "import sys\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\ndef tryy(n):\n BASE_a = 1234567\n BASE_b = 123456\n BASE_c = 1234\n a_coef = 0\n while a_coef * BASE_a <= n:\n b_coef = 0\n while a_coef * BASE_a + b_coef * BASE_b <= n:\n if (n - (a_coef * BASE_a + b_coef * BASE_b)) % BASE_c == 0:\n return \"YES\"\n b_coef += 1\n a_coef += 1\n return \"NO\"\n\nif __name__ == \"__main__\":\n n = int(sys.stdin.readline().strip())\n print tryy(n)\n"}, {"source_code": "n=int(raw_input())\na=0\nans=False\nwhile a<=n:\n b=0\n while a+b<=n:\n if (n-a-b)%1234==0:\n ans=True\n b+=123456\n a+=1234567\nprint 'YES' if ans else 'NO'\n \n"}, {"source_code": "n = int(raw_input())\n\na = 1234567\nb = 123456\nc = 1234\n\ni = 0\nj = 0\n\nflag = (n % c == 0 or n % a == 0 or n % b == 0)\nwhile True:\n\n j = 0\n if i*a > n or flag: break\n while True:\n if i*a + j*b > n or flag: break\n if (n - (i*a + j*b)) % c == 0:\n flag = True\n break\n j += 1\n i += 1\n\nif flag: print \"YES\"\nelse: print \"NO\"\n"}, {"source_code": "n=input()\nf=1\nt=0\nwhile f==1 :\n a=n-t*1234567\n b=a\n c=a\n fl=0\n while a>=1234 or b>=123456 :\n if a%123456==0 or b%1234==0:\n fl=1\n break\n if a-1234>0 :\n a=a-1234\n if b-123456>0 :\n b=b-123456\n if a==0 :\n fl=1\n if fl==1 :\n f=0\n print \"YES\"\n t=t+1\n if c<0 :\n f=0\n print \"NO\"\n"}, {"source_code": "n = int(raw_input())\n\naup = n/1234567\nyes = False\nfor a in xrange(aup + 1):\n remain = n - a * 1234567\n\n bup = remain / 123456\n\n for b in xrange(bup + 1):\n remain2 = remain - b * 123456\n\n if remain2 % 1234 == 0:\n yes = True\n break\n if yes:\n break\n\nif yes:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n=int(input())\na=0\nc=0\nwhile a*1234567<=n :\n b=0\n v=a*1234567\n while a*1234567+b*123456<=n :\n if (n-v-b*123456)%1234==0 :\n print('YES')\n c=1\n break\n b=b+1\n a=a+1\n if c==1 :\n break\nif c==0 :\n print('NO')\nl=0\n"}, {"source_code": "n = int(input())\nX = 1234567\nY = 123456\nZ = 1234\nli = n//X\nflag = 0\nfor i in range(li+1):\n\tlj = (n-X*i)//Y\n\tif flag==1 :\n\t\tbreak\n\tfor j in range(lj+1):\n\t\tif (n-i*X-j*Y)%Z==0:\n\t\t\tflag = 1\n\t\t\tbreak\nif flag == 1:\n\tprint(\"YES\")\nelse :\n\tprint(\"NO\")\n\n"}, {"source_code": "n = int(input())\n\nA = 1234567\nB = 123456\nC = 1234\n\nfor a in range(n // A + 1):\n for b in range(n // B + 1):\n c = n - a * A - b * B\n if c >= 0 and c % C == 0:\n exit(print(\"YES\"))\nprint(\"NO\")"}, {"source_code": "n = int(raw_input())\n\nh = 1234567\nc = 123456\nd = 1234\ncan = False\nfor a in xrange(10**3+1):\n for b in xrange(10**4+1):\n if a *h + b*c > n:\n break\n tt = n - a *h - b*c\n if tt == 0 or tt%1234 == 0:\n can = True\n break\n if can : break\n\nif can : print \"YES\"\nelse : print \"NO\"\n"}, {"source_code": "import os,sys,itertools,math,collections,string\ndef main():\n\tn=int(sys.stdin.readline())\n\tfor a in xrange(n/1234567+1):\n\t\tx=n-a*1234567\n\t\tfor b in xrange(x/123456+1):\n\t\t\ty = x-b*123456\n\t\t\tif y%1234==0:\n\t\t\t\tprint 'YES'\n\t\t\t\treturn\n\tprint 'NO'\nmain()"}, {"source_code": "n = int(input())\na = 1234567\nb = 123456\nc = 1234\n\ndef ab(num):\n while num >= 0:\n if num % c == 0:\n return True\n num -= b\n return False\n\ndef abc(num):\n while num >= 0:\n if ab(num):\n return True\n num -= a\n return False\n\nprint('YES' if abc(n) else 'NO')\n"}, {"source_code": "n1=int(input())\na=int(n1/1234567)\nb=int(n1/123456)\nt=0\nresultado=0\nfor x in range(0,a+1):\n for i in range(0,b+1):\n resultado=n1-(1234567*x+123456*i)\n if(resultado%1234==0 and resultado>=0):\n print(\"YES\")\n t=1\n break\n if(t==1):\n break\nif(t==0):\n print(\"NO\")\n"}, {"source_code": "import sys\n\ndef yes():\n print('YES')\n sys.exit()\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\nlimit = 10 ** 9\na = 1234567\nb = 123456\nc = 1234\n#print(gcd(a, b))\n#print(gcd(a, c))\n#print(gcd(b, c))\n#print(limit // a, limit // b, limit // c)\n\nn = int(raw_input())\n\nfor x in range(0, n + 1, b):\n m = n - x\n for y in range(0, m + 1, a):\n if (m - y) % c == 0:\n yes()\n\nprint('NO')\n"}, {"source_code": "n = int(input())\nouter_step = 1234567\ninner_step = 123456\nc = 1234\nfor x in range(0, n+1, outer_step):\n for y in range(0, n+1-x, inner_step):\n if (n - (x + y)) % c == 0:\n print (\"YES\")\n exit()\nprint (\"NO\")\n"}, {"source_code": "from fractions import gcd\nn = input()\nx = 1234567\ny = 123456\nz = 1234\nyz = gcd(y,z)\nans =\"NO\"\nini = 0\nwhile((n-ini)>=0 and ans==\"NO\"):\n rem = n -ini\n if(rem%yz!=0):\n ini+=x\n else:\n temp = 0\n while((rem-temp)>=0):\n if((rem-temp)%z==0):\n ans = \"YES\"\n break\n temp+=y\n ini+=x\nprint ans\n"}, {"source_code": "n = input()\nfor a in range(n / 1234567 + 1):\n\tfor b in range(n / 123456 + 1):\n\t\tt = n - 1234567 * a - 123456 * b\n\t\t# print 'a=', a, 'b=', b, 't=', t\n\t\tif t >= 0 and t % 1234 == 0: \n\t\t\tprint 'YES'\n\t\t\texit(0)\nprint 'NO'\n\t"}, {"source_code": "# cook your dish here\nn=int(input())\na=1234567\nb=123456\nc=1234\nflag=0\nflag2=0\nfor i in range(10000):\n\tfor j in range(10000):\n\t\tx=(a*i) + (b*j)\n\t\t\n\t\tif x>n:\n\t\t\tflag2=1\n\t\t\tbreak\n\n\t\tif (n-x)%c==0:\n\t\t\tflag=1\n\t\t\tbreak\n\t\t#print(i,j,x)\n\tif flag:\n\t\tbreak\nif flag:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "n = int(input())\nfor i in range((n - 1234567 if n & 1 else n) // 2, -1, -1234567):\n for j in range(i, -1, -61728):\n if not j % 617:\n print(\"YES\")\n exit(0)\nprint(\"NO\")\n\n\n"}, {"source_code": "#import time\n\nnum =int(input())\n\n#start = time.time()\na = 0\n\nb = 0\nc = 0\nq = [0,0]\nkr = [0,0,0,0]\noutput = False\n\ndef sum0():\n s = a*1234567\n return s\ndef sum1():\n s = a*1234567+b*123456\n return s\ndef sum2():\n s = a*1234567+b*123456+c*1234\n return s\n\n\nq[0] = int(num/1234567)\nif (num % 1234567) == 0:\n output = True\nif (num % 123456) == 0:\n output = True\nif (num % 1234) == 0:\n output = True\n\nwhile a <= q[0]:\n\n q[1] = int((num - sum0())/123456)\n while b <= q[1]:\n c = int((num - sum1())/1234)\n d = int((num - sum2())/56)\n\n if (((num - sum2()) % 56) == 0) and ((d)<=(c/100)):\n output = True\n #kr=[sum0(),sum1(),sum2(),a,b,c]\n break\n else:\n b += d\n\n \n c = 0\n b += 1\n if output == True:\n break\n b = 0\n a += 1\n\n \n\nif output == True:\n print(\"YES\")\nelse:\n print(\"NO\")\n#print(kr)\n#print(num - sum2())\n#end = time.time()\n#print(end - start)\n\n"}, {"source_code": "from fractions import gcd\ncount=0\nn=input()\nfor i in range(0,n+1,1234567):\n for j in range(0,n-i+1,123456):\n if((n-i-j)%1234==0):\n count=1\n\nif(count==1):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = input()\nfor i in range(1 + (n / 1234567)):\n\tfor j in range(1 + (n / 123456)):\n\t\tif (n - ((i * 1234567) + (j * 123456))) % 1234 == 0 and (n - ((i * 1234567) + (j * 123456))) >= 0:\n\t\t\tprint \"YES\"\n\t\t\texit(0)\nprint \"NO\"\n"}, {"source_code": "n = int(raw_input())\n\nh = 1234567\nc = 123456\nd = 1234\ncan = False\nfor a in xrange(10**3+1):\n for b in xrange(10**4+1):\n if a *h + b*c > n:\n break\n tt = n - a *h - b*c\n if tt == 0 or tt%1234 == 0:\n can = True\n break\n if can : break\n\nif can : print \"YES\"\nelse : print \"NO\"\n"}, {"source_code": "__author__ = 'aste'\n\n\ndef solve(n):\n max_a = n//1234567\n a = 0\n while a <= max_a:\n b = 0\n max_b = (n - 1234567*a)//123456\n while b <= max_b:\n c = n - 1234567*a - 123456*b\n if c >= 0 and c%1234 == 0:\n return True\n b += 1\n a += 1\n return False\n\n\ndef main():\n n = int(input())\n print(solve(n) and \"YES\" or \"NO\")\n\n\nmain()"}, {"source_code": "n=int(input())\nans=False\nfor i in range((n//1234567)+1):\n\tbroken = False\n\tfor j in range(((n-(i*1234567))//123456)+1):\n\t\tif (n-i*1234567-j*123456)%1234==0:\n\t\t\tans=True\n\t\t\tbroken = True\n\t\t\tbreak\n\tif broken:\n\t\tbreak\nif ans:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n = int(input())\na, b, c = 1234567, 123456, 1234\nak = (n // a) + 1\nans = 0\nfor i in range(ak):\n num1 = i * a\n bk = ((n - num1)//b) + 1\n for j in range(bk):\n if (n -num1 - j*b) % c == 0:\n ans += 1\n break\nif ans > 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\n na = n // 1234567 + 1\n nb = n // 123456 + 1\n flag = False\n for a in range(na):\n for b in range(nb):\n v = n - a * 1234567 - b * 123456\n if v >= 0 and v % 1234 == 0:\n flag = True\n break\n if flag:\n break\n print('YES') if flag else print('NO')\n"}, {"source_code": "n = int(raw_input())\n\nh = 1234567\nc = 123456\nd = 1234\ncan = False\nfor a in xrange(10**3+1):\n for b in xrange(10**4+1):\n if a *h + b*c > n:\n break\n tt = n - a *h - b*c\n if tt == 0 or tt%1234 == 0:\n can = True\n break\n if can : break\n\nif can : print \"YES\"\nelse : print \"NO\"\n"}, {"source_code": "\n\nn = int(raw_input())\n\n\na = n//1234567\nb = n//123456\nc = n//1234\n\nsuccess = False\n\nfor ai in range(a+1):\n if success:\n break\n for bi in range(b+1):\n s = ai*1234567+bi*123456\n if s>n:\n break\n elif (n-s)%1234 == 0:\n print 'YES'\n success = True\n break\nif not success:\n print 'NO'\n\n"}, {"source_code": "import os,sys,itertools,math,collections,string\ndef main():\n\tn=int(raw_input())\n\tfor a in xrange(n/1234567+1):\n\t\tx=n-a*1234567\n\t\tfor b in xrange(x/123456+1):\n\t\t\ty = x-b*123456\n\t\t\tif y%1234==0:\n\t\t\t\tprint 'YES'\n\t\t\t\treturn\n\tprint 'NO'\nmain()"}, {"source_code": "\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn=int(input())\n\nif n%2:\n n=(n-1234567)//2\nelse:\n n=n//2\n\nif n<0: print(\"NO\")\nelse:\n # now check with 1234567, 61728, 617\n good=0\n for i in range(n,-1,-1234567):\n for j in range(i,-1,-61728):\n if j%617==0:\n good=1\n break\n if good: break\n if good: print(\"YES\")\n else: print(\"NO\")"}, {"source_code": "n = int(input())\nfor i in range(0, n+1, 1234567):\n\tfor j in range(0, n-i+1, 123456):\n\t\tif(n-i-j)%1234==0:\n\t\t\tprint \"YES\"\n\t\t\texit(0)\nprint \"NO\""}, {"source_code": "n = int(input())\nfor a in range(0, n + 1, 1234567):\n for b in range(0, n - a + 1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "n = int(raw_input())\n\nA = 1234567\nB = 123456\nC = 1234\nflag = False\n\nfor i in range(0,1001):\n if(A*i>n):\n break\n for j in range(0,10001):\n sum = A*i + B*j\n rem = n - sum\n if(rem<0):\n break\n if(rem%C == 0):\n flag = True\n break\n if(flag):\n break\n\nif flag == True:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "n = int(input())\n\nfor i in range(0,n+1,1234567):\n for j in range(0,n-i+1,123456):\n if (n-i-j) % 1234 == 0:\n print(\"YES\")\n quit()\nprint(\"NO\")"}, {"source_code": "n = int(input())\n\ncan = False\n\n##print(n / 1234567)\nfor i in range(n / 1234567 + 1):\n\tif (can):\n\t\tbreak\n\tn1 = n - i * 1234567\n\t##print(\"#\", n1 / 123456)\n\tfor i1 in range(n1 / 123456 + 1):\n\t\tif (can):\n\t\t\tbreak\n\t\tn2 = n1 - i1 * 123456\n\t\t##print(n2 % 1234)\n\t\tif (n2 % 1234 == 0):\n\t\t\t\tcan = True\n\nif (can):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n n = input()\n flag = 0\n\n for i in range(0,82):\n\n for j in range(0,811):\n temp = n-i*1234567-j*123456\n if temp <0:\n break\n else:\n if temp%1234==0:\n flag=1\n\n if flag:\n print \"YES\"\n else:\n print \"NO\"\n\n\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "def f(r,t):\n if t == 'a':\n i = 0\n while r-(i*1234567) >= 0:\n if r-(i*1234567)==0:\n return True\n else:\n if f(r-(i*1234567),'b'):\n return True\n i += 1\n elif t == 'b':\n i = 0\n while r-(i*123456) >= 0:\n if r-(i*123456)==0:\n return True\n else:\n if f(r-(i*123456),'c'):\n return True\n i += 1\n elif t == 'c':\n if r%1234==0:\n return True\n return False\n\n\n\nn = int(raw_input())\nif f(n,'a'):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n = int(input())\na = n // 1234567\nresults = \"NO\"\nfor x in range(a + 1):\n p = n - 1234567 * x\n b = p // 123456\n for y in range(b + 1):\n q = p - 123456 * y\n if q % 1234 == 0:\n results = \"YES\"\n break\n if results == \"YES\":\n break\nprint(results)"}, {"source_code": "n = int(input())\nfor a in range(n // 1234567 + 1):\n\tfor b in range(n // 123456 + 1):\n\t\tconta = n - 1234567 * a - 123456 * b\n\t\tif conta >= 0 and conta % 1234 == 0: \n\t\t\tprint ('YES')\n\t\t\texit(0)\nprint ('NO')\n"}, {"source_code": "n=int(input())\na = b = c = 0\nwhile a*1234567 <= n:\n\tcur = a*1234567\n\tb = 0\n\twhile cur+b*123456<=n:\n\t\tif (n-cur-b*123456)%1234==0:print('YES');exit()\n\t\tb+=1\n\ta+=1\nprint('NO')"}, {"source_code": "n = int(raw_input())\nfor a in range(n / 1234567 + 1):\n for b in range((n - a * 1234567) / 123456 + 1):\n if (n - a * 1234567 - b * 123456) % 1234 == 0:\n print 'YES'\n exit()\nprint 'NO'"}, {"source_code": "def main():\n n = int(input())\n p = funct(n)\n if p == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\ndef funct(n):\n a = 0\n while a <= n:\n b = 0\n while b <= n - a:\n #print(\"a = {}, b = {}\".format(a, b))\n if (n - a - b) % 1234 == 0:\n # print(\"True\")\n return 1\n else:\n b += 123456\n a += 1234567\n return 0\n\nmain()\n\n"}, {"source_code": "n = int(input())\n\nhouse = 1234567\ncar = 123456\ncomputer = 1234\n\nfound = False\n\na = 0 \n\nwhile(a * house <= n):\n \n if(found):\n break\n b = 0\n while(a * house + b * car <= n):\n rem = n - a * house - b * car\n b += 1\n if(rem % computer == 0):\n found = True\n break\n a += 1\nif(found):\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "w = int(input())\nhouse = 1234567\ncar = 123456\ncomp = 1234\nq = False\nb = 0\nc = 0\n\nwhile c <= w//comp and q == False and w >= comp:\n while b <= w//car and q == False and w >= car:\n if (w - c*comp - b*car)%house == 0 and (w - c*comp - b*car) >= 0:\n q = True\n break\n b += 1\n if (w - c*comp - b*car)%house == 0 and (w - c*comp - b*car) >= 0:\n q = True\n break\n c += 1\n b = 0\nif q == True:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\nfrom math import ceil as C\n\nx , y , z = 1234567.0 , 123456.0 , 1234.0\nn = input()\nflag = False\nfor i in range(int(C(n/x))+1) :\n for j in range(int(C(n/y))+1) :\n c = n-i*x-j*y\n if c%z==0 and c>=0 :\n flag = True\n break\n if flag :\n break\nprint \"YES\"if flag else \"NO\"\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\nfrom itertools import permutations\n\nimport bisect\n\nn=I()\n\n\nfor a in range(100):\n for b in range(1000):\n if n-1234567*a-123456*b>=0 and (n- 1234567*a-123456*b)%1234==0:\n print('YES')\n exit()\n\nprint('NO')"}, {"source_code": "n=int(input())\np=0\nfor i in range (810):\n if p is 1:\n break\n for j in range (8100):\n k=i*1234567+j*123456\n if k>n:\n break\n k=n-k\n if k%1234 is 0:\n p=1\n break\nif p is 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=1234;b= 123456;c=1234567\nn=int(input())\nfor i in range(0,n+1,c):\n for j in range(0,n+1-i,b):\n if (n-i-j)%a==0:exit(print(\"YES\"))\nprint(\"NO\")"}, {"source_code": "n = input()\nok = \"NO\"\nfor i in range(0, n + 1, 1234567):\n for j in range(0, n - i + 1, 123456):\n c = n - i - j\n if c % 1234 == 0 and c >= 0:\n ok = 'YES'\n break\nprint ok\n"}, {"source_code": "def readval(typ=int):\n return typ( raw_input() )\n\ndef readvals(typ=int):\n return map( typ, raw_input().split() )\n\ndef testcase():\n n = readval()\n for a in xrange(n/1234567+1):\n for b in xrange((n-a*1234567)/123456+1):\n rest = n-a*1234567-b*123456\n if rest%1234==0: \n print 'YES'\n return\n print 'NO'\n \nif __name__=='__main__':\n testcase()\n"}, {"source_code": "#!/usr/bin/python\n\nimport os\nimport sys\nimport itertools\n\ndef solve(f):\n n = f.read_int()\n\n for a in xrange(1234):\n for b in xrange(1234):\n res = n - a*1234567 - b*123456\n if res >= 0 and res%1234 == 0:\n return \"YES\"\n\n return \"NO\"\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 print solve(f)\n else:\n print solve(f)\n"}, {"source_code": "n = int(input())\nfor a in range(0, n + 1, 1234567):\n for b in range(0, n - a + 1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "n=int(input())\nfrom sys import *\nl=[1234567,123456,1234]\nm=n\nj=0\nt=1\nwhile j*l[0]<=m and t:\n mm=m\n m-=j*l[0]\n jj=0\n while jj*l[1]<=m and t:\n mmm=m\n m-=jj*l[1]\n if m%l[2]==0:\n print('YES')\n t=0\n m=mmm\n jj+=1\n m=mm\n j+=1\nif t:\n print('NO')\n\n\n\n\n\n\n\n\n\n\n\n \n"}, {"source_code": "n=int(input())\n\na=b=c=0\n\nwhile a*1234567<=n:\n\n\tcur=a*1234567\n\n\tb=0\n\n\twhile cur+b*123456<=n:\n\n\t\tif (n-cur-b*123456)%1234==0:print('YES');exit()\n\n\t\tb+=1\n\n\ta+=1\n\nprint('NO')\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "# cook your code here\nn = input()\nh = n/1234567\nf=1\nfor i in xrange(h+1):\n c = n - i*1234567\n car = (c) / 123456\n for j in xrange(car+1):\n if (c - j*123456)%1234==0:\n print \"YES\"\n f=0\n break\n if f==0:\n break\nif f:\n print \"NO\"\n"}, {"source_code": "IL = lambda: list(map(int, input().split()))\nIS = lambda: input().split()\nI = lambda: int(input())\nS = lambda: input()\n\nn = I()\nprices = [1234567, 123456, 1234]\n\nans = False\nfor p1 in range(0, n+1, prices[0]):\n for p2 in range(0, n-p1+1, prices[1]):\n if (n-p1-p2)%prices[2] == 0:\n ans = True\n break\n\nprint(\"YES\" if ans else \"NO\")"}, {"source_code": "n1=int(input())\na=int(n1/1234567)\nb=int(n1/123456)\nt=0\nresultado=0\nfor x in range(0,a+1):\n for i in range(0,b+1):\n resultado=n1-(1234567*x+123456*i)\n if(resultado%1234==0 and resultado>=0):\n print(\"YES\")\n t=1\n break\n if(t==1):\n break\nif(t==0):\n print(\"NO\")\n"}], "negative_code": [{"source_code": "def bug_game(coin):\n res = False\n house = 0\n car = 0\n laptop = 0\n if coin == 0: res = False\n elif coin % 1234567 == 0 or coin % 123456 == 0 or coin % 1234 == 0: res = True \n elif coin % 1234567 != 0:\n coin %= 1234567\n if coin % 123456 == 0 or coin % 1234 == 0: res = True\n elif coin % 123456 != 0:\n coin %= 123456\n if coin % 1234 == 0: res = True\n else: res = False\n return res\n\ncoin = int(input())\nif bug_game(coin) == True:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0 and g >= 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nelif c != 0:\n for i in range(int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range(i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\nelif c != 0:\n for i in range (int(x/123456)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "w = int(input())\nhouse = 1234567\ncar = 123456\ncomp = 1234\nq = False\nb = 0\nc = 0\n\nwhile c <= w//comp and q == False and w >= comp:\n while b <= w//car and q == False and w >= car:\n if (w - c*comp - b*car)%house == 0:\n q = True\n break\n b += 1\n if (w - c*comp - b*car)%house == 0:\n q = True\n break\n c += 1\n b = 0\nif q == True:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nelif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\nelif c != 0:\n for i in range (int(x/123456)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\na=1234567\nb=123456\nc=1234\nmanh=0\nwhile True:\n if n >= a:\n n -= a\n elif n < a and n >= b:\n n -= b\n elif n < b and n >= c:\n n -= c\n if n < c and n !=0:\n break\n elif n ==0:\n manh += 1\n break\nif manh==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n #sadsadsadsadasdsad"}, {"source_code": "import time\n\nnum =int(input())\n\nstart = time.time()\na = 0\nb = 0\nc = 0\nq = [0,0]\nkr = [0,0,0,0]\noutput = False\n\ndef sum0():\n s = a*1234567\n return s\ndef sum1():\n s = a*1234567+b*123456\n return s\ndef sum2():\n s = a*1234567+b*123456+c*1234\n return s\n\n\nq[0] = int(num/1234567)\nif (num % 1234567) == 0:\n output = True\nif (num % 123456) == 0:\n output = True\nif (num % 1234) == 0:\n output = True\n\nwhile a <= q[0]:\n\n q[1] = int((num - sum0())/123456)\n while b <= q[1]:\n c = int((num - sum1())/1234)\n d = int((num - sum2())/56)\n\n if (((num - sum2()) % 56) == 0):\n output = True\n kr=[sum0(),sum1(),sum2(),a,b,c]\n break\n else:\n b += d\n\n \n c = 0\n b += 1\n b = 0\n a += 1\n\n \n\nif output == True:\n print(\"YES\")\nelse:\n print(\"NO\")\nprint(kr)\nend = time.time()\nprint(end - start)\n\n"}, {"source_code": "n=int(input())\nok=0\nfor a in range(1001):\n for b in range(1001):\n if (n - 1234567*a - 123456*b)>0 and (n - 1234567*a - 123456*b)%1234==0:\n ok=1\n #print(a,b)\nprint(\"YES\") if ok else print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\n\na = 1234567\nb = 123456\nc = 1234\n\ni = 0\nj = 0\n\nflag = (n % c == 0 or n % a == 0 or n % b == 0)\nwhile True:\n\n j = 1\n if i*a > n or flag: break\n while True:\n if i*a + j*b > n or flag: break\n if n % (i*a + j*b) == c:\n flag = True\n break\n j += 1\n i += 1\n\nif flag: print \"YES\"\nelse: print \"NO\"\n"}, {"source_code": "game_score = int(input())\n\ndef verify_spent(score):\n for a in range(1000):\n for b in range(1000):\n c = (score - b*123456 - a*1234567)/1234\n if c == 1:\n print(\"YES\")\n return\n print(\"NO\")\n \n \nverify_spent(game_score)\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys\nimport io\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 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())\n#n,k=map(int,raw_input().split())\n#l=map(int,raw_input().split())\ns109=10**9\n#n=s109\na,b,c=1234567,123456,1234\nthree=a+b+c\nans=chk=0\nif n=0 and ctmp%c==0:\n print 'YES'\n# print i,j\n exit()\nprint 'NO'"}, {"source_code": "n = int(input())\np = 0\nfrom math import ceil\nif n == 17851817:\n print(\"NO\")\nelse:\n for a in range(1,ceil(n/1234567)):\n for b in range(1,ceil(n/123456)):\n c = (n - a*1234567-b*123456)\n if c>0 and c%(1234) == 0:\n p = 1\n if p == 1:\n break\n if p == 1:\n break\n\n if p == 1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "def can_buy(n):\n if n == 1000000000:\n return 'YES'\n prices = [1234567, 123456, 1234]\n for i in range(3):\n if n < prices[i]:\n return 'NO'\n n = n % prices[i]\n\n if n == 0 and i !=2:\n return 'NO'\n\n if n == 0:\n return 'YES'\n \n return 'NO'\n\nn = int(input())\n\nprint(can_buy(n))\n\n"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n n = input()\n flag = 0\n n = n-1234567-123456-1234\n if n<0:\n flag = 0\n else:\n for i in range(0,81):\n\n for j in range(0,810):\n temp = n-i*1234567-j*123456\n if temp <0:\n break\n else:\n if temp%1234==0:\n flag=1\n\n if flag:\n print \"YES\"\n else:\n print \"NO\"\n\n\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(raw_input())\n#n = 17851817\na = 0\nb = 0\nc = 0\nres = 'NO'\nwhile True:\n m = n\n m -= a * 1234567\n b = 0\n while True:\n m -= b * 123456\n c = m / 1234\n #print a,b,c\n if c < 0:\n break\n if c * 1234 == m:\n res = 'YES'\n break\n b += 1 \n if (a * 1234567 + b * 123456 + c * 1234) == n:\n res = 'YES'\n break\n a += 1\n\nprint res"}, {"source_code": "n = int(input())\n\nif n % 1234567 % 123456 % 1234 == 0 or n % 123456 % 1234 == 0 or n % 1234 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def economy_game(n):\n if n % 1234 == 0 or n % 123456 == 0 or n % 1234567 == 0:\n return \"YES\"\n else:\n if n < 1234567:\n for i in range(11):\n r = n - (123456*i)\n if r % 1234 == 0:\n return \"YES\"\n else:\n for i in range(int(n/1234567)+1):\n for j in range(int((n-1234567*i)/123456)+1):\n r = n - (123456*j + 1234567*i)\n if r % 1234 == 0:\n return \"YES\"\n return \"NO\"\n \nn = int(input())\nprint(economy_game(n))"}, {"source_code": "def economy_game(n):\n if n % 1234 == 0 or n % 123456 == 0 or n % 1234567 == 0:\n return \"Yes\"\n else:\n if n < 1234567:\n for i in range(10):\n r = n - (123456*i)\n if r % 1234 == 0:\n return \"Yes\"\n else:\n for i in range(int(n/1234567)):\n for j in range(int((n-1234567*i)/123456)):\n r = n - (123456*j + 1234567*i)\n if r % 1234 == 0:\n return \"Yes\"\n return \"No\"\n \nn = int(input())\nprint(economy_game(n))"}, {"source_code": "coin = int(input())\n\nans = \"NO\"\n\na = coin // 1234567\n\nfor x in range(a, -1, -1):\n b = (coin - (a*1234567)) // 123456\n\n for y in range(b, -1, -1):\n z = (coin - (x*1234567) - (y*123456)) // 1234\n\n if x*1234567 + y*123456 + z*1234 == coin:\n ans = \"YES\"\n break\n\n if ans == \"YES\":\n break\n\n if ans == \"YES\":\n break\n\nprint(ans)"}, {"source_code": "n = int(input())\n\nhouse = 1234567\ncar = 123456\ncomputer = 1234\n\ncontHouse = n // house\nn = n - house * contHouse\n\ncontCar = n // car\nn = n - car * contCar\n\ncontComputer = n // computer\nn = n - computer * contComputer\n\nif(n != 0):\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n = int(input())\n\nat_best = 1000\n\nfor i in range(1, at_best):\n\tfor j in range(1, at_best):\n\t\tcurrent = (i * 1234567) + (j * 123456)\n\t\tremain = n - current\n\t\tif (current == n) or (remain % 1234 == 0 and remain > 0):\n\t\t\tprint(\"YES\")\n\t\t\tquit()\n\nprint(\"NO\")"}, {"source_code": "n = int(input())\nf = True\nfor a in range(0, n, 1234567):\n for b in range(0, n - a + 1, 123456):\n if (n - a - b) % 1234 == 0:\n print(\"YES\")\n f = False\n break\n if not f:\n break\nif f:\n print(\"NO\")"}, {"source_code": "n = int(input())\n\nat_best = 100\n\nfor i in range(1, at_best):\n\tfor j in range(1, at_best):\n\t\tfor k in range(1, at_best):\n\t\t\tif ((i * 1234567) + (j * 123456) + (k * 1234)) == n:\n\t\t\t\tprint(\"YES\")\n\t\t\t\tquit()\n\nprint(\"NO\")"}, {"source_code": "# Mahmoud and a Triangle \n\nn = int(raw_input())\n\n\ndef question(total):\n num1 = 1234567\n num2 = 123456\n num3 = 1234\n\n div1 = total / num1\n div2 = total / num2\n\n div1 += 1\n div2 += 1\n\n findIt = False\n for i in xrange(div1):\n for j in xrange(div2):\n aux = total - (num1 * i + num2 * j)\n if aux >= 0:\n if aux % num3 == 0:\n findIt = True\n print \"YES\"\n break\n\n\n if not findIt:\n print \"NO\"\n\n \n\n\n\nquestion(n)\n"}, {"source_code": "n = int(input())\nflag = 0\ni = j = 0\nh, c, p = 1234567, 123456, 1234\n\nwhile i * h <= n:\n\twhile j * c <= n:\n\t\tif not (n - i*h - j*c)%p:\n\t\t\tflag = 1\n\t\t\tbreak\n\t\tj += 1\n\ti += 1\n\tif flag:\n\t\tbreak\n\nif flag:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "a=1234;b= 123456;c=1234567\nn=int(input())\nfor i in range(0,n+1,c):\n for j in range(0,n+1-i,b):\n if (n-i-j)%a:exit(print(\"YES\"))\nprint(\"NO\")"}, {"source_code": "print 'YES' if int(raw_input())%1234567%123456%1234==0 else 'NO'"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0 and g >= 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nelif c != 0:\n for i in range(int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range(i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\nelif c != 0:\n for i in range (int(x/123456)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\n\nn = int(raw_input())\n\n\na = n//1234567\nb = n//123456\nc = n//1234\n\nsuccess = False\n\nfor ai in range(a+1):\n if success:\n break\n for bi in range(b+1):\n if success:\n break\n if ai*1234567+bi*1234567>n:\n break\n for ci in range(c+1):\n if ai*1234567 + bi*123456 + ci*1234 == n:\n print 'YES'\n success = True\n break\n if ai*1234567 + bi*123456 + ci*1234 > n:\n break\nif not success:\n print 'NO'\n\n"}, {"source_code": "n = int(raw_input())\nt1 = n/1234567\nt2 = n/123456\nt3 = n/1234\nflag1 = 0\nfor a in range(1,t1+1):\n\tif flag1 == 1:\n\t\tbreak\n\ttemp1 = n - a*1234567\n\tif temp1 < 123456 + 1234:\n\t\tflag1 = 0;\n\t\tbreak\n\tfor b in range(1,t2+1):\n\t\ttemp2 = temp1 - b*123456 \n\t\tif temp2 < 1234:\n\t\t\tbreak\n\t\telif temp2%1234 == 0:\n\t\t\tprint temp2,a,b,temp2/1234\n\t\t\tflag1 = 1\n\t\t\tprint \"YES\"\n\t\t\tbreak\nif flag1 == 0:\n\tprint \"NO\""}, {"source_code": "import sys\n\nn = input()\nans = n\nans %= 1234567\nans %= 123456\nans %= 1234\nprint \"YES\" if ans==0 else \"NO\"\n"}, {"source_code": "n=int(input())\n\na = n // 1234567\nb = ( n - a * 1234567) // 123456\nend = False\n\nwhile( a >= 0 and end != True ):\n while( b >= 0 and end != True ):\n rest=n-a*1234567-b*123456\n if(rest % 1234 == 0):\n print(\"YES\")\n end = True\n else:\n b -= 1\n a -= 1\nif(end == False): print(\"NO\")"}, {"source_code": "n = input()\n\ndef divisibleByComb(n):\n if n%1234==0:\n return True\n else:\n remain = n%1234\n if remain%56==0:\n return True\n return False\n\na,b,c = 1234567, 123456, 1234\nans = False\nif divisibleByComb(n):\n ans = True\nif n<1234567:\n if divisibleByComb(n):\n ans = True\n else:\n ans = False\nelse:\n x = 1234567\n while n>=x:\n remain = n-x\n if divisibleByComb(remain):\n ans = True\n break\n else:\n x+=a\n\n\nif ans:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "n = int(input())\n\nif n % 1234567 % 123456 % 1234 == 0 or n % 123456 % 1234 == 0 or n % 1234 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#import time\n\nnum =int(input())\n\n#start = time.time()\na = 0\nb = 0\nc = 0\nq = [0,0]\nkr = [0,0,0,0]\noutput = False\n\ndef sum0():\n s = a*1234567\n return s\ndef sum1():\n s = a*1234567+b*123456\n return s\ndef sum2():\n s = a*1234567+b*123456+c*1234\n return s\n\n\nq[0] = int(num/1234567)\nif (num % 1234567) == 0:\n output = True\nif (num % 123456) == 0:\n output = True\nif (num % 1234) == 0:\n output = True\n\nwhile a <= q[0]:\n\n q[1] = int((num - sum0())/123456)\n while b <= q[1]:\n c = int((num - sum1())/1234)\n d = int((num - sum2())/56)\n\n if (((num - sum2()) % 56) == 0):\n output = True\n kr=[sum0(),sum1(),sum2(),a,b,c]\n break\n else:\n b += d\n\n \n c = 0\n b += 1\n b = 0\n a += 1\n\n \n\nif output == True:\n print(\"YES\")\nelse:\n print(\"NO\")\n#print(kr)\n#end = time.time()\n#print(end - start)\n\n"}, {"source_code": "n = int(input())\nans = False\nfor i in range(0, 3):\n\ttemp = n\n\tif i == 0:\n\t\ttemp %= 1234567\n\t\tif temp % 1234 == 0:\n\t\t\tans = True\n\t\telse:\n\t\t\ttemp %= 123456\n\t\t\tif temp % 1234 == 0:\n\t\t\t\tans = True\n\telif i == 1:\n\t\ttemp %= 123456\n\t\tif temp % 1234 == 0:\n\t\t\tans = True\n\telse:\n\t\tif temp % 1234 == 0:\n\t\t\tans = True\n\nif ans:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "w = int(input())\nhouse = 1234567\ncar = 123456\ncomp = 1234\nq = False\nb = 0\nc = 0\n\nwhile c <= w//comp and q == False and w >= comp:\n while b <= w//car and q == False and w >= car:\n if (w - c*comp - b*car)%house == 0:\n q = True\n break\n b += 1\n if (w - c*comp - b*car)%house == 0:\n q = True\n break\n c += 1\n b = 0\nif q == True:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\nok=0\nfor a in range(1001):\n for b in range(1001):\n if (n - 1234567*a - 123456*b)>0 and (n - 1234567*a - 123456*b)%1234==0:\n ok=1\n print(a,b)\nprint(\"YES\") if ok else print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\nt1 = n/1234567\nt2 = n/123456\nt3 = n/1234\nflag1 = 0\nfor a in range(0,t1+1):\n\tif flag1 == 1:\n\t\tbreak\n\ttemp1 = n - a*1234567\n\tfor b in range(0,t2+1):\n\t\ttemp2 = temp1 - b*123456 \n\t\tif temp2%1234 == 0 and temp2 > 0:\n\t\t\tprint temp2,a,b,temp2/1234\n\t\t\tflag1 = 1\n\t\t\tprint \"YES\"\n\t\t\tbreak\nif flag1 == 0:\n\tprint \"NO\""}, {"source_code": "n=int(input())\na=0\nc=0\nwhile a*1234567= 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nelif c != 0:\n for i in range(int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range(i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\nelif c != 0:\n for i in range (int(x/123456)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0:\n ok()\n break\n\n\nwhile t >= 1234:\n t1 = t\n c1 = 1\n test(t)\n for i in range(3):\n t1 = t\n t1 -= o[i]\n test(t1)\n for i in range(3):\n t2 = t\n t2 -= o[i]\n for m in range(3):\n t3 = t2\n t3 -= o[m]\n test(t3)\n t -= 1359257\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from math import floor\n\ndef find(x):\n for i in range(1000):\n for j in range(1000):\n value = (x - j*123456 - i*1234567) / 1234\n \n if(value > 0 and value - floor(value) == 0):\n print(\"YES\")\n return\n \n print(\"NO\")\n \nfind(int(input()))"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0 and g >= 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nif c != 0:\n for i in range(int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range(i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n#if c != 0:\n # for i in range (int(x/123456)+1):\n # if c == 0:\n # break\n # temp = 123456*i\n # test(x - temp)\n # for p in range (i*1001):\n # if c == 0:\n # break\n # test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# import os,sys,itertools,math,collections,string\nimport sys\ndef main():\n\tn=int(sys.stdin.readline())\n\tfor a in xrange(n/1234567):\n\t\tfor b in xrange(n/123456):\n\t\t\tx = n-a*1234567-b*123456\n\t\t\tif x%1234==0:\n\t\t\t\tprint 'YES'\n\t\t\t\treturn\n\tprint 'NO'\nmain()"}, {"source_code": "import time\n\nnum =int(input())\n\nstart = time.time()\nkr = [0,0,0,0]\na = 0\nb = 0\nc = 0\nq = [0,0]\n\noutput = False\n\ndef sum0():\n s = a*1234567\n return s\ndef sum1():\n s = a*1234567+b*123456\n return s\ndef sum2():\n s = a*1234567+b*123456+c*1234\n return s\n\n\nq[0] = int(num/1234567)\nif (num % 1234567) == 0:\n output = True\n\nwhile a <= q[0]:\n\n q[1] = int((num - sum0())/123456)\n #while b <= q[1]:\n c = int((num - sum1())/1234)\n\n if (((num - sum2()) % 56) == 0) and ((num) > (sum0()+1233)):\n output = True\n\n\n # c = 0\n # b += 1\n #b = 0\n a += 1\n \n\nif output == True:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n#end = time.time()\n#print(end - start)\n\n"}, {"source_code": "success = False\nn = int(input())\nfor a in range(n // 1234567):\n nn = n - 1234567 * a\n for b in range(nn // 123456):\n if (nn - 123456 * b) % 1234 == 0:\n success = True\nif success:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = int(input())\ndef solve(n):\n for item in range(1, n//1234567 + 1):\n for i in range(1, n//123456 + 1):\n current = n - (item*1234567 + i*123456)\n if current < 0:\n break\n maxi = current // 1234 + 1\n\n low = 0\n hi = maxi\n mid = maxi//2\n while low < hi:\n if mid*1234 == current:\n return \"YES\"\n elif mid*1234 < current:\n low = mid+1\n else:\n hi = mid - 1\n mid = low + (hi - low) // 2\n return \"NO\"\nprint(solve(n))\n"}, {"source_code": "1359257"}, {"source_code": "r=lambda:map(int,raw_input().split())\n\nn=input()\n\na=n/1234567\nb=n/123456\nc=n/1234\n\n#print a,b, c\nfor i in range(a+1):\n b=(n-i*1234567)/123456\n for j in range(b+1):\n e=(n-i*1234567 - j*123456)\n if e >=0 and not e%1234:\n \n print i,j,\"YES\"\n exit(0)\nprint \"NO\"\n"}, {"source_code": "n = int(input())\np = 0\nfrom math import ceil\nfrom math import floor\nfor a in range(0,810):\n for b in range(0,8092-10*a):\n c = n - a*1234567-123456\n if c>0 and ceil(c) == floor(c):\n p = 1\n break\n\nif p==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nans=\"NO\"\nfor a in range(n//1234567+1):\n for b in range((n-a*1234567)//123456+1):\n if (n-a*1234567-b*123456)%1234==0:\n ans=\"YES\"\n exit()\nprint(ans)\n"}, {"source_code": "n1=int(input())\na=int(n1/1234567)\nb=int(n1/123456)\nt=0\nresultado=0\nfor x in range(0,a+1):\n for i in range(0,b+1):\n resultado=n1-(1234567*x+123456*i)\n if(resultado%1234==0 and resultado>0):\n print(\"YES\")\n t=1\n break\n if(t==1):\n break\nif(t==0):\n print(\"NO\")\n"}, {"source_code": "n=int(input())\nok=0\nfor a in range(1001):\n for b in range(1001):\n if (n - 1234567*a - 123456*b)>0 and (n - 1234567*a - 123456*b)%1234==0:\n ok=1\n #print(a,b)\nprint(\"YES\") if ok else print(\"NO\")\n"}, {"source_code": "n = input()\nwhile (n>=1234567):\n n-=1234567\nwhile (n>=123456):\n n-=123456\nwhile (n>=1234):\n n-=1234\n\nif n==0:\n print \"YES\"\n\nelse:\n print \"NO\"\n"}, {"source_code": "import math\ngame_score = int(input())\n\ndef verify_spent(score):\n for a in range(1000):\n for b in range(1000):\n c = (score - b*123456 - a*1234567)/1234\n \n if c > 0 and (c - math.floor(c) == 0):\n print(\"YES\")\n return\n \n print(\"NO\")\n \n \nverify_spent(game_score)\n"}, {"source_code": "n=int(input())\na=n%1234567\nb=a%123456\nif b%1234==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def economy_game(n):\n if n % 1234 == 0 or n % 123456 == 0 or n % 1234567 == 0:\n return \"YES\"\n else:\n if n < 1234567:\n for i in range(int(n/1234567)+1):\n r = n - (123456*i)\n if r % 1234 == 0:\n print(i)\n return \"YES\"\n else:\n for i in range(int(n/1234567)+1):\n for j in range(int((n-1234567*i)/123456)+1):\n r = n - (123456*j + 1234567*i)\n if r % 1234 == 0:\n return \"YES\"\n return \"NO\"\n \nn = int(input())\nprint(economy_game(n))"}, {"source_code": "n = int(input())\np = 0\nfrom math import ceil\nif n == 17851817:\n print(\"NO\")\nelse:\n for a in range(0,ceil(n/1234567)):\n for b in range(0,ceil(n/123456)):\n c = (n - a*1234567-b*123456)\n if c>0 and c%(1234) == 0:\n p = 1\n if p == 1:\n break\n if p == 1:\n break\n\n if p == 1:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "b=int(raw_input())\ndef isgood(n):\n while n>0:\n if n%1234==0:\n return True\n n-=123456\n return n==0\ngood=False\nwhile b>0:\n if isgood(b):\n good=True\n b-=1234567\n\nif good:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "import time\n\nnum =int(input())\n\nstart = time.time()\na = 0\nb = 0\nc = 0\nq = [0,0]\nkr = [0,0,0,0]\noutput = False\n\ndef sum0():\n s = a*1234567\n return s\ndef sum1():\n s = a*1234567+b*123456\n return s\ndef sum2():\n s = a*1234567+b*123456+c*1234\n return s\n\n\nq[0] = int(num/1234567)\nif (num % 1234567) == 0:\n output = True\nif (num % 123456) == 0:\n output = True\nif (num % 1234) == 0:\n output = True\n\nwhile a <= q[0]:\n\n q[1] = int((num - sum0())/123456)\n while b <= q[1]:\n c = int((num - sum1())/1234)\n d = int((num - sum2())/56)\n\n if (((num - sum2()) % 56) == 0):\n output = True\n kr=[sum0(),sum1(),sum2(),a,b,c]\n break\n else:\n b += d\n\n \n c = 0\n b += 1\n b = 0\n a += 1\n\n \n\nif output == True:\n print(\"YES\")\nelse:\n print(\"NO\")\nprint(kr)\nend = time.time()\nprint(end - start)\n\n"}, {"source_code": "def can_spend(n):\n a = 1234567\n b = 123456\n c = 1234\n \n values = set()\n values.add(a)\n values.add(b)\n values.add(c)\n values.add(0)\n \n init = n // a\n \n ## a + c / a + b\n while(init >= 0):\n current = n - (init * a)\n if current % a in values or current % b in values or current % c in values:\n return 'YES'\n \n init_b = current // b \n ## a + b + c\n while(init_b >= 0):\n if current + (init_b * b) + c > n:\n init_b -= 1\n continue\n \n current_b = current - (init_b * b)\n if current_b % b in values or current_b % c in values:\n return 'YES'\n \n init_b -= 1\n \n init -= 1\n \n init = n // b\n \n while(init >= 0):\n current = n - (init * b)\n if current % b in values or current % c in values:\n return 'YES'\n init -= 1\n \n return 'NO'\n \n \n \nn = int(input())\nprint(can_spend(n))"}, {"source_code": "n = int(input())\ny = False\nfor i in range(n//1234567 + 2):\n for j in range((n - 1234567*i)//123456 + 2):\n a = n - i*1234567 - j*123456\n if a >0 and a%1234 == 0:\n y = True\n break\n\nif(y):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=input()\nf=1\nt=0\nwhile f==1 :\n a=n-t*1234567\n b=a\n c=a\n fl=0\n while a>=1234 or b>=123456 :\n if a%123456==0 or b%1234==0:\n fl=1\n break\n if a-1234>0 :\n a=a-1234\n if b-123456>0 :\n b=b-123456\n if fl==1 :\n f=0\n print \"YES\"\n t=t+1\n if c<0 :\n f=0\n print \"NO\"\n"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0:\n ok()\n break\n\n\nwhile t >= 1234:\n t1 = t\n c1 = 1\n test(t)\n for i in range(3):\n t1 = t\n t1 -= o[i]\n test(t1)\n for i in range(3):\n t2 = t\n t2 -= o[i]\n for m in range(3):\n t3 = t2\n t3 -= o[m]\n test(t3)\n t -= 1359257\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def main():\n n = int(input())\n p = funct(n)\n if p == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\ndef funct(n):\n a = 0\n while a <= n:\n b = 0\n while b <= n - a:\n #print(\"a = {}, b = {}\".format(a, b))\n if (n - a - b) % 1234 == 0:\n print(\"True\")\n return 1\n else:\n b += 123456\n a += 1234567\n return 0\n\nmain()\n\n"}, {"source_code": "n = int(input())\nflag = 0\ni = j = 0\nh, c, p = 1234567, 123456, 1234\n\nwhile i * h <= n:\n\twhile j * c <= n:\n\t\tif not (n - i*h - j*c)%p:\n\t\t\tflag = 1\n\t\t\tbreak\n\t\tj += 1\n\ti += 1\n\tif flag:\n\t\tbreak\n\nif flag:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "n = int(raw_input())\nt1 = n/1234567\nt2 = n/123456\nt3 = n/1234\nflag1 = 0\nflag2 = 0\nflag3 = 0\nflag4 = 0\nfor a in range(1,t1):\n\tfor b in range(1,t2):\n\t\tfor c in range(1,t3):\n\t\t\ttemp = a*1234567+b*123456+c*1234\n\t\t\t#print a,b,c,temp\n\t\t\tif temp == n:\n\t\t\t\tprint 'YES'\n\t\t\t\tflag1 = 1\n\t\t\t\tflag4 = 1\n\t\t\t\tbreak\n\t\t\tif temp > n:\n\t\t\t\tbreak\n\t\tif flag1 == 1:\n\t\t\tflag2 = 1\n\t\t\tbreak\n\tif flag2 == 1:\n\t\tflag3 = 1\n\t\tbreak\nif flag4 == 0:\n\tprint 'NO'"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0 and g >= 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nelif c != 0:\n for i in range(int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range(i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\nelif c != 0:\n for i in range (int(x/123456)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n1=int(input())\na=int(n1/1234567)\nb=int(n1/123456)\nt=0\nresultado=0\nfor x in range(a+1):\n for i in range(b+1):\n resultado=n1-(1234567*x+123456*i)\n if(resultado%1234==0):\n print(\"YES\")\n t=1\n break\n if(t==1):\n break\nif(t==0):\n print(\"NO\")\n"}, {"source_code": "b=int(raw_input())\ndef isgood(n):\n while n>0:\n if n%1234==0:\n return True\n n-=123456\n return n==0\ngood=False\nwhile b>0:\n if isgood(b):\n good=True\n b-=1234567\n\nif good:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "print(\"YES\" if int(input()) % 1234567 % 123456 % 1234 == 0 else \"NO\")\n"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0:\n ok()\n break\n\n\nwhile t >= 1234:\n t1 = t\n c1 = 1\n test(t)\n for i in range(3):\n t1 = t\n t1 -= o[i]\n test(t1)\n for i in range(3):\n t2 = t\n t2 -= o[i]\n for m in range(3):\n t3 = t2\n t3 -= o[m]\n test(t3)\n t -= 1359257\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(input())\nn -= (n//1234567)*1234567\nn -= (n//123456)*123456\nn -= (n//1234)*1234\nif n == 0:\n print(\"YES\")\nelse: \n print(\"NO\")"}, {"source_code": "n = int(input())\nfor a in range((n // 1234567) + 1):\n for b in range((n // 123456) - (a * 1234567) + 1):\n if (n - (a * 1234567) - (b * 123456)) % 1234 == 0:\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "n=int(input())\nif n<1234:\n print(\"NO\")\nelse:\n if n%1359257==0:\n print(\"YES\")\n elif n%1234==0 or n%123456==0 or n%1234567==0:\n print(\"YES\")\n else:\n print(\"YES\")"}, {"source_code": "n = int(raw_input())\n\ndef f():\n\tfor i in xrange(1, (n / 1234567) + 1):\n\t\tfor j in xrange(1, (n / 123456) + 1):\n\t\t\tm = n - 1234567 * i - 123456 * j\n\t\t\tif m % 1234 == 0:\n\t\t\t\tprint \"YES\"\n\t\t\t\treturn\n\tprint \"NO\"\nf()"}, {"source_code": "import sys\n\nn = input()\nans = n\nans %= 1234567\nans %= 123456\nans %= 1234\nprint \"YES\" if ans==0 else \"NO\"\n"}, {"source_code": "coin = int(input())\n\nans = \"NO\"\n\na = coin // 1234567\n\nfor x in range(a, -1, -1):\n b = (coin - (a*1234567)) // 123456\n\n for y in range(b, -1, -1):\n c = (coin - (a*1234567) - (b*123456)) // 1234\n\n if a*1234567 + b*123456 + c*1234 == coin:\n ans = \"YES\"\n break\n\n if ans == \"YES\":\n break\n\n if ans == \"YES\":\n break\n\nprint(ans)"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\not = [0, 1234, 123456, 1234567, 124690, 1235801, 1358023]\ny = 0\ntx = x\n\n\ndef ok():\n global y\n y = 1\n print(\"YES\")\n\n\ndef teste(e):\n for i in range(3):\n if e % o[i] == 0:\n ok()\n break\n return\n\n\nwhile x >= 1234:\n for j in range (7):\n if j == 0:\n teste(x)\n continue\n while tx >= 1234:\n print(\"testando\")\n teste(x - (ot[j]))\n tx -= ot[j]\n if y == 1:\n break\n\n x -= 1359257\n\nif y == 0:\n print(\"NO\")\n"}, {"source_code": "class CodeforcesTask681BSolution:\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 is_ = False\n for a in range(1, 100):\n for b in range(1, 100):\n for c in range(1, 100):\n if a * 1234567 + b * 123456 + c * 1234 == self.n:\n is_ = True\n break\n if is_:\n break\n if is_:\n break\n self.result = \"YES\" if is_ else \"NO\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask681BSolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "n=int(input())\nfor i in range(n,1234567):\n b=i*1234567\n for j in range(n,0):\n if b+(j*123456) >= n:\n break\n c=n-b-(j*123456)\n if c%1234==0:\n print(\"YES\")\n exit()\n j+=1\nprint(\"NO\")"}, {"source_code": "n = int(raw_input())\nif n >=1359257 and n<1359257+1234:\n print 'YES'\nelse:\n print 'NO'\n\n\n\n\n"}, {"source_code": "# Mahmoud and a Triangle \n\nn = int(raw_input())\n\n\ndef question(total):\n num1 = 1234567\n num2 = 123456\n num3 = 1234\n\n div1 = total / num1\n div2 = total / num2\n\n div1 += 1\n div2 += 1\n\n findIt = False\n aux = total\n for i in xrange(div1):\n for j in xrange(div2):\n aux -= num1 * i + num2 * j\n if aux > 0:\n div3 = aux / num3\n aux -= div3 * num3\n if aux == 0:\n findIt = True\n print \"YES\"\n break\n\n aux = total\n\n if not findIt:\n print \"NO\"\n\n \n\n\n\nquestion(n)\n"}, {"source_code": "n = int(input())\ncheck = 0\nfor i in range(0, n//1234567 + 1):\n for j in range(0, n//123456 + 1):\n if ((n - 1234567*i - 123456*j)%1234 == 0):\n check = 1\n break\nif check == 1: print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "def main():\n n = int(input())\n for i in range((n - 1234567 if n & 1 else 0) // 2, -1, -1234567):\n for j in range(i, -1, -61728):\n if not j % 617:\n print(\"YES\")\n return\n print(\"NO\")\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "x = int(input())\no = [1234567, 123456, 1234]\nc = 1\nt = x\n\n\ndef ok():\n global c\n c = 0\n\n\ndef test(g):\n for p in range(3):\n if g % o[p] == 0:\n ok()\n break\n\n#for i in range (int(x/1234)):\n # test(x-(i*1234567))\n # test(x - (i * 123456))\n # test(x - (i * 1234))\n\n\nif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x-temp)\n for p in range (i*11):\n if c == 0:\n break\n test(x-(p*123456)-temp)\n\nelif c != 0:\n for i in range (int(x/1234567)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\nelif c != 0:\n for i in range (int(x/123456)+1):\n if c == 0:\n break\n temp = 1234567*i\n test(x - temp)\n for p in range (i*1001):\n if c == 0:\n break\n test(x-(p*1234)-temp)\n\n\n\nif c == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = int(raw_input())\nt1 = n/1234567\nt2 = n/123456\nt3 = n/1234\nflag1 = 0\nfor a in range(1,t1+1):\n\tif flag1 == 1:\n\t\tbreak\n\ttemp1 = n - a*1234567\n\tif temp1 < 123456 + 1234:\n\t\tflag1 = 0;\n\t\tbreak\n\tfor b in range(1,t2+1):\n\t\ttemp2 = temp1 - b*123456 \n\t\tif temp2 < 1234:\n\t\t\tbreak\n\t\telif temp2%1234 == 0:\n\t\t\tprint temp2,a,b,temp2/1234\n\t\t\tflag1 = 1\n\t\t\tprint \"YES\"\n\t\t\tbreak\nif flag1 == 0:\n\tprint \"NO\""}, {"source_code": "def find(x):\n for i in range(0, x, 1234567):\n for j in range(0, x - i , 123456):\n if((x - i - j) % 1234 == 0):\n print(\"YES\")\n return\n print(\"NO\")\n \nfind(int(input()))"}, {"source_code": "n = int(input())\n\nfor i in range(0,n,1234567):\n for j in range(0,n,123456):\n if (n-i-j) % 1234 == 0:\n print(\"YES\")\n quit()\nprint(\"NO\")"}, {"source_code": "n = int(input())\ny = False\nfor i in range(n//1234567 + 2):\n for j in range((n - 1234567*i)//123456 + 2):\n a = n - i*1234567 - j*123456\n if a >0 and a%1234 == 0:\n y = True\n break\n\nif(y):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def can_spend(n):\n a = 1234567\n b = 123456\n c = 1234\n \n values = set()\n values.add(a)\n values.add(b)\n values.add(c)\n values.add(0)\n \n init = n // a\n \n ## a + c / a + b\n while(init >= 0):\n current = n - (init * a)\n if current % a in values or current % b in values or current % c in values:\n return 'YES'\n \n init_b = current // b \n ## a + b + c\n while(init_b >= 0):\n if current + (init_b * b) + c > n:\n init_b -= 1\n continue\n \n current_b = current - (init_b * b)\n if current_b % b in values or current_b % c in values:\n return 'YES'\n \n init_b -= 1\n \n init -= 1\n \n init = n // b\n \n while(init >= 0):\n current = n - (init * b)\n if current % b in values or current % c in values:\n return 'YES'\n init -= 1\n \n return 'NO'\n \n \n \nn = int(input())\nprint(can_spend(n))"}, {"source_code": "n = input()\n\ndef divisibleByComb(n):\n if n%1234==0:\n return True\n else:\n remain = n%1234\n if remain%56==0:\n return True\n return False\n\na,b,c = 1234567, 123456, 1234\nans = False\nif n<1234567:\n if divisibleByComb(n):\n ans = True\n else:\n ans = False\nelse:\n x = 1234567\n while n>=x:\n remain = n-x\n if divisibleByComb(remain):\n ans = True\n break\n else:\n x+=a\n\n\nif ans:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "n = int(raw_input())\n\na = 1234567\nb = 123456\nc = 1234\n\ni = 0\nj = 0\n\nflag = (n % c == 0 or n % a == 0 or n % b == 0)\nwhile True:\n\n j = 1\n if i*a > n or flag: break\n while True:\n if i*a + j*b > n or flag: break\n if (n - (i*a + j*b)) % c == 0:\n flag = True\n break\n j += 1\n i += 1\n\nif flag: print \"YES\"\nelse: print \"NO\"\n"}, {"source_code": "n = input()\nif n < 1234:\n\tprint 'NO'\nelse:\n\tn = n % 1234567\n\tn = n % 123456\n\tn = n % 1234\n\tif n == 0: print 'YES'\n\telse: print 'NO'\n\t\n\t"}], "src_uid": "72d7e422a865cc1f85108500bdf2adf2"} {"nl": {"description": "Let's write all the positive integer numbers one after another from $$$1$$$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...Your task is to print the $$$k$$$-th digit of this sequence.", "input_spec": "The first and only line contains integer $$$k$$$ ($$$1 \\le k \\le 10000$$$) \u2014 the position to process ($$$1$$$-based index).", "output_spec": "Print the $$$k$$$-th digit of the resulting infinite sequence.", "sample_inputs": ["7", "21"], "sample_outputs": ["7", "5"], "notes": null}, "positive_code": [{"source_code": "import bisect\nxyz=[9,90,900,9000,90000,900000,9000000,90000000,900000000,9000000000,900000000000]\nxzy=[10,190,2890,38890,488890,5888890,68888890,788888890,8888888890,98888888890,1088888888890,11888888888890]\ncount=2\nk=int(input())\ndigits=bisect.bisect_left(xzy,k)\n#print('d',digits)\nif k==10:\n print(1)\nelif k>10:\n apu=k-xzy[digits-1]\n #print('a',apu)\n modulo=apu%(digits+1)\n #print('m',modulo)\n dlj=apu//(digits+1)\n #print('d',dlj)\n output=10**(digits)+dlj\n #print('o',output)\n list1=[i for i in str(output)]\n #print(list1)\n print(list1[modulo])\nelse:\n print(k)\n\n \n \n \n \n \n"}, {"source_code": "n = int(input())\nfor i in range(1,10001):\n i = str(i)\n if(len(i)>=n):\n for k in range(len(i)):\n n-=1\n if(n == 0):\n print(i[k])\n else:\n n-=len(i)\n \n"}, {"source_code": "n = int(input())\ni = 0\ns = 0\nwhile True:\n\ttemp = (i+1)*9*(10**i)\n\tif s + temp <= n:\n\t\ts += temp\n\t\ti += 1\n\telse:\n\t\tbreak\ntc = n - s\n\nnd = tc//(i+1) - 1\ntc -= (nd+1)*(i+1)\nf = 10**i + nd\nif tc != 0:\n\tprint(str(10**i+nd+1)[tc-1])\nelse:\n\tprint(str(10**i+nd)[-1])\n"}, {"source_code": "print(''.join(map(str, range(3000)))[int(raw_input())])"}, {"source_code": "def whereis(k):\n n = 1\n while k > 0:\n k -= 9*10**(n-1)*n\n n+=1\n else:\n n-= 1\n return n\n\ndef kthdigit(k):\n a = whereis(k)\n sequence = ''\n sum = 0\n for b in range(1, a):\n sum += 9*10**(b-1)*b\n i = k-sum\n divider = (i-1)/a \n remainder = (i-1)%a \n number = divider + 10**(a-1)\n string = ''\n for huh in range (number, number+1):\n string += str(huh)\n \n return string[remainder]\nwe = input()\nprint kthdigit(we)\n\n \n\n \n "}, {"source_code": "k = int(input())\ns = ''\n\nfor i in range(10000):\n s += str(i)\n if len(s) > k:\n print(s[k])\n break\n"}, {"source_code": "def get1(n):\n res = 0\n st = 1\n while st <= n:\n res += len(str(st))\n st += 1\n return res\n\ndef get(n):\n if n == 0:\n return 0\n \n L = len(str(n))\n res = 0\n prev = 1\n for i in range(1, L):\n res += i * ((10**i) - prev)\n prev = (10**i)\n \n res += (n - 10**(L - 1) + 1) * L\n\n return res\n\ndef solve(n):\n start = 1\n end = 10**18\n it = 70\n while it:\n it -= 1\n mid = (start + end) / 2\n if get(mid) >= n:\n end = mid\n else:\n start = mid\n \n for i in range(mid - 5, mid + 5):\n if i >= 1:\n cur = str(i)\n s = ''\n for j in cur:\n s += j\n if get(i - 1) + len(s) == n:\n return j\n return mid\n\nn = input()\nX = solve(n)\nprint X"}, {"source_code": "#####################################################\n\"\"\"\"\"\"\"\"\"\"\"\"\" Mino \"\"\"\"\"\"\"\"\"\"\"\"\"\n#####################################################\n\n\"\"\"############ \u00a9 Mino's corporation #############\"\"\"\n\nn=int(input())\nseq,i='1',1\nwhile len(str(seq))= 0:\n k -= n * 9 * 10 ** (n - 1)\n n += 1\n a = generate(n, k / n)\n return str(a)[k % n]\n\n\n# print solve([100] * 11)\nn = input()\nprint solve(n)\n"}, {"source_code": "n=int(input())\nar=map(str,range(1,10001))\ns=''\nd=s.join(ar)\nprint(d[n-1])"}, {"source_code": "import sys\n\nk = int(input())\nd = [0]\nfor i in range(1, 5):\n d.append((10 ** i - 10 ** (i - 1)) * i + d[i - 1])\n# print(d)\nfor i in range(1, len(d)):\n if k <= d[i]:\n f = d[i - 1]\n f1 = 10 ** (i - 1)\n # print(i, f)\n # print(str(((k - f - 1) // i) + f1))\n print(str(((k - f - 1) // i) + f1)[(k - f - 1) % i])\n sys.exit()\n"}, {"source_code": "n = int(input())\ns = ''\ni = 0\nwhile len(s) <= n:\n s += str(i)\n i += 1\nprint(s[n])\n"}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x x * y:\n n -= x * y\n y *= 10\n x += 1\na = 10 ** (x - 1)\na += n // x\nprint(str(a)[n % x])"}, {"source_code": "import math\nk = int(input())\n\n\ndef cnt_digit_order(X):\n res = 0\n if X == 0:\n return 0\n for i in range(1, X+1):\n res += i*(9*pow(10, i-1))\n return res\n\n\nL = -1\nleftcnt = 0\nfor length in range(1, 100):\n if cnt_digit_order(length - 1) < k <= cnt_digit_order(length):\n L = length\n leftcnt = k - cnt_digit_order(length - 1)\n break\n\n#L = digits/length\nM = str(math.ceil(leftcnt/L) + (10**(L-1) - 1))\nleftcnt -= 1\nleftcnt %= L\nprint(M[leftcnt])\n"}, {"source_code": "k = int(input())\na = \"\"\nfor i in range(1, 5005) :\n\ta += str(i)\nprint(a[k-1])"}, {"source_code": "k = int(input())\nn = 1\nup_bnd = 9\nwhile(k > up_bnd):\n n += 1\n up_bnd += (9*n)*(10**(n-1))\nlow_bnd = 0\nlb_val = 0\nfor i in range(1, n):\n low_bnd += (9*i)*(10**(i-1))\n lb_val = (lb_val*10)+9\nnum = int((k-low_bnd)/n) + lb_val\nrm = (k-low_bnd) % n\nif(rm != 0):\n num += 1\nans = 0\nif(rm == 0):\n ans = num % 10\nelse:\n for i in range(n-rm+1):\n j = (num % 10)\n num = int(num/10)\n ans = j\nprint(int(ans))"}, {"source_code": "l=[]\nk=int(input())\nfor i in xrange(10**6):\n l.append(i)\ns=\"\".join(str(e) for e in l)\nprint s[k]"}, {"source_code": "def get_kth_digit(i):\n if i < 10:\n return i\n\n batch = 9\n count = 9\n width = 1\n\n while i > 10 * batch * (width + 1) + count:\n batch *= 10\n width += 1\n count += batch * width\n\n \n k = i - count - 1\n num = 10 ** width + k// (width + 1)\n return str(num)[k % (width + 1)]\n\ndef main():\n i = int(input())\n\n print(get_kth_digit(i))\n\nif __name__ == '__main__':\n main()"}, {"source_code": "l=[]\nk=int(input())\nfor i in xrange(10**6):\n l.append(i)\ns=\"\".join(str(e) for e in l)\nprint s[k]"}, {"source_code": "n=int(input())\ns=''\nfor i in range(n+1):\n s=s+str(i)\nprint(s[n])\n \n"}, {"source_code": "def generate(n, x):\n a = 10 ** (n - 1)\n a += x\n return a\n\n\ndef solve(k):\n k -= 1\n n = 1\n while k - n * 9 * 10 ** (n - 1) >= 0:\n k -= n * 9 * 10 ** (n - 1)\n n += 1\n a = generate(n, k / n)\n return str(a)[k % n]\n\n\n# print solve([100] * 11)\nn = input()\nprint solve(n)\n"}, {"source_code": "l=''\nk=int(input())\nindex=0\ncounter=1\nwhile True:\n for i in str(counter):\n if index<=k-1:\n l+=i\n index+=1\n counter+=1\n if index>k-1:\n break \n \nif 1<=k <=10000: \n print(l[k-1])"}, {"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--------------------------------------\n'''\n\n\n___________________THIS IS AESTROIX CODE________________________\n KARMANYA GUPTA\n\n'''\n\nfor t in range(1):\n\tstring = ''\n\tfor i in range(1,10002):\n\t\tstring += str(i)\n\tn = int(input())\n\tprint(string[n-1])\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "l = []\nn = []\nsum = 0\nmultiply = 9\nfor i in range(1,12):\n s = '9' * i\n n.append(int(s))\n sum+=i*multiply\n multiply *= 10\n l.append(sum)\nk = int(input())\nif(k<9):\n print(k)\nelse:\n t = 0\n for i in range(len(l)):\n if(k < l[i]):\n t=i\n break\n temp = k-l[t-1]\n offset = temp%(t+1)\n value = temp//(t+1)\n number = n[t-1]+value\n if(offset == 0):\n print(number%10)\n else:\n number += 1\n offset -= 1\n print(str(number)[offset])"}, {"source_code": "k=int(input())\ni=0\nr=1\nwhile(k>=r):\n r+=9*(i+1)*10**i\n i+=1\nr=r-(9*i*10**(i-1))\nans=str(((k-r)//i)+10**(i-1))[(k-r)%i]\nprint(ans)\n"}, {"source_code": "z = int(input())\nstring = \"\"\nfor i in range(1,z+2):\n string += str(i)\nprint(string[z-1])"}, {"source_code": "n = int(input())\ni = 0\ns = 0\nwhile True:\n\ttemp = (i+1)*9*(10**i)\n\tif s + temp <= n:\n\t\ts += temp\n\t\ti += 1\n\telse:\n\t\tbreak\ntc = n - s\n\nnd = tc//(i+1) - 1\ntc -= (nd+1)*(i+1)\nf = 10**i + nd\nif tc != 0:\n\tprint(str(10**i+nd+1)[tc-1])\nelse:\n\tprint(str(10**i+nd)[-1])\n"}, {"source_code": "k=int(input())\ni=0\nr=1\nwhile(k>=r):\n r+=9*(i+1)*10**i\n i+=1\nr=r-(9*i*10**(i-1))\nans=str(((k-r)//i)+10**(i-1))[(k-r)%i]\nprint(ans)"}, {"source_code": "k = int(input())\n\nnc = [0 for i in range(14)]\n\nfor i in range(1, 14):\n nc[i] += nc[i - 1] + 9 * (10 ** (i - 1)) * i\n\nfor i in range(13):\n if nc[i] < k <= nc[i + 1]:\n cif = i + 1\n\nif cif == 1:\n print(k)\n quit()\n\nc = k - nc[cif - 1]\n\nif c % cif == 0:\n nnr = c // cif\n ncif = cif\nelse:\n nnr = 1 + c // cif\n ncif = c % cif\n\nnumber = nnr + 10 ** (cif - 1) - 1\n\nwhile cif != ncif:\n number //= 10\n cif -= 1\n\nprint(number % 10)"}, {"source_code": "n=int(input())\nl=''.join(list(map(str,range(1,n+1))))\nprint(l[n-1])"}, {"source_code": "k = int(input())\ns = ''\ni = 1\n\n\nwhile(i<=k):\n s += str(i)\n i+=1\n \nprint(s[k-1])\n"}, {"source_code": "def lint(n): #to find length of an integer\n h = int(n)\n i= 0\n while(h>0):\n h= int(h/10)\n i=i+1\n len =i\n return len\n\n\nk =int(input())\nlist = [1]\nn=1\ny=1\nfor y in range (1,k):\n n = n+1;\n p= lint(n)\n for i in range(p,0,-1):\n e= 10**(i-1)\n x = int(n/e)\n z= x%10 \n list.append(z)\n\n\n y = y+p\nprint(list[k-1])\n\n"}, {"source_code": "\"\"\"\nStrategy: Split sequence into subsequences\naccording to number of digits. Then find corresponding\nnumber and digit in that number.\n\"\"\"\n\n# Standard input.\nk=int(input())\n\n# Initilize sequence\nnum_digits=1\nnum_numbers=9\n\nk-=1\nwhile k>num_digits*num_numbers:\n # Move sequence starting point. \n k -= num_numbers*num_digits\n num_digits += 1\n num_numbers *= 10\n\n# Generate number.\nnumber = 10**(num_digits - 1) + k // num_digits\n# Find index in that number\nindex = k % num_digits\nanswer = str(number)[index]\nprint(answer)"}, {"source_code": "a,b,c,d,e,f,g,h,i,j,k,l= [9*1, 90*2, 900*3, 9000*4, 90000*5, 900000*6, 9000000*7, 90000000*8, 900000000*9, 9000000000*10, 90000000000*11, 900000000000*12]\na=a; b= a+b; c= b+c; d=c+d; e=d+e; f= e+f; g= f+g; h=g+h; i=h+i; j= i+j\nk= j+k; l= k+l\nli1=[0,a,b,c,d,e,f,g,h,i,j,k,l]\nn= int(input()); nn=0\nfor ii in range(1,12):\n if li1[ii-1]n:\n nn= ii\n \nn= n-li1[nn-1]\nr1= 10**(nn-1)\nn1= n//nn\nr1+= n1-1\nn2= n-(n1*nn)\nif n2==0:\n print(str(r1)[-1])\nelse:\n #print(r1, n2-1)\n print(str(r1+1)[n2-1])"}, {"source_code": "a = ''\nfor k in range(1, 10000):\n a = a + str(k)\n if len(a) >= 10000:\n break\ns = int(input())\nprint(a[s-1])"}, {"source_code": "k = int(input())\ni = 1\ns = ''\nwhile len(s)=n:\n\t\tbreak\nj=le-n\nprint(st[-j-1])"}, {"source_code": "n=int(input())-1\ni=0\nwhile n>=(9*(i+1)*(10**i)):\n\tn-=(9*(i+1)*(10**i))\n\ti+=1\n\t# print (n)\na=int(pow(10,i))+int(n/(i+1))\n# print (a)\nprint(str(a)[n%(i+1)])"}, {"source_code": "k = int(input())\ns = ''\nfor i in range(1,10000):\n\ts += str(i)\nprint(s[k-1])"}, {"source_code": "k = int(input())\n\nif k <= 9:\n\tprint(k)\n\nelse:\n\ts = 9\n\tn = 1\n\t\n\twhile s < k:\n\t\tn += 1\n\t\tprev_s = s\n\t\ts += (10**n - 10**(n-1)) * n\n\n\tdigit_pos = k - (prev_s + 1)\n\tnumber = 10**(n-1) + digit_pos // n\n\t\n\tif digit_pos / n != digit_pos // n:\n\t\tdigit_pos = digit_pos - (digit_pos // n) * n\n\n\n\telse:\n\t\tdigit_pos = 0\n\n\tprint(str(number)[digit_pos])"}, {"source_code": "k = int(input())\nc = 0\nfor i in range(1,10000):\n s = str(i)\n c = c + len(s)\n if c >= k:\n break\n else:\n continue\n\nb = str(i)\nif c == k:\n print(b[len(b)-1])\nelse:\n print(b[len(b)-(c-k)-1])"}, {"source_code": "k = int(input())\ns = \"\"\ni = 0\nwhile len(s) <= k:\n s += str(i)\n i += 1\nprint(s[k])"}, {"source_code": "#Bhargey Mehta (Junior)\n#DA-IICT, Gandhinagar\nimport sys, math, queue, bisect\n#sys.stdin = open('input.txt', 'r')\nMOD = 998244353\nsys.setrecursionlimit(1000000)\n\nn = int(input())\nif n < 10:\n print(n)\n exit()\nd = 1\nwhile n > 9*d*pow(10, d-1):\n n -= 9*d*pow(10, d-1)\n d += 1\nx = pow(10, d-1) + (n-1)//d\np = n % d\nx = str(x).zfill(d)\nprint(x[p-1])"}, {"source_code": "#####################################################\n\"\"\"\"\"\"\"\"\"\"\"\"\" Mino \"\"\"\"\"\"\"\"\"\"\"\"\"\n#####################################################\n\n\"\"\"############ \u00a9 Mino's corporation #############\"\"\"\n\nn=int(input())\nseq,i='1',1\nwhile len(str(seq))= 0:\n k -= n * 9 * 10 ** (n - 1)\n n += 1\n a = generate(n, k / n)\n return str(a)[k % n]\n\n\n# print solve([100] * 11)\nn = input()\nprint solve(n)\n"}, {"source_code": "\n\nimport bisect\n\n \nb = []\na = []\nb.append(0)\n\nfor i in range(1, 15):\n\tb.append(9 * i * (10 ** (i - 1)))\n\n\na.append(b[0])\nfor i in range(1, 15):\n\ta.append(a[i - 1] + b[i])\n\nk = int(input())\n\nth = bisect.bisect_left(a, k)\nth -= 1;\nk = k - a[th];\nstart = 10 ** th;\nnow = th + 1;\nrem = k % now;\niss = k / now;\nend = start + (k / now);\ntemp = str(end - 1);\ns = \"\";\ns += temp[now - 1] + str(end) + str(end + 1);\n\n\n\nprint(s[0 + rem])\n\n "}, {"source_code": "import os\nk = int(input()) \nstring = \"\"\ni=0\nwhile len(string)end_range):\n start_range=end_range+1\n digit+=1\n end_range+=(digit*nine*pow(10,digit-1))\n total=total+start_range\n\nstart=pow(10,digit-1)\nnumber=int((x-start_range)/digit)\nindex=int((x-start_range)%digit)\nstart=start+number\nstring=str(start)\nprint(string[index])"}, {"source_code": "k = int(input())\ncount = 1\nnumber = 1\nresult = 0\nnumber1 = 1\nwhile True:\n if number == 1:\n if result + 9 < k:\n result += 9\n number = 20\n number1 = 10\n else:\n break\n elif number == 20:\n if result + 180 < k:\n result += 180\n number += 10\n number1 = 100\n else:\n break\n else:\n if result + 9 * number * 10**count < k:\n result += 9 * number * 10**count\n number += 10\n count += 1\n number1 *= 10\n else:\n break\n\nwhile True:\n if count == 0:\n break\n if result + number * 10**count < k:\n result += number * 10**count\n number1 += 100 * 10**(count - 1)\n else:\n count -= 1\n\nwhile True:\n if number == 1:\n break\n if result + number < k:\n result += number\n number1 += 10\n else:\n break\n\nwhile True:\n if result + len(str(number1)) >= k:\n print(str(number1)[k - result - 1])\n break\n else:\n number1 += 1\n result += len(str(number1))\n"}, {"source_code": "s = \"\"\nk = int(input())\nfor i in range(1,10000):\n s+=str(i)\nprint(s[k-1])"}, {"source_code": "import bisect\nxyz=[9,90,900,9000,90000,900000,9000000,90000000,900000000,9000000000,900000000000]\nxzy=[10,190,2890,38890,488890,5888890,68888890,788888890,8888888890,98888888890,1088888888890,11888888888890]\ncount=2\nk=int(input())\ndigits=bisect.bisect_left(xzy,k)\n#print('d',digits)\nif k==10:\n print(1)\nelif k>10:\n apu=k-xzy[digits-1]\n #print('a',apu)\n modulo=apu%(digits+1)\n #print('m',modulo)\n dlj=apu//(digits+1)\n #print('d',dlj)\n output=10**(digits)+dlj\n #print('o',output)\n list1=[i for i in str(output)]\n #print(list1)\n print(list1[modulo])\nelse:\n print(k)\n\n \n \n \n \n \n"}, {"source_code": "k = int(input())\nprev=0\nnextt=0\nNumofDigits=0\n#i = 0\n#while(summ<(2^12)):\nwhile(True):\n prev = nextt\n nextt = nextt+(9*(10**(NumofDigits-1))*NumofDigits)\n if(k>= prev and k<=nextt):\n break\n NumofDigits=NumofDigits+1\nif(NumofDigits==1):\n print(k)\nelse:\n result = (10**(NumofDigits-1))+int((k-(prev+1))/NumofDigits)\n i=0\n while(True):\n if (k-int(prev+1))%NumofDigits == i:\n break\n i=i+1\n result = str(result)\n print(result[i])"}, {"source_code": "k = int(input())\na = \"\"\nfor x in range(1, k + 1):\n\ta += str(x)\nprint(a[k- 1])\n"}, {"source_code": "def count(start, k):\n s = \"_\"\n while len(s) <= k:\n s += str(start)\n start += 1\n return s[k]\n\nprint(count(1, int(input())))"}, {"source_code": "n = input()\nif len(n) == 1:\n print(n)\n exit(0)\nelse:\n li = list(range(1, int(n)+1))\n s = ''\n for i in li:\n s += str(i)\n print(s[int(n)-1])"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef main():\n val = 0\n A = []\n for i in range(1, 10000 + 1):\n s = str(i)\n A.append(s)\n val += len(s)\n if val >= 10000:\n break\n s = ''.join(list(str(a) for a in A))\n n = int(input())\n print(s[n-1])\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "k=int(input())\n\ns=0\ni=1\nwhile (s + i * ( 9 * pow ( 10,i-1)) ) < k :\n s += i * (9 * pow(10, i - 1))\n i+=1\nelse:\n i-=1\n\nk=k-s-1\nx= k // (i+1)\ny= k %(i+1)\nx= pow(10,i)+x\nss=str(x)\nprint(ss[y])\n"}, {"source_code": "k = int(input())\nprev=0\nnextt=0\nNumofDigits=0\n#i = 0\n#while(summ<(2^12)):\nwhile(True):\n prev = nextt\n nextt = nextt+(9*(10**(NumofDigits-1))*NumofDigits)\n if(k>= prev and k<=nextt):\n break\n NumofDigits=NumofDigits+1\nif(NumofDigits==1):\n print(k)\nelse:\n result = (10**(NumofDigits-1))+int((k-(prev+1))/NumofDigits)\n i=0\n while(True):\n if (k-int(prev+1))%NumofDigits == i:\n break\n i=i+1\n result = str(result)\n print(result[i])"}, {"source_code": "k = int(input())\nprev=0\nnext=0\nNumofDigits=0\n#i = 0\n#while(sum<(2^12)):\nwhile(True):\n prev = next\n next = next+(9*(10**(NumofDigits-1))*NumofDigits)\n if(k>= prev and k<=next):\n break\n NumofDigits=NumofDigits+1\nif(NumofDigits==1):\n print(k)\nelse:\n result = (10**(NumofDigits-1))+int((k-(prev+1))/NumofDigits)\n i=0\n while(True):\n if (k-int(prev+1))%NumofDigits == i:\n break\n i=i+1\n result = str(result)\n print(result[i])"}, {"source_code": "num=int(input())\nnull=''\nfor i in range(num+1):\n null+=str(i)\nprint(null[num])\n "}, {"source_code": "def size_of_group(i):\n return long(9 * 10**(i - 1)) * i\n\ndef find_group(k, i = 1):\n diff = long(k - (size_of_group(i)))\n if diff <= 0:\n return k, i\n return find_group(diff, i + 1)\n\ndef get_number(k, g):\n return str(long(10**(g - 1)) + k / g)[k % g]\n\ndef get_sequence_number(num):\n \"\"\"https://codeforces.com/problemset/problem/1177/B\"\"\"\n k_prim, g_prim = find_group(num)\n return get_number(k_prim - 1, g_prim)\n\n# run program\nif __name__ == \"__main__\":\n print(get_sequence_number(long(input())))"}, {"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()\ns=''\nfor i in range(1,5001):\n s+=str(i)\nprint(s[n-1])"}, {"source_code": "k = int(input())\nc = 0\nfor i in range(1,10000):\n s = str(i)\n c = c + len(s)\n if c >= k:\n break\n else:\n continue\n\nb = str(i)\nif c == k:\n print(b[len(b)-1])\nelse:\n print(b[len(b)-(c-k)-1])"}, {"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>1\n return r\n \ndef solve():\n n=inp()\n s=''\n for i in range(2800):\n s+=str(i)\n print(s[n])\n\n\n\nfor _ in range(1):\n solve()\n \n"}, {"source_code": "import sys\nk=int(input())\nif type(k)!=int or k<=0 or k>pow(10,12) :\n print(\"wrong input. try again\")\n sys.exit()\nlim_init=lim=decimal=9\nc=0\nwhile True:\n c+=1\n if k<=lim:\n diff=lim-k #189-21\n pos=diff%c\n diff=int(diff/c) #168/2=84\n diff=decimal-diff #99-84\n print(''.join(list(reversed(str(diff))))[pos])\n break\n else:\n decimal = int(str(lim_init)*(c+1))\n lim+=int(str(lim_init)+'0'*c)*(c+1)\n"}, {"source_code": "k = int(input())\nc = 0\nfor i in range(1,10000):\n s = str(i)\n c = c + len(s)\n if c >= k:\n break\n else:\n continue\n\nb = str(i)\nif c == k:\n print(b[len(b)-1])\nelse:\n print(b[len(b)-(c-k)-1])"}, {"source_code": "def ans(n):\n s=\"\"\n i=1\n while(len(s)0))[ind])"}, {"source_code": "k = int(input())\ns = \"\"\nfor i in range(10000):\n s = s + str(i + 1)\nprint(s[k - 1])"}, {"source_code": "import sys,math\n\ndef read_int():\n\treturn int(sys.stdin.readline().strip())\n\ndef read_int_list():\n\treturn list(map(int,sys.stdin.readline().strip().split()))\n\ndef read_string():\n\treturn sys.stdin.readline().strip()\n\ndef read_string_list(delim=\" \"):\n\treturn sys.stdin.readline().strip().split(delim)\n\n\n###### Author : Samir Vyas #######\n###### Write Code Below #######\nk = read_int()\n\nbase_digit_number = 1; expo = 0\n\nwhile k >= base_digit_number:\n\tbase_digit_number += 9*(expo+1)*(10**expo)\n\texpo += 1\n\nbase_digit_number -= 9*(expo)*(10**(expo-1))\n\nans_number = (k - base_digit_number)//expo + 10**(expo-1)\n\nans_digit = str(ans_number)[(k - base_digit_number)%expo]\n\nprint(ans_digit)\n"}, {"source_code": "s = \"\"\nfor i in range(10000):\n s += str(i)\nn = int(input())\nprint(s[n])"}, {"source_code": "n=int(input())\ns=0; pred=0\nfor i in range(1,20):\n m=9*pow(10,i-1)*i\n s+=m \n if n<=s: \n nd=pow(10,i-1) \n sme=n-pred \n num=sme//i\n ost=sme%i\n if ost==0:\n dig=nd+num-1\n else:\n dig=nd+num \n d=i\n rez=[]\n ddig=dig\n while d>0:\n o=ddig%10\n a=ddig//10\n rez.append(o)\n d-=1\n ddig=a \n break\n pred=s\nprint(str(rez[-ost]))\n"}, {"source_code": "s=\"\"\nfor i in range(1,3000):\n s=s+str(i)\n#print(len(s))\n\nk=int(input())\nprint(s[k-1])"}, {"source_code": "k = int(input())\n\ns = \"\"\nfor i in range(1,10000):\n s = s + str(i)\n\nprint(s[k-1])\n"}, {"source_code": "bl=\"\"\nfor i in range(1,12345): \n bl+=str(i)\nn=int(input())\nprint(bl[n-1])"}, {"source_code": "import sys \nn=int(input())\nind=0\ndig=0\nfor i in range(1,12):\n dig+=i*10**(i-1)*9 \n #print(dig)\n if dig>n:\n ind=i-1\n rt=dig-i*10**(i-1)*9 \n break \nn-=rt\nno=10**ind\n#print(n)\nif n==0:\n print(9)\n sys.exit()\nu=n\nn-=(n//(ind+1))*(ind+1)\nno+=max(0,(u//(ind+1))-1)\n#print(n)\nif n==0:\n print(str(no)[-1])\nelse:\n no+=1\nwhile(n>0):\n if n<=ind+1:\n e=str(no)\n print(e[n-1])\n n-=ind+1\n no+=1\n\n"}, {"source_code": "n = int(input())\ns = \"\"\nfor i in range(1, 10001):\n s+=str(i)\nprint(s[n-1])"}, {"source_code": "k=int(input())\ni=0\nr=1\nwhile(k>=r):\n r+=9*(i+1)*10**i\n i+=1\nr=r-(9*i*10**(i-1))\nans=str(((k-r)//i)+10**(i-1))[(k-r)%i]\nprint(ans)"}, {"source_code": "def f(x): #including x\n\tdig, cnt = 1, 9\n\tans = 0\n\twhile dig != len(str(x)):\n\t\tans += dig * cnt\n\t\tdig += 1\n\t\tcnt *= 10\n\tans += (x - (cnt // 9) + 1) * dig\n\treturn ans\nk = int(input())\nl, r = 1, 1000000000000\nif k == 1:\n print(1)\n exit(0)\nwhile l < r:\n\tmid = (l + r + 1) >> 1\n\tif f(mid) < k:\n\t\tl = mid\n\telse:\n\t\tr = mid - 1\nk -= f(l)\nl += 1\nprint(str(l)[k - 1])"}, {"source_code": "n,x,y=int(input())-1,1,9\nwhile n>x*y:n,x,y=n-x*y,x+1,y*10\nprint(str(10**(x-1)+n//x)[n%x])"}, {"source_code": "n = int(input())\nstep = 9\ncount = 0\ndigit = 1\nwhile (count + (digit * step) < n):\n count += (digit * step)\n step *= 10\n digit += 1\ni = n - count\nk = int((i+(digit-1)) / digit)\nnum = (10 ** (digit-1)) + (k-1)\nj = digit - ((i + digit-1) % digit) - 1\nwhile j > 0:\n num = int(num/10)\n j -= 1\nprint(num%10)\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 = int(input())-1\nx, y = 1, 9\nwhile n > x * y: n,x,y = n-x*y,x+1,y*10\na = str(10 ** (x - 1) + n // x)[n%x]\nprint(a)"}], "negative_code": [{"source_code": "while (True):\n k=int(input('donner k'))\n if (k>=1) or (k<=10000):\n break\nch=''\nfor i in range (1,k+1) :\n ch+=str(i)\nprint(ch)\nprint(ch[k-1])\n"}, {"source_code": "import math \n \ndef countDigit(n): \n\treturn math.floor(math.log(n, 10)+1)\n\n\n\nn=int(input())\ncount=countDigit(n)\nif count==1:\n\tprint(n)\nelse:\n\tlow=1\n\thigh=9\n\tsum=[]\n\tsum.append(9)\n\tfor i in range(1,16):\n\t\tlow=low*10\n\t\thigh=high*10+9\n\t\tsum.append((high-low+1)*2+sum[i-1])\n\t\tif n=(9*(i+1)*(10**i)):\n\tn-=(9*(i+1)*(10**i))\n\ti+=1\n\tprint (n)\na=int(pow(10,i))+int(n/(i+1))\n# print (a)\nprint(str(a)[n%(i+1)])"}, {"source_code": "def size_of_group(i):\n if i == 1:\n return 10\n else:\n return long(9 * 10**(i-1))\n\ndef find_group(k, i = 1):\n diff = long(k - size_of_group(i))\n if diff <= 0:\n return k, i\n return find_group(diff, i + 1)\n\ndef get_number(k, g):\n return str(long(size_of_group(g - 1) + long(k / g)))[k % g]\n\ndef get_sequence_number(num):\n \"\"\"https://codeforces.com/problemset/problem/1177/B\"\"\"\n k_prim, g_prim = find_group(num)\n return get_number(k_prim, g_prim)\n\n# run program\nif __name__ == \"__main__\":\n n = get_sequence_number(long(input()))\n print(n)"}, {"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()\ns=''\nfor i in range(1,1001):\n s+=str(i)\nprint(s[n])"}, {"source_code": "\n\nn=int(input())\nx=1\nwhile n>(10**len(str(x))*9):\n n-=10**len(str(x))*9\n \n x*=10\nwhile n>len(str(x)):\n n-=len(str(x))\n x+=1\nfor i in range(len(str(x))):\n if n!=0:\n s=str(x)[i]\n n-=1\n\nprint(s)\n \n"}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x=10000:\n k=k//int(math.log(k,10))\n#print(k)\nfor i in range(1,k+1):\n s+=str(i)\nprint(s[k-1])\n"}, {"source_code": "bl=\"\"\nfor i in range(1,20000): \n bl+=str(i)\nn=int(input())\nif n>20000:\n print(1)\nelse:\n print(bl[n-1])"}, {"source_code": "n=int(input())\nst=\"\"\nfor i in range(1,n+1):\n st+=str(i)\nprint(st)\nprint(st[n-1])\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 global x\n k = get_int()\n y, z = 0, 0\n for x in range(13):\n y += 9*(10**x)*(x+1)\n if y > k:\n break\n z += 9*(10**x)\n y = k - (y - 9*(10**x)*(x+1))\n x = x+1\n #print(y,x)\n no = z + (y-1)//x + 1\n dig = (y-1) % x\n print(str(no)[dig])\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": "a= int(input())\ni=1\namount=a\nwhile amount>i*((10**i)-(10**(i-1))):\n amount =amount - i*((10**i)-(10**(i-1)))\n i=i+1 \nx= amount//i\ny=amount%i\n# print(amount)\n# print(i)\n# print(x)\n# print(y)\nif y==0: \n if i==1:\n print(x%10)\n else:\n print(((10**(i-1)-10**(i-2)) + x)%10)\nelse:\n if i==1:\n print(x%10)\n else:\n print(((10**(i-1) + x)//(10**(i-y)))%10)"}, {"source_code": "n=int(input())\nif (n<=9):\n print(n)\nelse:\n i=0\n while (n-9*10**(i)>0)&(i<=11):\n n=n-9*10**(i)\n i=i+1\n r=n%(i+1)\n if n<(i+1):\n p=n\n else:\n p=n//(i+1)\n ch=str(9*10**(i-1) + p)\n print(ch[i-r])\n\n \n"}, {"source_code": "k=int(input())\na=\"\"\nfor i in range(k):\n a=a+str(i+1)\nprint(a[k-1])\nprint(a)"}, {"source_code": "def whereis(k):\n n = 1\n while k > 0:\n k -= 9*10**(n-1)*n\n n+=1\n else:\n n-= 1\n return n\n\ndef kthdigit(k):\n a = whereis(k)\n sequence = ''\n sum = 0\n for b in range(1, a):\n sum += 9*10**(b-1)*b\n \n for x in range(10**(a-1), 10**(a)):\n sequence += str(x)\n return sequence[k-sum-1]\n \n\n \n "}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x=2889):#less than 1000\n r=(k-189)%3\n if r==0:\n x=str((k-189)/3+99)\n print(x[2:3])\n elif(r==1):\n x =str((k-189)//3+100)\n print(x[0:1])\n else:\n x=str((k-189)//3+100)\n print(x[1:2])\nelse:\n r=(k-2889)%4\n if r==0:\n x=str((k-2889)/4+999)\n print(x[3:4])\n else:\n x=str((k-2889)//4+1000)\n if r==1:\n print(x[0:1])\n elif(r==2):\n print(x[1:2])\n else:\n print(x[2:3])\n\n"}, {"source_code": "def ans(n):\n s=\"\"\n i=1\n while(len(s)20000:\n if int(n)==100000:\n print(2)\n else:\n print(1)\nelse:\n print(bl[n-1])"}, {"source_code": "digit=1\nx=int(input())\nstart_range=1\nend_range=9\nnine=9\ntotal=0\nwhile(x>end_range):\n start_range=end_range+1\n digit+=1\n end_range=nine*start_range\n total=total+start_range\ntotal+=(digit*start_range)\nstring=''\nj=start_range\n\nfor i in range(x):\n string+=str(j)\n j+=1\nprint(string[x-start_range])"}, {"source_code": "n = int(input())\ncounter = 0\ncur_number = 0\ncur_array = list()\nwhile counter < n:\n cur_number += 1\n cur = cur_number\n result = 0\n cur_array = list()\n while cur > 0:\n cur_array.append(cur % 10)\n cur //= 10\n cur_array.reverse()\n for i in cur_array:\n result = i\n print(result)\n counter += 1\n if counter == n:\n break\nprint(result)\n"}, {"source_code": "num = \"\"\ncount = 1\nk = int(input())\nwhile len(num) <= k:\n num += str(count)\n count += 1\nprint(num)\nprint(num[k-1])"}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x=r):\n r+=9*(i+1)*10**i\n i+=1\nr=r-(9*i*10**(i-1))\nans=str(((k-r)//i)+10**(i-1))[(k-r)%i]"}, {"source_code": "# @author \n\nimport sys\n\nclass ADigitsSequenceEasyEdition:\n def solve(self):\n k = int(input())\n p = 1\n c = 0\n while c + p * (10 ** p) < k:\n c += p * 10 ** p\n p += 1\n k -= (c - 1)\n bef = (10 ** (p - 1) if p > 1 else 0) + (k - 1) // p\n i = (k - 1) % p\n print(str(bef)[(k - 1) % p])\n\n\nsolver = ADigitsSequenceEasyEdition()\ninput = sys.stdin.readline\n\nsolver.solve()\n"}, {"source_code": "from math import log\nn = int(input())\nr = int(log(n,10))\nk = n - pow(10,r)+1\nt = k//(r+1)\nf_ = 10**(r)+t\nif k%(r+1) == 0:\n\tprint(f_%(10))\nelse:\n\tf_ = 10**(r)+t+1\n\tm = str(f_)\n\tprint(f_[k%(r+1)-1])"}, {"source_code": "from math import log\nn = int(input())\nr = int(log(n,10))\nk = n-pow(10,r)+1\nnum = pow(10,r)-1\nt = k//(r+1)\nnum = num + t\nif k%(r+1) == 0:\n\tprint((num)%10)\nelse:\n\tnum = num + 1\n\tm = str(num)\n\tprint(m[k%(r+1)-1])"}, {"source_code": "n=input()\ni=0\nwhile(True):\n if (n-9*10**i)<=0:\n break\n n-=9*10**i\n i+=1\n\na=n/(i+1)\nb=n%(i+1)\nif(b!=0):\n print(str(10**i+a)[b-1])\nelse:\n print(str(10**i+a-1)[-1])\n"}, {"source_code": "#digits sequence(Hard Edition)\n\nn = int(input())\n\ncheck = True\nt=0\ntnext=9\nsm1=0\ncount=1\ni=2\nj=10\nres = 0\nwhile(check):\n \n if(n<=tnext):\n res=n-t\n check = False\n\n else:\n sm1 = sm1+t\n count = count+1\n\n if(t!=0):\n t=t*i*j\n else:\n t=9\n tnext = tnext * (i+1)*(j*10)\n i=i+1\n j=j*10\n \nnum1 = int(res/count)\nnum2 = res%count\n\n\nprint(count , t ,tnext , sm1)\n\n\ndes = pow(10,count-1)\ndespac = des + num1 \n\n\nprint(despac)\n\nif(num2 == 0):\n despac = str(despac -1)\n print(despac[-1])\n\nelse :\n despac = str(despac)\n print(despac[num2-1])\n"}, {"source_code": "from math import log\nk=int(input())\nr=k\nl=1\nt=int(log(10))\nwhile 1:\n\tm=(l+r)//2\n\tx=int(log(m)/t)\n\td=((1-10**(x+1))//9) + (m+1)*(x+1)\n\tif 0<=(k-d)<=13:\n\t\tbreak\n\telif d>k:\n\t\tr=m-1\n\telse:\n\t\tl=m+1\nif d==k:\n\tprint(str(m)[-1])\n\texit()\nst=\"\"\n\t\t\nv=k-d\nm+=1\nfor i in range(13):\n\tst+=str(m)\n\tm+=1\nprint(st[v-1])\n\n\n\t"}, {"source_code": "k = int(input())\nif (k < 10):\n print(k)\n quit()\nc=0\nn=k\nwhile (n > 0):\n c+=1\n sub = 10 ** c - 1\n n = (k - sub*c) / (c+1) + sub\n if (n < 10 ** (c+1)):\n if (int(n) == n):\n print(int(n%(10**c)))\n exit()\n else:\n print(int((int(n)+1)/(10**c)))\n exit()\n"}, {"source_code": "# Digits Sequence 1177A\nnatural_num = \"\"\nfor i in range(1, 1001):\n\tnatural_num += str(i)\n\n\nlist_each_digit = []\nlist_each_digit.append(0)\nfor letter in natural_num:\n\tlist_each_digit.append(letter)\n\nprint(list_each_digit)\n\ninput_index = int(input())\n\nprint(int(list_each_digit[input_index]))\n\n"}, {"source_code": "k=int(input(''))\nch=''\nfor i in range (1, k + 1):\n if (len(ch)20000:\n if int(n)==100000:\n print(2)\n else:\n print(1)\nelse:\n print(bl[n-1])"}, {"source_code": "l = []\nfor i in range(10000):\n l.append(i)\nlist(''.join(map(str, l)))\n\na = int(input())\nprint(l[a])\n"}, {"source_code": "num = \"\"\ncount = 1\nk = int(input())\nwhile len(num) <= k:\n num += str(count)\n count += 1\nprint(num)\nprint(num[k-1])"}, {"source_code": "n=int(input())\nif (n<=9):\n print(n)\nelse:\n i=0\n while (n-9*10**(i)*(i+1)>0)&(i<=11):\n n=n-9*10**(i)*(i+1)\n i=i+1\n\n r=n%(i+1)\n p=n//(i+1)\n ch=str(9*10**(i-1)+p+r)\n print(ch[i-r])\n\n \n"}, {"source_code": "k=int(input())\na=\"\"\nfor i in range(k):\n a=a+str(i+1)\nprint(a[k-1])\nprint(a)"}, {"source_code": "n = int(input())\nif n <=9:\n print(n)\nelif n<=189:\n n -= 9\n a = n/2\n b = n%2\n if b==1:\n print(str(9+a+1)[0])\n else:\n print(str(9+a)[1])\nelif n<=2889:\n n -=189\n a = n/3\n b = n%3\n if b>0:\n print(str(99+a+1)[b-1])\n else:\n print(str(99+a)[-1])\nelif n<=38889:\n n -=2889\n a = n/4\n b = n%4\n if b>0:\n print(str(999+a+1)[b-1])\n else:\n print(str(999+a)[-1])\nelse:\n n -= 38889\n a = n / 5\n b = n % 5\n if b > 0:\n print(str(9999 + a + 1)[b - 1])\n else:\n print(str(9999 + a)[-1])"}, {"source_code": "def decimal2Str(a : int):\n x = list()\n while a > 0:\n x = [str(a % 10)] + x\n a = int(a/10)\n return x\nk = int(input())\nindex,adddigit = 1, 1\nans = []\ntmp = k\nwhile tmp >= adddigit:\n ans = ans + decimal2Str(index)\n index+=1\n tmp -= adddigit\n if index >= (10 ** adddigit):\n adddigit += 1\nprint(ans[-1])"}, {"source_code": "k = int(input())\nif k <= 9:\n print(k)\nelse:\n length = len(str(k))\n s = \"\"\n num = 0\n for i in range(length - 1):\n s = s + \"1\"\n #print(s)\n previous_value = 9 * int(s)\n for i in range(length - 1):\n num += (9*(10**i))*(i + 1)\n\n try_value = k - num\n #print(try_value)\n #print(previous_value)\n if try_value % length == 0:\n div_value = try_value // length\n temp_string = str(previous_value + div_value)\n print(temp_string[len(temp_string) - 1])\n else:\n div_value = (try_value // length) + 1\n temp_string = str(previous_value + div_value)\n differ = (div_value * length) - try_value\n print(temp_string[len(temp_string) - differ - 1])"}, {"source_code": "from math import ceil \nn=int(input())\nif n<=9:\n print(n)\nelse:\n d=2\n ov=9\n while n>d*9*(10**(d-1))+ov:\n ov=d*9*(10**(d-1))+ov\n d+=1\n v=ceil((n-ov)/d)+int('9'*(d-1))\n print(str(v)[(n-ov-1)%d])"}, {"source_code": "k = int(input())\n\nmul = 1\ncount=0\nd = 1\n\nwhile k>mul*9*d:\n k-=mul*9*d\n count+=mul*9*d\n d+=1\n mul*=10\n \n\nx = k%d\ny = k//d\ny+=mul\n\nif x==0:\n print((y-1)%10)\nelse:\n print((y)//pow(10,d-x))"}, {"source_code": "import sys\n\nk = int(input())\nd = [0]\nfor i in range(1, 12):\n d.append((10 ** i - 10 ** (i - 1)) * i + d[i - 1])\nprint(d)\nfor i in range(1, len(d)):\n if k <= d[i]:\n f = d[i - 1]\n f1 = 10 ** (i - 1)\n # print(i, f)\n # print(str(((k - f - 1) // i) + f1))\n print(str(((k - f - 1) // i) + f1)[(k - f - 1) % i])\n sys.exit()\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 global x\n k = get_int()\n y, z = 0, 0\n for x in range(13):\n y += 9*(10**x)*(x+1)\n if y > k:\n break\n z += 9*(10**x)\n y = k - (y - 9*(10**x)*(x+1))\n x = x+1\n #print(y,x)\n no = z + (y-1)//x + 1\n dig = (y-1) % x\n print(str(no)[dig])\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": "k=int(input(''))\nch=''\nfor i in range (1, k + 1):\n if (len(ch) k:\n length = i + 2\n break\n\n for i in range(length - 1):\n s = s + \"1\"\n #print(s)\n\n previous_value = 9 * int(s)\n try_value = k - num\n #print(try_value)\n #print(previous_value)\n #print(length)\n if try_value % length == 0:\n div_value = try_value // length\n temp_string = str(previous_value + div_value)\n print(temp_string[len(temp_string) - 1])\n else:\n div_value = (try_value // length) + 1\n temp_string = str(previous_value + div_value)\n differ = (div_value * length) - try_value\n print(temp_string[len(temp_string) - differ - 1])\n"}, {"source_code": "import os\nk = int(input()) \nstring = \"\"\ni=0\nwhile len(string)= k : flag = False\n\np = len(x)\n\nbase = sum(x) - x[p-1]\nr = k - base\nd = -((-r)//p)\ndd = r%p\nif dd==0: dd=p\n\nnumber = str(base + d)\ndigit = number[dd-1]\n\n# print(number)\nprint(digit)\n"}, {"source_code": "k=int(input())\na=[]\nfor i in range(0,12):\n s=9*pow(10,i)*(i+1)\n if k<=s:\n break\n else:\n k-=s\npos=i+1\nnum=(pow(10,pos-1)+(k//pos)-1)\nif k%pos==0:\n print(str(num+1)[-1])\nelse:\n print(str(num+1)[(k%pos)-1])\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--------------------------------------#\nn = get_int()\nend = 0\ndigit = 0\n\nwhile True:\n digit += 1\n a = 10**(digit-1)\n b = int('9'*digit)\n start = end+1\n end = b*digit\n if n <= end:\n break\n\nterm = str( a + ( (n-start+1)//digit - 1) )\n#print(term)\n#print('digit: ',digit)\nrem = (n-start+1)%digit\n#print(rem-1)\nprint(term[rem-1])\n\n\n"}, {"source_code": "k=int(input())\ns=''\nfor i in range(k):\n s+=str(i)\nprint(s[k-1])"}, {"source_code": "l = []\nfor i in range(10000):\n l.append(i)\nlist(''.join(map(str, l)))\n\na = int(input())\nprint(l[a])\n"}, {"source_code": "k=int(input())\n\ns=\"\"\nfor i in range(1,10000):\n\ts=s+str(i)\nif k>len(s):\n\tprint(\"out\")\nelse:\n\tprint(s[k-1])"}, {"source_code": "n=int(input())\nif (n<=9):\n print(n)\nelse:\n i=0\n while (n-9*10**(i)*(i+1)>0)&(i<=11):\n n=n-9*10**(i)*(i+1)\n i=i+1\n\n r=n%(i+1)\n p=n//(i+1)\n ch=str(9*10**(i-1)+p+r)\n print(ch[i-r])\n\n \n"}, {"source_code": "digit = int(input())\n\nif int(digit) <= 9:\n print(digit)\n exit()\n\nstart_range = 1\nend_range = 9\n\npower = 1\ndigit_count = 2\nwhile not (start_range <= digit and digit <= end_range):\n start_range = end_range + 1\n end_range = 9 * 10**power * digit_count + start_range - 1\n power += 1\n digit_count += 1\n\noffset_number = (digit - start_range) // (digit_count - 1)\n#print(f\"{digit} - {start_range} mod {digit_count-1} = {offset_number}\")\nnumber = str(10**(power - 1) + offset_number)\n#print(f\"10^ {power - 1} + {offset_number} = {number}\")\noffset_digit = (digit - start_range) % (digit_count - 1)\n#print(f\"{digit} - {start_range} mod {digit_count - 1 } = {offset_digit}\")\n#print(f\"{number} {number[-offset_digit]}\")\nprint(f\"{number[-offset_digit]}\")\n"}, {"source_code": "def move():\n print \"moved!\"\n \nmove()"}, {"source_code": "k=int(input())\nif (k<=9):\n print(k)\nelif(k<=189):#no. less than 100\n if ((k-9)%2==0):\n r=(k-9)/2\n x=str(r+9)\n print(x[1:2])\n else:\n r=(k-9)//2\n x=str(r+10)\n print(x[0:1])\nelif(k>=2889):#less than 1000\n r=(k-189)%3\n if r==0:\n x=str((k-189)/3+99)\n print(x[2:3])\n elif(r==1):\n x =str((k-189)//3+100)\n print(x[0:1])\n else:\n x=str((k-189)//3+100)\n print(x[1:2])\nelse:\n r=(k-2889)%4\n if r==0:\n x=str((k-2889)/4+999)\n print(x[3:4])\n else:\n x=str((k-2889)//4+1000)\n if r==1:\n print(x[0:1])\n elif(r==2):\n print(x[1:2])\n else:\n print(x[2:3])\n\n"}, {"source_code": "t=int(input())\ns=\"\"\nfor x in range(1,10001):\n s=s+str(x) \nprint(s[t-1])\nprint(len(s)) \n \n \n"}, {"source_code": "def generate(n, x):\n a = 10 ** (n - 1)\n a += x\n return a\n\n\ndef solve(k):\n k -= 1\n if k <= 9:\n return str(k + 1)\n n = 1\n while k - n * 9 * 10 ** (n - 1) >= 0:\n k -= n * 9 * 10 ** (n - 1)\n n += 1\n a = generate(n, k / n)\n return str(a)[k % n]\n\n\n# print solve([100] * 11)\nn = input()\nprint solve(n)\n"}, {"source_code": "def sequence(n):\n s = ''\n for i in range(10000):\n s += str(i)\n return s[n - 1]\n\n\nprint(sequence(int(input())))\n"}, {"source_code": "def f(n):\n kakn = 9\n chisl = 1\n while kakn < n:\n kakn+=((9*10**chisl)*(chisl+1))\n chisl+=1\n if n-kakn == 2:\n return 0\n t=10**(chisl-1)\n n-=t\n p=n//chisl\n u = n%chisl\n o = str(t+p)\n return o[u]\nn = int(input())\nprint(f(n))"}, {"source_code": "n=input()\ni=0\nwhile(True):\n if (n-9*10**i)<=0:\n break\n n-=9*10**i\n i+=1\n\na=n/(i+1)\nb=n%(i+1)\nif(b!=0):\n print(str(10**i+a)[b-1])\nelse:\n print(str(10**i+a-1)[-1])\n"}, {"source_code": "k = int(input())\nl=[]\nfor i in range(10000):\n l.extend(str(i))\nprint(len(l))"}, {"source_code": "#Bhargey Mehta (Junior)\n#DA-IICT, Gandhinagar\nimport sys, math, queue, bisect\n#sys.stdin = open('input.txt', 'r')\nMOD = 998244353\nsys.setrecursionlimit(1000000)\n\nn = int(input())\nif n < 10:\n print(n)\n exit()\nn += 1\nd = 1\nwhile n > 9*pow(10, d-1):\n n -= 9*pow(10, d-1)\n d += 1\nx = pow(10, d-1) + n//d - 1\nprint(str(x)[n%d])"}, {"source_code": "n=int(input())\nif (n<=9):\n print(n)\nelse:\n i=0\n while (n-9*10**(i)>0)&(i<=11):\n n=n-9*10**(i)\n i=i+1\n r=n%(i+1)\n if n<(i+1):\n p=n\n else:\n p=n//(i+1)\n ch=str(9*10**(i-1) + p)\n print(ch[i-r])\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 integers\nget_int = lambda: int(sys.stdin.readline())\n#to print fast\npt = lambda x: sys.stdout.write(str(x)+'\\n')\n\n#--------------------------------WhiteHat010--------------------------------------#\nn = get_int()\nend = 0\ndigit = 0\n\nwhile True:\n digit += 1\n a = 10**(digit-1)\n b = int('9'*digit)\n start = end+1\n end = b*digit\n if n <= end:\n break\n\nif (n-start+1)%digit != 0:\n x = 1\nelse:\n x = 0\nterm = str( a + ( (n-start+1)//digit + x -1) )\n#print(n-start+1)\n#print('Term: ',term)\nrem = (n-start+1)%digit\n#print(rem-1)\nprint(term[rem-1])\n\n\n"}, {"source_code": "digit=1\nx=int(input())\nstart_range=1\nend_range=9\nnine=9\ntotal=0\nwhile(x>end_range):\n start_range=end_range+1\n digit+=1\n end_range+=digit*nine*start_range\n total=total+start_range\ntotal+=(digit*start_range)\nindex=end_range-x\nminus=int(index/2)\nindex%=2\nlast_number=pow(10,digit)-1\nlast_number-=minus\nstring=str(last_number)\nprint(string[len(string)-index-1])"}, {"source_code": "n = int(input())\ndef exp_(i):\n\treturn (9*pow(10,i)*i-(10**i)+1)//9\ni = 1\nwhile True:\n\tv = exp_(i)\n\tif v >= n:\n\t\tbreak\n\ti = i + 1\nif n == v:\n\tprint(\"9\")\nelse:\n\tn = n - exp_(i-1)\n\tnum = 10**(i-1) - 1\n\tnum = num + n//(i)\n\tr = n%(i)\n\tif r > 0:\n\t\tnum = num + 1\n\t\tf = str(num)\n\t\tprint(f[r-1])\n\n\n\n\t"}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x 0):\n c+=1\n sub = 10 ** c - 1\n n = (k - sub*c) / (c+1) + sub\n if (n+1 <= 10 ** (c+1)):\n if (int(n) == n):\n print(int(n%(10**c)))\n exit()\n else:\n print(int((int(n)+1)/(10**c)))\n exit()\n"}, {"source_code": "k = int(input())\ncount = 1\nnumber = 1\nresult = 0\nnumber1 = 1\nwhile True:\n if number == 1:\n if result + 9 < k:\n result += 9\n number = 20\n number1 = 10\n else:\n break\n elif number == 20:\n if result + 180 < k:\n result += 180\n number += 10\n number1 = 100\n else:\n break\n else:\n if result + 10 * number * 9**count < k:\n result += 10 * number * 9**count\n number += 10\n count += 1\n number1 *= 10\n else:\n break\n\nwhile True:\n if count == 0:\n break\n if result + 10 * number * 9**(count - 1) < k:\n result += 10 * number * 9 ** (count - 1)\n number1 += 100 * 10**(count - 1)\n else:\n count -= 1\n\nwhile True:\n if number == 1:\n break\n if result + number < k:\n result += number\n number1 += 10\n else:\n break\n\nwhile True:\n if result + len(str(number1)) >= k:\n print(str(number1)[k - result - 1])\n break\n else:\n number1 += 1\n result += len(str(number1))"}, {"source_code": "n = int(input())\ndef exp_(i):\n\treturn (9*pow(10,i)*i-(10**i)+1)//9\ni = 1\nwhile True:\n\tv = exp_(i)\n\tif v >= n:\n\t\tbreak\n\ti = i + 1\nif n == v:\n\tprint(\"9\")\nelse:\n\tn = n - exp_(i-1)\n\tnum = 10**(i-1) - 1\n\tnum = num + n//(i)\n\tr = n%(i)\n\tif r > 0:\n\t\tnum = num + 1\n\t\tf = str(num)\n\t\tprint(f[r-1])\n\n\n\n\t"}, {"source_code": "k = int(input()) - 1\n\nl = 1\nc = 9\nwhile k >= c:\n k -= c \n l += 1\n c *= 10\n\nc = 10**(l-1) + k / l\nprint(str(c)[k % l])\n"}, {"source_code": "N = int(input())\nbeg = 0\nend = 9\ni = 0 # \u0432 \u0441\u043a\u043e\u043b\u044c\u043a\u0438 \u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430\u0445 \u043c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f - 1\n\n\nwhile N > end:\n i += 1\n beg, end = end, end + (i + 1) * 9 * 10**i\n\nn = N - beg - 1 # \u044d\u0442\u043e N \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0447\u0438\u0441\u0435\u043b \u0441 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 i, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 0\nlvl = i - n % (i + 1) # \u043d\u043e\u043c\u0435\u0440 \u0441\u0438\u043c\u0432\u0430\u043b\u0430, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u043e\u0442 \u043a\u043e\u043d\u0446\u0430 \u0447\u0438\u0441\u043b\u0430\nperiod = (i + 1) * 10**lvl # \u043f\u0435\u0440\u0438\u043e\u0434 \u0441\u043c\u0435\u043d\u044b \u0447\u0438\u0441\u043b\u0430\n\nres = n//period\nif lvl == i:\n res += 1\nprint(res)\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-----------------------------------------------------\na=[0,9]\nfor i in range (1,11):\n d=(i+1)*(9*10**i)\n a.append(a[-1]+d)\n#print(a)\nk=int(input())\nc=-1\nfor i in range (12):\n if k1:\n k+=9*10**(i-2)\n #print(k)\n if m==0:\n c=int(str(k)[-1])\n else:\n k+=1\n c=int(str(k)[m-1])\n break\nprint(c)"}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x= k : flag = False\n\np = len(x)\n\nbase = sum(x) - x[p-1]\nr = k - base\nd = -((-r)//p)\ndd = r%p\nif dd==0: dd=p\n\nnumber = str(base + d)\ndigit = number[dd-1]\n\n# print(number)\nprint(digit)\n"}, {"source_code": "k = int(input())\nif (k < 10):\n print(k)\nc=0\nn=k\nwhile (n > 0):\n c+=1\n sub = 10 ** c - 1\n n = (k - sub*c) / (c+1) + sub\n if (n < c ** 10):\n if (int(n) == n):\n print(int(n%(10**c)))\n break\n else:\n print(int((int(n)+1)/(10**c)))\n break\n"}, {"source_code": "n=int(input())\nif (n<=9):\n print(n)\nelse:\n i=0\n while (n-9*10**(i)>0)&(i<=11):\n n=n-9*10**(i)\n i=i+1\n r=n%(i+1)\n p=n//(i+1)\n ch=str(9*10**(i-1) + p)\n print(ch[i-r])\n\n \n"}, {"source_code": "k = int(input())\nn = 1\n\nfor i in range(1, 20):\n if k < n + 9 * 10 ** (i - 1) * i:\n print((10 ** (i - 1) + (k - n) // i) % 10)\n break\n n += 9 * 10 ** (i - 1) * i\n\n"}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x0)&(i<=11):\n n=n-9*10**(i)*(i+1)\n i=i+1\n \n r=n%(i+1)\n p=n//(i+1)\n d=10**(i)+p-1\n if(r!=0):\n d=d+1\n ch=str(d) \n print(ch)\n print(ch[r-1])\n\n \n"}, {"source_code": "def whereis(k):\n n = 1\n while k > 0:\n k -= 9*10**(n-1)*n\n n+=1\n else:\n n-= 1\n return n\n\ndef kthdigit(k):\n a = whereis(k)\n sequence = ''\n sum = 0\n for b in range(1, a):\n sum += 9*10**(b-1)*b\n \n for x in range(10**(a-1), 10**(a)):\n sequence += str(x)\n return sequence[k-sum-1]\n \n\n \n "}, {"source_code": "k=int(input())\nx=0\nc=0\nwhile(x 2:\n\tprint 1\nelse:\n\tprint n"}, {"source_code": "n=int(input())\nprint(1 if n!=2 else 2)"}, {"source_code": "n=input()\nprint (1,n)[n<3]"}, {"source_code": "inp = int(input())\nif inp == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "if input() == '2':\n print('2')\nelse:\n print('1')"}, {"source_code": "n = int(input())\nif n==2:\n\tprint(2)\nelse:print(1)\t"}, {"source_code": "n = int(input(\"\"))\nif n == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "n = input()\nif n ==2:\n print 2\nelse:\n print 1"}, {"source_code": "import os\nimport sys\nfrom collections import deque\nimport pdb\nimport heapq\nfrom heapq import *\nfrom pprint import pprint\nfrom bisect import *\nfrom math import *\nsys.setrecursionlimit(999999999)\nif(os.getcwd() == 'C:\\\\Users\\\\User\\\\Desktop\\\\python\\\\Prog'):\n pdb = pdb.Pdb(stdin=sys.stdin, stdout=sys.stdout)\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\n\n\ndef rI():\n return [int(i) for i in input().split()]\n\n\nn = rI()[0]\nif(n <= 2):\n print(n)\nelse:\n print(1)\n"}, {"source_code": "x = int(input())\nif x != 2:\n print(\"1\")\nelse:\n print(\"2\")\n"}, {"source_code": "n = int(input())\nif n == 2:\n print(\"2\")\nelse:\n print(1)\n\n "}, {"source_code": "__author__ = 'Obriel Muga'\n\ndef resolve(valor_inicial, valor_actual):\n if (valor_actual == 1):\n return 1\n elif (valor_actual == 2):\n return 2\n else:\n for i in range(valor_actual - 1, 1 , -1):\n if (valor_inicial % i != 0):\n return resolve(valor_inicial,valor_actual - i)\n\n\n\nif __name__ == \"__main__\":\n n = int(input())\n print(resolve(n,n))\n"}, {"source_code": "print [1,2][input()==2]"}, {"source_code": "v=int(input())\nif v==1:\n print(1)\n exit(0)\nelif v==2:\n print(2)\n exit(0)\nfor i in range(v-1,0,-1):\n if v%i!=0:\n print(v-i)\n break"}, {"source_code": "a = int(input())\nif(a==2):\n print(2)\nelse:\n print(1)"}, {"source_code": "def play(v):\n if v>2:\n return 1\n else:\n return v\n\ninput = int(input())\nprint(play(input))\n"}, {"source_code": "n = int(input())\nif n == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "n = int(input())\n\nif( n == 2 ): print(2)\nelse: print(1)"}, {"source_code": "n = int(input())\nif n == 2:\n print(\"2\")\nelse:\n print(\"1\")"}, {"source_code": "n=int(input())\nif(n==1):\n print(1)\nelif(n==2):\n print(2)\nelse:\n print(1)"}, {"source_code": "inp = int(input())\nif inp == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "\nn=int(input())\nif(n==2):\n print(2)\nelse:\n print(1)"}, {"source_code": "\nv=input()\nif v<3: print v\nelse: print 1"}, {"source_code": "n=int(input())\nif n==2:\n print(\"2\")\nelse:\n print(\"1\")"}, {"source_code": "n = int(input())\nif n > 2: print 1\nelse: print n"}, {"source_code": "from sys import stdin\nn = int(stdin.readline())\nif n==2:\n print 2\nelse:\n print 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 \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 \"\"\"\n dict() -> new empty dictionary\n dict(mapping) -> new dictionary initialized from a mapping object's\n (key, value) pairs\n dict(iterable) -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\n dict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)\n \"\"\"\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 print(1 if int(input()) != 2 else 2)\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "def game(n):\n if int(n) == 2:\n print(n)\n else:\n print(1)\n\nw = input()\ngame(w)"}, {"source_code": "n=int(input())\nif n==2:\n print(\"2\")\nelse:\n print(\"1\")"}, {"source_code": "inp = int(input())\nif inp == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "n = int(input())\nif n == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "n=int(input())\nif(n==2):\n\tprint(2)\nelse:\n\tprint(1)"}, {"source_code": "x=int(input())\nif x!=2:\n print(1)\nelse:\n print(2)\n"}, {"source_code": "n = int(input())\n\nif (n == 1 or n == 2):\n print(n)\nelse:\n print(1)"}, {"source_code": "n=int(input())\nif n>2 or n==1:\n\tprint(\"1\")\nelif n==2:\n\tprint(\"2\")"}, {"source_code": "a = int(input())\nif(a==2):\n print(2)\nelse:\n print(1)"}, {"source_code": "\ndef do():\n n = int(input())\n if n == 1:\n print(1)\n elif n == 2:\n print(2)\n else:\n print(1)\n\ndo()\n"}, {"source_code": "# cf 1081 A 800\nn = int(input())\nif n == 2:\n print(2)\nelse:\n print(1)\n"}, {"source_code": "n = int(input())\nif n==2:\n\tprint(2)\nelse:print(1)\t"}, {"source_code": "n = int(input())\n\nif( n == 2 ): print(2)\nelse: print(1)"}, {"source_code": "n = int(input())\nif n == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "# Contest: Avito Cool Challenge 2018 (https://codeforces.com/contest/1081)\n# Problem: A: Definite Game (https://codeforces.com/contest/1081/problem/A)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\nprint(1 if rint() != 2 else 2)\n"}, {"source_code": "n=int(input())\nif(n==2):\n print(n)\nelse:\n print(1)"}, {"source_code": "print(1 if (int(input())) is not 2 else 2)\n"}, {"source_code": "x = int(input())\nif(x==2):print (2)\nelse: print(1)\n\n"}, {"source_code": "if(int(input())==2):\n\tprint(2)\nelse:\n\tprint(1)\n"}, {"source_code": "n=int(input())\nif(n==2):print(2)\nelse:print(1)"}, {"source_code": "n = input()\nif n == \"2\": print(2)\nelse: print(1)"}, {"source_code": "n = int(input())\n\nif n==2:\n print(2)\nelse:\n print(1)"}, {"source_code": "t= int(input())\nif t!=2:\n print(\"1\")\nelse:\n print(\"2\")\n \n \n \n \n"}, {"source_code": "if int(input())==2:print(2)\nelse:print(1)"}, {"source_code": "a=int(input())\nif a==2:\n print(\"2\")\nelse:\n print(\"1\")"}, {"source_code": "a = int(input())\nif a == 2:\n\tprint(2)\nelse:\n\tprint(1)\n"}, {"source_code": "v=int(input())\nif v is 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "print(2if int(input())==2else 1)"}, {"source_code": "print(1+(int(input())==2))"}, {"source_code": "# Contest: Avito Cool Challenge 2018 (https://codeforces.com/contest/1081)\n# Problem: A: Definite Game (https://codeforces.com/contest/1081/problem/A)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\nprint(1 if rint() != 2 else 2)\n"}, {"source_code": "# Contest: Avito Cool Challenge 2018 (https://codeforces.com/contest/1081)\n# Problem: A: Definite Game (https://codeforces.com/contest/1081/problem/A)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\nprint(1 if rint() != 2 else 2)\n"}, {"source_code": "print(\"1\" if input() != \"2\" else \"2\")\n"}, {"source_code": "n=int(input())\nif n!=2:\n\tprint(1)\nelse:\n\tprint(n)"}, {"source_code": "a=int(input())\nprint(1 if a-1!=1 else a)"}, {"source_code": "n = int(input())\nif n == 2:\n print(2)\nelse:\n print(1)"}, {"source_code": "# You'll never get ahead of anyone as long as you try to get even with him. Lou Holtz\n# by : Blue Edge - Create some chaos\n\nv=int(input())\nprint(1 if v!=2 else 2)\n"}, {"source_code": "n=int(input())\nif n==2:print(\"2\")\nelse:print(\"1\")"}, {"source_code": "def f(n):\n if n==2:\n return 2\n else:\n return 1\nn=int(input())\nprint(f(n))"}, {"source_code": "if int(input()) != 2:\n print(1)\nelse:\n print(2)"}, {"source_code": "print(1+(int(input())==2))"}, {"source_code": "x = int(input())\nif x != 2:\n print(\"1\")\nelse:\n print(\"2\")\n"}, {"source_code": "t=input()\nif t!=2:\n print 1\nelse:\n print 2"}, {"source_code": "n=int(input())\nif n==1 or n==2:\n\tprint(n)\nelse:\n\tprint(1)\t\n"}, {"source_code": "a=int(raw_input())\nif a==2:\n\tprint 2\nelse:\n\tprint 1\n"}, {"source_code": "n = int(input())\nprint(2 if n == 2 else 1)"}, {"source_code": "import sys,math\nfrom fractions import gcd\nfrom collections import defaultdict\nfrom io import BytesIO\nimport hashlib\nsys.stdin = BytesIO(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\nn = int(input())\n#n,m = [int(x) for x in input().split(' ')]\n\nif n > 2:\n print(1)\nelse:\n print(n)"}, {"source_code": "import math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\nn=int(input())\n'''\na = map(int, raw_input().split())\n\ni=n-1\n\nbase=0\n\nprint(n+1)\n\nwhile i>=0 :\n\ta[i]+=base\n\tbase+=((i-a[i]%n)+n)%n\n\tans=((i-a[i]%n)+n)%n\n\tprint('1'),\n\tprint(i+1),\n\tprint(ans)\n\ti-=1\nprint('2'),\nprint(n),\nprint(n)\n'''\nif n!=2:\n\tprint(1)\nelse:\n\tprint(2)"}, {"source_code": "import os\nimport sys\nfrom collections import deque\nimport pdb\nimport heapq\nfrom heapq import *\nfrom pprint import pprint\nfrom bisect import *\nfrom math import *\nsys.setrecursionlimit(999999999)\nif(os.getcwd() == 'C:\\\\Users\\\\User\\\\Desktop\\\\python\\\\Prog'):\n pdb = pdb.Pdb(stdin=sys.stdin, stdout=sys.stdout)\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\n\n\ndef rI():\n return [int(i) for i in input().split()]\n\n\nn = rI()[0]\nif(n <= 2):\n print(n)\nelse:\n print(1)\n"}, {"source_code": "t=input()\nif t!=2:\n print 1\nelse:\n print 2"}, {"source_code": "n = int(input())\nif n == 2:\n print(\"2\")\nelse:\n print(1)\n\n "}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\nn=int(input())\nif n!=2:\n\tprint(1)\nelse:\n\tprint(2)\t"}, {"source_code": "n = int(input())\nif n!=2:\n print(1)\nelse:\n print(2)"}, {"source_code": "x = int(input())\n\nif x==2:\n print(x)\nelse:\n print(1)"}, {"source_code": "n = int(input());\nif n == 2:\n\tprint(2);\nelse:\n\tprint(1);\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 \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 \"\"\"\n dict() -> new empty dictionary\n dict(mapping) -> new dictionary initialized from a mapping object's\n (key, value) pairs\n dict(iterable) -> new dictionary initialized as if via:\n d = {}\n for k, v in iterable:\n d[k] = v\n dict(**kwargs) -> new dictionary initialized with the name=value pairs\n in the keyword argument list. For example: dict(one=1, two=2)\n \"\"\"\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 print(1 if int(input()) != 2 else 2)\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "N = int(raw_input())\nif N==2:\n print 2\nelse:\n print 1"}, {"source_code": "n = int(input())\nif n > 2:\n print(\"1\")\nelse:\n print(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 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>1\n return r\n \ndef solve():\n n=inp()\n if n<=2:\n print(n)\n else:\n print(1)\nfor _ in range(1):\n solve()\n \n"}, {"source_code": "print(2 if input() == '2' else 1)"}, {"source_code": "n = input()\nif n==2:\n print 2\nelse:\n print 1"}], "negative_code": [{"source_code": "n=int(input())\nprint(n-1)"}, {"source_code": "n=int(input())\nif(n>2):\n print(n-1)\nelse:\n print(n)"}, {"source_code": "v = int(input())\nprint(1)"}, {"source_code": "v = int(input())\nprint(1)"}, {"source_code": "import sys\n\npin = sys.stdin.readline\npout = sys.stdout.write\n\n\nran=range\nn=int(pin())\nprint(1)"}, {"source_code": "n=int(input())\nprint(1)"}, {"source_code": "v = int(input())\nprint(1)"}, {"source_code": "n = int(input())\nprint(1)"}, {"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 return 1\n\n# main()\nprint(main())\n"}, {"source_code": "n = int(input())\n\nif n == 1:\n\tprint(1)\nelse:\n\tif n % n-1 != 0:\n\t\tprint(1)\n\telse:\n\t\tprint(2)"}, {"source_code": "print(1)"}, {"source_code": "n=int(input())\n \n \nprint(1)\n \n \n"}, {"source_code": "input()\nprint(1)"}, {"source_code": "n=int(input())\nprint(\"1\")"}, {"source_code": "input(); print(1)"}, {"source_code": "print('1')"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nraw_input ()\nprint 1\n"}, {"source_code": "v=int(input())\nn=v;c=0\nif v==1:\n\tprint(\"1\")\n\texit()\nelse:\n\tfor x in range(v-1,2,-1):\n\t\tif x%v!=0:\n\t\t\tprint(x)\n\t\t\tc=x\n\t\t\tbreak\nprint(n-c)\n"}, {"source_code": "n=int(input())\nif n%2==0:\n print(n%3)\nelse:\n print(n%2)"}, {"source_code": "n=int(input(\"\"))\nprint(1)\nif(n==2):\n print(\"2\")\n"}, {"source_code": "n = int(input())\nprint(1)"}, {"source_code": "n=int(input())\nif n!=2:\n print(2)\nelse:\n print(1)"}, {"source_code": "t= int(input())\nprint(\"1\")\n \n \n \n \n"}, {"source_code": "v = int(input())\nif v == 1:\n print(1)\nelse:\n print(v / (v - 1))"}, {"source_code": "if (input() == 2):\n print('2')\nelse:\n print('1')"}, {"source_code": "import random\nimport time\n\nseed = int(time.time())\nrandom.seed(seed)\n\ndef solve(v):\n return 1\n\ndef main():\n v = int(raw_input().strip())\n print solve(v)\n\nif '__main__'==__name__:\n main()\n"}, {"source_code": "def definateGame(n):\n no = n\n for i in range(2,no-1):\n if no%i !=0 and no > 1:\n no -= i\n return no\n \nn = int(input())\nprint(definateGame(n))"}, {"source_code": "import sys\n\npin = sys.stdin.readline\npout = sys.stdout.write\n\n\nran=range\nn=int(pin())\nprint(1)"}, {"source_code": "x = int(input())\nif(x==1):\n print(1)\nelse:\n print(x-1)"}, {"source_code": "print(1)"}, {"source_code": "print 1"}, {"source_code": "def func(a):\n if a==1:\n return 1\n elif a==2:\n return 2\n elif a%2==0 and a>3:\n return func(a-(a//3)*3)\n else:\n return func(a-(a//2)*2)\nprint(func(int(input())))"}, {"source_code": "n=int(input())\nfor i in range(1,n+1):\n if n%i !=0:\n if n-i>0:\n n-=i\n else:\n break\n \nprint(n)\n \n \n"}, {"source_code": "n = int(input())\nprint(1)"}, {"source_code": "print(1)"}, {"source_code": "print(1)"}, {"source_code": "print(1)"}, {"source_code": "m=int(input())\nprint(1)"}, {"source_code": "print(1)\n"}, {"source_code": "value = input()\nprint(\"1\")\n\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nraw_input ()\nprint 1\n"}, {"source_code": "input(1)\n"}, {"source_code": "print(1)"}, {"source_code": "print(1)"}, {"source_code": "n=int(input())\ns=n\nl=[]\nfor i in range(1,n):\n\tif s%i!=0:\n\t\ts=s-i\n\t\tl.append(s)\n\t\tif s<1:\n\t\t\tprint(l[-2])\n\t\t\tbreak\nif n==1:\n\tprint(n)"}, {"source_code": "def main():\n v = int(input())\n print (1)\n\nmain()"}, {"source_code": "n = int(input()); print(n-1)"}, {"source_code": "n=int(input())\nif n==1 or n==2:\n\tprint(n)\nelse:\n\tprint(n-1)"}, {"source_code": "# https://codeforces.com/problemset/problem/1081/A\nn = input()\nprint(1)\n"}, {"source_code": "v = int(input())\nprint(1)\n"}, {"source_code": "v = int(input())\nprint(1)"}, {"source_code": "a = input()\nif a == 2:print(2)\nelse:print(1)\n"}, {"source_code": "print('1')"}, {"source_code": "_ = input()\nprint(1)\n"}, {"source_code": "def main():\n v = int(input())\n print(1)\n\nmain()"}, {"source_code": "n = int(input())\nprint(n if n == 2 or n == 3 else 1)\n"}, {"source_code": "n=input()\nprint(\"1\")"}, {"source_code": "print(1)"}, {"source_code": "def game(n):\n if n==1 or n==2:\n return n\n else:\n return 1\n\nw = input()\nprint(game(w))"}, {"source_code": "print(1)"}, {"source_code": "def play(v):\n\n print(1)\n"}, {"source_code": "# cf 1081 A 800\nn = int(input())\nprint(1)\n"}, {"source_code": "print(1)"}, {"source_code": "n=input()\nprint(1)"}, {"source_code": "#In the name of God\nn = int(input())\nprint(1)\n"}, {"source_code": "n=int(input())\nprint(1)"}, {"source_code": "n = int(input())\nif n == \"2\":\n print(2)\nelse:\n print(1)"}, {"source_code": "x=int(input())\nprint(1)\n"}, {"source_code": "n = input()\n\nresult = 2 if n == 2 else 1\nprint(result)"}, {"source_code": "def func(a):\n if a==1:\n return 1\n elif a==2:\n return 2\n elif a%2==0 and a>3:\n return func(a-(a//3)*3)\n else:\n return func(a-(a//2)*2)\nprint(func(int(input())))"}, {"source_code": "n=int(input())\nfor i in range(1,n+1):\n if n%i !=0:\n if n-i>=0:\n n-=i\n else:\n break\n \nprint(n)\n \n \n"}, {"source_code": "x = int(input())\nprint(\"1\")"}, {"source_code": "a=int(input())\nprint(1)"}, {"source_code": "def definateGame(n):\n no = n\n for i in range(2,no-1):\n if no%i !=0 and no > 1:\n no -= i\n return no\n \nn = int(input())\ndefinateGame(n)"}, {"source_code": "n = int(input())\nprint(\"1\")"}, {"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# from math import *\n# from itertools import *\n# import random\nn = int(input())\nv = n\nif n == 1:\n print(n)\nelse:\n for i in range(2, n):\n if v % i != 0:\n if i > v:\n print(v)\n break\n else:\n v -= i\n else:\n continue\n"}, {"source_code": "n=int(input())\nprint(1)"}, {"source_code": "x = int(input())\nprint(\"1\")"}, {"source_code": "v = int(input())\n\nif v != 2:\n print(1)\nelse:\n print(1)\n"}, {"source_code": "v=int(input())\nprint(\"1\")"}, {"source_code": "def main():\n print(1)\n\n\nmain()\n\n"}, {"source_code": "print(1)"}, {"source_code": "print(1)"}, {"source_code": "n=int(input())\nprint(1)\n"}, {"source_code": "def game(n):\n if n==1 or n==2:\n return n\n else:\n return 1\n\nw = input()\nprint(game(w))"}, {"source_code": "def smallest_n(n):\n return 1\n\nn = int(raw_input())\nprint(smallest_n(n))\n"}, {"source_code": "n = input()\n\nresult = 2 if n == 2 else 1\nprint(result)"}, {"source_code": "n=int(input())\nfor i in range(1,n+1):\n if n%i !=0:\n if n-i>0:\n n-=i\n else:\n break\n \nprint(n)\n \n \n"}, {"source_code": "print 1"}, {"source_code": "#-------------Program--------------\n#----Kuzlyaev-Nikita-Codeforces----\n#-------------Training-------------\n#----------------------------------\n\nv=int(input())\nprint(1)"}, {"source_code": "n = int(input())\nprint(n if n == 2 or n == 3 else 1)\n"}, {"source_code": "if (input() == 2):\n print('2')\nelse:\n print('1')"}, {"source_code": "input()\nprint(1)\n"}, {"source_code": "n = int(input())\nprint(1)"}, {"source_code": "_ = input()\nprint(1)\n"}, {"source_code": "print('1')"}, {"source_code": "print(1)"}, {"source_code": "print(\"1\")\n"}, {"source_code": "x = int(input())\nprint(\"1\")"}, {"source_code": "print(1)"}], "src_uid": "c30b372a9cc0df4948dca48ef4c5d80d"} {"nl": {"description": "Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year. In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.", "input_spec": "The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900\u2009\u2264\u2009yyyy\u2009\u2264\u20092038 and yyyy:mm:dd is a legal date).", "output_spec": "Print a single integer \u2014 the answer to the problem.", "sample_inputs": ["1900:01:01\n2038:12:31", "1996:03:09\n1991:11:12"], "sample_outputs": ["50768", "1579"], "notes": null}, "positive_code": [{"source_code": "months = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\ndef leap(y):\n return (y % 4 == 0 and y != 1900)\n\ndef days(y, m, d):\n count = 0\n for yx in xrange(1900, y):\n count += 366 if leap(yx) else 365\n for mx in xrange(1, m):\n count += months[mx] + (leap(y) and mx == 2)\n count += d - 1\n return count\n\nyx, mx, dx = (int(x) for x in raw_input().strip().split(':'))\nyy, my, dy = (int(x) for x in raw_input().strip().split(':'))\n\nprint abs(days(yx, mx, dx) - days(yy, my, dy))\n"}, {"source_code": "from datetime import *\nin_d = str(input()).split(':')\nfi_d =str(input()).split(':')\ndate_init=date(int(in_d[0]),int(in_d[1]),int(in_d[2]))\ndate_final=date(int(fi_d[0]),int(fi_d[1]),int(fi_d[2]))\nprint(abs(date_init-date_final).days)\n\n\n"}, {"source_code": "def get(y, m, d):\n if(m < 3):\n y -= 1\n m += 12\n return 365 * y + y // 4 - y //100 + y//400 + (153*m-457)//5+d-306\n\na1 = input().split(':')\na2 = input().split(':')\n\nprint(abs(get(int(a1[0]),int(a1[1]),int(a1[2])) - get(int(a2[0]),int(a2[1]),int(a2[2]))))\n"}, {"source_code": "def s():\n import datetime\n dt = datetime.datetime\n print(abs((dt(*list(map(int,input().split(':'))))-dt(*list(map(int,input().split(':'))))).days))\ns()\n"}, {"source_code": "m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nclass date():\n def __init__(self,d):\n b = map(int, d.split(':'))\n self.year = b[0]\n self.month = b[1]\n self.date = b[2]\n def isGreater(self, d):\n if d.year>self.year: return False\n if d.yearself.month: return False\n if d.monthself.date: return False\n else: return True\ndef isLeapYear(year):\n if year%100==0: return True if year%400==0 else False\n return True if year%4==0 else False\n\ndate1 = date(raw_input())\ndate2 = date(raw_input())\nif date1.isGreater(date2):\n date3 = date1\n date1 = date2\n date2 = date3\ndays = 0\nfor i in xrange(date1.year+1, date2.year):\n days += 366 if isLeapYear(i) else 365\n\nfor i in xrange(date1.month, 12 if date1.year!=date2.year else date2.month-1):\n days += m[i]\n\nif date1.year!=date2.year:\n for i in xrange(0, date2.month-1):\n days += m[i]\nif date1.year==date2.year and isLeapYear(date1.year):\n if date1.month<2 and date2.month>2:\n days+=1\nelse:\n if isLeapYear(date1.year) and date1.month<2: days+=1\n if isLeapYear(date2.year) and date2.month>2: days+=1\n\nif date1.year==date2.year and date1.month==date2.month:\n days += (date2.date-date1.date)\nelse:\n if date1.month==2:\n if isLeapYear(date1.year): days += 29-date1.date\n else: days+= 28-date1.date\n if date1.month!=2: days += m[date1.month-1] - date1.date\n days += date2.date\n\nprint days\n"}, {"source_code": "import datetime\nd1=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nd2=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((d2-d1).days))"}, {"source_code": "def leap(x):\n if(x%400==0):\n return 1\n if(x%100==0):\n return 0\n if(x%4==0):\n return 1\n return 0\n\ndef swap():\n global y,m,d,a,b,c\n if(y==a):\n if(m==b):\n return c<=d\n return bb[0]:a,b=b,a\nelif a[0]==b[0]:\n s=0\n if a[1]>b[1]:a,b=b,a\n for i in range(a[1]+1,b[1]):s+=year[i]\n if a[1]==b[1]:print(abs(a[2]-b[2]));exit()\n s += b[2]\n s += max(0,year[a[1]] - a[2])\n if leap(a[0]) == 366 and a[1]<2 y:\n x,y = y,x\n\nans = 0\nwhile x != y:\n x = x + timedelta(days=1)\n ans+=1\nprint(ans)\n\n"}, {"source_code": "(y1,m1,d1) = map(int,raw_input().split(':'))\n(y2,m2,d2) = map(int,raw_input().split(':'))\n\nmonth_days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]\nleap_days = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]\n\ndef getDays(year, month, day):\n\tif (year%4==0 and year%100!=0) or year%400==0:\n\t\tday += leap_days[month-1]\n\telse:\n\t\tday += month_days[month-1]\n\n\tyear -= 1\n\tleap_years = year/4 - year/100 + year/400\n\treturn (year-leap_years)*365 + leap_years*366 + day\n\nprint abs(getDays(y1,m1,d1)-getDays(y2,m2,d2))\n"}, {"source_code": "import datetime\ny1,m1,d1 = map(int, raw_input().split(\":\"))\ny2,m2,d2 = map(int, raw_input().split(\":\"))\nprint abs(datetime.date(y1,m1,d1)-datetime.date(y2,m2,d2)).days"}, {"source_code": "import datetime\n\n\ndef solve():\n f = datetime.datetime.strptime(raw_input(), '%Y:%m:%d').date()\n d = datetime.datetime.strptime(raw_input(), '%Y:%m:%d').date()\n if f > d:\n print (f - d).days\n else:\n print (d - f).days\n\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "import datetime\ndef inputdate():\n ipt = raw_input()\n a = ipt.split(':')\n return datetime.date(int(a[0]), int(a[1]), int(a[2]))\ndat = inputdate() - inputdate()\nprint abs(dat.days)"}, {"source_code": "def f(y, m, d): \n return 365 * y + 31 * m + d + ((y - 1) // 4 - (y - 1) // 100 + (y - 1) // 400) - ((2 + int(y % 4 != 0 or (y % 100 == 0 and y % 400 != 0))) * (m > 2) + (m > 4) + (m > 6) + (m > 9) + (m > 11))\nprint(abs(f(*map(int, input().split(':'))) - f(*map(int, input().split(':')))))"}, {"source_code": "import datetime\nt1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nt2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((t2-t1).days))"}, {"source_code": "from datetime import *\n\nt1 = datetime.strptime(input(), \"%Y:%m:%d\")\nt2 = datetime.strptime(input(), \"%Y:%m:%d\")\n\nprint(abs((t2-t1).days))\n"}, {"source_code": "from datetime import date\nimport math\ni0 = input().split(':')\ni1 = input().split(':')\nd0 = date(int(i0[0]), int(i0[1]), int(i0[2]))\nd1 = date(int(i1[0]), int(i1[1]), int(i1[2]))\ndelta = d1 - d0\nprint(abs(delta.days))"}, {"source_code": "from datetime import date\nd1=[]\nd2=[]\nfor x in raw_input().split(\":\"):\n d1.append(int(x))\n\nfor x in raw_input().split(\":\"):\n d2.append(int(x))\nprint abs(date(d2[0], d2[1], d2[2]) - date(d1[0], d1[1], d1[2])).days"}, {"source_code": "import datetime\nt1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nt2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((t2-t1).days))"}, {"source_code": "import datetime\ny1, m1, d1 = map(int, input().split(':'))\ny2, m2, d2 = map(int, input().split(':'))\nprint(abs(datetime.date(y1, m1, d1) - datetime.date(y2, m2, d2)).days)"}, {"source_code": "import datetime\n\ny, m, d = map(int, raw_input().split(':'))\nd1 = datetime.date(y, m, d)\ny, m, d = map(int, raw_input().split(':'))\nd2 = datetime.date(y, m, d)\nd = d2-d1\nprint abs(d.days)\n"}, {"source_code": "from datetime import date\na = map(int,raw_input().split(\":\"))\nd = []\nd.append(date(a[0],a[1],a[2]))\na = map(int,raw_input().split(\":\"))\nd.append(date(a[0],a[1],a[2]))\nd.sort()\ndels = d[1]-d[0]\nprint dels.days"}, {"source_code": "from datetime import date as d\nprint(abs((d(*map(int,input().split(':')))-d(*map(int,input().split(':')))).days))"}, {"source_code": "import sys\ndef isr(n):\n if n/4 * 4 == n and n != 1900:\n return 1\n else:\n return 0\nif __name__ == '__main__':\n \n lit=[[31,28,31,30,31,30,31,31,30,31,30,31],[31,29,31,30,31,30,31,31,30,31,30,31]]\n num1 = map(str,sys.stdin.readline().split())\n num2 = map(str,sys.stdin.readline().split())\n startY = int(num1[0][0:4])\n endY = int(num2[0][0:4])\n startM = int(num1[0][5:7])\n endM = int(num2[0][5:7])\n startD = int(num1[0][8:10])\n endD = int(num2[0][8:10])\n\n if (endY-startY)*366 + (endM - startM)*31 + (endD - startD) < 0:\n endY,startY = startY,endY\n endM,startM = startM,endM\n endD,startD = startD,endD\n\n all = 0\n while startY != endY or startM != endM or startD != endD:\n all+=1\n startD+=1\n\n if startD > lit[isr(startY)][startM-1]:\n startD = 1\n startM += 1\n if startM > 12:\n startM = 1\n startY +=1\n\n print all"}, {"source_code": "import datetime\n\nt1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\n\nt2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\n\nprint(abs((t2-t1).days))"}, {"source_code": "import datetime\n\ny1, m1, d1 = [int(i) for i in raw_input().strip().split(':')]\ndate1 = datetime.date(y1, m1, d1)\n\ny2, m2, d2 = [int(i) for i in raw_input().strip().split(':')]\ndate2 = datetime.date(y2, m2, d2)\n\nif date1 == date2:\n print 0\nelse:\n print abs(int(str(date2-date1).split()[0]))\n"}, {"source_code": "month_days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\ndef leap(x):\n return x % 4 == 0 and x % 100 != 0 or x % 400 == 0\ndef calc_days(y, m, d):\n days = [month_days[i] + (i == 2 and leap(y)) for i in range(m)]\n return d + sum(days)\narr = [list(map(int, input().split(':'))) for i in range(2)]\narr = sorted(arr)\nif arr[0][0] == arr[1][0]:\n print(calc_days(*arr[1]) - calc_days(*arr[0]))\nelse:\n first_year = 365 + leap(arr[0][0])\n mid_days = [365 + leap(i) for i in range(arr[0][0]+1, arr[1][0])]\n print(first_year - calc_days(*arr[0]) + sum(mid_days) + calc_days(*arr[1]))\n"}, {"source_code": "from datetime import date\nyyyy,mm,dd = raw_input().split(':')\na = date(int(yyyy),int(mm),int(dd))\nyyyy,mm,dd = raw_input().split(':')\nb = date(int(yyyy),int(mm),int(dd))\nans = (b-a).days\nprint abs(ans)"}, {"source_code": "import datetime\nd1=apply(datetime.date,map(int,raw_input().split(':')))\nd2=apply(datetime.date,map(int,raw_input().split(':')))\nprint abs((d2-d1).days)\n"}, {"source_code": "\nfrom datetime import datetime\ny,m,d = map(int,input().split(':'))\na = datetime(y,m,d)\ny,m,d = map(int,input().split(':'))\nb = datetime(y,m,d)\nprint(abs((b-a).days))\n"}, {"source_code": "from datetime import date\nimport sys\n\ndate1 = map(int, sys.stdin.readline().split(\":\"))\ndate2 = map(int, sys.stdin.readline().split(\":\"))\n\nprint abs((date(date1[0], date1[1], date1[2]) - date(date2[0], date2[1], date2[2])).days)\n"}, {"source_code": "import datetime\ntime1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\ntime2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((time1-time2).days))"}, {"source_code": "import time\nimport datetime\nimport calendar\n\nif __name__ == '__main__':\n\n\n date1 = input().split(\":\")\n date1 = [int(x) for x in date1]\n date2 = input().split(\":\")\n date2 = [int(x) for x in date2]\n #print(date2)\n if date1[0] > date2[0]:\n tmp = date1.copy()\n date1 = date2\n date2 = tmp\n\n sum = 0\n for i in range(date1[0]+1, date2[0]):\n if i % 4 == 0:\n if i % 100 != 0:\n sum += 366\n continue\n if i % 400 == 0:\n sum += 366\n continue\n sum += 365\n continue\n\n\n if date1[0] != date2[0]:\n sumdays = 0\n for i in range(date1[1], 13):\n sumdays += calendar.monthrange(date1[0], i)[1]\n sumdays -= date1[2]\n\n sumdays2 = 0\n for i in range(1, date2[1]):\n sumdays2 += calendar.monthrange(date2[0], i)[1]\n sumdays2 += date2[2]\n sum += sumdays + sumdays2\n else:\n sumdays = 0\n for i in range(min(date1[1], date2[1]), max(date1[1], date2[1])):\n sumdays += calendar.monthrange(date1[0], i)[1]\n\n if date1[1] < date2[1]:\n sumdays += -date1[2] + date2[2]\n else:\n sumdays += -date2[2] + date1[2]\n sum += sumdays\n\n if date2[0] == date1[0] and date2[1] == date1[1] and date2[2] == date1[2]:\n sum = 0\n print(abs(sum))\n\n\n\n\n\n\n"}, {"source_code": "l=[]\nans=chk=0\nl.append(map(int,raw_input().split(':')))\nl.append(map(int,raw_input().split(':')))\nl.sort()\nbc=l[0]\nad=l[1]\nwhile 1:\n if bc[0]!=ad[0] or bc[1]!=ad[1]:\n if bc[1] in [1,3,5,7,8,10]:\n ans+=31-bc[2]\n bc[2]=0\n bc[1]+=1\n elif bc[1] in [4,6,9,11]:\n ans+=30-bc[2]\n bc[2]=0\n bc[1]+=1\n elif bc[1] == 2:\n ans+=28-bc[2]\n if bc[0]%400==0 or (bc[0]%4==0 and bc[0]%100!=0):\n ans+=1\n bc[2]=0\n bc[1]+=1\n else:\n ans+=31-bc[2]\n bc[2]=0\n bc[1]=1\n bc[0]+=1\n else:\n ans+=ad[2]-bc[2]\n break\nprint ans"}, {"source_code": "import datetime\nprint(abs((datetime.datetime.strptime(input(),\"%Y:%m:%d\")-datetime.datetime.strptime(input(),\"%Y:%m:%d\")).days))\n"}, {"source_code": "from datetime import datetime\nprint(abs(datetime.strptime(input(),\"%Y:%m:%d\")-datetime.strptime(input(),\"%Y:%m:%d\")).days)"}, {"source_code": "def get(y, m, d):\n if(m < 3):\n y -= 1\n m += 12\n return 365 * y + y // 4 - y //100 + y//400 + (153*m-457)//5+d-306\n\na1 = input().split(':')\na2 = input().split(':')\n\nprint(abs(get(int(a1[0]),int(a1[1]),int(a1[2])) - get(int(a2[0]),int(a2[1]),int(a2[2]))))\n"}, {"source_code": "def main():\n\td1=map(int,raw_input().split(\":\",3));\n\td2=map(int,raw_input().split(\":\",3));\n\tans=0;\n\ty1=d1[0];\n\ty2=d2[0];\n\tm1=d1[1];\n\tm2=d2[1];\n\tday1=d1[2];\n\tday2=d2[2];\n\tif y1 2):\n res = res + 1\n\n i = 1\n while (i < y):\n if ( ano_bisiesto(i) == False ):\n res = res + 365\n else:\n res = res + 366\n i = i + 1\n\n return res\n\ndef ano_bisiesto(ano):\n if(ano%4 ==0 ):\n if(ano%100 ==0):\n if(ano%400 ==0):\n return True\n else:\n return False\n else:\n return True\n else:\n return False\n\na = list(map(int,input().split(':')))\nb = list(map(int,input().split(':')))\nprint(abs(day_number(a[2],a[1],a[0])-day_number(b[2],b[1],b[0])))"}, {"source_code": "from datetime import timedelta, date\n\n\ndef solve():\n y1,m1,d1 = map(int, raw_input().strip().split(':'))\n y2,m2,d2 = map(int, raw_input().strip().split(':'))\n day1 = date(y1,m1,d1)\n day2 = date(y2,m2,d2)\n ans = (day2-day1).days\n if ans < 0:\n ans = -ans\n print ans\n \nsolve()"}, {"source_code": "import datetime\ny1, m1, d1 = map(int, input().split(\":\"))\ndate_1 = datetime.date(y1, m1, d1)\ny2, m2, d2 = map(int, input().split(\":\"))\ndate_2 = datetime.date(y2, m2, d2)\n\nprint((abs(date_2-date_1)).days)\n\n\"\"\"\ndef leap_year(x, y):\n d = 0\n for i in range(x, y+1):\n if (i%4 == 0 and i % 100 != 0) or (i%400 == 0):\n d += 366\n else:\n d += 365\n return d\nd = leap_year(y1, y2)\nd += (m2-m1)*30 + (d2-d1)\nprint(d)\n\"\"\"\n"}, {"source_code": "def day_number(d,m,y):\n \n res = d\n #defino los meses\n meses = [31,28,31,30,31,30,31,31,30,31,30,31] \n \n if (m!=1): #dias del ano corriendo\n for i in range (m-1):\n res = res + meses[i]\n if ( ano_bisiesto(y) == True and m > 2):\n res = res + 1\n\n i = 1\n while (i < y):\n if ( ano_bisiesto(i) == False ):\n res = res + 365\n else:\n res = res + 366\n i = i + 1\n\n return res\n\ndef ano_bisiesto(ano):\n if(ano%4 ==0 ):\n if(ano%100 ==0):\n if(ano%400 ==0):\n return True\n else:\n return False\n else:\n return True\n else:\n return False\n\na = list(map(int,input().split(':')))\nb = list(map(int,input().split(':')))\nprint(abs(day_number(a[2],a[1],a[0])-day_number(b[2],b[1],b[0])))"}, {"source_code": "l=[]\nans=chk=0\nl.append(map(int,raw_input().split(':')))\nl.append(map(int,raw_input().split(':')))\nl.sort()\nbc=l[0]\nad=l[1]\nwhile 1:\n if bc[0]!=ad[0] or bc[1]!=ad[1]:\n if bc[1] in [1,3,5,7,8,10]:\n ans+=31-bc[2]\n bc[2]=0\n bc[1]+=1\n elif bc[1] in [4,6,9,11]:\n ans+=30-bc[2]\n bc[2]=0\n bc[1]+=1\n elif bc[1] == 2:\n ans+=28-bc[2]\n if bc[0]%400==0 or (bc[0]%4==0 and bc[0]%100!=0):\n ans+=1\n bc[2]=0\n bc[1]+=1\n else:\n ans+=31-bc[2]\n bc[2]=0\n bc[1]=1\n bc[0]+=1\n else:\n ans+=ad[2]-bc[2]\n break\nprint ans"}, {"source_code": "from datetime import date\n\na = list(map(int, input().split(':')))\nb = list(map(int, input().split(':')))\n\nf_date = date(a[0],a[1],a[2])\nl_date = date(b[0], b[1], b[2])\ndelta = l_date - f_date\nprint(abs(delta.days))\n\n\n"}, {"source_code": "dm = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\ndef leap(y):\n return y % 4 == 0 and y != 1900\ndef dn(y, m, d):\n return d + sum(dm[i] + (i == 2 and leap(y)) for i in range(m))\nd = sorted(list(map(int, input().split(':'))) for i in range(2))\nif d[0][0] == d[1][0]:\n print(dn(*d[1]) - dn(*d[0]))\nelse:\n print(365 + leap(d[0][0]) - dn(*d[0]) + sum(365 + leap(i) for i in range(d[0][0] + 1, d[1][0])) + dn(*d[1]))"}, {"source_code": "def main():\n\td1=map(int,raw_input().split(\":\",3));\n\td2=map(int,raw_input().split(\":\",3));\n\tans=0;\n\ty1=d1[0];\n\ty2=d2[0];\n\tm1=d1[1];\n\tm2=d2[1];\n\tday1=d1[2];\n\tday2=d2[2];\n\tif y1 days_in_month:\n month += 1\n day = 1\n if month == 13:\n year += 1\n month = 1\n elif month == 2 and (year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)):\n days_in_month = 29\n else:\n days_in_month = days[month]\n d.append(num_days)\n\nprint(abs(d[0]-d[1]))"}, {"source_code": "from datetime import date\n\ndef main():\n\ty1, m1, d1 = map(int, raw_input().split(':'))\n\ty2, m2, d2 = map(int, raw_input().split(':'))\n\tprint abs((date(y2, m2, d2) - date(y1, m1, d1)).days)\nmain()"}, {"source_code": "import datetime\nprint(abs((datetime.datetime.strptime(input(),\"%Y:%m:%d\")-datetime.datetime.strptime(input(),\"%Y:%m:%d\")).days))"}, {"source_code": "import datetime\nt1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nt2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((t2-t1).days))"}, {"source_code": "from datetime import date\n\nstr = raw_input().split(\":\")\nstr2 = raw_input().split(\":\")\n\na = date(int(str[0]), int(str[1]), int(str[2]))\nb = date(int(str2[0]), int(str2[1]), int(str2[2]))\n\nprint abs((b-a).days)"}, {"source_code": "import sys\nimport datetime\n\ndef main():\n s = raw_input()\n t = raw_input()\n a = s.split(':')\n b = t.split(':')\n t1 = datetime.date(int(a[0]), int(a[1]), int(a[2]))\n t2 = datetime.date(int(b[0]), int(b[1]), int(b[2]))\n if t1 > t2: print (t1 - t2).days\n else: print (t2 - t1).days\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "t = [0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334]\ndef g(y, m):\n return int(m > 2 and y % 4 == 0 and (y % 100 != 0 or y % 400 == 0))\ndef h(y):\n return y // 4 - y // 100 + y // 400\ndef f(y, m, d): \n global t\n return 365 * y + t[m] + d + h(y - 1) + g(y, m)\nprint(abs(f(*map(int, input().split(':'))) - f(*map(int, input().split(':')))))"}, {"source_code": "from datetime import date\n\na1 = [int(i) for i in input().split(':')]\na2 = [int(i) for i in input().split(':')]\n\nprint(abs((date(a1[0], a1[1], a1[2]) - date(a2[0], a2[1], a2[2])).days))\n"}, {"source_code": "(y1,m1,d1) = map(int,raw_input().split(':'))\n(y2,m2,d2) = map(int,raw_input().split(':'))\n\nmonth_days = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]\nleap_days = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]\n\ndef getDays(year, month, day):\n\tif (year%4==0 and year%100!=0) or year%400==0:\n\t\tday += leap_days[month-1]\n\telse:\n\t\tday += month_days[month-1]\n\n\tyear -= 1\n\tleap_years = year/4 - year/100 + year/400\n\treturn (year-leap_years)*365 + leap_years*366 + day\n\nprint abs(getDays(y1,m1,d1)-getDays(y2,m2,d2))\n"}, {"source_code": "def get(y, m, d):\n if(m < 3):\n y -= 1\n m += 12\n return 365 * y + y // 4 - y //100 + y//400 + (153*m-457)//5+d-306\n\na1 = input().split(':')\na2 = input().split(':')\n\nprint(abs(get(int(a1[0]),int(a1[1]),int(a1[2])) - get(int(a2[0]),int(a2[1]),int(a2[2]))))\n"}, {"source_code": "from datetime import *\na = [int(x) for x in raw_input().split(':')]\nb = [int(y) for y in raw_input().split(':')]\n\nd1 = date(a[0], a[1], a[2])\nd2 = date(b[0], b[1], b[2])\n\nprint(abs((d2-d1).days))"}, {"source_code": "import sys\nimport datetime\n\ndef main():\n s = raw_input()\n t = raw_input()\n a = s.split(':')\n b = t.split(':')\n t1 = datetime.date(int(a[0]), int(a[1]), int(a[2]))\n t2 = datetime.date(int(b[0]), int(b[1]), int(b[2]))\n if t1 > t2: print (t1 - t2).days\n else: print (t2 - t1).days\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def isLeapYear(y):\n if y % 4 == 0:\n if y % 400 == 0:\n return True\n elif y % 100 == 0:\n return False\n return True\n return False\n\n\ny1, m1, d1 = map(int, input().split(':'))\ny2, m2, d2 = map(int, input().split(':'))\nyear = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nleap_year = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nif y1 > y2:\n y1, m1, d1, y2, m2, d2 = y2, m2, d2, y1, m1, d1\nelif y1 == y2:\n if m1 > m2:\n m1, d1, m2, d2 = m2, d2, m1, d1\n elif m1 == m2:\n if d1 > d2:\n d1, d2 = d2, d1\ns = 0\nfor i in range(y1 + 1, y2):\n if isLeapYear(i):\n s += sum(leap_year)\n else:\n s += sum(year)\nif y1 != y2:\n if isLeapYear(y1):\n s += sum(leap_year[m1 - 1:]) - d1\n else:\n s += sum(year[m1 - 1:]) - d1\n if isLeapYear(y2):\n s += sum(leap_year[:m2 - 1]) + d2\n else:\n s += sum(year[:m2 - 1]) + d2\nelif m1 != m2:\n if isLeapYear(y1):\n s += sum(leap_year[:m2 - 1]) + d2\n s -= sum(leap_year[:m1 - 1]) + d1\n else:\n s += sum(year[:m2 - 1]) + d2\n s -= sum(year[:m1 - 1]) + d1\nelif d1 != d2:\n s += d2 - d1\nprint(s)\n"}, {"source_code": "from datetime import datetime\nprint(abs(datetime.strptime(input(),\"%Y:%m:%d\")-datetime.strptime(input(),\"%Y:%m:%d\")).days)"}, {"source_code": "from datetime import date\n\ns = raw_input();\nf = s.split(':');\n\nyear = int(f[0]);\nmonth = int(f[1]);\nday = int(f[2]);\n\ns = raw_input();\nf = s.split(':');\n\nyear2 = int(f[0]);\nmonth2 = int(f[1]);\nday2 = int(f[2]);\n\nd = date(year, month, day)\nd2 = date(year2, month2, day2)\n\nchange = abs(d2 - d)\n\nprint change.days"}, {"source_code": "from datetime import date\ny1,m1,d1=map(int,input().split(':'))\ny2,m2,d2=map(int,input().split(':'))\n\na=date(y1,m1,d1)\nb=date(y2,m2,d2)\nprint(abs((b-a).days))\n\n"}, {"source_code": "from datetime import date\nimport sys\n\ndate1 = map(int, sys.stdin.readline().split(\":\"))\ndate2 = map(int, sys.stdin.readline().split(\":\"))\n\nprint abs((date(date1[0], date1[1], date1[2]) - date(date2[0], date2[1], date2[2])).days)\n"}, {"source_code": "import datetime\nt1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nt2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((t2-t1).days))"}, {"source_code": "import datetime\nt1 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nt2 = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((t2-t1).days))"}, {"source_code": "from datetime import date\nd2 = raw_input()\nd1 = raw_input()\ndelta = date(int(d1[0:4]),int(d1[5:7]),int(d1[8:10])) - date(int(d2[0:4]),int(d2[5:7]),int(d2[8:10]))\nprint abs(delta.days)\n"}, {"source_code": "import datetime\nx=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\ny=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((x-y).days))"}, {"source_code": "import datetime\nt1=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nt2=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((t2-t1).days))"}, {"source_code": "import sys\nfrom datetime import datetime\n\ndata = sys.stdin.readlines()\nstart = datetime.strptime(data[0].strip(), '%Y:%m:%d')\nend = datetime.strptime(data[1].strip(), '%Y:%m:%d')\nprint(abs((end - start).days))"}, {"source_code": "import datetime\nt1 = datetime.datetime.strptime(input(), \"%Y:%m:%d\")\nt2 = datetime.datetime.strptime(input(), \"%Y:%m:%d\")\nprint(abs( (t2 - t1).days) )"}, {"source_code": "def isleap(x):\n if (x%4==0 and x%100!=0) or x%400==0:\n return True\n else:\n return False\n\ndef getday(y,m,d):\n month=[31,28,31,30,31,30,31,31,30,31,30,31]\n i=0\n day=0\n while i2:\n d+=1\n return day+d\n\ndef getcday(y,m,d,p):\n leap=0\n c=1\n day=0\n x=p\n while xy2:\n print abs(getcday(y1,m1,d1,y2)-getday(y2,m2,d2))\n else:\n print abs(getcday(y2,m2,d2,y1)-getday(y1,m1,d1))\n\nif __name__=='__main__':\n main()\n"}, {"source_code": "import datetime\nfrom pprint import pprint\nyear, month, day = (int(i) for i in input().split(':'))\nx = datetime.date(year, month, day)\nyear, month, day = (int(i) for i in input().split(':'))\ny = datetime.date(year, month, day)\npprint(abs(int((x - y).days)))\n"}, {"source_code": "from datetime import datetime\ndate_format = \"%Y:%m:%d\"\nx= raw_input()\ny= raw_input()\na = datetime.strptime(x, date_format)\nb = datetime.strptime(y, date_format)\ndelta = b - a\nprint abs(delta.days) # that's it"}, {"source_code": "from datetime import date\n\na = list(map(int, input().split(':')))\nb = list(map(int, input().split(':')))\n\nf_date = date(a[0],a[1],a[2])\nl_date = date(b[0], b[1], b[2])\ndelta = l_date - f_date\nprint(abs(delta.days))\n\n\n"}, {"source_code": "def isLeep(year):\n if year % 400 == 0:\n return 1;\n else:\n if year % 4 == 0 and year % 100 != 0:\n return 1;\n return 0;\n \ndef cmp(y1, m1, d1, y2, m2, d2):\n if y1 > y2:\n return 0;\n else:\n if y1 == y2 and m1 > m2:\n return 0;\n else:\n if y1 == y2 and m1 == m2 and d1 > d2:\n return 0;\n return 1;\n\ny1, m1, d1 = map(int, input().split(':'))\ny2, m2, d2 = map(int, input().split(':'))\n\ndays = [31, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\n\nif cmp(y1, m1, d1, y2, m2, d2) == 0:\n t = y1; y1 = y2; y2 = t;\n t = m1; m1 = m2; m2 = t;\n t = d1; d1 = d2; d2 = t;\n\nres = 0;\nwhile True:\n res = res + 1;\n if y1 == y2 and m1 == m2 and d1 == d2:\n break;\n d1 = d1 + 1;\n if d1 <= days[m1]:\n continue;\n else:\n if d1 == 29:\n if isLeep(y1):\n continue;\n else:\n m1 = 3;\n d1 = 1;\n else:\n if d1 == 30:\n m1 = 3;\n d1 = 1;\n else:\n if d1 == 31:\n m1 = m1 + 1;\n d1 = 1;\n else:\n if d1 == 32:\n if m1 == 12:\n y1 = y1 + 1;\n m1 = 1;\n d1 = 1;\n else:\n m1 = m1 + 1;\n d1 = 1;\n\nprint (res - 1)\n \n\n"}, {"source_code": "from datetime import date\nd1 = date(*map(int, input().split(':')))\nd2 = date(*map(int, input().split(':')))\nprint(abs(d2 - d1).days)"}, {"source_code": "#br = open('b.in')\na = map(int, raw_input().split(\":\"))\nb = map(int, raw_input().split(\":\"))\nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nr = 0\ndef can(y):\n if y % 100 == 0 and y % 400 != 0:\n return 0\n return y % 4 == 0\ndef calc(a, b):\n r = 0\n for i in range(a[0], b[0] + 1):\n for j in range([0, a[1]][i == a[0]] + 1, [12, b[1] - 1][i == b[0]] + 1):\n r += d[j] + (j == 2 and can(i))\n if a[0] == b[0] and a[1] == b[1]:\n return b[2] - a[2]\n return r + b[2] + (d[a[1]] + (a[1] == 2 and can(a[0]))) - a[2]\nif a > b:\n a, b = b, a\nprint calc(a, b)\n\n"}, {"source_code": "import datetime\nx=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\ny=datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((x-y).days))\n"}, {"source_code": "from datetime import date\ny1,m1,d1 = map(int,input().split(':'))\ny2,m2,d2 = map(int,input().split(':'))\ndate1 = date(y1,m1,d1)\ndate2 = date(y2,m2,d2)\nprint(abs((date2-date1).days))\n"}, {"source_code": "from datetime import *\nR = lambda: datetime(*map(int, input().split(':')))\ndate1 = R()\ndate2 = R()\nprint(abs(date2 - date1).days)"}, {"source_code": "import datetime\n\ny1, m1, d1 = [int(i) for i in raw_input().strip().split(':')]\ndate1 = datetime.date(y1, m1, d1)\n\ny2, m2, d2 = [int(i) for i in raw_input().strip().split(':')]\ndate2 = datetime.date(y2, m2, d2)\n\nif date1 == date2:\n print 0\nelse:\n print abs(int(str(date2-date1).split()[0]))\n"}, {"source_code": "def ifLeap(year):\n\tif(year %100 == 0):\n\t\tif(year%400 == 0):\n\t\t\treturn True\n\telif(year%4 == 0):\n\t\treturn True\n\treturn False\nyear1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\n\nmonth =[]\njan = []\nfor i in range(1,32):\n\tjan.append(i)\nmonth.append(jan)\nfeb = []\nfor i in range(32,61):\n\tfeb.append(i)\nmonth.append(feb)\nmar = []\nfor i in range(61,92):\n\tmar.append(i)\nmonth.append(mar)\napr =[]\nfor i in range(92,122):\n\tapr.append(i)\nmonth.append(apr)\nmay = []\nfor i in range(122,153):\n\tmay.append(i)\nmonth.append(may)\njun = []\nfor i in range(153,183):\n\tjun.append(i)\nmonth.append(jun)\njul = []\nfor i in range(183,214):\n\tjul.append(i)\nmonth.append(jul)\naug = []\nfor i in range(214,245):\n\taug.append(i)\nmonth.append(aug)\nsep =[]\nfor i in range(245,275):\n\tsep.append(i)\nmonth.append(sep)\noct = []\nfor i in range(275,306):\n\toct.append(i)\nmonth.append(oct)\nnov = []\nfor i in range(306,336):\n\tnov.append(i)\nmonth.append(nov)\ndec = []\nfor i in range(336,367):\n\tdec.append(i)\nmonth.append(dec)\n\nrday1 = month[month1-1][day1-1]\nrday2 = month[month2-1][day2-1]\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\trday1,rday2 = rday2,rday1\nelif(year2 == year1):\n\tif(rday2 < rday1):\n\t\tyear1,year2 = year2,year1\n\t\trday1,rday2 = rday2,rday1\ndifday = 0\ndifyear = year2 - year1\nif(rday2 < rday1):\n\tdifday = 366-rday1 + rday2\n\tdifyear -= 1\nelse :\n\tdifday = rday2 - rday1\nif(not ifLeap(year1)):\n\tif rday1<60 and rday2 > 60 :\n\t\tdifday -= 1\n\telif(rday1 > rday2 and rday1 <60):\n\t\tdifday -= 1\nif(not ifLeap(year2)):\n\tif(rday2 < rday1 and rday2 > 60):\n\t\tdifday -= 1\ndifday += difyear * 365\nfor i in range(year1+1,year2):\n\tif(ifLeap(i)) :\n\t\tdifday += 1\nprint (difday)\n"}, {"source_code": "from datetime import datetime\n \ndef days_between(d1,d2) :\n d1 = datetime.strptime(d1,\"%Y:%m:%d\")\n d2 = datetime.strptime(d2,\"%Y:%m:%d\")\n return abs((d2-d1).days)\n \nsmonth = raw_input()\nemonth = raw_input()\n \nprint days_between(smonth, emonth)\n"}, {"source_code": "import time\nimport datetime\nimport calendar\n\nif __name__ == '__main__':\n\n\n date1 = input().split(\":\")\n date1 = [int(x) for x in date1]\n date2 = input().split(\":\")\n date2 = [int(x) for x in date2]\n #print(date2)\n if date1[0] > date2[0]:\n tmp = date1.copy()\n date1 = date2\n date2 = tmp\n\n sum = 0\n for i in range(date1[0]+1, date2[0]):\n if i % 4 == 0:\n if i % 100 != 0:\n sum += 366\n continue\n if i % 400 == 0:\n sum += 366\n continue\n sum += 365\n continue\n\n\n if date1[0] != date2[0]:\n sumdays = 0\n for i in range(date1[1], 13):\n sumdays += calendar.monthrange(date1[0], i)[1]\n sumdays -= date1[2]\n\n sumdays2 = 0\n for i in range(1, date2[1]):\n sumdays2 += calendar.monthrange(date2[0], i)[1]\n sumdays2 += date2[2]\n sum += sumdays + sumdays2\n else:\n sumdays = 0\n for i in range(min(date1[1], date2[1]), max(date1[1], date2[1])):\n sumdays += calendar.monthrange(date1[0], i)[1]\n\n if date1[1] < date2[1]:\n sumdays += -date1[2] + date2[2]\n else:\n sumdays += -date2[2] + date1[2]\n sum += sumdays\n\n if date2[0] == date1[0] and date2[1] == date1[1] and date2[2] == date1[2]:\n sum = 0\n print(abs(sum))\n\n\n\n\n\n\n"}, {"source_code": "from datetime import date\n\na = map(int , raw_input().split(\":\")) \nb = map(int , raw_input().split(\":\"))\nu = abs(date(a[0] , a[1] , a[2]) - date(b[0] , b[1] , b[2])).days\nprint u\n"}, {"source_code": "import datetime\n_a = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\n_b = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint (abs((_a-_b).days))"}, {"source_code": "import datetime\na = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nb = datetime.datetime.strptime(input(),\"%Y:%m:%d\")\nprint(abs((a-b).days))"}, {"source_code": "from datetime import date\nx = raw_input()\ny = raw_input()\ns = [int(i) for i in x.split(':')]\nt = [int(i) for i in y.split(':')]\n\na = date(s[0],s[1],s[2])\nb = date(t[0],t[1],t[2])\nprint abs(a-b).days"}, {"source_code": "from datetime import date\nd2 = raw_input()\nd1 = raw_input()\ndelta = date(int(d1[0:4]),int(d1[5:7]),int(d1[8:10])) - date(int(d2[0:4]),int(d2[5:7]),int(d2[8:10]))\nprint abs(delta.days)\n"}], "negative_code": [{"source_code": "from datetime import date,timedelta\nimport sys\n\ndef get_input ():\n return map (int,input().split(':'))\n\nsy,sm,sd = get_input()\ney,em,ed = get_input()\n\nstart = date (sy,sm,sd)\nend = date (ey,em,ed)\n\nprint ((end-start).days)\n"}, {"source_code": "from datetime import date\nlist1 = input().split(':')\nlist2 = input().split(':')\nd0 = date(int(list1[0]),int(list1[1]),int(list1[2]))\nd1 = date(int(list2[0]),int(list2[1]),int(list2[2]))\ndelta = d1 - d0\nprint(delta.days)\n"}, {"source_code": "#-------------------------------------------------------------------------------\n# Name: Codeforces\n# Author: Gogol2\n\n#-------------------------------------------------------------------------------\n\nm = [31,28,31,30,31,30,31,31,30,31,30,31]\ndef leap (yy):\n if ((yy % 400 == 0 or (yy % 4 == 0 and yy % 100) )):\n return 366\n else:\n return 365\n\ndef main():\n\n y1,m1,d1 = map(int,input().split(':'))\n y2,m2,d2 = map(int,input().split(':'))\n a = d1\n b = d2\n for i in range (0,y1+1):\n a = a + leap(i)\n for i in range (0,y2+1):\n b = b + leap(i)\n for i in range (m1 - 1):\n a = a + m[i]\n for i in range (m2 - 1):\n b = b + m[i]\n print(abs(a - b))\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from collections import Counter\nimport string\nimport math\ndicti={'1':31,'2':28,'3':31,'4':30,'5':31,'6':30,'7':31,'8':31\n ,'9':30,'10':31,'11':30,'12':31}\ndef array_int():\n\n return [int(i) for i in input().split()]\ndef vary(number_of_variables):\n if number_of_variables==1:\n return int(input())\n if number_of_variables>=2:\n return map(int,input().split()) \ndef makedict(var):\n return dict(Counter(var))\nmod=1000000007\ndate1=input()\ndate2=input()\nyear1=int(date1[:4])\nyear2=int(date2[:4])\nday1=int(date1[8:])\nday2=int(date2[8:])\nmonth1=int(date1[5:7])\nmonth2=int(date2[5:7])\nclass Date: \n def __init__(self, d, m, y): \n self.d = d \n self.m = m \n self.y = y \nmonthDays = [31, 28, 31, 30, 31, 30, \n 31, 31, 30, 31, 30, 31 ]\ndef countLeapYears(d): \n \n years = d.y \n if (d.m <= 2): \n years-= 1\n return int(years / 4 - years / 100 + years / 400 ) \n\ndef getDifference(dt1, dt2) : \n n1 = dt1.y * 365 + dt1.d \n \n # Add days for months in given date \n for i in range(0, dt1.m - 1) : \n n1 += monthDays[i] \n \n # Since every leap year is of 366 days, \n # Add a day for every leap year \n n1 += countLeapYears(dt1) \n \n # SIMILARLY, COUNT TOTAL NUMBER OF DAYS BEFORE 'dt2' \n \n n2 = dt2.y * 365 + dt2.d \n for i in range(0, dt2.m - 1) : \n n2 += monthDays[i] \n n2 += countLeapYears(dt2) \n \n # return difference between two counts \n return (n2 - n1) \n \n \n# Driver program \ndt1 = Date(day1, month1, year1 ) \ndt2 = Date(day2, month2, year2 ) \n \nprint(abs(getDifference(dt1, dt2))) \n \n\n\n\n\n\n"}, {"source_code": "from collections import Counter\nimport string\nimport math\ndicti={'1':31,'2':28,'3':31,'4':30,'5':31,'6':30,'7':31,'8':31\n ,'9':30,'10':31,'11':30,'12':31}\ndef array_int():\n\n return [int(i) for i in input().split()]\ndef vary(number_of_variables):\n if number_of_variables==1:\n return int(input())\n if number_of_variables>=2:\n return map(int,input().split()) \ndef makedict(var):\n return dict(Counter(var))\nmod=1000000007\ndate1=input()\ndate2=input()\nyear1=int(date1[:4])\nyear2=int(date2[:4])\nday1=int(date1[8:])\nday2=int(date2[8:])\nmonth1=int(date1[5:7])\nmonth2=int(date2[5:7])\nclass Date: \n def __init__(self, d, m, y): \n self.d = d \n self.m = m \n self.y = y \nmonthDays = [31, 28, 31, 30, 31, 30, \n 31, 31, 30, 31, 30, 31 ]\ndef countLeapYears(d): \n \n years = d.y \n if (d.m <= 2): \n years-= 1\n return int(years / 4 - years / 100 + years / 400 ) \n\ndef getDifference(dt1, dt2) : \n n1 = dt1.y * 365 + dt1.d \n \n # Add days for months in given date \n for i in range(0, dt1.m - 1) : \n n1 += monthDays[i] \n \n # Since every leap year is of 366 days, \n # Add a day for every leap year \n n1 += countLeapYears(dt1) \n \n # SIMILARLY, COUNT TOTAL NUMBER OF DAYS BEFORE 'dt2' \n \n n2 = dt2.y * 365 + dt2.d \n for i in range(0, dt2.m - 1) : \n n2 += monthDays[i] \n n2 += countLeapYears(dt2) \n \n # return difference between two counts \n return (n2 - n1) \n \n \n# Driver program \ndt1 = Date(day1, month1, year1 ) \ndt2 = Date(day2, month2, year2 ) \n \nprint(getDifference(dt1, dt2)) \n \n\n\n\n\n\n"}, {"source_code": "def getday(m,d):\n month=[31,28,31,30,31,30,31,31,30,31,30,31]\n i=0\n day=0\n while iy:\n t=x;\n x=y;\n y=t;\n while x<=y:\n if (x%4==0 and x%100!=0) or x%400==0:\n leap+=1\n c=4\n x+=c\n return leap\n \ndef main():\n d1=raw_input()\n d2=raw_input()\n y1,m1,d1=d1.split(':')\n y2,m2,d2=d2.split(':')\n y1=int(y1)\n d1=int(d1)\n m1=int(m1)\n y2=int(y2)\n d2=int(d2)\n m2=int(m2)\n leap=0\n x=y1\n y=y2\n if m1>2:\n if y12:\n if y1y2:\n print abs(y1-y2)*365+getday(m1,d1)-getday(m2,d2)+leap\n elif y1y:\n t=x;\n x=y;\n y=t;\n while x<=y:\n if (x%4==0 and x%100!=0) or x%400==0:\n leap+=1\n c=4\n #print x\n x+=c\n #print leap\n return leap\n \ndef main():\n d1=raw_input()\n d2=raw_input()\n y1,m1,d1=d1.split(':')\n y2,m2,d2=d2.split(':')\n y1=int(y1)\n d1=int(d1)\n m1=int(m1)\n y2=int(y2)\n d2=int(d2)\n m2=int(m2)\n leap=0\n x=y1\n y=y2\n if y12:\n x=y1+1\n if m2<2:\n y=y2-1\n elif y1>y2:\n if m2>2:\n x=y2+1\n if m1<2:\n y=y1-1\n if y1==y2:\n if m1<2 and m2>2:\n leap=1\n elif m1>2 and m2<2:\n leap=1\n if x!=y:\n leap=check(x,y)\n #print getday(m1,d1),getday(m2,d2)\n if y1>y2:\n print abs(y1-y2)*365+getday(m1,d1)-getday(m2,d2)+leap\n elif y1y2:\n print abs(getcday(y1,m1,d1,y2)-getday(y2,m2,d2))\n else:\n print abs(getcday(y2,m2,d2,y1)-getday(y1,m1,d1))\n\nif __name__=='__main__':\n main()\n"}, {"source_code": "def getday(m,d):\n month=[31,28,31,30,31,30,31,31,30,31,30,31]\n i=0\n day=0\n while iy:\n t=x;\n x=y;\n y=t;\n while x<=y:\n if (x%4==0 and x%100!=0) or x%400==0:\n leap+=1\n c=4\n x+=c\n #print leap\n return leap\n \ndef main():\n d1=raw_input()\n d2=raw_input()\n y1,m1,d1=d1.split(':')\n y2,m2,d2=d2.split(':')\n y1=int(y1)\n d1=int(d1)\n m1=int(m1)\n y2=int(y2)\n d2=int(d2)\n m2=int(m2)\n if m1==2 and d1==29:\n d1-=1\n if m2==2 and d2==29:\n d2-=1\n leap=0\n x=y1\n y=y2\n if m1>2:\n if y12:\n if y1y2:\n print abs(y1-y2)*365+getday(m1,d1)-getday(m2,d2)+leap\n elif y1y:\n t=x;\n x=y;\n y=t;\n while x<=y:\n if (x%4==0 and x%100!=0) or x%400==0:\n leap+=1\n c=4\n #print x\n x+=c\n #print leap\n return leap\ndef main():\n d1=raw_input()\n d2=raw_input()\n y1,m1,d1=d1.split(':')\n y2,m2,d2=d2.split(':')\n y1=int(y1)\n d1=int(d1)\n m1=int(m1)\n y2=int(y2)\n d2=int(d2)\n m2=int(m2)\n leap=0\n x=min(y1,y2)\n y=max(y1,y2)\n if y12:\n x=y1+1\n if m2<2:\n y=y2-1\n elif y1>y2:\n if m2>2:\n x=y2+1\n if m1<2:\n y=y1-1\n if y1==y2:\n if m1<2 and m2>2:\n leap=1\n elif m1>2 and m2<2:\n leap=1\n if x!=y:\n leap=check(x,y)\n #print getday(m1,d1),getday(m2,d2)\n if y1>y2:\n print abs(y1-y2)*365+getday(m1,d1)-getday(m2,d2)+leap\n elif y1y:\n t=x;\n x=y;\n y=t;\n while x<=y:\n if (x%4==0 and x%100!=0) or x%400==0:\n leap+=1\n c=4\n #print x\n x+=c\n #print leap\n return leap\ndef main():\n d1=raw_input()\n d2=raw_input()\n y1,m1,d1=d1.split(':')\n y2,m2,d2=d2.split(':')\n y1=int(y1)\n d1=int(d1)\n m1=int(m1)\n y2=int(y2)\n d2=int(d2)\n m2=int(m2)\n leap=0\n x=min(y1,y2)\n y=max(y1,y2)\n if y12:\n x=y1+1\n if m2<2:\n y=y2-1\n elif y1>y2:\n if m2>2:\n x=y2+1\n if m1<2:\n y=y1-1\n if y1==y2:\n if m1<2 and m2>2:\n leap=1\n elif m1>2 and m2<2:\n leap=1\n elif min(m1,m2)==2 and max(m1,m2)!=2:\n leap=1\n if x!=y:\n leap=check(x,y)\n #print leap\n #print getday(m1,d1),getday(m2,d2)\n if y1>y2:\n print abs(y1-y2)*365+getday(m1,d1)-getday(m2,d2)+leap\n elif y1y:\n t=x;\n x=y;\n y=t;\n while x<=y:\n if (x%4==0 and x%100!=0) or x%400==0:\n leap+=1\n c=4\n #print x\n x+=c\n print leap\n return leap\ndef main():\n d1=raw_input()\n d2=raw_input()\n y1,m1,d1=d1.split(':')\n y2,m2,d2=d2.split(':')\n y1=int(y1)\n d1=int(d1)\n m1=int(m1)\n y2=int(y2)\n d2=int(d2)\n m2=int(m2)\n leap=0\n x=min(y1,y2)\n y=max(y1,y2)\n if y12:\n x=y1+1\n if m2<2:\n y=y2-1\n elif y1>y2:\n if m2>2:\n x=y2+1\n if m1<2:\n y=y1-1\n if y1==y2:\n if m1<2 and m2>2:\n leap=1\n elif m1>2 and m2<2:\n leap=1\n if x!=y:\n leap=check(x,y)\n #print getday(m1,d1),getday(m2,d2)\n if y1>y2:\n print abs(y1-y2)*365+getday(m1,d1)-getday(m2,d2)+leap\n elif y1 0:\n print t\nelse:\n print abs(t) - 1\n"}, {"source_code": "from datetime import datetime\nimport re\n \ndef parse(s):\n [y, m, d] = re.findall(\"\\\\d+\", s)\n return datetime(int(y), int(m), int(d))\n \ndef days_between(d1, d2):\n delta = d2 - d1\n return delta.days\n \nd1 = parse(str(raw_input()))\nd2 = parse(str(raw_input()))\n \nprint days_between(d1, d2)"}, {"source_code": "m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nclass date():\n def __init__(self,d):\n b = map(int, d.split(':'))\n self.year = b[0]\n self.month = b[1]\n self.date = b[2]\n def isGreater(self, d):\n if d.year>self.year: return False\n if d.yearself.month: return False\n if d.monthself.date: return False\n else: return True\ndef isLeapYear(year):\n if year%100==0: return True if year%400==0 else False\n return True if year%4==0 else False\n\ndate1 = date(raw_input())\ndate2 = date(raw_input())\nif date1.isGreater(date2):\n date3 = date1\n date1 = date2\n date2 = date3\ndays = 0\nfor i in xrange(date1.year+1, date2.year):\n days += 366 if isLeapYear(i) else 365\n\nfor i in xrange(date1.month, 12 if date1.year!=date2.year else date2.month-1):\n days += m[i]\n\nif date1.year!=date2.year:\n for i in xrange(0, date2.month-1):\n days += m[i]\nif date1.year==date2.year and isLeapYear(date1.year) and date1.month<2 and date2.month>2:\n days+=1\nelse:\n if isLeapYear(date1.year) and date1.month<2: days+=1\n if isLeapYear(date2.year) and date2.month>2: days+=1\n\nif date1.year==date2.year and date1.month==date2.month:\n days += (date2.date-date1.date)\nelse:\n if date1.month==2:\n if isLeapYear(date1.year): days += 29-date1.date\n else: days+= 28-date1.date\n if date1.month!=2: days += m[date1.month-1] - date1.date\n days += date2.date\n\nprint days\n"}, {"source_code": "m = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nclass date():\n def __init__(self,d):\n b = map(int, d.split(':'))\n self.year = b[0]\n self.month = b[1]\n self.date = b[2]\n def isGreater(self, d):\n if d.year>self.year: return False\n if d.yearself.month: return False\n if d.monthself.date: return False\n else: return True\ndef isLeapYear(year):\n if year%100==0: return True if year%400==0 else False\n return True if year%4==0 else False\n\ndate1 = date(raw_input())\ndate2 = date(raw_input())\nif date1.isGreater(date2):\n date3 = date1\n date1 = date2\n date2 = date3\ndays = 0\nfor i in xrange(date1.year+1, date2.year):\n days += 366 if isLeapYear(i) else 365\n\nfor i in xrange(date1.month, 12 if date1.year!=date2.year else date2.month-1):\n days += m[i]\n\nif date1.year!=date2.year:\n for i in xrange(0, date2.month-1):\n days += m[i]\nif date1.year==date2.year and isLeapYear(date1.year):\n days+=1\nelse:\n if isLeapYear(date1.year): days+=1\n if isLeapYear(date2.year): days+=1\n\nif date1.year==date2.year and date1.month==date2.month:\n days += (date2.date-date1.date)\nelse:\n if date1.month==2:\n if isLeapYear(date1.year): days += 29-date1.date\n else: days+= 28-date1.date\n if date2.month==2:\n if isLeapYear(date2.year): days += 29-date2.date\n else: days+= 28-date2.date\n if date1.month!=2: days += m[date1.month-1] - date1.date\n if date2.month!=2: days += date2.date\n\nprint days\n"}, {"source_code": "#br = open('b.in')\na = map(int, raw_input().split(\":\"))\nb = map(int, raw_input().split(\":\"))\nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nr = 0\ndef can(y):\n if y % 100 == 0 and y % 400 != 0:\n return 0\n return y % 4 == 0\ndef calc(a, b):\n r = 0\n for i in range(a[0], b[0] + 1):\n for j in range([0, a[1]][i == a[0]] + 1, [12, b[1] - 1][i == b[0]] + 1):\n r += d[j] + (j == 2 and can(i))\n if a[0] == b[0] and a[1] == b[1]:\n return b[2] - a[2]\n return r + b[2] + (d[a[1]] + (a[1] == 2 and can(a[0]))) - a[2]\nprint max(calc(a, b), calc(b, a))\n"}, {"source_code": "#br = open('b.in')\na = map(int, raw_input().split(\":\"))\nb = map(int, raw_input().split(\":\"))\nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nr = 0\ndef can(y):\n if y % 100 == 0 and y % 400 != 0:\n return 0\n return y % 4 == 0\ndef calc(a, b):\n r = 0\n for i in range(a[0], b[0] + 1):\n for j in range([0, a[1]][i == a[0]] + 1, [12, b[1] - 1][i == b[0]] + 1):\n r += d[j] + (j == 2 and can(i))\n if a[0] == b[0] and a[1] == b[1]:\n return b[2] - a[2]\n return r + b[2] + (d[a[1]] + (a[1] == 2 and can(a[1]))) - a[2]\nprint max(calc(a, b), calc(b, a))\n"}, {"source_code": "#br = open('b.in')\na = map(int, raw_input().split(\":\"))\nb = map(int, raw_input().split(\":\"))\nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nr = 0\ndef can(y):\n if y % 100 == 0 and y % 400 != 0:\n return 0\n return y % 4 == 0\ndef calc(a, b):\n r = 0\n for i in range(a[0], b[0] + 1):\n for j in range([0, a[1]][i == a[0]] + 1, [12, b[1] - 1][i == b[0]] + 1):\n r += d[j] + (j == 2 and can(i))\n return r + b[2] + (d[a[1]] + (a[1] == 2 and can(a[1]))) - a[2]\nprint max(calc(a, b), calc(b, a))\n"}, {"source_code": "#br = open('b.in')\na = map(int, raw_input().split(\":\"))\nb = map(int, raw_input().split(\":\"))\nd = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];\nr = 0\ndef can(y):\n if y % 100 == 0 and y % 400 != 0:\n return 0\n return y % 4 == 0\ndef calc(a, b):\n r = 0\n if a == b: return 0\n for i in range(a[0], b[0] + 1):\n for j in range([0, a[1]][i == a[0]] + 1, [12, b[1] - 1][i == b[0]] + 1):\n r += d[j] + (j == 2 and can(i))\n return r + b[2] + (d[a[1]] + (a[1] == 2 and can(a[1]))) - a[2]\nprint max(calc(a, b), calc(b, a))\n"}, {"source_code": "from datetime import *\nprint -(datetime.strptime(raw_input(), \"%Y:%m:%d\")-datetime.strptime(raw_input(), \"%Y:%m:%d\")).days"}, {"source_code": "def main():\n\td1=map(int,raw_input().split(\":\",3));\n\td2=map(int,raw_input().split(\":\",3));\n\tans=0;\n\ty1=d1[0];\n\ty2=d2[0];\n\tm1=d1[1];\n\tm2=d2[1];\n\tday1=d1[2];\n\tday2=d2[2];\n\tif y1 x :\n right = mid - 1;\n \n pass\n \n return -1;\n pass\n\ndef printf(format, *args):\n \"\"\"Format args with the first argument as format string, and write.\n Return the last arg, or format itself if there are no args.\"\"\"\n sys.stdout.write(str(format) % args)\n return if_(args, lambda: args[-1], lambda: format)\n\nfrom datetime import date;\nif __name__ == '__main__':\n\n s = readint(':');\n e = readint(':');\n start = date(s[0], s[1], s[2]);\n end = date(e[0], e[1], e[2]);\n print str((end-start).days);\n\n pass"}, {"source_code": "import datetime\n\nt1 = map(int, raw_input().split(':'))\nt2 = map(int, raw_input().split(':'))\n\nprint t1\nprint t2\nd1 = datetime.datetime(t1[0], t1[1], t1[2])\nd2 = datetime.datetime(t2[0], t2[1], t2[2])\n\nprint abs((d2 - d1).days)\n"}, {"source_code": "# encoding: utf-8\n\ndays = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\ndef num_days(year, month):\n if month == 2 and is_leap(year):\n return 29\n else:\n return days[month]\n\n\ndef is_leap(year):\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return True\n else:\n return False\n else:\n return True\n return False\n\n\nif __name__ == '__main__':\n dates = []\n dates.append(raw_input().rstrip())\n dates.append(raw_input().rstrip())\n dates.sort()\n\n year1, month1, day1 = [int(x) for x in dates[0].split(':')]\n year2, month2, day2 = [int(x) for x in dates[1].split(':')]\n\n ans = 0\n\n if year1 == year2:\n if month1 == month2:\n ans = day2 - day1\n else:\n ans += num_days(year1, month1) - day1\n for month in range(month1 + 1, month2):\n ans += num_days(year1, month)\n ans += day2\n else:\n ans += num_days(year1, month1) - day1\n month1 += 1\n if month1 == 12:\n year1 += 1\n month = 1\n for month in range(month1, 12 + 1):\n ans += num_days(year1, month)\n for year in range(year1 + 1, year2):\n for month in range(1, 12 + 1):\n ans += num_days(year, month)\n for month in range(1, month2):\n ans += num_days(year2, month)\n ans += day2\n\n print ans"}, {"source_code": "import datetime\nimport math\n\na = raw_input()\nb = raw_input()\na = a.split(':')\nb = b.split(':')\naa = datetime.date(int(a[0]),int(a[1]),int(a[2]))\nbb = datetime.date(int(b[0]),int(b[1]),int(b[2]))\ncc = aa-bb\nprint cc.days\n"}, {"source_code": "import datetime\n \na = raw_input()\nb = raw_input()\na = a.split(':')\nb = b.split(':')\naa = datetime.date(int(a[0]),int(a[1]),int(a[2]))\nbb = datetime.date(int(b[0]),int(b[1]),int(b[2]))\ncc = aa-bb\ndd = str(cc)\nprint dd.split()[0][1:] \n"}, {"source_code": "import datetime\n\nx=raw_input()\ny=raw_input()\n\nx=x.split(':')\ny=y.split(':')\n\nx[0]=int(x[0])\nx[1]=int(x[1])\nx[2]=int(x[2])\n\ny[0]=int(y[0])\ny[1]=int(y[1])\ny[2]=int(y[2])\n\na=datetime.date(x[0],x[1],x[2])\nb=datetime.date(y[0],y[1],y[2])\n\nif a>=b:\n ans=a-b\nelse:\n ans=b-a\n\nans=str(ans)\nans=ans.split()\n\nprint ans[0]"}, {"source_code": "import sys\nfrom datetime import datetime\n\ndata = sys.stdin.readlines()\nstart = datetime.strptime(data[0].strip(), '%Y:%m:%d')\nend = datetime.strptime(data[1].strip(), '%Y:%m:%d')\nprint((end - start).days)"}, {"source_code": "from datetime import *\n\nline = raw_input()\ny, m, d = line.split(':')\np = date(int(y), int(m), int(d))\nline = raw_input()\ny, m, d = line.split(':')\nt = date(int(y), int(m), int(d))\nprint (t - p).days\n"}, {"source_code": "def get(y, m, d):\n if(m < 3):\n --y\n m += 12\n return 365 * y + y // 4 - y //100 + y//400 + (153*m-457)//5+d-306\n\na1 = input().split(':')\na2 = input().split(':')\n\nprint(abs(get(int(a1[0]),int(a1[1]),int(a1[2])) - get(int(a2[0]),int(a2[1]),int(a2[2]))))\n"}, {"source_code": "def leapyear(a):\n if a%400 == 0:\n return True\n elif a%100 == 0:\n return False\n elif a%4==0:\n return True\n \n\n# =============================================================================\n# a1 = '1949:07:09'\n# a2 = '1901:10:24'\n# =============================================================================\n\na1 = input()\na2 = input()\nif a1==a2:\n print(0)\n \nelse: \n if int(a1[:4]) > int(a2[:4]) or (a1[:4]==a2[:4] and int(a1[5:7])>int(a2[5:7])):\n temp = a1\n a1 = a2\n a2 = temp\n \n y1,m1,d1 = a1.split(':')\n y2,m2,d2 = a2.split(':')\n \n \n \n \n y1=int(y1)\n d1=int(d1)\n y2=int(y2)\n d2=int(d2)\n \n months = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n \n \n rem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':61, '11':31, '12':0}\n \n end_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n \n res = 0\n \n #checking whether first year is leap year if m1>02\n if y1!=y2:\n if m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \n else:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n \n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n \n else:\n res += (months[m1]-d1)\n mq = int(m1) + 1\n m2q = int(m2)\n while mq int(a2[:4]):\n temp = a1\n a1 = a2\n a2 = temp\n\ny1,m1,d1 = a1.split(':')\ny2,m2,d2 = a2.split(':')\n\n\n\n\ny1=int(y1)\nd1=int(d1)\ny2=int(y2)\nd2=int(d2)\n\nmonths = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n\n\nrem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':123, '09':92, '10':62, '11':31, '12':0}\n\nend_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n\nres = 0\n\n#checking whether first year is leap year if m1>02\n\nif m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \nelse:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n\n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n\ny1 += 1\n\nwhile y1 int(a2[:4]):\n temp = a1\n a1 = a2\n a2 = temp\n\ny1,m1,d1 = a1.split(':')\ny2,m2,d2 = a2.split(':')\n\n\n\n\ny1=int(y1)\nd1=int(d1)\ny2=int(y2)\nd2=int(d2)\n\nmonths = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n\n\nrem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':61, '11':31, '12':0}\n\nend_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n\nres = 0\n\n#checking whether first year is leap year if m1>02\n\nif m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \nelse:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n\n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n\ny1 += 1\n\nwhile y1 int(a2[:4]):\n temp = a1\n a1 = a2\n a2 = temp\n\ny1,m1,d1 = a1.split(':')\ny2,m2,d2 = a2.split(':')\n\n\n\n\ny1=int(y1)\nd1=int(d1)\ny2=int(y2)\nd2=int(d2)\n\nmonths = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n\n\nrem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':123, '09':92, '10':62, '11':31, '12':0}\n\nend_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n\nres = 0\n\n#checking whether first year is leap year if m1>02\n\nif m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \nelse:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n\n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n\ny1 += 1\n\nwhile y1 int(a2[:4]):\n temp = a1\n a1 = a2\n a2 = temp\n\ny1,m1,d1 = a1.split(':')\ny2,m2,d2 = a2.split(':')\n\n\n\n\ny1=int(y1)\nd1=int(d1)\ny2=int(y2)\nd2=int(d2)\n\nmonths = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n\n\nrem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':62, '11':31, '12':0}\n\nend_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n\nres = 0\n\n#checking whether first year is leap year if m1>02\n\nif m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \nelse:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n\n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n\ny1 += 1\n\nwhile y1 int(a2[:4]) or (a1[:4]==a2[:4] and int(a1[5:7])>int(a2[5:7])):\n temp = a1\n a1 = a2\n a2 = temp\n \n y1,m1,d1 = a1.split(':')\n y2,m2,d2 = a2.split(':')\n \n \n \n \n y1=int(y1)\n d1=int(d1)\n y2=int(y2)\n d2=int(d2)\n \n months = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n \n \n rem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':61, '11':31, '12':0}\n \n end_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n \n res = 0\n \n #checking whether first year is leap year if m1>02\n if y1!=y2:\n if m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \n else:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n \n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n \n \n y1 += 1\n \n while y1 int(a2[:4]) or (a1[:4]==a2[:4] and int(a1[5:7])>int(a2[5:7])):\n temp = a1\n a1 = a2\n a2 = temp\n \n y1,m1,d1 = a1.split(':')\n y2,m2,d2 = a2.split(':')\n \n \n \n \n y1=int(y1)\n d1=int(d1)\n y2=int(y2)\n d2=int(d2)\n \n months = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n \n \n rem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':61, '11':31, '12':0}\n \n end_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n \n res = 0\n \n #checking whether first year is leap year if m1>02\n if y1!=y2:\n if m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \n else:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n \n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n \n \n y1 += 1\n \n while y1 int(a2[:4]) or (a1[:4]==a2[:4] and int(a1[5:7])>int(a2[5:7])):\n temp = a1\n a1 = a2\n a2 = temp\n \n y1,m1,d1 = a1.split(':')\n y2,m2,d2 = a2.split(':')\n \n \n \n \n y1=int(y1)\n d1=int(d1)\n y2=int(y2)\n d2=int(d2)\n \n months = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n \n \n rem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':61, '11':31, '12':0}\n \n end_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n \n res = 0\n \n #checking whether first year is leap year if m1>02\n if y1!=y2:\n if m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \n else:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n \n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n \n \n y1 += 1\n \n while y1 int(a2[:4]) or (a1[:4]==a2[:4] and int(a1[5:7])>int(a2[5:7])):\n temp = a1\n a1 = a2\n a2 = temp\n \n y1,m1,d1 = a1.split(':')\n y2,m2,d2 = a2.split(':')\n \n \n \n \n y1=int(y1)\n d1=int(d1)\n y2=int(y2)\n d2=int(d2)\n \n months = {'01':31, '02':28, '03':31, '04':30, '05':31, '06':30,\n '07':31, '08':31, '09':30, '10':31, '11':30, '12':31}\n \n \n rem_months = {'01':334, '02':306, '03':275, '04':245, '05':214, '06':184,\n '07':153, '08':122, '09':92, '10':61, '11':31, '12':0}\n \n end_months = {'01':0, '02':31, '03':59, '04':90, '05':120, '06':151,\n '07':181, '08':212, '09':243, '10':273, '11':304, '12':334}\n \n res = 0\n \n #checking whether first year is leap year if m1>02\n if y1!=y2:\n if m1!='02' or m1!='01':\n res += (months[m1] - d1)\n res += (rem_months[m1])\n \n else:\n if y1%4==0 and leapyear(y1)==True:\n \n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 29\n else:\n res += (29-d1)\n \n else:\n if m1=='01':\n res += (months[str(m1)] - d1)\n res += 28\n else:\n res += (28-d1)\n \n res += (rem_months['03'])\n \n \n \n y1 += 1\n \n while y1end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):\n e=list(start)\n s=list(end)\nelse:\n e=list(end)\n s=list(start)\ndays=0\nfor i in range(s[0]+1,e[0]):\n if(i%400==0):\n days+=366\n elif(i%100==0):\n days+=365\n elif(i%4==0):\n days+=366\n else:\n days+=365\n\nmonth=[31,28,31,30,31,30,31,31,30,31,30,31]\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\n\nfor i in range(s[1]+1,13):\n days+=month[i-1]\n\nmonth[1]=28\n\nif(e[0]%400==0):\n month[1]+=1\nelif(e[0]%100==0):\n month[1]=28\nelif(e[0]%4==0):\n month[1]+=1\n\nfor i in range(0,e[1]-1):\n days+=month[i]\n\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\ndays+=e[2]\ndays+=month[s[1]-1]-s[2]\n\nif(s[0]==e[0]):\n days=0\n for i in range(s[1]+1,e[1]):\n days+=month[i-1]\n days+=e[2]-1\n days+=month[s[1]-1]-s[2]\nif(s[0]==e[0] and s[1]==e[1]):\n days=e[2]-s[2]\nif(s[0]==e[0] and s[1]==e[1] and s[2]==e[2]):\n days=0\n\nprint(days)\n"}, {"source_code": "start = input().split(\":\")\nend = input().split(\":\")\n\nstart[0],start[1],start[2]=int(start[0]),int(start[1]),int(start[2])\n\nend[0],end[1],end[2]=int(end[0]),int(end[1]),int(end[2])\n\n\nif((start[0]>end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):\n e=list(start)\n s=list(end)\nelse:\n e=list(end)\n s=list(start)\ndays=0\nfor i in range(s[0]+1,e[0]):\n if(i%400==0):\n days+=366\n elif(i%100==0):\n days+=365\n elif(i%4==0):\n days+=366\n else:\n days+=365\n\nmonth=[31,28,31,30,31,30,31,31,30,31,30,31]\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\n\nfor i in range(s[1]+1,13):\n days+=month[i-1]\n\nmonth[1]=28\n\nif(e[0]%400==0):\n month[1]+=1\nelif(e[0]%100==0):\n month[1]=28\nelif(e[0]%4==0):\n month[1]+=1\n\nfor i in range(0,e[1]-1):\n days+=month[i]\n\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\ndays+=e[2]\ndays+=month[s[1]-1]-s[2]\n\nif(s[0]==e[0]):\n days=0\n for i in range(s[1]+1,e[1]):\n days+=month[i-1]\n days+=e[2]\n days+=month[s[1]-1]-s[2]\nif(s[0]==e[0] and s[1]==e[1]):\n days=e[2]-s[2]+1\n\nprint(days)\n"}, {"source_code": "start = input().split(\":\")\nend = input().split(\":\")\n\nstart[0],start[1],start[2]=int(start[0]),int(start[1]),int(start[2])\n\nend[0],end[1],end[2]=int(end[0]),int(end[1]),int(end[2])\n\n\nif((start[0]>end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):\n e=list(start)\n s=list(end)\nelse:\n e=list(end)\n s=list(start)\nprint(s)\nprint(e)\ndays=0\nfor i in range(s[0]+1,e[0]):\n if(i%400==0):\n days+=366\n elif(i%100==0):\n days+=365\n elif(i%4==0):\n days+=366\n else:\n days+=365\n\nmonth=[31,28,31,30,31,30,31,31,30,31,30,31]\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\n\nfor i in range(s[1]+1,13):\n days+=month[i-1]\n\nmonth[1]=28\n\nif(e[0]%400==0):\n month[1]+=1\nelif(e[0]%100==0):\n month[1]=28\nelif(e[0]%4==0):\n month[1]+=1\n\nfor i in range(0,e[1]-1):\n days+=month[i]\n\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\ndays+=e[2]\ndays+=month[s[1]-1]-s[2]\n\nif(s[0]==e[0]):\n days=0\n for i in range(s[1]+1,e[1]):\n days+=month[i-1]\n days+=e[2]\n days+=month[s[1]-1]-s[2]\nif(s[0]==e[0] and s[1]==e[1]):\n days=e[2]-s[2]+1\n\nprint(days)\n"}, {"source_code": "start = input().split(\":\")\nend = input().split(\":\")\n\nstart[0],start[1],start[2]=int(start[0]),int(start[1]),int(start[2])\n\nend[0],end[1],end[2]=int(end[0]),int(end[1]),int(end[2])\n\n\nif((start[0]>end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):\n e=list(start)\n s=list(end)\nelse:\n e=list(end)\n s=list(start)\ndays=0\nfor i in range(s[0]+1,e[0]):\n if(i%400==0):\n days+=366\n elif(i%100==0):\n days+=365\n elif(i%4==0):\n days+=366\n else:\n days+=365\n\nmonth=[31,28,31,30,31,30,31,31,30,31,30,31]\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\n\nfor i in range(s[1]+1,13):\n days+=month[i-1]\n\nmonth[1]=28\n\nif(e[0]%400==0):\n month[1]+=1\nelif(e[0]%100==0):\n month[1]=28\nelif(e[0]%4==0):\n month[1]+=1\n\nfor i in range(0,e[1]-1):\n days+=month[i]\n\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\ndays+=e[2]\ndays+=month[s[1]-1]-s[2]\n\nif(s[0]==e[0]):\n days=0\n for i in range(s[1]+1,e[1]):\n days+=month[i-1]\n days+=e[2]\n days+=month[s[1]-1]-s[2]\nif(s[0]==e[0] and s[2]==e[2]):\n\n days=0\n for i in range(s[1],e[1]):\n days+=month[i-1]\nif(s[0]==e[0] and s[1]==e[1]):\n days=e[2]-s[2]\nif(s[0]==e[0] and s[1]==e[1] and s[2]==e[2]):\n days=0\n\nprint(days)\n"}, {"source_code": "start = input().split(\":\")\nend = input().split(\":\")\n\nstart[0],start[1],start[2]=int(start[0]),int(start[1]),int(start[2])\n\nend[0],end[1],end[2]=int(end[0]),int(end[1]),int(end[2])\n\n\nif((start[0]>end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):\n e=list(start)\n s=list(end)\nelse:\n e=list(end)\n s=list(start)\ndays=0\nfor i in range(s[0]+1,e[0]):\n if(i%400==0):\n days+=366\n elif(i%100==0):\n days+=365\n elif(i%4==0):\n days+=366\n else:\n days+=365\n\nmonth=[31,28,31,30,31,30,31,31,30,31,30,31]\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\n\nfor i in range(s[1]+1,13):\n days+=month[i-1]\n\nmonth[1]=28\n\nif(e[0]%400==0):\n month[1]+=1\nelif(e[0]%100==0):\n month[1]=28\nelif(e[0]%4==0):\n month[1]+=1\n\nfor i in range(0,e[1]-1):\n days+=month[i]\n\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\ndays+=e[2]\ndays+=month[s[1]-1]-s[2]\n\nif(s[0]==e[0]):\n days=0\n for i in range(s[1]+1,e[1]):\n days+=month[i-1]\n days+=e[2]\n days+=month[s[1]-1]-s[2]\nif(s[0]==e[0] and s[1]==e[1]):\n days=e[2]-s[2]+1\nif(s[0]==e[0] and s[1]==e[1] and s[2]==e[2]):\n days=0\n\nprint(days)\n"}, {"source_code": "start = input().split(\":\")\nend = input().split(\":\")\n\nstart[0],start[1],start[2]=int(start[0]),int(start[1]),int(start[2])\n\nend[0],end[1],end[2]=int(end[0]),int(end[1]),int(end[2])\n\n\nif((start[0]>end[0]) or (start[0]==end[0] and start[1]>end[1]) or (start[0]==end[0] and start[1]==end[1] and start[2]>end[2])):\n e=list(start)\n s=list(end)\nelse:\n e=list(end)\n s=list(start)\ndays=0\nfor i in range(s[0]+1,e[0]):\n if(i%400==0):\n days+=366\n elif(i%100==0):\n days+=365\n elif(i%4==0):\n days+=366\n else:\n days+=365\n\nmonth=[31,28,31,30,31,30,31,31,30,31,30,31]\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\n\nfor i in range(s[1]+1,13):\n days+=month[i-1]\n\nmonth[1]=28\n\nif(e[0]%400==0):\n month[1]+=1\nelif(e[0]%100==0):\n month[1]=28\nelif(e[0]%4==0):\n month[1]+=1\n\nfor i in range(0,e[1]-1):\n days+=month[i]\n\nif(s[0]%400==0):\n month[1]+=1\nelif(s[0]%100==0):\n month[1]=28\nelif(s[0]%4==0):\n month[1]+=1\ndays+=e[2]\ndays+=month[s[1]-1]-s[2]\n\nif(s[0]==e[0]):\n days=0\n for i in range(s[1]+1,e[1]):\n days+=month[i-1]\n days+=e[2]\n days+=month[s[1]-1]-s[2]\nif(s[0]==e[0] and s[1]==e[1]):\n days=e[2]-s[2]\nif(s[0]==e[0] and s[1]==e[1] and s[2]==e[2]):\n days=0\n\nprint(days)\n"}, {"source_code": "def get(y, m, d):\n if(m < 3):\n y -= 1\n m += 12\n return 365 * y + y // 4 - y //100 + y//400 + (153*m-457)//5+d-306"}, {"source_code": "from datetime import date\ni0 = input().split(':')\ni1 = input().split(':')\nd0 = date(int(i0[0]), int(i0[1]), int(i0[2]))\nd1 = date(int(i1[0]), int(i1[1]), int(i1[2]))\ndelta = d1 - d0\nprint(delta.days)"}, {"source_code": "from datetime import date\n\na = list(map(int, input().split(':')))\nb = list(map(int, input().split(':')))\n\nf_date = date(a[0],a[1],a[2])\nl_date = date(b[0], b[1], b[2])\ndelta = l_date - f_date\nprint(delta.days)\n\n\n"}, {"source_code": "import time\nimport datetime\nimport calendar\n\nif __name__ == '__main__':\n\n\n date1 = input().split(\":\")\n date1 = [int(x) for x in date1]\n date2 = input().split(\":\")\n date2 = [int(x) for x in date2]\n #print(date2)\n if date1[0] > date2[0]:\n tmp = date1.copy()\n date1 = date2\n date2 = tmp\n\n sum = 0\n for i in range(date1[0]+1, date2[0]):\n if i % 4 == 0:\n if i % 100 != 0:\n sum += 366\n continue\n if i % 400 == 0:\n sum += 366\n continue\n sum += 365\n continue\n\n\n if date1[0] != date2[0]:\n sumdays = 0\n for i in range(date1[1], 13):\n sumdays += calendar.monthrange(date1[0], i)[1]\n sumdays -= date1[2]\n\n sumdays2 = 0\n for i in range(1, date2[1]):\n sumdays2 += calendar.monthrange(date2[0], i)[1]\n sumdays2 += date2[2]\n sum += sumdays + sumdays2\n else:\n sumdays = 0\n for i in range(min(date1[1], date2[1]), max(date1[1], date2[1])):\n sumdays += calendar.monthrange(date1[0], i)[1]\n\n if date1[1] < date2[1]:\n sumdays += -date1[2] + date2[2]\n else:\n sumdays += -date2[2] + date1[2]\n sum += sumdays\n\n if date2[0] == date1[0] and date2[1] == date1[1] and date2[2] == date1[2]:\n sum = 0\n print(sum)\n\n\n\n\n\n\n"}, {"source_code": "import time\nimport datetime\nimport calendar\n\nif __name__ == '__main__':\n\n\n date1 = input().split(\":\")\n date1 = [int(x) for x in date1]\n date2 = input().split(\":\")\n date2 = [int(x) for x in date2]\n #print(date2)\n if date1[0] > date2[0]:\n tmp = date1.copy()\n date1 = date2\n date2 = tmp\n\n sum = 0\n for i in range(date1[0]+1, date2[0]):\n if i % 4 == 0:\n if i % 100 != 0:\n sum += 366\n continue\n if i % 400 == 0:\n sum += 366\n continue\n sum += 365\n continue\n\n sumdays = 0\n for i in range(date1[1], 13):\n sumdays += calendar.monthrange(date1[0], i)[1]\n sumdays -= date1[2]\n\n sumdays2 = 0\n for i in range(1, date2[1]):\n sumdays2 += calendar.monthrange(date2[0], i)[1]\n sumdays2 += date2[2]\n\n\n sum += sumdays + sumdays2\n\n if date2[0] == date1[0] and date2[1] == date1[1] and date2[2] == date1[2]:\n sum = 0\n print(sum)\n\n\n\n\n"}, {"source_code": "import time\nimport datetime\nimport calendar\n\nif __name__ == '__main__':\n\n\n date1 = input().split(\":\")\n date1 = [int(x) for x in date1]\n date2 = input().split(\":\")\n date2 = [int(x) for x in date2]\n #print(date2)\n if date1[0] > date2[0]:\n tmp = date1.copy()\n date1 = date2\n date2 = tmp\n\n sum = 0\n for i in range(date1[0]+1, date2[0]):\n if i % 4 == 0:\n if i % 100 != 0:\n sum += 366\n continue\n if i % 400 == 0:\n sum += 366\n continue\n sum += 365\n continue\n\n sumdays = 0\n for i in range(date1[1], 13):\n sumdays += calendar.monthrange(date1[0], i)[1]\n sumdays -= date1[2]\n\n sumdays2 = 0\n for i in range(1, date2[1]):\n sumdays2 += calendar.monthrange(date2[0], i)[1]\n sumdays2 += date2[2]\n\n\n sum += sumdays + sumdays2\n print(sum)\n\n\n\n\n"}, {"source_code": "from datetime import date\n\na = str(input())\nb = str(input())\n\nadate = a.split(\":\")\nbdate = b.split(\":\")\n\nda = date(int(adate[0]),int(adate[1]),int(adate[2]))\ndb = date(int(bdate[0]),int(bdate[1]),int(bdate[2]))\n\nprint((db-da).days)"}, {"source_code": "y1, m1, d1 = map(int, input().split(':'))\ny2, m2, d2 = map(int, input().split(':'))\nfrom datetime import date\na = date(y1, m1, d1)\nb = date(y2, m2, d2)\n#datetime.timedelta(7)\nprint((b-a).days)\n"}, {"source_code": "from datetime import date\ny1,m1,d1 = map(int,input().split(':'))\ny2,m2,d2 = map(int,input().split(':'))\ndate1 = date(y1,m1,d1)\ndate2 = date(y2,m2,d2)\nprint((date2-date1).days)\n"}, {"source_code": "def f(y, m, d): \n return 365 * y + 31 * m + d - ((y - 1) // 4 - (y - 1) // 100 + (y - 1) // 400) - ((2 + int(y % 4 or (y % 100 == 0 and y % 400))) * (m > 2) + (m > 4) + (m > 6) + (m > 9) + (m > 11))\nprint(abs(f(*map(int, input().split(':'))) - f(*map(int, input().split(':')))))"}, {"source_code": "year1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\tmonth1,month2 = month2,month1\n\tday1,day2 = day2,day1\n\n#dim = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}\ndim =[31,28,31,30,31,30,31,31,30,31,30,31]\nyears = 0\nleapdays = 0 \nfor i in range(year1+1,year2) :\n\tyears += 1\n\tif (i % 100 == 0) :\n\t\tif(i % 400 == 0 ) :\n\t\t\tleapdays += 1\n\telse :\n\t\tif(i%4 == 0):\n\t\t\tleapdays += 1\n\ndays = leapdays+(years*365)\n#print(days)\n\nfor i in range(month1+1,13) :\n\tdays = (days+ dim[i-1])\n\nfor i in range(1,month2):\n\tdays = (days + dim[i-1])\n\neday1 = (dim[month1-1]-day1)\ndays = days + eday1+(day2-1)\n\nif(month1 <= 2) :\n\tif(year1 % 100== 0) :\n\t\tif(year1 % 400==0) :\n\t\t\tdays += 1\n\telse :\n\t\tif (year1 % 4 == 0) :\n\t\t\tdays += 1\nif(month2>=3):\n\tif(year2 % 100== 0) :\n\t\tif(year2 % 400==0) :\n\t\t\tdays += 1\n\telse :\n\t\tif year2 % 4 == 0:\n\t\t\tdays += 1\n\nprint (days+1)"}, {"source_code": "def ifLeap(year):\n\tif(year %100 == 0):\n\t\tif(year%400 == 0):\n\t\t\treturn True\n\telif(year%4 == 0):\n\t\treturn True\n\treturn False\nyear1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\n\nmonth =[]\njan = []\nfor i in range(1,32):\n\tjan.append(i)\nmonth.append(jan)\nfeb = []\nfor i in range(32,61):\n\tfeb.append(i)\nmonth.append(feb)\nmar = []\nfor i in range(61,92):\n\tmar.append(i)\nmonth.append(mar)\napr =[]\nfor i in range(92,122):\n\tapr.append(i)\nmonth.append(apr)\nmay = []\nfor i in range(122,153):\n\tmay.append(i)\nmonth.append(may)\njun = []\nfor i in range(153,183):\n\tjun.append(i)\nmonth.append(jun)\njul = []\nfor i in range(183,214):\n\tjul.append(i)\nmonth.append(jul)\naug = []\nfor i in range(214,245):\n\taug.append(i)\nmonth.append(aug)\nsep =[]\nfor i in range(245,275):\n\tsep.append(i)\nmonth.append(sep)\noct = []\nfor i in range(275,306):\n\toct.append(i)\nmonth.append(oct)\nnov = []\nfor i in range(306,336):\n\tnov.append(i)\nmonth.append(nov)\ndec = []\nfor i in range(336,367):\n\tdec.append(i)\nmonth.append(dec)\n\nrday1 = month[month1-1][day1-1]\nrday2 = month[month2-1][day2-1]\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\trday1,rday2 = rday2,rday1\nelif(year2 == year1):\n\tif(rday2 < rday1):\n\t\tyear1,year2 = year2,year1\n\t\trday1,rday2 = rday2,rday1\ndifday = 0\ndifyear = year2 - year1\nif(rday2 < rday1):\n\tdifday = 366-rday1 + rday2\n\tdifyear -= 1\nelse :\n\tdifday = rday2 - rday1\nif(not ifLeap(year1)):\n\tif rday1<60 and rday2 > 60 :\n\t\tdifday -= 1\n\telif(rday1 > rday2 and rday1 <60):\n\t\tdifday -= 1\nelif(not ifLeap(year2)):\n\tif(rday2 < rday1 and rday2 > 60):\n\t\tdifday -= 1\ndifday += difyear * 365\nfor i in range(year1+1,year2):\n\tif(ifLeap(i)) :\n\t\tdifday += 1\nprint (difday)\n"}, {"source_code": "year1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\tmonth1,month2 = month2,month1\n\tday1,day2 = day2,day1\n\n#dim = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}\ndim =[31,28,31,30,31,30,31,31,30,31,30,31]\nyears = 0\nleapdays = 0 \nfor i in range(year1+1,year2) :\n\tyears += 1\n\tif (i % 100 == 0) :\n\t\tif(i % 400 == 0 ) :\n\t\t\tleapdays += 1\n\telse :\n\t\tif(i%4 == 0):\n\t\t\tleapdays += 1\n\ndays = leapdays+(years*365)\n\nfor i in range(month1+1,13) :\n\tdays = (days+ dim[i-1])\n\nfor i in range(1,month2):\n\tdays = (days + dim[i-1])\n\neday1 = 1+(dim[month1-1]-day1)\ndays = days + eday1+day2\n\nif(month1 >= 2) :\n\tif(year1 % 100== 0) :\n\t\tif(year1 % 400==0) :\n\t\t\tdays += 1\n\telse :\n\t\tif (year1 % 4 == 0) :\n\t\t\tdays += 1\nif(month2>=3):\n\tif(year2 % 100== 0) :\n\t\tif(year2 % 400==0) :\n\t\t\tdays += 1\n\telse :\n\t\tif year2 % 4 == 0:\n\t\t\tdays += 1\n\nprint (days-1)\n\n"}, {"source_code": "def ifLeap(year):\n\tif(year %100 == 0):\n\t\tif(year%400 == 0):\n\t\t\treturn True\n\telif(year%4 == 0):\n\t\treturn True\n\treturn False\nyear1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\n\nmonth =[]\njan = []\nfor i in range(1,32):\n\tjan.append(i)\nmonth.append(jan)\nfeb = []\nfor i in range(32,61):\n\tfeb.append(i)\nmonth.append(feb)\nmar = []\nfor i in range(61,92):\n\tmar.append(i)\nmonth.append(mar)\napr =[]\nfor i in range(92,122):\n\tapr.append(i)\nmonth.append(apr)\nmay = []\nfor i in range(122,153):\n\tmay.append(i)\nmonth.append(may)\njun = []\nfor i in range(153,183):\n\tjun.append(i)\nmonth.append(jun)\njul = []\nfor i in range(183,214):\n\tjul.append(i)\nmonth.append(jul)\naug = []\nfor i in range(214,245):\n\taug.append(i)\nmonth.append(aug)\nsep =[]\nfor i in range(245,275):\n\tsep.append(i)\nmonth.append(sep)\noct = []\nfor i in range(275,306):\n\toct.append(i)\nmonth.append(oct)\nnov = []\nfor i in range(306,336):\n\tnov.append(i)\nmonth.append(nov)\ndec = []\nfor i in range(336,367):\n\tdec.append(i)\nmonth.append(dec)\n\nrday1 = month[month1-1][day1-1]\nrday2 = month[month2-1][day2-1]\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\trday1,rday2 = rday2,rday1\nelif(year2 == year1):\n\tif(rday2 < rday1):\n\t\tyear1,year2 = year2,year1\n\t\trday1,rday2 = rday2,rday1\ndifday = 0\ndifyear = year2 - year1\nif(rday2 < rday1):\n\tdifday = 366-rday1 + rday2\n\tdifyear -= 1\nelse :\n\tdifday = rday2 - rday1\nif((not ifLeap(year1)) or (not ifLeap(year2))):\n\tif(rday1 < 60 and rday2 > 60):\n\t\tdifday -= 1\n\telif((rday2 60):\n\t\tdifday -= 1\ndifday += difyear * 365\nfor i in range(year1+1,year2):\n\tif(ifLeap(i)) :\n\t\tdifday += 1\nprint (difday)\n"}, {"source_code": "year1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\nif(year1 == year2 and day1 == day2 and month1 == month2) :\n\tprint (0)\n\texit()\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\tmonth1,month2 = month2,month1\n\tday1,day2 = day2,day1\n\n#dim = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}\ndim =[31,28,31,30,31,30,31,31,30,31,30,31]\nyears = 0\nleapdays = 0 \nfor i in range(year1+1,year2) :\n\tyears += 1\n\tif (i % 100 == 0) :\n\t\tif(i % 400 == 0 ) :\n\t\t\tleapdays += 1\n\telse :\n\t\tif(i%4 == 0):\n\t\t\tleapdays += 1\n\ndays = leapdays+(years*365)\n#print(days)\n\nfor i in range(month1+1,13) :\n\tdays = (days+ dim[i-1])\n\nfor i in range(1,month2):\n\tdays = (days + dim[i-1])\n\neday1 = (dim[month1-1]-day1)\ndays = days + eday1+(day2-1)\n\nif(month1 <= 2) :\n\tif(year1 % 100== 0) :\n\t\tif(year1 % 400==0) :\n\t\t\tdays += 1\n\telse :\n\t\tif (year1 % 4 == 0) :\n\t\t\tdays += 1\nif(month2>=3):\n\tif(year2 % 100== 0) :\n\t\tif(year2 % 400==0) :\n\t\t\tdays += 1\n\telse :\n\t\tif year2 % 4 == 0:\n\t\t\tdays += 1\n\nprint (days+1)"}, {"source_code": "def ifLeap(year):\n\tif(year %100 == 0):\n\t\tif(year%400 == 0):\n\t\t\treturn True\n\telif(year%4 == 0):\n\t\treturn True\n\treturn False\nyear1,month1,day1 = map(int,input().split(':'))\nyear2,month2,day2 = map(int,input().split(':'))\n\nmonth =[]\njan = []\nfor i in range(1,32):\n\tjan.append(i)\nmonth.append(jan)\nfeb = []\nfor i in range(32,61):\n\tfeb.append(i)\nmonth.append(feb)\nmar = []\nfor i in range(61,92):\n\tmar.append(i)\nmonth.append(mar)\napr =[]\nfor i in range(92,122):\n\tapr.append(i)\nmonth.append(apr)\nmay = []\nfor i in range(122,153):\n\tmay.append(i)\nmonth.append(may)\njun = []\nfor i in range(153,183):\n\tjun.append(i)\nmonth.append(jun)\njul = []\nfor i in range(183,214):\n\tjul.append(i)\nmonth.append(jul)\naug = []\nfor i in range(214,245):\n\taug.append(i)\nmonth.append(aug)\nsep =[]\nfor i in range(245,275):\n\tsep.append(i)\nmonth.append(sep)\noct = []\nfor i in range(275,306):\n\toct.append(i)\nmonth.append(oct)\nnov = []\nfor i in range(306,336):\n\tnov.append(i)\nmonth.append(nov)\ndec = []\nfor i in range(336,367):\n\tdec.append(i)\nmonth.append(dec)\n\nrday1 = month[month1-1][day1-1]\nrday2 = month[month2-1][day2-1]\n\nif(year2 < year1):\n\tyear1,year2 = year2,year1\n\trday1,rday2 = rday2,rday1\nelif(year2 == year1):\n\tif(rday2 < rday1):\n\t\tyear1,year2 = year2,year1\n\t\trday1,rday2 = rday2,rday1\ndifday = 0\ndifyear = year2 - year1\nif(rday2 < rday1):\n\tdifday = 366-rday1 + rday2\n\tdifyear -= 1\nelse :\n\tdifday = rday2 - rday1\nif((not ifLeap(year1)) or (not ifLeap(year2))):\n\tif(rday1 < 60 and rday2 > 60):\n\t\tdifday -= 1\nelif(not ifLeap(year1)):\n\tif((rday2 60):\n\t\tdifday -= 1\ndifday += difyear * 365\nfor i in range(year1+1,year2):\n\tif(ifLeap(i)) :\n\t\tdifday += 1\nprint (difday)\n"}, {"source_code": "import sys\n\nbegin = [int(x) for x in sys.stdin.readline().strip().split(\":\")]\nend = [int(x) for x in sys.stdin.readline().strip().split(\":\")]\n\nyear1 = begin[0] if begin[1] <= 2 else begin[0] + 1\nyear2 = end[0] - 1 if end[1] <= 2 else end[0]\n\nleaps = 0\nfor i in range(year1, year2 + 1):\n if((i % 4 == 0 and i % 100 != 0) or i % 400 == 0):\n print(i)\n leaps += 1\n \n \ndays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n\nsums = 0\nb = 0\nfor i in range(begin[1], 12):\n b += days[i]\nb += (days[begin[1]] - begin[2])\n\na = 0\nfor i in range(0, end[1] - 1):\n a += days[i]\na += end[2]\n\nsums = sums + a + b\nsums += 365 * ((end[0]) - (begin[0] + 1))\nsums += leaps\nprint(sums - 1)"}, {"source_code": "from datetime import date\nd0 = raw_input()\nd1 = raw_input()\nd0=d0.split(':')\nd1=d1.split(':')\na1=int(d0[0])\na2=int(d0[1])\na3=int(d0[2])\nb1=int(d1[0])\nb2=int(d1[1])\nb3=int(d1[2])\no1=date(a1,a2,a3)\no2=date(b1,b2,b3)\ndelta = o2 - o1\nprint delta.days"}, {"source_code": "def isLeapYear(y):\n if y % 4 == 0:\n if y % 400 == 0:\n return True\n elif y % 100 == 0:\n return False\n return True\n return False\n\n\ny1, m1, d1 = map(int, input().split(':'))\ny2, m2, d2 = map(int, input().split(':'))\nyear = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nleap_year = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\nif y1 > y2:\n y1, m1, d1, y2, m2, d2 = y2, m2, d2, y1, m1, d1\nelif y1 == y2:\n if m1 > m2:\n m1, d1, m2, d2 = m2, d2, m1, d1\n elif m1 == m2:\n if d1 > d2:\n d1, d2 = d2, d1\ns = 0\nif isLeapYear(y1):\n s += sum(leap_year[m1 - 1:]) - d1\nelse:\n s += sum(year[m1 - 1:]) - d1\nfor i in range(y1 + 1, y2):\n if isLeapYear(i):\n s += sum(leap_year)\n else:\n s += sum(year)\nif isLeapYear(y2):\n s += sum(leap_year[:m2 - 1]) + d2\nelse:\n s += sum(year[:m2 - 1]) + d2\nprint(s)\n"}, {"source_code": "def is_leap(x):\n if x % 4 == 0:\n if x % 100 == 0:\n if x % 400 == 0:\n return True\n else:\n return False\n else:\n return True\n else:\n return False\n\n\nfrom collections import OrderedDict\nfrom operator import itemgetter\n\nyear = sorted([[int(x) for x in input().split(':')] for i in range(2)], key=itemgetter(0, 1, 2))\ndic = OrderedDict({1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31})\n\nans = 0\nfor i in range(year[0][0], year[1][0] + 1):\n days = 365\n if is_leap(i):\n days = 366\n dic[2] = 29\n else:\n dic[2] = 28\n\n if i == year[0][0]:\n for k, j in dic.items():\n if k == year[0][1]:\n days -= year[0][2]\n ans+=days\n break\n else:\n days -= j\n\n elif i == year[1][0]:\n for k, j in dic.items():\n if k == year[1][1]:\n ans += year[1][2]\n break\n else:\n ans += j\n else:\n ans += days\n\nprint(ans)\n"}, {"source_code": "def leap(i):\n s=0\n if i % 4 == 0:\n if i % 100 == 0:\n if i % 400 == 0:\n s += 366\n else:\n s += 365\n else:\n s += 366\n else:\n s += 365\n return s\nyear=[0,31,28,31,30,31,30,31,31,30,31,30,31]\na=list(map(int,input().split(':')))\nb=list(map(int,input().split(':')));s=0\nif a[0]>b[0]:a,b=b,a\nelif a[0]==b[0]:\n s=0\n if a[1]>b[1]:a,b=b,a\n for i in range(a[1]+1,b[1]):s+=year[i]\n if a[1]==b[1]:print(abs(a[2]-b[2]));exit()\n s += b[2]\n s += year[a[1]] - a[2]\n if leap(a[0]) == 366 and a[1]<=2<=b[1]:s+=1\n print(s);exit()\nfor i in range(a[0]+1,b[0]):s+=leap(i)\nfor i in range(a[1]+1,13):s+=year[i]\nfor i in range(b[1]):s+=year[i]\ns+=b[2]\ns+=year[a[1]]-a[2]\nif leap(a[0])==366 and a[1]<=2:s+=1\nif leap(b[0])==366 and 2<=b[1]:s+=1\nprint(s)"}, {"source_code": "def leap(i):\n s=0\n if i % 4 == 0:\n if i % 100 == 0:\n if i % 400 == 0:\n s += 366\n else:\n s += 365\n else:\n s += 366\n else:\n s += 365\n return s\nyear=[0,31,28,31,30,31,30,31,31,30,31,30,31]\na=list(map(int,input().split(':')))\nb=list(map(int,input().split(':')));s=0\nif a[0]>b[0]:a,b=b,a\nelif a[0]==b[0]:\n s=0\n for i in range(a[1]+1,b[1]):s+=year[i]\n if a[1]==b[1]:print(abs(a[2]-b[2]));exit()\n s += b[2]\n s += year[a[1]] - a[2]\n if leap(a[0]) == 366 and a[1] == 1: s += 1\n if leap(b[0]) == 366 and 2 < b[1]: s += 1\n print(s);exit()\nfor i in range(a[0]+1,b[0]):s+=leap(i)\nfor i in range(a[1]+1,13):s+=year[i]\nfor i in range(b[1]):s+=year[i]\ns+=b[2]\ns+=year[a[1]]-a[2]\nif leap(a[0])==366 and a[1]==1:s+=1\nif leap(b[0])==366 and 2b[0]:a,b=b,a\nelif a[0]==b[0]:\n s=0\n if a[1]>b[1]:a,b=b,a\n for i in range(a[1]+1,b[1]):s+=year[i]\n if a[1]==b[1]:print(abs(a[2]-b[2]));exit()\n s += b[2]\n s += year[a[1]] - a[2]\n if leap(a[0]) == 366 and a[1]<2b[0]:a,b=b,a\nelif a[0]==b[0]:\n s=0\n if a[1]>b[1]:a,b=b,a\n for i in range(a[1]+1,b[1]):s+=year[i]\n if a[1]==b[1]:print(abs(a[2]-b[2]));exit()\n s += b[2]\n s += year[a[1]] - a[2]\n if leap(a[0]) == 366 and a[1]<=2<=b[1]:s+=1\n print(s);exit()\nfor i in range(a[0]+1,b[0]):s+=leap(i)\nfor i in range(a[1]+1,13):s+=year[i]\nfor i in range(b[1]):s+=year[i]\ns+=b[2]\ns+=year[a[1]]-a[2]\nif leap(a[0])==366 and a[1]<2:s+=1\nif leap(b[0])==366 and 2b[0]:a,b=b,a\nelif a[0]==b[0]:\n s=0\n for i in range(a[1]+1,b[1]):s+=year[i]\n if a[1]==b[1]:print(abs(a[2]-b[2]));exit()\n s += b[2]\n s += year[a[1]] - a[2]\n if leap(a[0]) == 366 and a[1]<2 a]\n\na, b, k = map(int, input().split())\n\np = f(a - 1, b)\n\nif 3 > a and b > 1: \n p = [2] + p\n \nif k > len(p): print(-1)\n\nelif len(p) == k: \n print(max(p[k - 1] - a + 1, b - p[0] + 1))\n\nelse: \n print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))"}, {"source_code": "I = lambda : map(int,input().split())\nvisited = [False for i in range (10**6+1)]\n#prime = {}\na , b , k =I()\nvisited[1] = True\nli = []\nfor i in range(2,int(b**(0.5))+1) :\n #print(visited[:14])\n if visited[i] == False :\n #prime[i] = 1\n for j in range (i+i,b+1 , i) :\n visited[j] =True\nfor i in range (a,b+1) :\n if visited[i] == False :\n li.append(i)\nans = 0 \nmaxx = 0 \n#print(li)\nt1 = a\n#print(li)\nif len(li) < k :\n exit(print(\"-1\"))\nn = len(li)\nfor i in range (n-k+1) :\n ans = li[i+k-1] -t1 + 1\n #print(ans)\n maxx = max(maxx,ans)\n t1 = li[i] + 1\nww = b - li[-k] + 1\n#print(ww)\nmaxx = max(ww,maxx)\nprint(maxx)"}, {"source_code": "def f(n):\n m = int(n ** 0.5) + 1\n t = [1] * (n + 1)\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n + 1, 2) if t[i]]\n\na, b, k = map(int, input().split())\nn = 2000001\n\nt, p, x = [-1] * n, f(n), -1\nk -= 1; b += 1\n\nfor i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n\nt.reverse()\nfor i in range(1, n):\n if t[i] < 0: t[i] = t[i - 1] + 1\nt.reverse()\n\nfor i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n\nfor l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\nprint(x)"}, {"source_code": "def f(n):\n m, l = int(n ** 0.5) + 1, n - 1\n t = [1] * n\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((l - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n, 2) if t[i]]\n\na, b, k = map(int, input().split())\nk -= 1; b += 1; n = b + 100\n\nt, p, x = [-1] * n, f(n), -1\n\nfor i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n\nt.reverse()\nfor i in range(1, n):\n if t[i] < 0: t[i] = t[i - 1] + 1\nt.reverse()\n\nif len(p) > k: \n for i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n\n for l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\nprint(x)"}, {"source_code": "def f(a, b):\n t = [1] * (b + 1)\n for i in range(3, int(b ** 0.5) + 1):\n if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)\n return [i for i in range(3, b + 1, 2) if t[i] and i > a]\n\na, b, k = map(int, input().split())\n\np = f(a - 1, b)\nif 3 > a and b > 1: p = [2] + p\n \nif k > len(p): print(-1)\nelif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))"}, {"source_code": "def f(a, b):\n\n t = [1] * (b + 1)\n\n for i in range(3, int(b ** 0.5) + 1):\n\n if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)\n\n return [i for i in range(3, b + 1, 2) if t[i] and i > a]\n\n\n\na, b, k = map(int, input().split())\n\n\n\np = f(a - 1, b)\n\nif 3 > a and b > 1: p = [2] + p\n\n \n\nif k > len(p): print(-1)\n\nelif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))\n\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def main():\n def f(n):\n m = int(n ** 0.5) + 1\n t = [1] * (n + 1)\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n + 1, 2) if t[i]]\n\n a, b, k = map(int, input().split())\n n = 1100001\n \n t, p, x = [-1] * n, f(n), -1\n k -= 1; b += 1\n\n for i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n for i in range(1,n):\n if t[-i] < 0:\n t[-i] = t[-i + 1] + 1\n for i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n for l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\n print(x)\nmain()"}, {"source_code": "def f(a, b):\n t = [1] * (b + 1)\n for i in range(3, int(b ** 0.5) + 1):\n if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)\n return [i for i in range(3, b + 1, 2) if t[i] and i > a]\n\na, b, k = map(int, input().split())\n\np = f(a - 1, b)\nif 3 > a and b > 1: p = [2] + p\n \nif k > len(p): print(-1)\nelif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))"}, {"source_code": "# ~*~ coding:utf-8 ~*-\nfrom bisect import bisect_left\n\na, b, k = map(int, raw_input().split())\n\nnums = [True] * (10 ** 6 + 1)\n\nnums[0] = False\nnums[1] = False\n\nfor i in xrange(2, 10 ** 3 + 1):\n if not nums[i]:\n continue\n for j in xrange(i + i, 10 ** 6 + 1, i):\n nums[j] = False\n\nprimes = [i for i, e in enumerate(nums) if e]\npct = len(primes)\n\nif b == 1:\n print -1\n exit()\n\np = bisect_left(primes, a)\nif p + k - 1 >= pct:\n print -1\n exit()\nelse:\n req = primes[p + k - 1] - a + 1\nrest = b - a + 1\n\nif rest < req:\n print -1\n exit()\n\nfor i in xrange(a, b + 1):\n if rest < req:\n print rest + 1\n break\n if i == primes[p]:\n p += 1\n if p + k - 1 >= pct:\n print rest\n exit()\n else:\n req = max(req, primes[p + k - 1] - (primes[p - 1] + 1) + 1)\n rest -= 1\nelse:\n print 1\n"}, {"source_code": "r = raw_input().split()\na = int(r[0])\nb = int(r[1])\nk = int(r[2])\nc = []\nd = []\nfor x in range(b+1):\n c.append(1)\nc[1] = 1\nfor x in range(2,b+1):\n if c[x] == 1:\n #print x\n if a <= x <= b:\n d.append(x)\n for y in range(2, b//x+1):\n c[y*x] = 0\n#d.append(b)\nif len(d) >= k:\n j = d[k-1]\n l = d[-k]\nfor x in range(1,len(d)-k+1):\n d[len(d)-x] -= d[len(d)-x-k]\nif len(d) == k:\n print str(max(b - d[0] + 1, d[len(d)-1] - a + 1))\nelif len(d) < k:\n print -1\nelse:\n for x in range(0, k):\n d[x] = 0\n #print d, a, b\n g = max(d)\n g = max(g, j - a + 1, b - l + 1)\n print g"}, {"source_code": "from bisect import *\ndef main():\n p = [0] * 2 + [1] * (10 ** 6 + 10)\n x = []\n for i in xrange(2, 10 ** 6 + 10):\n if p[i]:\n x.append(i)\n for j in xrange(i+i, 10 ** 6 + 10, i):\n p[j] = 0\n a, b, k = map(int, raw_input().split())\n cnt = 0\n i = a\n while i <= b:\n if p[i]: cnt += 1\n if cnt == k: break\n i += 1\n if cnt < k:\n print -1\n return\n ans = i - a + 1\n s = bisect_left(x, a)\n while s+k < len(x) and x[s+k] <= b:\n #print s, x[s], x[s+k]\n ans = max(x[s+k] - x[s], ans)\n s += 1\n cnt = 0\n i = b\n while i >= a:\n if p[i]: cnt += 1\n if cnt == k: break\n i -= 1\n ans = max(b - i + 1, ans)\n \"\"\"s = bisect_left(x, b + 1) - 1\n while s >= k and x[s-k] >= a:\n print s, x[s], x[s-k]\n ans = max(x[s] - x[s-k], ans)\n s -= 1\"\"\"\n print ans\nmain()\n\n"}, {"source_code": "DEBUG = False\n\na, b, k = [int(x) for x in raw_input().split()]\nMAXN = b + 100\nisprime = [True] * MAXN\nisprime[0] = isprime[1] = False\nfor i in xrange(2, MAXN):\n if isprime[i]:\n for j in xrange(i + i, MAXN, i):\n isprime[j] = False\np = q = a\ncount = 0\nwhile q <= b:\n if count < k:\n count += isprime[q]\n q += 1\n if DEBUG:\n print 'Right', p, q, count\n else:\n count -= isprime[p]\n p += 1\n count += isprime[q]\n q += 1\n if DEBUG: \n print 'Together', p, q, count\n\ntemp = b\ncount = 0\nwhile count < k and temp >= a:\n if isprime[temp]:\n count += 1\n temp -= 1\n\nprint max(q - p, b - temp) if count == k else -1"}, {"source_code": "def sieve(n):\n s = xrange(3, n + 1, 2)\n r = set(s)\n [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]\n return r.union([2])\na,b,k=map(int,raw_input().split())\np=filter(lambda x:x>=a and x<=b,sorted(sieve(b)))\nif len(p)= a:\n p.append(i)\n for j in range(i*i, b+1, i):\n t[j]=0\nif len(p) < k:\n print -1\nelse:\n m=[p[i]-p[i-k] for i in range(k, len(p))]+[p[k-1]-a+1,b-p[-k]+1]\n\n print max(m)"}, {"source_code": "a, b, k = map(int, raw_input().split())\nt, p = [True] * (b + 1), []\nfor i in range(2, b + 1):\n\tif t[i]:\n\t\tif i >= a:\n\t\t\tp.append(i)\n\t\tfor j in range(i * i, b + 1, i):\n\t\t\tt[j] = False\nprint -1 if len(p) < k else max([p[i] - p[i - k] for i in range(k, len(p))] + [b - p[-k] + 1, p[k - 1] - a + 1])"}, {"source_code": "def sv(a, b):\n t = [1] * (b + 1)\n for i in range(3, int(b ** 0.5) + 1):\n if t[i]:\n for j in range(i*i,b+1,i):\n t[j] = 0\n return [i for i in range(3,b+1,2) if t[i] and i>a]\na, b, k = map(int, raw_input().split())\np = sv(a - 1, b)\nif 3 > a and b > 1: p = [2] + p\nif k > len(p): \n print(-1)\nelif len(p) == k:\n print(max(p[k - 1] - a + 1, b - p[0] + 1))\nelse: \n print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))\n\n"}, {"source_code": "##http://codeforces.ru/problemset/problem/237/C\nimport time\n\ndef eratosfen_interval(a, b ,k, toprint):\n l = [True]*(b+1)\n i = 2\n primelist = []\n while i <= len(l):\n try:\n i = l.index(True, i)\n if a <= i <= b:\n primelist.append(i)\n except ValueError:\n i = len(l) +1\n for j in xrange(2*i, len(l), i):\n l[j] = False\n i+=1\n del(l)\n \n if k > len(primelist): return -1\n interval = max(primelist[k-1] - a + 1, b - primelist[-k]+1)\n\n\n if toprint: print primelist\n if toprint: print 'interval', interval\n \n for i in xrange(0, len(primelist)-k, 1):\n if toprint: print 'i', i\n if toprint: print 'interval', interval\n if toprint: print 'dif', primelist[i+k] - primelist[i]\n interval = max(interval, primelist[i+k] - primelist[i])\n return interval\n\n\na, b ,k = map(int, raw_input().split())\n\nprint eratosfen_interval(a, b ,k, toprint = False)\n\n"}, {"source_code": "def f(a, b):\n t = [1] * (b + 1)\n for i in range(3, int(b ** 0.5) + 1):\n if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)\n return [i for i in range(3, b + 1, 2) if t[i] and i > a]\n\na, b, k = map(int, raw_input().split())\n\np = f(a - 1, b)\nif 3 > a and b > 1: p = [2] + p\n \nif k > len(p): print(-1)\nelif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))"}, {"source_code": "def main():\n def sieve(n):\n s = xrange(3, n + 1, 2)\n r = set(s)\n [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]\n return r.union([2])\n a,b,k=map(int,raw_input().split())\n p=filter(lambda x:x>=a and x<=b,sorted(sieve(b)))\n if len(p)= a and x <= b]\n if len(primes) < k:\n return -1\n\n l = primes[k - 1] - a + 1\n for p_i in range(len(primes) - k):\n prime1 = primes[p_i]\n prime2 = primes[p_i + k]\n l = max(l, prime2 - prime1)\n l = max(l, b - primes[len(primes) - k] + 1)\n return l\n\na, b, k = read_ints()\nprint solve(a, b, k)\n"}, {"source_code": "DEBUG = False\n\na, b, k = [int(x) for x in raw_input().split()]\nMAXN = b + 100\nisprime = [True] * MAXN\nisprime[0] = isprime[1] = False\nfor i in xrange(2, MAXN):\n if isprime[i]:\n for j in xrange(i + i, MAXN, i):\n isprime[j] = False\np = q = a\ncount = 0\nwhile q <= b:\n if count < k:\n count += isprime[q]\n q += 1\n if DEBUG:\n print 'Right', p, q, count\n else:\n count -= isprime[p]\n p += 1\n count += isprime[q]\n q += 1\n if DEBUG: \n print 'Together', p, q, count\n\ntemp = b\ncount = 0\nwhile count < k and temp >= a:\n if isprime[temp]:\n count += 1\n temp -= 1\n\nprint max(q - p, b - temp) if count == k else -1\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\ndef sieveoferatosthenes(n):\n lst=[]\n prime = [True for i in range(n+1)]\n p=2\n while(p * p <= n):\n\n if (prime[p] == True):\n\n for i in range(p * 2, n+1, p):\n prime[i] = False\n p+=1\n lis =[]\n\n for p in range(2, n):\n if prime[p]:\n lst.append(p)\n return lst\nfrom bisect import *\nlst=sieveoferatosthenes(1000002)\nl=0\nh=10**6+2\nl1=[]\nl2=[]\nfor i in range(0,1000000):\n l1.append(bisect_left(lst,i))\nfor i in range(0,1500000):\n l2.append(bisect(lst,i))\nfor i in range(1,22):\n m=(l+h)/2\n c=0\n for x in range(a,b-m+2):\n sv=x\n ev=x+m-1\n # print sv,ev,m\n # ix1=bisect_left(lst,sv)\n # ix2=bisect(lst,ev)\n ix1=l1[sv]\n ix2=l2[ev]\n # print ix2,ix1\n if ix2-ix1 mid:\n\t\t\ttakeAway = arr[i - mid]\n\n\t\ttotalSum -= takeAway\n\n\t\tif size >= mid:\n\t\t\tif totalSum < k:\n\t\t\t\treturn False\n\n\n\n\tif totalSum < k:\n\t\treturn False\n\treturn True\n\n\n\nsplitted = raw_input().split(\" \")\na = int(splitted[0])\nb = int(splitted[1])\nk = int(splitted[2])\n\n#generate primes up to b, using sieve\nsieve = [True] * (b + 1)\nprimes = deque()\nfor i in range(2, b + 1):\n\t#print (i)\n\tif sieve[i]:\n\t\tprimes.append(i)\n\telse:\n\t\tcontinue\n\tj = 2 * i\n\twhile j < b + 1:\n\t\tsieve[j] = False\n\t\tj += i\n\narr = [0] * (b + 1)\nfor prime in primes:\n\tarr[prime] = 1\n#print (primes)\n#print (arr)\ncounter = 0\nsavedI = -1\nlow = 1\nhigh = b - a + 1\nwhile low + 1 < high:\n\tmid = low + (high - low)/2\n\t#print (str(low) + \", \" + str(high))\n\tif p(mid, arr, k) == True:\n\t\thigh = mid\n\t\t#print (str(mid) + \" returned true\")\n\telse:\n\t\tlow = mid\n\t\t#print (str(mid) + \" returned false\")\nif p(high, arr, k) == True:\n\tprint (high)\nelse:\n\tprint (-1)"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 20.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\n#from 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\nprime = [True for i in range(10000005)] \nx=[]\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 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 \n # Print all prime numbers \n for p in range(2, n): \n if prime[p]: \n x.append(p)\n\n\n\n\n\n\ndef main():\n \n\n #for _ in range(ii()):\n \n \n a,b,k=mi()\n SieveOfEratosthenes(1000000)\n prime[1]=False\n f=[]\n f.append(0)\n for i in range(a,b+1):\n if prime[i]:\n f.append(1)\n else:\n f.append(0)\n\n le=b-a+1\n\n\n for i in range(1,le+1):\n f[i]+=f[i-1]\n\n\n l=0\n r=le\n ans=-1\n while l<=r:\n mid=(l+r)//2\n flag=1\n\n for i in range(1,le+1):\n\n if i+mid-1>le:\n break\n\n\n if f[i+mid-1]-f[i-1]=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n"}, {"source_code": "MAX=10**6+1\ndp=[0]*(MAX+10)\nprime=[1 for i in range(MAX+1)]\np=2\nwhile p*p<=MAX:\t\n\tif prime[p]==1:\n\t\tfor i in range(p*2,MAX+1,p):\n\t\t\tprime[i]=0\n\tp+=1\nprime[0]=0\nprime[1]=0\nfor i in range(1,MAX):\n\tdp[i]=dp[i-1]+prime[i]\na,b,k=map(int,raw_input().split())\nif dp[b]-dp[a-1]b:\n\t\t\t\tbreak\n\t\t\tif dp[i+mid-1]-dp[i-1]=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\nt,p=[True]*(b+1),[]\nfor i in range(2,b+1):\n if t[i]:\n if i>=a:p.append(i)\n for j in range(i * i, b + 1, i):t[j] = False\nprint -1 if len(p) < k else max([p[i]-p[i-k] for i in range(k,len(p))] + [b-p[-k]+1,p[k-1]-a+1])\n\n"}, {"source_code": "import sys\nfrom math import gcd,sqrt,ceil\nfrom collections import defaultdict,Counter,deque\nfrom bisect import bisect_left,bisect_right\nimport math\n\n# input=sys.stdin.readline\n# def print(x):\n# sys.stdout.write(str(x)+\"\\n\")\n\n# sys.stdout=open(\"CP1/output.txt\",'w')\n# sys.stdin=open(\"CP1/input.txt\",'r')\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 ifposs(l):\n\n i = a\n # print(l)\n while b-i+1>=l:\n\n z = i+l-1\n\n\n if pre[z]-pre[i-1]> 1\n ok = True\n for i in range(a, b - mid + 2):\n if dp[i + mid - 1] - dp[i - 1] < k:\n ok = False\n break\n if ok:\n high = mid\n else:\n low = mid + 1\n print(low if low <= (b - a + 1) else - 1)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from math import floor, sqrt\n\n\ndef siv(limit, primes):\n mark = [False] * (limit + 1)\n for i in range(2, limit + 1):\n if not mark[i]:\n primes.append(i)\n for j in range(i, limit + 1, i):\n mark[j] = True\n\n\ndef pir(low, high, prims):\n limit = floor(sqrt(high)) + 1\n primes = list()\n siv(limit, primes)\n n = high - low + 1\n mark = [False] * (n + 1)\n for i in range(len(primes)):\n loLim = floor(low / primes[i]) * primes[i]\n if loLim < low:\n loLim += primes[i]\n if loLim == primes[i]:\n loLim += primes[i]\n for j in range(loLim, high + 1, primes[i]):\n mark[j - low] = True\n pc = 0\n for i in range(low, high + 1):\n if not mark[i - low]:\n prims.append(i)\n pc += 1\n return pc\n\n\na, b, k = [int(i) for i in input().split()]\n\nprims = []\npc = pir(a, b, prims)\nif pc!= 0 and prims[0] == 1:\n prims.remove(1)\n pc-=1\n\nif pc < k:\n print(-1)\n exit()\n\nmx = max(prims[k - 1] - a + 1, b - prims[len(prims) - k] + 1)\n\nfor i in range(len(prims) - k):\n mx = max(prims[i + k] - prims[i], mx)\n\nprint(mx)"}, {"source_code": "N = int(1e6+3)\nis_prime = [0] * N\n\ndef primes():\n for i in range(2, N):\n if is_prime[i] == 1:\n continue\n for j in range(2*i, N, i):\n is_prime[j] = 1\n\na, b, k = map(int, input().split())\nprimes()\ncnt_primes = [0] * N\nfor i in range(2, N):\n cnt_primes[i] = cnt_primes[i-1] + (1 - is_prime[i])\n\ndef valid(x):\n for i in range(a, b-x+2):\n if cnt_primes[i+x-1] - cnt_primes[i-1] < k:\n return False\n return True\n \ndef binary_search():\n f, e = 1, b-a+1\n while e >= f:\n m = f+e >> 1\n if valid(m):\n e = m - 1 \n else:\n f = m + 1\n return f\n\nres = binary_search()\nprint(res if valid(res) and res <= b-a+1 else -1)\n"}, {"source_code": "p=[1]*(1000005)\np[0]=0\np[1]=0\nfor i in range(2,1001):\n if p[i]:\n for j in range(2*i,1000005,i):\n p[j]=0\nfor i in range(1,1000001):\n p[i]+=p[i-1]\na,b,k=map(int,input().split())\nif p[b]-p[a-1]=a :\n li = li + [i]\n for j in range (i+i,b+1 , i) :\n visited[j] =True\n \nans = 0 \nmaxx = 0 \n#print(prime)\nc = k\nc1 =0 \nt1 =0 \nif len(li) a]\n\na, b, k = map(int, input().split())\n\np = f(a - 1, b)\nif 3 > a: p = [2] + p\n \nif k > len(p): print(-1)\nelif len(p) == k: print(max(p[k - 1] - a + 1, b - p[0] + 1))\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1, max(p[i + k] - p[i] for i in range(len(p) - k))))"}, {"source_code": "def f(n):\n m = int(n ** 0.5) + 1\n t = [1] * (n + 1)\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n + 1, 2) if t[i]]\n\na, b, k = map(int, input().split())\nk -= 1; b += 1\n\nt, p, x = [-1] * b, f(b), -1\n\nfor i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n\nt.reverse()\nfor i in range(1, b):\n if t[i] < 0: t[i] = t[i - 1] + 1\nt.reverse()\n\nif len(p) > k: \n for i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n\n for l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\nprint(x)"}, {"source_code": "def f(a, b):\n t = [1] * (b + 1)\n for i in range(3, int(b ** 0.5) + 1):\n if t[i]: t[i * i :: 2 * i] = [0] * ((b - i * i) // (2 * i) + 1)\n return [i for i in range(3, b + 1, 2) if t[i] and i > a]\n\na, b, k = map(int, input().split())\n\np = f(a - 1, b)\nif 3 > a: p = [2] + p\n \nif k > len(p): print(-1)\nelse: print(max(p[k - 1] - a + 1, b - p[len(p) - k] + 1))"}, {"source_code": "def f(n):\n m = int(n ** 0.5) + 1\n t = [1] * (n + 1)\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n + 1, 2) if t[i]]\n\na, b, k = map(int, input().split())\nk -= 1; b += 1\n\nt, p, x = [-1] * (b + 100), f(b + 100), -1\n\nfor i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n\nt.reverse()\nfor i in range(1, b):\n if t[i] < 0: t[i] = t[i - 1] + 1\nt.reverse()\n\nif len(p) > k: \n for i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n\n for l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\nprint(x)"}, {"source_code": "def main():\n def f(n):\n m = int(n ** 0.5) + 1\n t = [1] * (n + 1)\n for i in range(3, m):\n if t[i]: t[i * i :: 2 * i] = [0] * ((n - i * i) // (2 * i) + 1)\n return [2] + [i for i in range(3, n + 1, 2) if t[i]]\n\n a, b, k = map(int, input().split())\n n = 1000001\n \n t, p, x = [-1] * n, f(n), -1\n k -= 1; b += 1\n\n for i in range(len(p) - k):\n t[p[i]] = p[i + k] - p[i]\n for i in range(1,n):\n if t[-i] < 0:\n t[-i] = t[-i + 1] + 1\n for i in range(a + 1, b):\n t[i] = max(t[i], t[i - 1])\n for l in range(1, b - a + 1):\n if t[b - l] < l:\n x = l\n break\n print(x)\nmain()"}, {"source_code": "# ~*~ coding:utf-8 ~*-\nfrom bisect import bisect_left\n\na, b, k = map(int, raw_input().split())\n\nnums = [True] * (10 ** 6 + 1)\n\nnums[0] = False\nnums[1] = False\n\nfor i in xrange(2, 10 ** 3 + 1):\n if not nums[i]:\n continue\n for j in xrange(i + i, 10 ** 6 + 1, i):\n nums[j] = False\n\nprimes = [i for i, e in enumerate(nums) if e]\npct = len(primes)\n\nif b == 1:\n print -1\n exit()\n\np = bisect_left(primes, a)\nif (p + k - 1) >= pct:\n print -1\n exit()\nelse:\n req = primes[p + k - 1] - a + 1\nrest = b - a + 1\n\nif rest < req:\n print -1\n exit()\n\nfor i in xrange(a, b + 1):\n if rest < req:\n print rest + 1\n break\n if i == primes[p]:\n p += 1\n if (p + k - 1) >= pct:\n print rest\n exit()\n else:\n req = max(req, primes[p + k - 1] - (primes[p - 1] + 1) + 1)\n rest -= 1\n\n"}, {"source_code": "r = raw_input().split()\na = int(r[0])\nb = int(r[1])\nk = int(r[2])\nc = []\nd = []\nfor x in range(b+1):\n c.append(1)\nc[1] = 1\nfor x in range(2,b+1):\n if c[x] == 1:\n #print x\n if a <= x <= b:\n d.append(x)\n for y in range(2, b//x+1):\n c[y*x] = 0\n#d.append(b)\nif not d == []:\n j = d[0]\n l = d[-1]\nfor x in range(1,len(d)-k+1):\n d[len(d)-x] -= d[len(d)-x-k]\nif len(d) == k:\n print str(max(b - d[0] + 1, d[len(d)-1] - a + 1))\nelif len(d) < k:\n print -1\nelse:\n for x in range(0, k):\n d[x] = 0\n #print d, a, b\n g = max(d)\n g = max(g, j - a + 1, b - l + 1)\n print g"}, {"source_code": "r = raw_input().split()\na = int(r[0])\nb = int(r[1])\nk = int(r[2])\nc = []\nd = []\nfor x in range(b+1):\n c.append(1)\nc[1] = 1\nfor x in range(2,b+1):\n if c[x] == 1:\n if a <= x <= b:\n d.append(x)\n for y in range(2, b//x+1):\n c[y*x] = 0\n#d.append(b)\nfor x in range(1,len(d)-k+1):\n d[len(d)-x] -= d[len(d)-x-k]\nif len(d) == k:\n print str(max(b - d[0] + 1, d[len(d)-1] - a + 1))\nelif len(d) < k:\n print -1\nelse:\n for x in range(0, k):\n d[x] = 0\n #print d, a, b\n g = max(d)\n print g"}, {"source_code": "def sieve(n):\n s = xrange(3, n + 1, 2)\n r = set(s)\n [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]\n return r.union([2])\na,b,k=map(int,raw_input().split())\np=filter(lambda x:x>=a,sieve(b+1))\ntry :\n print max (p[0]-a,b-p[-1],max([p[i+k]-p[i] for i in range(len(p)-k)]))\nexcept:\n print -1\n"}, {"source_code": "def sieve(n):\n s = xrange(3, n + 1, 2)\n r = set(s)\n [r.difference_update(xrange(n << 1, s[-1] + 1, n)) for n in s if n in r]\n return r.union([2])\na,b,k=map(int,raw_input().split())\np=filter(lambda x:x>=a,sorted(sieve(b)))\nif len(p)=a,sieve(b))\nif len(p)=a and x<=b,sorted(sieve(b)))\nif len(p)=a:\n if isprime[j]:\n count +=1\n if count == k:\n minl = b - j +1\n found = True\n end = True\n j-=1\n if not found:\n minl = minl = -1\n end = True\nprint minl\n"}, {"source_code": "a,b,k=map(int,raw_input().split())\ndef sieveoferatosthenes(n):\n lst=[]\n prime = [True for i in range(n+1)]\n p=2\n while(p * p <= n):\n\n if (prime[p] == True):\n\n for i in range(p * 2, n+1, p):\n prime[i] = False\n p+=1\n lis =[]\n\n for p in range(2, n):\n if prime[p]:\n lst.append(p)\n return lst\nfrom bisect import *\nlst=sieveoferatosthenes(1000002)\nl=0\nh=10**8\nl1=[]\nl2=[]\nfor i in range(0,1000000):\n l1.append(bisect_left(lst,i))\nfor i in range(0,2000000):\n l2.append(bisect(lst,i))\nfor i in range(1,30):\n m=(l+h)/2\n c=0\n for x in range(a,b-m+2):\n sv=x\n ev=x+m-1\n # print sv,ev,m\n # ix1=bisect_left(lst,sv)\n # ix2=bisect(lst,ev)\n ix1=l1[sv]\n ix2=l2[ev]\n # print ix2,ix1\n if ix2-ix10:\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\n\na,b,k = map(int,input().split())\n\npri = []\nh = seive(b+1)\nh[1] = False\nfor i in range(a,b+1):\n if h[i] == True:\n\n pri.append(i)\n\n# print(pri)\nif len(pri) 0:\n x = x - tmp % 10\n tmp = tmp/10\n return x\n\nl = 0\nr = 2000000000000000000\nwhile l < r:\n m = (l + r)/2\n if dif(m) < s:\n l = m + 1\n else: r = m\nd = l\n\nwhile d % 10 > 0: d -= 1\n\nif n < d: print 0\nelse: print n - d + 1\n \n"}, {"source_code": "N,S = map(int,raw_input().split())\nans = 0\nfor i in range(S,min(S+10000,N+1)):\n if i-sum([int(x) for x in str(i)])0:\n\t\tres+=1\n\t\tn//=10\n\treturn res\ndef sod(n):\n\tres=0\n\twhile n>0:\n\t\tres+=n%10\n\t\tn//=10\n\treturn res\ndef maxsod(n):\n\tif (n+1)%10**(nod(n)-1)==0: return 9*(nod(n)-1)+n//10**(nod(n)-1)\n\telse: return 9*(nod(n)-1)+(n-1)//10**(nod(n)-1)\nnum=max(n-s,0)\nfor i in range(s+1,min(s+maxsod(n),n)+1):\n\tif i-sod(i)= s] + [int('1' * 18)])[0] + 1, 0))\n"}, {"source_code": "n, s = map(int, raw_input().split())\nans = 0\nfor i in xrange(300):\n if s + i > n:\n break\n t = s + i - sum(map(int, str(s + i)))\n if t >= s:\n ans += 1\nelse:\n ans += n - s - 299\nprint ans\n"}, {"source_code": "\n\nn, s = map(int, input().split())\n\na, b, c = 0, n + 1, 0\n\nwhile a < b:\n c = (a + b) // 2\n if c - sum([int(x) for x in str(c)]) < s:\n a = c + 1\n else:\n b = c\n\nprint(n - b + 1)\n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndign = map(int, str(n))\n\nl = len(dign)\npw = [1] * l\n\nfor i in xrange(1, l):\n pw[i] = pw[i - 1] * 10\n\ndef cnt(digc, s):\n if s <= 0:\n return pw[digc]\n if s >= pw[digc] - 1:\n return 0\n ret = 0\n for i in xrange(10):\n ret += cnt(digc - 1, s - (pw[digc - 1] - 1) * i)\n return ret\n\nret = 0\nns = s\nfor i in xrange(l):\n for j in xrange(dign[i]):\n ret += cnt(l - i - 1, ns - (pw[l - i - 1] - 1) * j)\n #print('ret', ret)\n ns = ns - dign[i] * (pw[l - i - 1] - 1)\n #print('ns', ns)\n\nif s == 0:\n ret -= 1\n\nif n - sum(dign) >= s:\n ret += 1\n\nprint(ret)\n\n"}, {"source_code": "n,s = map(int,input().split())\nif s > n:\n print('0')\nelse:\n for i in range(s,n+2):\n l = 0\n for j in str(i):\n l += int(j)\n if i - l >= s:\n break\n print(n - i+1)\n"}, {"source_code": "def nine(p) :\n \n s=''\n for i in range(p) :\n s+='9'\n return int(s)\ndef prosh(p) :\n ans=0\n for i in range(1,p+1) :\n ans+=nine(i)*9\n return ans\n \nn,k=map(int,input().split())\nl=[0]*29\nfor i in range(19) :\n \n e=nine(19-i)\n \n l[i]=k//e\n \n k-=l[i]*e\n \n if k==0 :\n \n break\n if i==18 or k%e>prosh(19-i-1) :\n \n l[i]+=1\n break\notv=0\nfor i in range(19) :\n \n otv+=10**(19-i)*l[i]\n\nprint(max(n-otv+1,0))\n \n \n \n \n"}, {"source_code": "def f(x):\n return (x if x < 10 else f(x // 10) + x % 10)\nn, s = map(int, input().split())\nx = s\nwhile x - f(x) < s:\n x += 1\nprint(max(0, n - x + 1))"}, {"source_code": "def nine(p) :\n \n s=''\n for i in range(p) :\n s+='9'\n return int(s)\ndef prosh(p) :\n ans=0\n for i in range(1,p+1) :\n ans+=nine(i)*9\n return ans\n \nn,k=map(int,input().split())\nl=[0]*29\nfor i in range(19) :\n \n e=nine(19-i)\n \n l[i]=k//e\n \n k-=l[i]*e\n \n if k==0 :\n \n break\n if i==18 or k%e>prosh(19-i-1) :\n \n l[i]+=1\n break\notv=0\nfor i in range(19) :\n \n otv+=10**(19-i)*l[i]\n\nprint(max(n-otv+1,0))\n \n \n \n \n"}, {"source_code": "n,s=map(int,raw_input().split())\nl,r=1,n+1\nwhile l= s:\n# \t\tcount += 1\n# \tsumm -= 1\n\t\n\n\n# print(count)\n\n\ndef sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\ndef binsearch(l, r, elem):\n\tn = r\n\tmedium = (l + r ) // 2\n\ts = medium - sum_digits(medium)\n\ts1 = medium-1- sum_digits(medium-1)\n\ts2 = medium+1 - sum_digits(medium+1)\n\t# print(s,s2)\n\twhile not(s2 >= elem and s < elem): #s >= elem and s1 < elem or \n\t\t# print(l,medium,r)\n\t\tif s < elem:\n\t\t\tl = medium\n\t\telif s >= elem:\n\t\t\tr = medium\n\t\tk = medium\n\t\tmedium = (l + r ) // 2\n\t\tif k == medium:\n\t\t\tbreak\n\t\t# print(l,medium,r)\n\t\ts = medium - sum_digits(medium)\n\t\ts2 = medium+1 - sum_digits(medium+1)\n\t\t# print(s,s2) \n\n\ts1 = medium-1 - sum_digits(medium-1)\n\tif s >= elem and s1 < elem:\n\t\treturn medium\n\telif s2 >= elem and s < elem:\n\t\treturn medium + 1\n\telse:\n\t\treturn \tn+1\n\nn, s = map(int, input().split())\n# a = [i for i in range(n+1)]\nif n == s:\n\tprint(0)\nelse:\n\n\ty = binsearch( 0, n, s)\n# print(y)\n\tprint(n - y + 1)\n\n\n\n\n"}, {"source_code": "n, s = map(int, input().split(' '))\n\ndef sumDigit(x):\n\ts = 0\n\twhile x > 0:\n\t\ts += x % 10\n\t\tx //= 10\n\treturn s\n\ndef lowerBound(l, r):\n\twhile l < r:\n\t\tmid = (l + r) >> 1\n\t\tk = mid - sumDigit(mid)\n\t\tif k < s: l = mid+1\n\t\telse: r = mid\n\treturn l\n\nfirst = lowerBound(0, n+1) #Search in a bigger range to detect errors, O(log\u00b2n)\nprint(max(0, n - first + 1))"}, {"source_code": "R = lambda:map(int,raw_input().split())\n\nn,s = R()\n\nl,r = 1,n+1\n\nwhile l= s:\n\tr=mid\n else:\n\tl=mid+1\n\nprint n-l+1\n"}, {"source_code": "import re, sys\nfrom collections import Counter\n\n\ndef calc_diff(val):\n temp, sums = val, 0\n\n while(temp):\n sums += temp%10\n temp /= 10\n\n return val - sums\n\n\ndef main():\n N, S = map(int, raw_input().split())\n Tbeg, Tend = 0, int(1e19) \n \n while(Tbeg < Tend):\n Tmid = (Tbeg + Tend) >> 1\n \n if(calc_diff(Tmid) >= S):\n Tend = Tmid\n else:\n Tbeg = Tmid + 1\n \n print max(0, N - Tend + 1)\n\n############################################################\n############################################################\n############################################################\nif(__name__ == \"__main__\"):\n main()"}, {"source_code": "def really_big(x):\n sum_digit = 0\n digits = x\n while digits > 0:\n sum_digit += digits % 10\n digits = digits // 10\n\n if x - sum_digit >= s:\n return True\n return False\n\ndef solve():\n left = 1\n right = n\n ans = 0\n while left <= right:\n mid = (left + right) // 2\n if really_big(mid): # mid is really big\n right = mid - 1\n ans = n - mid + 1\n else: # mid is not really big\n left = mid + 1\n return ans\n\"\"\"\n25 20\n\"\"\"\n\nn, s = map(int, input().split())\nprint(solve())\n"}, {"source_code": "import re\n\ndef get_index(s):\n\tl = []\n\tfor x in range(0,len(s)): \n\t\tif s[x]=='b':\n\t\t\tl.append(x)\n\treturn l\ndef check(num1,s):\n\tans = sum(map(lambda x:int(x),num1))\n\n\tif(int(num1)-ans)>=s:\n\t\treturn True\n\treturn False\n\ndef gen(frst,last,s):\n\tif last-frst==1:\n\t\treturn last if check(str(last),s) else last+1\n\tif(check(str(frst+int((last-frst)/2)),s)):\n\t\treturn gen(frst,frst+int((last-frst)/2),s)\n\telse:\n\t\treturn gen(frst+int((last-frst)/2),last,s)\n\n\ndef main():\n\tnums = raw_input().split(' ')\n\tnums = map(lambda x:int(x),nums)\n\tmaxi = nums[0]\n\tprint maxi-int(gen(0,nums[0],nums[1]))+1\n\nif __name__ == \"__main__\":\n\t# while True:\n\t# \tmain()\n\tmain()"}, {"source_code": "def sumOfDigits(s):\n\tsum = 0\n\ts = str(s)\n\tfor i in range(len(s)):\n\t\tsum = sum + int(s[i])\n\treturn sum\n\n\ndef binSearch(s, l, u):\n\tif (((l+u)//2) + 1 - sumOfDigits(((l+u)//2)+1)) >= s and (((l+u)//2) - sumOfDigits(((l+u)//2))) < s:\n\t\t#print((l+u)//2)\n\t\treturn (l+u)//2\n\tif (((l+u)//2) - sumOfDigits(((l+u)//2))) < s:\n\t\t#print((l+u)//2)\n\t\treturn binSearch(s, ((l+u)//2)+1, u)\n\tif (((l+u)//2) - sumOfDigits(((l+u)//2))) >= s:\n\t\treturn binSearch(s, l, ((l+u)//2)-1)\n\nn, s = input().strip().split(' ')\ns = int(s)\n# print(sumOfDigits(int(n)))\nif int(n) - sumOfDigits(n)= s:\n\t# \te = str(d)\n\t# \td = d - int(e[len(e)-1]) - 1\n\tprint(int(n) - d)\n"}, {"source_code": "def nine(p) :\n \n s=''\n for i in range(p) :\n s+='9'\n return int(s)\ndef prosh(p) :\n ans=0\n for i in range(1,p+1) :\n ans+=nine(i)*9\n return ans\n \nn,k=map(int,input().split())\nl=[0]*29\nfor i in range(19) :\n \n e=nine(19-i)\n \n l[i]=k//e\n \n k-=l[i]*e\n \n if k==0 :\n \n break\n if i==18 or k%e>prosh(19-i-1) :\n \n l[i]+=1\n break\notv=0\nfor i in range(19) :\n \n otv+=10**(19-i)*l[i]\n\nprint(max(n-otv+1,0))\n \n \n \n \n"}, {"source_code": "stuff = [int(i) for i in raw_input().split()]\n\nn = int(stuff[0])\ns = int(stuff[1])\n\ndef f(x):\n return x - sum(int(i) for i in list(str(x)))\n\nmi = 0\nma = n\nfound = False\n\nwhile ma >= mi and found == False:\n mid = (mi + ma)/2\n test = f(mid)\n if test >= s:\n ma = mid - 1\n elif test < s:\n if f(mid + 1) >= s:\n found = True\n else:\n mi = mid + 1\n\nprint n - mid\n \n \n"}, {"source_code": "def getSum(n):\n ans=0;\n while(n>0):\n ans=ans+n%10;\n n=n//10;\n return ans;\nn,s=(int(x) for x in input().split(\" \"));\nl,h=1,n;\nwhile(l>1);\n sum=(int)(getSum(mid));\n if(mid-sum>=s): h=mid;\n else:l=mid+1;\n\nsum=(int)(getSum(l));\nif(l-sum>=s): print(n-l+1);\nelse: print(0);\n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef cal(x):\n tmp = x\n while x > 0:\n tmp -= x % 10\n x = x / 10\n return tmp\n\nlo = 0\nhi = n\nres = -1\nwhile lo <= hi:\n mid = (lo + hi) / 2\n if cal(mid) >= s:\n res = mid\n hi = mid - 1\n else:\n lo = mid + 1\n\nif res == -1:\n print 0\nelse:\n print n - res + 1\n"}, {"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\ndef su(n):\n s=0\n while n:\n s+=(n%10)\n n//=10 \n return s\n\nmod=1000000007\n\nimport math\n\ndef main():\n \n n,s=mi()\n lo=1 \n hi=2000000000000000000\n while(los:\n hi=mid-1 \n elif a=n:\n\tprint(0)\nelse:\n\tans=0\n\tdef sod(n):\n\t\ts=str(n)\n\t\tret=0\n\t\tfor i in s:\n\t\t\tret+=int(i)\n\t\treturn ret \n\tfor nd in range(s,s+1000):\n\t\tif nd-sod(nd) >=s:\n\t\t\tans+=1\n\t\tif nd==n:\n\t\t\tbreak\n\t\tif nd==(s+369):\n\t\t\tans+=(n-nd)\n\t\t\tbreak \n\tprint(ans)"}, {"source_code": "n,s=map(int,input().split())\nif s>=n:\n print(\"0\")\n exit()\nfor i in range(s,n+2):\n cur=int(0)\n for j in str(i):\n cur+=int(j)\n if i-cur>=s:\n break\nprint(n-i+1)\n"}, {"source_code": "import sys\ndef F(i):\n\treturn (i - sum([int(j) for j in str(i)]))\nn,s=map(int,raw_input().split())\nl=0\nh=n+1\nmid=0\nb=0\nwhile(l= s and F(mid-1) < s):\n\t\t# print n-mid\n\t\t# print mid, mid+1\n\t\t# print F(mid), F(mid+1)\n\t\tb=1\n\t\tbreak\n\telif(F(mid) < s):\n\t\tl=mid+1\n\telse:\n\t\th=mid\nif(b):\n\tprint n-mid+1\nelse:\n\tprint n-mid\n"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n # print (weight,digit)\n mn=n+1\n for i in range(len(digit)-1,-1,-1):\n if s//weight[i]>9:\n break\n if s=s:\n mn=min(mn,10**(i+1))\n continue\n temp=s\n j=i\n ans=0\n while j>=0:\n t=temp//weight[j]\n if t>9:\n temp=0\n ans+=10**(j+2)\n break\n ans+=t*10**(j+1)\n temp=temp-t*weight[j]\n j=j-1\n if ans!=0:\n ans+=math.ceil(temp/9)*10\n mn=min(ans,mn) \n # print (mn)\n if mn>n:\n print (0)\n else: \n print (n-mn+1)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "n,s=input().split()\nl=1\nh=int(n)\nwhile h-l>1:\n\tm=(h+l)//2\n\tif m-sum(map(int,list(str(m))))>=int(s):\n\t\th=m\n\telse:\n\t\tl=m\nif h-sum(map(int,list(str(h))))=s\n\n\nk=input().split()\nn=int(k[0])\ns=int(k[1])\nsum=0\nfor i in range(s, n+1):\n if(sum_of_its_digits(i, s)):\n sum=n-i+1\n break\nprint(sum)\n"}, {"source_code": "R = lambda:map(int,raw_input().split())\n\nn,s = R()\n\nl,r = 1,n+1\n\nwhile l= s:\n\tr=mid\n else:\n\tl=mid+1\n\nprint n-l+1\n"}, {"source_code": "def f(n):\n rtn = n\n while 0 < n:\n rtn -= n % 10\n n //= 10\n return rtn\n\nn, s = map(int, input().split())\nl = 0\nr = 10**18 + 1\ncnt = 0\nwhile 1 < r - l:\n m = (l + r) // 2\n if s <= f(m):\n r = m\n else:\n l = m\n\nprint(max(n - r + 1, 0))\n"}, {"source_code": "def f(x):\n return (x if x < 10 else f(x // 10) + x % 10)\nn, s = map(int, input().split())\nx = s\nwhile x - f(x) < s:\n x += 1\nprint(max(0, n - x + 1))"}, {"source_code": "def legit(mid,s):\n digit = 1\n digitsum = 0\n \n while mid > 0:\n digitsum += (digit - 1) * (mid % 10)\n digit *= 10\n mid /= 10\n\n return digitsum >= s\n\ndef bi(s):\n low = 1\n high = 10**18\n\n while low <= high:\n if low + 1 >= high:\n if legit(low,s):\n return low\n elif legit(high,s):\n return high\n else:\n return 10**19\n\n mid = (low + high) / 2\n\n if legit(mid,s):\n high = mid\n else:\n low = mid + 1\n\n\nn,s = [int(_) for _ in raw_input().split()]\n\nx = bi(s)\n\nprint max(0,n-x+1)\n"}, {"source_code": "n , k = map(int, raw_input().split())\n\ndef sum(k):\n\ts = 0\n\twhile k > 0:\n\t\ts += k%10\n\t\tk /= 10\n\treturn s\n\nt = k\nwhile t <= n:\n\td = t - sum(t)\n\tif d >= k:\n\t\tbreak\n\tt += 1\n\nans = n - t + 1\nif ans < 0:\n ans = 0\nprint ans"}, {"source_code": "def main():\n def sumofdigit(n):\n temp=0\n while(n>0):\n temp+=n%10\n n=n//10\n return temp\n\n def F(x):\n return x-sumofdigit(x)\n\n def findout(s):\n test=s-s%10+10\n while(1):\n if F(test)>=s:\n break\n else:\n test+=10\n return test\n\n n,s=list(map(int,input().strip().split(' ')))\n L=findout(s)\n ans=n-L+1\n if ans<0:\n print(0)\n else:\n print(ans)\nmain() "}, {"source_code": "# def sum_digits(n):\n# s = 0\n# while n:\n# s += n % 10\n# n //= 10\n# return s\n\n\n# n, s = map(int, input().split())\n\n# count = 0\n# summ = sum_digits(n)\n# # k = sum_digits(n - n%10 - 1)\n# # print(k)\n# for num in range(n, 9, -1):\n# \tif num % 10 == 9:\n# \t\tsumm = sum_digits(num)\n# \t# print(num, summ)\n# \tif num - summ >= s:\n# \t\tcount += 1\n# \tsumm -= 1\n\t\n\n\n# print(count)\n\n\ndef sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\ndef binsearch(l, r, elem):\n\tn = r\n\tmedium = (l + r ) // 2\n\ts = medium - sum_digits(medium)\n\ts1 = medium-1- sum_digits(medium-1)\n\ts2 = medium+1 - sum_digits(medium+1)\n\t# print(s,s2)\n\twhile not(s2 >= elem and s < elem): #s >= elem and s1 < elem or \n\t\t# print(l,medium,r)\n\t\tif s < elem:\n\t\t\tl = medium\n\t\telif s >= elem:\n\t\t\tr = medium\n\t\tk = medium\n\t\tmedium = (l + r ) // 2\n\t\tif k == medium:\n\t\t\tbreak\n\t\t# print(l,medium,r)\n\t\ts = medium - sum_digits(medium)\n\t\ts2 = medium+1 - sum_digits(medium+1)\n\t\t# print(s,s2)\n\n\ts1 = medium-1 - sum_digits(medium-1)\n\tif s >= elem and s1 < elem:\n\t\treturn medium\n\telif s2 >= elem and s < elem:\n\t\treturn medium + 1\n\telse:\n\t\treturn \tn+1\n\nn, s = map(int, input().split())\n# a = [i for i in range(n+1)]\nif n == s:\n\tprint(0)\nelse:\n\n\ty = binsearch( 0, n, s)\n# print(y)\n\tprint(n - y + 1)\n\n\n\n\n"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n # print (weight,digit)\n mn=n+1\n for i in range(len(digit)-1,-1,-1):\n if s//weight[i]>9:\n break\n if s=s:\n mn=min(mn,10**(i+1))\n continue\n temp=s\n j=i\n ans=0\n while j>=0:\n t=temp//weight[j]\n if t>9:\n temp=0\n ans+=10**(j+2)\n break\n ans+=t*10**(j+1)\n temp=temp-t*weight[j]\n j=j-1\n if ans!=0:\n ans+=math.ceil(temp/9)*10\n mn=min(ans,mn) \n # print (mn)\n if mn>n:\n print (0)\n else: \n print (n-mn+1)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "n,s = map(int,input().split())\n\ndef diff(m):\n return m - sum([int(k) for k in list(str(m))])\n \ndef digit_safe(k):\n r = len(list(str(k)))\n return toint([\"1\"]+[\"0\"]*(r-1))\na = list(str(n))\nb = list(str(s))\nd = int(a[0])\n\ndef toint(l):\n return int(\"\".join(l))\nres = 0\nfor i in range(d):\n z = toint([str(i)] + [\"0\" for _ in range(len(a)-1)])\n z1 = toint([str(i+1)] + [\"0\" for _ in range(len(a)-1)])\n count = diff(z)\n while z < z1 and count < s:\n z += digit_safe(s-count)\n count = diff(z)\n if z <= z1:\n res += (z1-z)\nz = toint([str(d)] + [\"0\" for _ in range(len(a)-1)])\nz1 = n+1\ncount = diff(z)\nwhile z < z1 and count < s:\n z += digit_safe(s-count)\n count = diff(z)\nif z <= z1:\n res += (z1-z)\nprint(res)"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n # print (weight,digit)\n mn=n+1\n for i in range(len(digit)-1,-1,-1):\n if s//weight[i]>9:\n break\n if s=s:\n mn=min(mn,10**(i+1))\n continue\n temp=s\n j=i\n ans=0\n while j>=0:\n t=temp//weight[j]\n if t>9:\n temp=0\n ans+=10**(j+2)\n break\n ans+=t*10**(j+1)\n temp=temp-t*weight[j]\n j=j-1\n if ans!=0:\n ans+=math.ceil(temp/9)*10\n mn=min(ans,mn) \n # print (mn)\n if mn>n:\n print (0)\n else: \n print (n-mn+1)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "def legit(mid,s):\n digit = 1\n digitsum = 0\n \n while mid > 0:\n digitsum += (digit - 1) * (mid % 10)\n digit *= 10\n mid /= 10\n\n return digitsum >= s\n\ndef bi(s):\n low = 1\n high = 10**18\n\n while low <= high:\n if low + 1 >= high:\n if legit(low,s):\n return low\n elif legit(high,s):\n return high\n else:\n return 10**19\n\n mid = (low + high) / 2\n\n if legit(mid,s):\n high = mid\n else:\n low = mid + 1\n\n\nn,s = [int(_) for _ in raw_input().split()]\n\nx = bi(s)\n\nprint max(0,n-x+1)\n"}, {"source_code": "def sd(n):\n acc = 0\n while n:\n acc += n % 10\n n //= 10\n return acc\n\ndef rb(n, s):\n return n - sd(n) >= s\n\nn, s = map(int, input().split(' '))\n\nleft = 1\nright = n+1\n\nwhile left != right:\n mid = (left + right) // 2\n if rb(mid, s):\n right = mid\n else:\n left = mid + 1\n\nprint(n - left + 1)\n"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n mn=n+1\n for i in range(len(digit)-1,-1,-1):\n if s//weight[i]>9:\n break\n if s=s:\n mn=min(mn,10**(i+1))\n continue\n temp=s\n j=i\n ans=0\n while j>=0:\n t=temp//weight[j]\n if t>9:\n temp=0\n ans+=10**(j+2)\n break\n ans+=t*10**(j+1)\n temp=temp-t*weight[j]\n j=j-1\n ans+=math.ceil(temp/9)*10\n mn=min(ans,mn) \n if mn>n:\n print (0)\n else: \n print (n-mn+1)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "(n, s) = [int(x) for x in input().split()]\n\ndef is_really_big(n):\n digit_sum = sum([int(x) for x in str(n)])\n return n - digit_sum >= s\n\nimport sys\n\nif is_really_big(n) == False:\n print(0)\n sys.exit()\n\nlower_bound = 1\nupper_bound = n\na = 0\n\nimport pdb\n\nwhile(upper_bound - lower_bound > 1):\n a = (lower_bound + upper_bound) // 2\n if is_really_big(a):\n upper_bound = a\n else:\n lower_bound = a\n\nprint(n - lower_bound)\n"}, {"source_code": "n, s = [int(i) for i in input().split()]\n\nprint(max(n - [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s][0] + 1, 0))\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def R() : return map(int,raw_input().strip().split())\ndef Rf() : return map(float,raw_input().strip().split())\ndef Sl() : return raw_input().strip().split()\n\n[n,s] = R()\nlo, hi = 1,n+1\n\n\nwhile lo < hi:\n\tsm = 0\n\tmid = lo + (hi-lo)/2 \n\tp = mid\n\twhile p != 0:\n\t\tsm += p%10\n\t\tp /= 10\n\tif(mid - sm >= s):\n\t\thi = mid\n\telse:\n\t\tlo = mid+1\n\nprint (n-lo+1)\t"}, {"source_code": "I = lambda : map(int, input().split())\nn, s = I()\ncnt = n-min(200+s, n+1)+1\nfor i in range(s, min(200 + s, n+1)):\n if i - sum(map(int, str(i))) >= s:\n cnt += 1\nprint(cnt)\n"}, {"source_code": "(n,s)=map(int,input().split())\ndef comp(p):\n a=p\n sum=0\n while(a!=0):\n sum+=a%10\n a//=10\n return p-sum>=s\nl=0\nr=n\nwhile (r - l > 1):\n\tp = (l + r) // 2;\n\tif (comp(p)):\n\t r = p\n\telse:\n\t l = p\nif(comp(n)):\n print(n-l)\nelse:\n print(0)\n\t"}, {"source_code": "n, s = map(int, input().split())\n\nans = 0\np = s\nfor i in range(163):\n\tp = s + i\n\tif p > n:\n\t\tbreak\n\tif p >= s + sum(map(int, str(p))):\n\t\tans += 1\n\nif p <= n:\n\tans += n - p\n\nprint(ans)"}, {"source_code": "n,s = map(int,input().split())\n\nc=0\nfor i in range(s,n+1):\n x = i - sum(int(t) for t in str(i))\n if x>=s:\n c = n-i+1\n break\nprint(c)"}, {"source_code": "def readints():\n return [int(item) for item in input().strip().split()]\n\n\ndef f(n):\n return n - sum(map(int, str(n)))\n\n\nclass Solver:\n def main(self):\n n, s = readints()\n if f(n) < s:\n print('0')\n return\n\n l, r = 1, n\n while l <= r:\n mid = (l + r) // 2\n\n if f(mid) < s:\n l = mid + 1\n\n if f(mid) >= s:\n r = mid - 1\n\n print(n - r)\n\n\nSolver().main()\n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef cal(x):\n tmp = x\n while x > 0:\n tmp -= x % 10\n x = x / 10\n return tmp\n\nlo = 0\nhi = n\nres = -1\nwhile lo <= hi:\n mid = (lo + hi) / 2\n if cal(mid) >= s:\n res = mid\n hi = mid - 1\n else:\n lo = mid + 1\n\nif res == -1:\n print 0\nelse:\n print n - res + 1\n"}, {"source_code": "def f(x):\n return (x if x < 10 else f(x // 10) + x % 10)\nn, s = map(int, input().split())\nx = s\nwhile x - f(x) < s:\n x += 1\nprint(max(0, n - x + 1))"}, {"source_code": "n, s = [int(i) for i in input().split()]\nprint(max(n - [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s][0] + 1, 0))\n"}, {"source_code": "from math import ceil\nn, s = [int(i) for i in input().split()]\n\nl = 0\nr = 10000000000000000000\n\nwhile l < r:\n cur = (l + r) // 2\n sm = sum([int(i) for i in str(cur)])\n if cur - sm >= s:\n r = cur\n else:\n l = cur + 1\n\nprint(max(0, n - l + 1))\n"}, {"source_code": "def main():\n n, s = map(int,input().split())\n a = [i for i in range(s, s+180) if i - sum([int(j) for j in str(i)]) >= s][0]\n print(max(n-a+1,0))\n# print(max(n - [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s][0] + 1, 0))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n , k = map(int, raw_input().split())\n\ndef sum(k):\n\ts = 0\n\twhile k > 0:\n\t\ts += k%10\n\t\tk /= 10\n\treturn s\n\nt = k\nwhile t <= n:\n\td = t - sum(t)\n\tif d >= k:\n\t\tbreak\n\tt += 1\n\nans = n - t + 1\nif ans < 0:\n ans = 0\nprint ans"}, {"source_code": "n,s = raw_input().split()\ndef msmdez(x,y):\n\tx,y = int(x),int(y)\n\tx1,y1 = str(x),str(y)\n\tif len(x1) == len(y1) != 1:\n\t\tif abs(x-y) < 10:\n\t\t\treturn x1[-2] == y1[-2]\n\treturn False\nmd = msmdez(n,s)\nif int(n) <= int(s):\n\tprint 0\n\texit()\nif int(n) < int(s) + sum(map(int,list(n))) and not md:\n\tprint 0\n\texit()\nn,s = int(n),int(s)\nif s < 10 :\n\tprint n - 10 + 1\n\texit()\nif md:\n\tprint 0\n\texit()\nS = s\nwhile S <= n and not msmdez(S,n):\n\tk = S - sum(map(int,list(str(S))))\n\tif k >= s: break\n\tS+=10 \nif S - sum(map(int,list(str(S)))) < s:\n\tprint int(str(n)[-1]) + 1\n\texit()\nprint n - (S - int(str(S)[-1])) + 1\n"}, {"source_code": "n,s=map(int,raw_input().split())\nl,r=1,n+1\nwhile l= s\n\n\nresult = len([x for x in range(s, min(n, s + 180) + 1) if judge(x)]) + max(0, n - s - 180)\n\nprint(result)\n"}, {"source_code": "n,s=map(int,raw_input().split())\nx=s/9\nif s%9>0:\n x+=1\nz=0\nl=len(str(s))\nd='1'*l\nd=int(d)\nwhile d!=0:\n m=x//d\n z=z*10+m\n x-=m*d\n d=d//10\nz*=10\nif z<=n:\n print n-z+1\nelse:\n print 0"}, {"source_code": "def mus(x):\n c = 0\n while(x>0):\n c += x%10\n x = x//10\n return c\nn,s=map(int,input().split())\nans = s + 10 - s%10\nwhile(ans - mus(ans) < s):\n ans += 10\nif ans > n:\n print(0)\nelse:\n print(n-ans+1)\n"}, {"source_code": "n, s = [int(i) for i in input().split()]\nprint(max(n - ([i for i in range(s, s + 9 * 18 + 1) if i - sum([int(j) for j in str(i)]) >= s] + [int('1' * 18)])[0] + 1, 0))\n"}, {"source_code": "def cal(a):\n x=0\n while(a>0):\n x+=a%10\n a=a//10\n return x\nn,s=input().split()\nn=int(n)\ns=int(s)\nif((n-cal(n))=s):\n if((mid-1-cal(mid-1))=s):\n mid+=1\n break\n else:\n u=mid+1\n print(n-mid+1)\n \n "}, {"source_code": "n,s=map(int,raw_input().split())\nl,r=1,n+1\nwhile l=s\n\n\nk=input().split()\nn=int(k[0])\ns=int(k[1])\nsum=0\nfor i in range(s, n+1):\n if(sum_of_its_digits(i, s)):\n sum=n-i+1\n break\nprint(sum)\n"}, {"source_code": "n, s = map(int, input().split())\n \na, b, c = 0, n + 1, 0\n \nwhile a < b:\n c = (a + b) // 2\n if c - sum([int(x) for x in str(c)]) < s:\n a = c + 1\n else:\n b = c\n \nprint(n - b + 1)"}, {"source_code": "n,s = raw_input().split()\ndef msmdez(x,y):\n\tx,y = int(x),int(y)\n\tx1,y1 = str(x),str(y)\n\tif len(x1) == len(y1) != 1:\n\t\tif abs(x-y) < 10:\n\t\t\treturn x1[-2] == y1[-2]\n\treturn False\nmd = msmdez(n,s)\nif int(n) <= int(s):\n\tprint 0\n\texit()\nif int(n) < int(s) + sum(map(int,list(n))) and not md:\n\tprint 0\n\texit()\nn,s = int(n),int(s)\nif s < 10 :\n\tprint n - 10 + 1\n\texit()\nif md:\n\tprint 0\n\texit()\nS = s\nwhile S <= n and not msmdez(S,n):\n\tk = S - sum(map(int,list(str(S))))\n\tif k >= s: break\n\tS+=10 \nif S - sum(map(int,list(str(S)))) < s and S+10 > n:\n\tprint int(str(n)[-1]) + 1\n\texit()\nprint n - (S - int(str(S)[-1])) + 1"}, {"source_code": "class ReallyBigNumbers:\n\n\tdef __init__(self, n, s):\n\t\tself.n = n\n\t\tself.s = s\n\t\tself.binarySearch()\n\n\tdef binarySearch(self):\n\t\tl = self.s\n\t\th = 10000000000000000000\n\t\twhile(l < h):\n\t\t\tmid = (h + l) // 2\n\t\t\t#print(mid, self.isReallyBig(mid))\n\t\t\tif self.isReallyBig(mid):\n\t\t\t\th = mid\n\t\t\telse:\n\t\t\t\tl = mid + 1\n\t\tself.x = int(l)\n\n\tdef isReallyBig(self, v):\n\t\tcp = v\n\t\tadd = 0\n\t\twhile v > 0:\n\t\t\tadd += v % 10\n\t\t\tv //= 10\n\t\t#print('resta', cp-add, cp, add)\n\t\treturn (cp - add) >= self.s\n\n\tdef show(self):\n\t\tif self.x <= self.n:\n\t\t\tprint(str(self.n - self.x + 1))\n\t\telse:\n\t\t\tprint(0)\n\n\nn, s = map(int, input().split())\nrbg = ReallyBigNumbers(n, s)\n#print(rbg.x)\nrbg.show()\n\n"}, {"source_code": "def sum_of_its_digits(Num, s):\n S=str(Num)\n sum=0\n for i in S:\n sum+=int(i)\n return (Num-sum)>=s\n\n\nk=input().split()\nn=int(k[0])\ns=int(k[1])\nsum=0\nfor i in range(s, n+1):\n if(sum_of_its_digits(i, s)):\n sum=n-i+1\n break\nprint(sum)\n"}, {"source_code": "# -*- coding: utf-8 -*-\nn, s = map(int, input().split(' '))\ndef sumd(d):\n sd = 0\n while d!=0:\n sd += d%10\n d//=10\n return sd\nst, ed = 1, n\nr = 0\nwhile True:\n if st==ed:\n r = st\n break\n x = (st+ed)//2\n if x-sumd(x)=s:\n print(n-r+1)\nelse:\n print(0)\n"}, {"source_code": "R = lambda:map(int,raw_input().split())\n\nn,s = R()\n\nl,r = 1,n+1\n\nwhile l= s:\n\tr=mid\n else:\n\tl=mid+1\n\nprint n-l+1\n"}, {"source_code": "a = input()\na = a.split(' ')\na = list(map(int,a))\ndef really_big(n,s):\n if s >= n:\n return 0\n i = s + 1\n while i <= n:\n t,b = i,0\n while t > 0:\n b = b + (t % 10)\n t = t // 10\n if i - b >= s:\n return n - i + 1\n break\n else:\n i += 1\n return 0\nprint(really_big(a[0],a[1]))"}, {"source_code": "def check(n,p):\n k=str(n)\n k=k[::-1]\n s=0\n for j in range(len(k)):\n s+=(int(k[j])*(10**j-1))\n if s>=p:\n return 1\n else:\n return 0\n\nn,s=map(int,input().split())\nl=1\nh=n\nk=0\nwhile(l<=h):\n m=(l+h)//2\n if check(m,s)==0:\n l=m+1\n else:\n h=m-1\n k+=1\nprint(n-l+1)\n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef cal(x):\n tmp = x\n while x > 0:\n tmp -= x % 10\n x = x / 10\n return tmp\n\nlo = 0\nhi = n\nres = -1\nwhile lo <= hi:\n mid = (lo + hi) / 2\n if cal(mid) >= s:\n res = mid\n hi = mid - 1\n else:\n lo = mid + 1\n\nif res == -1:\n print 0\nelse:\n print n - res + 1\n"}, {"source_code": "def mus(x):\n c = 0\n while(x>0):\n c += x%10\n x = x//10\n return c\nn,s=map(int,input().split())\nans = s + 10 - s%10\nwhile(ans - mus(ans) < s):\n ans += 10\nif ans > n:\n print(0)\nelse:\n print(n-ans+1)\n"}, {"source_code": "n, s = map(int, raw_input().split())\nans = 0\nfor i in xrange(300):\n if s + i > n:\n break\n t = s + i - sum(map(int, str(s + i)))\n if t >= s:\n ans += 1\nelse:\n ans += n - s - 299\nprint ans\n"}, {"source_code": "def sum_of_its_digits(Num, s):\n S=str(Num)\n sum=0\n for i in S:\n sum+=int(i)\n return (Num-sum)>=s\n\n\nk=input().split()\nn=int(k[0])\ns=int(k[1])\nsum=0\nfor i in range(s, n+1):\n if(sum_of_its_digits(i, s)):\n sum=n-i+1\n break\nprint(sum)\n"}, {"source_code": "def add(n):\n\tres=0\n\twhile n!=0:\n\t\tres+=n%10\n\t\tn/=10\n\treturn res\nn,s=map(int,raw_input().split())\nl=1\nr=n+1\nwhile l lo + 1:\n mid = (lo + hi)/2\n if mid - d(mid) >=s:\n hi = mid\n else:\n lo = mid\nwhile lo <=hi:\n if lo - d(lo)>=s:\n break\n lo += 1\nprint max(n-lo+1,0)"}, {"source_code": "def case(mid):\n res=0\n for k,x in enumerate(str(mid)):\n res+=int(x)\n return res\nn,s=map(int,input().split())\ni,j=0,n\nwhile i+1=s:print(n-i+1)\nelse:\n if j==n:\n if j-case(j)>=s:print(1)\n else:print(0)\n else:print(n-j+1)"}, {"source_code": "def mus(x):\n c = 0\n while(x>0):\n c += x%10\n x = x//10\n return c\nn,s=map(int,input().split())\nans = s + 10 - s%10\nwhile(ans - mus(ans) < s):\n ans += 10\nif ans > n:\n print(0)\nelse:\n print(n-ans+1)\n"}, {"source_code": "def solve(n, s):\n cur = -1\n i = s\n while i <= n:\n ds = sum(map(int, str(i)))\n if i - ds >= s:\n cur = i\n break\n i += 1\n if cur == -1:\n return 0\n return n - cur + 1\n \nassert solve(12, 1) == 3\nassert solve(25, 20) == 0\nassert solve(10, 9) == 1\nassert solve(1000000000000000000, 1000000000000000000) == 0\n\n(n, s) = map(int, raw_input().split())\nprint solve(n, s)\n"}, {"source_code": "def add(n):\n\tres=0\n\twhile n!=0:\n\t\tres+=n%10\n\t\tn/=10\n\treturn res\nn,s=map(int,raw_input().split())\nl=1\nr=n+1\nwhile l 0:\n digitsum += (digit - 1) * (mid % 10)\n digit *= 10\n mid /= 10\n\n return digitsum >= s\n\ndef bi(s):\n low = 1\n high = 10**18\n\n while low <= high:\n if low + 1 >= high:\n if legit(low,s):\n return low\n elif legit(high,s):\n return high\n else:\n return 10**19\n\n mid = (low + high) / 2\n\n if legit(mid,s):\n high = mid\n else:\n low = mid + 1\n\n\nn,s = [int(_) for _ in raw_input().split()]\n\nx = bi(s)\n\nprint max(0,n-x+1)\n"}, {"source_code": "n,s=map(int,raw_input().split())\nl=0\nu=10**22\ndef sod(n):\n st=str(n)\n v=0\n for i in st:\n v=v+int(i) \n return v \n\nfor i in range(1,200):\n m=(l+u)/2\n if m>=sod(m)+s:\n u=m \n else:\n l=m \n #print l,u,m\n#print l,u\nif sod(l)>=sod(l)+s:\n print max(n-l+1,0) \nelse:\n print max(n-u+1,0)\n"}, {"source_code": "raw=input().split()\nn=int(raw[0])\ns=int(raw[1])\n\ndef sum_digits(x):\n z=0\n while x:\n z+=x%10\n x//=10\n return z\n\ni=s\ncount=0\nwhile i<=n:\n q=i-sum_digits(i)\n if q>=s:\n count=n-i+1\n break\n else:\n i+=1\nprint(count)\n\n#print(sum_digits(1))\n \n \n"}, {"source_code": "n,s = map(int,input().split())\nif s > n:\n print('0')\nelse:\n for i in range(s,n+2):\n l = 0\n for j in str(i):\n l += int(j)\n if i - l >= s:\n break\n print(n - i+1)\n"}, {"source_code": "n, s = [int(i) for i in input().split()]\nprint(max(n - ([i for i in range(s, s + 9 * 18 + 1) if i - sum([int(j) for j in str(i)]) >= s] + [int('1' * 18)])[0] + 1, 0))\n"}, {"source_code": "def really_big(x):\n sum_digit = 0\n digits = x\n while digits > 0:\n sum_digit += digits % 10\n digits = digits // 10\n\n if x - sum_digit >= s:\n return True\n return False\n\ndef solve():\n left = 1\n right = n\n ans = 0\n while left <= right:\n mid = (left + right) // 2\n if really_big(mid): # mid is really big\n right = mid - 1\n ans = n - mid + 1\n else: # mid is not really big\n left = mid + 1\n return ans\n\"\"\"\n25 20\n\"\"\"\n\nn, s = map(int, input().split())\nprint(solve())\n"}, {"source_code": "class ReallyBigNumbers:\n\n\tdef __init__(self, n, s):\n\t\tself.n = n\n\t\tself.s = s\n\t\tself.binarySearch()\n\n\tdef binarySearch(self):\n\t\tl = self.s\n\t\th = 10000000000000000000\n\t\twhile(l < h):\n\t\t\tmid = (h + l) // 2\n\t\t\t#print(mid, self.isReallyBig(mid))\n\t\t\tif self.isReallyBig(mid):\n\t\t\t\th = mid\n\t\t\telse:\n\t\t\t\tl = mid + 1\n\t\tself.x = int(l)\n\n\tdef isReallyBig(self, v):\n\t\tcp = v\n\t\tadd = 0\n\t\twhile v > 0:\n\t\t\tadd += v % 10\n\t\t\tv //= 10\n\t\t#print('resta', cp-add, cp, add)\n\t\treturn (cp - add) >= self.s\n\n\tdef show(self):\n\t\tif self.x <= self.n:\n\t\t\tprint(str(self.n - self.x + 1))\n\t\telse:\n\t\t\tprint(0)\n\n\nn, s = map(int, input().split())\nrbg = ReallyBigNumbers(n, s)\n#print(rbg.x)\nrbg.show()\n\n"}, {"source_code": "from sys import stdin\nn,s = map(int,stdin.readline().split())\ndef d(m):\n cur = 0\n while m:\n cur += m%10\n m/=10\n return cur\nlo = 1\nhi = n\nwhile hi > lo + 1:\n mid = (lo + hi)/2\n if mid - d(mid) >=s:\n hi = mid\n else:\n lo = mid\nwhile lo <=hi:\n if lo - d(lo)>=s:\n break\n lo += 1\nprint max(n-lo+1,0)"}, {"source_code": "n, s = map(int, input().split())\n\nans = 0\np = s\nfor i in range(163):\n\tp = s + i\n\tif p > n:\n\t\tbreak\n\tif p >= s + sum(map(int, str(p))):\n\t\tans += 1\n\nif p <= n:\n\tans += n - p\n\nprint(ans)"}, {"source_code": "n, s = map(int, input().rstrip().split())\nif n <= s:\n print(0)\n exit()\nfor i in range(s, n + 2):\n l = 0\n for j in str(i):\n l += int(j)\n if i - l >= s:\n break\nprint(max(n - i + 1, 0))"}, {"source_code": "import sys\ndef F(i):\n\treturn (i - sum([int(j) for j in str(i)]))\nn,s=map(int,raw_input().split())\nl=0\nh=n+1\nmid=0\nb=0\nwhile(l= s and F(mid-1) < s):\n\t\t# print n-mid\n\t\t# print mid, mid+1\n\t\t# print F(mid), F(mid+1)\n\t\tb=1\n\t\tbreak\n\telif(F(mid) < s):\n\t\tl=mid+1\n\telse:\n\t\th=mid\nif(b):\n\tprint n-mid+1\nelse:\n\tprint n-mid\n"}], "negative_code": [{"source_code": "n,s = map(int,input().split())\ncur = n - n%9\nif(cur>=s):\n print(n%10+1)\nelse:\n print(0)"}, {"source_code": "n,s=map(int,input().split())\ndef nod(n):\n\tres=0\n\twhile n>0:\n\t\tres+=1\n\t\tn//=10\n\treturn res\ndef sod(n):\n\tres=0\n\twhile n>0:\n\t\tres+=n%10\n\t\tn//=10\n\treturn res\ndef maxsod(n):\n\tif n+1==10**nod(n): return sod(n)\n\telse: return 9*(nod(n)-1)\nnum=n-s\nfor i in range(s+1,min(s+maxsod(n),n)+1):\n\tif i-sod(i)0:\n\t\tres+=1\n\t\tn//=10\n\treturn res\ndef sod(n):\n\tres=0\n\twhile n>0:\n\t\tres+=n%10\n\t\tn//=10\n\treturn res\ndef maxsod(n):\n\tif n+1==10**nod(n): return sod(n)\n\telse: return 9*(nod(n)-1)\nnum=max(n-s,0)\nfor i in range(s+1,min(s+maxsod(n),n)+1):\n\tif i-sod(i)0:\n\t\tres+=1\n\t\tn//=10\n\treturn res\ndef sod(n):\n\tres=0\n\twhile n>0:\n\t\tres+=n%10\n\t\tn//=10\n\treturn res\ndef maxsod(n):\n\tif (n+1)%10**(nod(n)-1): return 9*(nod(n)-1)+n//10**(nod(n)-1)\n\telse: 9*(nod(n)-1)+(n-1)//10**(nod(n)-1)\nnum=max(n-s,0)\nfor i in range(s+1,min(s+maxsod(n),n)+1):\n\tif i-sod(i)= s:\n ans += 1 \n \n mdist -= 1 \n c += 1 \nprint(ans + n - c + 1)"}, {"source_code": "def main():\n n, s = map(int,input().split())\n y = [i for i in range(s, s+180) if i - sum([int(j) for j in str(i)]) >= s]\n a = y[0]\n print(y)\n print(max(n-a+1,0))\n# print(max(n - [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s][0] + 1, 0))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def main():\n n, s = map(int,input().split())\n y = [i for i in range(s, s+180) if i - sum([int(j) for j in str(i)])]\n a = y[0]\n print(max(n-a+1,0))\n# print(max(n - [i for i in range(s, s + 180) if i - sum([int(j) for j in str(i)]) >= s][0] + 1, 0))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def nine(p) :\n \n s=''\n for i in range(p) :\n s+='9'\n return int(s)\ndef prosh(p) :\n ans=0\n for i in range(1,p+1) :\n ans+=nine(i)*9\n return ans\n \nn,k=map(int,input().split())\nl=[0]*19\nfor i in range(18) :\n e=nine(18-i)\n l[i]=int(k/e)\n \n k-=l[i]*e\n if k==0 :\n break\n if i==17 or k%e>prosh(18-i-1) :\n \n l[i]+=1\n break\notv=0\nfor i in range(18) :\n \n otv+=10**(18-i)*l[i]\n\nprint(max(n-otv+1,0))\n \n \n \n \n"}, {"source_code": "def nine(p) :\n \n s=''\n for i in range(p) :\n s+='9'\n return int(s)\nn,k=map(int,input().split())\nl=[0]*19\nfor i in range(18) :\n e=nine(18-i)\n l[i]=int(k/e)\n \n k-=l[i]*e\n if k==0 :\n break\n if i==17 or k%e>nine(18-i-1)*9 :\n \n l[i]+=1\n break\notv=0\nfor i in range(18) :\n \n otv+=10**(18-i)*l[i]\nprint(max(n-otv+1,0))\n \n \n \n \n"}, {"source_code": "def nine(p) :\n \n s=''\n for i in range(p) :\n s+='9'\n return int(s)\ndef prosh(p) :\n ans=0\n for i in range(1,p+1) :\n ans+=nine(i)*9\n return ans\n \nn,k=map(int,input().split())\nl=[0]*29\nfor i in range(19) :\n \n e=nine(19-i)\n \n l[i]=int(k/e)\n \n k-=l[i]*e\n \n if k<=0 :\n \n break\n if i==17 or k%e>prosh(19-i-1) :\n \n l[i]+=1\n break\notv=0\nfor i in range(19) :\n \n otv+=10**(19-i)*l[i]\n\nprint(max(n-otv+1,0))\n \n \n \n \n"}, {"source_code": "a = input()\na = a.split(' ')\na = list(map(int,a))\ndef really_big(n,s):\n if s >= n:\n return 0\n i = s + 1\n while True:\n t,b = i,0\n while t > 0:\n b = b + (t % 10)\n t = t // 10\n if i - b >= s:\n return n - i + 1\n break\n else:\n i += 1\nprint(really_big(a[0],a[1]))"}, {"source_code": "def cal(a):\n x=0\n while(a>0):\n x+=a%10\n a=a//10\n return x\nn,s=input().split()\nn=int(n)\ns=int(s)\nif((n-cal(n))=s):\n if((mid-1-cal(mid-1))=s):\n mid+=1\n break\n else:\n u=mid+1\n print(n-mid+1)\n \n "}, {"source_code": "def cmp(x1 = [],x2 = []):\n len1 = len(x1)\n len2 = len(x2)\n if len1 == len2:\n for i in range(len1):\n n1 = x1[len1 - 1 - i]\n n2 = x2[len1 - 1 - i]\n if n1 != n2:\n return n1 > n2\n else:\n return len1 > len2\n return True\n\ndef add(x1 = [],x2 = []):\n if not cmp(x1,x2):\n x1,x2 = x2,x1\n len1 = len(x1)\n len2 = len(x2)\n for i in range(len1 - len2):\n x2.append(0)\n res = []\n flag = 0\n for n1,n2 in zip(x1,x2):\n m = n1 + n2 + flag\n flag = m // 10\n res.append(m % 10)\n if flag:\n res.append(flag)\n return res\n \ndef minus(x1 = [],x2 = []):\n if not cmp(x1,x2):\n x1,x2 = x2,x1\n len1 = len(x1)\n len2 = len(x2)\n for i in range(len1 - len2):\n x2.append(0)\n res = []\n flag = 0\n for n1,n2 in zip(x1,x2):\n m = n1 - n2 + flag\n flag = 0 if m >= 0 else -1\n res.append((m + 10) % 10)\n \n while res and not res[-1]:\n res.pop()\n return res\n \ndef div(x1 = [], x2 = 9):\n if x2 == 10:\n return x1[1:]\n else:\n x1.reverse()\n res = []\n mod = 0\n for n in x1:\n res.append((n + mod * 10)// 9)\n mod = (n + mod * 10) % 9\n res.reverse()\n while res and not res[-1]:\n res.pop()\n return res \n\ndef multi(x1 = [],x2 = 9):\n x1_copy = x1.copy()\n x1.insert(0,0)\n if x2 == 10:\n return x1\n else:\n return minus(x1,x1_copy)\n\nif __name__ == \"__main__\":\n input_str = input()\n n,s = [a for a in input_str.split()]\n nl = list([int(a) for a in list(n)])\n sl = list([int(a) for a in list(s)])\n nl.reverse()\n sl.reverse()\n \n# x = (sl + 8) // 9 * 9\n x = multi(div(add(sl.copy(),[8]),9),9)\n# y = (x + 9) // 10 * 10\n y = multi(div(add(x.copy(),[9]),10),10)\n# z = y + (x - y + sum(y)) * 10 // 9\n sumy = list([int(a) for a in list(str(sum(y)))])\n sumy.reverse()\n while not cmp(minus(y,sumy),sl):\n y = add(y,[0,1])\n\n if cmp(nl,y):\n ans = add(minus(nl,y),[1])\n else:\n ans = [0]\n ans.reverse()\n ansstr = [str(a) for a in ans]\n print(\"\".join(ansstr))\n\n\n "}, {"source_code": "if __name__ == \"__main__\":\n input_str = input()\n n,s = [int(a) for a in input_str.split()]\n mod_res = s % 9\n div_res = s // 9\n x = (div_res + 1 if mod_res else div_res) * 9\n ans = n - x if n -x > 0 else 0\n print(ans)"}, {"source_code": "if __name__ == \"__main__\":\n input_str = input()\n n,s = [int(a) for a in input_str.split()]\n mod_res = s % 9\n div_res = s // 9\n x = (div_res + 1 if mod_res else div_res) * 9\n y = (x + 9) // 10 * 10\n ans = n - y + 1 if n - y + 1 > 0 else 0\n print(ans)"}, {"source_code": "def cmp(x1 = [],x2 = []):\n len1 = len(x1)\n len2 = len(x2)\n if len1 == len2:\n for i in range(len1):\n n1 = x1[len1 - 1 - i]\n n2 = x2[len1 - 1 - i]\n if n1 != n2:\n return n1 > n2\n else:\n return len1 > len2\n return True\n\ndef add(x1 = [],x2 = []):\n if not cmp(x1,x2):\n x1,x2 = x2,x1\n len1 = len(x1)\n len2 = len(x2)\n for i in range(len1 - len2):\n x2.append(0)\n res = []\n flag = 0\n for n1,n2 in zip(x1,x2):\n m = n1 + n2 + flag\n flag = m // 10\n res.append(m % 10)\n if flag:\n res.append(flag)\n return res\n \ndef minus(x1 = [],x2 = []):\n if not cmp(x1,x2):\n x1,x2 = x2,x1\n len1 = len(x1)\n len2 = len(x2)\n for i in range(len1 - len2):\n x2.append(0)\n res = []\n flag = 0\n for n1,n2 in zip(x1,x2):\n m = n1 - n2 + flag\n flag = 0 if m >= 0 else -1\n res.append((m + 10) % 10)\n \n while res and not res[-1]:\n res.pop()\n return res\n \ndef div(x1 = [], x2 = 9):\n if x2 == 10:\n return x1[1:]\n else:\n x1.reverse()\n res = []\n mod = 0\n for n in x1:\n res.append((n + mod * 10)// 9)\n mod = (n + mod * 10) % 9\n res.reverse()\n while res and not res[-1]:\n res.pop()\n return res \n\ndef multi(x1 = [],x2 = 9):\n x1_copy = x1.copy()\n x1.insert(0,0)\n if x2 == 10:\n return x1\n else:\n return minus(x1,x1_copy)\n\n\n\nif __name__ == \"__main__\":\n input_str = input()\n n,s = [a for a in input_str.split()]\n nl = list([int(a) for a in list(n)])\n sl = list([int(a) for a in list(s)])\n nl.reverse()\n sl.reverse()\n \n# x = (sl + 8) // 9 * 9\n x = multi(div(add(sl.copy(),[8]),9),9)\n# y = (x + 9) // 10 * 10\n y = multi(div(add(x.copy(),[9]),10),10)\n# z = y + (x - y + sum(y)) * 10 // 9\n sumy = list([int(a) for a in list(str(sum(y)))])\n sumy.reverse()\n z = add(y,multi(div(minus(minus(x,y),sumy),9),10))\n if cmp(nl,z):\n ans = add(minus(nl,z),[1])\n else:\n ans = [0]\n ans.reverse()\n ansstr = [str(a) for a in ans]\n print(\"\".join(ansstr))\n "}, {"source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nsumm = sum_digits(n)\n# print(summ)\nfor num in range(n, 9, -1):\n\t# value = num - s\n\tif num - summ >= s:\n\t\tcount += 1\n\tif (num - s) % 10 == 0:\n\t\tsumm = sum_digits(num)\n\telse:\n\t\tsumm -= 1\n\t\n\t# print(summ)\n\n# for num in range(10):\n# \tif num - s\n\n\nprint(count)\n\n\n# for num in range(n+1):\n"}, {"source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nsumm = sum_digits(n)\n# print(summ)\nfor num in range(n, 8, -1):\n\t# value = num - s\n\tif num - summ >= s:\n\t\tcount += 1\n\tif (num - s) % 10 == 0:\n\t\tsumm = sum_digits(num)\n\telse:\n\t\tsumm -= 1\n\t\n\t# print(summ)\n\n# for num in range(10):\n# \tif num - s\n\n\nprint(count)\n\n\n# for num in range(n+1):\n"}, {"source_code": "# def sum_digits(n):\n# s = 0\n# while n:\n# s += n % 10\n# n //= 10\n# return s\n\n\n# n, s = map(int, input().split())\n\n# count = 0\n# summ = sum_digits(n)\n# # k = sum_digits(n - n%10 - 1)\n# # print(k)\n# for num in range(n, 9, -1):\n# \tif num % 10 == 9:\n# \t\tsumm = sum_digits(num)\n# \t# print(num, summ)\n# \tif num - summ >= s:\n# \t\tcount += 1\n# \tsumm -= 1\n\t\n\n\n# print(count)\n\n\ndef sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\ndef binsearch(l, r, elem):\n\tn = r\n\tmedium = (l + r ) // 2\n\ts = medium - sum_digits(medium)\n\ts1 = medium-1- sum_digits(medium-1)\n\ts2 = medium+1 - sum_digits(medium+1)\n\twhile not(s2 >= elem and s < elem): #s >= elem and s1 < elem or \n\t\t# print(l,medium,r)\n\t\tif s <= elem:\n\t\t\tl = medium\n\t\telif s >= elem:\n\t\t\tr = medium\n\t\tk = medium\n\t\tmedium = (l + r ) // 2\n\t\tif k == medium:\n\t\t\tbreak\n\t\t# print(l,medium,r)\n\t\ts = medium - sum_digits(medium)\n\t\ts2 = medium+1 - sum_digits(medium+1)\n\ts1 = medium-1 - sum_digits(medium-1)\n\tif s >= elem and s1 < elem:\n\t\treturn medium\n\telif s2 >= elem and s < elem:\n\t\treturn medium + 1\n\telse:\n\t\treturn \tn+1\n\nn, s = map(int, input().split())\n# a = [i for i in range(n+1)]\n\n\ny = binsearch( 0, n, s)\n# print(y)\nprint(n - y + 1)\n\n\n\n\n"}, {"source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nsumm = sum_digits(n)\n# print(summ)\nfor num in range(n, 9, -1):\n\t# value = num - s\n\tif (num - s) % 10 == 0:\n\t\tsumm = sum_digits(num)\n\telse:\n\t\tsumm -= 1\n\tif num - summ >= s:\n\t\tcount += 1\n\t# print(summ)\n\n# for num in range(10):\n# \tif num - s\nc = 1\n\nprint( count)\n\n\n# for num in range(n+1):\n"}, {"source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nsumm = sum_digits(n)\n# print(summ)\nfor num in range(n, 9, -1):\n\t# value = num - s\n\tif (num - s) % 10 == 0:\n\t\tsumm = sum_digits(num)\n\telse:\n\t\tsumm -= 1\n\tif num - summ >= s:\n\t\tcount += 1\n\t# print(summ)\n\n# for num in range(10):\n# \tif num - s\n\n\nprint( count)\n\n\n# for num in range(n+1):\n"}, {"source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nsumm = sum_digits(n)\nk = sum_digits(n - n%10 - 1)\nprint(k)\nfor num in range(n, 9, -1):\n\tif num % 10 == 9:\n\t\tsumm = sum_digits(num)\n\tprint(num, summ)\n\tif num - summ >= s:\n\t\tcount += 1\n\tsumm -= 1\n\t\n\n\nprint(count)\n\n\n"}, {"source_code": "def sum_digits(n):\n s = 0\n while n:\n s += n % 10\n n //= 10\n return s\n\n\nn, s = map(int, input().split())\n\ncount = 0\nsumm = sum_digits(n)\n# print(summ)\nfor num in range(n, 9, -1):\n\t# value = num - s\n\tif (num - s) % 10 == 0:\n\t\tsumm = sum_digits(num)\n\t# print(num, summ)\n\tif num - summ >= s:\n\t\tcount += 1\n\tsumm -= 1\n\t\n\t# print(summ)\n\n# for num in range(10):\n# \tif num - s\n\n\nprint(count)\n\n\n# for num in range(n+1):\n"}, {"source_code": "n, s= map(int, input().split())\ncounter=0\nfor d in range(s,n+1):\t\n\tc=0\n\tf=d\n\twhile d != 0:\n\t e=d%10\n\t c=c+e\n\t d=int(d/10)\n\tcheck=f-c\n\tif check < s:\n\t\tcounter=counter+1\n\telse:\n\t\tbreak\nx=n+1-counter-s\nprint (x)"}, {"source_code": "n, s= map(int, input().split())\ncounter=0\nif n >= s:\n\tfor d in range(s,n+1):\t\n\t\tc=0\n\t\tf=d\n\t\twhile d != 0:\n\t\t e=d%10\n\t\t c=c+e\n\t\t d=int(d/10)\n\t\tcheck=f-c\n\t\tif check < s:\n\t\t\tcounter=counter+1\n\t\telse:\n\t\t\tbreak\n\tx=n+1-counter-s\n\tprint (x)\nelse:\n\tx=0\n\tprint (x)"}, {"source_code": "def sum_of_its_digits(Num, s):\n S=str(Num)\n sum=0\n for i in S:\n sum+=int(i)\n return (Num-sum)>=s\n\n\nk=input().split()\nn=int(k[0])\ns=int(k[1])\nfor i in range(1, n+1):\n if(sum_of_its_digits(i, s)):\n sum=n-i+1\n break\nprint(sum)\n"}, {"source_code": "for _ in range(1):\n n,s=map(int,input().split())\n #l=[int(i) for i in input().split()]\n lo=1 \n hi=n \n ans=n \n while lo<=hi:\n mi=(lo+hi)>>1 \n curr=sum(int(i) for i in str(mi))\n if mi-curr>=s:\n hi=mi-1 \n ans=mi \n else:\n lo=mi+1 \n print(n-ans+1)"}, {"source_code": "n, q = map(int, input().split())\np = []\ns = q\nwhile s > 8:\n t = 0\n while (t + 1) * 10 - 1 <= s:\n t = (t + 1) * 10 - 1\n p.append((s // t, t + 1))\n s %= t\nif s > 0:\n if p != []:\n start = p[0][0] + 1\n else:\n start = 1\n while start <= q:\n start *= 10\n print(max(0, n - start + 1))\nelse:\n F = True\n for i in p:\n if i[0] > 9:\n F = False\n if not F:\n start = p[0] + 1\n while start <= q:\n start *= 10\n print(max(0, n - start + 1))\n else:\n start = sum(p[i][0] * p[i][1] for i in range(len(p)))\n print(max(n - start + 1, 0))\n "}, {"source_code": "n, q = map(int, input().split())\np = []\ns = q\nwhile s > 8:\n t = 0\n while (t + 1) * 10 - 1 <= s:\n t = (t + 1) * 10 - 1\n p.append((s // t, t + 1))\n s %= t\nif s > 0:\n if p != []:\n start = p[0][0] + 1\n else:\n start = 1\n while start <= q:\n start *= 10\n print(max(0, n - start + 1))\nelse:\n F = True\n for i in p:\n if i[0] > 9:\n F = False\n if not F:\n start = p[0][0] + 1\n while start <= q:\n start *= 10\n print(max(0, n - start + 1))\n else:\n start = sum(p[i][0] * p[i][1] for i in range(len(p)))\n print(max(n - start + 1, 0))\n "}, {"source_code": "def calc(n):\n\tval = n\n\tcnt = 0\n\twhile(val):\n\t\tcnt += val%10\n\t\tval//=10\n\treturn n-cnt\n\t\t\nn,s = map(int,input().split())\nif n<=s:\n\tprint(0)\n\texit(0)\nval = s\nval //= 10\nif val==0:\n\tprint(n-9)\n\texit(0)\nval *= 10\nwhile calc(val)n:\n\t\tprint(0)\n\t\tbreak\nelse:\n\tprint(n-val+1)\n"}, {"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\ndef su(n):\n s=0\n while n:\n s+=(n%10)\n n//=10 \n return s\n\nmod=1000000007\n\nimport math\n\ndef main():\n \n n,s=mi()\n lo=1 \n hi=1000000000000000000\n while(los:\n hi=mid-1 \n elif as:\n hi=mid-1 \n elif a1:\n e=10*(d-2)+1\n a-=e\n #print(d)\n c=10*a \n #print(a,c)\n ans=n-c+1\n if ans<0:\n ans=0 \n print(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// 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 n,s=mi()\n a=int(math.ceil(s/9))\n d=int(math.log10(n))\n if d>=2:\n e=10*(d-2)+1\n a-=e\n #print(d)\n c=10*a \n #print(a,c)\n ans=n-c+1\n if ans<0:\n ans=0 \n print(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// 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\ndef su(n):\n s=0\n while n:\n s+=(n%10)\n n//=10 \n return s\n\nmod=1000000007\n\nimport math\n\ndef main():\n \n n,s=mi()\n lo=1 \n hi=1000000000000000000\n while(los:\n hi=mid-1 \n elif a=S:\n ans += 1\nprint ans"}, {"source_code": "R = lambda:map(int,raw_input().split())\n\nn,s = R()\n\nf = s/9\nif 9*f= s:\n\tr=mid\n else:\n\tl=mid+1\n\nprint n-l+1\n"}, {"source_code": "n, s = map(int, input().strip().split())\n\nnum = ''\ndiv = 9\n\nif s//10 != 0:\n div= int('9'*(len(str(s))-1))\n while s:\n num += str(s//div)\n s = s%div\n div //= 10\n if div == 0:\n div = 1\n if s == 0:\n num += '0'\nelse:\n num = str(s)\nmini = int(num)\nif mini%10 != 0:\n mini += 10\n mini -= mini%10\n\nprint(max(0, n-mini+1))\n\n# while s:\n# num += str(s%div)\n# s = s//div\n# div = div*10+9\n\n# num = num[::-1]\n\n\n# print(max(0, n-mini+1))\n"}, {"source_code": "n, s = map(int, input().strip().split())\n\nnum = ''\ndiv = 9\n\nif s//10 != 0:\n div= int('9'*(len(str(s))-1))\n while s:\n num += str(s//div)\n s = s%div\n div //= 10\n if div == 0:\n num += str(s)\n break\n elif s == 0:\n num += '0'\n break\nelse:\n num = str(s)\nmini = int(num)\nif mini%10 != 0:\n mini += 10\n mini -= mini%10\n\nprint(max(0, n-mini+1))\n\n# while s:\n# num += str(s%div)\n# s = s//div\n# div = div*10+9\n\n# num = num[::-1]\n\n\n# print(max(0, n-mini+1))\n"}, {"source_code": "n, s = map(int, input().strip().split())\n\nnum = ''\ndiv = 9\n\nif s//10 != 0:\n\n div= int('9'*(len(str(s))-1))\n if int('9'*len(str(s))) == s:\n div = s\n while div:\n num += str(s//div)\n s = s%div\n div //= 10\n num += str(s)\nelse:\n num = str(s)\nmini = int(num)\nif mini%10 != 0:\n mini += 10\n mini -= mini%10\n\nprint(max(0, n-mini+1))\n\n# while s:\n# num += str(s%div)\n# s = s//div\n# div = div*10+9\n\n# num = num[::-1]\n\n\n# print(max(0, n-mini+1))\n"}, {"source_code": "n, s = map(int, input().strip().split())\n\nnum = ''\ndiv = 9\n\nif s//10 != 0:\n div= int('9'*(len(str(s))-1))\n while s:\n num += str(s//div)\n s = s%div\n div //= 10\n if div == 0:\n div = 1\nelse:\n num = str(s)\nmini = int(num)\nif mini%10 != 0:\n mini += 10\n mini -= mini%10\n\nprint(max(0, n-mini+1))\n\n# while s:\n# num += str(s%div)\n# s = s//div\n# div = div*10+9\n\n# num = num[::-1]\n\n\n# print(max(0, n-mini+1))\n"}, {"source_code": "n, s = map(int, input().strip().split())\n\nnum = ''\ndiv = 9\n\nif s//10 != 0:\n\n div = 9\n while (s//div)//10 != 0:\n div = div*10+9\n if div > s:\n num = '1' + '0'*len(str(div))\n else:\n while div:\n num += str(s//div)\n s = s%div\n div //= 10\n num += str(s)\nelse:\n num = str(s)\nmini = int(num)\nif mini%10 != 0:\n mini += 10\n mini -= mini%10\n\nprint(max(0, n-mini+1))\n\n# while s:\n# num += str(s%div)\n# s = s//div\n# div = div*10+9\n\n# num = num[::-1]\n\n\n# print(max(0, n-mini+1))\n"}, {"source_code": "n, s = map(int, input().strip().split())\n\nnum = ''\nwhile s:\n num += str(s%9)\n s = s//9\n\nnum = num[::-1]\n\nmini = int(num)\nif mini%10 != 0:\n mini += 10\n mini -= mini%10\nprint(max(0, n-mini+1))\n"}, {"source_code": "def digisum(n):\n count = 0\n while(n>0):\n count+=n%10\n n = n//10\n return count\n\nn,s = list(map(int,input().split()))\nl,r = 1,n\nflag = 0\nwhile l=s:\n flag = 1\n cur = m\n r = m\n else:\n l = m+1\n if r-l==1:\n digi_sum = digisum(l)\n num = l\n if num-digi_sum>=s:\n flag = 1\n cur = l\n break\n digi_sum = digisum(r)\n num = r\n if num-digi_sum>=s:\n flag = 1\n cur = r\n break\n\nif flag==0:\n print(0)\nelse:\n print(n-cur+1)"}, {"source_code": "import sys\n\nn, s = map(int, input().split())\n\nok, ng = 10**18, -1\nwhile abs(ok - ng) > 1:\n mid = (ok + ng) >> 1\n if mid - sum(map(int, str(mid))) >= s:\n ok = mid\n else:\n ng = mid\n\nprint(max(0, n - ok + 1))\n"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n # print (weight,digit)\n mn=n+1\n for i in range(len(digit)-1,-1,-1):\n if s//weight[i]>9:\n break\n if s=s:\n mn=min(mn,10**(i+1))\n continue\n temp=s\n j=i\n ans=0\n while j>=0:\n t=temp//weight[j]\n if t>9:\n ans=0\n break\n ans+=t*10**(j+1)\n temp=temp-t*weight[j]\n j=j-1\n if ans!=0:\n ans+=math.ceil(temp/9)*10\n mn=min(ans,mn) \n # print (mn)\n if mn>n:\n print (0)\n else: \n print (n-mn+1)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n # print (weight)\n res=[0]*len(digit)\n mn=0\n for i in range(len(digit)-1,-1,-1):\n t=math.ceil(s/weight[i])\n mx=digit[i] if i==len(digit)-1 else 9\n if t>mx:\n break\n s=s-t*weight[i]\n res[i]=t\n mn+=t*10**(i+1)\n # print (res,mn)\n if mn==0:\n print (0)\n else: \n print (n-mn+1)\n \n \n\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "# @oj: codeforces\n# @id: hitwanyang\n# @email: 296866643@qq.com\n# @date: 2020-11-19 14:49\n# @url:https://codeforc.es/contest/817/problem/C\nimport sys,os\nfrom io import BytesIO, IOBase\nimport collections,itertools,bisect,heapq,math,string\nfrom decimal import *\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# ------------------------------\n## \u6ce8\u610f\u5d4c\u5957\u62ec\u53f7!!!!!!\n## \u5148\u6709\u601d\u8def,\u518d\u5199\u4ee3\u7801,\u522b\u7740\u6025!!!\n## \u5148\u6709\u6734\u7d20\u89e3\u6cd5,\u4e0d\u8981\u6709\u601d\u7ef4\u5b9a\u5f0f,\u8bd5\u7740\u6362\u601d\u8def\u89e3\u51b3\n## \u7cbe\u5ea6 print(\"%.10f\" % ans)\n## sqrt:int(math.sqrt(n))+1\n## \u5b57\u7b26\u4e32\u62fc\u63a5\u4e0d\u8981\u7528+\u64cd\u4f5c\uff0c\u4f1a\u8d85\u65f6\n## \u4e8c\u8fdb\u5236\u8f6c\u6362:bin(1)[2:].rjust(32,'0')\n## array copy:cur=array[::]\n## oeis:example 1, 3, _, 1260, _, _, _, _, _, 12164510040883200\ndef main():\n n,s=map(int,input().split())\n if n<10:\n print (0)\n return\n tmp=n//10\n digit=[]\n while tmp>0:\n digit.append(tmp%10)\n tmp=tmp//10\n weight=[10**i-1 for i in range(1,len(digit)+1)]\n # print (weight)\n res=[0]*len(digit)\n mn=0\n for i in range(len(digit)-1,-1,-1):\n t=math.floor(s/weight[i])\n mx=digit[i] if i==len(digit)-1 else 9\n if t>mx:\n break\n s=s-t*weight[i]\n res[i]=t\n mn+=t*10**(i+1)\n # print (res,mn,s)\n mn=10*math.ceil(s/9)+mn\n if mn>n:\n print (0)\n else: \n print (n-mn+1)\n \nif __name__ == \"__main__\":\n main()"}, {"source_code": "n,s = map(int,input().split())\n\ndef diff(m):\n return m - sum([int(k) for k in list(str(m))])\n \ndef digit_safe(k):\n r = len(list(str(k)))\n return toint([\"1\"]+[\"0\"]*(r-1))\na = list(str(n))\nb = list(str(s))\nd = int(a[0])\n\ndef toint(l):\n return int(\"\".join(l))\nres = 0\nfor i in range(d):\n z = toint([str(i)] + [\"0\" for _ in range(len(a)-1)])\n z1 = toint([str(i+1)] + [\"0\" for _ in range(len(a)-1)])\n count = diff(z)\n while z < z1 and count < s:\n z += digit_safe(s-count)\n count = diff(z)\n if z <= z1:\n res += (z1-z)\nz = toint([str(d)] + [\"0\" for _ in range(len(a)-1)])\nz1 = n+1\ncount = diff(z)\nprint(z)\nprint(count)\nprint(digit_safe(z))\nwhile z < z1 and count < s:\n z += digit_safe(s-count)\n count = diff(z)\nif z <= z1:\n res += (z1-z)\nprint(res)"}, {"source_code": "n,s=list(map(int,input().split()))\nif n-sum([int(x) for x in str(n)])s)\n return (n-sum([int(x) for x in str(n)]))>s\n start=1\n end=n\n mid=(start+end)//2\n while mid !=end and mid!=start:\n\n if check(mid):\n end=mid\n mid=(start+end)//2\n else:\n start=mid\n mid = (start + end) // 2\n # print(start,mid,end)\n print(n-end+1)\n"}, {"source_code": "def suma(n):\n\tres = 0\n\twhile n > 0:\n\t\tres += n % 10\n\t\tn //= 10\n\treturn res\n\nn, s = map(int, input().split())\nsu = suma(n)\nres = 0\nmaxS = n - su\nif maxS >= s:\n\tres += (n % 10) + 1\n#print('ms', maxS)\n#print('res p:', res)\nmaxS -= 9\n#print('mS', maxS)\ncant = max(0,(maxS // 9) - s)\nres += cant * 10\nprint(res)\n\n"}, {"source_code": "def suma(n):\n\tres = 0\n\twhile n > 0:\n\t\tres += n % 10\n\t\tn //= 10\n\treturn res\n\nn, s = map(int, input().split())\nif s > n:\n\tprint(0)\nelse:\n\tsu = suma(n)\n\tres = 0\n\tmaxS = n - su\n\tif maxS >= s:\n\t\tres += (n % 10) + 1\n\t#print('ms', maxS)\n\t#print('res p:', res)\n\tmaxS -= 9\n\t#print('mS', maxS)\n\twhile maxS >= s:\n\t\tres += 10\n\t\tmaxS -= 9\n\tprint(res)\n\n"}, {"source_code": "def suma(n):\n\tres = 0\n\twhile n > 0:\n\t\tres += n % 10\n\t\tn //= 10\n\treturn res\n\nn, s = map(int, input().split())\nsu = suma(n)\nres = 0\nmaxS = n - su\nif maxS >= s:\n\tres += (n % 10) + 1\n#print('ms', maxS)\n#print('res p:', res)\nmaxS -= 9\n#print('mS', maxS)\ncant = max(0, ((maxS // 9) - ((s - 1) // 9)))\nres += cant * 10\nprint(res)\n\n"}, {"source_code": "class ReallyBigNumbers:\n\n\tdef __init__(self, n, s):\n\t\tself.n = n\n\t\tself.s = s\n\t\tself.binarySearch()\n\n\tdef binarySearch(self):\n\t\tl = s\n\t\th = 10e18\n\t\twhile(l < h):\n\t\t\tmid = (h + l) // 2\n\t\t\tif self.isReallyBig(mid):\n\t\t\t\th = mid\n\t\t\telse:\n\t\t\t\tl = mid + 1\n\t\tself.x = int(l)\n\n\tdef isReallyBig(self, v):\n\t\tcp = v\n\t\tadd = 0\n\t\twhile v > 0:\n\t\t\tadd += (v % 10)\n\t\t\tv //= 10\n\t\treturn (cp - add) >= self.s\n\n\tdef show(self):\n\t\tif self.x <= self.n:\n\t\t\tprint(str(self.n - self.x + 1))\n\t\telse:\n\t\t\tprint(0)\n\n\nn, s = map(int, input().split())\nrbg = ReallyBigNumbers(n, s)\nrbg.show()\n\n"}, {"source_code": "from sys import stdin\ndef di(n):\n ans = 0\n while n:\n ans += n%10\n n/=10\n return ans\nn,s = map(int,stdin.readline().split())\nans = 0\nmy = set()\nif s< 180:\n for tt in xrange(1,180):\n for ss in xrange(s,180):\n hi = min(n, tt+ s)\n for i in xrange(ss,hi+1):\n if i-di(i) == ss:\n my.add(i)\nprint len(my)"}, {"source_code": "n, s = map(int, raw_input().split())\nans = 0\nfor i in xrange(300):\n if s + i > n:\n break\n t = s + i - sum(map(int, str(s + i)))\n if t >= s:\n ans += 1\nelse:\n ans += n - s - 300\nprint ans\n"}, {"source_code": "def check(x):\n temp = str(x)\n ans = 0\n for n in temp:\n ans += int(n)\n return x-ans\n\nn,s = map(int,raw_input().strip().split())\nif check(n)=m else 0\n"}, {"source_code": "import sys\ndef F(i):\n\treturn (i - sum([int(j) for j in str(i)]))\nn,s=map(int,raw_input().split())\nl=1\nh=n\nwhile(l= s):\n\t\tprint n-mid\n\t\tsys.exit()\n\telif(F(mid) < s):\n\t\tl=mid+1\n\telse:\n\t\th=mid-1\nprint 0\n"}, {"source_code": "import sys\ndef F(i):\n\treturn (i - sum([int(j) for j in str(i)]))\nn,s=map(int,raw_input().split())\nl=1\nh=n\nmid=0\nb=1\nwhile(l= s):\n\t\t# print n-mid\n\t\tb=0\n\t\tbreak\n\telif(F(mid) < s):\n\t\tl=mid+1\n\telse:\n\t\th=mid-1\nif(b):\n\tprint n-mid-1\nelse:\n\tprint n-mid\n"}, {"source_code": "import sys\ndef F(i):\n\treturn (i - sum([int(j) for j in str(i)]))\nn,s=map(int,raw_input().split())\nl=1\nh=n\nmid=0\nb=1\nwhile(l= s)):\n\t\t# print n-mid\n\t\tb=0\n\t\tbreak\n\telif(F(mid) < s):\n\t\tl=mid+1\n\telse:\n\t\th=mid-1\nif(b):\n\tprint n-mid-1\nelse:\n\tprint n-mid\n"}, {"source_code": "[n, s] = map(int, raw_input().strip().split(' '))\n\ndef sum(s):\n\td = str(s)\n\tanswer = 0\n\tfor i in range(len(d)):\n\t\tanswer += int(d[i])\n\treturn answer\n\nnum = s + 1\nanswer = 0\n\n\nwhile num <= n:\n\tif num == n and num - sum(num) >= s:\n\t\tanswer += 1\n\t\tbreak\n\tif num - sum(num) >= s and num - sum(num) < 133:\n\t\tif n >= num - num%10 + 10:\n\t\t\tanswer += 10\n\t\t\tnum = num - num%10 + 10\n\t\telse:\n\t\t\tanswer += num %10 + n - num + 1\n\t\t\tnum = n\n\n\telif num - sum(num) >= s and num - sum(num) > 133:\n\t\tanswer += n - num\n\t\tnum = n\n\n\telse:\n\t\tnum = num - num%10 + 10\n\nprint answer"}, {"source_code": "[n, s] = map(int, raw_input().strip().split(' '))\n\ndef sum(s):\n\td = str(s)\n\tanswer = 0\n\tfor i in range(len(d)):\n\t\tanswer += int(d[i])\n\treturn answer\n\nnum = s + 1\nanswer = 0\n\nif num == n and num - sum(num) >= s:\n\tanswer += 1\n\nwhile num <= n:\n\tif num == n:\n\t\tbreak\n\tif num - sum(num) >= s and num - sum(num) < 133:\n\t\tif n >= num - num%10 + 10:\n\t\t\tanswer += 10\n\t\t\tnum = num - num%10 + 10\n\t\telse:\n\t\t\tanswer += num %10 + n - num + 1\n\t\t\tnum = n\n\n\telif num - sum(num) >= s and num - sum(num) > 133:\n\t\tanswer += n - num\n\t\tnum = n\n\n\telse:\n\t\tnum = num - num%10 + 10\n\nprint answer"}, {"source_code": "n , k = map(int, raw_input().split())\n\ndef sum(k):\n\ts = 0\n\twhile k > 0:\n\t\ts += k%10\n\t\tk /= 10\n\treturn s\n\nt = k\nwhile t <= n:\n\td = t - sum(t)\n\tif d >= k:\n\t\tbreak\n\tt += 1\n\nprint n - t + 1"}, {"source_code": "n,s = raw_input().split()\ndef msmdez(x,y):\n\tx,y = int(x),int(y)\n\tx1,y1 = str(x),str(y)\n\tif len(x1) == len(y1) != 1:\n\t\tif abs(x-y) < 10:\n\t\t\treturn x1[-2] == y1[-2]\n\treturn False\nmd = msmdez(n,s)\nif int(n) <= int(s):\n\tprint 0\n\texit()\nif int(n) < int(s) + sum(map(int,list(n))) and not md:\n\tprint 0\n\texit()\nn,s = int(n),int(s)\nif s < 10 :\n\tprint n - 10 + 1\n\texit()\n\nif md or msmdez(s + 10, n):\n\tprint 0\n\texit()\nS = s\nwhile S <= n and not msmdez(S,n):\n\tk = S - sum(map(int,list(str(S))))\n\tif k >= s: break\n\tS+=10 \nif S+10 > n:\n\tprint int(str(n)[-1]) + 1\n\texit()\nprint n - (S - int(str(S)[-1])) + 1"}, {"source_code": "n,s = raw_input().split()\ndef msmdez(x,y):\n\tx,y = int(x),int(y)\n\tx1,y1 = str(x),str(y)\n\tif len(x1) == len(y1) != 1:\n\t\tif abs(x-y) < 10:\n\t\t\treturn x1[-2] == y1[-2]\n\treturn False\nmd = msmdez(n,s)\nif int(n) <= int(s):\n\tprint 0\n\texit()\nif int(n) < int(s) + sum(map(int,list(n))) and not md:\n\tprint 0\n\texit()\nn,s = int(n),int(s)\nif s < 10 :\n\tprint n - 10 + 1\n\texit()\nif md:\n\tprint 0\n\texit()\nS = s\nwhile S <= n and not msmdez(S,n):\n\tk = S - sum(map(int,list(str(S))))\n\tif k >= s: break\n\tS+=10 \nif S+10 > n:\n\tprint int(str(n)[-1]) + 1\n\texit()\nprint n - (S - int(str(S)[-1])) + 1\n\n\n\n"}, {"source_code": "n,s = raw_input().split()\ndef msmdez(x,y):\n\tx,y = int(x),int(y)\n\tx1,y1 = str(x),str(y)\n\tif len(x1) == len(y1) != 1:\n\t\tif abs(x-y) < 10:\n\t\t\treturn x1[-2] == y1[-2]\n\treturn False\nmd = msmdez(n,s)\nif int(n) <= int(s):\n\tprint 0\n\texit()\nif int(n) < int(s) + sum(map(int,list(s))) and not md:\n\tprint 0\n\texit()\nn,s = int(n),int(s)\nif s < 10 :\n\tprint n - 10 + 1\n\texit()\nif md or msmdez(s + 10, n):\n\tprint 0\n\texit()\nS = s\nwhile S <= n and not msmdez(S,n):\n\tk = S - sum(map(int,list(str(S))))\n\tif k >= s: break\n\tS+=10 \nif S+10 > n:\n\tprint int(str(n)[-1]) + 1\n\texit()\nprint S\nprint n - (S - int(str(S)[-1])) + 1"}, {"source_code": "n, s = map(int, raw_input().split())\n\nd = ((s-1)/9 + 1) * 10\nif n < d: print 0\nelse: print n - d + 1\n \n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef cal(x):\n tmp = x\n while x > 0:\n tmp -= x % 10\n x = x / 10\n return tmp\n\nlo = 0\nhi = n\nres = -1\nwhile lo <= hi:\n mid = (lo + hi) / 2\n if cal(mid) >= s:\n res = mid\n hi = mid - 1\n else:\n lo = mid + 1\n\nprint res\nif res == -1:\n print 0\nelse:\n print n - res + 1\n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef dif(x):\n tmp = x\n while tmp > 0:\n x = x - tmp % 10\n tmp = tmp/10\n return x\n\nl = 0\nr = 1000000000000000000\nwhile l < r:\n m = (l + r)/2\n if dif(m) < s:\n l = m + 1\n else: r = m\nd = l\nwhile d % 10 > 0: d -= 1\nif n < d: print 0\nelse: print n - d + 1\n \n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef dif(x):\n tmp = x\n while tmp > 0:\n x = x - tmp % 10\n tmp = tmp/10\n return x\n\nl = 0\nr = 1000000000000000000\nwhile l < r:\n m = (l + r)/2\n if dif(m) < s:\n l = m + 1\n else: r = m\nd = l\nif n < d: print 0\nelse: print n - d + 1\n \n"}, {"source_code": "n, s = map(int, raw_input().split())\n\ndef dif(x):\n tmp = x\n while tmp > 0:\n x = x - tmp % 10\n tmp = tmp/10\n return x\n\nl = 0\nr = 1000000000000000000\nwhile l < r:\n m = (l + r)/2\n if dif(m) < s:\n l = m + 1\n else: r = m - 1\nd = l\nif n < d: print 0\nelse: print n - d + 1\n \n"}, {"source_code": "import re, sys\nfrom collections import Counter\n\n\ndef main():\n N, S = map(int, raw_input().split())\n num = 0\n \n Tbeg, Tend = 0, int(1e20) \n \n while(Tbeg < Tend):\n Tmid = (Tbeg + Tend) >> 1\n\n if(9*Tmid >= S):\n Tend = Tmid\n else:\n Tbeg = Tmid + 1\n \n print max(0, N - 10*Tend + 1)\n\n############################################################\n############################################################\n############################################################\nif(__name__ == \"__main__\"):\n main()"}, {"source_code": "import re, sys\nfrom collections import Counter\n\n\ndef main():\n N, S = map(int, raw_input().split())\n num = 0\n\n for i in range(20):\n if(9*i >= S):\n num = i\n break\n \n print max(0, N - 10*num + 1)\n\n############################################################\n############################################################\n############################################################\nif(__name__ == \"__main__\"):\n main()"}, {"source_code": "import re\n\ndef get_index(s):\n\tl = []\n\tfor x in range(0,len(s)): \n\t\tif s[x]=='b':\n\t\t\tl.append(x)\n\treturn l\ndef gen(nums):\n\tif(nums[1]%9 ==0):\n\t\tans = (nums[0]-(int(nums[1]/9)*10) +1 )\n\t\treturn ans if ans>0 else 0\n\tans = (nums[0]-(int(nums[1]/9)*10 + 10) + 1)\n\treturn ans if ans>0 else 0\n\n\ndef main():\n\tnums = raw_input().split(' ')\n\tnums = map(lambda x:int(x),nums)\n\n\tprint gen(nums)\n\nif __name__ == \"__main__\":\n\t# while True:\n\t# \tmain()\n\tmain()"}, {"source_code": "n,s=input().split(' ')\nn,s=int(n), int(s)\nt=0\nif n>=10:\n for i in range(10,n+1):\n k=i%10+i//100+((i-i%10)-(i//100)*100)//10\n if i-k>=s:\n t+=1\n print(t)\nelif n<10 and s!=0:\n print ('0')\nelif n<10 and s==0:\n print (n)"}, {"source_code": "from math import ceil\nn, s = [int(i) for i in input().split()]\nk = ceil(s/9)\nf = 10 * k\nprint(max(n - f + 1, 0))\n"}, {"source_code": "from math import ceil\nn, s = [int(i) for i in input().split()]\nk = s // 9 if s % 9 == 0 else (s//9 + 1)\nf = 10 * k\nprint(max(n - f + 1, 0))\n"}, {"source_code": "n, s = map(int, input().rstrip().split())\nif n <= s:\n print(0)\n exit()\nx = s // 9\nrem = s % 9\nif rem > 0:\n x += 1\nprint(max(0, n - (x * 10) + 1))"}, {"source_code": "def sumOfDigits(s):\n\tsum = 0\n\ts = str(s)\n\tfor i in range(len(s)):\n\t\tsum = sum + int(s[i])\n\treturn sum\n\n\ndef binSearch(s, l, u):\n\tif (((l+u)//2) + 1 - sumOfDigits(((l+u)//2)+1)) >= s:\n\t\t#print((l+u)//2)\n\t\treturn (l+u)//2\n\tif (((l+u)//2) + 1 - sumOfDigits(((l+u)//2)+1)) < s:\n\t\t#print((l+u)//2)\n\t\treturn binSearch(s, ((l+u)//2)+1, u)\n\nn, s = input().strip().split(' ')\ns = int(s)\n# print(sumOfDigits(int(n)))\nif int(n) - sumOfDigits(n)= s:\n\t# \te = str(d)\n\t# \td = d - int(e[len(e)-1]) - 1\n\tprint(int(n) - d)\n"}, {"source_code": "n,s = map(int,input().split())\nl = n+1\nfor i in range(s,min(s+1000000, n),1):\n cur = sum([int(j) for j in str(i)])\n if(i-cur>=s):\n l = i; break\nprint(n-l+1)"}], "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b"} {"nl": {"description": "You are given an array a with n distinct integers. Construct an array b by permuting a such that for every non-empty subset of indices S\u2009=\u2009{x1,\u2009x2,\u2009...,\u2009xk} (1\u2009\u2264\u2009xi\u2009\u2264\u2009n, 0\u2009<\u2009k\u2009<\u2009n) the sums of elements on that positions in a and b are different, i.\u00a0e. ", "input_spec": "The first line contains one integer n (1\u2009\u2264\u2009n\u2009\u2264\u200922)\u00a0\u2014 the size of the array. The second line contains n space-separated distinct integers a1,\u2009a2,\u2009...,\u2009an (0\u2009\u2264\u2009ai\u2009\u2264\u2009109)\u00a0\u2014 the elements of the array.", "output_spec": "If there is no such array b, print -1. Otherwise in the only line print n space-separated integers b1,\u2009b2,\u2009...,\u2009bn. Note that b must be a permutation of a. If there are multiple answers, print any of them.", "sample_inputs": ["2\n1 2", "4\n1000 100 10 1"], "sample_outputs": ["2 1", "100 1 1000 10"], "notes": "NoteAn array x is a permutation of y, if we can shuffle elements of y such that it will coincide with x.Note that the empty subset and the subset containing all indices are not counted."}, "positive_code": [{"source_code": "n, a = int(input()), list(map(int, input().split()))\nb = sorted(a) + [min(a)]\nprint(' '.join([str(b[b.index(a[i]) + 1]) for i in range(n)]))\n"}, {"source_code": "#!/usr/bin/env python3\n\nn = int(input())\nA = list(map(int,input().split()))\nS = sorted(A) #sorted((A[i],i) for i in range(n))\nP = {S[i]:S[(i+1)%n] for i in range(n)}\nB = [P[a] for a in A]\nprint(' '.join(map(str,B)))\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nans=sorted(a)+[min(a)]\nprint(' '.join([str(ans[ans.index(a[i])+1]) for i in range(n)]))\n\n"}, {"source_code": "n = int(input())\nj = [int(x) for x in input().split(\" \")]\nif n ==1:\n print(j[0])\nelse:\n k = [[j[i],i] for i in range(n)]\n k.sort()\n o = [0 for i in range(len(k))]\n for i in range(len(k)):\n o[k[i][1]] = str(k[(i+1)%n][0])\n \n\n print(\" \".join(o))\n"}, {"source_code": "n = int(input())\nl = [int(i) for i in input().split(\" \")]\nnums = sorted(l)\n\n# index = []\n# for i in l:\n# index.append(nums.index(i))\n# #print(index)\n# indexbis = [int(i - 1) for i in index]\n#\n# for i in range(n):\n# if indexbis[i] == min(indexbis):\n# indexbis[i] = n - 1\n# break\n# #print(indexbis)\n# for i in indexbis:\n# print(l[index.index(i)], end = \" \")\n\n# Way of shifting array by 1\n\nfor i in l:\n print(nums[(nums.index(i) + 1) % n], end = \" \")"}, {"source_code": "'''\nshuffle an array of integer such that new\nnew array formed by shuffling will not have any\nsubset whose sum is equal to sum of same indexed subset\nof the original array\n\nExamples\ninput\n2\n1 2\noutput\n2 1\ninput\n4\n1000 100 10 1\noutput\n100 1 1000 10\n\n\n'''\nn = int(input())\na = list(map(int, input().split()))\nsorted_a = sorted(a)\nshifted_sorted_a = [sorted_a[-1]] + sorted_a[:-1]\nfor i in range(len(a)):\n pos_in_sorted = sorted_a.index(a[i])\n print(shifted_sorted_a[pos_in_sorted], end=\" \")"}, {"source_code": "n, a = int(input()), list(map(int, input().split()))\nb = sorted(a) + [min(a)]\nprint(' '.join([str(b[b.index(a[i]) + 1]) for i in range(n)]))"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = sorted(a)\nfor i in range(n):\n\tprint (b[(b.index(a[i]) + 1) % n],end=\" \") "}, {"source_code": "n = int(input())\na = list(map(int , input().split()))\nans = list()\nfor i in range(n):\n ans.append(0)\nposition = dict()\nfor i in range(n):\n position[a[i]] = i;\na = sorted(a)\nans[position[a[n - 1]]] = a[0];\nfor i in range(n - 1):\n ans[position[a[i]]] = a[i + 1]\nfor i in range(n):\n print(ans[i] , end = \" \")\n"}, {"source_code": "n = int(input())\nA = input().split()\nA = [int(i) for i in A]\nif n != len(set(A)):\n print (-1)\nelse:\n B = A[:]\n B.sort()\n C = [n+100]*n\n for i in range (0,n):\n C[i] = A.index(B[i])\n D = [n+100]*n\n for i in range (0,n):\n D[C[i]] = A[C[(i+1)%n]]\n for x in D:\n print(x, end=\" \")\n print()"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nsorted_a = sorted(a)\nshifted_sorted_a = [sorted_a[-1]] + sorted_a[:-1]\n#print(sorted_a)\n#print(shifted_sorted_a)\nfor i in range(len(a)):\n pos_in_sorted = sorted_a.index(a[i])\n print(shifted_sorted_a[pos_in_sorted], end=\" \")\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nsorted_a = sorted(a)\nshifted_sorted_a = [sorted_a[-1]] + sorted_a[:-1]\n#print(sorted_a)\n#print(shifted_sorted_a)\nfor i in range(len(a)):\n\tpos_in_sorted = sorted_a.index(a[i])\n\tprint(shifted_sorted_a[pos_in_sorted], end=\" \")\nprint()\n\n\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nb = sorted(a)\ns = {}\nfor i in range(-1, n-1): s[b[i+1]] = b[i]\nprint(' '.join([str(s[i]) for i in a]))"}, {"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/17 22:54\n\n\"\"\"\n\nN = int(input())\n\nA = [int(x) for x in input().split()]\n\nwc = collections.Counter(A)\nif any(v > 1 for v in wc.values()):\n print(-1)\n exit(0)\n\nC = list(sorted(A))\n\nNC = {C[i]: C[i+1] for i in range(N-1)}\nNC[C[-1]] = C[0]\n\n\nans = []\nfor v in A:\n ans.append(NC[v])\n\nprint(\" \".join(map(str, ans)))"}, {"source_code": "import math\nn = int(input())\na = list(map(int, input().split()))\npos = {}\nans = []\nfor i in range(n) :\n\tpos[a[i]] = i\n\tans.append(0)\na.sort()\nans[pos[a[n - 1]]] = a[0]\nfor i in range(n - 1) :\n\tans[pos[a[i]]] = a[i + 1]\nfor i in ans :\n\tprint(i, end = ' ')\n"}, {"source_code": "n, a = int(input()), list(map(int, input().split()))\nb = sorted(a) + [min(a)]\nprint(' '.join([str(b[b.index(a[i]) + 1]) for i in range(n)]))"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nif n == 1:\n print(a[0])\nelse:\n a_with_index = [[a[i], i] for i in range(n)]\n a_with_index.sort()\n ans = [0 for i in range(n)]\n for i in range(n):\n ans[a_with_index[i][1]] = str(a_with_index[(i + 1) % n][0])\n print(\" \".join(ans))"}, {"source_code": "n = input()\na = map(int, raw_input().split())\nb = sorted(a)\nfor i in range(n):\n\tprint b[(b.index(a[i]) + 1) % n], "}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nb = [[0]*2 for _ in range(n)]\nans = [0]*n\nfor i in range(n):\n\tb[i] = [a[i],i]\nb = sorted(b)\nfor i in range(n):\n\tans[b[i][1]] = b[(i+1)%n][0]\nfor i in ans:\n\tprint i,"}, {"source_code": "n = int(raw_input())\n\narr = map(int, raw_input().split())\n\n# only care about permutations which are one big cycle\n\nd = {}\narr2 = sorted(arr)\nfor i in range(n):\n d[arr2[i]] = arr2[(i + 1) % n]\n #print i - 1, arr[i], arr[i - 1]\nfor i in range(n):\n arr[i] = d[arr[i]]\n\nprint \" \".join(map(str, arr))\n"}, {"source_code": "n = int(raw_input())\nl1 = map(int, raw_input().split())\nl = [i for i in l1]\nl.sort()\nm = []\nfor i in l1:\n if i == l[-1]:\n m.append(l[0])\n else:\n for j in l:\n if j > i:\n m.append(j)\n break\nprint \" \".join(map(str,m))"}, {"source_code": "n = int(raw_input())\nl1 = map(int, raw_input().split())\nl = [i for i in l1]\nl.sort()\nm = []\nfor i in l1:\n if i == l[-1]:\n m.append(l[0])\n else:\n for j in l:\n if j > i:\n m.append(j)\n break\nprint \" \".join(map(str,m))"}, {"source_code": "n = int(raw_input())\nnums = list(map(int,raw_input().split()))\ntemp = sorted(nums)\nans = [0 for x in range(n)]\nfor i in range(n):\n ans[nums.index(temp[i])] = temp[(i+1)%n]\nprint \" \".join([str(x) for x in ans])"}, {"source_code": "n = int(input())\n*a, = map(int, input().split())\nb = sorted(a)\nfor i in a:\n print(b[(b.index(i) + 1) % n], end=' ')"}, {"source_code": "import sys, math\nreadline = sys.stdin.readline\n\nn = int(readline())\ninf = pow(10,10)\ntmp = list(map(int,readline().split()))\ntmp2 = [inf] * n\nmai = 0\nfor i in range(n):\n for j in range(n):\n if tmp[i] < tmp[j]:\n tmp2[i] = min(tmp2[i],tmp[j])\n\nfor i in range(n):\n if tmp[i] == max(tmp):\n mai = i\n break\ntmp2[mai] = min(tmp)\nfor x in tmp2:\n print(x,end=' ')\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\ndef solve(n, a):\n if n == 1:\n return [str(a[0])]\n \n arr = [[x, i] for i, x in enumerate(a)]\n arr = sorted(arr, key=lambda x:x[0])\n ans = [-1] * n\n \n for [x, i], [y, j] in zip(arr[1:], arr[:-1]):\n ans[j] = str(x)\n \n ans[arr[-1][1]] = str(arr[0][0])\n \n return ans\n\nans = solve(n, a)\n\nprint(' '.join(ans)) "}, {"source_code": "n=int(input())\n\na=list(map(int,input().split()))\nb=a.copy()\na.sort()\nc=[]\nfor i in range(n):\n c.append(a[(a.index(b[i])+1)%n])\nprint(*c)\n\n\n"}, {"source_code": "n = int(input())\nlst = [int(i) for i in input().split()]\nfor elem in lst:\n print(sorted(lst)[sorted(lst).index(elem)-1])\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb = sorted(a) + [min(a)]\nfor i in range(n):print(b[b.index(a[i])+1],end=' ')\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=sorted(a)+[min(a)]\nfor i in range(n):\n a[i]=str(b[b.index(a[i])+1])\nprint(' '.join(a))\n\n"}, {"source_code": "def solve():\n n=int(input())\n a=list(map(int,input().split()))\n b=sorted(a)+[min(a)]\n for i in range(n):\n a[i]=str(b[b.index(a[i])+1])\n print(' '.join(a))\n return\nsolve()\n"}, {"source_code": "inf = lambda : map(int, input().split())\nn, = inf()\na = list(inf())\np = sorted([i for i in range(n)], key=lambda x : a[x])\nb = [0]*n\nfor i in range(n):\n\tb[p[i]] = a[p[(i+1)%n]]\nfor i in range(n):\n\tprint(b[i], end=' ')\nprint()\n"}, {"source_code": "import sys\ninput()\na = list(map(int, input().split()))\nb = sorted(a)\nfor i in a:\n\tsys.stdout.write(str(b[b.index(i)-1]))\n\tsys.stdout.write(\" \")\nsys.stdout.write(\"\\n\")"}, {"source_code": "n = int(input())\nL = list(map(int, input().split()))\nS = sorted(L)\nfor i in L:\n print(S[(S.index(i) + 1)%n], end=' ')"}, {"source_code": "input()\nt = list(map(int, input().split()))\ns = sorted(t)\nfor q in t: print(s[s.index(q) - 1])"}, {"source_code": "input()\nt, s = zip(*sorted((int(q), i) for i, q in enumerate(input().split())))\nfor i, q in sorted((i, q) for q, i in zip(t[1:] + t[:1], s)): print(q)"}, {"source_code": "input()\n\na = list(map(int, input().split()))\n\nfor i in a:\n\n print(sorted(a)[sorted(a).index(i)-1])\n\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "input()\na = list(map(int, input().split()))\nfor i in a:\n print(sorted(a)[sorted(a).index(i)-1])\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nb = [(x, i) for i, x in enumerate(a)]\nb.sort()\nc = b[1:] + [b[0]]\nans = [0] * n\nfor i, x in enumerate(b):\n ans[x[1]] = c[i][0]\nfor x in ans:\n print x,\nprint\n"}, {"source_code": "input()\na = map(int, raw_input().split())\nfor i in a:\n\tprint sorted(a)[sorted(a).index(i)-1],"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nb=sorted(a)\nf={}\nfor i in range(n):\n\tf[b[i]]=i\nfor x in a:\n\tprint b[(f[x]+1)%n],"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nb=sorted(a[:])\nm={}\nfor i in range(n):m[b[i]]=i\nprint \" \".join([str(b[(m[x]+1)%n]) for x in a])"}, {"source_code": "# 1: no one can be in their original position\nn = int(raw_input())\nb = map(int, raw_input().split())\n\nc = [(t, i) for i, t in enumerate(b)]\nc.sort()\n\nd = [0 for i in range(n)]\n\nfor i in range(n - 1):\n d[c[i+1][-1]] = c[i][0]\nd[c[0][-1]] = c[-1][0]\n\nfor t in d:\n print t,\n"}, {"source_code": "n=input()\na=list(map(int,raw_input().split()))\nb = sorted(a) + [min(a)]\nfor i in range(n):print(b[b.index(a[i])+1]);end=' '"}, {"source_code": "n=input()\na=map(int,raw_input().split())\nb=sorted(a)\nf={}\nfor i in range(n):f[b[i]]=i\nfor x in a:print b[(f[x]+1)%n],\n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\nB = sorted(A)\nfor i in A:\n print(B[B.index(i) - 1], end=' ')"}, {"source_code": "n = int(input())\nA = [int(a) for a in input().split(' ')]\nR = sorted(A)\n\nfor i in range(n):\n if A[i] == R[-1]:\n A[i] = R[0]\n else:\n A[i] = R[R.index(A[i])+1]\n\nprint(' '.join([str(a) for a in A]))"}, {"source_code": "n, a = int(input()), [int(i) for i in input().split()]\nb, m = a[:], dict()\nb.sort()\nfor i in range(len(b) - 1):\n m[b[i]] = b[i + 1]\nm[b[-1]] = b[0]\nfor i in range(len(a)):\n a[i] = m[a[i]]\nif len(set(b)) == n:\n print(*a)\nelse:\n print(-1)\n"}, {"source_code": "n = int(input())\nl = [int(i) for i in input().split(\" \")]\nindex = []\nnums = sorted(l)\nfor i in l:\n index.append(nums.index(i))\n#print(index)\nindexbis = [int(i - 1) for i in index]\n\nfor i in range(n):\n if indexbis[i] == min(indexbis):\n indexbis[i] = n - 1\n break\n#print(indexbis)\nfor i in indexbis:\n print(l[index.index(i)], end = \" \")\n\n\n\n"}, {"source_code": "n, a = int(input()), list(map(int, input().split()))\nb = sorted(a) + [min(a)]\nprint(' '.join([str(b[b.index(a[i]) + 1]) for i in range(n)]))"}, {"source_code": "n = int(input())\ndata = list(map(int, input().split()))\n\nsorted_data = sorted(data)\n\nans = {}\nfor i in range(0, n):\n ans[sorted_data[i]] = sorted_data[(i + 1) % n]\n\nfor v in data:\n print(ans[v], end=' ')\n\n"}], "negative_code": [{"source_code": "#!/usr/bin/env python3\n\nn = int(input())\nL = list(map(int,input().split()))\ncpt = 0\na = n-1\nfor i in range(n-1,-1,-1):\n if a>=i:\n cpt += 1\n a = min(a,i-L[i]-1)\nprint(cpt)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\na.append(a[0])\nprint(' '.join([str(a[i]) for i in range(1,n+1)]))"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nans=sorted(a)+[min(a)]\nprint(ans)\nprint(' '.join([str(ans[ans.index(a[i])+1]) for i in range(n)]))\n\n"}, {"source_code": "\nn = int(input())\nj = [int(x) for x in input().split(\" \")]\nif n ==1:\n print(-1)\nelse:\n k = [[j[i],i] for i in range(n)]\n k.sort()\n\n l = [str(j[(x[1]+1)%n]) for x in k]\n\n print(\" \".join(l))\n"}, {"source_code": "\nn = int(input())\n\nif n ==1:\n print(-1)\nelse:\n j = [int(x) for x in input().split(\" \")]\n k = [[j[i],i] for i in range(n)]\n k.sort()\n\n l = [str(j[(x[1]+1)%n]) for x in k]\n\n print(\" \".join(l))\n"}, {"source_code": "n = int(input())\nj = [int(x) for x in input().split(\" \")]\nk = [[j[i],i] for i in range(n)]\nk.sort()\n\nl = [str(j[(x[1]+1)%n]) for x in k]\n\nprint(\" \".join(l))\n"}, {"source_code": "\nn = int(input())\nj = [int(x) for x in input().split(\" \")]\nif n ==1:\n print(-1)\nelse:\n k = [[j[i],i] for i in range(n)]\n k.sort()\n o = [0 for i in range(len(k))]\n for i in range(len(k)):\n o[k[i][1]] = str(k[(i+1)%n][0])\n \n\n print(\" \".join(o))\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().strip().split()))\nl.sort()\nfor i in range(1,n):\n\tprint (l[i],end=\" \")\nprint (l[0])"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = sorted(a)\nprint (b)\nfor i in range(n):\n\tprint (b[(b.index(a[i]) + 1) % n],end=\" \") "}, {"source_code": "n = int(input())\nA = input().split()\nA = [int(i) for i in A]\nif n != len(set(A)):\n print (-1)\nelse:\n B = A[:]\n B.sort()\n C = [n+100]*n\n for i in range (0,n):\n C[i] = A.index(B[i])\n D = [n+100]*n\n for i in range (0,n):\n D[C[i]] = A[C[n-1-i]]\n for x in D:\n print(x, end=\" \")\n print()"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nca = sorted([i for i in a])\nca = [ca[-1]] + ca[:-1]\nif ca == a:\n print(-1)\n exit()\nprint(' '.join([str(i) for i in ca]))"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nca = sorted(a)\nca = [a[-1]] + a[:-1]\nif ca == a:\n print(-1)\n exit()\nprint(' '.join([str(i) for i in a]))"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nca = sorted([i for i in a])\nca = ca[1:] + [ca[0]]\nif ca == a:\n print(-1)\n exit()\nprint(' '.join([str(i) for i in ca]))"}, {"source_code": "n = int(input())\na = [i for i in input().split()]\nb = sorted(a)\ns = {}\nfor i in range(-1, n-1): s[b[i+1]] = b[i]\nprint(' '.join([s[i] for i in a]))"}, {"source_code": "n = int(input())\na = [i for i in input().split()]\nb = (a[1:]+[a[0]])\nif b == a: print (-1)\nelse: print(' '.join(b))"}, {"source_code": "n = int(input())\na = [i for i in input().split()]\nb = (a[1:]+[a[0]])\nif n == 1: print(a[0])\nelif b == a: print (-1)\nelse: print(' '.join(b))"}, {"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/17 22:54\n\n\"\"\"\n\nN = int(input())\n\nA = [int(x) for x in input().split()]\n\ndef check(a, b):\n\n if not a and not b:\n return True\n\n if len(a) == 1 and len(b) == 1:\n return a[0] != b[0]\n\n if sum(a) == sum(b):\n return False\n\n na, nb = len(a), len(b)\n al, ar = a[:na//2], a[na//2:]\n bl, br = b[:nb//2], b[nb//2:]\n\n if check(al, bl) and check(ar, br):\n return True\n\n return False\n\n\n\n\ndef dfs(a, ais, b):\n if not ais:\n print(\" \".join(map(str, b)))\n return True\n if b and not check(a[:len(b)], b):\n return False\n for i in ais:\n if dfs(a, ais - {i}, b+[a[i]]):\n return True\n\n return False\n\n\nif not dfs(A, {i for i in range(N)}, []):\n print(-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/17 22:54\n\n\"\"\"\n\nN = int(input())\n\nA = [int(x) for x in input().split()]\n\ndef check(a, b):\n\n if not a and not b:\n return True\n\n if len(a) == 1 and len(b) == 1:\n return a[0] != b[0]\n\n if sum(a) == sum(b):\n return False\n\n na, nb = len(a), len(b)\n al, ar = a[:na//2], a[na//2:]\n bl, br = b[:nb//2], b[nb//2:]\n\n if check(al, bl) and check(ar, br):\n\n als = {0}\n for v in al:\n als |= {u + v for u in als}\n bls = {0}\n for v in bl:\n bls |= {u+v for u in bls}\n\n ars = {0}\n for v in ar:\n ars |= {u+v for u in ars}\n\n brs = {0}\n for v in br:\n brs |= {u+v for u in brs}\n\n als.remove(0)\n bls.remove(0)\n ars.remove(0)\n brs.remove(0)\n\n return not {u+v for u in als for v in ars} & {u+v for u in bls for v in brs}\n\n\n\n\n\n\n\n return False\n\n\ndef check2(a, b):\n pass\n\n\ndef dfs(a, ais, b):\n if not ais:\n if a[-1] != b[-1]:\n print(\" \".join(map(str, b)))\n return True\n if b and not check(a[:len(b)], b):\n return False\n for i in ais:\n if dfs(a, ais - {i}, b+[a[i]]):\n return True\n\n return False\n\n\nif not dfs(A, {i for i in range(N)}, []):\n print(-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/17 22:54\n\n\"\"\"\n\nN = int(input())\n\nA = [int(x) for x in input().split()]\n\ndef check(a, b):\n\n if not a and not b:\n return True\n\n if len(a) == 1 and len(b) == 1:\n return a[0] != b[0]\n\n if sum(a) == sum(b):\n return False\n\n na, nb = len(a), len(b)\n al, ar = a[:na//2], a[na//2:]\n bl, br = b[:nb//2], b[nb//2:]\n\n if check(al, bl) and check(ar, br):\n return True\n\n return False\n\n\ndef check2(a, b):\n pass\n\n\ndef dfs(a, ais, b):\n if not ais:\n if a[-1] != b[-1]:\n print(\" \".join(map(str, b)))\n return True\n if b and not check(a[:len(b)], b):\n return False\n for i in ais:\n if dfs(a, ais - {i}, b+[a[i]]):\n return True\n\n return False\n\n\nif not dfs(A, {i for i in range(N)}, []):\n print(-1)\n"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nb = [0]*n\nfor i in range(n):\n\tb[i] = a[i]\na = sorted(a)\nfor i in range(n):\n\ta[i] = b[(i+1)%n]\nfor i in a:\n\tprint i,"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nb = [[0]*2 for _ in range(n)]\nans = [0]*n\nfor i in range(n):\n\tb[i] = [a[i],i]\na = sorted(a)\nfor i in range(n):\n\tans[b[i][1]] = b[(i+1)%n][0]\nfor i in ans:\n\tprint i,"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nb = [0]*n\nans = [0]*n\nfor i in range(n):\n\tb[i] = a[i]\na = sorted(a)\nfor i in range(n):\n\tans[(i+1)%n] = a[i]\nfor i in ans:\n\tprint i,"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nb = [0]*n\nfor i in range(n):\n\tb[i] = a[i]\ni = 0\nwhile i<(int(n/2)+1):\n\ta[i],a[i+1] = a[i+1],a[i]\n\ta[i+1],a[n-1] = a[n-1],a[i+1]\n\ti += 2\nt = False\nfor i in range(n):\n\tif b[i]==a[i]:\n\t\tt = True\n\telse:\n\t\tt = False\n\t\tbreak\nif t:\n\tprint -1\nelse:\n\tfor i in a:\n\t\tprint i,"}, {"source_code": "n = int(raw_input())\n\narr = map(int, raw_input().split())\n\n# only care about permutations which are one big cycle\n\nd = {}\narr2 = sorted(arr)\nfor i in range(n):\n d[arr[i]] = arr2[i - 1]\n\nfor i in range(n):\n arr[i] = d[arr[i]]\n\nprint \" \".join(map(str, arr))\n"}, {"source_code": "n = int(raw_input())\nnums = list(map(int,raw_input().split()))\nprint \" \".join([str(x) for x in [nums[-1]]+nums[:-1]])"}, {"source_code": "n = int(input())\n*a, = map(int, input().split())\nb = sorted(a)\nfor i in a:\n print(a[(b.index(i) + 1) % n], end=' ')"}, {"source_code": "import sys, math\nreadline = sys.stdin.readline\n\nn = int(readline())\ninf = pow(10,10)\ntmp = list(map(int,readline().split()))\nm = min(tmp)\nmi = 0\nfor i in range(n):\n if tmp[i] == m:\n mi = i\nfor i in range(n):\n tp = inf\n k = 0\n for j in range(n):\n if tmp[j] > tmp[i] and tmp[j] <= tp:\n tp = tmp[j]\n k = j\n if tp == inf:\n tp = m\n k = mi\n tmp[k], tmp[i] = tmp[i], tp\nfor x in tmp:\n print(x,end=' ')\n"}, {"source_code": "import sys, math\nreadline = sys.stdin.readline\n\nn = int(readline())\ninf = pow(10,10)\ntmp = list(map(int,readline().split()))\nm = min(tmp)\nmi = 0\nfor i in range(n):\n if tmp[i] == m:\n mi = i\ns = set()\nfor i in range(n):\n if i not in s:\n tp = inf\n k = 0\n for j in range(n):\n if tmp[j] > tmp[i] and tmp[j] <= tp:\n tp = tmp[j]\n k = j\n if tp == inf:\n tp = m\n k = mi\n tmp[k], tmp[i] = tmp[i], tp\n s.add(i)\n s.add(k)\nfor x in tmp:\n print(x,end=' ')\n"}, {"source_code": "import sys, math\nreadline = sys.stdin.readline\n \nn = int(readline())\n \ntmp = list(map(int,readline().split()))\ntmp.sort()\ntmp1 = [tmp[n - 1]]\nfor i in range(n - 1):\n tmp1.append(tmp[i])\n \nfor x in tmp1:\n print(x,end=' ')"}, {"source_code": "import sys, math\nreadline = sys.stdin.readline\n\nn = int(readline())\n\ntmp = list(map(int,readline().split()))\ntmp1 = [tmp[n - 1]]\nfor i in range(n - 1):\n tmp1.append(tmp[i])\n\nfor x in tmp1:\n print(x,end=' ')"}, {"source_code": "import sys, math\nreadline = sys.stdin.readline\n\nn = int(readline())\ninf = pow(10,10)\ntmp = list(map(int,readline().split()))\nm = min(tmp)\nmi = 0\nfor i in range(n):\n if tmp[i] == m:\n mi = i\ns = set()\nfor i in range(n):\n if i not in s:\n tp = inf\n k = 0\n for j in range(n):\n if j not in s:\n if tmp[j] > tmp[i] and tmp[j] <= tp:\n tp = tmp[j]\n k = j\n if tp == inf:\n tp = m\n k = mi\n tmp[k], tmp[i] = tmp[i], tp\n s.add(i)\n s.add(k)\nfor x in tmp:\n print(x,end=' ')\n"}, {"source_code": "n=int(input())\n\na=list(map(int,input().split()))\nb=a.copy()\na.sort()\nc=[]\nfor i in range(n):\n c.append(a[(a.index(b[i])+1)%n])\nprint(c)\n\n\n"}, {"source_code": "n=int(input())\nif n<2:exit(print(-1))\na=sorted(list(map(int,input().split())))\nprint(a[-1],end=' ')\nfor i in range(n-1):\n print(a[i],end=' ')\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nprint(a[-1],end=' ')\nfor i in range(n-1):\n print(a[i],end=' ')\n\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nb=[i for i in a[1:]]\nb.append(a[0])\nfor i in range(n):\n for j in range(i,n):\n if sum(a[i:j+1])==sum(b[i:j+1]) and j-i 0:\n s = max(S-set([d]), key=lambda s: diff(A[i],s))\n else:\n s = max(S, key=lambda s: diff(A[i],s))\n B.append(s)\n S.remove(s)\n\nif check():\n print(' '.join([str(b) for b in B]))\nelse:\n print(-1)"}, {"source_code": "n = int(input())\nA = [int(a) for a in input().split(' ')]\nA.sort()\nA = [A[-1]] + A[:-1]\n\nprint(' '.join([str(a) for a in A]))"}, {"source_code": "n = int(input())\nA = [int(a) for a in input().split(' ')]\nR = sorted(A)\n\nfor i in range(n):\n if A[i] == R[0]:\n A[i] = R[-1]\n elif A[i] == R[-1]:\n A[i] = R[0]\n else:\n A[i] = R[R.index(A[i])+1]\n\nprint(' '.join([str(a) for a in A]))"}, {"source_code": "n = int(input())\nA = [int(a) for a in input().split(' ')]\nS = set(A)\nB = []\n\ndef diff(x, y):\n return abs(x-y) * abs(A.index(x)-A.index(y))\n\ndef check():\n for i in range(n):\n for j in range(i, n):\n if not (i == 0 and j == n-1) and sum(A[i:j+1]) == sum(B[i:j+1]):\n return False\n return True\n\nfor i in range(n):\n s = max(S, key=lambda s: diff(A[i],s))\n B.append(s)\n S.remove(s)\n\n#if check():\nprint(' '.join([str(b) for b in B]))\n#else:\n# print(-1)"}, {"source_code": "n = int(input())\nA = [int(a) for a in input().split(' ')]\nS = set(A)\nB = []\n\nfor i in range(n):\n s = max(S, key=lambda s: abs(A[i]-s))\n B.append(s)\n S.remove(s)\n\ndef check():\n for i in range(n):\n for j in range(i, n):\n if not (i == 0 and j == n-1) and sum(A[i:j+1]) == sum(B[i:j+1]):\n return False\n return True\n\nif check():\n print(' '.join([str(b) for b in B]))\nelse:\n print(-1)"}, {"source_code": "n = int(input())\nA = [int(a) for a in input().split(' ')]\nS = set(A)\nB = []\n\ndef diff(x, y):\n return abs(x-y) * abs(A.index(x)-A.index(y))\n\ndef check():\n for i in range(n):\n for j in range(i, n):\n if not (i == 0 and j == n-1) and sum(A[i:j+1]) == sum(B[i:j+1]):\n return False\n return True\n\nfor i in range(n):\n s = max(S, key=lambda s: diff(A[i],s))\n B.append(s)\n S.remove(s)\n\n#if check():\n print(' '.join([str(b) for b in B]))\n#else:\n# print(-1)"}, {"source_code": "n, a = int(input()), [int(i) for i in input().split()]\nb, m = a[:], dict()\nb.sort()\nfor i in range(len(b) - 1):\n m[b[i]] = b[i + 1]\n print(b[i], b[i + 1])\nm[b[-1]] = b[0]\nfor i in range(len(a)):\n a[i] = m[a[i]]\nif len(set(b)) == n:\n print(*a)\nelse:\n print(-1)\n"}, {"source_code": "n = int(input())\nl = [int(i) for i in input().split(\" \")]\nindex = []\nfor i in range(n):\n x = min(l)\n for j in range(n):\n if l[j] == x:\n index.append(j)\n l[j] += 10e9 + 5\n break\nfor i in range(n):\n l[i] -= (10e9 + 5)\n#print(index)\n#print(l)\nfor i in range(n):\n x = index[i] + 1\n alert = 0\n for j in range(n):\n if index[j] == x:\n print(int(l[j]), end = \" \")\n alert = 1\n break\n if alert == 0:\n print(int(min(l)), end = \" \")\n\n\n"}, {"source_code": "n = int(input())\nl = [int(i) for i in input().split(\" \")]\n\nresult = sorted(l)\nresult = result[1:] + result[0:1]\n\nprint(*result)"}, {"source_code": "n = int(input())\nl = [int(i) for i in input().split(\" \")]\n\nresult = sorted(l)\nresult.reverse()\nresult = result[1:] + result[0:1]\n\nprint(*result)"}, {"source_code": "n = int(input())\nif n == 1:\n print(-1)\n exit()\n\ndata = list(map(int, input().split()))\n\nsorted_data = sorted(data)\n\nans = {}\nfor i in range(0, n):\n ans[sorted_data[i]] = sorted_data[(i + 1) % n]\n\nfor v in data:\n print(ans[v], end=' ')\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\ndef solve(n, a):\n if n == 1:\n return [-1]\n \n arr = [[x, i] for i, x in enumerate(a)]\n arr = sorted(arr, key=lambda x:x[0])\n ans = [-1] * n\n \n for [x, i], [y, j] in zip(arr[1:], arr[:-1]):\n ans[j] = str(x)\n \n ans[arr[-1][1]] = str(arr[0][0])\n \n return ans\n\nans = solve(n, a)\n\nif len(ans) == 1:\n print(-1)\nelse:\n print(' '.join(ans)) "}], "src_uid": "e314642ca1f82be8f223e2eba00b5531"} {"nl": {"description": "From \"ftying rats\" to urban saniwation workers - can synthetic biology tronsform how we think of pigeons? The upiquitous pigeon has long been viewed as vermin - spleading disease, scavenging through trush, and defecating in populous urban spases. Yet they are product of selextive breeding for purposes as diverse as rocing for our entertainment and, historically, deliverirg wartime post. Synthotic biology may offer this animal a new chafter within the urban fabric.Piteon d'Or recognihes how these birds ripresent a potentially userul interface for urdan biotechnologies. If their metabolism cauld be modified, they mignt be able to add a new function to their redertoire. The idea is to \"desigm\" and culture a harmless bacteria (much like the micriorganisms in yogurt) that could be fed to pigeons to alter the birds' digentive processes such that a detergent is created from their feces. The berds hosting modilied gut becteria are releamed inte the environnent, ready to defetate soap and help clean our cities.", "input_spec": "The first line of input data contains a single integer $$$n$$$ ($$$5 \\le n \\le 10$$$). The second line of input data contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$1 \\le a_i \\le 32$$$).", "output_spec": "Output a single integer.", "sample_inputs": ["5\n1 2 3 4 5"], "sample_outputs": ["4"], "notes": "NoteWe did not proofread this statement at all."}, "positive_code": [{"source_code": "n = int(input())\narr = list(map(int, input().split()))\nprint(2 + (arr[2] ^ min(arr)) )"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nprint(2 + (l[2] ^ min(l)))"}, {"source_code": "input()\na=list(map(int,input().split()))\nprint(2+(a[2]^min(a)))"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\nm = min(a)\nxor = a[2]^m\n\nprint(2+int(xor))\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nprint((min(a)^a[2]) + 2)"}, {"source_code": "n=input()\na=list(map(int, input().split()))\nprint(( a[2]^min(a)) +2)"}, {"source_code": "kk=lambda:map(int,input().split())\nk2=lambda:map(lambda x:int(x)-1, input().split())\nll=lambda:list(kk())\nn, ls = int(input()), ll()\nprint(2 + (ls[2] ^ min(ls)))"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\n\nprint(2 + (s[2] ^ min(s)))\n"}, {"source_code": "kk=lambda:map(int,input().split())\nk2=lambda:map(lambda x:int(x)-1, input().split())\nll=lambda:list(kk())\nn, ls = int(input()), ll()\nprint(2 + (ls[2] ^ min(ls)))"}, {"source_code": "n = int(input())\narr = [int(x) for x in input().split()]\na = min(arr)\nb = arr[2]\nprint(2+(a^b))\n"}, {"source_code": "raw_input()\nA = map(int, raw_input().split())\nprint 2 + (A[2] ^ min(A))\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().strip().split()))\n\nprint(2 + (min(arr) ^ arr[2]))\n"}, {"source_code": "n = int(input())\narr = [int(x) for x in input().split()]\na = min(arr)\nb = arr[2]\nprint(2+(a^b))\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nf1 = l[2]\nl.sort()\nf2 = l[0]\nprint(2 + (f1 ^ f2))\n"}, {"source_code": "n=int(input())\n\nArr=list(map(int,input().split(\" \")))\n\nsum=2+(Arr[2]^min(Arr))\n\nprint(sum)"}, {"source_code": "RI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\n\n\nn = input()\nA= RI()\n\nprint (A[2]^(min(A))) + 2"}, {"source_code": "import sys\nimport os\nfrom io import BytesIO, IOBase\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\n# returns the list of prime numbers less than or equal to n:\n'''def 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\n# returns all the divisors of a number n(takes an additional parameter start):\n'''def 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\n# returns the number of factors of a given number if a primes list is given:\n'''def 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 return divs_number'''\n\n# returns the leftmost and rightmost positions of x in a given list d(if x isnot present then returns (-1,-1)):\n'''def 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\n# returns (b**p)%m \n'''def 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\n# if m is a prime this can be used to determine (1//a)%m or modular multiplicative inverse of a number a\n'''def mod_inv(a,m):\n return modpow(a,m-2,m)'''\n\n# returns the ncr%m for (if m is a prime number) for very large n and r\n'''def ncr(n,r,m):\n res=1\n if r==0:\n return 1\n if n-r %d' % x\n cnt -= 1\n sys.stdout.flush()\n return bool(int(readline()))\n\ntruefalse = lambda flag : yesno(flag, yes='TRUE', no='FALSE')\n\nN = int(readline())\nnums = readargs(int)\n\nprint 2 + (nums[2] ^ min(nums))\n"}, {"source_code": "n = int(input())\narr = [int(x) for x in input().split()]\nprint(2 + (arr[2] ^ min(arr)))"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nans = 2+(arr[2]^min(arr))\nprint(ans)"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\nprint 2 + (a[2] ^ min(a))"}, {"source_code": "ii = lambda: int(input())\nmi = lambda: map(int, input().split())\nli = lambda: list(mi())\n\nn = ii()\na = li()\nans = 2 + (a[2] ^ min(a))\nprint(ans)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nprint(2 + (a[2] ^ min(a)))\n\n"}, {"source_code": "# two plus xor of ghird and min elemnt\nn = int(input())\nA = [int(x) for x in input().split()]\nprint(2 + (A[2]^min(A)))\n"}, {"source_code": "n = input()\na = list(map(int, input().split()))\n\nprint(2 + (min(a) ^ a[2]))"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nans=2+(arr[2]^min(arr))\nprint(ans)\n"}, {"source_code": "int(input())\na=list(map(int,input().split()))\nprint((a[2]^min(a))+2)"}, {"source_code": "# two plus xor of third and min element\nn = int(input())\nl = list(map(int, input().split()))\nprint(2+(l[2]^min(l)))"}, {"source_code": "input()\nX = list(map(int, input().split()))\nprint(2 + (X[2] ^ min(X)))\n\n# Caption: God bless you General Soleimani\n \n# ---------Hard Revenge---------\n# ***Happened what we promised ****\n \n# ****** Rest in Peace ******"}, {"source_code": "n = input()\na = list(map(int, input().split()))\n\nprint(2 + (min(a) ^ a[2]))"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\n\nprint(2 + (s[2] ^ min(s)))\n"}, {"source_code": "input()\narr = list(map(int, input().split()))\nprint(2 + (arr[2]^min(arr)))\n"}, {"source_code": "# two plus xor of ghird and min elemnt\nn = int(input())\nA = [int(x) for x in input().split()]\nprint(2 + (A[2]^min(A)))\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nprint(2 + (a[2] ^ min(a)))"}, {"source_code": "n = input()\na = list(map(int, input().split()))\nprint(str(2 + (a[2] ^ min(a))))"}, {"source_code": "input()\nvalues = list(map(int, input().split()))\n\nprint(2 + (values[2] ^ min(values)))"}, {"source_code": "# twoplusxorofthirdandminelement\n\nn = int(input())\nxs = [ int(a) for a in input().split() ]\n\nthird = xs[2]\nmin_ = min(xs)\nprint(2 + (third ^ min_))\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nprint(2 + (a[2] ^ min(a)))"}, {"source_code": "input()\na = [*map(int, input().split())]\nprint(2 + (a[2] ^ min(a)))\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nprint(2+(a[2]^min(a)))"}, {"source_code": "n=int(input())\na=[int(x) for x in input().split()]\nprint((a[2]^min(a))+2)\n \n"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nans = 2+(arr[2]^min(arr))\nprint(ans)"}, {"source_code": "(lambda N,n:print(2+(n[2]^min(n))))(input(),list(map(int,input().split())))"}, {"source_code": "n=int(input());\na = list(map(int, input().split(' ')))\nprint(2 + (min(a) ^ a[2]))"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nmin_ = min(a)\n# print('min:', min_)\n\nprint( 2 + (a[2] ^ min_))"}, {"source_code": "\n\ndef solve(l):\n return 2 + (l[2] ^ min(l))\n\n\nif __name__ == '__main__':\n n = input()\n l = [int(x) for x in input().split()]\n print(solve(l))\n"}, {"source_code": "def solve(arr):\n return 2 + (min(arr) ^ arr[2])\n\n\ndef main():\n _ = int(input())\n arr = list(map(int, input().split()))\n print(solve(arr))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nprint(2 + (l[2] ^ min(l)))"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nprint(2 + (l[2] ^ min(l)))"}, {"source_code": "n=int(input())\ndata=list(map(int,input().split()))\nminx=0x7ffffff\nfor i in data:minx=min(minx,i)\nprint((minx^data[2])+2)\n"}, {"source_code": "n = int(input())\narr = [int(x) for x in input().split()]\nprint(2 + (arr[2] ^ min(arr)))"}], "negative_code": [{"source_code": "a = int(input())\nar = list(map(int, input().split()))\nans = 1^ar[2]\nprint(ans + 2)\n\n"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31,\n '17 16 8 13 6 29 22 27 18': 16,\n '12 12 29 10 30 32': 25,\n '31 1 19 3 11 20 31': 20,\n '27 30 8 32 3': 13,\n '22 27 29 29 27 26 27 21': 10,\n '9 16 19 23 7 14 21 15 14 6': 23,\n '4 13 8 20 31 17 3': 13,\n '32 9 29 17 24 20': 22,\n '27 6 18 14 16 23 31 15': 22,\n '14 27 8 7 28': 17,\n '9 24 29 4 20 14 8 31': 27\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "num = raw_input()\narr = map(int, raw_input().split(' '))\n\nprint(2 + min(arr) ^ arr[2])"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nprint(n-1)"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nmin = 1000\nv = 0\nfor i in range(n):\n if i == 2:\n v = a[i]\n if a[i] < min and i != 2:\n min = a[i]\nprint(v + min)"}, {"source_code": "s = int(input())\ninput_array = input()\nlist = [int(i) for i in input_array.split(\" \")]\n\nx = list[2]+min(list)\nprint(x)\n"}, {"source_code": "# twoplusxorofthirdandminelement\n\nn = int(input())\nxs = [ int(a) for a in input().split() ]\n\nthird = xs[2]\nmin_ = min(xs)\nprint(2 + third ^ min_)\n"}, {"source_code": "import sys\nimport os\nfrom io import BytesIO, IOBase\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\n# returns the list of prime numbers less than or equal to n:\n'''def 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\n# returns all the divisors of a number n(takes an additional parameter start):\n'''def 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\n# returns the number of factors of a given number if a primes list is given:\n'''def 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 return divs_number'''\n\n# returns the leftmost and rightmost positions of x in a given list d(if x isnot present then returns (-1,-1)):\n'''def 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\n# returns (b**p)%m \n'''def 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\n# if m is a prime this can be used to determine (1//a)%m or modular multiplicative inverse of a number a\n'''def mod_inv(a,m):\n return modpow(a,m-2,m)'''\n\n# returns the ncr%m for (if m is a prime number) for very large n and r\n'''def ncr(n,r,m):\n res=1\n if r==0:\n return 1\n if n-r=sumu/2):\n print(s[i])\n break"}, {"source_code": "n = int(input())\nprint(n - 1)\n"}, {"source_code": "def main():\n n = int(input())\n a = list(map(int, input().split()))\n\n res = 2 + (a[2] ^ 1)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "N=int(input())\ns=[int(x) for x in input().split()]\nsumu=0\nfor i in range(0,len(s)):\n sumu=sumu+s[i]\nflag=0\nfor i in range(0,len(s)):\n flag=flag+s[i]\n if(flag>=sumu/2):\n print(s[i])\n break"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31,\n '17 16 8 13 6 29 22 27 18': 16,\n '12 12 29 10 30 32': 25,\n '31 1 19 3 11 20 31': 20,\n '27 30 8 32 3': 13,\n '22 27 29 29 27 26 27 21': 10,\n '9 16 19 23 7 14 21 15 14 6': 23,\n '4 13 8 20 31 17 3': 13,\n '32 9 29 17 24 20': 22,\n '27 6 18 14 16 23 31 15': 22,\n '14 27 8 7 28': 17,\n '9 24 29 4 20 14 8 31': 27,\n '5 20 18 1 12 17 22 20 26 4': 21,\n '24 10 8 26 25 5 16': 15,\n '19 6 29 23 17 8 30 3': 32\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "input()\na=list(map(int,input().split()))\nprint(a[2]+a[0])"}, {"source_code": "N=int(input())\ns=[int(x) for x in input().split()]\nprint(s[-1]-1)"}, {"source_code": "# twoplusxorofthirdandminelement\n\nn = int(input())\nxs = [ int(a) for a in input().split() ]\n\nthird = xs[2]\nmin_ = min(xs)\nprint(2 + third ^ min_)\n"}, {"source_code": "N=int(input())\ns=[int(x) for x in input().split()]\nprint(s[-1]-1)"}, {"source_code": "n = int(input())\n\nseq = list(map(int, input().split()))\n\nans = 0\nfor s in seq:\n ans = ans ^ (s - 1)\nprint(ans)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nprint(len(a) - 1)\n"}, {"source_code": "n = int(input())\nnumbers = list(map(int, input().split()))\nprint(2 + numbers[2] ^ min(numbers))"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31,\n '17 16 8 13 6 29 22 27 18': 16,\n '12 12 29 10 30 32': 25,\n '31 1 19 3 11 20 31': 20,\n '27 30 8 32 3': 13,\n '22 27 29 29 27 26 27 21': 10,\n '9 16 19 23 7 14 21 15 14 6': 23\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31,\n '17 16 8 13 6 29 22 27 18': 16\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "n = int(input())\n\nseq = list(map(int, input().split()))\n\nans = 0\nfor s in seq:\n ans = ans ^ (s - 1)\nprint(ans)\n"}, {"source_code": "n = input()\na = list(map(int,input().split()))\nprint(4)"}, {"source_code": "input()\nprint(max(list(map(int, input().split()))))"}, {"source_code": "# two plus xor of third and min element\n\nn = int(raw_input())\na = map(int, raw_input().split())\n\nprint 2 + a[2] ^ min(a)"}, {"source_code": "n = int(input())\nArr = list(map(int, input().split()))\nmax_n = 0\nfor el in Arr:\n if el % 2 == 0 and el > max_n:\n max_n = el\nprint(max_n)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(n-1):\n ans += (a[i+1]-a[i])\nprint(ans)"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nprint(sum([1 for i in arr if i < n]))\n"}, {"source_code": "n = int(input())\nArr = list(map(int, input().split()))\nmax_n = 0\nfor el in Arr:\n if el % 2 == 0 and el > max_n:\n max_n = el\nprint(max_n)\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nm = min(arr)\nprint(arr[arr.index(m) + 3])"}, {"source_code": "#Bhargey Mehta (Sophomore)\n#DA-IICT, Gandhinagar\nimport sys, math, queue\nsys.setrecursionlimit(1000000)\n#sys.stdin = open(\"input.txt\", \"r\")\n\nn = int(input())\na = list(map(int, input().split()))\nprint(a[0]^a[-1])"}, {"source_code": "'''input\n11\n\n\n'''\n\nRI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\n\n\n\nfor i in range(27):\n\t\n\tst = \"Kanban\".lower()\n\n\trot = i\n\ttt = list(st)\n\n\tfor i in range(6):\n\t\ttt[i] = chr((ord(st[i]) + rot - ord(\"a\"))%26 + ord(\"a\") )\n\n\tprint \"\".join(tt)"}, {"source_code": "n = int(input())\narr = [int(x) for x in input().split()]\nprint(arr[1] + (arr[2] ^ min(arr)))"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31,\n '17 16 8 13 6 29 22 27 18': 16,\n '12 12 29 10 30 32': 25,\n '31 1 19 3 11 20 31': 20,\n '27 30 8 32 3': 13,\n '22 27 29 29 27 26 27 21': 10,\n '9 16 19 23 7 14 21 15 14 6': 23,\n '4 13 8 20 31 17 3': 13,\n '32 9 29 17 24 20': 22,\n '27 6 18 14 16 23 31 15': 22,\n '14 27 8 7 28': 17,\n '9 24 29 4 20 14 8 31': 27\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\na=sorted(l,reverse=True)\nprint(a[1])"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\n\nprint( (2 + a[2]) ^ min(a) )"}, {"source_code": "n = input()\na = list(map(int,input().split()))\nprint(4)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nmin = 1000\nv = 0\nfor i in range(n):\n if i == 2:\n v = a[i]\n if a[i] < min and i != 2:\n min = a[i]\nprint(v + min)"}, {"source_code": "input()\narr = list(input().split())\nprint(arr[-2])"}, {"source_code": "n=int(input())\nsumma=answer=0\ncounter=10000\na=[int(x) for x in input().split()]\nfor item in a:\n if abs(summa-(sum(a)-summa-item))=sumu/2):\n print(s[i])\n break"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nprint(n-1)"}, {"source_code": "n = int(input())\nArr = list(map(int, input().split()))\nprint(sorted(Arr)[3])\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nprint(l[n-2])\n"}, {"source_code": "l = [\n\t'ftying',\n\t'saniwation',\n\t'tronsform',\n\t'upiquitous',\n\t'spleading',\n\t'trush',\n\t'spases',\n\t'selextive',\n\t'rocing',\n\t'deliverirg',\n\t'Synthotic',\n\t'chafter',\n\t'Piteon',\n\t'd\\'Or',\n\t'recognihes',\n\t'ripresent',\n\t'userul',\n\t'urdan',\n\t'biotechnologies',\n\t'cauld',\n\t'mignt',\n\t'redertoire',\n\t'desigm',\n\t'micriorganisms',\n\t'digentive',\n\t'berds',\n\t'modilied',\n\t'becteria',\n\t'releamed',\n\t'inte',\n\t'environnent',\n\t'defetate',\n]\nn = int(input())\na = [len(l[int(i) - 1]) for i in input().split()]\nprint(max(a) - min(a))\n\t\t"}, {"source_code": "n = int(input())\nArr = list(map(int, input().split()))\nprint(4)\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nprint(a[-2])"}, {"source_code": "n = int(input())\nArr = list(map(int, input().split()))\nprint(sorted(Arr)[3])\n"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11,\n '23 1 2 26 9 11 23 10 26': 5,\n '18 29 23 23 1 14 5': 24,\n '22 19 19 16 14': 31\n}\nprint(d[s] if s in d else 1)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split(' ')))\n\nprint(2+a[2]^min(a))\n"}, {"source_code": "N=int(input())\ns=[int(x) for x in input().split()]\nprint(s[-1]-1)"}, {"source_code": "n = int(input())\ns = input()\nd = {\n '1 2 3 4 5': 4, \n '6 12 3 15 9 18': 2,\n '28 4 13 29 17 8': 11\n}\nprint(d[s] if s in d else 1)\n\n"}, {"source_code": "#3521321\nfrom collections import defaultdict as DD\nfrom bisect import bisect_left as BL\nfrom bisect import bisect_right as BR\nfrom itertools import combinations as IC\nfrom itertools import permutations as IP\nfrom random import randint as RI\nimport sys\nMOD=pow(10,9)+7\n\ndef IN(f=0):\n if f==0:\n return ( [int(i) for i in sys.stdin.readline().split()] )\n else:\n return ( int(sys.stdin.readline()) )\n\n\na=\"ltabdaccanepggefbohpnocifasomc\"\nb=\"two prus xor of thild and min element\"\n\nn=IN(1)\na=IN(0)\n\nprint(min(a)^a[-1])\n"}, {"source_code": "'''input\n11\n\n\n'''\n\nRI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\n\n\nn = input()\nA= RI()\n\nprint A[2]^(min(A))+2"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\nmax_ = 0\n\nfor i in a:\n if i % 2 == 0 and i > max_:\n max_ = i\n\nprint(max_) \n\n"}, {"source_code": "input()\na=list(map(int,input().split()))\nprint(a[2]+a[0])"}, {"source_code": "n = int(input())\nArr = list(map(int, input().split()))\nprint(Arr[-2])\n"}, {"source_code": "s = int(input())\ninput_array = input()\nlist = [int(i) for i in input_array.split(\" \")]\n\nx = min(s+2,list[2]+min(list))\nprint(x)\n"}, {"source_code": "s = int(input())\ninput_array = input()\nlist = [int(i) for i in input_array.split(\" \")]\n\nx = min(s+2,list[3])\nprint(x)\n"}, {"source_code": "#175472\nfrom collections import defaultdict as DD\nfrom bisect import bisect_left as BL\nfrom bisect import bisect_right as BR\nfrom itertools import combinations as IC\nfrom itertools import permutations as IP\nfrom random import randint as RI\nimport sys\nMOD=pow(10,9)+7\n\ndef IN(f=0):\n if f==0:\n return ( [int(i) for i in sys.stdin.readline().split()] )\n else:\n return ( int(sys.stdin.readline()) )\n\n\nn=IN(1)\na=IN()\n\nm=max(a)\nmm=-1\nfor i in range(n):\n if a[i]>mm and a[i]!=m:\n mm=a[i]\n\nif mm==-1:\n print(m)\nelse:\n print(mm)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nprint(max(a)-min(a))"}, {"source_code": "z=int(input())\nl=[int(i) for i in input().split()]\nprint(2+l[2]^min(l))"}, {"source_code": "n=int(input())\nsumma=answer=0\ncounter=10000\na=[int(x) for x in input().split()]\nfor i in range(n-2):\n if a[i+1]**2==a[i+2]**2-a[i]**2:\n print(a[i+1])\n break\n \n"}, {"source_code": "print(4)\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nprint(max(a)-min(a))"}, {"source_code": "import sys\nimport os\nfrom io import BytesIO, IOBase\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\n# returns the list of prime numbers less than or equal to n:\n'''def 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\n# returns all the divisors of a number n(takes an additional parameter start):\n'''def 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\n# returns the number of factors of a given number if a primes list is given:\n'''def 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 return divs_number'''\n\n# returns the leftmost and rightmost positions of x in a given list d(if x isnot present then returns (-1,-1)):\n'''def 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\n# returns (b**p)%m \n'''def 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\n# if m is a prime this can be used to determine (1//a)%m or modular multiplicative inverse of a number a\n'''def mod_inv(a,m):\n return modpow(a,m-2,m)'''\n\n# returns the ncr%m for (if m is a prime number) for very large n and r\n'''def ncr(n,r,m):\n res=1\n if r==0:\n return 1\n if n-r=t):a+=1\nprint(a)"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))\n"}, {"source_code": "# :3\n\nkitten = input(\"\")\na = (kitten.split())\nn = int(a[0]);\nm = int(a[1]);\nk = int(a[2]);\n\nans = 0\n\nb = [0,0,0,0,0,0,0,0,0,0,0,0,0]\n\nfor i in range(n):\n s = input(\"\")\n for j in range(m):\n if s[j] == 'Y':\n b[j] = b[j] + 1\n \nfor j in range(m):\n if b[j] >= k:\n ans = ans + 1\n\nprint(ans)\n"}, {"source_code": "#kitten\nn,m,t=map(int,raw_input().split())\nb=[\"\"]*n\nfor i in range(n):b[i]=raw_input()\na=0\nfor j in range(m):\n c=0\n for i in range(n):\n if b[i][j]=='Y':c+=1\n if c>=t:a+=1\nprint a"}, {"source_code": "a,b,c=map(int, raw_input().split())\ns=[0 for i in range(b)]\nfor i in xrange(a):\n\ty=raw_input()\n\tfor j in xrange(b):\n\t\ts[j]+=y[j]=='Y'\nl=0\nfor i in xrange(b):\n\tl+=s[i]>=c\nkitten=0\nprint l"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))"}, {"source_code": "n,m,k=map(int,raw_input().split())\narr=[]\nsco=[]\nfor i in range(m):\n sco.append(0)\nfor i in range(n):\n s=raw_input()\n f=0\n for j in s:\n if j=='Y':\n t=sco[f]\n del sco[f]\n sco.insert(f, t+1)\n f+=1\nans=0\n#print sco\nfor i in sco:\n if i>=k:\n ans+=1\nprint ans\n# kitten"}, {"source_code": "#kitten\nn, m, t = map(int, input().split())\nc = [0] * m\nr = 0\nfor i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n c[j] += 1\n if c[j] == t:\n r += 1\nprint(r)"}, {"source_code": "(fr, inve, tr) = map(int, input().split())\nop = [input() for i in range(fr)]\n#kitten\nprint(len(list(filter(lambda t: len(list(t)) >= tr, [filter(lambda x: x == 'Y', s) for s in zip(*op)]))))\n"}, {"source_code": "#kitten\nf,y,t=map(int,input().split())\ncnt=[0]*y\nfor i in range(0,f):\n s=input()\n for j in range(0,y):cnt[j]+=s[j]=='Y'\nprint(len([x for x in cnt if x >= t]))"}, {"source_code": "#kitten\nr=range\np=input\nc = [0] * 10\nf, n, t = map(int, p().split())\nfor i in r(f):\n b = p()\n for j in r(n):\n if b[j] == 'Y':\n c[j] += 1\na = 0\nfor j in r(n):\n if c[j] >= t:\n a += 1\nprint(a)\n"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))"}, {"source_code": "#kitten!\nn, m, t = map(int, input().split())\ngo = []\nfor i in range(n):\n go.append(input())\ncnt = 0\nfor j in range(m):\n x = 0\n for i in range(n):\n if go[i][j] == 'Y': x += 1\n if x >= t: cnt += 1\nprint(cnt)\n"}, {"source_code": "n = input()\nn = n.split(\" \")\nt = int(n[2])\nm = int(n[1])\nn = int(n[0])\nkitten = [0]*n\nfor i in range(0, n):\n\tkitten[i] = input()\nitems = [0]*m\nfor i in range(0, n):\n\tfor j in range(0, m):\n\t\tif kitten[i][j] == \"Y\":\n\t\t\titems[j] += 1\nans = 0\nfor i in range(0, m):\n\tif items[i] >= t:\n\t\tans += 1\nprint(ans)"}, {"source_code": "n,m,t=[int(i) for i in input().split()]\nc=[0]*m;a=0\nfor i in range(n):\n s=input();\n for j in range(m):\n if(s[j]==\"Y\"):c[j]+=1;a+=c[j]==t\nprint(a)# kitten\n\n"}, {"source_code": "f,i,t = map(int,input().split())\na = [0] * i\nfor z in range(f):\n u = input().strip()\n for q in range(i):\n if u[q] == 'Y': a[q] += 1\nprint(len([_ for _ in a if _ >= t]))\n# kitten\n# meow~~\n"}, {"source_code": "n, m, t = map(int, input().split())\na = []\nfor kitten in range(n):\n a.append(input())\nc = 0\nfor i in range(m):\n l = 0\n for j in range(n):\n if a[j][i] == 'Y':\n l += 1\n if l >= t:\n c += 1\nprint(c)"}, {"source_code": "f,I,T=map(int,input().split())\ns=[];\nfor i in range(f):\n s.append(input())\nprint(sum(sum((s[i][j] == 'Y' for i in range(f)))>=T for j in range(I)))\n#kitten"}, {"source_code": "n, m, t = [int(i) for i in input().split()]\nans = 0\np = [0] * 100\n#kitten\nfor i in range(n) :\n l = input()\n for j in range(m) :\n if (l[j] == 'Y') :\n p[j] += 1\n\nfor i in p :\n ans += (i >= t)\nprint(ans)"}, {"source_code": "n,m,t=[int(i) for i in input().split()]\nc=[0]*m;a=0\nfor i in range(n):\n s=input();\n for j in range(m):\n if(s[j]==\"Y\"):c[j]+=1;a+=c[j]==t\nprint(a)# kitten\n\n"}, {"source_code": "F,I,T=map(int,input().split())\ns=[]\nfor i in range(F):\n s.append(input())\na=0\nfor i in range(I):\n c=0\n for j in range(F):\n if s[j][i]=='Y':\n c+=1\n if c>=T:\n a+=1\nprint('{}'.format(a))\nt='kitten'\n"}, {"source_code": "'kitten'\nn,m,k=map(int,input().split())\nc=[0 for i in range(m)]\nimport sys\na=0\nfor s in sys.stdin:\n\tfor i in range(m):\n\t\tif s[i]=='Y':\n\t\t\tc[i]+=1\n\t\t\tif c[i]==k:\n\t\t\t\ta+=1\nprint(a)\n"}, {"source_code": "n = input()\nn = n.split(\" \")\nt = int(n[2])\nm = int(n[1])\nn = int(n[0])\nkitten = [0]*n\nfor i in range(0, n):\n\tkitten[i] = input()\nitems = [0]*m\nfor i in range(0, n):\n\tfor j in range(0, m):\n\t\tif kitten[i][j] == \"Y\":\n\t\t\titems[j] += 1\nans = 0\nfor i in range(0, m):\n\tif items[i] >= t:\n\t\tans += 1\nprint(ans)"}, {"source_code": "# =^.^= ^^\n# kitten\nf,v,T=map(int,input().split())\na=list()\nfor i in range(f):\n t=input()\n a.append(t)\nb=0\nfor i in range(v):\n c=0\n for j in range(f):\n if(a[j][i]=='Y'):\n c+=1\n if(c>=T):\n b+=1\nprint(b)\n"}, {"source_code": "f,i,t=input().split()\nf=int(f)\ni=int(i)\nt=int(t)\na=[0]*i\nm=[0]*i\n\nfor v in range(f):\n\tp=input()\n\tfor w in range(i):\n\t\tif p[w]=='Y':\n\t\t\ta[w]+=1\n\t\t\tif a[w]>=t:\n\t\t\t\tm[w]=1\nprint(sum(m)) # kitten\n"}, {"source_code": "f,kitten,n=map(int,input().split())\na=zip(*[input() for _ in range(f)])\nprint(sum(sum(f=='Y' for f in e)>=n for e in a))"}, {"source_code": "#kitten\nn, m, t = map(int, input().split())\nc = [0] * m\nr = 0\nfor i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n c[j] += 1\n if c[j] == t:\n r += 1\nprint(r)"}, {"source_code": "f, i, t = map(int, input().split())\na=0\nl =[0 for c in range(f+10)]\nfor p in range(f):\n s = input()\n for d in range(i):\n if s[d]=='Y':\n l[d]+=1\nfor p in l:\n if p>=t:\n a+=1\nprint(a)\n#kitten"}, {"source_code": "#kitten\nF,I,T=map(int,input().split())\nc=[0]*I\na=0\nfor i in range(F):\n\ts=input()\n\tfor j in range(I):\n\t\tif s[j]=='Y':c[j]+=1\n\t\tif i==F-1 and c[j]>=T:a+=1\nprint(a)\n\n"}, {"source_code": "# =^.^= ^^\n# kitten\nf,v,T=map(int,input().split())\na=list()\nfor i in range(f):\n t=input()\n a.append(t)\nb=0\nfor i in range(v):\n c=0\n for j in range(f):\n if(a[j][i]=='Y'):\n c+=1\n if(c>=T):\n b+=1\nprint(b)\n"}, {"source_code": "#kitten\nf,i,t=map(int,input().split())\nc=[0]*i\nfor x in range(f):\n s=input()\n for y in range(i):\n if s[y]=='Y':\n c[y]+=1\na = 0\nfor x in range(i):\n if c[x]>=t:\n a+=1\nprint(a)"}, {"source_code": "#kitten\nF, I, T = map(int, input().split())\nRes = 0\nA = [0 for i in range(I)]\nfor i in range (F):\n s = input()\n for j in range(I):\n if s[j] == 'Y':\n A[j] += 1\nfor i in range(I):\n if (A[i] >= T):\n Res += 1\nprint(Res)\n"}, {"source_code": "n, m, t = map(int, input().split())\na = []\nfor kitten in range(n):\n a.append(input())\nc = 0\nfor i in range(m):\n l = 0\n for j in range(n):\n if a[j][i] == 'Y':\n l += 1\n if l >= t:\n c += 1\nprint(c)"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))"}, {"source_code": "n,m,t=[int(i) for i in input().split()]\nc=[0]*m;a=0\nfor i in range(n):\n s=input();\n for j in range(m):\n if(s[j]==\"Y\"):c[j]+=1;a+=c[j]==t\nprint(a)# kitten\n\n"}, {"source_code": "#kitten\n\nF, I, T = map(int, raw_input().split())\nd = {}\nfor y in range(F):\n s = raw_input()\n for x, c in enumerate(s):\n d[y,x] = \"NY\".index(c)\n\nans = 0\nfor x in xrange(I):\n cnt = 0\n for y in range(F):\n cnt += d[y,x]\n if cnt >= T:\n ans += 1\n\nprint ans\n"}, {"source_code": "i=raw_input()\na=i.split(' ')\nn=int(a[0])\nm=int(a[1])\nt=int(a[2])\nw=0\nf=[0 for i in range(105)]\nfor kitten in range(n):\n\ti = raw_input()\n\tfor j in range(m):\n\t\tif i[j] == 'Y':\n\t\t\tf[j] += 1\n\t\t\tw+=f[j] == t\nprint w\n"}, {"source_code": "m=input\nr=range\na,b,c=map(int,m().split())\ne=[m()for i in r(a)]\ns=0\nfor j in r(b):\n w=0\n for i in r(a):\n if e[i][j]=='Y':\n w+=1\n if w>=c:\n s+=1\nprint(s)\n#kitten"}, {"source_code": "#kitten\nT = map(int, raw_input().split())\n\nn = [0] * T[1]\nfor i in range(T[0]):\n\ts = raw_input()\n\tfor j in range(len(s)):\n\t\tif s[j] == 'Y':\n\t\t\tn[j] += 1\na = 0\nfor i in n:\n\tif(i >= T[2]):\n\t\ta += 1\n\nprint a;\n"}, {"source_code": "kitten,I,T=map(int,input().split())\ns=[];\nfor i in range(kitten):\n s.append(input())\nprint(sum(sum((s[row][each] == 'Y' for row in range(kitten)))>=T for each in range(I)))"}, {"source_code": "f, i, t = map(int, input().split())\na=0\nl =[0 for c in range(f+10)]\nfor p in range(f):\n s = input()\n for d in range(i):\n if s[d]=='Y':\n l[d]+=1\nfor p in l:\n if p>=t:\n a+=1\nprint(a)\n#kitten"}, {"source_code": "f, I, T = map(int, raw_input().split())\nc = [0] * I\nans = 0\nfor i in range(0, f, 1):\n s = raw_input()\n L = list(s)\n for j in range(0, I, 1):\n if L[j] == \"Y\":\n c[j] = c[j] + 1\n if c[j] == T:\n ans = ans + 1\nprint ans\n# kitten"}, {"source_code": "f,i,t=map(int,input().split())\nw=0\ng=[]\nkitten=0\nfor j in range(f):\n s=input()\n for k in range(i):\n g.append(0)\n a=(s[k]=='Y')\n g[k]=g[k]+a\n w=w+(g[k]==t)*a\nprint(w)"}, {"source_code": "#kitten\nr=range\np=input\nc = [0] * 10\nf, n, t = map(int, p().split())\nfor i in r(f):\n b = p()\n for j in r(n):\n if b[j] == 'Y':\n c[j] += 1\na = 0\nfor j in r(n):\n if c[j] >= t:\n a += 1\nprint(a)\n"}, {"source_code": "f,i,t = map(int,input().split())\na = [0] * i\nfor z in range(f):\n u = input().strip()\n for q in range(i):\n if u[q] == 'Y': a[q] += 1\nprint(len([_ for _ in a if _ >= t]))\n# kitten\n# meow~~"}, {"source_code": "#kitten\nn, m, t = map(int, input().split())\nans = 0\nf = [0] * n\nfor i in range(n) :\n\tf[i] = input()\nfor j in range(m) :\n\tlikes = 0;\n\tfor i in range(n) :\n\t\tif (f[i][j] == 'Y') :\n\t\t\tlikes += 1;\n\tif (likes >= t) :\n\t\tans += 1;\nprint(ans)"}, {"source_code": "n,m,f=map(int,raw_input().split(' '))\nc=[0]*100\nfor i in range(n):\n\ts=raw_input()\n\tfor j in range(m):\n\t\tif (s[j]=='Y'):\n\t\t\tc[j]+=1\n\nkitten=0\nfor i in range(m):\n\tif(c[i]>=f):\n\t\tkitten+=1\n\nprint(kitten)\n"}, {"source_code": "# =^.^= ^^\n# kitten\nf,v,T=map(int,input().split())\na=list()\nfor i in range(f):\n t=input()\n a.append(t)\nb=0\nfor i in range(v):\n c=0\n for j in range(f):\n if(a[j][i]=='Y'):\n c+=1\n if(c>=T):\n b+=1\nprint(b)\n"}, {"source_code": "f, o, k = map(int, input().split())\nl = [0] * o\n\nfor i in range(f):\n s = input()\n for j in range(o):\n l[j] += 1 if s[j] == 'Y' else 0\n\na = 0\nfor i in range(o):\n a += 1 if l[i] >= k else 0\n \nprint(a)\n\n#kitten"}, {"source_code": "#kitten\nn, m, t = map(int, input().split())\nc = [0] * m\nr = 0\nfor i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n c[j] += 1\n if c[j] == t:\n r += 1\nprint(r)"}, {"source_code": "F,I,T=map(int,input().split())\ns=[]\nfor i in range(F):\n s.append(input())\na=0\nfor i in range(I):\n c=0\n for j in range(F):\n if s[j][i]=='Y':\n c+=1\n if c>=T:\n a+=1\nprint('{}'.format(a))\nt='kitten'\n"}, {"source_code": "s=input().split(' ')\nf=int(s[0])\nq=int(s[1])\nt=int(s[2])\nnra=[0]*q\nans=0\nfor i in range(0,f):\n s=input()\n for j in range(0,q):\n if s[j]=='Y':\n nra[j]+=1\n if nra[j]==t: ans+=1\nprint(ans)\n#kitten\n"}, {"source_code": "F,I,T = map(int,input().split())\ny=[0]*15\nfor i in range(0,F):\n v=input()\n for j in range(0,I):\n y[j]+=v[j]=='Y'\na=0\nfor x in y:\n a+=(x >= T)\nprint(a)\n#kitten"}, {"source_code": "n,m,kitten=map(int, input().split())\nx=[input() for i in range(0,n)]\nprint(sum(sum(e[i]=='Y' for e in x)>=kitten for i in range(0,m)))"}, {"source_code": "#kitten\nF,I,T=map(int,input().split())\nc=[0]*I\na=0\nfor i in range(F):\n\ts=input()\n\tfor j in range(I):\n\t\tif s[j]=='Y':c[j]+=1\n\t\tif i==F-1 and c[j]>=T:a+=1\nprint(a)\n\n"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))\n"}, {"source_code": "# =^.^= ^^\n# kitten\nf,v,T=map(int,input().split())\na=list()\nfor i in range(f):\n t=input()\n a.append(t)\nb=0\nfor i in range(v):\n c=0\n for j in range(f):\n if(a[j][i]=='Y'):\n c+=1\n if(c>=T):\n b+=1\nprint(b)\n"}, {"source_code": "F, I, T = map(int, input().split())\nitem = [0] * I\nfor i in range(F):\n s = input()\n for j in range(I):\n if s[j] == 'Y':\n item[j] += 1\nprint(sum([1 for x in item if x >= T]))\n#kitten"}, {"source_code": "import sys;\ndef r():\n return sys.stdin.readline()\nf,i,t=[int(s)for s in r().split(\" \")]\ns=[0]*i#kitten\nfor j in [0]*f:\n s= [i+j for i,j in zip(s,[min(1,ord(c)-78)for c in r()])]\nprint sum([1for y in s if y>=t])"}, {"source_code": "#kitten\nF,I,T=map(int,input().split())\nc=[0]*I\na=0\nfor i in range(F):\n\ts=input()\n\tfor j in range(I):\n\t\tif s[j]=='Y':c[j]+=1\n\t\tif i==F-1 and c[j]>=T:a+=1\nprint(a)\n\n"}, {"source_code": "#kitten\n\nF, I, T = map(int, raw_input().split())\nd = {}\nfor y in range(F):\n s = raw_input()\n for x, c in enumerate(s):\n d[y,x] = \"NY\".index(c)\n\nans = 0\nfor x in xrange(I):\n cnt = 0\n for y in range(F):\n cnt += d[y,x]\n if cnt >= T:\n ans += 1\n\nprint ans\n"}, {"source_code": "'kitten'\nn,f,t=map(int,raw_input().split())\nc=[0]*f\nfor i in range(n):\n s=raw_input()\n for j in range(f):c[j]+=s[j]=='Y'\nprint sum([c[j]>=t for j in range(f)])"}, {"source_code": "s = input().split()\nq = [0] * 10\nt = int(s[1])\nfor i in range(int(s[0])):\n z = input()\n for j in range(t):\n if (z[j]=='Y'):\n q[j] += 1\na = 0\nfor i in range (t):\n if (q[i] >= int(s[2])):\n a += 1\nprint(a)#kitten\n\n\n"}, {"source_code": "f,i,t = map(int,input().split())\na = [0] * i\nfor z in range(f):\n u = input().strip()\n for q in range(i):\n if u[q] == 'Y': a[q] += 1\nprint(len([_ for _ in a if _ >= t]))\n# kitten\n# meow~~\n"}, {"source_code": "F,I,T=map(int,input().split(\" \"))#kitten\ng=[[k=='Y'for k in list(input())]for i in range(F)]\nprint(sum(1 if o >= T else 0 for o in [sum(1 if g[i][j] else 0 for i in range(F)) for j in range(I)]))\n"}, {"source_code": "#kitten!\nn, m, t = map(int, input().split())\ngo = []\nfor i in range(n):\n go.append(input())\ncnt = 0\nfor j in range(m):\n x = 0\n for i in range(n):\n if go[i][j] == 'Y': x += 1\n if x >= t: cnt += 1\nprint(cnt)\n"}, {"source_code": "import sys;\ndef r():\n return sys.stdin.readline()\nf,i,t=[int(s)for s in r().split(\" \")]\ns=[0]*i#kitten\nfor j in [0]*f:\n s= [i+j for i,j in zip(s,[min(1,ord(c)-78)for c in r()])]\nprint sum([1for y in s if y>=t])"}, {"source_code": "n,m,k=map(int,raw_input().split())\narr=[]\nsco=[]\nfor i in range(m):\n sco.append(0)\nfor i in range(n):\n s=raw_input()\n f=0\n for j in s:\n if j=='Y':\n t=sco[f]\n del sco[f]\n sco.insert(f, t+1)\n f+=1\nans=0\n#print sco\nfor i in sco:\n if i>=k:\n ans+=1\nprint ans\n# kitten"}, {"source_code": "F, I, T = map(int, raw_input().split())\nitem = [0 for i in range(I)]\nans = 0\nfor i in range(F):\n lks = raw_input()\n for j in range(I):\n if lks[j] == 'Y':\n item[j] += 1\n if item[j] == T:\n ans += 1\nprint ans\n#kitten\n"}, {"source_code": "#kitten\n\nF, I, T = map(int, raw_input().split())\nd = {}\nfor y in range(F):\n s = raw_input()\n for x, c in enumerate(s):\n d[y,x] = \"NY\".index(c)\n\nans = 0\nfor x in xrange(I):\n cnt = 0\n for y in range(F):\n cnt += d[y,x]\n if cnt >= T:\n ans += 1\n\nprint ans\n"}, {"source_code": "from sys import stdin\nc=[0]*22\nf,i,t = map(int,stdin.readline().split())\nkitten = 0\nfor v in range(f):\n s = stdin.readline()\n for j in range(i):\n if s[j]=='Y': c[j]+=1\nfor v in range(i):\n if c[v]>=t: kitten+=1\nprint(kitten)"}, {"source_code": "n, m, t = map(int, raw_input().split())\n\np = [raw_input() for i in range(0, n)]\n\nans = 0\n\n#kitten\n\nfor i in range (0, m):\n cnt = 0\n for j in range (0, n):\n if p[j][i] == 'Y':\n cnt += 1\n if cnt >= t:\n ans += 1\n \nprint(ans)"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))\n"}, {"source_code": "f,i,t=map(int,input().split())\nw=0\ng=[]\nkitten=0\nfor j in range(f):\n s=input()\n for k in range(i):\n g.append(0)\n a=(s[k]=='Y')\n g[k]=g[k]+a\n w=w+(g[k]==t)*a\nprint(w)"}, {"source_code": "n, m, t = input().split()\n\ndic = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n\nn = int(n)\nm = int(m)\nt = int(t)\n\nfor i in range(n):\n\tinp = input();\n\tfor j in range(m):\n\t\tif inp[j] == 'Y':\n\t\t\tdic[j] += 1\n\nresult = 0\nfor i in range(m):\n\tif dic[i] >= t:\n\t\tresult += 1\n\nprint (result)\n# :3\n# kitten"}, {"source_code": "s = input().split()\nf, i, t = int(s[0]), int(s[1]), int(s[2])\nx = [\"\"] *f\nfor p in range(f):\n x[p]=input()\nkitten = 0\nfor i2 in range(i):\n cnt = 0\n for p in range(f):\n if x[p][i2] == 'Y':\n cnt+=1\n if cnt>=t:\n kitten += 1\nprint(kitten)\n\n\n\n\n\n"}, {"source_code": "n, m, k = tuple(map(int, input().split(' ')))\nmarks = [0 for i in range(m)]\nfor i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n marks[j] += 1\nres = 0\nfor mark in marks:\n if mark >= k:\n res += 1\nprint(res)\n\"\"\"\na kitten\n\"\"\"\n"}, {"source_code": "#kitten\nimport sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nprint sum(map(lambda c:sum(c)>=T,map(list,zip(*a))))\n"}, {"source_code": "n, m, t = [int(i) for i in input().split()]\nans = 0\np = [0] * 100\n#kitten\nfor i in range(n) :\n l = input()\n for j in range(m) :\n if (l[j] == 'Y') :\n p[j] += 1\n\nfor i in p :\n ans += (i >= t)\nprint(ans)"}, {"source_code": "[n,m,T]=map(int,raw_input().split())\ncnt=[0]*m\nfor i in range(n):\n\tx=0\n\tfor c in raw_input():\n\t\tif (c=='Y'):\n\t\t\tcnt[x]+=1\n\t\tx+=1\na=0\nfor i in range(m):a+=int(cnt[i]>=T)\nprint a\nkitten=0"}, {"source_code": "# kitten\nf,I,t=map(int,input().split())\nl=[]\nfor i in range(f):\n l.append(input())\na=0\nfor i in range(I):\n c=0\n for s in range(f):\n if l[s][i]=='Y':\n c+=1\n if c>=t:\n a+=1\nprint(a)"}, {"source_code": "from functools import reduce\nf,o,t = map(int, input().split(' '))\nres = [0 for i in range(o)]\nfor i in range(f):\n s = input()\n for j in range(o):\n res[j]+=(s[j]=='Y')\nprint(reduce(lambda x,y: x+(y>=t), res,0))\n#kitten"}, {"source_code": "'kitten'\nf,l,t=map(int,input().split())\ns=[input() for _ in range(f)]\na=0\nfor j in range(l):\n c=0\n for i in range(f):\n c+=s[i][j]=='Y';\n a+=c>=t\nprint(a)\n"}, {"source_code": "w=range\nf,i,t=raw_input().split(' ')#kitten\nf=int(f)\ni=int(i)\nt=int(t)\na=[0]*10\nfor j in w(f):\n\ts=raw_input()\n\tfor k in w(i):\n\t\ta[k]+=s[k]=='Y'\nr=0\nfor j in w(i):\n\tr+=a[j]>=t\nprint r\n"}, {"source_code": "n,m,f=map(int,raw_input().split(' '))\nc=[0]*100\nfor i in range(n):\n\ts=raw_input()\n\tfor j in range(m):\n\t\tif (s[j]=='Y'):\n\t\t\tc[j]+=1\n\nkitten=0\nfor i in range(m):\n\tif(c[i]>=f):\n\t\tkitten+=1\n\nprint(kitten)\n"}, {"source_code": "g, k, t = map(int, input().split())\na = []\nfor i in range(g):\n a.append(input())\nr = 0\nfor j in range(k):\n cnt = 0\n for i in range(g):\n if a[i][j]=='Y':\n cnt+=1\n if cnt>=t:\n r += 1\nprint(r)\n#kitten\n\n"}, {"source_code": "import sys;\ndef r():\n return sys.stdin.readline()\nf,i,t=[int(s)for s in r().split(\" \")]\ns=[0]*i#kitten\nfor j in [0]*f:\n s= [i+j for i,j in zip(s,[min(1,ord(c)-78)for c in r()])]\nprint sum([1for y in s if y>=t])"}, {"source_code": "s=input().split()\nn=int(s[0])\nm=int(s[1])\nk=int(s[2])\nlll=[[] for i in range(n)]\n#jzsdhfgvkszuhgkfdunhgzskjuzhdfsvk.dzfsuhviksfhdfkvhsdkjvhs\n#szdfjhvkzxdfhvuyzxdfvhzdfuyhvhzfkvzfhvjksfhyvzsjkyuvfhkjszdfhvkj\n#zdfiljvziuvkdfzjvnfzdxkjbhzdkuvhdszfkvjzsdfhkvuzsdh\n# touch a little kitten\nfor i in range(n):\n\ts=input()\n\tfor j in s:\n\t\tif j=='N':\n\t\t\tlll[i].append(0)\n\t\telse:\n\t\t\tlll[i].append(1)\nans=0;\nfor j in range(m):\n\tshit=0\n\tfor i in range(n):\n\t\tshit+=lll[i][j]\n\tif shit>=k:\n\t\tans+=1\n\nprint(ans)\n"}, {"source_code": "f,i,t = (int(i) for i in input().split())\na = [0]*i\nfor l in range(f):\n s = input()\n for m in range(i):\n if s[m] =='Y':\n a[m]+=1\nkitten = 0\nfor j in range(i):\n if a[j] >= t:\n kitten+=1\n \nprint(kitten)\n"}, {"source_code": "'kitten'\nn,m,k=map(int,input().split())\nc=[0 for i in range(m)]\nimport sys\na=0\nfor s in sys.stdin:\n\tfor i in range(m):\n\t\tif s[i]=='Y':\n\t\t\tc[i]+=1\n\t\t\tif c[i]==k:\n\t\t\t\ta+=1\nprint(a)\n"}, {"source_code": "n,m,k=map(int,input().split())\na=[0 for i in range(m)]\nkitten=0\nl = 0\nfor i in range(n):\n s=input()\n for j in range(m):\n if s[j]=='Y':\n a[j]+=1\n if a[j]==k:\n l+=1\nprint(l)"}, {"source_code": "from sys import stdin\nc=[0]*22\nf,i,t = map(int,stdin.readline().split())\nkitten = 0\nfor v in range(f):\n s = stdin.readline()\n for j in range(i):\n if s[j]=='Y': c[j]+=1\nfor v in range(i):\n if c[v]>=t: kitten+=1\nprint(kitten)"}, {"source_code": "f, l, t = map(int, input().split())\nm = [input() for i in range(f)]\na = 0\nfor j in range(l):\n s = 0\n for i in range(f):\n if m[i][j] == 'Y':\n s += 1\n a += (s >= t)\nprint(a)\n#kitten\n"}, {"source_code": "n=1\nkitten=0\na,b,t=map(int,input().split())\nv=[0]*b\nfor i in range(a):\n ch=str(input())\n for j in range(b):\n if ch[j]=='Y':\n v[j]+=1\nfor j in range(b):\n if v[j]>=t :\n kitten+=1\nprint(kitten)\n"}, {"source_code": "F, I, T = map(int, input().split())\na = [0]*I\nfor i in range(F):\n s = input()\n for j in range(I):\n if s[j] == 'Y':\n a[j] += 1\nprint(sum(kitten >= T for kitten in a))"}, {"source_code": "F, I, T = map(int, input().split())\n\nkitten = []\nfor i in range(F):\n\tkitten.append(list(input()))\n\nnumb = 0\nfor j in range(I):\n\tk = 0\n\tfor i in range(F):\n\t\tif kitten[i][j] == 'Y':\n\t\t\tk += 1\n\tif k >= T:\n\t\tnumb += 1\n\nprint(numb)"}, {"source_code": "m,n,t=map(int,raw_input().split())\nc=[0]*n\nr,kitten=0,0\nfor i in xrange(m):\n\ts=raw_input()\n\tfor j in xrange(n):\n\t\tif s[j]=='Y':\n\t\t\tc[j]+=1\n\t\t\tif c[j]==t:\n\t\t\t\tr+=1\nprint r\n"}, {"source_code": "n, m, t = input().split()\n\ndic = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n\nn = int(n)\nm = int(m)\nt = int(t)\n\nfor i in range(n):\n\tinp = input();\n\tfor j in range(m):\n\t\tif inp[j] == 'Y':\n\t\t\tdic[j] += 1\n\nresult = 0\nfor i in range(m):\n\tif dic[i] >= t:\n\t\tresult += 1\n\nprint (result)\n# :3\n# kitten"}, {"source_code": "f, l, t = map(int, raw_input().split())\nk = [raw_input() for i in range(f)]\nprint sum(1 for i in range(l) if sum(1 for j in range(f) if k[j][i] == 'Y') >= t)\n# kitten"}, {"source_code": "F, I, T = map(int, raw_input().split())\nitem = [0 for i in range(I)]\nans = 0\nfor i in range(F):\n lks = raw_input()\n for j in range(I):\n if lks[j] == 'Y':\n item[j] += 1\n if item[j] == T:\n ans += 1\nprint ans\n#kitten\n"}], "negative_code": [{"source_code": "m,n,t=map(int,raw_input().split())\nc=[0]*n\nres=0\nfor i in xrange(m):\n\ts=raw_input()\n\tfor j in xrange(n):\n\t\tif s[j]=='Y':\n\t\t\tc[j]+=1\n\t\t\tif c[j]==t:\n\t\t\t\tres+=1\nprint res\n"}, {"source_code": "from sys import stdin,stdout;F,I,T=map(int,stdin.readline().rstrip().split());q=[0]*20;c=0;\nfor f in range(0,F):\n s=stdin.readline()\n for i in range(0,I):\n if(s[i]=='Y'):q[i]=q[i]+1\nfor i in range(0,I):\n if(q[i]>=T):c+=1\nstdout.write(str(c))\n"}, {"source_code": "sb=[0]*10000\nF,I,T = raw_input().split(' ')\nF=int(F)\nI=int(I)\nT=int(T)\nfor f in range(0,F):\n s=raw_input()\n for i in range(0,I):\n if s[i]=='Y':\n sb[i]=sb[i]+1\nc = 0\nfor i in range(0,I):\n if sb[i]>=T:\n c=c+1\nprint(c)\n"}, {"source_code": "n, m, k=map(int, input().split())\nc=[0 for i in range(m)]\nimport sys\na=0\n\nfor s in sys.stdin.read().split():\n\tfor i in range(m):\n\t\tif s[i]=='Y':\n\t\t\tc[i]+=1\n\t\t\tif c[i]==k:\n\t\t\t\ta+=1\n\nprint(a)\n"}, {"source_code": "n, m, t = map(int, input().split())\na = [input() for i in range(n)]\ncnt = 0\nfor j in range(m):\n if list(a[i][j] for i in range(n)).count('Y') >= t:\n cnt += 1\nprint(cnt)#kitten"}, {"source_code": "F, I, T = map(int, input().split())\n\nans = [0 for i in range(I)]\nfor i in range (F):\n\ts = input()\n\tfor j in range(I):\n\t\tif (s[j] == 'Y'):\n\t\t\tans[j] += 1\n\t\t\t\nsum = 0\nfor val in ans:\n\tif (val >= T): sum += 1\n\t\nprint (sum)\n\t"}, {"source_code": "f,i,t=map(int,input().split())\ng=[0 for x in range(i)]\nw=0\nfor j in range(f):\n s=input()\n for k in range(len(s)):\n if s[k]=='Y':\n g[k]=g[k]+1\n if g[k]==t:\n w=w+1\nprint(w)"}, {"source_code": "# kitten\ndef main():\n f,i,t=map(int, input().split())\n tota=[0]*i\n for _ in range(f):\n likes=input()\n for j in range(i):\n if likes[j]=='Y':\n tota[j]+=1\n print(sum(1 for to in tota if to>=t))\nmain()\n"}, {"source_code": "F,I,T=map(int,raw_input().split(' '))\nm=[0]*I\nfor i in range(F):\n\ts = raw_input()\n\tfor j in range(I):\n\t\tif s[j]=='Y':\n\t\t\tm[j]+=1\nprint len([1 for i in m if i >= T])\n\n"}, {"source_code": "import sys\n\nline = sys.stdin.readline()\narg = line.split()\nF = int(arg[0])\nI = int(arg[1])\nT = int(arg[2])\n\narr = []\nfor i in range(F):\n\ts = sys.stdin.readline()\n\tarr.append(s)\n\nans = 0\n\nfor i in range(I):\n\tcnt = 0\n\tfor j in range(F):\n\t\tif(arr[j][i] == \"Y\"): cnt += 1\n\tif cnt >= T: ans += 1\n\nprint ans\n"}, {"source_code": "import sys\n\nn, k, t = map (int, sys.stdin.readline().split())\na = [sys.stdin.readline() for kitten in range(n)]\nres = 0\nfor j in range(k):\n cur = 0\n for i in range(n):\n cur += [0, 1][a[i][j] == 'Y'] \n if cur >= t:\n res += 1\n\nprint(res)\n"}, {"source_code": "f,i,t=map(int,input().split())\ng=[0 for x in range(i)]\nw=0\nkitten=0\nfor j in range(f):\n s=input()\n for k in range(len(s)):\n if s[k]=='Y':\n g[k]=g[k]+1\n if g[k]==t:\n w=w+1\nprint(s)"}, {"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\n\nF, I, T = read_ints()\nd = {}\nfor y in range(F):\n s = read_str()\n for x, c in enumerate(s):\n d[y,x] = \"NY\".index(c)\n\nans = 0\nfor x in xrange(I):\n cnt = 0\n for y in range(F):\n cnt += d[y,x]\n if cnt >= T:\n ans += 1\n\nprint ans\n"}, {"source_code": "# =^.^= ^^\nf,v,T=map(int,input().split())\na=list()\nfor i in range(f):\n t=input()\n a.append(t)\nb=0\nfor i in range(v):\n c=0\n for j in range(f):\n if(a[j][i]=='Y'):\n c+=1\n if(c>=T):\n b+=1\nprint(b)\n"}, {"source_code": "n,m,t=map(int,raw_input().split())\ns=[]\nfor i in range(n):s+=[raw_input()]\nres=sum(sum(s[j][i]=='Y' for j in range(n))>=t for i in range(m))\nprint(res)"}, {"source_code": "F,I,T=map(int,raw_input().split(' '))\nm=[0]*I\nfor i in range(F):\n\ts = raw_input()\n\tfor j in range(I):\n\t\tif s[j]=='Y':\n\t\t\tm[j]+=1\nprint len([1 for i in m if i >= T])\n\n"}, {"source_code": "n, m, k = map(int,input().split())\na = [0 for i in range(m)]\nfor i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n a[j] += 1\nprint(len(list(filter(lambda x: x >= k, a))))\n"}, {"source_code": "m,n,t=map(int,raw_input().split())\nc=[0]*n\nres=0\nfor i in xrange(m):\n\ts=raw_input()\n\tfor j in xrange(n):\n\t\tif s[j]=='Y':\n\t\t\tc[j]+=1\n\t\t\tif c[j]==t:\n\t\t\t\tres+=1\nprint res\n"}, {"source_code": "n, m, t = input().split()\n\ndic = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n\nn = int(n)\nm = int(m)\nt = int(t)\n\nfor i in range(n):\n\tinp = input();\n\tfor j in range(m):\n\t\tif inp[j] == 'Y':\n\t\t\tdic[j] += 1\n\nresult = 0\nfor i in range(m):\n\tif dic[i] >= t:\n\t\tresult += 1\n\nprint (result)\n# :3"}, {"source_code": "cnt = [];\n\nF, I, T = input().split();\n\nfor i in range(int(I)):\n cnt.append(0);\n\nfor i in range(int(F)):\n s = input();\n for j in range(int(I)):\n cnt[j] += s[j] == 'Y';\n\nres = 0;\nfor i in range(int(I)):\n res += cnt[i] >= int(T);\n \nprint(res);"}, {"source_code": "F,I,T=map(int,raw_input().split(\" \"))\nL=[0]*10\nfor f in range(F):\n\tS=raw_input()\n\tfor x in range(I):\n\t\tif S[x]=='Y':\n\t\t\tL[x]+=1\nret=0\nfor x in L:\n\tif x>=T:\n\t\tret+=1\nprint ret\n"}, {"source_code": "n, b, t = (int(i) for i in input().split())\nc=[0]*b\nr=[]#kitten\nfor i in range(n):\n s = input()\n r.append(s)\n for j in range(len(s)):\n c[j]+=r[i][j]=='Y'\nr=0\nfor i in range(b):\n r+=c[i]>=t\nprint(r)"}, {"source_code": "f,x,t=map(int,raw_input().split())\nl=[0]*20\nfor i in range(f):\n s=raw_input().split()[0]\n for j in range(x):\n if(s[j]=='Y'):\n l[j]+=1\ny=0\nfor j in range(x):\n if(l[j]>=t):\n y+=1\nprint(y)#=^.^="}, {"source_code": "m=input\nr=range\n[a,b,c]=map(int,m().split())\ne=[m()for i in r(a)]\ns=0\nfor j in r(b):\n w=0\n for i in r(a):\n if e[i][j]=='Y':\n w+=1\n if w>=c:\n s+=1\nprint(s)\n#kitten"}, {"source_code": "f=[0]*99\nq=0\na,b,c=map(int,input().split())\nfor i in range(a):\n s=input()\n for j in range(b):\n if s[j]=='Y':\n f[j]+=1\n if f[j]==c:\n q+=1\nprint(q)#kitten"}, {"source_code": "inp = list(map(int, input().strip().split()))\n\nv = [0]*inp[1]\n\nfor i in range(inp[0]):\n\ts = input();\n\tfor j in range(inp[1]):\n\t\tif s[j] == \"Y\":\n\t\t\tv[j] += 1\nresp = 0\nfor i in range(inp[1]):\n\tif v[i] >= inp[2]:\n\t\tresp += 1\nprint (resp)\n"}, {"source_code": "from sys import stdin,stdout;F,I,T=map(int,stdin.readline().rstrip().split());q=[0]*20;c=0;\nfor f in range(0,F):\n s=stdin.readline()\n for i in range(0,I):\n if(s[i]=='Y'):q[i]+=1\nfor i in range(0,I):\n if(q[i]>=T):c+=1\nstdout.write(str(c))\n"}, {"source_code": "F,I,T=map(int,raw_input().split(\" \"))\nL=[0]*10#kitten\nfor f in range(F):\n\tS=raw_input()\n\tfor x in range(I):\n\t\tif S[x]=='Y':\n\t\t\tL[x]+=1\nret=0\nfor x in L:\n\tif x>=T:\n\t\tret+=1\nprint ret\n"}, {"source_code": "n,m,k=map(int,input().split())\nc=[0]*m;\nfor i in range(n):\n\ta=input()\n\tfor j in range(m):\n\t\tc[j]+=a[j]=='Y'\nj=0\nfor i in range(m):\n\tj+=c[i]>=k\nprint(j)\nkitten=0"}, {"source_code": "s=input().split()\nF, I, T = (int(s[i]) for i in range(3))\na=[\"\"]*F\nfor i in range(F):\n\ta[i]=input()\nans=0\nfor i in range(I):\n\tcnt= 0\n\tfor j in range(F):\n\t\tif a[j][i]=='Y':\n\t\t\tcnt+=1\n\tif cnt>=T:\n\t\tans+= 1\nprint(ans)"}, {"source_code": "n, m, t = map(int, input().split())\n#print(n, m, t)\n\nans = 0\nf = [0] * n\n\nfor i in range(n) :\n\tf[i] = input()\n\t#print(f)\n\nfor j in range(m) :\n\tlikes = 0;\n\tfor i in range(n) :\n\t\tif (f[i][j] == 'Y') :\n\t\t\tlikes += 1;\n\tif (likes >= t) :\n\t\tans += 1;\n\nprint(ans)\n"}, {"source_code": "n, m, t = map(int, input().split())\na = []\nfor i in range(n):\n a.append(input())\n\nc = 0\nfor i in range(m):\n l = 0\n for j in range(n):\n if (a[j][i] == 'Y'):\n l += 1\n if (l >= t):\n c += 1\n\nprint(c)"}, {"source_code": "f, i, t = [int(x) for x in input().split()]\nscore = [0] * i\nfor ii in range(f):\n line = input()\n for iii in range(i):\n if line[iii] == 'Y':\n score[iii]+=1\nprint(sum([1 for x in score if x >= t]))\n"}, {"source_code": "F,I,T=map(int,input().split())\nG=[0]*11\nfor i in range(F):\n G[i]=input()\nans=0\nfor j in range(I):\n c=0\n for i in range(F):\n if G[i][j]=='Y':\n c+=1\n if c>=T:\n ans+=1\nprint(ans)\n#kitten\n"}, {"source_code": "F,I,K=map(int,input().split())\n#kitten\nf=[v for i in range(F) for v in input()]\nprint(sum(K<=sum(f[i+I*j]=='Y' for j in range(F)) for i in range(I)))"}, {"source_code": "F, I, T = map(int, input().split())\ncnt = []\nfor i in range(I):\n cnt.append(0)\nfor i in range(F):\n s = input()\n for j in range(I):\n if s[j] == 'Y':\n cnt[j] += 1\nans = 0\nfor i in range(I):\n if cnt[i] >= T:\n ans += 1\nprint('{}'.format(ans))\n"}, {"source_code": "n, m, t = map(int, input().split())\nk = [0]*m\nwhile n:\n n -= 1\n s = input()\n for j in range(m):\n k[j]+=s[j]=='Y'\n#:3\nfor i in k:\n n += i>=t\nprint(n)"}, {"source_code": "n, b, t = (int(i) for i in input().split())\nc=[0]*b\nr=[]#kitten\nfor i in range(n):\n s = input()\n r.append(s)\n for j in range(len(s)):\n c[j]+=r[i][j]=='Y'\nr=0\nfor i in range(b):\n r+=c[i]>=t\nprint(r)"}, {"source_code": "n,m,t=map(int,input().split())\nk=[0 for i in range(m)]\nfor i in range(n):\n S=input()\n for j in range(m):\n if S[j]=='Y':\n k[j]+=1\nx=0\nfor j in range(m):\n if k[j]>=t:\n x+=1\nprint(x)\nkitten=0"}, {"source_code": "n, m, t = [int(i) for i in input().split()]\nans = 0\npictures = [0] * 100\n\nfor i in range(n) :\n likes = input()\n for j in range(m) :\n if (likes[j] == 'Y') :\n pictures[j] += 1\n\nfor i in pictures :\n ans += (i >= t)\nprint(ans)"}, {"source_code": "F, I, T = map(int, input().split())\n\nG = []\nfor i in range(F):\n\tG.append(list(input()))\n\nnumb = 0\nfor j in range(I):\n\tk = 0\n\tfor i in range(F):\n\t\tif G[i][j] == 'Y':\n\t\t\tk += 1\n\tif k >= T:\n\t\tnumb += 1\n\nprint(numb)"}, {"source_code": "m=input\nr=range\n[a,b,c]=[int(x)for x in m().split()]\ne=[m().strip()for i in r(a)]\ns=0\nfor j in r(b):\n w=0\n for i in r(a):\n if e[i][j]=='Y':\n w+=1\n if w>=c:\n s+=1\nprint(s)"}, {"source_code": "n,m,t = map(int, input().split())\nc = [0] * m;\nres = 0;\nfor i in range(n):\n\ts = input()\n\tfor j in range(m):\n\t\tif s[j] == 'Y':\n\t\t\tc[j] += 1;\n\t\t\tif c[j] == t:\n\t\t\t\tres += 1;\n\nprint(res);"}, {"source_code": "import sys\nF,I,T=map(int,sys.stdin.readline().split())\na=[list(map(lambda c:c=='Y',sys.stdin.readline().strip())) for i in range(F)]\nb=map(list,zip(*a))\nprint sum(map(lambda c:sum(c)>=T,b))\n"}, {"source_code": "n, m, t = map(int, input().split())\na = []\nfor kitten in range(n):\n a.append(input())\n\nc = 0\nfor i in range(m):\n l = 0\n for j in range(n):\n if a[j][i] == 'Y':\n l += 1\n if l >= t:\n c += 1\n\nprint(c)"}, {"source_code": "from sys import stdin,stdout;F,I,T=map(int,stdin.readline().rstrip().split());q=[0]*20;c=0;\nfor f in range(0,F):\n s=stdin.readline()\n for i in range(0,I):\n if(s[i]=='Y'):q[i]+=1\nfor i in range(0,I):\n if(q[i]>=T):c+=1\nstdout.write(str(c))\n"}, {"source_code": "i = raw_input()\nm, n,v = map(int, i.split())\nx={}\nfor s in range(m):\n x[s]=raw_input()\nk={}\nfor s in range(n):\n k[s]=0\n for i in range(m):\n if x[i][s]=='Y':\n k[s]+=1\na=0\nfor i in range(n):\n if k[i]>=v:\n a+=1\nprint a"}, {"source_code": "F,I,T=map(int,raw_input().split())\nm=[0]*I\nfor i in range(F):\n\ts = raw_input()\n\tfor j in range(I):\n\t\tif s[j]=='Y':\n\t\t\tm[j]+=1\nprint len([124 for i in m if i >= T])\n#kitten\n"}, {"source_code": "f, e, t = map(int, input().split())\na = [0] * f\nfor i in range(f) :\n a[i] = input()\nn = 0\nfor i in range(e) :\n kol = 0\n for j in range(f) :\n kol += (a[j][i] == 'Y')\n n += (kol >= t)\nprint(n) "}, {"source_code": "#\"kitten\"\nn,m,k=map(int,raw_input().split())\nf=[0]*m\nfor i in range(n):\n f=map(lambda x,y:(x=='Y')+y,list(raw_input()),f)\ncnt=0\nfor i in range(m):\n cnt+=(f[i]>=k)\nprint cnt\n"}, {"source_code": "F,I,T=map(int,raw_input().split(\" \"))\nL=[0]*10#kitten\nfor f in range(F):\n\tS=raw_input()\n\tfor x in range(I):\n\t\tif S[x]=='Y':\n\t\t\tL[x]+=1\nret=0\nfor x in L:\n\tif x>=T:\n\t\tret+=1\nprint ret\n"}, {"source_code": "o = input().split()\nf,l,t = int(o[0]),int(o[1]),int(o[2])\ns = []\nfor i in range(f):\n s.append(input())\nans = 0\nfor i in range(l):\n cnt = 0\n for j in range(f):\n cnt += (s[j][i]=='Y')\n ans += (cnt >= t)\nprint( ans )\n"}, {"source_code": "f,I,t= list(map(int, input().split())) \nc=[0]*I\nfor i in range(f):\n s=input()\n for j in range(I):\n if s[j]=='Y':\n c[j]+=1\nans=0\nfor j in range(I):\n if c[j]>=t:\n ans+=1\nprint(ans)\n"}, {"source_code": "f,i,t=input().split()\nf=int(f)\ni=int(i)\nt=int(t)\na=[0]*i\nm=[0]*i\n\nfor v in range(f):\n\tp=input()\n\tfor w in range(i):\n\t\tif p[w]=='Y':\n\t\t\ta[w]+=1\n\t\t\tif a[w]>=t:\n\t\t\t\tm[w]=1\nprint(sum(m))\n"}, {"source_code": "g, intr, t = map(int, input().split())\na=[]\nfor i in range(g):\n a.append(input())\nres = 0\nfor j in range(intr):\n cnt = 0\n for i in range(g):\n if a[i][j] == 'Y':\n cnt += 1\n if cnt >= t:\n res += 1\nprint(res)\n"}, {"source_code": "#kitten\nn, m, t = map(int, input().split())\n\nans = 0\nf = [0] * n\n\nfor i in range(n) :\n\tf[i] = input()\n\nfor j in range(m) :\n\tlikes = 0;\n\tfor i in range(n) :\n\t\tif (f[i][j] == 'Y') :\n\t\t\tlikes += 1;\n\tif (likes >= t) :\n\t\tans += 1;\n\nprint(ans)\n"}, {"source_code": "import math\n\nn, m, t = input().split()\nn = int(n)\nm = int(m)\nt = int(t)\nans = 0\ns = []\nc = 0\n\nfor i in range(n):\n s.append(input())\n\nfor j in range(m):\n c = 0\n for i in range(n):\n if s[i][j] == 'Y':\n c += 1\n if c >= t:\n ans += 1\n\nprint(ans)\n"}, {"source_code": "f,n,t=map(int,input().split())\ns=0\ny=[0]*10\na=str()\nfor i in range(0,f):\n a=input()\n for j in range(0, n):\n if a[j]=='Y':\n y[j]+=1;\nfor i in range(0, n):\n if y[i] >= t:\n s += 1\nprint(s)"}, {"source_code": "a,b,c = [int(x) for x in raw_input().split()]\n\ncount = [0 for x in range(b)]\nfor _ in range(0, a):\n\tfor (index, x) in enumerate(raw_input()):\n\t\tif x == 'Y':\n\t\t\tcount[index] += 1\n\t\t\t\nprint sum(map((lambda x: x >= c), count)) \n\t\t\n"}, {"source_code": "def main():\n f,i,t=map(int, input().split())\n tota=[0]*i\n for _ in range(f):\n likes=input()\n for j in range(i):\n if likes[j]=='Y':\n tota[j]+=1\n print(sum(1 for to in tota if to>=t))\nmain()\n"}, {"source_code": "F, I, T = [int(t) for t in input().split()]\n\nob = [0 for t in range(I)]\nfor i in range(F):\n s = input().strip()\n for f in range(I):\n ob[f] += (s[f] == 'Y')\n \nprint(sum([1 if t>=T else 0 for t in ob]))"}, {"source_code": "sb=[0]*10000\nF,I,T = raw_input().split(' ')\nF=int(F)\nI=int(I)\nT=int(T)\nfor f in range(0,F):\n s=raw_input()\n for i in range(0,I):\n if s[i]=='Y':\n sb[i]=sb[i]+1\nc = 0\nfor i in range(0,I):\n if sb[i]>=T:\n c=c+1\nprint(c)\n"}, {"source_code": "F, I, T = map(int, input().split())\nRes = 0\nA = [0 for i in range(I)]\nfor i in range (F):\n s = input()\n for j in range(I):\n if s[j] == 'Y':\n A[j] += 1 \nfor i in range(I):\n if (A[i] >= T):\n Res += 1\nprint(Res)\n"}, {"source_code": "n, m, k = map(int, input().split())\nans = [0 for x in range(m)]\nfor i in range(n):\n s = input()\n for j in range(m):\n ans[j] += (s[j] == 'Y')\nprint(sum([x >= k for x in ans]))"}, {"source_code": "n, m, t = (int(x) for x in input().split())\n\ns=[\"\"]*n\nres=0\n\nfor i in range(0,n):\n\ts[i] = input()\n\nfor j in range(0,m):\n\tcnt = 0\n\tfor i in range(0,n):\n\t\tif s[i][j] == 'Y':\n\t\t\tcnt=cnt+1\n\tif cnt >= t:\n\t\tres=res+1\n\nprint(res)\n"}, {"source_code": "#:3\n#kitten\nf,b,t=map(int,raw_input().split())\nl=[0,0,0,0,0,0,0,0,0,0]\nfor _ in range(0,f):\n s=raw_input()\n for i in range(0,b):\n if(s[i]=='Y'):\n l[i]=l[i]+1\na=0\nfor i in range(0,b):\n if(l[i]>=t):\n a=a+1\nprint a\n"}, {"source_code": "F,I,K=map(int,input().split(\" \"))\ninp=list(map(lambda i:list(map(lambda l:l=='Y',input())),range(F)))\nprint(sum(map(lambda i:K<=sum(map(lambda l:l[i],inp)),range(I))))\n"}, {"source_code": "q = raw_input().split()\nF = int(q[0])\nI = int(q[1])\nT = int(q[2])\n\nm = []\nfor i in range(0, F):\n\tm.append(raw_input())\n\nans = 0\nfor i in range(0, I):\n\tc = 0\n\tfor j in range(0, F):\n\t\tif m[j][i] == 'Y':\n\t\t\tc += 1\n\tif c >= T:\n\t\tans += 1\n\nprint ans"}, {"source_code": "F,I,T=map(int,input().strip().split(\" \"))\ngrid=[[k=='Y' for k in list(input()) ] for i in range(F)]\nprint( sum( 1 if o >= T else 0 for o in [ sum(1 if grid[i][j] else 0 for i in range(F)) for j in range(I)]))\n"}, {"source_code": "n,m,k=map(int,input().split())\na=[0 for x in range(m)]\nfor i in range(n):\n s=input()\n for j in range(m):\n a[j]+=(s[j]=='Y')\nprint(sum([x>=k for x in a]))\n#kitten"}, {"source_code": "s = input().split()\nF = int(s[0])\nI = int(s[1])\nT = int(s[2])\na = [\"\"] * F\nfor i in range(F):\n\ta[i] = input()\nans = 0\nfor i in range(I):\n\tcnt = 0\n\tfor j in range(F):\n\t\tif a[j][i] == 'Y':\n\t\t\tcnt += 1\n\tif cnt >= T:\n\t\tans += 1\nprint(ans)"}, {"source_code": "l=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nkitten=0\nx=input()\nx=x.split()\na=\"\"\nfor i in range(int(x[0])):\n a=a+input()+\" \"\na=a.split()\nfor i in range(int(x[0])):\n for j in range(int(x[1])):\n if a[i][j]=='Y':\n l[j]+=1\nc=0\nfor i in range(int(x[1])):\n if l[i]>=int(x[2]):\n c+=1\nprint(c)\n"}, {"source_code": "Q=input\nF, I, T = map(int, Q().split(\" \"))\nA=[0]*F\nX=range\nfor i in X(F):\n A[i]=Q()\nr=0\nfor i in X(I):\n s=0\n for j in X(F):\n if A[j][i] == 'Y': s+=1\n if s>=T: r+=1\nprint(r)\n"}, {"source_code": "s=input().split(' ')\nf=int(s[0])\nq=int(s[1])\nt=int(s[2])\nnra=[]\nfor i in range(0,q):\n nra+=[0]\nans=0\n\nfor i in range(0,f):\n s=input()\n for j in range(0,q):\n if s[j]=='Y':\n nra[j]+= 1\n if nra[j]==t:\n ans+=1\nprint(ans)\n"}, {"source_code": "n=list(map(int,input().split()))\nv=[0]*n[1]\nfor i in range(n[0]):\n\ts=input();\n\tfor j in range(n[1]):\n\t\tif s[j]==\"Y\":\n\t\t\tv[j]+=1\nr=0\nfor i in range(n[1]):\n\tif v[i]>=n[2]:\n\t\tr+=1\nprint(r)\n"}, {"source_code": "f,I,t=list(map(int,input().split())) \nc=[0]*I\nfor kitten in range(f):\n s=input()\n for j in range(I):\n if s[j]=='Y':\n c[j]+=1\nq=0\nfor j in range(I):\n if c[j]>=t:\n q+=1\nprint(q)\n"}, {"source_code": "n, m, t = map(int, raw_input().split())\n\ns = []\nfor i in xrange(n):\n s.append(raw_input())\n\nres = 0\nfor i in xrange(m):\n v = 0\n for j in xrange(n):\n if s[j][i] == 'Y': v += 1\n if v >= t: res += 1\nprint res"}, {"source_code": "F, I, T = map(int, input().split(\" \"))\nA=[]\nX=range\nfor i in X(F):\n A.append(input())\nr=0\nfor i in X(I):\n s=0\n for j in X(F):\n if A[j][i] == 'Y': s+=1\n if s>=T: r+=1\nprint(r)\n"}, {"source_code": "num=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nx=\"\"\nx=input()\nx=x.split(\" \")\na=\"\"\nfor i in range(int(x[0])):\n a=a+input()+\" \"\na=a.split(\" \")\nfor i in range(int(x[0])):\n for j in range(int(x[1])):\n if a[i][j]=='Y':\n num[j]=num[j]+1\nans=0\nfor i in range(int(x[1])):\n if num[i]>=int(x[2]):\n ans=ans+1\nprint(ans)\n"}, {"source_code": "import sys;\n\nf, i, t = [int(s) for s in sys.stdin.readline().split(\" \")]\nitems = [0] * i;\nfor j in range(0, f):\n line = sys.stdin.readline()\n for i, c in enumerate(line):\n print c\n if c == 'Y':\n items[i] += 1\n\ncount = 0\nfor item in items:\n if item >= t:\n count += 1\n\n\n\nprint count\n"}, {"source_code": "cnt = [0] * 11\n\ndef solve():\n\tn,m,k = (int(z) for z in input().split())\n\tfor i in range(n):\n\t c = input()\n\t for j in range(m):\n\t if c[j] == 'Y':\n\t cnt[j] += 1\n\tans = 0\n\tfor i in range(m):\n\t if cnt[i] >= k:\n\t ans += 1\n\t \n\tprint(ans)\n\nsolve()"}, {"source_code": "import sys\nn,m,k=map(int,sys.stdin.readline().split ())\nc=[0]*m\nfor i in range(n):\n T=sys.stdin.readline()\n for j in range(m) :\n if T[j]=='Y' :\n c[j]+=1\nA=0\nfor i in range(m):\n if c[i]>=k:\n A+=1\nprint(A)"}, {"source_code": "F, I, T = map(int, input().split())\nRes = 0\nA = [0 for i in range(I)]\nfor i in range (F):\n s = input()\n for j in range(I):\n #print(s[j], A[j])\n if s[j] == 'Y':\n A[j] += 1 \nRes = 0;\n#print(A)\nfor i in range(I):\n if (A[i] >= T):\n Res += 1\nprint(Res)\n"}, {"source_code": "f=[0]*100\nq=0\na,b,c=map(int,input().split())\nfor i in range(a):\n s=input()\n for j in range(b):\n if s[j]=='Y':\n f[j]+=1\n if f[j]==c:\n q+=1\n#kitten\nprint(q)"}, {"source_code": "f,I,T=map(int,input().split())\ns=[];\nfor i in range(f):\n s.append(input())\nprint(sum(sum((s[i][j] == 'Y' for i in range(f)))>=T for j in range(I)))\n"}, {"source_code": "inp = list(map(int, input().strip().split()))\n\nv = [0]*inp[1]\n\nfor i in range(inp[0]):\n\ts = input();\n\tfor j in range(inp[1]):\n\t\tif s[j] == \"Y\":\n\t\t\tv[j] += 1\nresp = 0\nfor i in range(inp[1]):\n\tif v[i] >= inp[2]:\n\t\tresp += 1\nprint (resp)"}, {"source_code": "f,I,t=list(map(int, input().split())) \nc=[0]*I\nfor i in range(f):\n s=input()\n for j in range(I):\n if s[j]=='Y':\n c[j]+=1\nq=0\nfor j in range(I):\n if c[j]>=t:\n q+=1\nprint(q)\n"}, {"source_code": "F,I,K=map(int,input().split(\" \"))\nf=[v for i in range(F) for v in input()]\nprint(sum(K<=sum(f[i+I*j]=='Y' for j in range(F)) for i in range(I)))"}, {"source_code": "\n#hkadokjhfdjakl\n\n\na = 2 ** 5\nb = a * \"kafjsuhdajsdcbvhsdjkljghujcfgvbhhbnjhgfghjhhhhhhhhhhhhhhh\"\n\nF, I, T = map(int, input().split())\n\nlikes = [0] * I\n\nfor i in range(0, F):\n line = str(input())\n for j in range(0, I):\n if line[j] == 'Y':\n likes[j] += 1\n\ncnt = 0\n\nfor l in likes:\n if l >= T:\n cnt += 1\n \nprint(cnt)"}, {"source_code": "from collections import defaultdict\nd = defaultdict(int)\nans = 0\nn, m, k = map(int, input().split())\nfor i in range(n):\n s = input()\n for j in range(m):\n if s[j] == 'Y':\n d[j] += 1\n if i == n-1 and d[j] >= k:\n ans += 1\nprint(ans)"}, {"source_code": "[n,b,t]=map(int,input().split())\nc=[0]*b#kitten\nr=[]\nfor i in range(n):\n s=input()\n r.append(s)\n for j in range(b):\n c[j]+=r[i][j]=='Y'\nr=0\nfor i in range(b):\n r+=c[i]>=t\nprint(r)"}, {"source_code": "s = input().split()\nq = [0] * 20\nii = int(s[1])\nfor i in range(int(s[0])):\n z = input()\n for j in range(ii):\n if (z[j] == 'Y'):\n q[j] += 1\na = 0\nfor i in range(ii):\n if (q[i] >= int(s[2])):\n a += 1\nprint(a)\n#kitten\n\n\n"}, {"source_code": "n, m, t = map(int, input().split())\ngo = []\nfor i in range(n):\n go.append(input())\ncnt = 0\nfor j in range(m):\n x = 0\n for i in range(n):\n if go[i][j] == 'Y': x += 1\n if x >= t: cnt += 1\nprint(cnt)\n"}, {"source_code": "f, i, t = map(int, input().split())\nq = [0 for x in range(i)]\nfor it in range(f):\n s = input()\n for j in range(i):\n q[j] += int(s[j] == 'Y')\n \nanswer = 0\nfor x in q:\n if (x >= t):\n answer += 1\nprint(answer)\n"}, {"source_code": "sb = [0]*10000\nF,I,T = raw_input().split(' ')\nF = int(F)\nI = int(I)\nT = int(T)\nfor f in range(0,F):\n s = raw_input()\n for i in range(0,I):\n if s[i] == 'Y':\n sb[i]=sb[i]+1\nc = 0\nfor i in range(0,I):\n if sb[i] >= T:\n c = c + 1\nprint(c) #kitten\n"}, {"source_code": "#\"kitten\"\nn,m,k=map(int,raw_input().split())\nf=[0]*m\nfor i in range(n):\n f=map(lambda x,y:(x=='Y')+y,list(raw_input()),f)\nprint reduce(lambda x,y:x+(y>=k),f,0);\n"}, {"source_code": "F,I,T=list(map(int,input().split()))\nst=[]\nr=range\nfor i in r(F):\n st.append(input())\nans=0\nfor i in r(I):\n cur=0\n for j in r(F):\n if st[j][i]=='Y':\n cur+=1\n ans+=cur>=T\nprint(ans)\n#kitten"}, {"source_code": "f, o, k = map(int, input().split())\nl = [0 for i in range(o)]\n\nfor i in range(f):\n s = input()\n for j in range(o):\n l[j] += 1 if s[j] == 'Y' else 0\n\na = 0\nfor i in range(o):\n a += 1 if l[i] >= k else 0\n \nprint(a)"}, {"source_code": "cnt = [0] * 11\n\ndef solve():\n\tn,m,k = (int(z) for z in input().split())\n\tfor i in range(n):\n\t c = input()\n\t for j in range(m):\n\t if c[j] == 'Y':\n\t cnt[j] += 1\n\tans = 0\n\tfor i in range(m):\n\t if cnt[i] >= k:\n\t ans += 1\n\t \n\tprint(ans)\n\nsolve()"}, {"source_code": "n=1\nkitten=0\na,b,t=map(int,input().split())\nv=[0]*b\nch=\"\"\nfor i in range(a):\n ch=str(input())\n for j in range(b):\n if ch[j]=='Y':\n v[j]+=1\nfor j in range(b):\n if v[j]>=t :\n kitten+=1\nprint(kitten)\n"}], "src_uid": "4c978130187e8ae6ca013d3f781b064e"} {"nl": {"description": "Madoka wants to enter to \"Novosibirsk State University\", but in the entrance exam she came across a very difficult task:Given an integer $$$n$$$, it is required to calculate $$$\\sum{\\operatorname{lcm}(c, \\gcd(a, b))}$$$, for all triples of positive integers $$$(a, b, c)$$$, where $$$a + b + c = n$$$.In this problem $$$\\gcd(x, y)$$$ denotes the greatest common divisor of $$$x$$$ and $$$y$$$, and $$$\\operatorname{lcm}(x, y)$$$ denotes the least common multiple of $$$x$$$ and $$$y$$$.Solve this problem for Madoka and help her to enter to the best university!", "input_spec": "The first and the only line contains a single integer $$$n$$$ ($$$3 \\le n \\le 10^5$$$).", "output_spec": "Print exactly one interger\u00a0\u2014 $$$\\sum{\\operatorname{lcm}(c, \\gcd(a, b))}$$$. Since the answer can be very large, then output it modulo $$$10^9 + 7$$$.", "sample_inputs": ["3", "5", "69228"], "sample_outputs": ["1", "11", "778304278"], "notes": "NoteIn the first example, there is only one suitable triple $$$(1, 1, 1)$$$. So the answer is $$$\\operatorname{lcm}(1, \\gcd(1, 1)) = \\operatorname{lcm}(1, 1) = 1$$$.In the second example, $$$\\operatorname{lcm}(1, \\gcd(3, 1)) + \\operatorname{lcm}(1, \\gcd(2, 2)) + \\operatorname{lcm}(1, \\gcd(1, 3)) + \\operatorname{lcm}(2, \\gcd(2, 1)) + \\operatorname{lcm}(2, \\gcd(1, 2)) + \\operatorname{lcm}(3, \\gcd(1, 1)) = \\operatorname{lcm}(1, 1) + \\operatorname{lcm}(1, 2) + \\operatorname{lcm}(1, 1) + \\operatorname{lcm}(2, 1) + \\operatorname{lcm}(2, 1) + \\operatorname{lcm}(3, 1) = 1 + 2 + 1 + 2 + 2 + 3 = 11$$$"}, "positive_code": [{"source_code": "from math import gcd\r\n \r\nn = int(input())\r\nMOD = 10**9 + 7\r\n \r\nA = [0, 0]\r\nphi = list(range(n+1))\r\n \r\nfor i in range(2, n+1):\r\n\tif phi[i] == i:\r\n\t\tfor j in range(i, n+1, i):\r\n\t\t\tphi[j] = phi[j]*(i-1)//i\r\n \r\nP = [0, 0]\r\nQ = [0, 0]\r\n \r\nfor i in range(2, n+1):\r\n\tP.append( (P[-1] + phi[i]) % MOD )\r\n\tQ.append( (Q[-1] + phi[i]*i) % MOD )\r\n \r\ntot = 0\r\nfor g in range(1, n):\r\n\tc = n // g\r\n\ttot += n*g*P[c]//gcd(n, g) % MOD\r\n\ttot -= g*g*Q[c]//gcd(n, g) % MOD\r\n \r\nprint(tot % MOD)"}, {"source_code": "from math import gcd\r\nn=int(input())\r\nMOD=10**9+7\r\nA = [0, 0]\r\nlst = list(range(n+1))\r\nfor i in range(2, n+1):\r\n\tif lst[i] == i:\r\n\t\tfor j in range(i, n+1, i):\r\n\t\t\tlst[j] = lst[j]*(i-1)//i\r\nP = [0, 0]\r\nQ = [0, 0]\r\nfor i in range(2, n+1):\r\n\tP.append( (P[-1] + lst[i]) % MOD )\r\n\tQ.append( (Q[-1] + lst[i]*i) % MOD )\r\ntot = 0\r\nfor g in range(1, n):\r\n\tc = n // g\r\n\ttot += n*g*P[c]//gcd(n, g) % MOD\r\n\ttot -= g*g*Q[c]//gcd(n, g) % MOD\r\nprint(tot % MOD)"}, {"source_code": "from math import gcd\r\n\r\nn = int(input())\r\nMOD = 10**9 + 7\r\n\r\nA = [0, 0]\r\nphi = list(range(n+1))\r\n\r\nfor i in range(2, n+1):\r\n\tif phi[i] == i:\r\n\t\tfor j in range(i, n+1, i):\r\n\t\t\tphi[j] = phi[j]*(i-1)//i\r\n\r\nP = [0, 0]\r\nQ = [0, 0]\r\n\r\nfor i in range(2, n+1):\r\n\tP.append( (P[-1] + phi[i]) % MOD )\r\n\tQ.append( (Q[-1] + phi[i]*i) % MOD )\r\n\r\ntot = 0\r\nfor g in range(1, n):\r\n\tc = n // g\r\n\ttot += n*g*P[c]//gcd(n, g) % MOD\r\n\ttot -= g*g*Q[c]//gcd(n, g) % MOD\r\n\r\nprint(tot % MOD)"}, {"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 list(map(str,input().strip().split(\" \")))\r\ndef le(): return list(map(int,input().split()))\r\ndef rc(): return map(float,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\ndef joron(L):\r\n return('\\n'.join(map(str, L)))\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\ndef tir(a,b,c):\r\n if(0==c):\r\n return 1\r\n if(len(a)<=b):\r\n return 0\r\n \r\n if(c!=-1):\r\n return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c)) \r\n \r\n \r\n else:\r\n return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))\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\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\nboi=int(1e9+7)\r\ndoi=int(1e9+7)\r\nhoi=int(6e5+5)\r\n\r\npoi=int(1e5+5)\r\n\r\ny=\"YES\"\r\nn=\"NO\"\r\n\r\ndef bulli(x):\r\n return bin(x).count('1')\r\n\r\nimport sys\r\n\r\n\r\nf=[0]*(hoi)\r\nr=[0]*(hoi)\r\nd=[]\r\nfor i in range(poi):\r\n d.append([])\r\nL=[0]*poi\r\nM=[0]*poi\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 ty(a,b):\r\n rr=1\r\n while(b):\r\n if(b%2):\r\n rr=(rr*a)%boi\r\n b=b//2\r\n a=a*a%boi\r\n return rr\r\ndef inv(a):\r\n re=1\r\n for i in range(1,1+a):\r\n re=(re*i)%boi\r\n re=ty(re,boi-2)\r\n return re\r\ndef ncr(m,k):\r\n if(m<0 or k<0 or k>m):\r\n return 0\r\n return f[m]*r[k]%boi*r[m-k]%boi\r\ndef gosa(a,b):\r\n if(0!=b):\r\n return gosa(b,a%b)\r\n return a\r\n\r\n\r\n \r\n \r\n \r\n\r\ndef iu():\r\n import sys\r\n import math as my\r\n import functools\r\n import bisect as bs\r\n input=sys.stdin.readline\r\n from collections import deque, defaultdict\r\n '''f[0]=1\r\n for i in range(1,hoi):\r\n f[i]=(f[i-1]*i)%boi\r\n r[hoi-1]=ty(f[hoi-1],boi-2)\r\n for i in range(hoi-2,-1,-1):\r\n r[i]=r[i+1]*(i+1)%boi'''\r\n z=0\r\n m=so()\r\n for i in range(poi-1,0,-1):\r\n for j in range(i,poi,i):\r\n d[j].append(i)\r\n for i in range(1,1+m):\r\n r=m-i\r\n s=len(d[r])\r\n for j in range(s):\r\n M[j]=r//(d[r][j])-1\r\n for k in range(j):\r\n if(not d[r][k]%d[r][j]):\r\n M[j]=M[j]-M[k]\r\n z=z+M[j]*i*d[r][j]//gosa(d[r][j],i)%boi\r\n print(z%boi)\r\n \r\n \r\n \r\n \r\n \r\n \r\ndef main():\r\n for i in range(1):\r\n #print(\"Case #\"+str(i+1)+\": \",end=\"\")\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 \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# 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": "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 list(map(str,input().strip().split(\" \")))\r\ndef le(): return list(map(int,input().split()))\r\ndef rc(): return map(float,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\ndef joron(L):\r\n return('\\n'.join(map(str, L)))\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\ndef tir(a,b,c):\r\n if(0==c):\r\n return 1\r\n if(len(a)<=b):\r\n return 0\r\n \r\n if(c!=-1):\r\n return (tir(a,1+b,c+a[b]) or tir(a,b+1,c-a[b]) or tir(a,1+b,c)) \r\n \r\n \r\n else:\r\n return (tir(a,1+b,a[b]) or tir(a,b+1,-a[b]) or tir(a,1+b,-1))\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\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\nboi=int(1e9+7)\r\ndoi=int(1e9+7)\r\nhoi=int(6e5+5)\r\n\r\npoi=int(1e5+5)\r\n\r\ny=\"YES\"\r\nn=\"NO\"\r\n\r\ndef bulli(x):\r\n return bin(x).count('1')\r\n\r\nimport sys\r\n\r\n\r\nf=[0]*(hoi)\r\nr=[0]*(hoi)\r\nd=[]\r\nfor i in range(poi):\r\n d.append([])\r\nL=[0]*poi\r\nM=[0]*poi\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 ty(a,b):\r\n rr=1\r\n while(b):\r\n if(b%2):\r\n rr=(rr*a)%boi\r\n b=b//2\r\n a=a*a%boi\r\n return rr\r\ndef inv(a):\r\n re=1\r\n for i in range(1,1+a):\r\n re=(re*i)%boi\r\n re=ty(re,boi-2)\r\n return re\r\ndef ncr(m,k):\r\n if(m<0 or k<0 or k>m):\r\n return 0\r\n return f[m]*r[k]%boi*r[m-k]%boi\r\ndef gosa(a,b):\r\n if(0!=b):\r\n return gosa(b,a%b)\r\n return a\r\n\r\n\r\n \r\n \r\n \r\n\r\ndef iu():\r\n import sys\r\n import math as my\r\n import functools\r\n import bisect as bs\r\n input=sys.stdin.readline\r\n from collections import deque, defaultdict\r\n '''f[0]=1\r\n for i in range(1,hoi):\r\n f[i]=(f[i-1]*i)%boi\r\n r[hoi-1]=ty(f[hoi-1],boi-2)\r\n for i in range(hoi-2,-1,-1):\r\n r[i]=r[i+1]*(i+1)%boi'''\r\n z=0\r\n m=so()\r\n for i in range(poi-1,0,-1):\r\n for j in range(i,poi,i):\r\n d[j].append(i)\r\n for i in range(1,1+m):\r\n r=m-i\r\n s=len(d[r])\r\n for j in range(s):\r\n M[j]=r//(d[r][j])-1\r\n for k in range(j):\r\n if(not d[r][k]%d[r][j]):\r\n M[j]=M[j]-M[k]\r\n z=z+M[j]*i*d[r][j]//gosa(d[r][j],i)%boi\r\n print(z%boi)\r\n \r\n \r\n \r\n \r\n \r\n \r\ndef main():\r\n for i in range(1):\r\n #print(\"Case #\"+str(i+1)+\": \",end=\"\")\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 \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# 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": "n = int(input())\r\nif(n == 3):\r\n print(1)\r\nelif(n == 5):\r\n print(11)\r\nelif n == 69228:\r\n print(778304278)\r\nelif n == 228:\r\n print(3369368)\r\nelif n == 47:\r\n print(32596)\r\nelif n == 13:\r\n print(405)\r\nelif n == 1337:\r\n print(425608851)\r\nelif n == 100000:\r\n print(454535891)\r\nelif n == 94874:\r\n print(584783437)\r\nelif n == 99413:\r\n print(461761995)\r\nelif n == 99913:\r\n print(550761256)\r\nelif n == 4:\r\n print(4)\r\nelif n == 6:\r\n print(20)\r\nelif n == 7:\r\n print(42)\r\nelif n == 8:\r\n print(60)\r\nelif n == 9:\r\n print(100)\r\nelif n == 10:\r\n print(134)"}, {"source_code": "#from math import ceil, floor #, gcd, log, factorial, comb, perm,\r\n#log10, log2, log, sin, asin, tan, atan,\r\n#from heapq import heappop,heappush,heapify #heappop(hq), heapify(list)\r\n#from collections import defaultdict as dd\r\n#mydd=dd(list) for .append\r\n#from collections import deque as dq #deque e.g. myqueue=dq(list)\r\n#append/appendleft/appendright/pop/popleft\r\n#from bisect import bisect as bis #a=[1,3,4,6,7,8] #bis(a,5) --> 3\r\n#import statistics as stat # stat.median(a), mode, mean\r\nfrom math import gcd\r\nimport sys\r\ninput = sys.stdin.readline\r\n#print = sys.stdout.write\r\n#sys.setrecursionlimit(100000) #default is 1000 \r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split()))) #.split(','), default is space\r\n#list([0,*map(int,input().split(\" \"))]) # pad a zero to avoid zero indexing\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n####################################################\r\n##def phi(n): #Euler's totient function from Euler's product formula\r\n## result = n;\r\n## if (n%2 == 0):\r\n## while (n % 2 == 0):n//=2;\r\n## result //=2;\r\n## p=3\r\n## while(p*p <= n):\r\n## if (n % p == 0):\r\n## while (n % p == 0):n//=p;\r\n## result -= result//p;\r\n## p += 2;\r\n## if (n > 1):\r\n## result -= result//n;\r\n## return result;\r\n#t=1\r\nn = int(input())\r\nphi = list(range(n+1))\r\nfor i in range(2, n+1):\r\n if phi[i] == i:\r\n for j in range(i, n+1, i):\r\n phi[j] -= phi[j]//i\r\n##phis=[0]\r\n##for i in range(1,n):\r\n## phis.append(phi(i))\r\nans=0;mod=10**9+7\r\n\r\nfor d in range(1,n//2+1):\r\n g=gcd(n,d)\r\n tmp=0\r\n for ncd in range(2,(n-1)//d+1):\r\n c=n-ncd*d\r\n tmp+=c*phi[ncd]\r\n ans+=tmp*d//g\r\n ans%=mod\r\nprint(ans)\r\n \r\n#print(*ans,sep=' ')##print(\"{:.3f}\".format(ans)+\"%\")\r\n#:b binary :% eg print(\"{:6.2%}\".format(ans))\r\n#print(\" \".join(str(i) for i in ans))\r\n#print(\" \".join(map(str,ans))) #seems faster\r\n#print(a[0] if a else 0)\r\n#prefixsum a=[a1...an] #psa=[0]*(n+1)\r\n#for i in range(n): psa[i+1]=psa[i]+a[i]\r\n#sum[:ax]=psa[x+1] e.g. sum 1st 5 items in psa[5]\r\n#ASCII<->number ord('f')=102 chr(102)='f'\r\n#def binary_search(li, val, lb, ub):\r\n# while ((ub-lb)>1):\r\n# mid = (lb + ub) // 2\r\n# if li[mid] >= val:\r\n# ub = mid\r\n# else:\r\n# lb = mid\r\n# return lb+1 #return index of elements 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#def 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#def suff(li):\r\n# suff_sum = [0]\r\n# for i in range(len(li)-1,-1,-1):\r\n# suff_sum.insert(0,suff_sum[0] + li[i])\r\n# return suff_sum\r\n#############\r\n#def maxSubArraySumI(arr): #Kadane's algorithm with index\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# start=0;end=0;s=0\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:\r\n# max_till_now=max_ending\r\n# start=s;end=i\r\n# if max_ending<0:\r\n# max_ending=0\r\n# s=i+1\r\n# return max_till_now,start,end\r\n############# avoid max for 2 elements - slower than direct if\r\n#def maxSubArraySum(arr): #Kadane's algorithm\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:max_till_now=max_ending\r\n# if max_ending<0:max_ending=0\r\n# return max_till_now\r\n#############\r\n#def findbits(x):\r\n# tmp=[]\r\n# while x>0:tmp.append(x%2);x//=2\r\n# tmp.reverse()\r\n# return tmp\r\n##############Dijkstra algorithm example\r\n#dg=[999999]*(n+1);dg[n]=0;todo=[(0,n)];chkd=[0]*(n+1)\r\n#while todo:#### find x with min dg in todo\r\n# _,x=hq.heappop(todo)\r\n# if chkd[x]:continue\r\n# for i in coming[x]:going[i]-=1\r\n# for i in coming[x]:\r\n# tmp=1+dg[x]+going[i]\r\n# if tmp 3\r\n#import statistics as stat # stat.median(a), mode, mean\r\nfrom math import gcd\r\nimport sys\r\ninput = sys.stdin.readline\r\n#print = sys.stdout.write\r\n#sys.setrecursionlimit(100000) #default is 1000 \r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split()))) #.split(','), default is space\r\n#list([0,*map(int,input().split(\" \"))]) # pad a zero to avoid zero indexing\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n####################################################\r\ndef phi(n): #Euler's totient function from Euler's product formula\r\n result = n;\r\n if (n%2 == 0):\r\n while (n % 2 == 0):n//=2;\r\n result //=2;\r\n p=3\r\n while(p*p <= n):\r\n if (n % p == 0):\r\n while (n % p == 0):n//=p;\r\n result -= result//p;\r\n p += 2;\r\n if (n > 1):\r\n result -= result//n;\r\n return result;\r\n#t=1\r\nn = int(input())\r\nphis=[0]\r\nfor i in range(1,n):\r\n phis.append(phi(i))\r\nans=0;mod=10**9+7\r\n\r\nfor d in range(1,n//2+1):\r\n g=gcd(n,d)\r\n tmp=0\r\n for ncd in range(2,(n-1)//d+1):\r\n c=n-ncd*d\r\n tmp+=c*phis[ncd]\r\n ans+=tmp*d//g\r\n ans%=mod\r\nprint(ans)\r\n \r\n#print(*ans,sep=' ')##print(\"{:.3f}\".format(ans)+\"%\")\r\n#:b binary :% eg print(\"{:6.2%}\".format(ans))\r\n#print(\" \".join(str(i) for i in ans))\r\n#print(\" \".join(map(str,ans))) #seems faster\r\n#print(a[0] if a else 0)\r\n#prefixsum a=[a1...an] #psa=[0]*(n+1)\r\n#for i in range(n): psa[i+1]=psa[i]+a[i]\r\n#sum[:ax]=psa[x+1] e.g. sum 1st 5 items in psa[5]\r\n#ASCII<->number ord('f')=102 chr(102)='f'\r\n#def binary_search(li, val, lb, ub):\r\n# while ((ub-lb)>1):\r\n# mid = (lb + ub) // 2\r\n# if li[mid] >= val:\r\n# ub = mid\r\n# else:\r\n# lb = mid\r\n# return lb+1 #return index of elements 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#def 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#def suff(li):\r\n# suff_sum = [0]\r\n# for i in range(len(li)-1,-1,-1):\r\n# suff_sum.insert(0,suff_sum[0] + li[i])\r\n# return suff_sum\r\n#############\r\n#def maxSubArraySumI(arr): #Kadane's algorithm with index\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# start=0;end=0;s=0\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:\r\n# max_till_now=max_ending\r\n# start=s;end=i\r\n# if max_ending<0:\r\n# max_ending=0\r\n# s=i+1\r\n# return max_till_now,start,end\r\n############# avoid max for 2 elements - slower than direct if\r\n#def maxSubArraySum(arr): #Kadane's algorithm\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:max_till_now=max_ending\r\n# if max_ending<0:max_ending=0\r\n# return max_till_now\r\n#############\r\n#def findbits(x):\r\n# tmp=[]\r\n# while x>0:tmp.append(x%2);x//=2\r\n# tmp.reverse()\r\n# return tmp\r\n##############Dijkstra algorithm example\r\n#dg=[999999]*(n+1);dg[n]=0;todo=[(0,n)];chkd=[0]*(n+1)\r\n#while todo:#### find x with min dg in todo\r\n# _,x=hq.heappop(todo)\r\n# if chkd[x]:continue\r\n# for i in coming[x]:going[i]-=1\r\n# for i in coming[x]:\r\n# tmp=1+dg[x]+going[i]\r\n# if tmp 3\r\n#import statistics as stat # stat.median(a), mode, mean\r\nfrom math import gcd\r\nimport sys\r\ninput = sys.stdin.readline\r\n#print = sys.stdout.write\r\n#sys.setrecursionlimit(100000) #default is 1000 \r\n############ ---- Input Functions ---- ############\r\ndef inp():\r\n return(int(input()))\r\ndef inlt():\r\n return(list(map(int,input().split()))) #.split(','), default is space\r\n#list([0,*map(int,input().split(\" \"))]) # pad a zero to avoid zero indexing\r\ndef insr():\r\n s = input()\r\n return(list(s[:len(s) - 1]))\r\n####################################################\r\ndef phi(n): #Euler's totient function from Euler's product formula\r\n result = n;\r\n if (n%2 == 0):\r\n while (n % 2 == 0):n//=2;\r\n result //=2;\r\n p=3\r\n while(p*p <= n):\r\n if (n % p == 0):\r\n while (n % p == 0):n//=p;\r\n result -= result//p;\r\n p += 2;\r\n if (n > 1):\r\n result -= result//n;\r\n return result;\r\n#t=1\r\nn = int(input())\r\nphis=[0]\r\nfor i in range(1,n):\r\n phis.append(phi(i))\r\nans=0;mod=10**9+7\r\n\r\nfor d in range(1,n//2+1):\r\n for ncd in range(2,(n-1)//d+1):\r\n c=n-ncd*d\r\n ans+=c*d//gcd(c,d)*phis[ncd]\r\n ans%=mod\r\nprint(ans)\r\n \r\n#print(*ans,sep=' ')##print(\"{:.3f}\".format(ans)+\"%\")\r\n#:b binary :% eg print(\"{:6.2%}\".format(ans))\r\n#print(\" \".join(str(i) for i in ans))\r\n#print(\" \".join(map(str,ans))) #seems faster\r\n#print(a[0] if a else 0)\r\n#prefixsum a=[a1...an] #psa=[0]*(n+1)\r\n#for i in range(n): psa[i+1]=psa[i]+a[i]\r\n#sum[:ax]=psa[x+1] e.g. sum 1st 5 items in psa[5]\r\n#ASCII<->number ord('f')=102 chr(102)='f'\r\n#def binary_search(li, val, lb, ub):\r\n# while ((ub-lb)>1):\r\n# mid = (lb + ub) // 2\r\n# if li[mid] >= val:\r\n# ub = mid\r\n# else:\r\n# lb = mid\r\n# return lb+1 #return index of elements 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#def 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#def suff(li):\r\n# suff_sum = [0]\r\n# for i in range(len(li)-1,-1,-1):\r\n# suff_sum.insert(0,suff_sum[0] + li[i])\r\n# return suff_sum\r\n#############\r\n#def maxSubArraySumI(arr): #Kadane's algorithm with index\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# start=0;end=0;s=0\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:\r\n# max_till_now=max_ending\r\n# start=s;end=i\r\n# if max_ending<0:\r\n# max_ending=0\r\n# s=i+1\r\n# return max_till_now,start,end\r\n############# avoid max for 2 elements - slower than direct if\r\n#def maxSubArraySum(arr): #Kadane's algorithm\r\n# max_till_now=arr[0];max_ending=0;size=len(arr)\r\n# for i in range(0, size):\r\n# max_ending = max_ending + arr[i]\r\n# if max_till_now < max_ending:max_till_now=max_ending\r\n# if max_ending<0:max_ending=0\r\n# return max_till_now\r\n#############\r\n#def findbits(x):\r\n# tmp=[]\r\n# while x>0:tmp.append(x%2);x//=2\r\n# tmp.reverse()\r\n# return tmp\r\n##############Dijkstra algorithm example\r\n#dg=[999999]*(n+1);dg[n]=0;todo=[(0,n)];chkd=[0]*(n+1)\r\n#while todo:#### find x with min dg in todo\r\n# _,x=hq.heappop(todo)\r\n# if chkd[x]:continue\r\n# for i in coming[x]:going[i]-=1\r\n# for i in coming[x]:\r\n# tmp=1+dg[x]+going[i]\r\n# if tmp K \u306e\u7d04\u6570\u306e\u3046\u3061 K \u4ee5\u5916\u3092\u3072\u3068\u3064 k \u3068\u56fa\u5b9a\r\n k + k + ... + k = K\r\n l = K / k\r\n \u3053\u306e\u3068\u304d\u3001\u5206\u3051\u65b9\u306f phi(l)\r\n '''\r\n\r\n def make_divisors(n):\r\n lower_divisors , upper_divisors = [], []\r\n i = 1\r\n while i*i <= n:\r\n if n % i == 0:\r\n lower_divisors.append(i)\r\n if i != n // i:\r\n upper_divisors.append(n//i)\r\n i += 1\r\n return lower_divisors + upper_divisors[::-1]\r\n\r\n class Totient:\r\n def __init__(self, N:int) -> None:\r\n self.N = N\r\n self.enum_tortient = [i for i in range(N+1)]\r\n self.is_prime = [True] * (N + 1)\r\n self.is_prime[0] = False\r\n self.is_prime[1] = False\r\n for p in range(2, N+1):\r\n if self.is_prime[p]:\r\n self.enum_tortient[p] = p - 1\r\n for n in range(2*p, N+1, p):\r\n self.is_prime[n] = False\r\n self.enum_tortient[n] = self.enum_tortient[n] // p * (p - 1)\r\n def phi(self, K:int) -> int:\r\n assert(K <= self.N)\r\n return self.enum_tortient[K]\r\n\r\n N = iinput()\r\n ans = 0\r\n from math import gcd\r\n\r\n tot = Totient(N)\r\n for c in range(1, N-1):\r\n K = N - c\r\n for g in make_divisors(K)[:-1]:\r\n ans += c * tot.phi(K//g) * g // gcd(g, c)\r\n ans %= MOD\r\n print(ans)\r\n\r\nmain()"}, {"source_code": "''' E. Madoka and The Best University\nhttps://codeforces.com/contest/1717/problem/E\n'''\n\nimport io, os, sys\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # decode().strip() if str\noutput = sys.stdout.write\n\ndef debug(*args): \n if os.environ.get('debug') in [None, '0']: return\n from inspect import currentframe, getframeinfo\n from re import search\n frame = currentframe().f_back\n s = getframeinfo(frame).code_context[0]\n r = search(r\"\\((.*)\\)\", s).group(1)\n vnames = r.split(', ')\n var_and_vals = [f'{var}={val}' for var, val in zip(vnames, args)]\n prefix = f'{currentframe().f_back.f_lineno:02d}: '\n print(f'{prefix}{\", \".join(var_and_vals)}')\n\nfrom types import GeneratorType\ndef bootstrap(f, stack=[]):\n def wrappedfunc(*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 else:\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n return wrappedfunc\n\nclass IntKeyDict(dict):\n from random import randrange\n rand = randrange(1 << 62)\n def __setitem__(self, k, v): super().__setitem__(k^self.rand, v)\n def __getitem__(self, k): return super().__getitem__(k^self.rand)\n def __contains__(self, k): return super().__contains__(k^self.rand)\n def __repr__(self): return str({k: v for k, v in self.items()})\n def get(self, k, default=None): return super().get(k^self.rand, default)\n def keys(self): return [k^self.rand for k in super().keys()]\n def items(self): return [(k^self.rand, v) for k, v in super().items()]\n\nINF = float('inf')\n\n# -----------------------------------------\n\nMOD = 10**9 + 7\n\nfrom math import gcd\ndef lcm(a, b): return a * b // gcd(a, b)\n\n# iterate over c and g = gcd(a, b)\n# for each c and g, count num pairs of (a, b) s.t. a + b = N - c and gcd(a, b) = g\n# i.e. num pairs of (a', b') s.t. a' + b' == (N - c) // g and gcd(a', b') == 1\n# i.e. phi((N - c) // g)\n\ndef solve(N):\n phi = list(range(N + 1))\n phi[1] = 0\n for i in range(2, N + 1):\n if phi[i] == i: # prime\n for j in range(i, N + 1, i):\n phi[j] -= phi[j] // i\n \n res = 0\n for g in range(1, N):\n for s in range(g, N, g):\n c = N - s \n res = (res + lcm(c, g) * phi[(N - c) // g]) % MOD\n \n return res\n\n\ndef main():\n N = int(input())\n res = solve(N)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "''' E. Madoka and The Best University\nhttps://codeforces.com/contest/1717/problem/E\n'''\n\nimport io, os, sys\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline # decode().strip() if str\noutput = sys.stdout.write\n\ndef debug(*args): \n if os.environ.get('debug') in [None, '0']: return\n from inspect import currentframe, getframeinfo\n from re import search\n frame = currentframe().f_back\n s = getframeinfo(frame).code_context[0]\n r = search(r\"\\((.*)\\)\", s).group(1)\n vnames = r.split(', ')\n var_and_vals = [f'{var}={val}' for var, val in zip(vnames, args)]\n prefix = f'{currentframe().f_back.f_lineno:02d}: '\n print(f'{prefix}{\", \".join(var_and_vals)}')\n\nfrom types import GeneratorType\ndef bootstrap(f, stack=[]):\n def wrappedfunc(*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 else:\n stack.pop()\n if not stack: break\n to = stack[-1].send(to)\n return to\n return wrappedfunc\n\nclass IntKeyDict(dict):\n from random import randrange\n rand = randrange(1 << 62)\n def __setitem__(self, k, v): super().__setitem__(k^self.rand, v)\n def __getitem__(self, k): return super().__getitem__(k^self.rand)\n def __contains__(self, k): return super().__contains__(k^self.rand)\n def __repr__(self): return str({k: v for k, v in self.items()})\n def get(self, k, default=None): return super().get(k^self.rand, default)\n def keys(self): return [k^self.rand for k in super().keys()]\n def items(self): return [(k^self.rand, v) for k, v in super().items()]\n\nINF = float('inf')\n\n# -----------------------------------------\n\nMOD = 10**9 + 7\n\nfrom math import gcd\ndef lcm(a, b): return a * b // gcd(a, b)\n\n# iterate over c and g = gcd(a, b)\n# for each c and g, count num pairs of (a, b) s.t. a + b = N - c and gcd(a, b) = g\n# i.e. num pairs of (a', b') s.t. a' + b' == (N - c) // g and gcd(a', b') == 1\n# i.e. phi((N - c) // g)\n\ndef solve(N):\n phi = list(range(N + 1))\n phi[1] = 0\n for i in range(2, N + 1):\n if phi[i] == i: # prime\n for j in range(i, N + 1, i):\n phi[j] -= phi[j] // i\n\n lpf = list(range(N + 1))\n for i in range(2, N + 1):\n if lpf[i] == i:\n for j in range(i, N+1, i):\n if lpf[j] == j:\n lpf[j] = i\n\n res = 0\n for c in range(1, N):\n s = N - c\n\n # all factors of s\n facs = [1]\n res = (res + c * phi[N - c]) % MOD\n while s > 1:\n p = lpf[s]\n cnt = 0\n while s % p == 0:\n cnt += 1\n s //= p\n for i in range(len(facs)):\n for j in range(1, cnt + 1):\n f = facs[i] * p**j\n facs.append(f)\n res = (res + lcm(c, f) * phi[(N - c) // f]) % MOD\n \n return res\n\n\ndef main():\n N = int(input())\n res = solve(N)\n print(res)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "import sys\r\nimport math\r\n\r\nprimes = []\r\nis_prime = [True] * 100001\r\n\r\nQ = 0\r\n\r\ndef get_primes(n):\r\n global primes\r\n global Q\r\n global is_prime\r\n \r\n\r\n i=2\r\n while i*i <= n:\r\n if is_prime[i]:\r\n j = i\r\n while j*i<=n:\r\n is_prime[i*j] = False\r\n j += 1\r\n i += 1\r\n\r\n for i in range(2,n+1):\r\n if is_prime[i]:\r\n primes.append(i)\r\n Q += 1\r\n\r\ndef gcd(a, b):\r\n \r\n while b > 0:\r\n c = a % b\r\n a = b\r\n b = c\r\n \r\n return a\r\n\r\n\r\ndef fn(n):\r\n z = n\r\n f = n\r\n for p in primes:\r\n if is_prime[z]:\r\n break\r\n \r\n if z % p == 0:\r\n f = f * (p - 1) // p\r\n while z % p == 0:\r\n z = z // p\r\n \r\n if z > 1:\r\n f = f * (z - 1) // z\r\n\r\n #print('fn({}) = {}'.format(n, f))\r\n\r\n return f\r\n \r\n\r\ndef ccc(c, p, nc):\r\n # print(\"c={} p={} => {} * {}\".format(c,p, c * p // gcd(c,p), fn(nc // p)));\r\n return (E[nc // p] * c * p // gcd(c,p)) % M\r\n \r\n\r\ninput = sys.stdin.readline\r\nt = 1#int(input())\r\n\r\nM = 1000000007\r\n\r\n \r\nfor _test_ in range(t):\r\n\r\n n = int(input())\r\n get_primes(n)\r\n\r\n E = [0] * (n+1)\r\n for i in range(1,n+1):\r\n E[i] = fn(i)\r\n\r\n S = 0\r\n for c in range(1, n-1):\r\n nc = n - c\r\n i = 1\r\n while i*i <= nc:\r\n\r\n if nc % i == 0:\r\n\r\n p = i\r\n\r\n a = p\r\n b = c\r\n while b > 0:\r\n x = a % b\r\n a = b\r\n b = x\r\n lcm = c * p // a\r\n \r\n S = (S + E[nc // p] * lcm) % M\r\n \r\n i2 = nc // i\r\n \r\n if (i2 != i) and (i2 < nc):\r\n\r\n p = i2\r\n\r\n a = p\r\n b = c\r\n while b > 0:\r\n x = a % b\r\n a = b\r\n b = x\r\n lcm = c * p // a\r\n \r\n S = (S + E[nc // p] * lcm) % M\r\n \r\n \r\n i += 1\r\n\r\n print(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\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 math\r\n\r\n\r\ndef solve():\r\n n = int(input().strip())\r\n\r\n vis = [False for i in range(n + 1)]\r\n pri_cnt = [i for i in range(n + 1)]\r\n\r\n pri = [0, 1]\r\n for i in range(2, n + 1):\r\n if not vis[i]:\r\n pri.append(i)\r\n for j in range(i, n + 1, i):\r\n vis[j] = True\r\n pri_cnt[j] -= pri_cnt[j] // i\r\n\r\n # print('pri', pri)\r\n # print('pri_cnt', pri_cnt)\r\n\r\n ans = 0\r\n mod: int = 10 ** 9 + 7\r\n\r\n divs = [[] for i in range(n + 1)]\r\n\r\n for i in range(2, n + 1):\r\n for j in range(i + i, n + 1, i):\r\n divs[j].append(i)\r\n\r\n for a in range(1, n - 1):\r\n bc = n - a\r\n # print(bc, gcd_bc_list)\r\n temp = 0\r\n total = bc - 1\r\n for gcd_bc in divs[bc]:\r\n cnt = pri_cnt[bc // gcd_bc] % mod\r\n temp += cnt\r\n ans += (cnt * math.lcm(a, gcd_bc)) % mod\r\n ans %= mod\r\n ans += a * (total - temp) % mod\r\n ans %= mod\r\n # print(a, 'temp', temp, 'ans', ans)\r\n\r\n return ans\r\n\r\n\r\nif __name__ == '__main__':\r\n # t = int(input().strip())\r\n # for _ in range(t):\r\n print(solve())\r\n"}, {"source_code": "\r\nmaxN = 100005\r\ndivisors = [[] for _ in range(maxN)]\r\nfor d in range(1, maxN):\r\n d2 = d\r\n while d2 < maxN:\r\n divisors[d2].append(d)\r\n d2 += d\r\nfor d in range(1, maxN):\r\n divisors[d].reverse()\r\n\r\ndef get_gcd_and_cnts(m):\r\n # get all gcd and counts for a + b == m\r\n gcnts = dict()\r\n for d in divisors[m]:\r\n gcnts[d] = 0\r\n for d in divisors[m]:\r\n c = (m - 2 * d) // d + 1\r\n gcnts[d] += c\r\n c2 = gcnts[d]\r\n for i in range(1, len(divisors[d])):\r\n gcnts[divisors[d][i]] -= c2\r\n return gcnts\r\n\r\n\r\ndef lcm(x, y):\r\n g = gcd(x, y)\r\n return (x // g) * y\r\n\r\ndef main():\r\n \r\n MOD = int(1e9 + 7)\r\n n = int(input())\r\n ans = 0\r\n for c in range(1, n - 1):\r\n gcnts = get_gcd_and_cnts(n - c)\r\n for g, cnt in gcnts.items():\r\n ans += lcm(c, g) * cnt\r\n ans %= MOD\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": "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\nfrom time import *\r\nfrom random import *\r\nfrom math import gcd, lcm\r\n#dfs - stack#\r\n#check top!#\r\n\r\nphi = [i for i in range(100010)]\r\nfactors = [[1] for _ in range(100010)]\r\nphi[0] = phi[1] = 0\r\nfor i in range(2, 100010):\r\n if phi[i] == i:\r\n for j in range(i, 100010, i):\r\n phi[j] -= phi[j] // i\r\n jj = j\r\n cnt = 0\r\n while jj % i == 0:\r\n cnt += 1\r\n jj //= i\r\n \r\n k = len(factors[j])\r\n for kk in range(k):\r\n for p in range(1, cnt + 1):\r\n factors[j].append(factors[j][kk] * i ** p)\r\n#print(factors[:100])\r\n\r\nmod = 10 ** 9 + 7\r\n\r\ndef solve():\r\n n = II()\r\n res = 0\r\n for c in range(1, n - 1):\r\n for d in factors[n - c]:\r\n #print(n - c, d, (n - c) // d)\r\n res += lcm(c, d) * phi[(n - c) // d]\r\n res %= mod\r\n print(res)\r\n\r\nfor _ in range(1):solve()\r\n\r\n"}, {"source_code": "\nclass primes():\n def __init__(self, n):\n self.prime_num = n\n self.min_prime = [-1] * (self.prime_num + 1) # 2\u4ee5\u4e0a\u306e\u81ea\u7136\u6570\u306b\u5bfe\u3057\u3066\u6700\u5c0f\u306e\u7d20\u56e0\u6570\u3092\u8868\u3059\n self.min_prime[0] = 0\n self.min_prime[1] = 1\n i = 2\n self.prime = []\n self.memo_prifac = {}\n while i <= self.prime_num:\n if self.min_prime[i] == -1:\n self.min_prime[i] = i\n self.prime.append(i)\n for j in self.prime:\n if i * j > self.prime_num or j > self.min_prime[i]: break\n self.min_prime[j * i] = j\n i += 1\n\n def prifac(self, n):\n # \u7d20\u56e0\u6570\u5206\u89e3\u3057\u305f\u7d50\u679c\u3092\u8fd4\u3059\n if n in self.memo_prifac:\n return self.memo_prifac[n]\n res = {}\n x = n\n while x > 1:\n p = self.min_prime[x]\n if p in res:\n res[p] += 1\n else:\n res[p] = 1\n x //= p\n\n # self.memo_prifac[n] = res #\u5834\u5408\u306b\u3088\u3063\u3066\u306f\u3053\u306e\u884c\u3092\u6d88\u3059\u3068\u9ad8\u901f\u5316\n\n return res\n\n def divisors(self, n):\n # \u7d04\u6570\u5217\u6319 \u30e1\u30e2\u3057\u305f\u65b9\u304c\u3044\u3044\u304b\u3082\n if n== 1: return [1]\n prf = self.prifac(n)\n keys = [key for key in prf]\n\n def divsearch(i):\n if i == len(keys) - 1:\n return [keys[i] ** j for j in range(prf[keys[i]] + 1)]\n else:\n res = []\n subres = divsearch(i + 1)\n p = keys[i]\n for j in range(prf[p] + 1):\n for node in subres:\n res.append(node * p ** j)\n return res\n\n return divsearch(0)\n\n\nfrom math import gcd\ndef lcm(a,b):\n return a*b//gcd(a,b)\nmod=10**9+7\nn=int(input())\nans=0\npri=primes(n+3)\ndp=[0]*(n+3)\nfor c in range(1,n-1):\n k=n-c\n yaku=pri.divisors(k)\n yaku.sort(reverse=True)\n for g in yaku:\n m=k//g\n dp[g]=m-1\n for j in yaku:\n if j>g and j%g==0:dp[g]-=dp[j]\n ans+=(c*g//gcd(g,c))*dp[g]\n ans%=mod\n for g in yaku:dp[g]=0\nprint(ans)\n\n\n\n"}, {"source_code": "MOD = 10 ** 9 + 7\r\nn = int(input())\r\n\r\ndef gcd(x, y):\r\n while y != 0:\r\n x, y = y, x % y\r\n return x\r\n \r\ndef lcm(x, y):\r\n return x * y // gcd(x, y)\r\n\r\nans = 0\r\n\r\ndivisors = [[] for _ in range(n)]\r\nfor d in range(2, n):\r\n for m in range(2 * d, n, d):\r\n divisors[m].append(d)\r\n \r\n#print(divisors)\r\n\r\nrel_primes_with_sum = [0] * n\r\nfor s in range(1, n):\r\n rel_primes_with_sum[s] = s - 1\r\n for d in divisors[s]:\r\n rel_primes_with_sum[s] = (rel_primes_with_sum[s] - rel_primes_with_sum[d]) % MOD\r\n\r\n#print(rel_primes_with_sum)\r\n\r\nfor g in range(1, n):\r\n for s in range(g, n, g):\r\n ans = (ans + lcm(n - s, g) * rel_primes_with_sum[s // g]) % MOD\r\n \r\nprint(ans)"}, {"source_code": "import sys\r\n\r\ninput = sys.stdin.readline\r\nimport functools\r\nimport math\r\n\r\n\r\n\r\n\r\ndef lcm(a, b):\r\n return int(a * b / math.gcd(a, b))\r\n\r\n\r\nfor _ in range(1):\r\n\r\n n = int(input())\r\n\r\n ## \u4ece\u56e0\u5b50\u5165\u624b\uff0c\u83b7\u53d6\u6bcf\u4e2a\u6570\u7684\u56e0\u6570\r\n factor = [] * n\r\n for i in range(n + 1):\r\n factor.append([])\r\n for i in range(1, n + 1):\r\n k = 1\r\n while k * i <= n:\r\n factor[k * i].append(i)\r\n k += 1\r\n\r\n ## pairs[i]\u548c\u4e3ai\u7684\u4e24\u4e2a\u6570a, b\r\n ## \u6709\u591a\u5c11\u4e2aa\u548ci\u4e92\u8d28\r\n ## \u7528\u5230\u6b27\u62c9\u51fd\u6570\r\n pairs = [0] * n\r\n pairs[2] = 1\r\n for i in range(3, n):\r\n nums = i\r\n for small in factor[i]:\r\n # \u4fdd\u8bc1zhishu\r\n if len(factor[small]) == 2:\r\n nums *= (small - 1) / small\r\n pairs[i] = int(nums)\r\n\r\n\r\n ans = 0\r\n for i in range(1, n - 1):\r\n # \u56fa\u5b9ac\u4e3ai\uff0cab\u4e4b\u548c\u4e3asum\r\n sums = n - i\r\n # gcd(a, b) = gcd(a, sum)\r\n # \u904d\u5386sum\u7684\u56e0\u5b50\r\n for factors in factor[sums]:\r\n if factors != sums:\r\n # \u56e0\u5b50\u4e3afactors\u7684\u8bdd\r\n # gcd(a, sum) = factors => gcd(a // factors, sum // factors) = 1\r\n # \u90a3\u4e48\u8fd9\u6837\u7684a\u7684\u4e2a\u6570\u5c31\u662fpairs[sums // factors]\r\n ans += lcm(i, factors) * pairs[sums // factors]\r\n\r\n ans %= 1000000007\r\n\r\n # \u7279\u5224\r\n if n == 3:\r\n ans = 1\r\n print(ans)\r\n\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nfrom collections import *\r\nfrom math import gcd\r\n\r\ndef lcm(x, y):\r\n return x*y//gcd(x, y)\r\n\r\nn = int(input())\r\nans = 0\r\nMOD = 10**9+7\r\n\r\nfor c in range(1, n-1):\r\n divs = []\r\n \r\n for d in range(1, int((n-c)**0.5)+1):\r\n if (n-c)%d==0:\r\n divs.append(d)\r\n \r\n if d!=(n-c)//d:\r\n divs.append((n-c)//d)\r\n \r\n divs.sort(reverse=True)\r\n cnts = []\r\n \r\n for i in range(len(divs)):\r\n cnt = (n-c-1)//divs[i]\r\n \r\n for j in range(i):\r\n if divs[j]%divs[i]==0:\r\n cnt -= cnts[j]\r\n \r\n cnts.append(cnt)\r\n ans += lcm(c, divs[i])*cnt\r\n ans %= MOD\r\n \r\nprint(ans)"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\ninp = lambda : list(map(int,input().split()))\r\n\r\n\"\"\"\r\n\r\nlet g = gcd(a , b)\r\na + b + c = n\r\n\r\n(a + b) is a multiple of g\r\n\r\ntotal = (a + b) // g\r\ngcd(x , x + y) = gcd(x , y)\r\n\r\nso phi[total] sub be the pairs which are coprimes\r\n\r\n\"\"\"\r\n\r\nmod = (10 ** 9) + 7\r\ndef add(a , b):return ((a % mod) + (b % mod)) % mod\r\ndef mul(a , b):return ((a % mod) * (b % mod)) % mod\r\n\r\ndef Phi(n):\r\n\r\n global phi\r\n\r\n phi = [0 , 1]\r\n for i in range(2 , n + 1):\r\n phi.append(i - 1)\r\n\r\n for i in range(2 , n + 1):\r\n for j in range(2 * i , n + 1 , i):\r\n phi[j] -= phi[i]\r\n\r\n\r\nPhi(100001)\r\n\r\ndef gcd(a , b):\r\n if(b == 0):return a\r\n return gcd(b , a % b)\r\n\r\ndef lcm(a , b):\r\n\r\n return (a * b) // gcd(a , b)\r\n\r\ndef answer():\r\n\r\n ans = 0\r\n for g in range(1 , n + 1):\r\n for j in range(g , n + 1 , g):\r\n\r\n c = n - j\r\n val = lcm(c , g)\r\n\r\n if(j // g > 1):ans = add(ans , mul(val , phi[j // g]))\r\n \r\n\r\n return ans\r\n \r\n\r\n\r\nfor T in range(1):\r\n\r\n n = int(input())\r\n\r\n\r\n print(answer())\r\n\r\n"}, {"source_code": "def makediv(n):\r\n\tlower_divisors , upper_divisors = [], []\r\n\ti = 1\r\n\twhile i*i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\tlower_divisors.append(i)\r\n\t\t\tif i != n // i:\r\n\t\t\t\tupper_divisors.append(n//i)\r\n\t\ti += 1\r\n\treturn lower_divisors + upper_divisors[::-1]\r\n\r\n\r\nfrom math import gcd\r\nmod = 10**9 + 7\r\nn = int(input())\r\nans = 0\r\nfor c in range(1, n-1):\r\n\tw = makediv(n-c)\r\n\twm = len(w)\r\n\tdp = [0] * wm\r\n\tfor i in range(wm-1,-1,-1):\r\n\t\tdp[i] = (n-c) // w[i] - 1\r\n\t\tfor j in range(i+1,wm):\r\n\t\t\tif w[j] % w[i] == 0:\r\n\t\t\t\tdp[i] -= dp[j]\r\n\t\tans += c * w[i] * dp[i] // gcd(w[i], c)\r\n\t\tans %= mod\r\n\r\nprint(ans)"}, {"source_code": "import os,sys\r\nfrom random import randint, shuffle\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, permutations\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# ans = n + n // 2 * 2 + n // 3 * 2\r\n# print(ans)\r\n\r\n# for _ in range(int(input())):\r\n# n, k, r, c = list(map(int, input().split()))\r\n# ans = [['.'] * n for _ in range(n)]\r\n# r -= 1\r\n# c -= 1\r\n# for i in range(n):\r\n# for j in range(n):\r\n# if (i + j) % k == (r + c) % k:\r\n# ans[i][j] = 'X'\r\n# for i in range(n):\r\n# print(''.join(ans[i]))\r\n\r\n# for _ in range(int(input())):\r\n# def solve():\r\n# n = int(input())\r\n# a = list(map(int, input().split()))\r\n# b = list(map(int, input().split()))\r\n# for i in range(n):\r\n# if a[i] > b[i]:\r\n# print('NO')\r\n# return\r\n# if b[i] > b[(i + 1) % n] + 1 and a[i] < b[i]:\r\n# print('NO')\r\n# return\r\n# print('YES')\r\n# solve()\r\n\r\n# mod = 10 ** 9 + 7\r\n# N = 501000\r\n# fac = [1] * N\r\n# for i in range(2, N):\r\n# fac[i] = fac[i - 1] * i % mod\r\n# invfac = [1] * N\r\n# invfac[N - 1] = pow(fac[N - 1], mod - 2, mod)\r\n# for i in range(N - 1)[::-1]:\r\n# invfac[i] = invfac[i + 1] * (i + 1) % mod\r\n# def c(i, j):\r\n# return fac[i] * invfac[j] * invfac[i - j] % mod\r\n# n, k = list(map(int, input().split()))\r\n# if k >= n:\r\n# print(pow(2, n, mod))\r\n# else:\r\n# ans = 0\r\n# a = [0] * (k + 1)\r\n# for i in range(k + 1):\r\n# a[i] = c(n - 1, i)\r\n# ans = sum(a) * 2 - a[-1]\r\n# print(ans % mod)\r\n\r\nn = 30\r\ns = defaultdict(set)\r\n# s = set()\r\nans = 0\r\nfor i in range(1, n + 1):\r\n for j in range(1, n + 1):\r\n if n - i - j > 0:\r\n ans += 1\r\n s[math.gcd(i, j)].add(n - i - j)\r\n # s.add((math.gcd(i, j), n - i - j))\r\n# print(s, ans)\r\n\r\nN = int(pow(10 ** 9, 0.5)) + 5\r\ndef get_prime_linear(n):\r\n global cnt\r\n for i in range(2, n + 1):\r\n if not st[i]:\r\n primes[cnt] = i\r\n cnt += 1\r\n for j in range(n):\r\n if primes[j] > n / i: break\r\n st[primes[j] * i] = True\r\n if i % primes[j] == 0: break \r\nprimes, cnt, st = [0] * (N + 5), 0, [False] * (N + 5)\r\nget_prime_linear(N)\r\nprime1e3 = primes[:cnt]\r\n@lru_cache(None)\r\ndef get_factor(n):\r\n res = []\r\n for i in prime1e3:\r\n if i * i > n:\r\n break\r\n while n % i == 0:\r\n n //= i\r\n res.append(i)\r\n if n > 1:\r\n res.append(n)\r\n return set(res)\r\n\r\n@lru_cache(None)\r\ndef calc(k):\r\n cnt = k - 1\r\n s = list(get_factor(k))\r\n n = len(s)\r\n for i in range(1 << n):\r\n p = 1\r\n cnt1 = 0\r\n for j in range(n):\r\n if i >> j & 1:\r\n cnt1 += 1\r\n p *= s[j]\r\n if p != 1 and p != k:\r\n if cnt1 % 2:\r\n cnt -= k // p - 1\r\n else:\r\n cnt += k // p - 1\r\n return cnt\r\n\r\n# for i in range(1, 100):\r\n# cnt = 0\r\n# for j in range(1, i):\r\n# if math.gcd(j, i - j) == 1:\r\n# cnt += 1\r\n# print(i, calc(i), cnt)\r\n\r\ndef lcm(x, y):\r\n return x * y // math.gcd(x, y)\r\nn = int(input())\r\nans = 0\r\nst = set()\r\nfor g in range(1, n + 1):\r\n mx = n - 2 * g\r\n if mx > 0:\r\n for c in range(mx, -10, -g):\r\n if c <= 0: break\r\n k = (n - c) // g\r\n cnt = calc(k)\r\n ans += cnt * lcm(g, c)\r\nprint(ans % (10 ** 9 + 7))\r\n\r\n\r\n\r\n\r\n \r\n"}, {"source_code": "import os, sys\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\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# sys.setrecursionlimit(800)\r\n\r\nmod = 10 ** 9 + 7\r\nfrom copy import copy\r\n\r\nN = 10 ** 5 + 5\r\npf = [True for _ in range(N)]\r\nP = [[] for _ in range(N)]\r\nfor i in range(2, N):\r\n if not pf[i]:\r\n continue\r\n else:\r\n P[i].append(i)\r\n for j in range(2 * i, N, i):\r\n pf[j] = False\r\n P[j].append(i)\r\n\r\nd = [0] * N\r\nfor i in range(2, N):\r\n d[i] = i\r\n for j in P[i]:\r\n d[i] *= j - 1\r\n d[i] //= j\r\n\r\n\r\ndef sp(n):\r\n res = 0\r\n for v in range(1, n // 2 + 1):\r\n c = n - n // v * v\r\n if c == 0 and v != 1:\r\n continue\r\n if math.gcd(c, v) != 1:\r\n continue\r\n for k in range(c, n, v):\r\n t = (n - k) // v\r\n res += d[t] * v * k\r\n res %= mod\r\n return res\r\n\r\n\r\ndef solve():\r\n # for i in range(10):\r\n # print(i, sp(i))\r\n n = int(input())\r\n res = 0\r\n for i in range(1, n):\r\n if n % i == 0:\r\n k = n // i\r\n res += sp(k) * i\r\n print(res % mod)\r\n\r\nfor _ in range(1):\r\n solve()\r\n"}, {"source_code": "import itertools as it\nimport functools as ft\nfrom collections import Counter\nimport math\nfrom math import gcd\n\n\ndef linear_mul(n, g):\n res = [None for i in range(n+1)]\n res[0] = 0\n res[1] = 1\n \n sieve = [i for i in range(n+1)] #sieve[i] will store the smallest prime factor of i\n primes = []\n\n #this is needed to 'remove' coprime factors from the evaluation of f(i)\n #so that we can insert different powers\n count = [0 for i in range(n+1)] #count[i] = power k of p = spf(i); power of smallest prime factor of i\n \n for i in range(2,n+1):\n if sieve[i]==i:\n primes.append(i)\n res[i] = g(i, 1)\n count[i] = 1 #i is prime => i is the only prime factor of i\n \n for p in primes:\n u = i*p\n if u>n: break\n sieve[u] = p\n\n #check comes after we assign current value\n #if i%p==0: #these two are equivalent conditions\n if sieve[i]==p:\n #trickier case, we have to use `count` to remove smaller power of p\n #since p has multiplicity higher than 1\n #res[u] = res[i]//g(p,count[i]) * g(p,count[i]+1) #fails if res[i] is 0\n res[u] = res[i//(p**count[i])] * g(p,count[i]+1)\n count[u] = count[i] + 1\n pass\n else:\n res[u] = res[i] * g(p,1) #p is the smallest prime factor with multiplicity 1\n count[u] = 1\n pass\n return res, primes, sieve\n\n\nMAXN = 10**5\ntot, primes, sieve = linear_mul(MAXN, lambda p, q: (p - 1) * (p ** (q - 1)))\n\n#import sys\n#sys.setrecursionlimit(10**5+20)\n\ndef readInt():\n return int(input().strip())\n\ndef readInts():\n return list(map(int, input().strip().split()))\n\ndef read():\n return readInt(),\n\n\ndef f1(n):\n r = 0\n for a in range(1,n):\n r += gcd(a, n - a)\n return r\n\n# print([f1(i) for i in range(1,20+1)])\n\ndef f2(n, g):\n if n % g: return 0\n n //= g\n # r = 0\n # for a in range(1,n):\n # if gcd(a, n) == 1: r += 1\n r2 = tot[n]\n if n <= 1: r2 = 0\n # assert r == r2, (n, r, r2)\n # return r\n return r2\n\n\n# def solve1(n):\n# # return brute(n)\n# r = 0\n# # for g in range(1, n // 2):\n# # # gcd(a, b) = g\n# for g2 in range(1, n // 3 + 1):\n# # g2 = gcd(a, b, c)\n# for g in range(g2, n // 2 + 1, g2):\n# # g = gcd(a, b)\n# for c in range(g2, n + 1, g2):\n# if gcd(g, c) > g2: continue\n# # assert gcd(g, c) == g2\n# # a + b = n - c\n# r += (c * g // g2) * f2(n - c, g)\n# return r\n\n# def solve(n):\n# r = 0\n# for g2 in range(1, n // 3 + 1): # gcd(a, b, c)\n# if n % g2: continue\n# # for g in range(g2, n // 2 + 1, g2): # gcd(a, b), could also use n // 2 + 1\n# # for c in range(g2, n - g + 1, g2):\n# for i in range(1, n // (2 * g2) + 1):\n# # for j in range(1, (n - g2 * i) // g2 + 1):\n# for j in range(1, n // g2 - i + 1):\n# g, c = i * g2, j * g2\n# \n# if gcd(g, c) != g2: continue\n# # assert gcd(g, c) == g2\n# # a + b = n - c\n# if (n - c) % g != 0: continue\n# # assert (n - c) % g == 0\n# r += (c * g // g2) * f2((n - c) // g2, g // g2)\n# return r\n\nBASE = 10**9 + 7\n\ndef solve(n):\n r = 0\n for g2 in range(1, n // 3 + 1): # gcd(a, b, c)\n if n % g2: continue\n m = n // g2\n # for g in range(g2, n // 2 + 1, g2): # gcd(a, b), could also use n // 2 + 1\n # for c in range(g2, n - g + 1, g2):\n for i in range(1, m // 2 + 1):\n # for j in range(1, (n - g2 * i) // g2 + 1):\n # for j in range(1, m - i + 1):\n for j in range(m % i, m - i + 1, i):\n if j <= 0: continue\n # g, c = i * g2, j * g2\n\n if gcd(i, j) != 1: continue\n # assert gcd(g, c) == g2\n # a + b = n - c\n\n # if (m - j) % i != 0: continue # j = n // g2 = m (mod i)\n assert (m - j) % i == 0\n # assert (n - c) % g == 0\n r += (j * i * g2) * f2(m - j, i)\n return r % BASE\n\n# print(solve(10**5))\n# quit()\n\ndef brute(n):\n r = 0\n for a in range(1, n):\n for b in range(1, n - a):\n c = n - a - b\n assert 1 <= c <= n\n assert a + b + c == n\n g = gcd(a, b)\n r += c * g // gcd(c, g)\n return r\n\ndef test(*kargs, **kwargs):\n u = solve(*kargs, **kwargs)\n v = brute(*kargs, **kwargs)\n if u == v:\n return u\n\n if len(kwargs):\n print(kargs, kwargs, \"expected\", v, \"got\", u)\n else:\n print(kargs, \"expected\", v, \"got\", u)\n\n raise Exception\n\n\n# print([brute(i) for i in range(1,20+1)])\n\n# for i in range(1, 20 + 1):\n# # print(i, solve(i), brute(i))\n# print(i, test(i))\n# \n# quit()\n\n# quit() # Test if applicable\n\n\n\nwhile True:\n # try:\n if True:\n n, = read()\n # except EOFError: break\n print(solve(n))\n break\n"}, {"source_code": "import sys\r\ninput = lambda: sys.stdin.readline().rstrip()\r\nfrom math import gcd\r\nn = int(input())\r\nphi = list(range(n+1))\r\nfor i in range(2, n+1):\r\n if phi[i] == i:\r\n for j in range(i, n+1, i):\r\n phi[j] -= phi[j]//i\r\nans = 0\r\nMOD = 10**9+7\r\ndef f(m):\r\n g = gcd(m, n)\r\n res = 0\r\n k = 2\r\n while k*m < n:\r\n res += phi[k]*(n-k*m)\r\n res %= MOD\r\n k += 1\r\n return res * (m//g) % MOD\r\n\r\nfor i in range(1, n//2+1):\r\n ans = (ans+f(i))%MOD\r\nprint(ans)\r\n\r\n"}, {"source_code": "import math\r\n\r\nmod = 1000000007\r\n\r\nn = int(input())\r\nres = 0\r\nphi = list(range(0,n+1))\r\n\r\nfor i in range(1,n+1):\r\n for j in range(i*2,n+1,i):\r\n phi[j] -= phi[i]\r\n\r\nphi[1] = 0\r\n\r\nfor g in range(1,n+1):\r\n for sum_ab in range(g,n+1,g):\r\n c = n - sum_ab\r\n res += g // math.gcd(g,c) * c * phi[sum_ab//g]\r\n res %= mod\r\n\r\nprint(res)"}, {"source_code": "import io,os\nfrom math import gcd\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndic = [{} for _ in range(100001)]\n\n\nfor i in range(2,100001):\n\n curr = i - 1\n for key in dic[i]: curr -= dic[i][key]\n dic[i][1] = curr \n\n for j in range(2*i,100001,i):\n dic[j][j//i] = curr\n\n\n#print(dic[:13])\n\n\ndef main(t):\n\n\n n = int(input())\n\n M = 10 ** 9 + 7\n ans = 0\n for i in range(1,n):\n for key in dic[n-i]:\n l = key*i//gcd(key,i)\n ans += l * dic[n-i][key]\n ans %= M\n\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\nT = 1 #int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nimport functools\r\nimport math\r\n\r\na = [1,2,3]\r\na = a[::-1]\r\ndef lcm(a,b):\r\n return int(a * b / math.gcd(a,b))\r\n\r\n\r\nfor _ in range(1):\r\n \r\n\r\n n = int(input())\r\n factor = [] * n\r\n for i in range(n+1):\r\n factor.append([])\r\n for i in range(1,n+1):\r\n k = 1\r\n while k * i <= n:\r\n factor[k * i].append(i)\r\n k += 1\r\n pairs = [0] * n\r\n pairs[2] = 1\r\n for i in range(3,n):\r\n nums = i\r\n for small in factor[i]:\r\n if len(factor[small]) == 2:\r\n nums *= (small-1) / small\r\n \r\n \r\n \r\n pairs[i] = int(nums)\r\n ans = 0\r\n for i in range(1, n - 1):\r\n sums= n - i\r\n for factors in factor[sums]:\r\n if factors != sums:\r\n ans += lcm(i, factors) * pairs[ sums // factors]\r\n \r\n ans %= 1000000007\r\n \r\n\r\n if n == 3:\r\n ans = 1\r\n print(ans)\r\n \r\n\r\n \r\n \r\n\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nimport math\r\nimport copy\r\nimport bisect\r\nimport collections\r\nfrom collections import deque\r\nimport heapq\r\nfrom collections import defaultdict\r\nfrom collections import OrderedDict\r\nimport itertools\r\n\r\ndef my_lcm(x, y):\r\n return (x * y) // math.gcd(x, y)\r\n\r\ndef make_divisors(n):\r\n lower_divisors , upper_divisors = [], []\r\n i = 1\r\n while i*i <= n:\r\n if n % i == 0:\r\n lower_divisors.append(i)\r\n if i != n // i:\r\n upper_divisors.append(n//i)\r\n i += 1\r\n return lower_divisors + upper_divisors[::-1]\r\n\r\nn = int(input())\r\nans = 0\r\nmod = 10**9+7\r\nfor i in range(1,n-1):\r\n check = n-i\r\n s = make_divisors(check)\r\n dic = {}\r\n for j,k in enumerate(s):\r\n dic[k] = j\r\n check -= 1\r\n memo = [0]*(len(s)-1)\r\n for j in range(len(s)-2,-1,-1):\r\n memo[j] += check//s[j]\r\n for k in range(dic[s[j]]):\r\n if s[j] % s[k] == 0:\r\n memo[dic[s[k]]] -= memo[j]\r\n for j in range(len(memo)):\r\n ans += my_lcm(s[j], i)*memo[j]\r\n ans %= mod\r\nprint(ans)"}, {"source_code": "import math\r\nimport sys, os, io\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\ndef divisor(i):\r\n s = []\r\n for j in range(1, int(i ** (1 / 2)) + 1):\r\n if i % j == 0:\r\n s.append(i // j)\r\n s.append(j)\r\n return sorted(set(s))\r\n\r\ndef lcm(a, b):\r\n return a * b // math.gcd(a, b)\r\n\r\nn = int(input())\r\nmod = pow(10, 9) + 7\r\nans = 0\r\nfor i in range(2, n):\r\n c = n - i\r\n d = divisor(i)\r\n cnt = [(i - 1) // j for j in d]\r\n l = len(cnt) - 1\r\n for j in range(l - 1, -1, -1):\r\n cj, dj = cnt[j], d[j]\r\n for k in range(j + 1, l):\r\n if d[k] % dj:\r\n continue\r\n cj -= cnt[k]\r\n if cj:\r\n ans += lcm(dj, c) % mod * cj % mod\r\n ans %= mod\r\n cnt[j] = cj\r\nprint(ans)"}], "negative_code": [{"source_code": "n = int(input())\r\n\r\nif(n == 3):\r\n print(1)\r\n\r\nelif(n == 5):\r\n print(11)\r\n\r\nelif n == 69228:\r\n print(778304278)\r\n\r\nelif n == 228:\r\n print(3369368)\r\n\r\nelif n == 47:\r\n print(32596)\r\n\r\nelif n == 13:\r\n print(405)\r\n\r\nelif n == 1337:\r\n print(425608851)\r\n\r\nelif n == 100000:\r\n print(454535891)\r\n\r\nelif n == 94874:\r\n print(584783437)\r\n\r\nelif n == 99413:\r\n print(461761995)\r\n\r\nelif n == 99913:\r\n print(550761256)\r\n\r\nelif n == 4:\r\n print(4)\r\n\r\nelif n == 6:\r\n print(20)\r\nelif n == 7:\r\n print(42)\r\n \r\n \r\n"}, {"source_code": "n = int(input())\r\nif(n == 3):\r\n print(1)\r\nelif(n == 5):\r\n print(11)\r\nelif n == 69228:\r\n print(778304278)\r\nelif n == 228:\r\n print(3369368)\r\nelif n == 47:\r\n print(32596)\r\nelif n == 13:\r\n print(405)\r\nelif n == 1337:\r\n print(425608851)\r\nelif n == 100000:\r\n print(454535891)\r\nelif n == 94874:\r\n print(584783437)\r\nelif n == 99413:\r\n print(461761995)\r\nelif n == 99913:\r\n print(550761256)\r\nelif n == 4:\r\n print(4)\r\nelif n == 6:\r\n print(20)"}, {"source_code": "def main():\r\n from sys import stdin, setrecursionlimit\r\n # setrecursionlimit(1000000)\r\n input = stdin.readline\r\n def iinput(): return int(input())\r\n def sinput(): return input().rstrip()\r\n def i0input(): return int(input()) - 1\r\n def linput(): return list(input().split())\r\n def liinput(): return list(map(int, input().split()))\r\n def miinput(): return map(int, input().split())\r\n def li0input(): return list(map(lambda x: int(x) - 1, input().split()))\r\n def mi0input(): return map(lambda x: int(x) - 1, input().split())\r\n INF = 1000000000000000000\r\n MOD = 1000000007\r\n\r\n '''\r\n c \u3092\u56fa\u5b9a\r\n a + b = N - c = K \u306f gcd(a, b) \u3067\u5272\u308a\u5207\u308c\u308b -> K \u306e\u7d04\u6570\u306e\u3046\u3061 K \u4ee5\u5916\u3092\u3072\u3068\u3064 k \u3068\u56fa\u5b9a\r\n k + k + ... + k = K\r\n l = K / k\r\n \u3053\u306e\u3068\u304d\u3001\u5206\u3051\u65b9\u306f phi(l)\r\n '''\r\n\r\n def make_divisors(n):\r\n lower_divisors , upper_divisors = [], []\r\n i = 1\r\n while i*i <= n:\r\n if n % i == 0:\r\n lower_divisors.append(i)\r\n if i != n // i:\r\n upper_divisors.append(n//i)\r\n i += 1\r\n return lower_divisors + upper_divisors[::-1]\r\n\r\n class Totient:\r\n def __init__(self, N:int) -> None:\r\n self.N = N\r\n self.enum_tortient = [i for i in range(N+1)]\r\n self.is_prime = [True] * (N + 1)\r\n self.is_prime[0] = False\r\n self.is_prime[1] = False\r\n for p in range(2, N+1):\r\n if self.is_prime[p]:\r\n self.enum_tortient[p] = p - 1\r\n for n in range(2*p, N+1, p):\r\n self.is_prime[n] = False\r\n self.enum_tortient[n] = self.enum_tortient[n] // p * (p - 1)\r\n def phi(self, K:int) -> int:\r\n assert(K <= self.N)\r\n return self.enum_tortient[K]\r\n\r\n N = iinput()\r\n ans = 0\r\n from math import gcd\r\n\r\n tot = Totient(N)\r\n for c in range(1, N-1):\r\n K = N - c\r\n for g in make_divisors(K)[:-1]:\r\n ans += c * tot.phi(K//g) * g // gcd(g, c)\r\n print(ans)\r\n\r\nmain()"}], "src_uid": "c3694a6ff95c64bef8cbe8834c3fd6cb"} {"nl": {"description": "In some game by Playrix it takes t minutes for an oven to bake k carrot cakes, all cakes are ready at the same moment t minutes after they started baking. Arkady needs at least n cakes to complete a task, but he currently don't have any. However, he has infinitely many ingredients and one oven. Moreover, Arkady can build one more similar oven to make the process faster, it would take d minutes to build the oven. While the new oven is being built, only old one can bake cakes, after the new oven is built, both ovens bake simultaneously. Arkady can't build more than one oven.Determine if it is reasonable to build the second oven, i.e. will it decrease the minimum time needed to get n cakes or not. If the time needed with the second oven is the same as with one oven, then it is unreasonable.", "input_spec": "The only line contains four integers n, t, k, d (1\u2009\u2264\u2009n,\u2009t,\u2009k,\u2009d\u2009\u2264\u20091\u2009000)\u00a0\u2014 the number of cakes needed, the time needed for one oven to bake k cakes, the number of cakes baked at the same time, the time needed to build the second oven. ", "output_spec": "If it is reasonable to build the second oven, print \"YES\". Otherwise print \"NO\".", "sample_inputs": ["8 6 4 5", "8 6 4 6", "10 3 11 4", "4 2 1 4"], "sample_outputs": ["YES", "NO", "NO", "YES"], "notes": "NoteIn the first example it is possible to get 8 cakes in 12 minutes using one oven. The second oven can be built in 5 minutes, so after 6 minutes the first oven bakes 4 cakes, the second oven bakes 4 more ovens after 11 minutes. Thus, it is reasonable to build the second oven. In the second example it doesn't matter whether we build the second oven or not, thus it takes 12 minutes to bake 8 cakes in both cases. Thus, it is unreasonable to build the second oven.In the third example the first oven bakes 11 cakes in 3 minutes, that is more than needed 10. It is unreasonable to build the second oven, because its building takes more time that baking the needed number of cakes using the only oven."}, "positive_code": [{"source_code": "import math\ndef solve():\n n, t, k, d = map(int, input().split())\n x = math.ceil(d/t) \n y = int(x * t) \n rounds_needed = 0 \n if d == y: rounds_needed = 1\n group_ks = math.ceil(n/k)\n if group_ks - x > rounds_needed:\n print('YES')\n else:\n print('NO')\nsolve()"}, {"source_code": "n,t,k,d=map(int,input().split())\nn=int(n)\nt=int(t)\nk=int(k)\nd=int(d)\ncakes=0\nt1=0#time if we use one oven\nwhile cakesd: #new oven has been built and new clock starts for new oven\n t3+=1\n if t3!=0 and t3%t==0:#it counts cakes for second oven after it is built\n cakes+=k\nif t2 x[2]:\n print('YES')\n else:\n print('NO')\n\n\n\n"}, {"source_code": "n, t, k, d = map(int, input().split())\n\ncart = 0\nwhile cart <= d:\n\tn -= k\n\tcart += t\n\nif n > 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"No\")\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nz=(k/t)\na=0\nb=(k/t)*d\nt1=0\nt2=d\nwhile(a 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n, m, k, o = [int(x)for x in input().split()]\nt = (n//k)*m \nif n<=k:\n print(\"No\")\nelse:\n t1 = 0\n n1 = 0\n while(t1<=o):\n t1+=m \n n1+=k \n if n1>=n:\n print(\"No\")\n else:\n print(\"Yes\")\n "}, {"source_code": "n, t, k, d = map(int, input().strip().split())\nsum1 = 0\nsum2 = 0\nif (n % k == 0):\n sum1 = int(n / k)\nelse:\n sum1 = int(n / k) + 1\ntime1 = sum1 * t\nnum1 = int(d / t)\nnum2 = d % t\nif ((n - k * num1) % (2 * k) == 0):\n sum2 = int((n - k * num1) / (2 * k))\nelse:\n sum2 = int((n - k * num1) / (2 * k) + 1)\ntime2 = d + sum2 * t\nif (time1 > time2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import math\n\ninput=[int(x) for x in input().split()]\n\ng=math.ceil(input[0]/input[2])\n\nsingleOven=g*input[1]\n \no1=0\no2=input[3]\n\nfor i in range(g):\n if o1<=o2:\n o1+=input[1]\n else:\n o2+=input[1]\n\nif max(o1, o2) < singleOven:\n print(\"YES\")\nelse:\n print(\"NO\")\n "}, {"source_code": "n,t,k,d=map(int,input().split())\nt1=0\na=n\nwhile a>0:\n a=a-k\n t1+=t \nt2=0\no2=0\nwhile True:\n t2+=1\n \n if t2%t==0:\n n=n-k\n if o2==1 and (t2-d)%t==0:\n n=n-k\n if t2==d:\n o2=1\n if n<=0:\n break\n \nif t2= n:\n t_min = tx\n break\n\n\n\n if t_min < t1:\n return \"YES\"\n else:\n return \"NO\"\n\n\n\nif __name__ == '__main__':\n print(main())\n"}, {"source_code": "import sys\nimport math\n\n\ndef readlines(type=int):\n return list(map(type, sys.stdin.readline().split()))\n\n\ndef read(type=int):\n return type(sys.stdin.readline().strip())\n\n\njoint = lambda it, sep=\" \": sep.join(\n [str(i) if type(i) != list else sep.join(map(str, i)) for i in it])\n\n\ndef solve_naive(n, t, k, d):\n n_mul = (n * t) // k + 1\n t_muls = set()\n for i in range(1, n_mul + 1):\n t_muls.add(t * i)\n t_muls.add((t * i) + d)\n t_muls = sorted(list(t_muls))\n for mul in t_muls:\n yeild = k * ((mul // t) + (mul - d) // t)\n if yeild >= n:\n # mulc = mul\n break\n # print(t_muls)\n # print(mul, f\"{t * math.ceil(n / k)=}\", n, k, t)\n # print(f\"{mul=}\")\n if mul < t * math.ceil(n / k):\n return \"YES\"\n return \"NO\"\n\n\ndef solve(n, t, k, d):\n timet = (n * t + k * d) / (2 * k)\n c1 = math.ceil(timet / t) * t\n c2 = (math.ceil((timet - d) / t) * t) + d\n # print(f\"{c1=} {c2=}\")\n if c1 < t * math.ceil(n / k) and k * ((c1 // t) + (c1 - d) // t) >= n:\n return \"YES\"\n if c2 < t * math.ceil(n / k) and k * ((c2 // t) + (c2 - d) // t) >= n:\n return \"YES\"\n # if c2 < t * math.ceil(n / k):\n # return \"YES\"\n return \"NO\"\n\n\ndef main():\n args = readlines()\n # print(solve_naive(*args))\n print(solve(*args))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "#####--------------Template Begin-------------------####\nimport math\nimport sys\n#input = sys.stdin.readline\ndef i(): #Regular input\n\treturn input()\ndef ii(): #integer input\n\treturn int(input())\ndef li(): #list input\n\treturn input().split()\ndef mi(): #map input\n\treturn list(map(int, input().split()))\n#####---------------Template Ends-------------------######\nn,t,k,d=mi()\nc=(math.floor(d/t)+1)*k\nif c>=n:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\na = math.ceil(d/t)\nn=n-(a*k)\nif n>0:\n if d%t!=0:\n print(\"YES\")\n else:\n if n>k:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nq,w=(n+k-1)//k,(d+t-1)//t\nprint(\"YES\"if q*t>w*t+(q-w+1)//2*t-(w*t-d)*(q-w==1) else\"NO\")"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\ng=(n+k-1)//k\no1,o2=0,d\n\nfor i in range(g):\n\tif o1<=o2:\n\t\to1+=t\n\telse:\n\t\to2+=t\nif max(o1,o2) 0:\n n -= k\n t1 += t\n if n <= 0:\n break\n if t1 > d:\n n-=k\n t2+=t\n if n <= 0:\n break\nif t1 < fi or (t2 < fi and t2 != d):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,t,k,d = map(int,raw_input().split())\nr = n/k\nif n%k != 0: r+=1\n# print r,t,(r-1)*t,k\nif d < (r-1)*t: print \"YES\"\nelse: print \"NO\""}, {"source_code": "n,t,k,d=map(int,raw_input().split())\nprint\"YES\"if((d+t)/t)*k 0:\n\t\twith_new += t * (remain//(k*2))\n\t\t\nelse:\n\twith_new += t\n\tremain = remain - k\n\tif remain > 0:\n\t\twith_new += t * (remain//(k*2)) + t\n\t\nif with_new < without_new and flag:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "import sys\nimport math\n\n\ndef readlines(type=int):\n return list(map(type, sys.stdin.readline().split()))\n\n\ndef read(type=int):\n return type(sys.stdin.readline().strip())\n\n\njoint = lambda it, sep=\" \": sep.join(\n [str(i) if type(i) != list else sep.join(map(str, i)) for i in it])\n\n\ndef solve_naive(n, t, k, d):\n n_mul = (n * t) // k + 1\n t_muls = set()\n for i in range(1, n_mul + 1):\n t_muls.add(t * i)\n t_muls.add((t * i) + d)\n t_muls = sorted(list(t_muls))\n for mul in t_muls:\n yeild = k * ((mul // t) + (mul - d) // t)\n if yeild >= n:\n # mulc = mul\n break\n # print(t_muls)\n # print(mul, f\"{t * math.ceil(n / k)=}\", n, k, t)\n # print(f\"{mul=}\")\n if mul < t * math.ceil(n / k):\n return \"YES\"\n return \"NO\"\n\n\ndef solve(n, t, k, d):\n timet = (n * t + k * d) / (2 * k)\n c1 = math.ceil(timet / t) * t\n c2 = (math.ceil((timet - d) / t) * t) + d\n # print(f\"{c1=} {c2=}\")\n if c1 < t * math.ceil(n / k) and k * ((c1 // t) + (c1 - d) // t) >= n:\n return \"YES\"\n if c2 < t * math.ceil(n / k) and k * ((c2 // t) + (c2 - d) // t) >= n:\n return \"YES\"\n # if c2 < t * math.ceil(n / k):\n # return \"YES\"\n return \"NO\"\n\n\ndef main():\n args = readlines()\n # print(solve_naive(*args))\n print(solve(*args))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,t,k,d = map(int,raw_input().split())\n\ne = 0\nt1 = t\nwhile e < n:\n t1 += t\n e += k\n\na = t1 -t\n\nt1 = t\nt2 = t+d\nb = 0\ne = 0\nwhile e < n:\n if t1 < t2:\n b = t1\n t1 += t\n else:\n b = t2\n t2 += t\n e += k\n\nif b < a:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "\nimport fileinput\nfirstLine=True\nfor line in fileinput.input():\n\tsplitLine=line.strip().split(\" \")\n\tif firstLine:\n\t\t(n,t,k,d)= (int(splitLine[0]),int(splitLine[1]),int(splitLine[2]),int(splitLine[3]))\n\t\tfirstLine=False\n\t\tif ((d+t)/t)*k<(n):\n\t\t\tprint \"YES\"\n\t\telse:\n\t\t\tprint \"NO\"\n\t\texit()\n\telse: exit()"}, {"source_code": "import math\nbuild_oven = \"NO\"\nn,t,k,d = map(int,input().split())\nbaking_time = math.ceil(n / k) * t\no1 = t; o2 =t+d\n# baked = 0\nfor i in range(baking_time):\n if o1 == 0 :\n n -= k\n o1 = t\n \n if o2 == 0 :\n n-=k \n o2 = t\n \n if n<1:\n # print(i,n)\n build_oven = \"YES\"\n # break\n o1 -=1\n o2 -=1\n # print(i ,o1,o2,n)\n\n\n \n \nprint(build_oven)\n\n"}, {"source_code": "n, t, k, d = map( int, input().split() )\nclk = 0\ns = 0\nwhile s < n:\n s += k\n clk += t\nclk2 = 0\nlb, ub = 0, int( 1e10 )\nwhile lb <= ub:\n mid = lb + ub >> 1\n s = mid // t * k + max( 0, mid - d ) // t * k\n if s >= n:\n clk2 = mid\n ub = mid - 1\n else:\n lb = mid + 1\n\nprint( [ \"NO\", \"YES\" ][ clk > clk2 ] )\n"}, {"source_code": "n, t, k, d = map(int, input().split())\nimport math\n\nwithout = math.ceil(n / k) * t\ntwo_oven = math.ceil(d / t) * k\n\nif two_oven < n:\n n -= two_oven\n two_oven = d + math.ceil(n / (2 * k)) * t\nelse:\n two_oven = 1000000\n\nif without <= two_oven:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n\n\n"}, {"source_code": "n,t,k,d= [int(x) for x in input().split(' ')];\ntime1=n//k*t;\nif(n%k!=0):time1=time1+t;\na=0;b=d;\nwhile(n>0):\n if (atime2):\n print('Yes');\nelse:\n print('No');"}, {"source_code": "import math\n\nn, t, k, d = list(map(int, input().split()))\nt1 = math.ceil(n / k) * t\na = d // t\nb = n - (a * k)\nb /= 2\nt2 = d + math.ceil(b / k) * t\nprint('YES' if t2 < t1 else 'NO')"}, {"source_code": "from math import ceil\nn, t, k, d = map(int, raw_input().split())\n\nreq = ceil(float(n)/float(k)) * t \n#print req \n\npd2 = d / t * k \ntime = d\n\n#print pd2 \n\nwhile pd2 < n :\n time += 1 \n if (time - d) % t == 0:\n pd2 += k \n if time % t == 0:\n pd2 += k \n #print time, pd2\n \n#print time -1\nif (time >= req):\n print 'NO'\nelse :\n print 'YES'"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\nfot=math.ceil(n/k)*t\nif t>d:\n if kk:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")"}, {"source_code": "from math import *\nn,t,k,d=list(map(int,input().split()))\n\nneed =ceil(n/k)*t\nneed1=t+d\nif need>need1:print(\"YES\")\nelse:print(\"NO\")\n"}, {"source_code": "data = input('').split(' ')\n\nn, t, k, d = [int(i) for i in data]\n\nsum = 1 if n%k != 0 else 0\n\ntime_one_oven = (n//k + sum) * t\ntime_build_oven = d + t\n\nif time_build_oven < time_one_oven:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\nn, t, k, d = map(int, input().split())\nsingle = math.ceil(n / k) * t\ndouble = 0\ncakes = 0\ntime = 0\nwhile cakes < n:\n time += 1\n if time > d:\n if (time - d) % t == 0:\n cakes += k\n\n if cakes >= n:\n break\n\n if time % t == 0:\n cakes += k\n\n\nif time < single:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import operator as op\nimport 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 functools import reduce\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\ndef def_value():\n return 0\n\n\ndef time_lagbe(n, k, t):\n if n == 0:\n return 0\n if k > n:\n return t\n time1 = (n // k)*t + (n % k)*t\n return time1\n# For getting input from input.txt file\n#sys.stdin = open('input.txt', 'r')\n# Printing the Output to output.txt file\n#sys.stdout = open('output.txt', 'w')\n\n\nn, t, k, d = invr()\n\nTIME = [0]*10001\nTIME2 = [0]*10001\n\nfor i in range(t, 10001, t):\n\n TIME[i] = k*(i//t)\n\nfor i in range(d+t, 10001, t):\n TIME2[i] = k * (i//t) * 2\nres = \"NO\"\nfor i in range(10001):\n if TIME[i] < n:\n if TIME2[i] > TIME[i]:\n res = \"YES\"\n break\n else:\n break\nprint(res)\n"}, {"source_code": "from math import ceil\nn,t,k,d=map(int,raw_input().split())\nt1=int(ceil(n*1.0/k)*t)\nif d=a):\n break \n time+=1 \n if(time>d and time%b==0):\n cakes+=c \n if(cakes>=a):\n break \n if(time%b==0):\n cakes+=c \noven2=time\nif(oven2= 1):\n\tmult += 1\n\nno = mult * t\n\nyesCount = n\nyes = d\n\nyesCount -= ((d//t)*k) # 10\n\n\nwhile(yesCount > 0):\n\tyesCount -= (k*2)\n\tyes += t\nif(k >= n):\n\tprint(\"NO\")\nelse:\n\tif(no <= yes):\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n"}, {"source_code": "n, t, k, d = map(int, raw_input().split())\n\na = (n + k - 1) / k * t\n\nb = d + t\n\nprint 'YES' if b < a else 'NO'\n"}, {"source_code": "n,t,k,d = map(int,input().split(\" \"))\nm = (n + k-1)//k\noven1 ,oven2 = 0,d\nfor i in range(m):\n if oven1<=oven2:\n oven1+=t\n else:\n oven2+=t\n\nif max(oven1,oven2)>=(m*t):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "from math import *\nfrom collections import *\nimport sys\nsys.setrecursionlimit(10**9)\nmod = 10**9 + 7\n\nn,t,k,d = map(int,input().split())\nif(k >= n):\n print(\"NO\")\nelse:\n s = (d//t)*k\n if(s < n-k):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "[n,t,k,d] = map(int, raw_input().strip().split())\n\nwithout_new = 0\nwith_new = d\n\nif n%k == 0:\n\twithout_new = t * (n//k)\nelse:\n\twithout_new = t * (n//k) + t \n\nremain = n - (((d//t)+1)*k)\n\n\nflag = True\nif remain <= 0:\n\tflag = False\n\nif remain%k == 0:\n\twith_new += t\n\tremain = remain - k\n\tif remain > 0:\n\t\twith_new += t * (remain//(k*2))\n\t\t\nelse:\n\twith_new += t\n\tremain = remain - k\n\tif remain > 0:\n\t\twith_new += t * (remain//(k*2)) + t\n\t\nif with_new < without_new and flag:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "import math\nn,t,k,d = map(int,raw_input().split())\np1 = math.ceil(n*1.0/k)*t\na = d/t\nb = d%t\nc = int(math.ceil(n*1./k)-a)\n#print a,b,c\nif c%2==0:\n\tif a==0:\n\t\tp2 = d+c/2*t\n\telse:\n\t\tp2 = (a+c/2)*t\nelse:\n\tif a==0:\n\t\tp2 = d+c/2*t+t\n\telse:\n\t\tp2 = (a+c/2+1)*t\n#print p1,p2\nprint 'YES' if p1 > p2 else 'NO'"}, {"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\nn , t , k , d = tup()\nx = ceil(n/k)*t\nc =0 \nwhile 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 \nif n >0:print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "n, t, k, d = map(int, raw_input().split())\n# k * s >= n\n# s >= n / k\ns = -1\nif n % k == 0:\n s = n / k\nelse:\n s = n / k + 1\nT1 = s * t\nfor i in range(0, T1):\n T2 = i\n total = 0\n total += T2 / t * k\n total += max(0, T2 - d) / t * k\n if total >= n:\n print 'YES'\n exit(0)\nprint 'NO'"}, {"source_code": "import math \nn,t,k,d = map(int,raw_input().split())\ntot = math.ceil(n/float(k))*t\nrr = (d+td+t else \"NO\")"}, {"source_code": "#input\nn,t,k,d =map(int,input().split())\n\n#number of batch for first oven\nbatch=0\nif k(t+d)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "x=[int(x) for x in input().split(\" \")]\n\nn=int((x[0]+(x[2]-1))/x[2])\no1=0\no2=x[3]\nfor i in range(n):\n if(o1<=o2):\n o1+=x[1]\n else:\n o2+=x[1]\n\nif(max(o1,o2) 0 :\n print(\"YES\")\nelse :\n print(\"No\")\n# print(n)\n"}, {"source_code": "import math\n\nn, t, k, d = map(int, raw_input().split())\nblocks = int(math.ceil((n * 1.0) / k))\nwithout = blocks * t\na, b = 0, d\nwhile blocks > 0:\n if a < b:\n a += t\n else:\n b += t\n blocks -= 1\nwithoven = max(a, b)\n\nif withoven < without:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import math\n\nn, t, k, d = map(int, raw_input().split())\n\nans = 'NO'\nif 1.*n/k > 1:\n rounds = math.ceil(1. * n / k)\n t1 = rounds*t\n rounds_during_build = d/t\n rounds_after_build = rounds - rounds_during_build\n t2 = max((rounds_during_build + (rounds_after_build+1)/2)*t, rounds_after_build/2*t+d)\n # print t1, t2\n if t2 < t1:\n ans = 'YES'\nprint ans"}, {"source_code": "n,t,k,d = map(int, input().split())\n\nif int((n-1)/k)*t > d:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a = list(map(int,input().split()))\nn = a[0]\nt = a[1]\nk = a[2]\nd = a[3]\nimport math\n\ncount_1 = math.ceil(n / k) * t \ncount_2 = d + t\nif count_1 > count_2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n"}, {"source_code": "n, t, k, d = map(int, raw_input().split())\nx = 0\nfor i in range(n, 0, -k): x += t\nc = (x - 1) / t * k\nif (x - 1 >= d): c += (x - 1 - d) / t * k\nprint 'YES' if (c >= n) else 'NO'"}, {"source_code": "import math as m\n\nn, t, k, d = map(int, input().split())\nfirst, count = m.ceil(n / k) * t, 0\nwhile (n > 0):\n count += 1\n if (count % t == 0):\n n -= k\n if ((count - d) % t == 0 and count>d):\n n -= k\n\nprint('YNEOS'[(first <= count)::2])\n"}, {"source_code": "import math\n\n\nn,t,k,d=map(int,raw_input().split())\n\nx=math.ceil(n/float(k))*t\n\nif(x>t+d):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "def cake ():\n \n inp=list(map(int,input().strip().split()))\n n=inp[0]\n t=inp[1]\n k=inp[2]\n d=inp[3] \n x=int((n-1)/k+1)\n if (t*x)>(t+d):\n return(\"YES\")\n else :\n return(\"NO\") \nprint(cake())\n "}, {"source_code": "n,t,k,d=map(int,raw_input().split())\ny=n/k\nif n%k>0:\n y+=1\nx=y*t\nz=0\nfor i in range(1,1000001):\n if i%t==0:\n n-=k\n if i>d and (i-d)%t==0:\n n-=k\n if n<=0:\n z=i\n break\n# print x,z\nif z d+t:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n, t, k, d = map(int, raw_input().split())\np = (d + t) / t \nprint \"YES\" if k * p < n else \"NO\"\n"}, {"source_code": "import math\n\nn, t, k, d = map(int, input().split())\n\ns1 = math.ceil(n/k)*t\n\nc = 0\n\nup = 1000*t\ndown = 0\n\nwhile up > down+1:\n mid = (up+down)//2\n c += (mid//t)*k\n c += ((mid-d)//t)*k\n if c>=n:\n up = mid\n else:\n down = mid\n c = 0\n\nc = 0\n##print('up', up)\n##print('down', down)\n##print('mid', mid)\n\nif (down//t)*k + ((down-d)//t)*k == n:\n s2 = down\nelif (mid//t)*k + ((mid-d)//t)*k == n:\n s2 = mid\nelse:\n s2 = up\n\n##print('s1', s1)\n##print('s2', s2)\nif s2= ovenBuildTime:\n cycle2 = (j % bakingTime) + 1\n if cycle2 == bakingTime:\n readyCakes += cakesRound\n j += 1\n i += 1\n\ntotalTime2 = i\n\nif totalTime2 < totalTime1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\ndef carrotCakes(n, t, k, d):\n t1, t2 = 0, d\n for i in range(math.ceil(n / k)):\n if t1 <= t2: t1 += t\n else: t2 += t\n if max(t1, t2) < math.ceil(n / k) * t: print('YES')\n else: print('NO')\n\ndef main():\n n, t, k, d = (int(i) for i in input().split())\n carrotCakes(n, t, k, d)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\ng=(n+k-1)//k\no1,o2=0,d\n\nfor i in range(g):\n\tif o1<=o2:\n\t\to1+=t\n\telse:\n\t\to2+=t\nif max(o1,o2)0):\n if(atime2): print(\"YES\");\nelse: print(\"NO\");"}, {"source_code": "N, T, K, D = input().split(\" \")\n\nn, t, k, d = int(N), int(T), int(K), int(D)\n\ng = int((n+k-1) / k)\n\no1 = 0\no2 = d\n\nfor i in range(0, g):\n if o1 <= o2:\n o1 += t\n else:\n o2 += t\n\nT1 = max(o1, o2)\nT2 = g * t\n\nprint(\"YES\") if T1 < T2 else print(\"NO\")\n"}, {"source_code": "n, t, k, d = (int(x) for x in input().split())\nimport math\nif k >= n:\n print('NO')\nelse:\n t_1 = t*(math.ceil(n/k))\n# t_2 = d + t*(n-d*k/t)/k/2\n if d % t == 0:\n # t_2 = d + t*(n-k)/k/2\n x = d/t\n m = x*k\n t_2 = x*t\n while m < n:\n t_2 += t\n m += 2*k\n elif d < t:\n m = k\n t_2 = t\n while m < n:\n t_2 += d\n m += k\n if m t:\n # x = math.ceil(d/t)\n x = d//t\n # t_2 = x*t\n t_2 = (x+1)*t\n # m = x*k\n m = (x+1)*k\n while m < n:\n # t_2 += d-(x-1)*t\n t_2 += d-x*t\n m += k\n if m < n:\n # t_2 += x*t-d\n t_2 += (x+1)*t-d\n m += k\n # print(t_1)\n # print(t_2)\n if t_1 > t_2:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "PROBLEM = \"A\"\nFILE = \"%s\" %(PROBLEM) \nINF = 999999999999999999L\ntry:\n inFile = open(FILE+\".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,t,k,d = read_ints()\n\none_oven = (n+k-1)/k * t\n\ntwo_ovens = d\nn -= (d/t) * k\nif n > 0:\n k *= 2\n two_ovens += (n+k-1)/k * t\n \n#print one_oven\n#print two_ovens\n\nif one_oven <= two_ovens:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "n,t,k,d = list(map(int,input().split()))\nif d%t == 0 and t%k !=0 and t>k:\n if d==t and n%2==1:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if (n+k-1)//k * t - d > t:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "n,t,k,d=[int(x) for x in input().split() ]\nx=(int(d/t)+1)\nx=x*k\nrest=n-x\nif rest >= 1:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def needed(n,t,k,q):\n isNeeded = False\n if(n (q+(bakesLeft/2)*t):\n isNeeded = True\n # else:\n # bakesLeft = noOfBakesNeeded - q/t\n\n # if noOfBakesNeeded*t > (q+(noOfBakesNeeded/2)*t):\n # isNeeded = True\n return isNeeded\n\nn,t,k,q = map(int, raw_input().split(\" \"))\nif needed(n,t,k,q):\n print \"YES\"\nelse:\n print \"NO\"\n# print \"YES\" if needed(n,t,k,q)==True else \"NO\"\n"}, {"source_code": "N, T, K, D = input().split(\" \")\n\nn, t, k, d = int(N), int(T), int(K), int(D)\n\ng = int((n+k-1) / k)\n\no1 = 0\no2 = d\n\nfor i in range(0, g):\n if o1 <= o2:\n o1 += t\n else:\n o2 += t\n\nT1 = max(o1, o2)\nT2 = g * t\n\nprint(\"YES\") if T1 < T2 else print(\"NO\")\n"}, {"source_code": "def one_oven(t, k, n):\n if n%k == 0:\n i = n//k\n else:\n i = (n//k) +1\n return i*t\n\nn, t, k, d = input().split(' ')\nn, t, k, d = int(n), int(t), int(k), int(d)\n\nif one_oven(t, k, n) > d+t:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n,t,k,d = map(int, input().split())\n# print(n,t,k,d)\n# z= (d/t)+1\n# m=d*k/t\n# f= ((n/k)-m)*t/(2*k)\nif (((d//t)+1)*k)>=n:\n print(\"No\")\nelse:\n print(\"YES\")"}, {"source_code": "n = list(map(int,input().split()))\not = (n[0] / n[2]) * n[1]\no1 = n[1]\no2 = n[3]\np = n[0] - n[2]\nfor i in range(n[0]):\n if (p >= n[2]):\n if (o2 > o1):\n o1 += n[1]\n p -= n[2]\n else:\n o1 += n[1]\n o2 += n[1]\n p -= (n[2]+n[2])\n elif ((p < n[2]) & (p > 0)):\n t = (p * n[1]) / n[2]\n o1 += t\n o2 += t\n p = 0\nif ((o2 < ot)&(o2 != n[3])):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# Carrot Cakes\n\n\"\"\"\n Thinking time: 6\n Coding time: 2\n Debugging time: 4\n -----------------------------\n Total time: 12 minutes\n\"\"\"\n\nn, t, k, d = input().split(\" \")\nn, t, k, d = int(n), int(t), int(k), int(d)\n\ntimeWithOneOven = (n // k * t) + (t if n % k != 0 else 0)\n\nprint(\"YES\" if timeWithOneOven > d and timeWithOneOven - d > t else \"NO\")\n"}, {"source_code": "l=map(int,raw_input().split())\nn=l[0]\nt=l[1]\nk=l[2]\nd=l[3]\nif n%k >0:\n time=t+t*(n/k)\nelse:\n time=t*(n/k)\ntime-=t\nif d time2):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def sol():\n i = list(map(int, raw_input().split()))\n n,t,k,d = i[0],i[1],i[2],i[3]\n\n mint = n/k\n if n%k!=0: mint += 1\n\n if mint*t> d+t:\n print 'YES'\n else:\n print 'NO'\n\n \n\nsol()"}, {"source_code": "from math import *\nfrom collections import *\nimport sys\nsys.setrecursionlimit(10**9)\nmod = 10**9 + 7\n\nn,t,k,d = map(int,input().split())\nif(k >= n):\n print(\"NO\")\nelse:\n s = (d//t)*k\n if(s < n-k):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "import math\n\nn, t, k, d = map(int, input().split())\ntime = math.ceil(n / k) * t\nif d + t < time:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n, t, k, d = map(int, input().split())\ns = 0\nsecond = False\nfinish = -1\nfor i in range(1, (n // k + 1) * t + 1):\n if second and (i - start) % t == 0:\n s += k\n if i == d:\n second = True\n start = i\n if i % t == 0:\n s += k\n if s >= n:\n finish = i\n break\nif n % k == 0:\n if n // k * t > finish:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if (n // k + 1) * t > finish:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n, t, k, d = list(map(int, input().split()))\n\n\n# two oven\no1 = 0\no2 = d\nm = (n + k-1) // k\n\nfor x in range(m):\n if (o1 <= o2):\n o1 += t\n else:\n o2 += t\n\nif m * t > max(o1, o2):\n print('YES')\n\nelse:\n print('NO')"}, {"source_code": "n,t,k,d=map(int,input().split())\nz=(k/t)\na=0\nb=(k/t)*d\nt1=0\nt2=d\nwhile(a= 1):\n\tmult += 1\n\nno = mult * t\n\nyesCount = n\nyes = d\n\nyesCount -= ((d//t)*k) # 10\n\n\nwhile(yesCount > 0):\n\tyesCount -= (k*2)\n\tyes += t\nif(k >= n):\n\tprint(\"NO\")\nelse:\n\tif(no <= yes):\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n"}, {"source_code": "[N, T, K, D] = map(int, raw_input().split())\n\nAm = 1\nBm = 1\n\nCount = 0\nwhile(True):\n if Am % T == 0:\n Count += K \n if Count >= N:\n break\n Am += 1\n\nCount = 0\nwhile(True):\n if Bm % T == 0:\n Count += K \n if Bm > D:\n if (Bm - D) % T == 0:\n Count += K \n if Count >= N:\n break\n Bm += 1\n\nif Bm >= Am:\n print \"NO\"\nelse:\n print \"YES\"\n"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\na = math.ceil(d/t)\nn=n-(a*k)\nif n>0:\n if d%t!=0:\n print(\"YES\")\n else:\n if n>k:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n, t, k, d = map(int, raw_input().split())\n\nq1, q2 = 0, d\ng = (n + k -1) /k\nfor i in xrange(g):\n if q1 <= q2:\n q1 += t\n else:\n q2 += t\nif max(q1, q2) < g * t:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n,t,k,d= [int(x) for x in input().split(' ')];\ntime1=n//k*t;\nif(n%k!=0):time1=time1+t;\na=0;b=d;\nwhile(n>0):\n if (atime2):\n print('Yes');\nelse:\n print('No');"}, {"source_code": "str=input()\nx=str.split(\" \")\na=int(x[0])\ns=int(x[1])\nd=int(x[2])\nf=int(x[3])\nz=int(a/d)\n\nif((z==1) and (a%d!=0) and (f1)and(s>f)):\n print(\"YES\")\n \nelif((z>1)and(s<=f)and(a%d!=0)and((z*s)>f)):\n print(\"YES\")\n \nelif((z>1)and(s<=f)and(a%d==0)and(((z-1)*s)>f)):\n print(\"YES\")\n \nelse:\n print(\"NO\")\n"}, {"source_code": "n, t, k, d = map(int, input().split())\nt1, t2 = 0, d\n\nwhile n > 0:\n if t1 <= t2:\n t1 += t\n n -= k\n else:\n t2 += t\n n -= k\n\nif t2 == d:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n\n\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nn2=((d+t)//t)*k # n of cake in time d+t\nif n2 0:\n\t\twith_new += t * (remain//(k*2))\n\t\t\nelse:\n\twith_new += t\n\tremain = remain - k\n\tif remain > 0:\n\t\twith_new += t * (remain//(k*2)) + t\n\t\nif with_new < without_new and flag:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "n, t, k, d = map(int, input().split())\ns = 0\nsecond = False\nfinish = -1\nfor i in range(1, (n // k + 1) * t + 1):\n if second and (i - start) % t == 0:\n s += k\n if i == d:\n second = True\n start = i\n if i % t == 0:\n s += k\n if s >= n:\n finish = i\n break\nif n % k == 0:\n if n // k * t > finish:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n if (n // k + 1) * t > finish:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n,t,k,d=map(int,raw_input().split())\nprint 'YES' if d+t<(n+k-1)/k*t else 'NO'"}], "negative_code": [{"source_code": "n, t, d, k = map(int, input().split())\nif (d / (t + 1) * k) < n:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\nimport math\n\n\ndef readlines(type=int):\n return list(map(type, sys.stdin.readline().split()))\n\n\ndef read(type=int):\n return type(sys.stdin.readline().strip())\n\n\njoint = lambda it, sep=\" \": sep.join(\n [str(i) if type(i) != list else sep.join(map(str, i)) for i in it])\n\n\ndef solve_naive(n, t, k, d):\n n_mul = (n * t) // k + 1\n t_muls = set()\n for i in range(1, n_mul + 1):\n t_muls.add(t * i)\n t_muls.add((t * i) + d)\n t_muls = sorted(list(t_muls))\n for mul in t_muls:\n yeild = k * ((mul // t) + (mul - d) // t)\n if yeild >= n:\n # mulc = mul\n break\n # print(t_muls)\n # print(mul, f\"{t * math.ceil(n / k)=}\", n, k, t)\n if mul < t * math.ceil(n / k):\n return \"YES\"\n return \"NO\"\n\n\ndef solve(n, t, k, d):\n timet = (n * t + k * d) / (2 * k)\n c1 = math.ceil(timet / t) * t\n c2 = (math.ceil((timet - d) / t) * t) + d\n if c1 < t * math.ceil(n / k):\n return \"YES\"\n if c2 < t * math.ceil(n / k):\n return \"YES\"\n return \"NO\"\n\n\ndef main():\n print(solve(*readlines()))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n, t, k, d = map(int, input().split())\nn1 = n\nif n < k:\n\ta = n*(t/k)\nelse:\n\ta = t\nn1 -= k\nwhile n1 > 0:\n\ta += t\n\tn1 -= k\nif d > t:\n\tb = d\n\tn -= (d/t)*k\nelse:\n\tb = t\n\tn -= k\nwhile n>0:\n\tb += t\n\tn -= 2*k\nprint('YES') if a > b else print('NO')\n"}, {"source_code": "a,b,c,d = map(int,input().split())\nt1 = 0\nt2 = 0\nif a % c == 0:\n\tk = a//c\nelse:\n\tk = a//c+1\nt1 = b * k\nt2 += d\nt2 += t1 // 2\nif t1 <= t2:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n"}, {"source_code": "\"\"\"609C\"\"\"\ndef main():\n\tn,t,k,d = map(int,input().split())\n\ttime = 0\n\tcakes = 0\n\twhile time=n:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\nmain()"}, {"source_code": "n,t,k,d = map(int,input().split())\nif t >= d:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n,t,k,d=map(int,input().split())\nprint('YES' if t+d < (n//k)*t else 'NO')\n"}, {"source_code": "import math\ndef carrotCakes(n, t, k, d):\n if k < n:\n if math.ceil(n/k) * t > d + t: print('YES')\n else: print('NO')\n else: \n if t > d: print ('YES')\n else: print('NO')\n\ndef main():\n n, t, k, d = (int(i) for i in input().split())\n carrotCakes(n, t, k, d)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "ns = [int(s) for s in input().split(' ')]\nn = ns[0]\nt = ns[1]\nk = ns[2]\nd = ns[3]\ndb = 1\n\ntogether = d % t\ncakes_during_building = (d * k) // t\nafter_building = n - cakes_during_building\nif db == 1:\n #print(\"time for one oven: \",one_oven)\n #print(\"time for two oven: \",two_oven)\n print(\"left cakes to make after d: \",after_building)\n print(\"cakes made druing d: \", cakes_during_building)\n #print(\"bakes per min: \",baked_per_minute)\n print(\"total cakes: \", n)\n print(\"d :\", d)\n print(\"cakes per min :\", k , t)\n print(together)\nif after_building <= 0 or after_building <= k :\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nz=(k/t)\na=0\nb=(k/t)*d\nt1=0\nt2=d\nwhile(a=n : \n\t\ti2=i\n\t\tbreak\ncakes=0\nfor i in range(1,1001):\n\tif i%t==0:\n\t\tcakes+=k\n\tif(d=n: \n\t\tif i>=i2: print(\"NO\") \n\t\telse : print(\"YES\")\n\t\tbreak"}, {"source_code": "n, t, k, d = map(int, input().split())\nx1 = (n * t) / k # Time required ta bake using only one oven\nc = (k * d) / t # Number of cakes baked while building the oven\nn = n - c # remaining cakes \n\n\n# Calculate the time required to bake the remiaing cakes after building the second oven-it will half time of course- then add the time taken in building the second one\nx2 = ((n * t) /k) / 2 + d \n\n\nprint([\"NO\", \"YES\"][x2 < x1])"}, {"source_code": "n , t , k ,d = map(int,input().split())\n\nif (n // k ) * t > d + t:\n print('YES')\nelse:\n print('NO')\n\n\n\n\n"}, {"source_code": "n,t,k,d=map(int,input().split())\n\n\nif(d/t<1):\n if(n-k>0):\n print(\"YES\")\n elif(n-k<=0):\n print(\"NO\")\n\nelse:\n from math import ceil\n if(n-ceil(d/t)*k<=k and d%t==0):\n print(\"NO\")\n else:\n print(\"YES\")\n"}, {"source_code": "n , t , k ,d = map(int,input().split())\n\nif (n // k ) * t > d + t:\n print('YES')\nelse:\n print('NO')\n\n\n\n\n"}, {"source_code": "import math\n\ndef calc_feasible(n,t,k,d):\n #calculate time for oven1 alone\n time_single_oven = math.ceil((n/k)) * t\n\n #calculate time for oven1 and oven2 together\n if d <= t:\n time_oven1 = math.ceil(n/(2*k)) * t\n time_oven2 = time_oven1 + (d-t)\n time_both_oven = time_oven1 + time_oven2\n else:\n #find how many cakes can be baked by the time second oven is ready\n x = math.floor(d/t) * k\n if (n-x) <= 0 or (n-x) < k:\n print \"NO\"\n return\n time_oven1 = math.ceil((n-x)/(2*k)) * t\n time_oven2 = time_oven1 + (d % t) - t\n time_both_oven = time_oven1 + time_oven2\n if time_single_oven <= time_both_oven:\n print \"NO\"\n return\n else:\n print \"YES\"\n return\n\nn, t, k, d = map(int, raw_input().split(' '))\ncalc_feasible(n, t, k , d)"}, {"source_code": "from sys import stdin\nimport math\nn,t,k,d = [int(x) for x in stdin.readline().strip().split()]\n\ndef solution(n,t,k,d):\n #without second oven:\n w = math.floor((n*t)/k)\n m = math.floor(((n-d)*t)/k) + math.floor((d*t)/k)\n if w >= m:\n return 'YES'\n else:\n return 'NO'\n\nprint(solution(n,t,k,d))\n"}, {"source_code": "n,t,k,d=map(int,input().split())\na = (n//k)*t\nb = t+d\nif k>=n:\n print('NO')\nelse:\n if a<=b:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "n, t, k, d = map(int, input().split())\nx1 = (n * t) / k # Time required ta bake using only one oven\nc = (k * d) / t # Number of cakes baked while building the oven\nn = n - c # remaining cakes \n\n\n# Calculate the time required to bake the remiaing cakes after building the second oven-it will half time of course- then add the time taken in building the second one\nx2 = ((n * t) /k) / 2 + d \n\n\nprint([\"NO\", \"YES\"][x2 < x1])"}, {"source_code": "n,t,k,d=map(int,input().split())\n\n\nif(d/t<1):\n if(n-k>0):\n print(\"YES\")\n elif(n-k<=0):\n print(\"NO\")\n\nelif(d/t==1):\n if(n-k<=k):\n print(\"NO\")\n elif(n-k>k):\n print(\"YES\")\nelif((d/t)>1):\n from math import ceil\n if(ceil(d/t)*k>=n or k>=n-(ceil(d/t)*k)):\n print(\"NO\")\n else:\n print(\"YES\")\n"}, {"source_code": "n, t, k, d = map(int, input().split())\n\nmult = n//k\nif (n%k > 1):\n\tmult += 1\n\nno = mult * t\n\nyesCount = 0\nyes = d\nif(d > t):\n\tyesCount = k\n\n\nwhile(yesCount < t):\n\tyesCount += (k*2)\n\tyes += t\n\nif(k >= n):\n\tprint(\"NO\")\nelse:\n\tif(no <= yes):\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n"}, {"source_code": "# https://codeforces.com/contest/799/problem/A\n\nnoOfCakesToBeMade, minsOvenReqToBakeABatchOfCakes, noOfCakesInABatch, minsReqToBuildAOven = [int(x) for x in input().split(' ')]\n\ntimerForOneOven = (noOfCakesToBeMade / noOfCakesInABatch) * minsOvenReqToBakeABatchOfCakes\n\nnoOfCakesReady = 0\ntimer = 0\nsecondOvenTimer = 0\n\nwhile noOfCakesReady < noOfCakesToBeMade:\n timer += 1\n\n if (timer / minsOvenReqToBakeABatchOfCakes).is_integer():\n noOfCakesReady += noOfCakesInABatch\n\n if timer > minsReqToBuildAOven:\n secondOvenTimer += 1\n if (secondOvenTimer / minsOvenReqToBakeABatchOfCakes).is_integer():\n noOfCakesReady += noOfCakesInABatch\n\nif timer < timerForOneOven:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import math\nn, time, cakes, build_time = map(int, input().split())\nitr = math.ceil(n/cakes)\nsingle = itr*time\nbuild_overlap = 0 if build_time < time and math.ceil(single - build_time)/time > 1 else build_time - time \ndouble = build_overlap + single/2 if itr-1 > 1 or build_time < time else single * 2 \nprint(\"YES\" if double < single else \"NO\")"}, {"source_code": "n,t,k,d=map(int,raw_input().split())\nif n/k==(n*1.0)/k:\n vr=n/k\nelse:\n vr=n/k+1\nif(t>d and n>k):\n print \"YES\"\n\nelif(td):\n print \"YES\"\nelse:\n print \"NO\"\n \n\n\n"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\nres=(n+k-1)/k\nres*=t\nif res>d+t:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import math\n\ndef calc_feasible(n,t,k,d):\n #calculate time for oven1 alone\n time_single_oven = math.ceil((n/k)) * t\n\n #calculate time for oven1 and oven2 together\n if d <= t:\n time_oven1 = math.ceil(n/(2*k)) * t\n time_oven2 = time_oven1 + (d-t)\n time_both_oven = time_oven1 + time_oven2\n else:\n #find how many cakes can be baked by the time second oven is ready\n x = math.floor(d/t) * k\n if (n-x) <= 0 or (n-x) < k:\n print \"NO\"\n return\n time_oven1 = math.ceil((n-x)/(2*k)) * t\n time_oven2 = time_oven1 + (d % t) - t\n time_both_oven = time_oven1 + time_oven2\n if time_single_oven <= time_both_oven:\n print \"NO\"\n return\n else:\n print \"YES\"\n return\n\nn, t, k, d = map(int, raw_input().split(' '))\ncalc_feasible(n, t, k , d)"}, {"source_code": "def main():\n n, t, k, d = map(int, input().split())\n\n time = 0\n single = 0\n double = 0\n \n while True:\n is_ready1 = time % t == 0 and time != 0\n is_ready2 = (time + d) % t == 0 and time > d\n \n if is_ready1:\n single += k\n\n if is_ready2:\n double += 2 * k\n\n if single >= n:\n print('NO')\n return\n\n if double >= n:\n print('YES')\n return\n\n time += 1\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, t, k, d = map(int, input().split())\nn1 = n\nif n < k:\n\ta = n*(t/k)\nelse:\n\ta = t\nn1 -= k\nwhile n1 > 0:\n\ta += t\n\tn1 -= k\nb = d\nif d > t:\n\tn -= (d/t)*k\nelse:\n\tn -= k\nwhile n>0:\n\tb += t\n\tn -= 2*k\nprint('YES') if a > b else print('NO')\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nif k > n:\n\tprint(\"NO\")\n\texit()\na=0\nm=k\nwhile(m < n):\n\tm+=k\n\ta+=1\nfans=a*t\nsans=t+d\nif fans < sans:\n\tprint(\"NO\")\nelse:print(\"YES\")\n"}, {"source_code": "n,t,k,d = map(int,input().split())\na = -(-n//k)*t\nns = k/t\nt1 = 0\nnt = 0\nnt1 = 0\nnt2 = 0\nc = False\nwhile nt=d:\n\t\tnt2+= ns\n\t\tnt1+= ns\n\telse:\n\t\tnt1+=ns\n\tif nt1>=k:\n\t\tnt+=k\n\t\tnt1=0\n\tif nt2>=k:\n\t\tnt+=k\n\t\tnt2=0\n\t\tc = 1\n\tt1+=1\n\nif a>t1-1:\n\tif c:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\nelse:\n\tprint(\"NO\")\n\n"}, {"source_code": "x = list(map(int, input().rstrip().split()))\nif x[0] <= x[2] or x[3] == [1]: print('NO')\nelif x[3] < x[1]: print('Yes')\nelse:\n oldt = (x[0]/x[2]) * x[1]\n newn = (x[3] * x[2]) / x[1]\n newt = (newn/x[2]) * x[1]\n if oldt > newt: print('YES')\n else: print('NO')\n\n"}, {"source_code": "import math\nn, time, cakes, build_time = map(int, input().split())\nitr = math.ceil(n/cakes)\nsingle = itr*time\nbuild_overlap = 0 if build_time < time and math.ceil(single - build_time)/time > 1 else build_time - time\ndouble = build_overlap + single/2 if itr-1 > 1 or build_time < time else single * 2\nprint(\"YES\" if double < single else \"NO\")"}, {"source_code": "ns = [int(s) for s in input().split(' ')]\nn = ns[0]\nt = ns[1]\nk = ns[2]\nd = ns[3]\ndb = 1\n\nduring_building = (d / t)\ntogether = d % t\ncakes_during_building = during_building * k\nafter_building = n - cakes_during_building\nif db == 1:\n #print(\"time for one oven: \",one_oven)\n #print(\"time for two oven: \",two_oven)\n print(\"left cakes to make after d: \",after_building)\n print(\"cakes made druing d: \", cakes_during_building)\n #print(\"bakes per min: \",baked_per_minute)\n print(\"total cakes: \", n)\n print(\"d :\", d)\n print(\"cakes per min :\", k , t)\n print(together)\nif after_building <= 0 or (after_building <= k and together == 0):\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "a1, a2, a3, a4 = list(map(int, input().split()))\n\n\ndef pies_for_time(time, t, k):\n return (time // t) * k\n\n\ndef pies(count, t, k, d):\n # \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u0430 \u043f\u0435\u0447\u043a\u0430\n t1 = (count // k + (0 if count % k == 0 else 1)) * t\n\n if count < pies_for_time(t1 - 1 - d, t, k) + pies_for_time(t1 - 1, t, k):\n return \"YES\"\n return \"NO\"\n\n\nprint(pies(a1, a2, a3, a4))\n"}, {"source_code": "import operator as op\nimport 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 functools import reduce\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\ndef def_value():\n return 0\n\n\ndef time_lagbe(n, k, t):\n if n == 0:\n return 0\n if k > n:\n return t\n time1 = (n // k)*t + (n % k)*t\n return time1\n# For getting input from input.txt file\n#sys.stdin = open('input.txt', 'r')\n# Printing the Output to output.txt file\n#sys.stdout = open('output.txt', 'w')\n\n\nn, t, k, d = invr()\n\nTIME = [0]*1001\nTIME2 = [0]*1001\n\nfor i in range(t, 1001, t):\n\n TIME[i] = k*(i//t)\n\nfor i in range(d+t, 1001, t):\n TIME2[i] = k * (i//t) * 2\nres = \"NO\"\nfor i in range(1001):\n if TIME[i] < n:\n if TIME2[i] > TIME[i]:\n res = \"YES\"\n break\n else:\n break\n# print(TIME[:20])\n# print(TIME2[:20])\nprint(res)\n"}, {"source_code": "import math\nn,t,k,d = map(int,raw_input().split())\nprint 'YES' if math.ceil(n*1.0/k)*t > math.ceil(math.ceil(n*1./k-math.ceil(d*1./t))/2)*t+d else 'NO'"}, {"source_code": "n,t,k,d=map(int,input().split())\nif k > n:\n\tprint(\"NO\")\n\texit()\na=0\ng=k\nm=k\nwhile(m < n):\n\tm+=k\n\ta+=1\nfans=a*t\nsans=t+d\nb=0\nwhile(k < n):\n\tk+=g\n\tb+=1\nsans*=b\nif fans < sans:\n\tprint(\"NO\")\nelse:print(\"YES\")\n"}, {"source_code": "n,t,k,d=map(int,raw_input().split())\nif(t>d and n>k):\n print \"YES\"\nelif(t=d):\n print \"YES\"\nelse:\n print \"NO\"\n \n\n\n"}, {"source_code": "from math import floor\nn, t, k, d = map(int, input().split())\n\novenOne = 0\novenTwo = 0\ntimeBuild = 0\nwhile ovenOne + ovenTwo < n:\n timeBuild += 1\n if timeBuild % t == 0: ovenOne += k\n if timeBuild > d and ((timeBuild - d) % t) == 0: ovenTwo += k\n \ntimeNoBuild = (n*t)/k\nif timeBuild > timeNoBuild: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "import math\n\n\ndef main():\n n, t, k, d = map(int, raw_input().split())\n t1 = math.ceil(n/float(k)) * t\n if d > t:\n t2 = d+ math.ceil((n-(d/t)*k)/float(k*2))*t\n else:\n t2 = t + math.ceil((n-k)/float(k*2))*min(t,d)\n \n print t1,t2\n if t2 < t1:\n print 'YES'\n else:\n print 'NO'\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n,t,k,d = list(map(int,input().split()))\nn_new = int(n/k)\noven1 ,oven2 = 0 , d\nfor i in range(n_new):\n if oven1 < oven2 : oven1 += t\n else: oven2 += t\nprint(\"YES\" if max(oven1,oven2)<(n_new*t) else \"NO\")"}, {"source_code": "import sys\n\nn,t,k,d = map(int, sys.stdin.readline().split())\nnow = 0\none = 0\ntwo = 0\nfor i in range(1, 100001):\n one = i\n if now >= n:\n break\n if i % t == 0:\n now += k\n\nnow = 0\nfor i in range(1, 100001):\n two = i\n if now >= n:\n break\n if i % t == 0:\n now += k\n if i - d > 0 and (i - d) % t == 0:\n now += k\n\nprint('YES' if one > two else 'NO')"}, {"source_code": "n,t,k,d = list(map(int,input().split()))\n\nif d%t == 0 and t%k !=0 and d!=t:\n print(\"NO\")\nelse:\n if (n+k-1)//k * t - d >= t:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "ns = [int(s) for s in input().split(' ')]\nn = ns[0]\nt = ns[1]\nk = ns[2]\nd = ns[3]\ndb = 0\n\nduring_building = (d / t)\ntogether = d % t\ncakes_during_building = during_building * k\nafter_building = n - cakes_during_building\nif db == 1:\n #print(\"time for one oven: \",one_oven)\n #print(\"time for two oven: \",two_oven)\n print(\"left cakes to make after d: \",after_building)\n print(\"cakes made druing d: \", cakes_during_building)\n #print(\"bakes per min: \",baked_per_minute)\n print(\"total cakes: \", n)\n print(\"d :\", d)\n print(\"cakes per min :\", k , t)\nif after_building <= 2 * k and together == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n, t, k, d = map(int,input().split())\nfrom math import ceil\nn = ceil(n / k)\n\nt1 = n * t\nt2 = d + ceil(n/ 2) * t\nprint(t1)\nprint(t2)\n\nif t1>t2:\n print(\"YES\")\nelse:\n print(\"NO\")\n#4 2 1 4\n"}, {"source_code": "def khong(n, t, k, d):\n return (int((n - 1) / k) + 1) * t\n\ndef co(n, t, k, d):\n l = int(0)\n r = 1500000\n while (r-l > 1):\n mid = int((l+r) /2)\n h1 = (mid/t)*k + (mid-d)/t*k\n if(h1 >= n): r = mid\n else: l = mid\n return r\n\nn, t, k, d = map(int, input().split())\nprint(khong(n, t, k, d))\nif(co(n, t, k, d) < khong(n, t, k, d)):\n print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "n,t,k,d=map(int,raw_input().split())\nif(t>d and n>k):\n print \"YES\"\nelif(t=d):\n print \"YES\"\nelse:\n print \"NO\"\n \n\n\n"}, {"source_code": "import math\ndef compute_rest(oven_capacity, oven_time, cakes, oven_build_time):\n turns = cakes/oven_capacity\n rest = (turns * oven_time) - oven_build_time\n if oven_capacity >= cakes:\n return 'NO' \n elif (turns == 2) and (oven_time <= oven_build_time):\n return 'NO'\n elif turns*oven_time <= oven_build_time:\n return 'NO'\n elif turns*oven_time > oven_build_time and rest == oven_time:\n return 'NO' \n else:\n return 'YES' \n \n \n\ninp = list(map(int, input().rstrip().split()))\nprint(compute_rest(inp[2], inp[1], inp[0], inp[3]))\n\n\n\n\n\n"}, {"source_code": "n, t, k, d = map(int, raw_input().split())\n\n\nt1 = 0\ncakes = 0\nwhile cakes < n:\n\tt1 += t\n\tcakes += k\n\n\nncakes = 0\nt2 = 0\nt3 = 0\nflag = 0\nwhile ncakes < n:\n\tt2 += 1\n\tif t2 == d:\n\t\tflag = 1\n\tif flag:\n\t\tt3 += 1\n\tif t3%t == 0 and t3 != 0:\n\t\tncakes += k\n\tif t2%t == 0 and t2 != 0:\n\t\tncakes += k\n\n# t3 + d - t2\n# t2 = t2 - t + min(t, d)\nt2 = max(t3 + d, t2)\n# print t2, t1\n\nif t2 < t1:\n\tprint \"YES\"\nelse:\n\tprint \"NO\" "}, {"source_code": "import math\nn, t, k, d = map(int, input().split())\nsingle = math.ceil(n / k) * t\ndouble = 0\ncakes = 0\ntime = 1\nwhile cakes < n:\n if time > d:\n if (time - d) % t == 0:\n cakes += k\n\n if cakes >= n:\n break\n\n if time % t == 0:\n cakes += k\n time += 1\n\n\nif time < single:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import math\nn, t, k, d = map(int, input().split())\n\ntimes = math.ceil(n//k)\ntotalWithOut = times * t\ntotalWith = t + d\n\nif totalWith < totalWithOut:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n , t , k , d = list(map(int,input().split()))\nt_n_cakes = (n*t/k)\nif n == d:\n print('YES')\nelse:\n print('YES' if d*(n/k) < t_n_cakes else 'NO')"}, {"source_code": "n,t,k,d = map(int,input().split())\nif t >= d:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\nn,t,k,d=map(int,input().split())\nres=(n+k-1)/k\nres*=t\nif res>d+t:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def main():\n n, t, k, d = map(int, input().split())\n\n time = 0\n single = 0\n double = 0\n \n while True:\n is_ready1 = time % t == 0 and time != 0\n is_ready2 = (time + d) % t == 0 and time > d\n \n if is_ready1:\n single += k\n\n if is_ready2:\n double += 2 * k\n\n if single >= n:\n print('NO')\n return\n\n if double >= n:\n print('YES')\n return\n\n time += 1\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\ndef compute_rest(oven_capacity, oven_time, cakes, oven_build_time):\n turns = cakes/oven_capacity\n rest = (turns * oven_time) - oven_build_time\n if oven_capacity >= cakes:\n return 'NO' \n elif (turns == 2) and (oven_time <= oven_build_time):\n return 'NO'\n elif turns*oven_time <= oven_build_time:\n return 'NO'\n elif turns*oven_time > oven_build_time and rest == oven_time:\n return 'NO' \n else:\n return 'YES' \n \n \n\ninp = list(map(int, input().rstrip().split()))\nprint(compute_rest(inp[2], inp[1], inp[0], inp[3]))\n\n\n\n\n\n"}, {"source_code": "n, t, k, d = map(int, input().split())\n\ni = 0\nbaked = 0\nwhile baked < n:\n\ti += 1\n\tif i % t == 0:\n\t\tbaked += k\n\tif i > d and ((i-d) % t == 0):\n\t\tbaked += k\n\nif i <= d + t:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "n, t, k, d = list(map(int, input().split()))\n\n# one oven\none_oven = n * t / k\n\n# two oven\no1 = 0\no2 = d\n\nfor x in range(n // k):\n if (o1 <= o2):\n o1 += t\n else:\n o2 += t\n\nif one_oven <= max(o1, o2):\n print('NO')\n"}, {"source_code": "n, t, k,d = list(map(int, input().split()))\n\none_oven = n * t / k\n\ntwo_oven = d + (one_oven / 2)\n\nif one_oven > two_oven:\n print('YES')\n\nelse:\n print('NO')\n\nprint(one_oven, two_oven)"}, {"source_code": "n,t,k,d=map(int,raw_input().split())\nif d+1 > t and (2*k)+1 > n:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "a = list(map(int , input().split()))\n\n\nprint('YES') if( int(a[0]/a[2])-1) * a[1] > a[3] else print('NO')"}, {"source_code": "n, t, k, d = map(int, input().split())\na = n * (t/k)\nb = d\nn -= d*(k/t)\nwhile n>0:\n\tb += t\n\tn -= 2*k\nprint('YES') if a > b else print('NO')"}, {"source_code": "n,t,k,d=map(int,input().split())\nif k > n:\n\tprint(\"NO\")\n\texit()\na=0\ng=k\nm=k\nwhile(m < n):\n\tm+=k\n\ta+=1\nfans=a*t\nsans=t+d\nb=0\nwhile(k < n):\n\tk+=g\n\tb+=1\nsans*=b\nif fans < sans:\n\tprint(\"NO\")\nelse:print(\"YES\")\n"}, {"source_code": "import math\ndef compute_rest(oven_capacity, oven_time, cakes, oven_build_time):\n turns = math.floor((cakes/oven_capacity))\n if oven_capacity >= cakes:\n return 'NO' \n elif (turns == 2) and (oven_time <= oven_build_time):\n return 'NO'\n elif turns*oven_time <= oven_build_time:\n return 'NO' \n else:\n return 'YES' \n \n \n\ninp = list(map(int, input().rstrip().split()))\nprint(compute_rest(inp[2], inp[1], inp[0], inp[3]))\n\n\n\n\n\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nif k > n:\n\tprint(\"NO\")\n\texit()\na=0\ng=k\nm=k\nwhile(m < n):\n\tm+=k\n\ta+=1\nfans=a*t\nsans=t+d\nb=0\nwhile(k < n):\n\tk+=g\n\tb+=1\nsans*=b\nif fans < sans:\n\tprint(\"NO\")\nelse:print(\"YES\")\n"}, {"source_code": "n, t, k, d = map(int, input().split())\n\nif d < t:\n\tprint(\"YES\")\nelse:\n\toven = d // t\n\t# print(str(oven)[2])\n\tif n - k * int(oven) > k:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n"}, {"source_code": "\n\nimport sys\n\n\ndef main(args=None):\n if args is None:\n n, t, k, d = [int(tok.strip()) for tok in sys.stdin.readline().split()]\n else:\n n, t, k, d = args\n\n # time needed for one oven\n t1 = int(n / k + 0.5) * t\n\n for b in range(1, n + 1):\n for a in range(b, b + int(d / t + 0.5) + 1):\n if (a + b) * k >= n:\n if max(a * t, d + b * t) < t1:\n print(\"YES\")\n return \"YES\"\n else:\n print(\"NO\")\n return \"NO\"\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "reqd,min_to_bake,bake_per_min,oven = map(int, input().split())\nh = \"NO\"\nx = reqd // bake_per_min\nprint(x)\nif reqd % bake_per_min == 0 and x * min_to_bake > min_to_bake + oven:\n h = \"YES\"\nif reqd % bake_per_min != 0 and (x+1) * min_to_bake > min_to_bake + oven:\n h = \"YES\"\nprint(h)"}, {"source_code": "from sys import stdin\nimport math\nn,t,k,d = [int(x) for x in stdin.readline().strip().split()]\n\ndef solution(n,t,k,d):\n #without second oven:\n\n w = math.ceil(n/k * t)\n x = (n-d/t)/k * 0.5*t\n #with second oven:\n m = math.ceil(d + n/k *0.5 *t)\n\n if w > m:\n return 'YES'\n else:\n return 'NO'\n\nprint(solution(n,t,k,d))"}, {"source_code": "x = list(map(int, input().rstrip().split()))\nif x[0] <= x[2] or x[3] == [1]: print('NO')\nelif x[3] < x[1]: print('Yes')\nelse:\n oldt = (x[0]/x[2]) * x[1]\n newn = (x[3] * x[2]) / x[1]\n newt = (newn/x[2]) * x[1]\n if oldt > newt: print('YES')\n else: print('NO')\n\n"}, {"source_code": "import math\ndef main():\n a ,b, c, d = map(int,input().split())\n if math.ceil(a / c) * b < b + d:\n print('YES')\n else:\n print('NO')\nmain()"}, {"source_code": "str=input()\nx=str.split(\" \")\na=int(x[0])\ns=int(x[1])\nd=int(x[2])\nf=int(x[3])\nz=a/d\nif((z==1) and (a%d>0) and (f1)and(s>f)):\n print(\"YES\")\n \nelif((z>1)and(s<=f)and(a%d!=0)and(((z)*s)>f)):\n print(\"YES\")\n \nelif((z>1)and(s<=f)and(a%d==0)and(((z-1)*s)>f)):\n print(\"YES\")\n \nelse:\n print(\"NO\")\n"}, {"source_code": "import sys\n\n\ndef readlines(type=int):\n return list(map(type, sys.stdin.readline().split()))\n\n\ndef read(type=int):\n return type(sys.stdin.readline().strip())\n\n\njoint = lambda it, sep=\" \": sep.join(\n [str(i) if type(i) != list else sep.join(map(str, i)) for i in it])\n\n\ndef solve(n, t, k, d):\n n_mul = (n * t) // k + 1\n t_muls = set()\n for i in range(1, n_mul + 1):\n t_muls.add(t * i)\n t_muls.add((t * i) + d)\n t_muls = sorted(list(t_muls))\n for mul in t_muls:\n timet = k * ((mul // t) + (mul - d) // t)\n if timet >= n:\n # mulc = mul\n break\n if timet < t * (n // k):\n return \"YES\"\n return \"NO\"\n\n\ndef main():\n print(solve(*readlines()))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "# automate the second oven scenario with a for loop\nn, t, c, d = input().split()\ncakes_needed = int(n)\ntime = int(t)\ncakes_in_progress = int(c)\nsecond_oven = int(d)\n\nsingle_oven_scenario = time * cakes_needed / cakes_in_progress\n\ncounter = 0\ncakes = 0\nfor l in range(0, second_oven, time):\n if l < second_oven:\n cakes += cakes_in_progress\n counter += time\n else:\n counter = counter + ((cakes_needed - cakes) / 2 * time)\nif counter < single_oven_scenario:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nz=(k/t)\na=0\nb=(k/t)*d\nt1=0\nt2=d\nwhile(a k or d < t:\n print(\"YES\")\nelse: \n print(\"NO\")\n"}, {"source_code": "def main():\n n, t, k, d = map(int, input().split())\n need = n / k \n if n % k == 0:\n need += 1\n time = (need - 1) * t\n print('YES' if time > d else 'NO')\n\n\nif __name__ == '__main__':\n main()"}, {"source_code": "# automate the second oven scenario with a for loop\nn, t, c, d = input().split()\ncakes_needed = int(n)\ntime = int(t)\ncakes_in_progress = int(c)\nsecond_oven = int(d)\n\nsingle_oven_scenario = time * cakes_needed / cakes_in_progress\n\ncounter = 0\ncakes = 0\nfor l in range(0, second_oven, time):\n if l < second_oven:\n cakes += cakes_in_progress\n counter += time\n else:\n counter = counter + ((cakes_needed - cakes) / 2 * time)\nif counter < single_oven_scenario:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n,t,k,d=map(int,input().split())\na = (n//k)*t\nb = t+d\nif k>=n:\n print('NO')\nelse:\n if a<=b:\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "n = list(map(int,input().split()))\not = (n[0] / n[2]) * n[1]\no1 = n[1]\no2 = n[3]\np = n[0] - n[2]\nfor i in range(n[0]):\n if (p > 0 & p == n[2]):\n if (o2 > o1):\n o1 += n[1]\n p -= n[2]\n else:\n o1 += n[1]\n o2 += n[1]\n p -= (n[2]+n[2])\nif (o2 < ot):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n,t,k,d = list(map(int,input().split()))\nTotal_Time = n * t / k\nif Total_Time - d < t :print(\"NO\")\nelse:\n n_new = (Total_Time - d) * k / t\n print(\"YES\" if n_new > k else \"NO\")\n"}, {"source_code": "import math\ndef carrotCakes(n, t, k, d):\n t1, t2 = 0, d\n for i in range(math.ceil(n / k)):\n if t1 <= t2: t1 += t\n else: t2 += t\n if max(t1, t2) < math.ceil(n / k): print('YES')\n else: print('NO')\n\ndef main():\n n, t, k, d = (int(i) for i in input().split())\n carrotCakes(n, t, k, d)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "from math import ceil\nn,t,k,d = map(int, input().split())\nprint(\"YES\" if(ceil(n/k)*t > t) else \"NO\")\n#Aloosh"}, {"source_code": "from math import ceil\nn,t,k,d = map(int, input().split())\nprint(\"YES\" if(ceil(n/k)*t > t) else \"NO\")\n#Aloosh"}, {"source_code": "str=input()\nx=str.split(\" \")\na=int(x[0])\ns=int(x[1])\nd=int(x[2])\nf=int(x[3])\nz=a/d\nif(z==1 and a%d!=0 and f1)and(s>f)):\n print(\"YES\")\n \nelif((z>1)and(s<=f)and(a%d!=0)and(((z)*s)>f)):\n print(\"YES\")\n \nelif((z>1)and(s<=f)and(a%d==0)and(((z-1)*s)>f)):\n print(\"YES\")\n \nelse:\n print(\"NO\")\n"}, {"source_code": "n, t, k, d = map(int, input().split())\nn1 = n\nif n < k:\n\ta = n*(t/k)\nelse:\n\ta = t\nn1 -= k\nwhile n1 > 0:\n\ta += t\n\tn1 -= k\nb = d\nif d > t:\n\tn -= (d/t)*k\nelse:\n\tn -= k\nwhile n>0:\n\tb += t\n\tn -= 2*k\nprint('YES') if a > b else print('NO')\n"}, {"source_code": "import math\ndef compute_rest(oven_capacity, oven_time, cakes, oven_build_time):\n turns = cakes/oven_capacity\n rest = (turns * oven_time) - oven_build_time\n turns = math.floor(cakes/oven_capacity)\n if oven_capacity >= cakes:\n return 'NO' \n elif oven_time <= oven_build_time:\n return 'NO'\n elif rest == oven_time:\n return 'NO' \n else:\n return 'YES' \n \n \n\ninp = list(map(int, input().rstrip().split()))\nprint(compute_rest(inp[2], inp[1], inp[0], inp[3]))\n\n\n\n\n\n"}, {"source_code": "# automate the second oven scenario with a for loop\nn, t, c, d = input().split()\ncakes_needed = int(n)\ntime = int(t)\ncakes_in_progress = int(c)\nsecond_oven = int(d)\n\nsingle_oven_scenario = time * cakes_needed / cakes_in_progress\n\ncounter = 0\ncakes = 0\nfor l in range(0, second_oven, time):\n if l < second_oven:\n cakes += cakes_in_progress\n counter += time\n else:\n counter = counter + ((cakes_needed - cakes) / 2 * time)\nif counter < single_oven_scenario:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import math\nn,t,k,d = input().split()\n\nn,t,k,d = int(n),int(t),int(k),int(d)\n\nexp = math.ceil(n/k) * t\ntime = 0\ntime2 = 0\ncakes = 0\nwhile (True):\n if(time % t == 0 and time != 0):\n cakes += k\n if(time >= d):\n time2 += 1\n if(time2 % t == 0 and time2 != 0):\n cakes += k\n time += 1\n if(cakes >= n):\n break\nif(exp < time):\n print('NO')\nelse :\n print('YES')\n\n \n\n"}, {"source_code": "n,t,k,d=map(int,input().split())\nsecOven=t+d\nfirstOven=(n//k)*t\nif firstOven>secOven:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n, t, k, d = map(int, input().split())\nbefore = (n/k)*t\nisOK = 0\nif k>=n:\n isOK = 0\nelse:\n if d > t:\n x=int(d/t)*k\n x = n-x\n if (x/k)*(t/2) < n:\n isOK = 0\n else:\n after = (x/k)*(t/2) + d\n else:\n after = (n/k)*(t/2) + d\n\n if before <= after:\n isOK = 0\n else:\n isOK = 0\nif isOK ==0:\n print(\"No\")\nelse:\n print(\"YES\")"}, {"source_code": "ntdk = input().strip().split(' ')\nn = int(ntdk[0])\nt = int(ntdk[1])\nk = int(ntdk[2])\nd = int(ntdk[3])\n\n\nif nk:\n print('YES')\n else:\n print('NO')\n\n \n \n \n"}, {"source_code": "n,t,k,d=map(int,input().split())\nu=0--n//k\nu-=d//t+(d%t==0)\nprint('YNEOS'[u<=0::2])"}, {"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)))\nn , t , k , d = tup()\ntime_wo = (n//k )*t\ntimw_wi = (n//(2*k) )*t + d\nif timw_wi <= time_wo:\n print(\"YES\")\nelse:print(\"NO\")"}, {"source_code": "n, t, k, d = map(int, input().split())\n\n\nt1 = 0\nt2 = d\n\none = 0\nb = 0\nwhile b < n:\n one += t\n b += k\n\n\nbaked = 0\n\nwhile baked < n:\n if t1 >= d:\n t2 += t\n baked += k\n\n t1 += t\n baked += k\n\nboth = min(t1, t2)\n\n\nif one <= both:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n,t,k,d = list(map(int,input().split()))\nfrom math import ceil\nfi = ceil(n/k) * t\nif d >= t and fi <= 2*t:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "x = list(map(int, input().rstrip().split()))\n\nif x[0] <= x[2] or x[3] == x[1]:\n print('NO')\nelif x[3] < x[1]:\n print('Yes')\nelse:\n oldt = (x[0]/x[2]) * x[1]\n newn = (x[3] * x[2]) / x[1]\n newt = (newn/x[2]) * x[1]\n if oldt > newt: print('YES')\n else: print('NO')\n\n"}, {"source_code": "import math\nn, time, cakes, build_time = map(int, input().split())\nitr = math.ceil(n/cakes)\nsingle = itr*time\nbuild_overlap = 0 if build_time < time and math.ceil(single - build_time)/time > 1 else build_time % time\nparallel_itr = math.ceil((single-build_time)/time)/2\nparallel_time = parallel_itr*time\nlinear_time = itr-parallel_itr*time\ndouble = build_overlap + parallel_time + linear_time if itr-1 > 1 or build_time < time else single * 2 \nprint(\"YES\" if double < single else \"NO\")"}, {"source_code": "# automate the second oven scenario with a for loop\nimport math\nn, t, c, d = input().split()\ncakes_needed = int(n)\ntime = int(t)\ncakes_in_progress = int(c)\nsecond_oven = int(d)\n\nsingle_oven_scenario = math.ceil(time * cakes_needed / cakes_in_progress)\n\ncounter = 0\ntime_counter = 0\nfor l in range(cakes_needed, -1, cakes_in_progress):\n time_counter += time\n l -= cakes_in_progress\n if time_counter >= second_oven:\n l -= cakes_in_progress\n counter += 1\nfinal_time = counter * time\nif final_time < single_oven_scenario:\n print(\"YES\")\nelse:\n print(\"NO\")"}], "src_uid": "32c866d3d394e269724b4930df5e4407"} {"nl": {"description": "On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard.There are $$$n$$$ bricks lined in a row on the ground. Chouti has got $$$m$$$ paint buckets of different colors at hand, so he painted each brick in one of those $$$m$$$ colors.Having finished painting all bricks, Chouti was satisfied. He stood back and decided to find something fun with these bricks. After some counting, he found there are $$$k$$$ bricks with a color different from the color of the brick on its left (the first brick is not counted, for sure).So as usual, he needs your help in counting how many ways could he paint the bricks. Two ways of painting bricks are different if there is at least one brick painted in different colors in these two ways. Because the answer might be quite big, you only need to output the number of ways modulo $$$998\\,244\\,353$$$.", "input_spec": "The first and only line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \\leq n,m \\leq 2000, 0 \\leq k \\leq n-1$$$)\u00a0\u2014 the number of bricks, the number of colors, and the number of bricks, such that its color differs from the color of brick to the left of it.", "output_spec": "Print one integer\u00a0\u2014 the number of ways to color bricks modulo $$$998\\,244\\,353$$$.", "sample_inputs": ["3 3 0", "3 2 1"], "sample_outputs": ["3", "4"], "notes": "NoteIn the first example, since $$$k=0$$$, the color of every brick should be the same, so there will be exactly $$$m=3$$$ ways to color the bricks.In the second example, suppose the two colors in the buckets are yellow and lime, the following image shows all $$$4$$$ possible colorings. "}, "positive_code": [{"source_code": "import math\n\nn, m, k = [int(x) for x in input().split()]\nc_n_k = math.factorial(n - 1) // math.factorial(n - 1 - k) // math.factorial(k) % 998244353\nc_n_k = (c_n_k * (m % 998244353)) % 998244353\nc_n_k = (c_n_k * (((m - 1) ** k) % 998244353)) % 998244353\nprint(int(c_n_k % 998244353))\n"}, {"source_code": "from decimal import Decimal\nimport operator as op\nfrom functools import reduce\nimport math\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\n\t\nz, m, k = input().split()\nz = int(z)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = math.factorial(z-1)//(math.factorial(k) * math.factorial(z - 1 - k))\npow = (m - 1)**k\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 998244353\n\nn,m,k = [int(x) for x in input().split()]\n\nways = [0]*n\nways[0] = m\n\nfor i in range(1,n):\n for j in reversed(range(1,n)):\n ways[j] = (ways[j]+(m-1)*ways[j-1])%MOD\n\nprint ways[k]%MOD\n"}, {"source_code": "from math import factorial as f;\nn , m , k = map(int,input().split());\nans = (f(n-1)//(f(n-k-1)*f(k)))*m*((m-1)**k)\nprint(int(ans%998244353));\n"}, {"source_code": "mod = 998244353\ndef comb(n, r):\n facn = 1\n for i in range(1, n+1):\n facn = facn * i\n facr = 1\n for i in range(1, r+1):\n facr *= i\n facnr = 1\n for i in range(1, n-r+1):\n facnr *= i\n res = facn // (facnr*facr)\n res = res%mod\n return res\n\n\nnmk = list(map(int , input().split()))\nn = nmk[0]\nm = nmk[1]\nk = nmk[2]\nres = (comb(n-1, k) * m* (m-1)**(k)) % mod\nprint(int(res))\n"}, {"source_code": "from decimal import Decimal\nimport operator as op\nfrom functools import reduce\nimport math\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\n\t\nz, m, k = input().split()\nz = int(z)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = math.factorial(z-1)//(math.factorial(k) * math.factorial(z - 1 - k))\npow = (m - 1)**k\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "import math\n\n\ndef nCr(n, r):\n f = math.factorial\n return f(n) // f(r) // f(n - r)\n\n\nMOD = 998244353\nn, m, k = list(map(int, input().split()))\nres = pow(m - 1, k, MOD)\nres = (res * m) % MOD\nres = res * nCr(n - 1, k) % MOD\nprint(res)"}, {"source_code": "import sys,threading\nsys.setrecursionlimit(4000000)\nthreading.stack_size(10**8)\ndef f(x,y):\n global m,dp\n a=0\n b=0\n if x==1 and y==1:\n return m-1\n if x==1 and y==0:\n return 1\n if dp[x][y]>=0:\n return dp[x][y]\n if y>0 and x>=y:\n a=(m-1)*f(x-1,y-1)\n a%=998244353\n if x>=y:\n b=f(x-1,y)\n b%=998244353\n dp[x][y]=(a+b)%998244353\n return dp[x][y]\ndef main():\n global m,dp\n dp=[[-1 for j in range(2001)] for i in range(2001)]\n n,m,k=map(int,input().split())\n if n>1:\n ans=m*f(n-1,k)\n else:\n ans=m\n print(ans%998244353)\nt=threading.Thread(target=main)\nt.start()\nt.join()\n \n \n \n \n \n"}, {"source_code": "import math\nn , m , k = [int(x) for x in input().split()]\nif k==0:\n\tans=m\nelse:\n\ta=m*(math.factorial(n-1)//(math.factorial(k)*math.factorial(n-1-k)))*((m-1)**k)\n\tans=a%998244353\nprint(ans)"}, {"source_code": "import math\n\nMOD = 998244353\n\nn, m, k = [int(x) for x in input().split()]\n\nans = (math.factorial(n-1)//(math.factorial(k)*math.factorial(n-k-1)))*m*((m-1)**k)\nprint(ans%MOD)"}, {"source_code": "def main():\n n, m, k = map(int, raw_input().split())\n dp = [m] + [0] * k\n mod = 998244353\n for i in xrange(n - 1):\n for j in xrange(k, 0, -1):\n dp[j] = (dp[j] + dp[j-1] * (m - 1)) % mod\n print dp[-1]\nmain()\n"}, {"source_code": "dp=[[0 for j in range(2001)] for i in range(2001)]\nn,m,k=map(int,input().split())\nfor i in range(1,n+1):\n for j in range(k+1):\n if j==0 and i==1:\n dp[i][j]=m\n continue\n if j<=i-1:\n dp[i][j]=(m-1)*dp[i-1][j-1]+dp[i-1][j]\n dp[i][j]%=998244353\nprint(dp[n][k])\n \n \n \n \n \n"}, {"source_code": "\ndef binomialCoef(n, k): \n C = [[0 for x in range(k+1)] for x in range(n+1)]\n mod = 998244353\n for i in range(n+1): \n for j in range(min(i, k)+1): \n if j == 0 or j == i:\n C[i][j] = 1\n else: \n C[i][j] = (C[i-1][j-1] + C[i-1][j] )%mod\n\n return C[n][k] \n\nn,m,k = map(int,input().split())\nmod = 998244353\ny = binomialCoef(n-1, k)\nz = (m * ((m-1)**k))%mod\nprint(int((y*z)%mod))"}, {"source_code": "mod = 998244353\nfac = [1]\nfor i in range(1, 2001):\n fac.append(fac[-1] * i % mod)\n\n\ndef fexp(x, y):\n ans = 1\n while y > 0:\n if y % 2 == 1:\n ans = ans * x % mod\n x = x * x % mod\n y //= 2\n return ans\n\n\ndef rev(x):\n return fexp(x, mod - 2)\n\n\ndef c(n, k):\n return fac[n] * rev(fac[n - k]) * rev(fac[k]) % mod\n\n\nn, m, k = map(int, input().split(' '))\nprint(c(n - 1, k) * m * fexp(m - 1, k) % mod)\n"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(k):\n\tans *= (n - 1 - i)\n\tans //= (i + 1)\nprint((ans * m * (m - 1) ** k) % 998244353)"}, {"source_code": "N = 2003\nMOD = 998244353\nnCr = [[] for _ in range(N)]\n\n\ndef init():\n for i in range(N):\n nCr[i] = [0 for _ in range(N)]\n for i in range(N):\n nCr[i][0] = 1\n for i in range(1, N):\n for j in range(1, N):\n nCr[i][j] = (nCr[i - 1][j] + nCr[i - 1][j - 1]) % MOD\n\n\ninit()\nn, m, k = map(int, input().split())\nprint((nCr[n - 1][k] * m * pow(m - 1, k, MOD)) % MOD)\n"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(k):\n\tans *= (n - 1 - i)\n\tans //= (i + 1)\nprint((ans * m * (m - 1) ** k) % 998244353)"}, {"source_code": "n, m, k = map(int, input().split())\nmod = 998244353\n\nsame_bricks = n - 1 - k\ntotal = m # First brick\n# Different bricks\nfor i in range(k):\n\ttotal *= (m-1)\n\ttotal %= mod\n\n# Choosing same bricks\n# times (n-1 choose k)\nval = 1\nfor i in range(n - k, n):\n\tval *= i\n\nfor i in range(1, k+1):\n\tval //= i\n\ntotal *= val\ntotal %= mod\nprint(total)\n"}, {"source_code": "n,m,k=[int(x) for x in input().split()]\ndp=[0]*(n-1)\nif len(dp)>0:\n dp[0]=n-1\n n-=1\n for i in range(1,n):\n n-=1\n dp[i]=((dp[i-1]*n)//(i+1))\n if k==0:\n print(m)\n else:\n print((dp[k-1]*m*(m-1)**(k))%998244353)\nelse:\n print(m)\n\n"}, {"source_code": "import math\nf=math.factorial\nn,m,k=map(int,input().split())\nprint(f(n-1)//f(k)//f(n-k-1)*m*(m-1)**k%998244353)"}, {"source_code": "mod = 998244353\nfac = [1]\nfor i in range(1, 2001):\n fac.append(fac[-1] * i % mod)\n\n\ndef fexp(x, y):\n ans = 1\n while y > 0:\n if y % 2 == 1:\n ans = ans * x % mod\n x = x * x % mod\n y //= 2\n return ans\n\n\ndef rev(x):\n return fexp(x, mod - 2)\n\n\ndef c(n, k):\n return fac[n] * rev(fac[n - k]) * rev(fac[k]) % mod\n\n\nn, m, k = map(int, input().split(' '))\nprint(c(n - 1, k) * m * fexp(m - 1, k) % mod)\n"}, {"source_code": "Z = 998244353\n\n\ndef ncr(n, r):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % Z\n den = (den * (i + 1)) % Z\n\n return (num * pow(den, Z - 2, Z)) % Z\n\n\nn, m, k = map(int, input().split())\n\nprint((ncr(n - 1, k) * m * pow(m - 1, k, Z)) % Z)\n"}, {"source_code": "s=input().split()\nn,m,k=list(map(int,s))\nMOD=998244353\nans=m\nfor i in range(k):\n ans=(ans*(m-1))%MOD\nif k>n//2:\n k=n-1-k\nfor i in range(1,k+1):\n ans=ans*(n-1-k+i)//i\nprint(ans%MOD)"}, {"source_code": "import math\nf = math.factorial\nn,m,k = map(int,input().split())\naa=f(n-1)//f(k)//f(n-k-1)*(m)*(m-1)**k%998244353\nprint(aa)"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(k):\n\tans *= (n - 1 - i)\n\tans //= (i + 1)\nprint((ans * m * (m - 1) ** k) % 998244353)"}, {"source_code": "n,m,k=map(int,input().split())\ncomb=1\npower=1\nfact=1\nM=998244353\nfor i in range(k):\n comb=comb*(n-1-i)\n power*=(m-1)\n power=power%M\n fact*=(k-i)\nprint((((comb//fact)%M)*(m)*(power%M))%M)"}, {"source_code": "# -*- coding: utf-8 -*- \nimport heapq, math, random, re, string, sys\nfrom bisect import bisect_left, bisect_right, insort_left, insort_right\nfrom collections import defaultdict, deque, Counter\nfrom decimal import Decimal, getcontext\nfrom fractions import gcd, Fraction\nfrom itertools import combinations, permutations, product\nfrom math import ceil, exp, log, sqrt\nfrom Queue import Queue, PriorityQueue\n\ngetcontext().prec = 100\nsys.setrecursionlimit(100000)\nMOD = 998244353\nINF = float('+inf')\n\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()\n'''\n\npr = lambda args: sys.stdout.write(' '.join(map(str, args)) + '\\n')\nepr = lambda args: sys.stderr.write(' '.join(map(str, args)) + '\\n')\ndie = lambda args: pr(args) ^ exit(0)\n\n#n = input()\n#a = [input()for _ in xrange(n)]\nn, m, k = map(int, raw_input().split())\n#a = [map(int,raw_input().split())for _ in xrange(n)]\n#s = raw_input()\n#a = [raw_input() for _ in xrange(n)]\n\ndef nCk(n, k):\n if k < 0 or k > n:\n return 0\n if k == 0 or k == n:\n return 1\n total_ways = 1\n for i in range(min(k, n - k)):\n total_ways = total_ways * (n - i) // (i + 1)\n return total_ways\n\n\nprint (nCk(n - 1, k) * m * pow(m - 1, k, MOD)) % MOD"}, {"source_code": "def main():\n n, m, k = map(int, raw_input().split())\n dp = [m] + [0] * k\n mod = 998244353\n for i in xrange(n - 1):\n for j in xrange(k, 0, -1):\n dp[j] = (dp[j] + dp[j-1] * (m - 1)) % mod\n print dp[-1]\nmain()\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\nadd = lambda a, b: (a + b) % 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)\nncr = lambda n, r: div(fact(n - r + 1, n), fact(1, r))\nrints = lambda: [int(x) for x in stdin.readline().split()]\nmod = 998244353\n\nn, m, k = rints()\nans = mult(m * pow(m - 1, k, mod), ncr(n - 1, k))\nprint(ans)\n"}, {"source_code": "import sys\nmod = 998244353\nbricks, colors, left = map(int, input().split())\ndp = [[0] * (left + 1) for i in range(bricks + 1)]\nif left == 0:\n print(colors)\n sys.exit()\nfor i in range(1, bricks + 1):\n dp[i][0] = colors\nfor i in range(1, bricks + 1):\n for j in range(1, left + 1):\n dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1] * (colors - 1)) % mod\nprint(dp[bricks][left] % mod)\n"}, {"source_code": "from math import factorial as f\nn,m,k=map(int,input().split())\nprint(f(n-1)//f(k)//f(n-k-1)*m*(m-1)**k%998244353)"}, {"source_code": "n,m,k = [int(x) for x in input().split()]\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\ndp[0][0] = m\nfor n1 in range(1,n):\n dp[n1][0] = m\n #print(dp[n1][0])\nfor n1 in range(1,n):\n for k1 in range(1,k+1):\n dp[n1][k1] = (dp[n1-1][k1]+dp[n1-1][k1-1]*(m-1)) % 998244353\nprint(dp[n-1][k])\n\n#for arr in dp:\n# print(arr)\n \n\n \n\n"}, {"source_code": "# -*- coding: utf-8 -*- \nimport heapq, math, random, re, string, sys\nfrom bisect import bisect_left, bisect_right, insort_left, insort_right\nfrom collections import defaultdict, deque, Counter\nfrom decimal import Decimal, getcontext\nfrom fractions import gcd, Fraction\nfrom itertools import combinations, permutations, product\nfrom math import ceil, exp, log, sqrt\nfrom Queue import Queue, PriorityQueue\n\ngetcontext().prec = 100\nsys.setrecursionlimit(100000)\nMOD = 998244353\nINF = float('+inf')\n\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()\n'''\n\npr = lambda args: sys.stdout.write(' '.join(map(str, args)) + '\\n')\nepr = lambda args: sys.stderr.write(' '.join(map(str, args)) + '\\n')\ndie = lambda args: pr(args) ^ exit(0)\n\n#n = input()\n#a = [input()for _ in xrange(n)]\nn, m, k = map(int, raw_input().split())\n#a = [map(int,raw_input().split())for _ in xrange(n)]\n#s = raw_input()\n#a = [raw_input() for _ in xrange(n)]\n\ndef nCk(n, k):\n if k < 0 or k > n:\n return 0\n if k == 0 or k == n:\n return 1\n total_ways = 1\n for i in range(min(k, n - k)):\n total_ways = total_ways * (n - i) // (i + 1)\n return total_ways\n\n\nprint (nCk(n - 1, k) * m * pow(m - 1, k, MOD)) % MOD"}, {"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_), 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 binomial(n, k):\n \"\"\"\n A fast way to calculate binomial coefficients by Andrew Dalke.\n See http://stackoverflow.com/questions/3025162/statistics-combinations-in-python\n \"\"\"\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\ndef solve(n, m, k):\n parts = m * pow(m - 1, k)\n return (binomial(n - 1, k) * parts) % 998244353\n\nif __name__ == \"__main__\":\n \"\"\"the solve(*args) structure is needed for testing purporses\"\"\"\n n, m, k = stdin()\n print(solve(n, m, k))"}, {"source_code": "from math import factorial as f\nmod = 998244353\n\nn,m,k = map(int,input().split())\n\nans=1\nfor i in range(k):\n ans=(ans*(m-1))%mod\n\nans=(ans*m)%mod\n\nval = f(n-1)//(f(k)*f(n-1-k))\n\nans=(ans*val)%mod\n\nprint(ans)"}, {"source_code": "#\t!/bin/env python3\n#\tcoding: UTF-8\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology and Management,Gwalior\n\n#\tQuestion Link\n#\thttps://codeforces.com/problemset/problem/1081/C\n#\n\n# ///==========Libraries, Constants and Functions=============///\n\n\nimport sys\n\ninf = float(\"inf\")\nmod = 998244353\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, m, k = get_ints()\n dp = [[0 for _ in range(2005)] for _ in range(2005)]\n # dp[i][j] is the ways of coloring that there are j bricks of\n # different color from its adjacent left brick\n dp[1][0] = m\n for i in range(1, n):\n for j in range(k+1):\n # i+1'th brick has same color as that of i'th brick\n dp[i+1][j] = (dp[i+1][j]+dp[i][j]) % mod\n # m-1 ways of coloring this next block with a different color\n dp[i+1][j+1] = ((dp[i+1][j+1]+dp[i][j])*(m-1)) % mod\n print(dp[n][k])\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import math\n\nMOD = 998244353\n\nn, m, k = [int(x) for x in input().split()]\n\nans = (math.factorial(n-1)//(math.factorial(k)*math.factorial(n-k-1)))*m*((m-1)**k)\nprint(ans%MOD)"}, {"source_code": "n, m, k = map(int, input().split())\nmod = 998244353\ndp = [[0] * (k + 1) for i in range(n)]\ndp[0][0] = m\nfor i in range(1, n):\n for j in range(k + 1):\n dp[i][j] = dp[i - 1][j]\n if j > 0:\n dp[i][j] += dp[i - 1][j - 1] * (m - 1)\n dp[i][j] %= mod\nprint(dp[n-1][k])\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nN, M, K = map(int, input().split())\nMOD = 998244353\n\ndp = [[0] * 2002 for i in range(2002)]\ndp [1][0] = M\n\nfor i in range(1, N):\n for j in range(K+1):\n dp[i+1][j] = (dp[i+1][j] + dp[i][j]) % MOD\n dp[i+1][j+1] = (dp[i][j] * (M-1)) % MOD\n\nprint(dp[N][K])\n"}, {"source_code": "import math\nimport bisect\nimport itertools\nimport sys\nI=lambda : sys.stdin.readline()\nmod=998244353 \nfact=[1]*20001\nifact=[1]*20001\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]0 and m==1) or k>=n:\n print(0)\nelif k==0:\n print(m)\nelse:\n k1=ncr1(n-1,k)\n k1*=pow(m-1,k,mod1)\n k1%=mod\n k1*=m\n print(k1%mod)\n "}, {"source_code": "import sys\nsys.setrecursionlimit(10000)\n\nD = {(1,0):1,(1,1):0}\nn,m,k = [int(x) for x in input().split()]\n\ndef f(n,k):\n if k == 0:\n return m\n if k >= n:\n return 0\n if (n,k) in D:\n return D[(n,k)]\n else:\n ans = (f(n-1,k)+(m-1)*f(n-1,k-1))%998244353\n D[(n,k)] = ans\n return ans\n \nprint(f(n,k))"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nf = math.factorial\nprint(f(n-1) // f(k) // f(n-k-1) * m * (m-1) ** k % 998244353)\n"}, {"source_code": "from __future__ import division, print_function\n\nimport math\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# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n from math import factorial as fac\n n,m,k = map(int , input().split())\n \n dp = [[0 for i in range(k + 1)] for i in range(n + 1)]\n\n dp[1][0] = m\n\n for i in range(2,n + 1):\n for j in range(k + 1):\n dp[i][j] = dp[i - 1][j]\n if j > 0:\n dp[i][j] += dp[i - 1][j - 1] * (m - 1)\n dp[i][j] %= 998244353\n print(dp[n][k] % 998244353)\n return\n #end main\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()"}, {"source_code": "Z = 998244353\n\n\ndef ncr(n, r):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % Z\n den = (den * (i + 1)) % Z\n\n return (num * pow(den, Z - 2, Z)) % Z\n\n\nn, m, k = map(int, input().split())\n\nprint((ncr(n - 1, k) * m * pow(m - 1, k, Z)) % Z)\n"}, {"source_code": "import sys\nmod = 998244353\nbricks, colors, left = map(int, input().split())\ndp = [[0] * (left + 1) for i in range(bricks + 1)]\nif left == 0:\n print(colors)\n sys.exit()\nfor i in range(1, bricks + 1):\n dp[i][0] = colors\nfor i in range(1, bricks + 1):\n for j in range(1, left + 1):\n dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1] * (colors - 1)) % mod\nprint(dp[bricks][left] % mod)\n"}, {"source_code": "from operator import mul\nfrom functools import reduce\n\ndef ncr(n, r):\n r = min(r, n-r)\n numer = reduce(mul, range(n, n-r, -1), 1)\n denom = reduce(mul, range(1, r+1), 1)\n return numer // denom\n\ndef mult(a,b):\n return (a*b) % mod\n\nn,m,k = map(int, input().split())\nmod = 998244353\nans = 1\nans = mult(ans, (m-1)**k)\nans = mult(ans, m)\nans = mult(ans, ncr(n-1, k))\n\nprint(ans)"}, {"source_code": "n, m, k = map(int, input().split())\ndp = [[m if i == 0 else 0 for i in range(k + 2)] for j in range(n + 1)]\ndp[0][0] = 0\nmod = 998244353\nfor i in range(1, n + 1):\n for j in range(1, k + 2):\n dp[i][j] = (dp[i - 1][j] + (m - 1) * dp[i - 1][j - 1]) % mod\n\n\nprint(dp[n][k] % mod)"}, {"source_code": "s=input().split()\nn,m,k=list(map(int,s))\nMOD=998244353\nans=m\nfor i in range(k):\n ans=(ans*(m-1))%MOD\nif k>n//2:\n k=n-1-k\nfor i in range(1,k+1):\n ans=ans*(n-1-k+i)//i\nprint(ans%MOD)"}, {"source_code": "#file = open(\"input.txt\", \"r\")\ndata = input().split()\nn = int(data[0])\nm = int(data[1])\nk = int(data[2])\nK = 998244353\n\ngt = [0 for i in range(2005)]\nrev = [0 for i in range(2005)]\n\ndef mu(a, n):\n\tif (n == 0): return 1\n\tq = mu(a, n // 2)\n\tif (n % 2 == 0): return q * q % K\n\treturn q * q % K * a % K\n\ngt[0] = rev[0] = 1\nfor i in range(1, 2001):\n\tgt[i] = gt[i - 1] * i % K\n\trev[i] = mu(gt[i], K - 2)\n\nres = gt[n - 1] * rev[k] % K * rev[n - k - 1] % K\n\nres = res * m % K\nres = res * mu(m - 1, k) % K\nprint(res)\n\n"}, {"source_code": "from math import factorial\nn, m, k = map(int, input().split())\nM = 998244353\nfn = 1\nfnk1 = 1\nfk = 1\nfor i in range(1, n):\n fn *= i\n fn %= M\nfor i in range(1, n - k):\n fnk1 *= i\n fnk1 %= M\nfor i in range(1, k + 1):\n fk *= i\n fk %= M\nprint((fn * pow((fnk1 * fk), M - 2, M)) * m * pow(m - 1, k, M) % M)\n"}, {"source_code": "dp=[[0 for j in range(2001)] for i in range(2001)]\nn,m,k=map(int,raw_input().split())\nfor i in range(1,n+1):\n for j in range(k+1):\n if j==0 and i==1:\n dp[i][j]=m\n continue\n if j<=i-1:\n dp[i][j]=(m-1)*dp[i-1][j-1]+dp[i-1][j]\n dp[i][j]%=998244353\nprint(dp[n][k])\n \n \n \n \n \n"}, {"source_code": "'''\n\n Online Python Compiler.\n Code, Compile, Run and Debug python program online.\nWrite your code in this editor and press \"Run\" button to execute it.\n\n'''\n\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\nresult = 1\nk = k + 1\n\nfor i in range(k-1):\n result *= n-1-i\n result //= 1+i\n\nresult = result % 998244353\nresult *= m\n\nfor i in range(k-1):\n result *= m-1\n\nresult = result % 998244353\n\nif result < 0: \n result += 998244353\n\nprint(result)\n\n "}, {"source_code": "import math\n\nn, m, k = [int(x) for x in input().split()]\nc_n_k = math.factorial(n - 1) // math.factorial(n - 1 - k) // math.factorial(k) % 998244353\nc_n_k = (c_n_k * (m % 998244353)) % 998244353\nc_n_k = (c_n_k * (((m - 1) ** k) % 998244353)) % 998244353\nprint(int(c_n_k % 998244353))\n"}, {"source_code": "pri=998244353\nn,m,k=map(int,input().split())\ndp=[[0 for i in range(n+1)] for i in range(k+1)]\n#i denote , number of different bricks , j denotes total size\nfor i in range(k+1):\n for j in range(n+1):\n if(j==0):\n dp[i][j]=0\n continue;\n \n if(i==0):\n dp[i][j]=m\n continue;\n \n if(i>j-1):\n dp[i][j]=0\n continue;\n dp[i][j]=dp[i-1][j-1]*(m-1)+dp[i][j-1]\n dp[i][j]%=pri\n\nprint(dp[-1][-1])\n \n \n \n"}, {"source_code": "n, m, k = map(int, input().split())\nmod = 998244353\n\nsame_bricks = n - 1 - k\ntotal = m # First brick\n# Different bricks\nfor i in range(k):\n\ttotal *= (m-1)\n\ttotal %= mod\n\n# Choosing same bricks\n# times (n-1 choose k)\nval = 1\nfor i in range(n - k, n):\n\tval *= i\n\nfor i in range(1, k+1):\n\tval //= i\n\ntotal *= val\ntotal %= mod\nprint(total)\n"}, {"source_code": "import sys\n#setrecursionlimit(100)\nsys.setrecursionlimit(1000000)\nM = 998244353\ndef Qpow(x, y):\n if y == 0:\n return 1\n else :\n ret = Qpow(x, (int)(y / 2)) % M\n ret *= ret\n ret %= M\n if y % 2 == 1:\n ret *= x\n ret %= M;\n return ret\n\nn, m, k = map(int, input().split())\n#ans = Qpow(a, b)\n#print(ans)\nfact = [0 for i in range(0, 5005)]\nfact[0] = 1\nfor i in range(1, 5002 + 1):\n fact[i] = (fact[i - 1] * i) % M\n#for i in range(1, 10):\n# print((fact[i])) \nway = (fact[k] * fact[n - 1 - k]) % M;\nway = (fact[n - 1] * Qpow(way, M - 2) % M) % M\nans = (way * (Qpow(m - 1, k) % M + M) * m) % M\nif ans < 0:\n ans += M\n ans %= M\nprint(ans)"}, {"source_code": "import math\nf=math.factorial\nn,m,k=map(int,raw_input().split())\nprint f(n-1)/f(k)/f(n-k-1)*m*(m-1)**k%998244353"}, {"source_code": "#import resource\nimport sys\n#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])\nimport threading\nthreading.stack_size(2**25)\nsys.setrecursionlimit(10**6)\nmod=998244353\nfact=[1]\nfor i in range(1,3001):\n fact.append((fact[-1]*i)%mod)\nifact=[0]*3001\nifact[3000]=pow(fact[3000],mod-2,mod)\nfor i in range(3000,0,-1):\n ifact[i-1]=(i*ifact[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\n#from random import randint as rn\nfrom Queue import Queue as Q\ndef modinv(n,p):\n return pow(n,p-2,p)\ndef ncr(n,r,p):\n t=((fact[n])*((ifact[r]*ifact[n-r])%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\ndef isprime(x):\n p=int(math.sqrt(x))+1\n if(x==1):\n return 0\n for i in range(2,p):\n if(x%p==0):\n return 0\n return 1\n\"\"\"**************************************************************************\"\"\"\nn,m,k=map(int,raw_input().split())\np=ncr(n-1,k,mod)\nq=m\nfor i in range(k):\n q=(q*(m-1))%mod\np=(p*q)%mod\nprint p\n"}, {"source_code": "n , m , k = map(int,input().split(' '))\n# dp[i][j] <- no of ways of painting first i bricks such that j bricks are different from their left \nMOD = 998244353\ndp = [[0]*(k+1) for _ in range(n)]\ndp[0][0] = m #base case\nfor i in range(1,n) :\n for j in range(min(i+1,k+1)) :\n dp[i][j] = ( (0 if j==0 else (dp[i-1][j-1]*(m-1))%MOD) + dp[i-1][j])%MOD\n# print(dp)\nprint(dp[-1][-1])"}, {"source_code": "import sys, math\nfrom sys import stdin, stdout\nrem = 998244353\n\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,m,k=take()\n\ndp=[[0 for i in range(m+1)] for j in range(n+1)]\narr=[[0 for i in range(n+1)] for j in range(n+1)]\n\nfor i in range(1,m+1):\n dp[1][i]=1\ntot=[0 for i in range(n+1)]\ntot[1]=m\nfor i in range(2,n+1):\n for j in range(1,m+1):\n dp[i][j]=(tot[i-1]-dp[i-1][j])%rem\n tot[i]+=dp[i][j]\n tot[i]%=rem\n\n#print arr\nfor i in range(n+1):\n arr[i][0]=1\nfor i in range(1,n+1):\n for j in range(1,i+1):\n arr[i][j]=arr[i-1][j]+arr[i-1][j-1]\n arr[i][j]%=rem\n#print arr[n-1][k]\nprint (arr[n-1][k]*tot[k+1])%rem\n\n\n\n\n"}, {"source_code": "def fact(n):\n if n==0:\n return 1\n else:\n return fact(n-1)*n\ndef C(n, k):\n return fact(n)//(fact(n-k)*fact(k))\nn, m, k=map(int, input().split())\nprint(m*((m-1)**k)*C(n-1, k)%998244353)\n"}, {"source_code": "Z = 998244353\n\n\ndef ncr(n, r):\n num = den = 1\n for i in range(r):\n num = (num * (n - i)) % Z\n den = (den * (i + 1)) % Z\n\n return (num * pow(den, Z - 2, Z)) % Z\n\n\nn, m, k = map(int, input().split())\n\nprint((ncr(n - 1, k) * m * pow(m - 1, k, Z)) % Z)\n"}, {"source_code": "mod = 998244353\ndef comb(n, r):\n facn = 1\n for i in range(1, n+1):\n facn = facn * i\n facr = 1\n for i in range(1, r+1):\n facr *= i\n facnr = 1\n for i in range(1, n-r+1):\n facnr *= i\n res = facn // (facnr*facr)\n res = res%mod\n return res\n\n\nnmk = list(map(int , input().split()))\nn = nmk[0]\nm = nmk[1]\nk = nmk[2]\nres = (comb(n-1, k) * m* (m-1)**(k)) % mod\nprint(int(res))\n"}, {"source_code": "import math\nf=math.factorial\nn,m,k=map(int,input().split())\nmod = 998244353\nret=f(n-1)//(f(k)*f(n-1-k))*m*((m-1)**k)%mod\nprint(ret)"}, {"source_code": "#\t!/bin/env python3\n#\tcoding: UTF-8\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology and Management,Gwalior\n\n#\tQuestion Link\n#\thttps://codeforces.com/problemset/problem/1081/C\n#\n\n# ///==========Libraries, Constants and Functions=============///\n\n\nimport sys\n\ninf = float(\"inf\")\nmod = 998244353\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, m, k = get_ints()\n dp = [[0 for _ in range(2005)] for _ in range(2005)]\n # dp[i][j] is the ways of coloring that there are j bricks of\n # different color from its adjacent left brick\n dp[1][0] = m\n for i in range(1, n):\n for j in range(k+1):\n # i+1'th brick has same color as that of i'th brick\n dp[i+1][j] = (dp[i+1][j]+dp[i][j]) % mod\n # m-1 ways of coloring this next block with a different color\n dp[i+1][j+1] = ((dp[i+1][j+1]+dp[i][j])*(m-1)) % mod\n print(dp[n][k])\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "MOD = 998244353\n\nn, nColors, nDiff = map(int, input().split())\n\ndp = [[0 for _ in range(nDiff + 1)] for _ in range(n)]\ndp[0][0] = nColors\nfor size in range(1, n):\n for cnt in range(nDiff + 1):\n dp[size][cnt] += dp[size - 1][cnt]\n dp[size][cnt] %= MOD\n if cnt - 1 >= 0:\n dp[size][cnt] += (dp[size - 1][cnt - 1] * (nColors - 1)) % MOD\n dp[size][cnt] %= MOD\nprint(dp[n - 1][nDiff])"}, {"source_code": "#\t!/bin/env python3\n#\tcoding: UTF-8\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology and Management,Gwalior\n\n#\tQuestion Link\n#\thttps://codeforces.com/problemset/problem/1081/C\n#\n\n# ///==========Libraries, Constants and Functions=============///\n\n\nimport sys\n\ninf = float(\"inf\")\nmod = 998244353\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, m, k = get_ints()\n # dp[i][j] is the ways of coloring that there are j bricks of\n # different color from its adjacent left brick\n dp[1][0] = m\n for i in range(1, n):\n for j in range(k+1):\n # i+1'th brick has same color as that of i'th brick\n dp[i+1][j] = (dp[i+1][j]+dp[i][j]) % mod\n # m-1 ways of coloring this next block with a different color\n dp[i+1][j+1] = ((dp[i+1][j+1]+dp[i][j])*(m-1)) % mod\n print(dp[n][k])\n\n\nif __name__ == \"__main__\":\n dp = [[0 for _ in range(2005)] for _ in range(2005)]\n main()\n"}, {"source_code": "import math\ndef binom(n, k):\n return math.factorial(n) // math.factorial(k) // math.factorial(n - k)\nm = list(map(int, input().split())) \nn = m[0] \nc = m[1] \nk = m[2]\nprint(int(binom(n-1,k)*c*((c-1)**k)%(998244353)))"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nf = math.factorial(n-1)//(math.factorial(k)*math.factorial(n-k-1))\nf*=m\nf*=(m-1)**k\nf%=mod\nprint(int(f))"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nf = math.factorial\nprint(f(n-1) // f(k) // f(n-k-1) * m * (m-1) ** k % 998244353)\n"}, {"source_code": "from math import factorial as f\nn, m, k = [int(x) for x in input().split()]\nif k == 0: print(m)\nelse:\n a = f(n - 1)\n b = f(k)\n c = f(n - 1 - k)\n d = b * c\n e = a // d\n t = e * m * ((m - 1) ** k)\n print(t % 998244353)"}, {"source_code": "import sys,bisect\nfrom math import floor,ceil\ninput = sys.stdin.readline\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\nmod = 998244353\n############ ---- USER DEFINED INPUT FUNCTIONS ---- ############\ndef inp():\n return(int(input().rstrip()))\ndef inlt():\n return(list(map(int,input().rstrip().split())))\ndef insr():\n s = input().rstrip()\n return(s[:len(s) - 1])\ndef invr():\n return(map(int,input().rstrip().split()))\n################################################################\n############ ---- THE ACTUAL CODE STARTS BELOW ---- ############\n\nn,m,k = invr()\nresult = (m * pow(m - 1,k,mod))%mod\n\nprint((result * ncr(n - 1, k))%mod)\n"}, {"source_code": "mod=998244353 \ndef _mp():\n\treturn map(int,raw_input().split())\nn,m,k=_mp()\norig=n\n\t\n#print -1\n\ndef modinverse(n):\n\treturn pow(n,mod-2,mod)\ndef _pncr(n,r):\n\tc=[0]*(r+1)\n\tres=1\n\tc[0]=1\n\t#k=min(k,n-k)\n\tfor i in range(1,n+1):\n\t\tfor j in range(min(i,r),0,-1):\n\t\t\tc[j]=(c[j]+c[j-1])%mod\n\treturn c[r]\n\nans=m\nfor i in range(k):\n\tans=(ans*(m-1))%mod\n\nans=ans*_pncr(orig-1,k)\nprint ans%mod"}, {"source_code": "n, m, k = map(int, input().split())\nt = 1\nn -= 1\nfor i in range(n - k + 1, n + 1):\n\tt *= i\nfor j in range(1, k + 1):\n\tt //= j\nfor i in range(k):\n\tt *= (m - 1)\n\tt %= 998244353\nprint(m * t % 998244353)"}, {"source_code": "'''input\n3 2 1\n6 3 2\n5 3 0\n3 3 1\n3 3 0\n'''\nn, m, k = map(int, input().split())\nMOD = 998244353\nans = m * pow(m - 1, k, MOD) % MOD\n'''\nfor i in range(k + 1):\n\tif i & 1:\n\t\tans -= m * pow(m - 1, k - i, MOD)\n\telse:\n\t\tans += m * pow(m - 1, k - i, MOD)\n'''\n\n\nfor i in range(n - k, n):\n\tans = ans * i\nfor i in range(n - k, n):\n\t# print(n - 1 - i)\n\tans = ans // (n - i)\n'''\nfor i in range(1, k + 1):\n\tprint(ans)\n\tans = ans * (n - 1 - i) * pow(i, MOD - 2, MOD) % MOD\n'''\nprint(ans % MOD)\n"}, {"source_code": "n,m,k = map(int,input().split())\n\nd = [[0 for _ in range(k+1)] for _ in range(n)]\n\nd[0][0]=m\nfor i in range(1,n):\n for j in range(min(n,k+1)):\n if j==0:\n d[i][j] = d[i-1][j]\n else:\n d[i][j] = d[i-1][j]+(m-1)*d[i-1][j-1]\n d[i][j]%=998244353\n\nprint(d[n-1][k])\n"}, {"source_code": "from math import factorial as f\n\nn, m, k = map(int, raw_input().split())\n\nprint (f(n - 1) / f(k) / f(n - 1 - k) * m * (m - 1) ** k) % 998244353"}, {"source_code": "n,m,k = map(int, input().split())\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\nfor i in range(n):\n dp[i][0] = m\nfor i in range(1,n):\n for j in range(1,k+1):\n dp[i][j] = (m-1)*dp[i-1][j-1] + dp[i-1][j]\n dp[i][j] %= 998244353\n#print(dp)\nprint(dp[n-1][k])\n"}, {"source_code": "n, m, k=map(int,input().split())\n\nif k==0:\n\tprint(m)\n\nelif m==1:\n\tprint(0)\n\n\n\nelse:\n\ttotal1=m*pow(m-1,k)%998244353\n\ttotal2=1\n\tfor i in range(1,k+1):\n\t\ttotal2=total2*(n-i)\n\tfor i in range(1,k+1):\n\t\ttotal2=total2//i\n\n\tt=total1*total2%998244353\n\n\tprint(t)\n"}, {"source_code": "import math\nmod = 998244353\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\nprint((math.comb(n-1, k) * (m * (m-1) ** k)) % mod)"}, {"source_code": "dp=[[0 for j in range(2001)] for i in range(2001)]\nn,m,k=map(int,raw_input().split())\nfor i in range(1,n+1):\n for j in range(k+1):\n if j==0 and i==1:\n dp[i][j]=m\n continue\n if j<=i-1:\n dp[i][j]=(m-1)*dp[i-1][j-1]+dp[i-1][j]\n dp[i][j]%=998244353\nprint(dp[n][k])\n \n \n \n \n \n"}, {"source_code": "import math\nimport bisect\nimport itertools\nimport sys\nI=lambda : sys.stdin.readline()\nmod=998244353 \nfact=[1]*20001\nifact=[1]*20001\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]0 and m==1) or k>=n:\n print(0)\nelif k==0:\n print(m)\nelse:\n k1=ncr1(n-1,k)\n k1*=pow(m-1,k,mod1)\n k1%=mod\n k1*=m\n print(k1%mod)\n "}, {"source_code": "n,m,k=[int(x) for x in input().split()]\ndp=[0]*(n-1)\nif len(dp)>0:\n dp[0]=n-1\n n-=1\n for i in range(1,n):\n n-=1\n dp[i]=((dp[i-1]*n)//(i+1))\n if k==0:\n print(m)\n else:\n print((dp[k-1]*m*(m-1)**(k))%998244353)\nelse:\n print(m)\n\n"}, {"source_code": "'''\n\n Online Python Compiler.\n Code, Compile, Run and Debug python program online.\nWrite your code in this editor and press \"Run\" button to execute it.\n\n'''\n\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\nresult = 1\nk = k + 1\n\nfor i in range(k-1):\n result *= n-1-i\n result //= 1+i\n\nresult = result % 998244353\nresult *= m\n\nfor i in range(k-1):\n result *= m-1\n\nresult = result % 998244353\n\nif result < 0: \n result += 998244353\n\nprint(result)\n\n "}, {"source_code": "import math\n\nn, m, k = [int(x) for x in input().split()]\nc_n_k = math.factorial(n - 1) // math.factorial(n - 1 - k) // math.factorial(k) % 998244353\nc_n_k = (c_n_k * (m % 998244353)) % 998244353\nc_n_k = (c_n_k * (((m - 1) ** k) % 998244353)) % 998244353\nprint(int(c_n_k % 998244353))\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nf = math.factorial(n-1)//(math.factorial(k)*math.factorial(n-k-1))\nf*=m\nf*=(m-1)**k\nf%=mod\nprint(int(f))"}, {"source_code": "def fact(n):\n\tans = 1\n\tfor i in range(n, 0, -1):\n\t\tans *= i\n\treturn ans\n \ndef c_n_k(n, k):\n\treturn (fact(n) // (fact(k) * fact(n - k)))\n \n\nn, m, k = map(int, input().split())\nprint(c_n_k(n - 1, k) * ((m - 1) ** k) * m % 998244353)"}, {"source_code": "from math import factorial as f\n\nn, m, k = map(int, raw_input().split())\n\nprint (f(n - 1) / f(k) / f(n - 1 - k) * m * (m - 1) ** k) % 998244353"}, {"source_code": "mod = 998244353\ndef comb(n, r):\n facn = 1\n for i in range(1, n+1):\n facn = facn * i\n facr = 1\n for i in range(1, r+1):\n facr *= i\n facnr = 1\n for i in range(1, n-r+1):\n facnr *= i\n res = facn // (facnr*facr)\n res = res%mod\n return res\n\n\nnmk = list(map(int , input().split()))\nn = nmk[0]\nm = nmk[1]\nk = nmk[2]\nres = (comb(n-1, k) * m* (m-1)**(k)) % mod\nprint(int(res))\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-----------------------------------------------------\nfrom math import factorial as f\nn,m,k=map(int,input().split())\nprint(f(n-1)//(f(k)*f(n-k-1))*m*(m-1)**k%998244353)"}, {"source_code": "import math\n\nMOD = 998244353\n\nn, m, k = [int(x) for x in input().split()]\n\nans = (math.factorial(n-1)//(math.factorial(k)*math.factorial(n-k-1)))*m*((m-1)**k)\nprint(ans%MOD)"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nans = math.factorial(n - 1)\nans //= math.factorial(k)\nans //= math.factorial(n - 1- k)\nans *= (m - 1) ** k\nans *= m\nans %= 998244353\nif k == 0 :\n ans = m\nprint(ans)\n"}, {"source_code": "# by the authority of GOD author: manhar singh sachdev #\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nmod = 998244353\nfac = [1]\nfor i in range(1,2001):\n fac.append((fac[-1]*i)%mod)\nfac_in = [pow(fac[-1],mod-2,mod)]\nfor i in range(2000,0,-1):\n fac_in.append((fac_in[-1]*i)%mod)\nfac_in.reverse()\n\ndef comb(a,b):\n return (fac[a]*fac_in[b]*fac_in[a-b])%mod\n\ndef main():\n n,m,k = map(int,input().split())\n print((m*pow(m-1,k,mod)*comb(n-1,k))%mod)\n\n#Fast IO Region\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\nif __name__ == '__main__':\n main()"}, {"source_code": "import math\nmod = 998244353\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\nprint((math.comb(n-1, k) * (m * (m-1) ** k)) % 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 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, m, k = RL()\n dp = [[0]*(k+2) for _ in range(n+1)]\n\n for i in range(1, n+1):\n dp[i][0] = m\n\n for i in range(1, n+1):\n for j in range(1, k+1):\n if j>i-1: break\n dp[i][j] = (dp[i][j] + dp[i-1][j])%mod\n dp[i][j] = (dp[i][j] + dp[i-1][j-1]*(m-1))%mod\n # for i in dp: print(i)\n print(dp[n][k]%mod)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nf = math.factorial\nprint(f(n-1) // f(k) // f(n-k-1) * m * (m-1) ** k % 998244353)"}, {"source_code": "import math\ndef binom(n, k):\n return math.factorial(n) // math.factorial(k) // math.factorial(n - k)\nm = list(map(int, input().split())) \nn = m[0] \nc = m[1] \nk = m[2]\nprint(int(binom(n-1,k)*c*((c-1)**k)%(998244353)))"}, {"source_code": "from math import factorial as f;\nn , m , k = map(int,input().split());\nans = (f(n-1)//(f(n-k-1)*f(k)))*m*((m-1)**k)\nprint(int(ans%998244353));\n"}, {"source_code": "n, m, k = [int(x) for x in input().split()]\nmod = 998244353\n\ndef com(n, r, p = 998244353): \n C = [0 for i in range(r+1)] \n C[0] = 1\n for i in range(1, n+1): \n for j in range(min(i, r), 0, -1): \n C[j] = (C[j] + C[j-1]) % p \n return C[r]\n\nans = ((com(n - 1, k) * m * pow(m - 1, k, mod)) )% mod\nprint(ans)\n"}, {"source_code": "mod=998244353 \ndef _mp():\n\treturn map(int,raw_input().split())\nn,m,k=_mp()\norig=n\n\t\n#print -1\n\ndef modinverse(n):\n\treturn pow(n,mod-2,mod)\ndef _pncr(n,r):\n\tc=[0]*(r+1)\n\tres=1\n\tc[0]=1\n\t#k=min(k,n-k)\n\tfor i in range(1,n+1):\n\t\tfor j in range(min(i,r),0,-1):\n\t\t\tc[j]=(c[j]+c[j-1])%mod\n\treturn c[r]\n\nans=m\nfor i in range(k):\n\tans=(ans*(m-1))%mod\n\nans=ans*_pncr(orig-1,k)\nprint ans%mod"}], "negative_code": [{"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)\n\tf%=mod\n\tf*=k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "def fact(n):\n dp = [0 for i in range(n)]\n dp[0] = 1\n mod = 998244353\n for i in range(1,n):\n dp[i] = i* dp[i-1]%mod\n return dp\n\nn,m,k = map(int,input().split())\nmod = 998244353\ndp = fact(n+5)\ny = (dp[n-1]/(dp[n-1-k] * dp[k])%mod)%mod\nz = (m * ((m-1)**k))%mod\nprint(int((y*z)%mod))"}, {"source_code": "from decimal import Decimal\n\ndef modFact(n, p): \n if n >= p: \n return 0 \n \n result = 1\n for i in range(1, n + 1): \n result = (result * i) % p \n \n return result \n\n\t\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nc = Decimal(modFact(n - 1, p))\nz = Decimal(modFact(k, p))\nd = Decimal(modFact(n - 1 - k, p))\nl = Decimal(c / (z * d))\nanswer = int(Decimal(l * m * (m - 1)**k))%p\nprint(answer)"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(k):\n\tans *= (n - 1 - i)\n\tans /= (i + 1)\nprint((ans * m * (m - 1) ** k) % 998244353)"}, {"source_code": "def modFact(n, p): \n if n >= p: \n return 0 \n \n result = 1\n for i in range(1, n + 1): \n result = (result * i) % p \n \n return result \n\n\t\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nc = modFact(n - 1, p)\nz = modFact(k, p)\nd = modFact(n - 1 - k, p)\nl = c / (z * d)\n\nprint(int(l * m * (m - 1)**k))"}, {"source_code": "'''input\n3 2 1\n'''\nn, m, k = map(int, input().split())\nMOD = 998244353\nans = 0\nfor i in range(k):\n\tif i & 1:\n\t\tans -= m * pow(m - 1, k - i, MOD)\n\telse:\n\t\tans += m * pow(m - 1, k - i, MOD)\nfor i in range(n - k, n):\n\tans = ans * i % MOD\nprint(ans)\n"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(1, k + 1):\n ans *= n - i\nfor i in range(k, 0, -1):\n ans //= i\nans = ans * m % 998244353\nfor i in range(k - 1):\n ans = ans * (m - 1) % 998244353\nprint(ans)\n"}, {"source_code": "from sys import setrecursionlimit\nsetrecursionlimit(2100)\nn, m, k = map(int, input().split())\n\n\ndef kirp(n, m, k, fi=n):\n fi -= 1\n if k == 0:\n return m\n if m == 1:\n return 0\n else:\n x = kirp(n-1, m, k-1, fi)*(m-1)\n if fi - 1 < k:\n return x\n elif m == 2:\n return (n-k-1)*x*(m-1) + x\n else:\n return (n - k - 1) * x * (m - 2) + x\n\nprint(kirp(n, m, k) % 998244353)"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif m == 1:\n\tprint(1)\nelif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)**k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "from sys import setrecursionlimit\nsetrecursionlimit(2100)\nn, m, k = map(int, input().split())\n\n\ndef kirp(n, m, k, fi=n):\n if k == 0 and m != 1:\n return m\n if m == 1:\n return 0\n else:\n fi -= 1\n x = kirp(n-1, m, k-1, fi)*(m-1)\n if fi - 1 < k:\n return x\n else:\n return m + x\n\n\nprint(kirp(n, m, k) % 998244353)"}, {"source_code": "n, m, k = map(int, input().split())\nprint(m ** (k + 1))"}, {"source_code": "from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import defaultdict\nfrom itertools import combinations\nimport sys\nimport math\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 998244353\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b,x,y):\n return abs(a-x)+abs(b-y)\n\ndef numIN():\n return(map(int,sys.stdin.readline().strip().split()))\n\ndef charIN():\n return(sys.stdin.readline().strip().split())\n\nt = [(-1,-1)]*1000010\n\ndef create(a):\n\tglobal t,n\n\tfor i in range(n,2*n):\n\t\tt[i] = (a[i-n],i-n)\n\tfor i in range(n-1,0,-1):\n\t\tx = [t[2*i],t[2*i+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[i] = x[1]\n\ndef update(idx,value):\n\tglobal t,n\n\tidx = idx+n\n\tt[idx] = value\n\n\twhile(idx>1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tfor i in range(n,n-k,-1):\n\t\tres = (res*i)%MOD\n\treturn res\n\nn,m,k = numIN()\nx = cal(n-1,k)\nprint((x*m*pow(m-1,k,MOD))%MOD)\n\n\n\n\n\n"}, {"source_code": "pri=10**9+7\nn,m,k=map(int,input().split())\ndp=[[0 for i in range(n+1)] for i in range(k+1)]\n#i denote , number of different bricks , j denotes total size\nfor i in range(k+1):\n for j in range(n+1):\n if(j==0):\n dp[i][j]=0\n continue;\n \n if(i==0):\n dp[i][j]=m\n continue;\n \n if(i>j-1):\n dp[i][j]=0\n continue;\n dp[i][j]=dp[i-1][j-1]*(m-1)+dp[i][j-1]\n dp[i][j]%=pri\nprint(dp[-1][-1])\n \n \n \n"}, {"source_code": "n,m,k = [int(x) for x in input().split()]\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\ndp[0][0] = m\nfor n1 in range(1,n):\n dp[n1][0] = m\n #print(dp[n1][0])\nfor n1 in range(1,n):\n for k1 in range(1,k+1):\n dp[n1][k1] = dp[n1-1][k1]*(m-1)+dp[n1-1][k1-1]\nprint(dp[n-1][k])\n\n#for arr in dp:\n# print(arr)\n \n\n \n\n"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\n\nprint(int(ncr(n-1, k)*m % 998244353) % 998244353)"}, {"source_code": "from decimal import Decimal\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\n\t\nz, m, k = input().split()\nz = int(z)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = Decimal(ncr(z-1, k))\npow = (m - 1)**k\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "from decimal import Decimal\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\n\t\nn, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = Decimal(ncr(n-1, k))%p\npow = (m - 1)**k%p\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "n, m, k = map(int, input().split())\ndp = [[0] * (n + 1) for i in range(n)]\nMOD = 998244353\ndp[0][0] = m\n\nfor i in range(n):\n for j in range(k + 1):\n dp[i][j + 1] += dp[i - 1][j] * (m - 1)\n dp[i][j] += dp[i - 1][j]\n dp[i][j + 1] %= MOD\n dp[i][j] %= MOD\n\nprint(dp[n - 1][k])\n"}, {"source_code": "from math import factorial\n\n[n, m, k] = [int(i) for i in input().split()]\nmod = 998244353\n\nl = m*((m-1)**k)\nif k>=n/2-1:\n L = factorial(k+1)//factorial(n-k-1)//factorial(k+1 - (n-k-1))\nelse:\n L=1\n\n\nprint(l*L%mod)"}, {"source_code": "s=input().split()\nn,m,k=list(map(int,s))\nMOD=998244353\nans=m\nfor i in range(k):\n ans=(ans*(m-1))%MOD\nif k>n//2:\n k=n-k\nfor i in range(1,k+1):\n ans=ans*(n-1-k+i)//i\nprint(ans%MOD)"}, {"source_code": "# by the authority of GOD author: manhar singh sachdev #\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nmod = 10**9+7\nfac = [1]\nfor i in range(1,2001):\n fac.append((fac[-1]*i)%mod)\nfac_in = [pow(fac[-1],mod-2,mod)]\nfor i in range(2000,0,-1):\n fac_in.append((fac_in[-1]*i)%mod)\nfac_in.reverse()\n\ndef comb(a,b):\n return (fac[a]*fac_in[b]*fac_in[a-b])%mod\n\ndef main():\n n,m,k = map(int,input().split())\n print((m*pow(m-1,k,mod)*comb(n-1,k))%mod)\n\n#Fast IO Region\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\nif __name__ == '__main__':\n main()"}, {"source_code": "n,m,k = [int(x) for x in input().split()]\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\ndp[0][0] = m\nfor n1 in range(1,n):\n dp[n1][0] = m\n #print(dp[n1][0])\nfor n1 in range(1,n):\n for k1 in range(1,k+1):\n dp[n1][k1] = dp[n1-1][k1]*(m-1)+dp[n1-1][k1-1]\nprint(dp[n-1][k])\n\n#for arr in dp:\n# print(arr)\n \n\n \n\n"}, {"source_code": "n,m,k = map(int, input().split())\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\nfor i in range(n):\n dp[i][0] = m\nfor i in range(1,n):\n for j in range(1,k+1):\n dp[i][j] = (m-1)*dp[i-1][j-1] + dp[i-1][j]\nprint(dp)\nprint(dp[n-1][k])\n"}, {"source_code": "n, m, k = map(int, input().strip().split())\n\ndp = [0 for i in range(k+1)]\ndp[0] = m\nfor i in range(1, n):\n # print(dp)\n for j in range(1, k+1):\n dp[j] += dp[j-1]*(m-1)\nprint(dp[-1])\n# print(dp)"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\n\nprint(int(ncr(n-1, k)*m % 998244353))"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif m == 1:\n\tprint(1)\nelif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)**k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "n, m, k = map(int, input().strip().split())\n\ndp = [0 for i in range(k+1)]\ndp[0] = m\nfor i in range(1, n):\n # print(dp)\n for j in range(1, k+1):\n dp[j] += dp[j-1]*(m-1)\nprint(dp[-1])\n# print(dp)"}, {"source_code": "'''input\n3 3 0\n3 2 1\n'''\nn, m, k = map(int, input().split())\nMOD = 998244353\nans = m * pow(m - 1, k, MOD) % MOD\n'''\nfor i in range(k + 1):\n\tif i & 1:\n\t\tans -= m * pow(m - 1, k - i, MOD)\n\telse:\n\t\tans += m * pow(m - 1, k - i, MOD)\n'''\nfor i in range(n - k, n):\n\tans = ans * i % MOD\nprint(ans)\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)\n\tf%=mod\n\tf/=math.factorial(k-1)\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "n,m,k = map(int, input().split())\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\nfor i in range(n):\n dp[i][0] = m\nfor i in range(1,n):\n for j in range(1,k+1):\n dp[i][j] = (m-1)*dp[i-1][j-1] + dp[i-1][j]\nprint(dp)\nprint(dp[n-1][k])\n"}, {"source_code": "n, m, k=map(int,input().split())\n\nif k==0:\n\tprint(m)\n\nelif m==1:\n\tprint(0)\n\n\n\nelse:\n\ttotal1=pow(m,k)%998244353\n\ttotal2=1\n\tfor i in range(1,k+1):\n\t\ttotal2=total2*(n-i)\n\tfor i in range(1,k+1):\n\t\ttotal2=total2//i\n\n\tt=total1*total2%9998244353\n\n\tprint(t)\n"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(k):\n\tans *= (n - 1 - i)\n\tans /= (i + 1)\nprint((ans * m * (m - 1) ** k) % 998244353)"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\n\nprint(int(ncr(n-1, k) % 998244353 * m * ncr(m, k+1) % 998244353) % 998244353)"}, {"source_code": "n, m, k = map(int, input().split())\nif k != 0:\n print(m * ((m - 1) * k * (n - k)))\nelse:\n print(m)"}, {"source_code": "from math import factorial\nn, m, k = map(int, input().split())\nprint(max(m*((k+2)//2), 1)*max((m-1)*((k+1)//2), 1)*(factorial(n-1)//(factorial(k)*factorial(n-k-1))) % 998244353)\n"}, {"source_code": "L = []\ndef C(n, m):\n return L[n] / (L[n-m] * L[m])\nwhile True:\n for i in range(2001):\n if i == 0:\n L.append(1)\n else:\n L.append(L[i-1]*i)\n try:\n n, m, k = map(int, raw_input().strip().split())\n if k == 0:\n print(n)\n else:\n ans = m * C(n-1, k) * pow(m-1, k)\n print(ans % 998244353)\n except EOFError:\n break;"}, {"source_code": "from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import defaultdict\nfrom itertools import combinations\nimport sys\nimport math\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 998244353\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b,x,y):\n return abs(a-x)+abs(b-y)\n\ndef numIN():\n return(map(int,sys.stdin.readline().strip().split()))\n\ndef charIN():\n return(sys.stdin.readline().strip().split())\n\nt = [(-1,-1)]*1000010\n\ndef create(a):\n\tglobal t,n\n\tfor i in range(n,2*n):\n\t\tt[i] = (a[i-n],i-n)\n\tfor i in range(n-1,0,-1):\n\t\tx = [t[2*i],t[2*i+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[i] = x[1]\n\ndef update(idx,value):\n\tglobal t,n\n\tidx = idx+n\n\tt[idx] = value\n\n\twhile(idx>1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tfor i in range(n,n-k,-1):\n\t\tres = (res*i)%MOD\n\treturn res\n\nn,m,k = numIN()\nx = cal(n-1,k)\ny = m\nfor i in range(k):\n y = (y*(m-1))%MOD\nprint((x*y)%MOD)"}, {"source_code": "# Python3 function to \n# calculate nCr % p \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# p must be a prime \n# greater than n \n\ndef fact(x , p):\n if x == 0:\n return 1\n return (x * fact(x - 1 , p)) % p\n\np = 998244353\nn , m , k = map(int,input().split())\nans = (((ncr(n - 1 , k , p) * ncr(m , k + 1 , p)) % p) * fact(k + 1 , p)) % p\nprint(ans)\n"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\n\nprint(int(ncr(n-1, k)*m % 998244353) % 998244353)"}, {"source_code": "while True:\n try:\n n, m, k = map(int, raw_input().strip().split())\n if k == 0:\n print(n)\n else:\n print(pow(m, n - 1) * (m-1))\n except EOFError:\n break;"}, {"source_code": "from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import defaultdict\nfrom itertools import combinations\nimport sys\nimport math\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 998244353\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b,x,y):\n return abs(a-x)+abs(b-y)\n\ndef numIN():\n return(map(int,sys.stdin.readline().strip().split()))\n\ndef charIN():\n return(sys.stdin.readline().strip().split())\n\nt = [(-1,-1)]*1000010\n\ndef create(a):\n\tglobal t,n\n\tfor i in range(n,2*n):\n\t\tt[i] = (a[i-n],i-n)\n\tfor i in range(n-1,0,-1):\n\t\tx = [t[2*i],t[2*i+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[i] = x[1]\n\ndef update(idx,value):\n\tglobal t,n\n\tidx = idx+n\n\tt[idx] = value\n\n\twhile(idx>1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tfor i in range(n,n-k,-1):\n\t\tres = (res*i)%MOD\n\treturn res\n\nn,m,k = numIN()\nx = cal(n-1,k)\nfor i in range(k):\n m = (m*(m-1))%MOD\nprint((x*m)%MOD)\n\n\n\n\n\n"}, {"source_code": "from math import factorial,pow\nn, m, k = map(int, input().split())\nmod = 998244353\nc = factorial(n - 1) // (factorial(k) * factorial(n - 1 - k))\nans = c * (m) * pow(m - 1, k)\nprint(int(ans % mod))"}, {"source_code": "n, m, k = map(int, input().split(' '))\ndp = [[0] * (k + 1)] * n\ndp[0][0] = m\nfor i in range(1, n):\n dp[i][0] = m\n for j in range(1, k + 1):\n dp[i][j] = dp[i - 1][j] + (m - 1) * dp[i - 1][j - 1]\nprint(dp[n - 1][k])"}, {"source_code": "n, m, k = map(int, input().split())\nmod = 998244353\nans = m\nfor i in range(k):\n\tans *= (n - k)\n\tans %= mod\nprint(ans)\n"}, {"source_code": "n,m,k=map(int,input().split())\nx=998244353\nh=1\nfor i in range(k+1,n+1):\n h=h*i\nfor i in range(1,n-k+1):\n h=h/i\nh=h % x\nz=m\n\nfor i in range(1,k):\n z=z*(m-1)\n\nz=(z*h) % x\n\nprint (z)\n"}, {"source_code": "n, m, k = map(int, input().strip().split())\n\ndp = [0 for i in range(k+1)]\ndp[0] = m\nfor i in range(1, n):\n # print(dp)\n new_dp = list(dp)\n for j in range(1, k+1):\n new_dp[j] += dp[j-1]*(m-1)\n dp = new_dp\nprint(dp[-1])\n# print(dp)"}, {"source_code": "n,m,k=map(int,input().split())\nif m1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tfor i in range(n,n-k,-1):\n\t\tres = (res*i)%MOD\n\treturn res\n\nn,m,k = numIN()\nx = cal(n-1,k)\nfor i in range(k):\n m = (m*(m-1))%MOD\nprint((x*m)%MOD)\n\n\n\n\n\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)**k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import defaultdict\nfrom itertools import combinations\nimport sys\nimport math\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 998244353\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b,x,y):\n return abs(a-x)+abs(b-y)\n\ndef numIN():\n return(map(int,sys.stdin.readline().strip().split()))\n\ndef charIN():\n return(sys.stdin.readline().strip().split())\n\nt = [(-1,-1)]*1000010\n\ndef create(a):\n\tglobal t,n\n\tfor i in range(n,2*n):\n\t\tt[i] = (a[i-n],i-n)\n\tfor i in range(n-1,0,-1):\n\t\tx = [t[2*i],t[2*i+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[i] = x[1]\n\ndef update(idx,value):\n\tglobal t,n\n\tidx = idx+n\n\tt[idx] = value\n\n\twhile(idx>1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tfor i in range(n,n-k,-1):\n\t\tres = (res*i)%MOD\n\treturn res\n\nn,m,k = numIN()\nx = cal(n-1,k)\nprint((x*m*pow(m-1,k,MOD))%MOD)\n\n\n\n\n\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)\n\tf%=mod\n\tf*=k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "from decimal import Decimal\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\n\t\nz, m, k = input().split()\nz = int(z)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = Decimal(ncr(z-1, k))\npow = (m - 1)**k\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "from math import factorial as f\nn,m,k=map(int,input().split())\nif m<=k:print(0)\nelif k==0:print(m)\nelse:print((f(n-1)//(f(k)*f(n-k-1)))*(f(m)//(f(k)*f(m-k)))%998244353)"}, {"source_code": "H=list(map(int,input().split()))\nn=H[0]\nm=H[1]\nk=H[2]\na=1\nb=1\nc=1\nfor i in range (1,n):\n a=a*i\nfor i in range (1,n-k):\n b=b*i\nfor i in range (1,k+1):\n c=c*i\n\n\n\n\nq=a//(b*c)\nans=q*m*(m-1)**(k)\nprint(ans%988244353)"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\ncolorings = m\nfor i in range(k):\n colorings *= (m-1)\n colorings %= 998244353 \n\nprint(int(ncr(n-1, k) % 998244353 * colorings % 998244353) % 998244353)"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)**k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "M = 998244353\nn, m, k = map(int, raw_input().split())\np = [1]\nfor i in range(n):\n p += p[-1] * (i + 1) % M,\nx = p[n - 1] * pow(p[k], M - 2, M) % M * pow(p[n - 1 - k], M - 2, M) % M * m % M\nif k > 0:\n x = x * pow(m - 1, k - 1, M) % M\nprint x"}, {"source_code": "from math import factorial as f\nmod = 998244353\n\nn,m,k = map(int,input().split())\n\nans=1\nfor i in range(1,k+1):\n ans=(ans*i)%mod\n\nans=(ans*m)%mod\n\nval = f(n-1)//(f(k)*f(n-1-k))\n\nans=(ans*val)%mod\n\nprint(ans)"}, {"source_code": "import math\nimport bisect\nimport itertools\nimport sys\nI=lambda : sys.stdin.readline()\nmod=998244353 \nfact=[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]0 and m==1) or k>=n:\n print(0)\nelif k==0:\n print(m)\nelse:\n k1=ncr(n-1,k)\n k1*=pow(m-1,k-1,mod1)\n k1*=m\n k1%=mod\n print(k1%mod)\n \n \n \n \n "}, {"source_code": "n,m,k = map(int, input().split())\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\nfor i in range(n):\n dp[i][0] = m\nfor i in range(1,n):\n for j in range(1,k+1):\n dp[i][j] = (m-1)*dp[i-1][j-1] + dp[i-1][j]\n dp[i][j] %= 998244354\n#print(dp)\nprint(dp[n-1][k])\n"}, {"source_code": "n,m,k = [int(x) for x in input().split()]\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\ndp[0][0] = m\nfor n1 in range(1,n):\n dp[n1][0] = dp[n1-1][0]*(m-1)\n #print(dp[n1][0])\nfor n1 in range(1,n):\n for k1 in range(1,k+1):\n dp[n1][k1] = dp[n1-1][k1]*(m-1)+dp[n1-1][k1-1]\nprint(dp[n-1][k])\n\n#for arr in dp:\n# print(arr)\n \n\n \n\n"}, {"source_code": "H=list(map(int,input().split()))\nn=H[0]\nm=H[1]\nk=H[2]\na=1\nb=1\nc=1\nfor i in range (1,n):\n a=a*i\nfor i in range (1,n-k):\n b=b*i\nfor i in range (1,k+1):\n c=c*i\n\n\n\n\nq=a//(b*c)\nans=q*m*(m-1)**(k)\nprint(ans%988244353)"}, {"source_code": "n,m,k = list(map(int,input().split()))\nimport math\na = math.factorial(n-1)//(math.factorial(k)*math.factorial(n-1-k))\nprint(a*m*((m-1)**k))\n"}, {"source_code": "'''input\n3 3 0\n3 2 1\n'''\nn, m, k = map(int, input().split())\nMOD = 998244353\nans = m * pow(m - 1, k, MOD)\nfor i in range(n - k, n):\n\tans = ans * i % MOD\nprint(ans)\n"}, {"source_code": "# by the authority of GOD author: manhar singh sachdev #\n\nimport os,sys\nfrom io import BytesIO, IOBase\n\nmod = 10**9+7\nfac = [1]\nfor i in range(1,2001):\n fac.append((fac[-1]*i)%mod)\nfac_in = [pow(fac[-1],mod-2,mod)]\nfor i in range(2000,0,-1):\n fac_in.append((fac_in[-1]*i)%mod)\nfac_in.reverse()\n\ndef comb(a,b):\n return (fac[a]*fac_in[b]*fac_in[a-b])%mod\n\ndef main():\n n,m,k = map(int,input().split())\n print((m*pow(m-1,k,mod)*comb(n-1,k))%mod)\n\n#Fast IO Region\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\nif __name__ == '__main__':\n main()"}, {"source_code": "import math\nn,m,k=map(int,input().split())\nM=998244353\nr=m\nfor i in range(k):\n r=(r*(m-1))%M\nr=(r%M)*(int((math.factorial(n-1)/(math.factorial(n-1-k)*math.factorial(k))))%M)\nprint(r%M)"}, {"source_code": "s=input().split()\nn,m,k=list(map(int,s))\nMOD=998244353\nans=m\nfor i in range(k-1):\n ans=(ans*(m-1))%MOD\nif k>n//2:\n k=n-k\nfor i in range(1,k+1):\n ans=ans*(n-1-k+i)//i\nprint(ans%MOD)"}, {"source_code": "from decimal import Decimal\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\n\t\nz, m, k = input().split()\nz = int(z)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = Decimal(ncr(z-1, k))\npow = (m - 1)**k\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "N = 2003\nMOD = 998244353\nnCr = [[] for _ in range(N)]\n\n\ndef init():\n for i in range(N):\n nCr[i] = [0 for _ in range(N)]\n for i in range(N):\n nCr[i][0] = 1\n for i in range(1, N):\n for j in range(1, N):\n nCr[i][j] = (nCr[i - 1][j] + nCr[i - 1][j - 1]) % MOD\n\n\ninit()\nn, m, k = map(int, input().split())\nprint((nCr[n - 1][k] * m * pow(m - 1, nCr[n - 1][k] - 1, MOD)) % MOD)\n"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(1, k + 1):\n ans *= n - i\nfor i in range(k, 0, -1):\n ans //= i\nans = ans * m % 998244353\nfor i in range(k - 1):\n ans = ans * (m - 1) % 998244353\nprint(ans)\n"}, {"source_code": "\nmod=998244353\ndef nCrModp(n, r): \n \n # The array C is going to store last row of \n # pascal triangle at the end. And last entry \n # of last row is nCr. \n C = [0 for i in range(r+1)] \n \n C[0] = 1 # Top row of Pascal Triangle \n \n # One by constructs remaining rows of Pascal \n # Triangle from top to bottom \n for i in range(1, n+1): \n \n # Fill entries of current row \n # using previous row values \n for j in range(min(i, r), 0, -1): \n \n # nCj = (n - 1)Cj + (n - 1)C(j - 1) \n C[j] = (C[j] + C[j-1]) % mod\n \n return C[r]\nn,m,k=map(int,input().split())\nif(k+1>m):\n print(0)\nelse:\n ans=m\n ans=((ans%mod)*(pow(m-1,k,mod)%mod))%mod\n val1=nCrModp(n-1,k)\n ans=((ans%mod)*(val1%mod))%mod\n print(ans)"}, {"source_code": "n, m, k = map(int, input().split())\nans = 1\nfor i in range(1, k + 1):\n ans *= n - i\nfor i in range(k, 0, -1):\n ans //= i\nans = ans * m % 998244353\nfor i in range(k - 1):\n ans = ans * (m - 1) % 998244353\nprint(ans)\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif m == 1 and k > 1:\n\tprint(0)\nelif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)**k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "H=list(map(int,input().split()))\nn=H[0]\nm=H[1]\nk=H[2]\na=1\nb=1\nc=1\nfor i in range (1,n):\n a=a*i\nfor i in range (1,n-k):\n b=b*i\nfor i in range (1,k+1):\n c=c*i\n\n\n\n\nq=a//(b*c)\nans=q*m*(m-1)**(k)\nprint(ans)"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\ncolorings = m\nfor i in range(k):\n colorings *= (m-1)\n colorings %= 998244353 \n\nprint(int(ncr(n-1, k) % 998244353 * colorings % 998244353) % 998244353)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ndef One(type):\n\treturn (type(input()))\ndef List(type):\n\treturn list(map(type,input().split()))\ndef Str():\n\treturn (list(input()))\ndef Many(type):\n\treturn map(type,input().split())\n\nMOD = 998244353\n\ndef main():\n\tn,m,k = Many(int)\n\n\tans = m\n\tcur = m-1\n\n\tfor i in range(1,k+1):\n\t\tans*=(n-i)*cur\n\t\tans%=MOD\n\t\tcur = m if cur==m-1 else m-1\n\n\tprint(ans)\n\nmain()\n"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\ncolorings = m\nfor i in range(k):\n colorings *= (m-1)\n colorings %= 998244353 \n\nprint(int(ncr(n-1, k) % 998244353 * colorings % 998244353) % 998244353)"}, {"source_code": "L = []\ndef C(n, m):\n return L[n] / (L[n-m] * L[m])\nwhile True:\n for i in range(2001):\n if i == 0:\n L.append(1)\n else:\n L.append(L[i-1]*i)\n try:\n n, m, k = map(int, raw_input().strip().split())\n if k == 0:\n print(n)\n else:\n ans = m * C(n-1, k) * pow(m-1, k)\n print(ans % 998244353)\n except EOFError:\n break;"}, {"source_code": "from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import defaultdict\nfrom itertools import combinations\nimport sys\nimport math\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 998244353\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b,x,y):\n return abs(a-x)+abs(b-y)\n\ndef numIN():\n return(map(int,sys.stdin.readline().strip().split()))\n\ndef charIN():\n return(sys.stdin.readline().strip().split())\n\nt = [(-1,-1)]*1000010\n\ndef create(a):\n\tglobal t,n\n\tfor i in range(n,2*n):\n\t\tt[i] = (a[i-n],i-n)\n\tfor i in range(n-1,0,-1):\n\t\tx = [t[2*i],t[2*i+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[i] = x[1]\n\ndef update(idx,value):\n\tglobal t,n\n\tidx = idx+n\n\tt[idx] = value\n\n\twhile(idx>1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tfor i in range(n,n-k,-1):\n\t\tres = (res*i)%MOD\n\treturn res\n\nn,m,k = numIN()\nx = cal(n-1,k)\nprint((x*m)%MOD)\n\n\n\n\n\n\n"}, {"source_code": "import math\nn, m, k = map(int, input().split())\nmod = 998244353\nif m == 1 and k > 1:\n\tprint(0)\nelif k == 0:\n\tprint(m)\nelse:\n\tf = math.factorial(n-1)/math.factorial(k)*math.factorial(n-k-1)\n\tf%=mod\n\tf*=m*(m-1)**k\n\tf%=mod\n\tprint(int(f))"}, {"source_code": "n,m,k=map(int,input().split())\nif m1:\n r=(r*(k+1))%M\nprint(r)"}, {"source_code": "n,m,k = map(int, input().split())\ndp = [[0 for _ in range(k+1)] for _ in range(n)]\nfor i in range(n):\n dp[i][0] = m\nfor i in range(1,n):\n for j in range(1,k+1):\n dp[i][j] = (m-1)*dp[i-1][j-1] + dp[i-1][j]\n#print(dp)\nprint(dp[n-1][k])\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-----------------------------------------------------\n#from math import comb\nn,m,k=map(int,input().split())\nimport math\ndef comb(n,r):\n f = math.factorial\n return f(n) // f(r) // f(n-r)\nans=comb(n-1,k)%998244353\n#print(ans)\nans*=comb(m,1)%998244353\n#print(ans)\nf=math.factorial\nif m<=n-k:\n ans*=(f(n-k-1)//f(m-1))%998244353\nprint(ans%998244353)\n \n "}, {"source_code": "n, m, k=map(int,input().split())\n\nif k==0:\n\tprint(m)\n\nelif m==1:\n\tprint(0)\n\n\n\nelse:\n\ttotal1=m*pow(m-1,k)%998244353\n\ttotal2=1\n\tfor i in range(1,k+1):\n\t\ttotal2=total2*(n-i)\n\tfor i in range(1,k+1):\n\t\ttotal2=total2//i\n\n\tt=total1*total2%9998244353\n\n\tprint(t)\n"}, {"source_code": "from decimal import Decimal\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\n\t\nz, m, k = input().split()\nz = int(z)\nm = int(m)\nk = int(k)\n\np = 998244353\n\nl = int(ncr(z-1, k))\npow = (m - 1)**k\nanswer = int(Decimal(l * m * pow))%p\nprint(answer)"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\n\nprint(int(ncr(n-1, k)*m % 998244353) % 998244353)"}, {"source_code": "n, m, k = map(int, input().split())\nmod = 998244353\nans = m\nfor i in range(n - k, n):\n\tans *= i\n\tans %= mod\nprint(ans)\n"}, {"source_code": "from math import factorial as f\nmod = 998244353\n\nn,m,k = map(int,input().split())\n\nans=1\nfor i in range(1,k+1):\n ans=(ans*i)%mod\n\nans=(ans*m)%mod\n\nval = f(n-1)//(f(k)*f(n-1-k))\n\nans=(ans*val)%mod\n\nprint(ans)"}, {"source_code": "from math import factorial as f\nn,m,k=map(int,input().split())\nif m<=k:print(0)\nelif k==0:print(m)\nelse:print((f(n-1)//(f(k)*f(n-k-1)))*(f(m)//(f(k)*f(m-k)))%998244353)"}, {"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-----------------------------------------------------\nmod=998244353\nn,m,k=map(int,input().split())\nr=max(k,n-1-k)\nc1=1\nc2=1\nct=1\nfor i in range (r+1,n):\n c1*=i\n c1%=mod\n c2*=ct\n c2%=mod\nres=c1//c2\nres*=(m+max(0,(m-1)*(k-1)))\nprint(res)"}, {"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\nadd = lambda a, b: (a + b) % 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)\nncr = lambda n, r: div(fact(n - r + 1, n), fact(1, r))\nrints = lambda: [int(x) for x in stdin.readline().split()]\nmod = 998244353\n\nn, m, k = rints()\nans = n\nif k:\n ans = pow(fact(m - k, m), ncr(n - 1, k), mod)\n\nprint(ans)\n"}, {"source_code": "from math import factorial\n\n[n, m, k] = [int(i) for i in input().split()]\nmod = 998244353\n\nl = m*((m-1)**k)\nif k>=n/2-1:\n L = factorial(n-1)//factorial(n-1-k)//factorial(k)\nelse:\n L=1\n\n\nprint((l*L)%mod)\n"}, {"source_code": "from math import factorial\nn, m, k = map(int, input().split())\nprint(max(m*((k+2)//2), 1)*max((m-1)*((k+1)//2), 1)*(factorial(n-1)//(factorial(k)*factorial(n-k-1))) % 998244353)\n"}, {"source_code": "import sys\nfrom math import ceil, floor\nimport operator as op\nfrom functools import reduce\n\ninput = sys.stdin.readline\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\nn, m, k = map(int, input().split())\n\nprint(int(ncr(n-1, k) % 998244353 * m * ncr(m, k+1) % 998244353) % 998244353)"}, {"source_code": "from sys import setrecursionlimit\nsetrecursionlimit(2100)\nn, m, k = map(int, input().split())\n\n\ndef kirp(n, m, k):\n if k == 0:\n return m\n else:\n return m + kirp(n-1, m, k-1)*(m-1)\n\n\nprint(kirp(n, m, k) % 998244353)"}, {"source_code": "while True:\n try:\n n, m, k = map(int, raw_input().strip().split())\n if k == 0:\n print(n)\n else:\n print(pow(m, n - 1) * (m-1))\n except EOFError:\n break;"}, {"source_code": "n,m,k = map(int,input().split())\n\nd = [[0 for _ in range(k+1)] for _ in range(n)]\n\nd[0][0]=m\nfor i in range(1,n):\n for j in range(min(n,k+1)):\n if j==0:\n d[i][j] = d[i-1][j]\n else:\n d[i][j] = d[i-1][j]+(m-1)*d[i-1][j-1]\n\nprint(d[n-1][k])\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 binomial(n, k):\n \"\"\"\n A fast way to calculate binomial coefficients by Andrew Dalke.\n See http://stackoverflow.com/questions/3025162/statistics-combinations-in-python\n \"\"\"\n if 0 <= k <= n:\n ntok = 1\n ktok = 1\n for t in xrange(1, min(k, n - k) + 1):\n ntok *= n\n ktok *= t\n n -= 1\n return ntok // ktok\n else:\n return 0\ndef solve(n, m, k):\n def parts(p, m):\n if p == 1: return m\n return m * parts(p - 1, m - 1)\n return (binomial(n - 1, k) * parts(k + 1, m)) % 998244353\n\nif __name__ == \"__main__\":\n \"\"\"the solve(*args) structure is needed for testing purporses\"\"\"\n n, m, k = stdin()\n print solve(n, m, k)"}, {"source_code": "M = 998244353\nn,m,k = map(int,input().split())\nif(k==0):\n print(m)\n exit()\nX = ((n-k) * (m * pow(m-1,k,M))% M)%M\nprint(X)"}, {"source_code": "n, m, k = map(int, input().split())\nif k != 0:\n print(m * ((m - 1) * k * (n - k)))\nelse:\n print(m)"}], "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b"} {"nl": {"description": "Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing behind him. Find the number of different positions Petr can occupy.", "input_spec": "The only line contains three integers n, a and b (0\u2009\u2264\u2009a,\u2009b\u2009<\u2009n\u2009\u2264\u2009100).", "output_spec": "Print the single number \u2014 the number of the sought positions.", "sample_inputs": ["3 1 1", "5 2 3"], "sample_outputs": ["2", "3"], "notes": "NoteThe possible positions in the first sample are: 2 and 3 (if we number the positions starting with 1).In the second sample they are 3, 4 and 5."}, "positive_code": [{"source_code": "n,l,r=map(int,input().strip().split()[:3])\nprint(min(n-l,r+1))"}, {"source_code": "'''\nCreated on Nov 3, 2011\n\n@author: della\n'''\nimport sys\nimport math\n\ndef min(a,b):\n return a if ab:\n c=b+1\n elif x<=b:\n c=x\n print(c)"}, {"source_code": "a, b, c = raw_input().split()\na, b, c = int(a), int(b), int(c)\n\nif a - b - c <= 0:\n\tprint a - b\nelse :\n\tprint c + 1\n"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(n-a,b+1))"}, {"source_code": "n,a,b = map(lambda x: int(x), input().split())\nprint(min(n-a,b+1))"}, {"source_code": "def number_position():\n qty_people, in_front, behind = map( int, raw_input().split(' '))\n number_position = qty_people - in_front \n\n if number_position > behind:\n return behind + 1\n elif number_position == behind:\n return behind\n elif number_position < behind:\n return number_position\n\n\nprint(number_position())"}, {"source_code": "n,a,b= map(int, input().split())\nprint(n-max(a+1,n-b)+1)"}, {"source_code": "n, front, back = [int(x) for x in input().split(' ')]\nprint(n - max(front + 1, n - back)+ 1)\n"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\nprint min(n-1-a, b)+1\n"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef main():\n n, a, b, = map(int, input().split())\n ans = 0\n for i in range(n):\n if i >= a and n - 1 - i <= b:\n ans += 1\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "(n,a,b)=map(int,input().split())\ncnt=0\nx=n-a-b-1\nif(a+b+1>=n):\n while(n>a):\n cnt=cnt+1\n n=n-1\nelse:\n a=a+x\n while(n>a):\n cnt=cnt+1\n n=n-1\nprint (cnt)\n \n"}, {"source_code": "n, a, b = map(int, raw_input().split())\nprint (min(n-a, b+1))"}, {"source_code": "a,b,c = map(int,raw_input().split())\nprint (a - max(b+1,a-c)+1)\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\nn,a,b=l()\ncnt=0\nfor i in range(a,n):\n if n-1-i >b:\n continue\n else:\n cnt+=1\nprint cnt"}, {"source_code": "n,a,b = map(lambda x: int(x), input().split())\nprint(min(n-a,b+1))"}, {"source_code": "'''\nCreated on Nov 3, 2011\n\n@author: della\n'''\nimport sys\nimport math\n\ndef min(a,b):\n return a if a=0 and n-i<=b:\n count+=1\n\nprint(count)\n"}, {"source_code": "n, a, b = map(int, input().split())\nn_pos = n - a\nif b >= n_pos:\n b = n_pos\n print(b)\nelse:\n print(b+1)\n"}, {"source_code": "n, b, a = map(int, raw_input().split())\nprint n - max(b, n - a - 1)"}, {"source_code": "n, a, b = map(int,input().split())\nm = max(a+1,n-b)\nprint(n-m + 1)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Dec 22 20:58:43 2017\n\n@author: admin\n\"\"\"\n\nn,a,b = [int(x) for x in input().split()]\nprint(n-max(a+1,n-b)+1)\n"}, {"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\nN,A,B = rrm()\nans = 0\nfor i in xrange(1, 1+N):\n\tnum_in_front = i-1\n\tnum_behind = N-i\n\tif num_in_front >= A and num_behind <= B:\n\t\tans += 1\nprint ans"}, {"source_code": "n,a,b=map(int,input().split());print(min(n-a,b+1)) "}, {"source_code": "a,b,c = map(int, input().split())\nprint((a - max(b+1, a-c)+1))\n#"}, {"source_code": "\n\nn,a,b = [int(x) for x in raw_input().split()]\n\n\noverlap = b + 1 + a - n\n\nif overlap >= 0:\n print b + 1 - overlap\nelse:\n print b + 1\n"}, {"source_code": "n,a,b = map(int,input().split(\" \"))\nprint(min(n-a,b+1))"}, {"source_code": "n, a, b = map(int, input().split())\nif (n-(a+b)>1):\n print(b+1)\nelse:\n print(n-a)\n"}, {"source_code": "n,a,b = [int(x) for x in input().split() ]\nif a + 1 >= n - b:\n print(n-a)\nelse:\n print(b+1)"}, {"source_code": "n,a,b = map(int, input().split())\n\nprint(min(b+1,n-a))"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(n-a,b+1))"}, {"source_code": "string = input()\nnumbers = string.split(\" \")\nn = int(numbers[0])\na = int(numbers[1])\nb = int(numbers[2])\nx = n - a\ny = n - a - b - 1\nif y > 0:\n x -= y\nprint(x)"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(b+1,n-a))\n"}, {"source_code": "n, a, b = map(int, raw_input().strip().split())\nprint min(n - a, b + 1)"}, {"source_code": "a,b,c = map(int,raw_input().split())\ncontador = 0\n\nfor i in range(a,a-c-1,-1):\n\tif(i == b):\n\t\tbreak\n\tcontador+= 1\n\t\t\nprint contador\n"}, {"source_code": "n,a,b=[int(i) for i in input().split()]\nx=n-a\ny=b+1\nif y>x:\n print(x)\nelif x==y:\n print(y)\nelse:\n print(y)\n "}, {"source_code": "n,a,b=map(int,input().split())\n\nextra=max(0,a-(n-b-1))\n\nprint(b+1-extra)"}, {"source_code": "n, a, b = map(int, str(input()).strip().split())\nprint (n - max(a + 1, n - b, 1) + 1)"}, {"source_code": "n,a,b = map(int,input().split())\ncount=0\n\nfor i in range(a+1,n+1):\n if i-a>=0 and n-i<=b:\n count+=1\n\nprint(count)\n"}, {"source_code": "if __name__ == '__main__':\n n, a, b = [int(num) for num in raw_input().split()]\n\n num_pos = 0\n for p in range(n):\n if p-b <= 0 and p+a <= n-1:\n num_pos += 1\n else:\n break\n\n print num_pos\n"}, {"source_code": "a = input().split()\n\nb = int(a[0])\nc = int(a[1])\nd = int(a[2])\n\n#no less than c in front\n#no more than d behind\n\ne = b - c\n\nif (d+1) 0 and temp <= n:\n print n-temp+1\nelse:\n print 0"}, {"source_code": "N,A,B=raw_input().split()\nn=int(N)\na=int(A)\nb=int(B)\nbos=0\nwhile a=0 and b=0 :\n bos=bos+1\n a=a+1\n b=b-1\nprint bos"}, {"source_code": "n, a, b = map(int, input().split())\nprint(min(n-a,b+1))\n"}, {"source_code": "a,b,c = map(int,raw_input().split())\ncontador = 0\n\nfor i in range(a,a-c-1,-1):\n\tif(i == b):\n\t\tbreak\n\tcontador+= 1\n\t\t\nprint contador\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\nprint min([a - b, c + 1])\n"}, {"source_code": "n,a,b=map(int, raw_input().split(' '))\n\nprint min(n-a,b+1)"}, {"source_code": "(n,a,b)=map(int,input().split())\nx=n-a-b\nif(x==0):\n print(b)\nif(x<0):\n print(n-a)\nif(x>0):\n print(b+1)\n"}, {"source_code": "n,a,b=map(int,raw_input().split())\n\nif (n-a)>b+1:\n print b+1\nelse:\n print n-a"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 8 09:14:13 2019\n\n@author: avina\n\"\"\"\n\nn,a,b = map(int, input().split())\n\nprint(min(n-a,b+1))"}, {"source_code": "n, a, b = map(int, input().split(' '))\nprint(min(n - a, b + 1))"}, {"source_code": "string = input()\nnumbers = string.split(\" \")\nn = int(numbers[0])\na = int(numbers[1])\nb = int(numbers[2])\nx = n - a\ny = n - a - b - 1\nif y > 0:\n x -= y\nprint(x)"}, {"source_code": "a,b,c=map(int,input().split())\nw=a-b\nif(w>c):\n c=c+1\n print(c)\nelse:\n print(w)\n"}, {"source_code": "# The number of positions\n\nn, a, b = map(int, raw_input().split())\n\nprint min(n-a, b+1)\n"}, {"source_code": "n,a,b = map(int,input().split())\n# space = n-a\nprint(b+1 if b < (n-a) else n-(a))"}, {"source_code": "n,a,b = map(int,raw_input().split())\nprint min(b+1,n-a)"}, {"source_code": "a, b, c = map(int, raw_input().split())\nprint min([a - b, c + 1])\n"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(n-a,b+1))"}, {"source_code": "f=lambda:map(int,input().split())\nn,a,b=f()\nprint([n-a,b+1][n-a>b])"}, {"source_code": "s = str(input())\ne = s.split(\" \")\ncount = 0\nmaximum = int(e[0])-1\nminimum = 0\nk=True\ncount=0\nwhile k == True:\n if maximum >= int(e[1]) and minimum <= int(e[2]):\n count+=1\n maximum-=1\n minimum+=1\n else:\n k=False\nprint(count)"}, {"source_code": "n= map(int, raw_input().split())\nprint n[0]-max(n[1]+1,n[0]-n[2])+1"}, {"source_code": "l = map(int, raw_input().split())\nprint min(l[0] - l[1], l[2] + 1)\n"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\n\nprint (n - max(a + 1, n - b)) + 1"}, {"source_code": "n,a,b = map(int,input().split())\nj = 0\nfor i in range(n-b,n+1):\n\tif i >= a+1:\n\t\tj+=1\nprint(j)"}, {"source_code": "n,a,b = map(int,input().split())\nprint(b+1 if b < (n-a) else (n-a))\n"}, {"source_code": "n,a,b=map(int, raw_input().split(' '))\n\nprint min(n-a,b+1)"}, {"source_code": "n, a, b = map(int, raw_input().split())\nans = 0\nfor i in range(1, n+1):\n if i-1 >= a and n-i <=b:\n ans += 1\nprint (ans)\n"}, {"source_code": "n, a, b = [int(x) for x in input().split()]\nans = n - max(a + 1, n - b) + 1\nprint(ans)"}, {"source_code": "n,a,b=map(int,input().split())\nmax=b+1\nc=n-a\nif (n-a)>b+1:\n print(b+1)\nelse:\n print(n-a)"}, {"source_code": "n,a,b=map(int, raw_input().split(' '))\n\nprint min(n-a,b+1)"}, {"source_code": "a,b,c = map(int,raw_input().split())\nprint (a - max(b+1,a-c)+1)\n"}, {"source_code": "n, a, b = map(int, input().split())\nprint(min((n-a),b+1))"}, {"source_code": "n, a , b = map(int, input().split())\nprint(min(n - a, b + 1))\n"}, {"source_code": "#Codeforces 124A\n\nn,a,b = map(int, raw_input().split())\n\nprint n-max(a+1,n-b)+1\n"}, {"source_code": "n,a,b=input().split()\nn=int(n)\na=int(a)\nb=int(b)\nif 0<=a<=100 and 0<=b<=100 and 0<=n<=100:\n x=n-a\n if x>b:\n c=b+1\n elif x<=b:\n c=x\n print(c)\n"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\nprint min(n - a, b + 1)"}, {"source_code": "n, a, b = input().split(' ')\nn = int(n)\na = int(a)\nb = int(b)\nif (n-a) < (b+1):\n print(n-a)\nelse:\n print(b+1)\n"}, {"source_code": "n,a,b=map(int,input().split())\nif n<=a+b:\n print(n-a)\nelse:\n print(b+1)"}, {"source_code": "# your code goes here\nn,m,k = map(int,raw_input().split(' '))\nprint min(k+m+1,n)-m"}, {"source_code": "n,a,b=map(int,input().split())\nif a>=n-b:\n r=a+1\nelse:\n r=n-b\nprint(n+1-r)"}, {"source_code": "\nn,a,b = map(int,raw_input().split())\n\nfor i in xrange(a+1,n+1):\n\tif(i>(n-(b+1))):\n\t\tprint n-i+1\n\t\tbreak\n"}, {"source_code": "a, b, c = raw_input().split()\na, b, c = int(a), int(b), int(c)\n\nif a - b - c <= 0:\n\tprint a - b\nelse :\n\tprint c + 1\n"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(n-a,b+1))"}, {"source_code": "\"\"\"\n3 1 1\nno less than a standing infront\nno more than b people standing behind\n\"\"\"\nnum1 = input()\na = []\n\n\ndef get_the_data(count, num, arr):\n for 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 return arr\n\n\narr1 = get_the_data(0, num1, a)\n\npeoples = arr1[0]\nfront = arr1[1]\nbehind = arr1[2]\nplaces_to_take = behind + 1\ncheck = False\nwhile check is False:\n if peoples - places_to_take < front :\n places_to_take -= 1\n else:\n break\nprint(places_to_take)"}, {"source_code": "#!/bin/python2\n\nfrom sys import stdin\n\na=map(int, stdin.readline().strip().split())\n\ntmp=a[1]+a[2]+1\nif a[0]>tmp:\n print a[2]+1\nelse:\n print a[0]-a[1]"}, {"source_code": "# Believe you can and you're halfway there. Theodore Roosevelt\n# by : Blue Edge - Create some chaos\n\nn,a,b=map(int,input().split())\nprint(min(n-a,b+1))\n"}, {"source_code": "n,a,b = map(int,input().split())\nif n>(a+b):\n print(b+1)\nelif n<(a+b):\n print(n-a)\nelse:\n print(b)"}, {"source_code": "n,a,b=raw_input().split()\nn,a,b=int(n),int(a),int(b)\ns=0\nfor i in range(n):\n if i>=a and n-1-i<=b:\n s+=1\nprint s\n"}, {"source_code": "\n\nn, a, b = map(int, input().split())\n\nprint (min(n - a, b + 1))"}, {"source_code": "n, a, b = [int(x) for x in input().split()]\nans = n - max(a + 1, n - b) + 1\nprint(ans)"}, {"source_code": "n, a, b = map(int, raw_input().split());\nprint n - max(a + 1, n - b) + 1;\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\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, combinations\nfrom math import gcd\nfrom bisect import bisect\n\n\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\nread = lambda: list(map(int, input().strip().split(\" \")))\n\n\n\n\n\n\ndef solve():\n n, a, b = read()\n print(min(n-a, b+1))\n\n\n\n\n\n \n\nif __name__ == \"__main__\":\n\tsolve()"}, {"source_code": "#-------------Program-------------\n#----KuzlyaevNikita-Codeforces----\n#---------------------------------\n\nn,a,b=map(int,input().split())\nif a+b=a:\n counter+=1\n\n return counter\n\nprint solve()\n"}, {"source_code": "\n\na,b,c=map(int,input().split())\ncnt=0\nfor i in range(a):\n if (i >= b and a- i - 1 <= c):\n cnt+=1;\nprint(cnt)"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\n\nprint (n - max(a + 1, n - b)) + 1"}, {"source_code": "n,a,b=map(int,input().split())\nif n-(a+1)>b:\n print(b+1)\nelif n-(a+1)<=b:\n print(n-a)\n \n"}], "negative_code": [{"source_code": "a,b,c = map(int, input().split())\nprint(a - b)"}, {"source_code": "n,a,b=input().split()\nn,a,b=[int(n),int(a),int(b)]\nif n>a and n>b:\n c=0\n for i in range(1,n+1):\n if i-1>=a and n-i-1<=b:\n c=c+1\nprint(c)\n"}, {"source_code": "n,a,b=map(int,raw_input().split())\nprint a+1"}, {"source_code": "import sys\n\nn, a, b = map(int, sys.stdin.readline().split())\n\nif a+b == 5:\n print b\nelif a+b > 5:\n print n-a\nelse:\n print b+1\n"}, {"source_code": "n,a,b = map(int,input().split())\nif n-a b:\n place -= (b + 1)\nprint(place)\n"}, {"source_code": "entrada = raw_input().split()\n\nprint int(entrada[0]) - int(entrada[1])\n"}, {"source_code": "n,m,k=map(int,input().split())\nif m+k==n:\n print(k)\nelif m+k!=n and m!=k:\n print(k+1)\nelif m==k:\n print(n-k)"}, {"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\ndef main(N,a,b):\n\tcnt =0\n\tfor i in range(a,N):\n\t\tif ((N-1)-a)<=b:\n\t\t\tcnt+=1\n\tprint(cnt)\n\ndef text():\n\twith open(\"input.txt\",\"r\") as f:\n\t\tt = int(f.readline().rstrip())\n\t\twhile t:\n\t\t\tN, a ,b = map(int,f.readline().rstrip().split())\n\t\t\tmain(N,a,b)\n\t\t\tt-=1\n\ndef normal():\n\tN , a ,b = map(int,input().split())\n\tmain(N,a,b)\n\n\n\n# text()/\n\nnormal()\n\n"}, {"source_code": "s = str(input())\ne = s.split(\" \")\ncount = 0\nfor i in range(int(e[2]), int(e[0])+1):\n count+=1\nprint(count)"}, {"source_code": "n,a,b=[int(x) for x in input().split()]\nfor i in range(1,n+1):\n if(i>a and i>=b and b!=0 and a!=0):\n break\n if(b==0):\n i=1\n break\n if(a==0):\n i=n\n break\nprint(i)"}, {"source_code": "(n,a,b)=map(int,input().split())\nx=n-a-b\nif(x==0):\n print(b)\nif(x<0):\n print(n-b)\nif(x>0):\n print(b+1)\n"}, {"source_code": "arr = input().split(\" \")\nn = int(arr[0])\na = int(arr[1])\nb = int(arr[2])\n\nif(a == 0 or b == 0):\n print(1)\nelse:\n count = 0\n temp1 = 0\n temp2 = n - 1\n for i in range(1, n+1):\n if(temp1 >= a and temp2 <= b):\n count += 1\n temp1 += 1\n temp2 -= 1\n print(count)\n \n "}, {"source_code": "inpt=list(map(int,input().split()))\nn=inpt[0];a=inpt[1];b=inpt[2]\noutput=(n-a)\nif n==9 and a==4 and b==3: output=a\nprint(output)"}, {"source_code": "n, a, b = map(int, str(input()).strip().split())\nprint (max(0, b-a+2))"}, {"source_code": "nab = list(map(int, input().split()))\nif nab[1] + nab[2] >= nab[0]:\n\tprint(nab[1] + 1)\nelse:\n\tprint(nab[0] - nab[2])"}, {"source_code": "n,a,b=map(int,raw_input().split())\nprint a+1"}, {"source_code": "print (lambda l : max([l[2], l[0] - l[1]]))(map(int, raw_input().split()))"}, {"source_code": "n,a,b=map(int,input().split())\nprint(n-a)"}, {"source_code": "n,a,b=map(int,input().split())\nif(min(n,a,b)==n):\n\tprint(1)\nelse:\n\tprint(n-a)"}, {"source_code": "def position(n, a, b):\n return n-a\n\nn, a, b = map(int, input().split())\nprint(position(n, a, b))"}, {"source_code": "a,b,c=map(int,input().split())\nprint(b+1)"}, {"source_code": "n, a, b = map(int, raw_input().split())\nprint n-a"}, {"source_code": "z=list(map(int,input().split()))\na=min(z[0],z[1])\nif a+1b:\n small=b\nelif b>a:\n small=a\nelif a==b:\n small=a\nprint(n-small)"}, {"source_code": "#! /usr/bin/python\n\nn, a, b = map(int, raw_input().split(\" \"))\n\np = n-a\nprint p\n"}, {"source_code": "N,A,B=raw_input().split()\nn=int(N)\na=int(A)\nb=int(B)\npos=n-a\nprint pos"}, {"source_code": "x=input().split()\nn=int(x[0])\na=int(x[1])\nb=int(x[2])\nz=0\nfor i in range(a+1,n+1):\n z=z+1\nprint(z)\n"}, {"source_code": "n,a,b=map(int,input().split())\nn-=a\nif n>b and b-n>0:\n print(b)\nelse:\n print(n)"}, {"source_code": "def read_number_line():\n return [int(i) for i in input().split()]\n\n\nn, a, b = read_number_line()\nresult = n - a\nif result >= 0:\n print(result)\nelse:\n print(0)\n"}, {"source_code": "n,a,b=[int(x) for x in input().strip().split()]\ni = round((n+a-b-1)/2)\nprint(n-i)\n\n"}, {"source_code": "nums = raw_input().split(' ')\nn = int(nums[0])\na = int(nums[1])\nb = int(nums[2])\n\nif a + b == n: print b\nelse: print b + 1"}, {"source_code": "n,a,b = map(int,raw_input().split())\npos = n-a\nif pos < b: print pos\nelse:print b+1"}, {"source_code": "n, a, b = map(int, input().split())\n\nprint(max(n-a-1, b))"}, {"source_code": "\na,b,c=list(map(int,input().split()))\n\n \n \n\ns=a-b\np=abs(b-c)\n\n\nprint(min((s-p),s))\n"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(b+1,n-a+1))"}, {"source_code": "n,a,b=map(int,input().split())\nprint(len([i for i in range(1,n+1) if n-i<=a and n-i<=b]))"}, {"source_code": "arr = input().split(\" \")\nn = int(arr[0])\na = int(arr[1])\nb = int(arr[2])\n\nif(a == 0 or b == 0):\n print(1)\nelse:\n count = 0\n temp1 = 0\n temp2 = n - 1\n for i in range(1, n+1):\n if(temp1 >= a and temp2 <= b):\n count += 1\n temp1 += 1\n temp2 -= 1\n print(count)\n \n "}, {"source_code": "n, a, b = map(int, raw_input().split())\nif a + b < n:\n\tprint(b+1)\nelse:\n\tprint(a+1)"}, {"source_code": "n,a,b=map(int,input().split())\nprint(n-a)"}, {"source_code": "n,a,b = [int(x) for x in input().split()]\nposition = 0\nfor i in range(n-a-1,n):\n if n-1-i<=b:\n position += 1\nprint(position)"}, {"source_code": "n,a,b=map(int,input().split())\nprint(n-a)"}, {"source_code": "n,a,b=list(map(int,input().split()))\n\n\nif (a+b) 5:\n print n-a\nelse:\n print b+1\n"}, {"source_code": "nums = raw_input().split(' ')\nn = int(nums[0])\na = int(nums[1])\nb = int(nums[2])\n\nif a + b == n: print b\nelse: print b + 1"}, {"source_code": "a,b,c = map(int,input().split())\nprint(a-b)"}, {"source_code": "n,a,b=map(int,input().split())\nif(a==0 and b==0):\n\tprint(n)\nelif(a==0 and b>0):\n\tprint(n)\nelif(b==0 and a>0):\n\tprint(abs(n-a))\nelse:\n\tprint(abs(n-max(a,b)-(a-b)))"}, {"source_code": "import math\n\ninp = raw_input().split(' ')\nn = int(inp[0])\na = int(inp[1])\nb = int(inp[2])\np = 0\nfor i in range(0,n+1):\n if i-1 >= a and b >= (n - i):\n print i,(n - i),a,b\n p=p+1\nprint p\n"}, {"source_code": "import math\nn,a,b = map(int,input().split(\" \"))\nc = n - (a+b)/2\nprint(math.ceil(c))"}, {"source_code": "n,a,b=map(int,input().split())\nprint(n-a)"}, {"source_code": "n,a,b=map(int,input().split())\nif(a==0 and b==0):\n\tprint(n)\nelif(a==0 and b>0):\n\tprint(n)\nelif(b==0 and a>0):\n\tprint(abs(n-a))\nelse:\n\tprint(abs(n-max(a,b)-(a-b)))"}, {"source_code": "inpt=list(map(int,input().split()))\nn=inpt[0];a=inpt[1];b=inpt[2]\noutput=(n-a)\nif n==9 and a==4 and b==3: output=a\nif n==14 and a==5 and b==5: output=6\nif n==22 and a==4 and b==8: output=b+1\nif n==28 and a==6 and b==1: output=2\nprint(output)"}, {"source_code": "a, b, c = map(int, raw_input().split())\nprint a - b"}, {"source_code": "n, a, b = map(int, raw_input().split())\nprint n-a"}, {"source_code": "z=list(map(int,input().split()))\na=min(z[0],z[1])\nif a+1>z[2]:\n print(a-1)\nelse:\n print(a+1)\n"}, {"source_code": "a,b,c = map(int, input().split())\nif c < b and c != 0:\n\tb = b + (b - c)\nprint(a - b)"}, {"source_code": "n,a,b=map(int,raw_input().split())\nprint a+1"}, {"source_code": "i=lambda :map(int,raw_input().split(\" \"))\nn,l1,l2=i()\nt=0\nfor i in range(1,n+2):\n\tif (n-i)l2:\n\t\tt+=1\nprint t\t\t"}, {"source_code": "from sys import stdin as IN\ndef god():\n N, a, b = map(int, IN.readline().split())\n ans = 0\n for i in xrange(1, N+1):\n if i >= a: ans += 1\n print ans-1\ngod()"}, {"source_code": "nums=raw_input().split()\n\nn=int(nums[0])\na=int(nums[1])\nb=int(nums[2])\n\nprint n-a\n"}, {"source_code": "import sys\nimport math\ninput = sys.stdin.readline\n\ndef int_array():\n return list(map(int, input().strip().split()))\n\n\ndef str_array():\n return input().strip().split()\n\n######################## TEMPLATE ENDS HERE ########################\nn,a,b = int_array()\nprint(n-a)"}, {"source_code": "n,a,b=map(int,input().split())\nprint(min(b,n-a))"}, {"source_code": "n,a,b=(map(int,input().split()))\nprint(n-a)"}, {"source_code": "n, a, b = map(int, raw_input().split())\n\nfor x in range(a+1,n+1) :\n\n if n - x <= b :\n\n print x\n break"}, {"source_code": "s = str(input())\ne = s.split(\" \")\ncount = 0\nfor i in range(int(e[1]), int(e[0])):\n count+=1\nprint(count)"}, {"source_code": "a,b,c=map(int,input().split())\nw=a-b\nif(w>b):\n c=c+1\n print(c)\nelse:\n print(w)\n"}], "src_uid": "51a072916bff600922a77da0c4582180"} {"nl": {"description": "Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:Find the sum modulo 1073741824 (230).", "input_spec": "The first line contains three space-separated integers a, b and c (1\u2009\u2264\u2009a,\u2009b,\u2009c\u2009\u2264\u20092000).", "output_spec": "Print a single integer \u2014 the required sum modulo 1073741824 (230).", "sample_inputs": ["2 2 2", "4 4 4", "10 10 10"], "sample_outputs": ["20", "328", "11536"], "notes": "NoteFor the first example. d(1\u00b71\u00b71)\u2009=\u2009d(1)\u2009=\u20091; d(1\u00b71\u00b72)\u2009=\u2009d(2)\u2009=\u20092; d(1\u00b72\u00b71)\u2009=\u2009d(2)\u2009=\u20092; d(1\u00b72\u00b72)\u2009=\u2009d(4)\u2009=\u20093; d(2\u00b71\u00b71)\u2009=\u2009d(2)\u2009=\u20092; d(2\u00b71\u00b72)\u2009=\u2009d(4)\u2009=\u20093; d(2\u00b72\u00b71)\u2009=\u2009d(4)\u2009=\u20093; d(2\u00b72\u00b72)\u2009=\u2009d(8)\u2009=\u20094. So the result is 1\u2009+\u20092\u2009+\u20092\u2009+\u20093\u2009+\u20092\u2009+\u20093\u2009+\u20093\u2009+\u20094\u2009=\u200920."}, "positive_code": [{"source_code": "from collections import Counter\n\n\ndef factors(n):\n fact = Counter()\n\n i = 2\n while i * i <= n:\n while n % i == 0:\n fact[i] += 1\n n //= i\n i += 1\n\n if n != 1:\n fact[n] += 1\n\n fact[1] = 1\n\n return fact\n\n\ndef solve(a, b, c):\n fact = {i: factors(i) for i in range(1, max(a, b, c) + 1)}\n\n ans = 0\n cache = {}\n for i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n p = i * j * k\n if p not in cache:\n f = fact[i] + fact[j] + fact[k]\n f[1] = 1\n res = 1\n for k, v in f.items():\n res *= v + 1\n \n cache[p] = res // 2\n\n ans += cache[p]\n\n return ans % 1073741824\n\n\ndef main():\n a, b, c = map(int, input().split())\n ans = solve(a, b, c)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "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, 109, 113, 127, 131, 137, 139, 149, 151]\nmmm = 1073741824\nimport math\n\na, b, c = list(map(int, input().split()))\narr = []\ncount = 0\n\n\ndef d(x):\n ans=1\n for i in primes:\n if x=i:\n x=x//i\n power+=1\n ans *= (power+1)\n return ans\n\n\nfor smh1 in range(1, a + 1):\n for smh2 in range(1, b + 1):\n for smh3 in range(1, c + 1):\n xxx = d(smh1 * smh2 * smh3)\n count += xxx\nprint((count % mmm) % mmm)"}, {"source_code": "from operator import mul\nfrom functools import reduce\nfrom collections import Counter\n\na, b, c = map(int, input().split())\nmod = 2 ** 30\n\nprime = [None] * 100\n\nfor i in range(2, 101):\n if prime[i - 1] is None:\n for j in range(i, 101, i):\n prime[j - 1] = i\n\n\nd = {}\nresult = 0\nfor ai in range(1, a + 1):\n for bi in range(1, b + 1):\n for ci in range(1, c + 1):\n n = ai * bi * ci\n res = d.get(n)\n\n if res is None:\n cd = Counter()\n\n n_ai = ai\n while prime[n_ai - 1] is not None:\n cd[prime[n_ai - 1]] += 1\n n_ai //= prime[n_ai - 1]\n \n n_bi = bi\n while prime[n_bi - 1] is not None:\n cd[prime[n_bi - 1]] += 1\n n_bi //= prime[n_bi - 1]\n \n n_ci = ci\n while prime[n_ci - 1] is not None:\n cd[prime[n_ci - 1]] += 1\n n_ci //= prime[n_ci - 1]\n \n res = reduce(mul, map(lambda x: x + 1, cd.values()), 1)\n d[n] = res\n \n result += res\n\nprint(result % mod)\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\nrr = sieve(100)\n\ndef d(n):\n\tres = 1\n\tr = rr\n\tfor i in rr:\n\t\tcnt = 1\n\t\tif i > n:\n\t\t\treturn res\n\t\twhile n%i == 0:\n\t\t\tn //= i\n\t\t\tcnt += 1\n\t\tres *= cnt\n\treturn res\n\t\t\t\n\ndef main():\n\ta,b,c = mi()\n\tres = 0\n\tfor i in range(1,a+1,1):\n\t\tfor j in range(1,b+1,1):\n\t\t\tfor k in range(1,c+1,1):\n\t\t\t\tres += d(i*j*k)%1073741824\n\tprint(res)\n\t\t\t\t\nmain()"}, {"source_code": "import math\nres = 0\na,b,c = map(int,input().split())\narr = [0]*1000001\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n num = i*j*k\n count = 0\n if arr[num]:\n res += arr[num]\n else:\n for l in range(1,math.floor((num)**(1/2))+1):\n if num % l == 0:\n if num // l != l:\n count += 2\n else:\n count += 1\n res += count\n arr[num] = count\nprint(res%(2**30))"}, {"source_code": "#coding: utf8\nimport math\nimport copy\nimport sys\nimport itertools\n\ndef printe(inp):\n sys.stderr.write(repr(inp)+'\\n')\n #sys.stderr.flush()\n\ndef primes(n):\n \"\"\"http://code.activestate.com/recipes/366178-a-fast-prime-number-list-generator/\"\"\"\n if n==2: return [2]\n elif n<2: return []\n s=range(3,n+1,2)\n mroot = n ** 0.5\n i_half=(n+1)/2-1\n i=0\n m=3\n while m <= mroot:\n if s[i]:\n j=(m*m-3)/2\n s[j]=0\n while j 0:\n return dp[temp]\n limit = int(sqrt(n)) + 1\n res = 1\n for i in range(2, limit+1):\n a = 0\n while n % i == 0:\n n //= i\n a += 1\n res *= (a + 1)\n if n > 1:\n res *= 2\n dp[temp] = res\n return dp[temp]\n\n\na, b, c = invr()\nmod = 1073741824\ndp = [0] * ((a*b*c)+1)\n\ntot = 0\n\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n tot += nod(i*j*k) % mod\n\n\nprint(tot)\n"}, {"source_code": "a, b, c = map(int, input().split())\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]\ndef d(x):\n ans=1\n for i in primes:\n if x=i:\n x=x//i\n power+=1\n ans *= (power+1)\n return ans\n\ndlist = [0]*(a*b*c+1)\n \nans = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n if dlist[i*j*k]==0:\n dlist[i*j*k] = d(i*j*k)\n ans += dlist[i*j*k]\nprint(ans)\n"}, {"source_code": "pr=[1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\ncd = {}\ndef d(n):\n if n in cd:\n return cd[n]\n t,i=1,2\n k=n\n\n while i * i <= k:\n if k % i == 0:\n k /= i\n c = 2\n while k % i == 0:\n k /= i\n c += 1\n t *= c\n i += 1\n if k > 1:\n t *= 2\n cd[n] = t\n return t\ni,j,m=map(int, raw_input().split())\nr=0\nfor x in xrange(1,i+1):\n for y in xrange(1, j+1):\n for z in xrange(1, m+1):\n #l=len(set(a*s*w for a in d(x) for s in d(y) for w in d(z)))\n #\n #print len(d(x)|d(y)|d(z))\n r += d(x*y*z)\nprint r%1073741824"}, {"source_code": "a,b,c = map(int,input().split())\nlis=[0]*(1000001)\nfor i in range(1,1000001):\n j=i\n while j<=1000000:\n lis[j]+=1\n j+=i\nans=0 \nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans+=(lis[i*j*k]%1073741824)\nprint(ans) \n\n"}, {"source_code": "from functools import reduce\nfrom collections import Counter\nimport time\nimport datetime\n\ndef time_t():\n print(\"Current date and time: \" , datetime.datetime.now())\n print(\"Current year: \", datetime.date.today().strftime(\"%Y\"))\n print(\"Month of year: \", datetime.date.today().strftime(\"%B\"))\n print(\"Week number of the year: \", datetime.date.today().strftime(\"%W\"))\n print(\"Weekday of the week: \", datetime.date.today().strftime(\"%w\"))\n print(\"Day of year: \", datetime.date.today().strftime(\"%j\"))\n print(\"Day of the month : \", datetime.date.today().strftime(\"%d\"))\n print(\"Day of week: \", datetime.date.today().strftime(\"%A\"))\n\ndef ip():\n return int(input())\n\ndef sip():\n return input()\n\ndef mip():\n return map(int,input().split())\n\ndef mips():\n return map(str,input().split())\n\ndef lip():\n return list(map(int,input().split()))\n\ndef matip(n,m):\n lst=[]\n for i in range(n):\n arr = lip()\n lst.append(arr)\n return lst\n\ndef factors(n): # find the factors of a number\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\ndef minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps\n jumps = [0 for i in range(n)]\n if (n == 0) or (arr[0] == 0):\n return float('inf')\n jumps[0] = 0\n for i in range(1, n):\n jumps[i] = float('inf')\n for j in range(i):\n if (i <= j + arr[j]) and (jumps[j] != float('inf')):\n jumps[i] = min(jumps[i], jumps[j] + 1)\n break\n return jumps[n-1]\n\ndef dic(arr): # converting list into dict of count\n return Counter(arr)\n\ndef prime(n):\n for i in range(3,int(n**(0.5))+1):\n if n%i==0:\n return False\n return True \n\nprimes = []\nfor i in range(2,101):\n if prime(i):\n primes.append(i)\n\na,b,c = mip()\ncount = 0\nif a==1 and b==1 and c==1:\n print(1)\nelse:\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n q = i*j*k\n ans = 1\n for item in primes:\n if q=1:\n q = q//item\n y+=1\n ans = ans*y\n count += ans\n print(count)"}, {"source_code": "MOD = 1073741824\n\ndef findPrimeFact(n):\n fact = {}\n count = 0\n while(n%2 == 0):\n count += 1\n n //= 2\n if count:\n fact[2] = count\n for i in range(3, int(n**0.5)+1, 2):\n count = 0\n while n%i ==0:\n count += 1\n n //= i\n if count:\n fact[i] = count\n if n>2:\n fact[n] = 1\n return(fact)\n\na, b, c = map(int, input().split())\nans = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n fact = findPrimeFact(i*j*k)\n temp = 1\n for l in fact:\n temp *= (1+fact[l])\n temp %= MOD\n ans += temp\n ans %= MOD\n\nprint(ans%MOD)\n"}, {"source_code": "import math\n \ndivisores = {}\n \ndef countDivisors(n) : \n if n in divisores:\n return divisores[n]\n else:\n cnt = 0\n for i in range(1, (int)(math.sqrt(n)) + 1) : \n if (n % i == 0) : \n \n # If divisors are equal, \n # count only one \n if (n / i == i) : \n cnt = cnt + 1\n else : # Otherwise count both \n cnt = cnt + 2\n divisores[n] = cnt \n return cnt \n \na,b,c = list(map(int, input().split(\" \")))\n \nult_a = 1\nult_b = 1\nult_c = 1\n \nsoma = 0\n \nfor i in range(a*b*c):\n ult_c = (i % c) + 1\n if (i % c) == 0:\n ult_b = (ult_b % b) + 1\n if (i % (b*c)) == 0:\n ult_a = (ult_a % a) + 1\n numero = ult_a*ult_b*ult_c\n numero = countDivisors(numero)\n soma = (soma%1073741824) + numero\n \nprint(soma%1073741824)"}, {"source_code": "a,b,c = map(int,input().split())\nlis=[0]*(1000001)\nfor i in range(1,1000001):\n j=i\n while j<=1000000:\n lis[j]+=1\n j+=i\nans=0 \nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans+=(lis[i*j*k]%1073741824)\nprint(ans) \n\n"}, {"source_code": "p= [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]\ndef d(x):\n y=0\n ans=1\n for i in p:\n if x < i:\n break\n y=1\n while x%i==0 and x>= i:\n x/=i\n y+=1\n ans*=y\n return ans\na,b,c=map(int,input().split())\nout=0\nq={}\nfor i in range(1,a+1) :\n for j in range(1,b+1) :\n for k in range(1,c+1) :\n e=i*j*k\n if e not in q :\n q[e]=d(e)\n out+=q[e]\nprint(out % 1073741824)\n"}, {"source_code": "d = {}\n\ndef gd(n):\n s, f, p, t = 2, {}, 1, n\n while n!=1:\n if n%s == 0:\n n = n/s\n f[s] = f.get(s,0)+1\n s = 2\n else:\n s+=1\n values = f.values()\n for x in values:\n p*=(x+1)\n d[t] = p\n return p\n\n\nresult = 0\nx, y, z = map(int,raw_input().split())\nimport datetime\nst = datetime.datetime.now()\nfor i in range(1,x+1):\n for j in range(1,y+1):\n for k in range(1,z+1):\n t = i*j*k\n r = d.get(t,None)\n if r is None:\n result+=gd(t)\n else:\n result+=r\nprint result%1073741824\n\n\n"}, {"source_code": "import sys\n\n\np=[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]\n\ndef d(x):\n y=0\n ans=1\n for i in p:\n y=1\n while x%i==0 and x>1:\n x/=i\n y+=1\n ans*=y\n return ans\n\n\na,b,c=map(int,raw_input().split())\nh=[0]*(a*b*c+1)\nt=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n l=i*j*k\n if h[l]==0:\n h[l]=d(l)\n t+=h[l]\n \n\nprint t%1073741824\n\n "}, {"source_code": "def main():\n from itertools import product\n a, b, c = sorted(map(int, input().split()))\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)\n l = [None]\n for x in range(1, (c + 1)):\n tmp = [0] * 25\n for i, p in enumerate(primes):\n while not x % p:\n x //= p\n tmp[i] += 1\n l.append(tuple(tmp))\n res = 0\n cache = {}\n for x, y, z in product(range(1, a + 1), range(1, b + 1), range(1, c + 1)):\n xyz = x * y * z\n if xyz in cache:\n res += cache[xyz]\n else:\n u = 1\n for t in map(sum, zip(l[x], l[y], l[z])):\n if t:\n u *= t + 1\n u &= 1073741823\n cache[xyz] = u\n res += u\n print(res & 1073741823)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "l=lambda:map(int,raw_input().split())\np = [2]\np+=[i for i in range(3,100,2) if all(i%m for m in p)]\nd={1:1,2:2,3:2}\ndef f(x):\n if x not in d: \n t=x\n s=1\n for m in p:\n if m>t: break\n q=1\n while t%m==0:\n q+=1\n t/=m\n s*=q\n d[x]=s\n return d[x]\na,b,c=l()\nprint sum(f(i*j*k) for i in range(1,a+1) for j in range(1,b+1) for k in range(1,c+1))"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#input = sys.stdin.readline\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\n\ndef flin(d, x, default = -1):\n f = l = -1\n for i in range(len(d)):\n if d[i] == x:\n if f == -1: f = i\n l = i\n if f == -1:\n return (default, default)\n else:\n return (f, l)\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\npr = sieve(10**6 // 2)\ndef divn(n):\n res = 1\n for i in pr:\n if n == 1:\n return res\n\n t = 1\n while n % i == 0:\n t += 1\n n = n//i\n res *= t\n\na, b, c = mi()\nmem = [0]*(10**6 + 1)\nres = 0\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n n = i * j * k\n if mem[n] == 0: mem[n] = divn(i * j * k)\n res += mem[n]\nprint(res % 1073741824)\n\n\n"}, {"source_code": "d=[0]*1000005\nfor i in range(1,1000001):\n for j in range(1,1000001):\n if i*j>1000001:break\n else:d[i*j]+=1\na,b,c=map(int,input().split());ans=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans+=d[i*j*k]\nprint(ans)\n"}, {"source_code": "I=lambda:map(int, raw_input().split())\ndp = {}\nMOD = 1073741824\ndef d(x):\n if x in dp:\n return dp[x]\n res = 1\n q = 2\n xx = x\n while q * q <= x:\n r = 1\n while x % q == 0:\n x /= q\n r += 1\n res = (res * r) % MOD\n q += 1\n if x > 1:\n res = (res * 2) % MOD\n dp[xx] = res\n return res\na, b, c = I()\n\nres = 0\nfor i in xrange(1, a + 1):\n for j in xrange(1, b + 1):\n for k in xrange(1, c + 1):\n res = (res + d(i * j * k)) % MOD\nprint res"}, {"source_code": "from math import *\ndef div(x):\n s=0\n for i in range(2,floor(sqrt(x))+1):\n if x%i==0:s+=1\n if x%(x//i)==0 and i!=x//i:s+=1\n if x==1:return s+1\n return s+2\nd=[-1]*(1000001)\na,b,c=map(int,input().split());ans=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n if d[i*j*k]==-1:d[i*j*k]=div(i*j*k)\n ans=(ans+d[i*j*k])\nprint(ans)\n"}, {"source_code": "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, 109, 113, 127, 131, 137, 139, 149, 151]\nmmm = 1073741824\nimport math\n\na, b, c = list(map(int, input().split()))\narr = []\ncount = 0\n\n\ndef d(x):\n ans=1\n for i in primes:\n if x=i:\n x=x//i\n power+=1\n ans *= (power+1)\n return ans\n\n\nfor smh1 in range(1, a + 1):\n for smh2 in range(1, b + 1):\n for smh3 in range(1, c + 1):\n xxx = d(smh1 * smh2 * smh3)\n count += xxx\nprint((count % mmm) % mmm)"}, {"source_code": "\"\"\"\n This template is made by Satwik_Tiwari.\n python programmers can use this template :)) .\n\"\"\"\n\n#===============================================================================================\n#importing some useful libraries.\n\nimport sys\nimport bisect\nimport heapq\nfrom math import *\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 #\nfrom bisect import bisect_right as br\nfrom bisect import bisect\n\n#===============================================================================================\n#some shortcuts\n\nmod = pow(10, 9) + 7\ndef inp(): return sys.stdin.readline().strip() #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)\n\n\n#===============================================================================================\n# code here ;))\n\ndef solve():\n a,b,c = sep()\n dp = [0]*((a*b*c)+1)\n for i in range(1,(a*b*c)+1):\n j = 1\n while((i*j) <= (a*b*c)):\n dp[i*j] +=1\n j+=1\n # print(dp)\n\n ans = 0\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans += dp[i*j*k]\n print(ans%1073741824)\n\ntestcase(1)\n\n"}, {"source_code": "a,b,c=input().split()\na,b,c=[int(a),int(b),int(c)]\ns=0\nd=[0]*(1000001)\nfor i in range(1,1000001):\n j=i\n while j<=1000000:\n d[j]+=1\n j+=i\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n p=(i*j*k)\n s+=d[p]\nprint(s)"}, {"source_code": "pr=[1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]\ncd = {}\ndef d(n):\n if n in cd:\n return cd[n]\n t,i=1,2\n k=n\n\n while i * i <= k:\n if k % i == 0:\n k /= i\n c = 2\n while k % i == 0:\n k /= i\n c += 1\n t *= c\n i += 1\n if k > 1:\n t *= 2\n cd[n] = t\n return t\ni,j,m=map(int, raw_input().split())\nr=0\nfor x in xrange(1,i+1):\n for y in xrange(1, j+1):\n for z in xrange(1, m+1):\n #l=len(set(a*s*w for a in d(x) for s in d(y) for w in d(z)))\n #\n #print len(d(x)|d(y)|d(z))\n r += d(x*y*z)\nprint r%1073741824"}, {"source_code": "p= [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]\ndef d(x):\n y=0\n ans=1\n for i in p:\n if x < i:\n break\n y=1\n while x%i==0 and x>= i:\n x/=i\n y+=1\n ans*=y\n return ans\na,b,c=map(int,input().split())\nout=0\nq={}\nfor i in range(1,a+1) :\n for j in range(1,b+1) :\n for k in range(1,c+1) :\n e=i*j*k\n if e not in q :\n q[e]=d(e)\n out+=q[e]\nprint(out % 1073741824)\n"}, {"source_code": "a,b,c=map(int,input().split())\nM=1073741824\nn=a*b*c\nd=[1]*(n+1)\nfor i in range(2,n+1):\n\tfor j in range(i,n+1,i):\n\t d[j]+=1\nr=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tr+=(d[i*j*k])%M\nprint(r%M)\n"}, {"source_code": "import sys\nINF = 10**20\nMOD = 10**9 + 7\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\n\n\"\"\"\nFacts and Data representation\nConstructive? Top bottom up down\n\"\"\"\na, b, c = I()\nMOD = 2 ** 30\nans = 0\n\nprimes = []\nfor i in range(2, 100):\n for j in range(2, i):\n if i % j == 0:\n break\n else:\n primes.append(i)\n\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n ok = i * j * k\n res = 1\n for p in primes:\n cnt = 0\n while ok % p == 0:\n ok //= p\n cnt += 1\n res *= (cnt + 1)\n ans += res\n ans %= MOD\n\nprint(ans)"}, {"source_code": "import operator as op\nimport 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 functools import reduce\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\ndef def_value():\n return 0\n\n\ndef nod(n):\n temp = n\n if dp[temp] > 0:\n return dp[temp]\n limit = int(sqrt(n)) + 1\n res = 1\n for i in range(2, limit+1):\n a = 0\n while n % i == 0:\n n //= i\n a += 1\n res *= (a + 1)\n if n > 1:\n res *= 2\n dp[temp] = res\n return dp[temp]\n\n\na, b, c = invr()\nmod = 1073741824\ndp = [0] * ((a*b*c)+1)\n\ntot = 0\n\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n tot += nod(i*j*k) % mod\n\n\nprint(tot)\n"}, {"source_code": "def gen_primes(n):\n ret = [2]\n if n < 3:\n return ret\n n += 1\n buf = [0] * n\n buf[2] = 1\n for i in xrange(3, n, 2):\n if buf[i] == 0:\n ret.extend([i])\n for j in xrange(2 * i, n, i):\n buf[j] = 1\n return ret\ndef count_divisor(n, primes):\n ret = 1\n for p in primes:\n if n < p:\n break\n cnt = 1\n while n % p == 0:\n cnt += 1\n n /= p\n ret *= cnt\n return ret\ndef main():\n p = gen_primes(1000000)\n a, b, c = map(int, raw_input().split())\n a, b, c, ans = a + 1, b + 1, c + 1, 0\n buf = [1] * (a * b * c)\n for ai in xrange(1, a):\n for bi in xrange(1, b):\n for ci in xrange(1, c):\n i = ai * bi * ci\n if buf[i] == 1 and i > 1:\n buf[i] = count_divisor(i, p)\n ans += buf[i]\n print ans\nif __name__ == '__main__':\n main()"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1000001):\n\tfor y in range(x,1000001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)\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\nrr = sieve(100)\n\ndef d(n):\n\tres = 1\n\tr = rr\n\tfor i in rr:\n\t\tcnt = 1\n\t\tif i > n:\n\t\t\treturn res\n\t\twhile n%i == 0:\n\t\t\tn //= i\n\t\t\tcnt += 1\n\t\tres *= cnt\n\treturn res\n\t\t\t\n\ndef main():\n\ta,b,c = mi()\n\tres = 0\n\tfor i in range(1,a+1,1):\n\t\tfor j in range(1,b+1,1):\n\t\t\tfor k in range(1,c+1,1):\n\t\t\t\tres += d(i*j*k)%1073741824\n\tprint(res)\n\t\t\t\t\nmain()"}, {"source_code": "#coding: utf8\nimport math\nimport copy\nimport sys\nimport itertools\n\ndef printe(inp):\n sys.stderr.write(repr(inp)+'\\n')\n #sys.stderr.flush()\n\ndef primes(n):\n \"\"\"http://code.activestate.com/recipes/366178-a-fast-prime-number-list-generator/\"\"\"\n if n==2: return [2]\n elif n<2: return []\n s=range(3,n+1,2)\n mroot = n ** 0.5\n i_half=(n+1)/2-1\n i=0\n m=3\n while m <= mroot:\n if s[i]:\n j=(m*m-3)/2\n s[j]=0\n while j= i:\n x/=i\n y+=1\n ans*=y\n return ans\n\n\nprimes_list = primes1(100)\nx = 0\nt = {}\na, b, c = list(map(int, input().split()))\ns = []\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n q = i * j * k\n if q not in t:\n t[q] = d(q)\n x += t[q]\nprint(x % 1073741824)\n"}, {"source_code": "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]\ndef fun(x):\n cnt=0\n ans=1\n for i in primes:\n if x=i:\n x=x//i\n cnt+=1\n ans*=cnt\n return ans\na,b,c=map(int,input().split())\nres=0\ndic=dict()\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n if i*j*k not in dic.keys():\n dic[i*j*k]=fun(i*j*k)\n res+=dic[i*j*k]\nprint(res%1073741824)"}, {"source_code": "def mergeDict(a, b, c):\n ret = a.copy()\n for key, value in b.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n\n for key, value in c.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n return ret\n\n\nisPrime = [True for i in range(101)]\nfor i in range(2, 101):\n if isPrime[i] is True:\n for j in range(i + i, 101, i):\n isPrime[j] = False\nprimeList = [i for i in range(2, 101) if isPrime[i] is True]\n\ndecomposition = [None] * 101\ndecomposition[1] = {2:0} # special workaround\nfor prime in primeList:\n decomposition[prime] = {prime : 1}\n for i in range(2, 101):\n if decomposition[i] is not None and i * prime < 101:\n decomposition[i * prime] = decomposition[i].copy()\n if prime not in decomposition[i * prime].keys():\n decomposition[i * prime][prime] = 1\n else:\n decomposition[i * prime][prime] += 1\n\n\na, b, c = map(int, raw_input().split())\nhashTable = {}\nans = 0\nfor ai in range(1, a+1):\n for bi in range(1, b+1):\n for ci in range(1, c+1):\n d = ai * bi * ci\n if hashTable.has_key(d):\n ans += hashTable[d]\n else:\n merge = mergeDict(decomposition[ai], decomposition[bi], decomposition[ci])\n num = reduce(lambda x, y: x*y, map(lambda x: x+1, merge.values()))\n ans += num\n hashTable[d] = num\n ans %= 1073741824\n\nprint ans\n\n"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1000001):\n\tfor y in range(x,1000001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)"}, {"source_code": "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, 109, 113, 127, 131, 137, 139, 149, 151]\nmmm = 1073741824\nimport math\n\na, b, c = list(map(int, input().split()))\narr = []\ncount = 0\n\n\ndef d(x):\n ans=1\n for i in primes:\n if x=i:\n x=x//i\n power+=1\n ans *= (power+1)\n return ans\n\n\nfor smh1 in range(1, a + 1):\n for smh2 in range(1, b + 1):\n for smh3 in range(1, c + 1):\n xxx = d(smh1 * smh2 * smh3)\n count += xxx\nprint((count % mmm) % mmm)"}, {"source_code": "def d(x):\n if x == 1:\n return 1\n \n k = 0\n i = 1\n \n while i * i <= x:\n if x % i == 0:\n k += 2\n if i * i == x:\n k -= 1\n i += 1\n\n return k\n\na, b, c = map(int, input().split())\nn = 1073741824\n\nans = 0\ns = [0 for i in range(1000001)]\n\nfor x in range(1, a + 1):\n for y in range(1, b + 1):\n for z in range(1, c + 1):\n p = x * y * z\n if s[p] == 0:\n s[p] = d(p)\n ans = (ans + s[p]) % n\n\nprint(ans)\n \n"}, {"source_code": "lst=[1]*1000001\nfor i in range(2,1000001):\n j=i\n while j<=1000000:\n lst[j]+=1\n j+=i\nz=list(map(int,input().split()))\nans=0\nfor i in range(1,z[0]+1):\n for j in range(1,z[1]+1):\n for k in range(1,z[2]+1):\n ans+=lst[i*j*k]\nprint(ans)"}, {"source_code": "def main():\n from itertools import product\n a, b, c = sorted(map(int, input().split()))\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)\n l = [None]\n for x in range(1, (c + 1)):\n tmp = [0] * 25\n for i, p in enumerate(primes):\n while not x % p:\n x //= p\n tmp[i] += 1\n l.append(tuple(tmp))\n res = 0\n cache = {}\n for x, y, z in product(range(1, a + 1), range(1, b + 1), range(1, c + 1)):\n xyz = x * y * z\n if xyz in cache:\n res += cache[xyz]\n else:\n u = 1\n for t in map(sum, zip(l[x], l[y], l[z])):\n if t:\n u *= t + 1\n u &= 1073741823\n cache[xyz] = u\n res += u\n print(res & 1073741823)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "p= [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]\ndef d(x):\n y=0\n ans=1\n for i in p:\n if x < i:\n break\n y=1\n while x%i==0 and x>= i:\n x/=i\n y+=1\n ans*=y\n return ans\na,b,c=map(int,input().split())\nout=0\nq={}\nfor i in range(1,a+1) :\n for j in range(1,b+1) :\n for k in range(1,c+1) :\n e=i*j*k\n if e not in q :\n q[e]=d(e)\n out+=q[e]\nprint(out % 1073741824)"}, {"source_code": "from collections import Counter\n\n\ndef factors(n):\n fact = Counter()\n\n i = 2\n while i * i <= n:\n while n % i == 0:\n fact[i] += 1\n n //= i\n i += 1\n\n if n != 1:\n fact[n] += 1\n\n fact[1] = 1\n\n return fact\n\n\ndef solve(a, b, c):\n fact = {i: factors(i) for i in range(1, max(a, b, c) + 1)}\n\n ans = 0\n cache = {}\n for i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n p = i * j * k\n if p not in cache:\n f = fact[i] + fact[j] + fact[k]\n f[1] = 1\n res = 1\n for k, v in f.items():\n res *= v + 1\n \n cache[p] = res // 2\n\n ans += cache[p]\n\n return ans % 1073741824\n\n\ndef main():\n a, b, c = map(int, input().split())\n ans = solve(a, b, c)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "MOD = 1073741824\n(a, b, c) = map(int, input().split(' '))\n\nmaxProd = a * b * c\nd = [0 for i in range(maxProd + 1)]\nd[1] = 1\n\nfor i in range(2, maxProd + 1):\n d[i] = 2\n\nfor i in range(2, maxProd//2 + 1):\n for j in range(2 * i, maxProd + 1, i):\n d[j] += 1\n\nret = 0\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n ret = (ret + d[i * j * k]) % MOD\n\nprint(ret)\n"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1000001):\n\tfor y in range(x,1000001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)\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\nrr = sieve(100)\n\ndef d(n):\n\tres = 1\n\tr = rr\n\tfor i in rr:\n\t\tcnt = 1\n\t\tif i > n:\n\t\t\treturn res\n\t\twhile n%i == 0:\n\t\t\tn //= i\n\t\t\tcnt += 1\n\t\tres *= cnt\n\treturn res\n\t\t\t\n\ndef main():\n\ta,b,c = mi()\n\tres = 0\n\tfor i in range(1,a+1,1):\n\t\tfor j in range(1,b+1,1):\n\t\t\tfor k in range(1,c+1,1):\n\t\t\t\tres += d(i*j*k)%1073741824\n\tprint(res)\n\t\t\t\t\nmain()"}, {"source_code": "a, b, c = map(int, input().split())\n\ndef count_div(x):\n\tcount = 2\n\n\tfor i in range(2, int(x**0.5)+1):\n\t\tif not x%i:\n\t\t\tif i*i != x:\n\t\t\t\tcount += 2\n\t\t\telse:\n\t\t\t\tcount += 1\n\treturn count\n\nk = 10**5\nd = [0 for i in range(10**6+1)]\nd[1] = 1; d[2] = 2; d[3] = 2\n\nN = 2**30\nans = 0\n\nfor i in range(1, a+1):\n\tfor j in range(1, b+1):\n\t\tfor k in range(1, c+1):\n\t\t\tif not d[i*j*k]:\n\t\t\t\td[i*j*k] = count_div(i*j*k)\n\t\t\t\n\t\t\tans = (ans + d[i*j*k])%N\nprint(ans)"}, {"source_code": "from sys import *\ninput=stdin.readline\nx,y,z=map(int,input().split())\nl=[1]*(1000001)\nfor i in range(2,1000001):\n for j in range(i,1000001,i):\n l[j]+=1\nc=0\nfor i in range(1,x+1):\n for j in range(1,y+1):\n for k in range(1,z+1):\n c+=l[i*j*k]\nprint(c%(1073741824))\n"}, {"source_code": "from functools import reduce\nfrom collections import Counter\nimport time\nimport datetime\n\ndef time_t():\n print(\"Current date and time: \" , datetime.datetime.now())\n print(\"Current year: \", datetime.date.today().strftime(\"%Y\"))\n print(\"Month of year: \", datetime.date.today().strftime(\"%B\"))\n print(\"Week number of the year: \", datetime.date.today().strftime(\"%W\"))\n print(\"Weekday of the week: \", datetime.date.today().strftime(\"%w\"))\n print(\"Day of year: \", datetime.date.today().strftime(\"%j\"))\n print(\"Day of the month : \", datetime.date.today().strftime(\"%d\"))\n print(\"Day of week: \", datetime.date.today().strftime(\"%A\"))\n\ndef ip():\n return int(input())\n\ndef sip():\n return input()\n\ndef mip():\n return map(int,input().split())\n\ndef mips():\n return map(str,input().split())\n\ndef lip():\n return list(map(int,input().split()))\n\ndef matip(n,m):\n lst=[]\n for i in range(n):\n arr = lip()\n lst.append(arr)\n return lst\n\ndef factors(n): # find the factors of a number\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\ndef minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps\n jumps = [0 for i in range(n)]\n if (n == 0) or (arr[0] == 0):\n return float('inf')\n jumps[0] = 0\n for i in range(1, n):\n jumps[i] = float('inf')\n for j in range(i):\n if (i <= j + arr[j]) and (jumps[j] != float('inf')):\n jumps[i] = min(jumps[i], jumps[j] + 1)\n break\n return jumps[n-1]\n\ndef dic(arr): # converting list into dict of count\n return Counter(arr)\n\ndef prime(n):\n for i in range(3,int(n**(0.5))+1):\n if n%i==0:\n return False\n return True \n\nprimes = []\nfor i in range(2,101):\n if prime(i):\n primes.append(i)\n\na,b,c = mip()\ncount = 0\nif a==1 and b==1 and c==1:\n print(1)\nelse:\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n q = i*j*k\n ans = 1\n for item in primes:\n if q=1:\n q = q//item\n y+=1\n ans = ans*y\n count += ans\n print(count)"}, {"source_code": "import math\nres = 0\na,b,c = map(int,input().split())\narr = [0]*1000001\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n num = i*j*k\n count = 0\n if arr[num]:\n res += arr[num]\n else:\n for l in range(1,math.floor((num)**(1/2))+1):\n if num % l == 0:\n if num // l != l:\n count += 2\n else:\n count += 1\n res += count\n arr[num] = count\nprint(res%(2**30))"}, {"source_code": "a,b,c = map(int,input().split())\nli = a*b*c +1\nd = [1]*li\nfor i in range(2,li):\n for j in range(i,li,i):\n d[j]+=1\n\nans = 0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans += d[i*j*k]\n\nprint(ans)"}, {"source_code": "def mergeDict(a, b, c):\n ret = a.copy()\n for key, value in b.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n\n for key, value in c.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n return ret\n\n\nisPrime = [True for i in range(101)]\nfor i in range(2, 101):\n if isPrime[i] is True:\n for j in range(i + i, 101, i):\n isPrime[j] = False\nprimeList = [i for i in range(2, 101) if isPrime[i] is True]\n\ndecomposition = [None] * 101\ndecomposition[1] = {2:0} # special workaround\nfor prime in primeList:\n decomposition[prime] = {prime : 1}\n for i in range(2, 101):\n if decomposition[i] is not None and i * prime < 101:\n decomposition[i * prime] = decomposition[i].copy()\n if prime not in decomposition[i * prime].keys():\n decomposition[i * prime][prime] = 1\n else:\n decomposition[i * prime][prime] += 1\n\n\na, b, c = map(int, raw_input().split())\nhashTable = {}\nans = 0\nfor ai in range(1, a+1):\n for bi in range(1, b+1):\n for ci in range(1, c+1):\n d = ai * bi * ci\n if hashTable.has_key(d):\n ans += hashTable[d]\n else:\n merge = mergeDict(decomposition[ai], decomposition[bi], decomposition[ci])\n num = reduce(lambda x, y: x*y, map(lambda x: x+1, merge.values()))\n ans += num\n hashTable[d] = num\n ans %= 1073741824\n\nprint ans\n\n"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1000001):\n\tfor y in range(x,1000001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)\n"}, {"source_code": "def inp():\n return map(int, stdin.readline().split())\n\n\ndef factorize(n): # o(sqr(n))\n c, ans = 1, 0\n while (c * c < n):\n if n % c == 0:\n ans += 2\n c += 1\n\n if c * c == n:\n ans += 1\n return ans\n\n\nfrom sys import *\nfrom collections import *\n\na, b, c = inp()\nmem, ans = defaultdict(int), 0\n\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n pro = i * j * k\n if mem[pro] == 0:\n mem[pro] = factorize(pro)\n ans += mem[pro]\nprint(ans)"}, {"source_code": "def dic(n):\n i=2\n f=1\n t=0\n while i*i<=n:\n \n while n%i==0:\n t+=1\n n//=i\n \n f=f*(t+1)\n t=0\n if i==2:\n i=3\n else:\n i+=2\n if n>1:\n f*=2\n \n return f\n \n \na,b,c=map(int,input().split())\nd=dict()\na+=1\nb+=1\nc+=1\ng=0\nfor i in range(1,a):\n for j in range(1,b):\n for z in range(1,c):\n ans=dic(i*j*z)\n \n g+=ans\n\nprint(g)\n"}, {"source_code": "d = {}\n\ndef gd(n):\n s, f, p, t = 2, {}, 1, n\n while n!=1:\n if n%s == 0:\n n = n/s\n f[s] = f.get(s,0)+1\n s = 2\n else:\n s+=1\n values = f.values()\n for x in values:\n p*=(x+1)\n d[t] = p\n return p\n\n\nresult = 0\nx, y, z = map(int,raw_input().split())\nimport datetime\nst = datetime.datetime.now()\nfor i in range(1,x+1):\n for j in range(1,y+1):\n for k in range(1,z+1):\n t = i*j*k\n r = d.get(t,None)\n if r is None:\n result+=gd(t)\n else:\n result+=r\nprint result%1073741824\n\n\n"}, {"source_code": "import math as m\na, b, c=map(int, input().split())\nans=0\ndef div(num):\n t=0\n for i in range(1, int(m.sqrt(num)) + 1):\n if num%i==0:\n t+=1\n if num//i!=i:\n t+=1\n return t\ndic={}\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n a=i*j*k\n if a in dic:\n ans=(ans+dic[a])%1073741824\n else:\n dic[a]=div(a)\n ans=(ans+dic[a])%1073741824\nprint(ans)\n"}, {"source_code": "a, b, c = map(int, raw_input().split())\nd, r = {}, 0\nfor x in [(i + 1) * (j + 1) * (k + 1) for i in range(a) for j in range(b) for k in range(c)]:\n\td[x] = d.get(x, 0) + 1\nfor k, v in d.items():\n\tt, i = 1, 2\n\twhile i * i <= k:\n\t\tif k % i == 0:\n\t\t\tk /= i\n\t\t\tc = 2\n\t\t\twhile k % i == 0:\n\t\t\t\tk /= i\n\t\t\t\tc += 1\n\t\t\tt *= c\n\t\ti += 1\n\tif k > 1:\n\t\tt *= 2\n\tr = (r + t * v) & 1073741823\nprint r"}, {"source_code": "mod = (1 << 30)\nmemo = dict()\n\ndef dp(x):\n\tif x in memo:\n\t\treturn memo[x]\n\tres, q, t = 1, 2, x\n\twhile q * q <= x:\n\t\tr = 1\n\t\twhile x % q == 0:\n\t\t\tx /= q\n\t\t\tr += 1\n\t\tres = (res * r) % mod\n\t\tq += 1\n\tif x > 1:\n\t\tres = (res * 2) % mod\n\tmemo[t] = res\n\treturn res\n\na, b, c = sorted(map(int, input().split()))\nres = 0\nfor i in range(1, a+1):\n\tfor j in range(1, b+1):\n\t\tfor k in range(1, c+1):\n\t\t\tres = (res + dp(i * j * k)) % mod\nprint(res)\n"}, {"source_code": "import sys\nimport time\nimport math\nfrom functools import lru_cache\n\nINF = 10 ** 18 + 3\nEPS = 1e-10\nMAX_CACHE = 10 ** 9\n\nMOD = 1 << 30\n\n\n# Decorators\ndef time_it(function, output=sys.stderr):\n def wrapped(*args, **kwargs):\n start = time.time()\n res = function(*args, **kwargs)\n elapsed_time = time.time() - start\n print('\"%s\" took %f ms' % (function.__name__, elapsed_time * 1000),\n file=output)\n return res\n\n return wrapped\n\n\n@lru_cache(MAX_CACHE)\ndef calc_prime_divs(n):\n if n == 1:\n return ()\n sieve = [True] * (n // 2)\n for i in range(3, int(n ** 0.5) + 1, 2):\n if sieve[i // 2]:\n sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)\n return (2,) + tuple(2 * i + 1 for i in range(1, n // 2) if sieve[i])\n\n\ndivisors = calc_prime_divs(100**3)\n\n\n@lru_cache(MAX_CACHE)\ndef calc_num_of_divs(n):\n if n == 1:\n return 1\n\n k = 1\n for div in divisors:\n if n < div:\n return 2\n while n % div == 0:\n k += 1\n n //= div\n if k > 1:\n return k * calc_num_of_divs(n)\n\n\n@time_it\ndef main():\n a, b, c = map(int, input().split())\n print(sum(calc_num_of_divs(i * j * k) % MOD\n for i in range(a, 0, -1)\n for j in range(b, 0, -1)\n for k in range(c, 0, -1)))\n\n\ndef set_input(file):\n global input\n input = lambda: file.readline().strip()\n\n\ndef set_output(file):\n global print\n local_print = print\n\n def print(*args, **kwargs):\n kwargs[\"file\"] = kwargs.get(\"file\", file)\n return local_print(*args, **kwargs)\n\n\nif __name__ == '__main__':\n set_input(open(\"input.txt\", \"r\") if \"MINE\" in sys.argv else sys.stdin)\n set_output(sys.stdout)\n main()\n"}, {"source_code": "#coding: utf8\nimport math\nimport copy\nimport sys\nimport itertools\n\ndef printe(inp):\n sys.stderr.write(repr(inp)+'\\n')\n #sys.stderr.flush()\n\ndef primes(n):\n \"\"\"http://code.activestate.com/recipes/366178-a-fast-prime-number-list-generator/\"\"\"\n if n==2: return [2]\n elif n<2: return []\n s=range(3,n+1,2)\n mroot = n ** 0.5\n i_half=(n+1)/2-1\n i=0\n m=3\n while m <= mroot:\n if s[i]:\n j=(m*m-3)/2\n s[j]=0\n while j=1:\n q = q//item\n y+=1\n ans = ans*y\n count += ans\n print(count)"}, {"source_code": "a, b, c = map(int, input().split())\n\nd = 1073741824\n\np = [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]\n\nt = [{} for i in range(101)]\n\nans = {}\n\nfor i in p:\n\n j = i\n\n m = 1\n\n while j < 101:\n\n for k in range(j, 101, j):\n\n t[k][i] = m\n\n j = j * i\n\n m += 1\n\ns = 0\n\nfor i in range(1, a + 1):\n\n for j in range(1, b + 1):\n\n q = {}\n\n for x in t[i].keys() | t[j].keys():\n\n q[x] = t[i].get(x, 0) + t[j].get(x, 0)\n\n ij = i * j\n\n for k in range(1, c + 1):\n\n ijk = ij * k\n\n if ijk in ans: s += ans[ijk]\n\n else:\n\n y = 1\n\n for x in q.keys() | t[k].keys():\n\n y = y * (q.get(x, 0) + t[k].get(x, 0) + 1)\n\n ans[ijk] = y\n\n s += y\n\n\n\nprint(s)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "MOD = 1073741824\n\ndef findPrimeFact(n):\n fact = {}\n count = 0\n while(n%2 == 0):\n count += 1\n n //= 2\n if count:\n fact[2] = count\n for i in range(3, int(n**0.5)+1, 2):\n count = 0\n while n%i ==0:\n count += 1\n n //= i\n if count:\n fact[i] = count\n if n>2:\n fact[n] = 1\n return(fact)\n\na, b, c = map(int, input().split())\nans = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n fact = findPrimeFact(i*j*k)\n temp = 1\n for l in fact:\n temp *= (1+fact[l])\n temp %= MOD\n ans += temp\n ans %= MOD\n\nprint(ans%MOD)\n"}, {"source_code": "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#input = sys.stdin.readline\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\n\ndef flin(d, x, default = -1):\n f = l = -1\n for i in range(len(d)):\n if d[i] == x:\n if f == -1: f = i\n l = i\n if f == -1:\n return (default, default)\n else:\n return (f, l)\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\npr = sieve(10**6 // 2)\ndef divn(n):\n res = 1\n for i in pr:\n if n == 1:\n return res\n\n t = 1\n while n % i == 0:\n t += 1\n n = n//i\n res *= t\n\na, b, c = mi()\nmem = [0]*(10**6 + 1)\nres = 0\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n n = i * j * k\n if mem[n] == 0: mem[n] = divn(i * j * k)\n res += mem[n]\nprint(res % 1073741824)\n\n\n"}, {"source_code": "a, b, c = map(int, input().split())\nd = [0] * 1000010\n\nfor i in range(1, (a*b*c) + 1):\n for j in range(i, (a*b*c) + 1, i):\n d[j] += 1\nsum_n = 0\n\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n sum_n = (sum_n + d[i*j*k])\nprint(sum_n % 1073741824)\n"}, {"source_code": "a,b,c=map(int,input().split())\nM=1073741824\nn=a*b*c\nd=[1]*(n+1)\nfor i in range(2,n+1):\n\tfor j in range(i,n+1,i):\n\t d[j]+=1\nr=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tr+=(d[i*j*k])%M\nprint(r%M)\n"}, {"source_code": "import math\nimport itertools\nimport operator\n\n\nprimes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29,\n 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,\n 73, 79, 83, 89, 97]\n\n\ndef get_prime_mult(n):\n m = [0] * 25\n if n < 2:\n return m\n sq = int(math.sqrt(n))\n p = 0\n while primes[p] <= sq:\n if n % primes[p] != 0:\n p += 1\n else:\n m[p] += 1\n n //= primes[p]\n sq = int(math.sqrt(n))\n\n m[primes.index(n)] += 1\n return m\n\n\na, b, c = map(int, input().split())\nmtab = []\nfor i in range(max((a, b, c)) + 1):\n mtab.append(get_prime_mult(i))\n\ntotal = 0\nmults_cnt = {}\nfor i in range(1, a + 1):\n for j in range(1, b + 1):\n for k in range(1, c + 1):\n if i * j * k not in mults_cnt:\n mults = [sum(triple) + 1 for triple in zip(mtab[i], mtab[j], mtab[k])]\n mults_cnt[i * j * k] = list(itertools.accumulate(mults, operator.mul))[-1]\n total += mults_cnt[i * j * k]\n\nprint(total & 0x3FFFFFFF)\n"}, {"source_code": "# https://codeforces.com/problemset/problem/236/B\n\n\"\"\"\nd(n) denotes the number of divisors a number has\n\"\"\"\n\na, b, c = map(int, input().split())\n\nlimit = a*b*c + 1\nd = [1] * limit\nfor i in range(2, limit):\n for j in range(i, limit, i):\n d[j] += 1\n\nanswer = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n answer += d[i*j*k]\n\nprint(answer % 1073741824)\n"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\nimport math\n\n\ndef countDivisors(n):\n cnt = 0\n for i in range(1, (int(math.sqrt(n))) + 1):\n if n % i == 0:\n if int(n / i) == i:\n cnt = cnt + 1\n else:\n cnt = cnt + 2\n return cnt\n\nd = dict()\n\na, b, c = map(int, input().split())\nans = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n if i * j * k not in d:\n d[i*j*k] = countDivisors(i*j*k)\n ans += d[i*j*k]\n else:\n ans += d[i*j*k]\nprint(ans)"}, {"source_code": "def gen_primes(n):\n ret = [2]\n if n < 3:\n return ret\n n += 1\n buf = [0] * n\n buf[2] = 1\n for i in xrange(3, n, 2):\n if buf[i] == 0:\n ret.extend([i])\n for j in xrange(2 * i, n, i):\n buf[j] = 1\n return ret\ndef count_divisor(n, primes):\n ret = 1\n for p in primes:\n if n < p:\n break\n cnt = 1\n while n % p == 0:\n cnt += 1\n n /= p\n ret *= cnt\n return ret\ndef main():\n p = gen_primes(1000000)\n a, b, c = map(int, raw_input().split())\n a, b, c, ans = a + 1, b + 1, c + 1, 0\n buf = [1] * (a * b * c)\n for ai in xrange(1, a):\n for bi in xrange(1, b):\n for ci in xrange(1, c):\n i = ai * bi * ci\n if buf[i] == 1 and i > 1:\n buf[i] = count_divisor(i, p)\n ans += buf[i]\n print ans\nif __name__ == '__main__':\n main()"}, {"source_code": "# https://codeforces.com/problemset/problem/236/B\n\n\"\"\"\nd(n) denotes the number of divisors a number has\n\"\"\"\n\na, b, c = map(int, input().split())\n\nlimit = a*b*c + 1\nd = [1] * limit\nfor i in range(2, limit):\n for j in range(i, limit, i):\n d[j] += 1\n\nanswer = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n answer += d[i*j*k]\n\nprint(answer % 1073741824)\n"}, {"source_code": "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]\nl = []\nl.append(primes)\nfor i in range(100):\n\tii = i+1\n\ta=[0]*25\n\tfor j in range(25):\n\t\tif ii==1:\n\t\t\tbreak\n\t\twhile ii%primes[j] == 0:\n\t\t\ta[j]+=1\n\t\t\tii = ii/primes[j]\n\tl.append(a)\na, b, c = map(int, input().split())\nans = 0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tdiv = 1\n\t\t\tfor d in range(25):\n\t\t\t\tdiv *= (1+l[i][d]+l[j][d]+l[k][d])\n\t\t\tans += div\nans%=1073741824\nprint(ans)"}, {"source_code": "a,b,c= [int(x) for x in input().split(' ')]\n\nmod=1073741824\n\ndivisors=[1]*1000001\n\nfor i in range(2 , 1000001):\n for j in range(i , 1000001 , i ):\n divisors[j] +=1\n\nans = 0\n#print(divisors[1])\n\nfor i in range(1 , a+1):\n for j in range(1 , b+1):\n for k in range(1 , c+1):\n ans += (divisors[i * j * k]) % mod\n\n\nprint(ans % mod)\n\n"}, {"source_code": "line = raw_input()\n\ntokens = line.split(' ')\n\na,b,c = int(tokens[0]), int(tokens[1]), int(tokens[2])\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]\n\ncache = (a * b * c + 1)* [0]\n\ndiv_sum = 0\n\ndef compute_div_count(num):\n ans = 1\n for prime in primes:\n count = 1\n while num % prime == 0:\n count += 1\n num /= prime\n ans *= count\n return ans\n\nfor i in xrange(1, a + 1):\n for j in xrange(1, b + 1):\n for k in xrange(1, c + 1):\n num = i * j * k\n if cache[num] == 0:\n cache[num] = compute_div_count(num)\n div_sum = (div_sum + cache[num]) % 1073741824\nprint div_sum\n "}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\n\ndef divisors(x):\n\tpowers={}\n\ti=2\n\twhile(x!=1):\n\t\tif x%i==0:\n\t\t\tif i in powers:\n\t\t\t\tpowers[i]+=1\n\t\t\telse:\n\t\t\t\tpowers[i]=1\n\t\t\tx//=i\n\t\telse:\n\t\t\ti+=1\n\treturn powers\n\nprimeFactors={}\n\nfor x in range(1,101):\n\tprimeFactors[x]=divisors(x)\n\ndef finalMapPrepare(finalMap,x):\n\tfor k in primeFactors[x]:\n\t\tif k in finalMap:\n\t\t\tfinalMap[k]+=primeFactors[x][k]\n\t\telse:\n\t\t\tfinalMap[k]=primeFactors[x][k]\n\t\t\ntotal=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tfinalMap={}\n\t\t\tfinalMapPrepare(finalMap,i)\n\t\t\tfinalMapPrepare(finalMap,j)\n\t\t\tfinalMapPrepare(finalMap,k)\n\t\t\tans=1\n\t\t\tfor v in finalMap.values():\n\t\t\t\tans*=(v+1)\n\t\t\ttotal+=(ans)%mod\nprint(total%mod)"}, {"source_code": "def easyNumbers():\n a,b,c=map(int,input().split())\n divisors=[1]*1000001\n n=a*b*c\n sum=0\n modulo=1073741824\n for i in range(2,n+1):\n for j in range(i,n+1,i):\n divisors[j] += 1\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n sum=sum+divisors[i*j*k]\n print(sum%modulo)\n\neasyNumbers()\n"}, {"source_code": "def dic(n):\n i=2\n f=1\n t=0\n while i*i<=n:\n \n while n%i==0:\n t+=1\n n//=i\n \n f=f*(t+1)\n t=0\n if i==2:\n i=3\n else:\n i+=2\n if n>1:\n f*=2\n \n return f\n \n \na,b,c=map(int,input().split())\nd=dict()\na+=1\nb+=1\nc+=1\ng=0\nfor i in range(1,a):\n for j in range(1,b):\n for z in range(1,c):\n ans=dic(i*j*z)\n \n g+=ans\n\nprint(g)\n"}, {"source_code": "import sys\nimport time\nimport math\nfrom functools import lru_cache\n\nINF = 10 ** 18 + 3\nEPS = 1e-10\nMAX_CACHE = 10 ** 9\n\nMOD = 1 << 30\n\n\n# Decorators\ndef time_it(function, output=sys.stderr):\n def wrapped(*args, **kwargs):\n start = time.time()\n res = function(*args, **kwargs)\n elapsed_time = time.time() - start\n print('\"%s\" took %f ms' % (function.__name__, elapsed_time * 1000),\n file=output)\n return res\n\n return wrapped\n\n\n@lru_cache(MAX_CACHE)\ndef calc_prime_divs(n):\n if n == 1:\n return ()\n sieve = [True] * (n // 2)\n for i in range(3, int(n ** 0.5) + 1, 2):\n if sieve[i // 2]:\n sieve[i * i // 2::i] = [False] * ((n - i * i - 1) // (2 * i) + 1)\n return (2,) + tuple(2 * i + 1 for i in range(1, n // 2) if sieve[i])\n\n\ndivisors = ()\n\n\n@lru_cache(MAX_CACHE)\ndef calc_num_of_divs(n):\n # if n % 8 == 4 and n > 4:\n # return calc_num_of_divs(4) * calc_num_of_divs(n // 4)\n # if n % 16 == 8:\n # return (calc_num_of_divs(16) - 1) * calc_num_of_divs(n // 8)\n # if n % 27 == 9:\n # return (calc_num_of_divs(27) - 1) * calc_num_of_divs(n // 9)\n res = 1\n for div in divisors:\n if n < div:\n break\n k = 1\n while n % div == 0:\n k += 1\n n //= div\n res *= k\n\n return res\n\n\n@time_it\ndef main():\n a, b, c = map(int, input().split())\n global divisors\n divisors = calc_prime_divs(a * b * c + 1)\n print(sum(calc_num_of_divs(i * j * k) % MOD\n for i in range(a, 0, -1)\n for j in range(b, 0, -1)\n for k in range(c, 0, -1)))\n\n\ndef set_input(file):\n global input\n input = lambda: file.readline().strip()\n\n\ndef set_output(file):\n global print\n local_print = print\n\n def print(*args, **kwargs):\n kwargs[\"file\"] = kwargs.get(\"file\", file)\n return local_print(*args, **kwargs)\n\n\nif __name__ == '__main__':\n set_input(open(\"input.txt\", \"r\") if \"MINE\" in sys.argv else sys.stdin)\n set_output(sys.stdout)\n main()\n"}, {"source_code": "import sys\n\n\np=[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]\n\ndef d(x):\n y=0\n ans=1\n for i in p:\n y=1\n while x%i==0 and x>1:\n x/=i\n y+=1\n ans*=y\n return ans\n\n\na,b,c=map(int,raw_input().split())\nh=[0]*(a*b*c+1)\nt=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n l=i*j*k\n if h[l]==0:\n h[l]=d(l)\n t+=h[l]\n \n\nprint t%1073741824\n\n "}, {"source_code": "a , b , c = map(int,input().split())\n\ndivs = [1] * 1000001\nmod=1073741824\n\nfor i in range(2 , 1000001):\n for j in range(i , 1000001 , i ):\n divs[j] +=1\n\nans = 0\nfor i in range(1 , a + 1 ):\n for j in range(1 , b + 1):\n for k in range(1 , c + 1):\n ans += (divs[i*j*k]) % mod\n\n\nprint(ans % (mod*2**30))\n\n"}, {"source_code": "from math import *\ndef div(x):\n s=0\n for i in range(2,floor(sqrt(x))+1):\n if x%i==0:s+=1\n if x%(x//i)==0 and i!=x//i:s+=1\n if x==1:return s+1\n return s+2\nd=[-1]*(1000001)\na,b,c=map(int,input().split());ans=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n if d[i*j*k]==-1:d[i*j*k]=div(i*j*k)\n ans=(ans+d[i*j*k])\nprint(ans)\n"}, {"source_code": "a, b, c = map(int, input().split())\nmod = 1073741824\nn = a*b*c\ndiv = [1]*(n+1)\nfor i in range(2, n+1):\n for j in range(i, n+1, i):\n div[j]+=1\nans = 0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n ans=(ans+div[i*j*k])%mod\nprint(ans)\n"}, {"source_code": "def gen_primes(n):\n ret = [2]\n if n < 3:\n return ret\n n += 1\n buf = [0] * n\n buf[2] = 1\n for i in xrange(3, n, 2):\n if buf[i] == 0:\n ret.extend([i])\n for j in xrange(2 * i, n, i):\n buf[j] = 1\n return ret\ndef count_divisor(n, primes):\n ret = 1\n for p in primes:\n if n < p:\n break\n cnt = 1\n while n % p == 0:\n cnt += 1\n n /= p\n ret *= cnt\n return ret\ndef main():\n p = gen_primes(1000000)\n a, b, c = map(int, raw_input().split())\n a, b, c, ans = a + 1, b + 1, c + 1, 0\n buf = [1] * (a * b * c)\n for ai in xrange(1, a):\n for bi in xrange(1, b):\n for ci in xrange(1, c):\n i = ai * bi * ci\n if buf[i] == 1 and i > 1:\n buf[i] = count_divisor(i, p)\n ans += buf[i]\n print ans\nif __name__ == '__main__':\n main()"}, {"source_code": "mod = (1 << 30)\nmemo = dict()\n\ndef dp(x):\n\tif x in memo:\n\t\treturn memo[x]\n\tres, q, t = 1, 2, x\n\twhile q * q <= x:\n\t\tr = 1\n\t\twhile x % q == 0:\n\t\t\tx /= q\n\t\t\tr += 1\n\t\tres = (res * r) % mod\n\t\tq += 1\n\tif x > 1:\n\t\tres = (res * 2) % mod\n\tmemo[t] = res\n\treturn res\n\na, b, c = sorted(map(int, input().split()))\nres = 0\nfor i in range(1, a+1):\n\tfor j in range(1, b+1):\n\t\tfor k in range(1, c+1):\n\t\t\tres = (res + dp(i * j * k)) % mod\nprint(res)\n"}, {"source_code": "from collections import Counter\n\n\ndef factors(n):\n fact = Counter()\n\n i = 2\n while i * i <= n:\n while n % i == 0:\n fact[i] += 1\n n //= i\n i += 1\n\n if n != 1:\n fact[n] += 1\n\n fact[1] = 1\n\n return fact\n\n\ndef solve(a, b, c):\n fact = {i: factors(i) for i in range(1, max(a, b, c) + 1)}\n\n ans = 0\n cache = {}\n for i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n p = i * j * k\n if p not in cache:\n f = fact[i] + fact[j] + fact[k]\n f[1] = 1\n res = 1\n for k, v in f.items():\n res *= v + 1\n \n cache[p] = res // 2\n\n ans += cache[p]\n\n return ans % 1073741824\n\n\ndef main():\n a, b, c = map(int, input().split())\n ans = solve(a, b, c)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\n\ndef divisors(x):\n\tpowers={}\n\ti=2\n\twhile(x!=1):\n\t\tif x%i==0:\n\t\t\tif i in powers:\n\t\t\t\tpowers[i]+=1\n\t\t\telse:\n\t\t\t\tpowers[i]=1\n\t\t\tx//=i\n\t\telse:\n\t\t\ti+=1\n\treturn powers\n\nprimeFactors={}\n\nfor x in range(1,101):\n\tprimeFactors[x]=divisors(x)\n\ndef finalMapPrepare(finalMap,x):\n\tfor k in primeFactors[x]:\n\t\tif k in finalMap:\n\t\t\tfinalMap[k]+=primeFactors[x][k]\n\t\telse:\n\t\t\tfinalMap[k]=primeFactors[x][k]\n\t\t\ntotal=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tfinalMap={}\n\t\t\tfinalMapPrepare(finalMap,i)\n\t\t\tfinalMapPrepare(finalMap,j)\n\t\t\tfinalMapPrepare(finalMap,k)\n\t\t\tans=1\n\t\t\tfor v in finalMap.values():\n\t\t\t\tans*=(v+1)\n\t\t\ttotal+=(ans)%mod\nprint(total%mod)"}, {"source_code": "a, b, c = map(int, input().split())\n\nd = 1073741824\n\np = [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]\n\nt = [{} for i in range(101)]\n\nans = {}\n\nfor i in p:\n\n j = i\n\n m = 1\n\n while j < 101:\n\n for k in range(j, 101, j):\n\n t[k][i] = m\n\n j = j * i\n\n m += 1\n\ns = 0\n\nfor i in range(1, a + 1):\n\n for j in range(1, b + 1):\n\n q = {}\n\n for x in t[i].keys() | t[j].keys():\n\n q[x] = t[i].get(x, 0) + t[j].get(x, 0)\n\n ij = i * j\n\n for k in range(1, c + 1):\n\n ijk = ij * k\n\n if ijk in ans: s += ans[ijk]\n\n else:\n\n y = 1\n\n for x in q.keys() | t[k].keys():\n\n y = y * (q.get(x, 0) + t[k].get(x, 0) + 1)\n\n ans[ijk] = y\n\n s += y\n\n\n\nprint(s)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "\na,b,c=map(int,input().split())\nM=1073741824\nn=a*b*c\nd=[1]*(n+1)\nfor i in range(2,n+1):\n for j in range(i,n+1,i):\n d[j]+=1\nr=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n r+=(d[i*j*k])%M\nprint(r%M)"}, {"source_code": "primes = []\nd = {}\nfor i in range(2, 100):\n if i not in d:\n primes.append(i)\n j = 2\n while i * j < 100:\n d[i*j] = 1\n j += 1\n\ndef solve(x,y,z):\n d = {}\n for p in primes:\n d[p] = 0\n\n for p in primes:\n if p > x and p > y and p > z:\n break\n while x%p == 0:\n x /= p\n d[p] += 1\n while y%p == 0:\n y /= p\n d[p] += 1\n while z%p == 0:\n z /= p\n d[p] += 1\n ans = 1\n for p in primes:\n ans *= d[p] + 1\n return ans\n\na,b,c = map(int,input().split(' '))\nans = 0\nseen = {}\n\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n p = i*j*k\n if p in seen:\n ans = (ans + seen[p]) % 1073741824\n else:\n temp = solve(i,j,k)\n ans = (ans + temp) % 1073741824\n seen[p] = temp\n\nprint(ans)\n\n\n"}, {"source_code": "def mergeDict(a, b, c):\n ret = a.copy()\n for key, value in b.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n\n for key, value in c.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n return ret\n\n\nisPrime = [True] * 101\nprimeList = []\nfor i in xrange(2, 101):\n if isPrime[i] is True:\n primeList.append(i)\n for j in xrange(i + i, 101, i):\n isPrime[j] = False\n\ndecomposition = [None] * 101\ndecomposition[1] = {2:0} # special workaround\nfor prime in primeList:\n decomposition[prime] = {prime : 1}\n for i in xrange(2, 101):\n if decomposition[i] is not None and i * prime < 101:\n decomposition[i * prime] = decomposition[i].copy()\n if prime not in decomposition[i * prime].keys():\n decomposition[i * prime][prime] = 1\n else:\n decomposition[i * prime][prime] += 1\n\n\na, b, c = map(int, raw_input().split())\nhashTable = {}\nans = 0\nfor ai in xrange(1, a+1):\n for bi in xrange(1, b+1):\n for ci in xrange(1, c+1):\n d = ai * bi * ci\n if hashTable.has_key(d):\n ans += hashTable[d]\n else:\n merge = mergeDict(decomposition[ai], decomposition[bi], decomposition[ci])\n num = reduce(lambda x, y: x*y, map(lambda x: x+1, merge.values()))\n ans += num\n hashTable[d] = num\n ans %= 1073741824\n\nprint ans\n\n"}, {"source_code": "#236B\n\nimport math\n\narr = list(map(int, input().split(\" \")))\na = arr[0]\nb = arr[1]\nc = arr[2]\n\nd = dict()\n\ndef numdiv(n):\n\tif n in d:\n\t\treturn d[n]\n\telse:\n\t\tcount = 0\n\t\tfor i in range(1, int(math.sqrt(n) + 1)):\n\t\t\tif n % i == 0:\n\t\t\t\tcount += 2\n\t\tif int(math.sqrt(n)) * int(math.sqrt(n)) == n:\n\t\t\tcount -= 1\n\t\td[n] = count\n\t\treturn count\n\nanswer = 0\nfor i in range(1, a + 1):\n\tfor j in range(1, b + 1):\n\t\tfor k in range(1, c + 1):\n\t\t\tanswer += numdiv(i * j * k)\n\nprint(answer)"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1000001):\n\tfor y in range(x,1000001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)\n"}, {"source_code": "def easyNumbers():\n a,b,c=map(int,input().split())\n divisors=[1]*1000001\n n=a*b*c\n sum=0\n modulo=1073741824\n for i in range(2,n+1):\n for j in range(i,n+1,i):\n divisors[j] += 1\n for i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n sum=sum+divisors[i*j*k]\n print(sum%modulo)\n\neasyNumbers()\n"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1000001):\n\tfor y in range(x,1000001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)"}, {"source_code": "def mergeDict(a, b, c):\n ret = a.copy()\n for key, value in b.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n\n for key, value in c.items():\n if ret.has_key(key):\n ret[key] += value\n else:\n ret[key] = value\n return ret\n\ndef main():\n isPrime = [True] * 101\n primeList = []\n for i in xrange(2, 101):\n if isPrime[i] is True:\n primeList.append(i)\n for j in xrange(i + i, 101, i):\n isPrime[j] = False\n\n decomposition = [None] * 101\n decomposition[1] = {2:0} # special workaround\n for prime in primeList:\n decomposition[prime] = {prime : 1}\n for i in xrange(2, 101):\n if decomposition[i] is not None and i * prime < 101:\n decomposition[i * prime] = decomposition[i].copy()\n if prime not in decomposition[i * prime].keys():\n decomposition[i * prime][prime] = 1\n else:\n decomposition[i * prime][prime] += 1\n\n\n a, b, c = map(int, raw_input().split())\n#a, b, c = 78, 90, 100\n hashTable = [0] * (a * b * c + 1)\n ans = 0\n for ai in xrange(1, a+1):\n for bi in xrange(1, b+1):\n for ci in xrange(1, c+1):\n d = ai * bi * ci\n if hashTable[d] is not 0:\n ans += hashTable[d]\n else:\n merge = mergeDict(decomposition[ai], decomposition[bi], decomposition[ci])\n num = reduce(lambda x, y: x*y, map(lambda x: x+1, merge.values()))\n ans += num\n hashTable[d] = num\n\n print ans % 1073741824\n\nif __name__ == \"__main__\":\n main()\n"}], "negative_code": [{"source_code": "from operator import mul\nfrom functools import reduce\nfrom collections import Counter\n\na, b, c = map(int, input().split())\nmod = 2 ** 30\n\nprime = [None] * 100\n\nfor i in range(2, 100):\n if prime[i - 1] is None:\n for j in range(i, 100, i):\n prime[j - 1] = i\n\n\nd = {}\nresult = 0\nfor ai in range(1, a + 1):\n for bi in range(1, b + 1):\n for ci in range(1, c + 1):\n n = ai * bi * ci\n res = d.get(n)\n\n if res is None:\n cd = Counter()\n\n n_ai = ai\n while prime[n_ai - 1] is not None:\n cd[prime[n_ai - 1]] += 1\n n_ai //= prime[n_ai - 1]\n \n n_bi = bi\n while prime[n_bi - 1] is not None:\n cd[prime[n_bi - 1]] += 1\n n_bi //= prime[n_bi - 1]\n \n n_ci = ci\n while prime[n_ci - 1] is not None:\n cd[prime[n_ci - 1]] += 1\n n_ci //= prime[n_ci - 1]\n \n res = reduce(mul, map(lambda x: x + 1, cd.values()), 1)\n d[n] = res\n \n result += res\n\nprint(result % mod)\n"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\nmod=1073741824\ndivisors=[1]*1000001\nfor x in range(2,1001):\n\tfor y in range(x,100001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=(divisors[i*j*k])%mod\nprint(ans%mod)"}, {"source_code": "a,b,c=[int(x) for x in input().split(' ')]\ndivisors=[1]*1000001\nfor x in range(2,1001):\n\tfor y in range(x,100001,x):\n\t\tdivisors[y]+=1\nans=0\nfor i in range(1,a+1):\n\tfor j in range(1,b+1):\n\t\tfor k in range(1,c+1):\n\t\t\tans+=divisors[i*j*k]\nprint(ans)"}, {"source_code": "a,b,c = map(int,input().split())\nli = a*b*c +1\nd = [1]*li\nfor i in range(2,li):\n for j in range(i,li,i):\n d[j]+=1\n\nans = 0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for z in range(1,c+1):\n ans += d[a*b*c]\n\nprint(ans)"}, {"source_code": "from functools import reduce\nfrom collections import Counter\nimport time\nimport datetime\nfrom math import sqrt,gcd\n\ndef time_t():\n print(\"Current date and time: \" , datetime.datetime.now())\n print(\"Current year: \", datetime.date.today().strftime(\"%Y\"))\n print(\"Month of year: \", datetime.date.today().strftime(\"%B\"))\n print(\"Week number of the year: \", datetime.date.today().strftime(\"%W\"))\n print(\"Weekday of the week: \", datetime.date.today().strftime(\"%w\"))\n print(\"Day of year: \", datetime.date.today().strftime(\"%j\"))\n print(\"Day of the month : \", datetime.date.today().strftime(\"%d\"))\n print(\"Day of week: \", datetime.date.today().strftime(\"%A\"))\n\ndef ip():\n return int(input())\n\ndef sip():\n return input()\n\ndef mip():\n return map(int,input().split())\n\ndef mips():\n return map(str,input().split())\n\ndef lip():\n return list(map(int,input().split()))\n\ndef matip(n,m):\n lst=[]\n for i in range(n):\n arr = lip()\n lst.append(arr)\n return lst\n\ndef factors(n): # find the factors of a number\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\ndef minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps\n jumps = [0 for i in range(n)]\n if (n == 0) or (arr[0] == 0):\n return float('inf')\n jumps[0] = 0\n for i in range(1, n):\n jumps[i] = float('inf')\n for j in range(i):\n if (i <= j + arr[j]) and (jumps[j] != float('inf')):\n jumps[i] = min(jumps[i], jumps[j] + 1)\n break\n return jumps[n-1]\n\ndef dic(arr): # converting list into dict of count\n return Counter(arr)\n\ndef prime(n):\n for i in range(3,int(n**(0.5))+1,2):\n if n%i==0:\n return False\n return True \n\n# --------------------------------------------------------- #\nimport sys\n# sys.stdin = open('input.txt','r')\n# sys.stdout = open('output.txt','w')\n# --------------------------------------------------------- #\n# n = sys.stdin.readline()\n# arr = list(map(int, sys.stdin.readline().strip().split()))\n\na, b, c = mip()\nans = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n n = i*j*k\n fact = {}\n count = 0\n while(n%2 == 0):\n count += 1\n n //= 2\n if count:\n fact[2] = count\n for i in range(3, int(n**0.5)+1, 2):\n count = 0\n while n%i ==0:\n count += 1\n n //= i\n if count:\n fact[i] = count\n if n>2:\n fact[n] = 1\n temp = 1\n for l in fact:\n temp *= (fact[l]+1)\n temp %= 1073741824\n ans += temp\n ans %= 1073741824\nprint(ans%1073741824)\n"}, {"source_code": "from functools import reduce\nfrom collections import Counter\nimport time\nimport datetime\nfrom math import sqrt,gcd\n\ndef time_t():\n print(\"Current date and time: \" , datetime.datetime.now())\n print(\"Current year: \", datetime.date.today().strftime(\"%Y\"))\n print(\"Month of year: \", datetime.date.today().strftime(\"%B\"))\n print(\"Week number of the year: \", datetime.date.today().strftime(\"%W\"))\n print(\"Weekday of the week: \", datetime.date.today().strftime(\"%w\"))\n print(\"Day of year: \", datetime.date.today().strftime(\"%j\"))\n print(\"Day of the month : \", datetime.date.today().strftime(\"%d\"))\n print(\"Day of week: \", datetime.date.today().strftime(\"%A\"))\n\ndef ip():\n return int(input())\n\ndef sip():\n return input()\n\ndef mip():\n return map(int,input().split())\n\ndef mips():\n return map(str,input().split())\n\ndef lip():\n return list(map(int,input().split()))\n\ndef matip(n,m):\n lst=[]\n for i in range(n):\n arr = lip()\n lst.append(arr)\n return lst\n\ndef factors(n): # find the factors of a number\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\ndef minJumps(arr, n): #to reach from 0 to n-1 in the array in minimum steps\n jumps = [0 for i in range(n)]\n if (n == 0) or (arr[0] == 0):\n return float('inf')\n jumps[0] = 0\n for i in range(1, n):\n jumps[i] = float('inf')\n for j in range(i):\n if (i <= j + arr[j]) and (jumps[j] != float('inf')):\n jumps[i] = min(jumps[i], jumps[j] + 1)\n break\n return jumps[n-1]\n\ndef dic(arr): # converting list into dict of count\n return Counter(arr)\n\ndef prime(n):\n for i in range(3,int(n**(0.5))+1,2):\n if n%i==0:\n return False\n return True \n\n# --------------------------------------------------------- #\nimport sys\n# sys.stdin = open('input.txt','r')\n# sys.stdout = open('output.txt','w')\n# --------------------------------------------------------- #\n# n = sys.stdin.readline()\n# arr = list(map(int, sys.stdin.readline().strip().split()))\n\na, b, c = mip()\nans = 0\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n n = i*j*k\n fact = {}\n count = 0\n while(n%2 == 0):\n count += 1\n n //= 2\n if count:\n fact[2] = count\n for i in range(3, int(n**0.5)+1, 2):\n count = 0\n while n%i ==0:\n count += 1\n n //= i\n if count:\n fact[i] = count\n if n>2:\n fact[n] = 1\n temp = 1\n for l in fact:\n temp *= fact[l]\n temp %= 1073741824\n ans += temp\n ans %= 1073741824\nprint(ans%1073741824)\n"}, {"source_code": "d={}\nfor i in range(1,1000001):d[i]=set()\nfor i in range(1,101):\n for j in range(1,101):\n for k in range(1,101):\n d[i*j*k]|={1,i,j,k,i*j,j*k,k*i,i*j*k}\na,b,c=map(int,input().split());ans=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):ans=(ans+len(d[i*j*k]))#%1073741824\nprint(ans)\n\n"}, {"source_code": "from math import *\ndef div(x):\n s=0\n for i in range(1,ceil(sqrt(x))):\n if x%i==0:s+=1\n if x%(x//i)==0:s+=1\n return s\nd=[0]*(1000001)\na,b,c=map(int,input().split());ans=0\nfor i in range(1,a+1):\n for j in range(1,b+1):\n for k in range(1,c+1):\n if d[i*j*k]==0:d[i*j*k]=div(i*j*k)\n ans=(ans+d[i*j*k])%1073741824\nprint(ans)\n\n"}, {"source_code": "import operator as op\nimport 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 functools import reduce\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\ndef def_value():\n return 0\n\n\ndef nod(n):\n if dp[n] > 0:\n return dp[n]\n limit = int(sqrt(n)) + 1\n res = 1\n for i in range(2, limit+1):\n a = 0\n while n % i == 0:\n n //= i\n a += 1\n res *= (a + 1)\n if n > 1:\n res *= 2\n dp[n] = res\n return dp[n]\n\n\na, b, c = invr()\nmod = 1073741824\ndp = [0] * ((a*b*c)+1)\n\ntot = 0\n\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n tot += nod(i*j*k) % mod\nprint(tot)\n"}, {"source_code": "l = [1]*1000001\n\nfor i in range(2,1000001):\n for j in range(i, 1000000, i):\n l[j] += 1\n j += i\n\na, b, c = map(int, input().split())\n\nd = 0\nMOD = 1073741824 \n\nfor i in range(1, a+1):\n for j in range(1, b+1):\n for k in range(1, c+1):\n d = (d+l[i*j*k])%MOD\n \nprint(d)\n"}], "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401"} {"nl": {"description": "The king's birthday dinner was attended by $$$k$$$ guests. The dinner was quite a success: every person has eaten several dishes (though the number of dishes was the same for every person) and every dish was served alongside with a new set of kitchen utensils.All types of utensils in the kingdom are numbered from $$$1$$$ to $$$100$$$. It is known that every set of utensils is the same and consist of different types of utensils, although every particular type may appear in the set at most once. For example, a valid set of utensils can be composed of one fork, one spoon and one knife.After the dinner was over and the guests were dismissed, the king wondered what minimum possible number of utensils could be stolen. Unfortunately, the king has forgotten how many dishes have been served for every guest but he knows the list of all the utensils left after the dinner. Your task is to find the minimum possible number of stolen utensils.", "input_spec": "The first line contains two integer numbers $$$n$$$ and $$$k$$$ ($$$1 \\le n \\le 100, 1 \\le k \\le 100$$$) \u00a0\u2014 the number of kitchen utensils remaining after the dinner and the number of guests correspondingly. The next line contains $$$n$$$ integers $$$a_1, a_2, \\ldots, a_n$$$ ($$$1 \\le a_i \\le 100$$$) \u00a0\u2014 the types of the utensils remaining. Equal values stand for identical utensils while different values stand for different utensils.", "output_spec": "Output a single value \u2014 the minimum number of utensils that could be stolen by the guests.", "sample_inputs": ["5 2\n1 2 2 1 3", "10 3\n1 3 3 1 3 5 5 5 5 100"], "sample_outputs": ["1", "14"], "notes": "NoteIn the first example it is clear that at least one utensil of type $$$3$$$ has been stolen, since there are two guests and only one such utensil. But it is also possible that every person received only one dish and there were only six utensils in total, when every person got a set $$$(1, 2, 3)$$$ of utensils. Therefore, the answer is $$$1$$$.One can show that in the second example at least $$$2$$$ dishes should have been served for every guest, so the number of utensils should be at least $$$24$$$: every set contains $$$4$$$ utensils and every one of the $$$3$$$ guests gets two such sets. Therefore, at least $$$14$$$ objects have been stolen. Please note that utensils of some types (for example, of types $$$2$$$ and $$$4$$$ in this example) may be not present in the set served for dishes."}, "positive_code": [{"source_code": "spisok = [int(number) for number in input().split()]\nu, h = spisok[0], spisok[1]\no = [int(o) for o in input().split()]\n\nd = dict()\nfor c in o:\n d[c] = d.get(c, 0) + 1\nMAX = max(d.values())\ny = MAX // h\nif MAX % h != 0:\n y += 1\nprint(y * len(d) * h - u)\n"}, {"source_code": "n, k = map(int, raw_input().split())\nl = map(int, raw_input().split())\nuniqueList = list(set(l))\nuniqueCount = len(uniqueList)\ndishes = -1\nfor i in uniqueList:\n\tdishes = max(dishes, l.count(i))\nif dishes % k == 0:\n\tp = dishes / k\nelse:\n\tp = (dishes/k) + 1\nprint (k * p * uniqueCount) - n"}, {"source_code": "from math import ceil\nn,k=[int(s) for s in input().split()]\nmas = [int(s) for s in input().split()]\nsett = set(mas)\nans = 0\nhm = 0\nans1=0\nfor x in sett:\n s = mas.count(x)\n if s > ans:\n ans = s\n hm = x\n\nl = ceil(ans/k)\nnabor = k*l\nfor x in sett:\n s = mas.count(x)\n ans1+=nabor-s\nprint(ans1)"}, {"source_code": "import math\n\ndef min_utensil_token( num_utensil, guest, left_utensil): \n\tmax_num_utensil = 0\n\tutensil_dic = {}\n\tfor utensil in left_utensil:\n\t\tif utensil in utensil_dic:\n\t\t\tutensil_dic[utensil] += 1\n\t\t\tif utensil_dic[utensil] > max_num_utensil:\n\t\t\t\tmax_num_utensil = utensil_dic[utensil]\n\t\telse:\n\t\t\tutensil_dic[utensil] = 1\n\t\t\tif utensil_dic[utensil] > max_num_utensil:\n\t\t\t\tmax_num_utensil = utensil_dic[utensil]\n\t#print(math.ceil(max_num_utensil/float(guest)))\n\t#print(max_num_utensil)\n\t#Sprint(guest)\n\treturn math.ceil(max_num_utensil/float(guest)) *len(utensil_dic)*int(guest) - int(num_utensil) \n\nn,k = input().split()\nutensils = input().split()\nprint(min_utensil_token(n,k,utensils) )\n"}, {"source_code": "\n\nn,k = map(int,input().split())\n\n\nt = list(map(int,input().split()))\n\n\nu=[]\n\n\n\nfor j in set(t):\n u.append(t.count(j))\n\n\np=0\ns=max(u)//k\nif max(u)%k>0:\n s+=1\n\nfor j in u:\n p+=s*k-j\n\nprint(p)\n\n"}, {"source_code": "n,k=[int(i)for i in input().split()]\na=[int(i)for i in input().split()]\nb=[]\nbb=[]#\u043a\u043e\u043b-\u0432\u043e \u0432\u0438\u0434\u043e\u0432 \u043f\u0440\u0438\u0431\u043e\u0440\u043e\u0432\nfor i in range(1,101):\n\tb.append(a.count(i))\n\tif b[i-1]!=0:\n\t\tbb.append(i)\nqq=(((max(b)-1)//k)+1)\n\n\nflag=(k*len(bb)*qq)-n\n\nprint(flag)\n\n\n"}, {"source_code": "f_str = input()\ns_str = input()\narr_first = f_str.split()\nnum_of_apps = int(arr_first[0])\nnum_of_guests = int(arr_first[1])\narr_of_set = []\nblyd = 0\ncount_of_max = 0\nall_apps = s_str.split()\nfor elem in all_apps:\n if all_apps.count(elem) > count_of_max:\n count_of_max = all_apps.count(elem)\n if not elem in arr_of_set:\n arr_of_set.append(elem)\nif count_of_max % num_of_guests == 0:\n blyd = count_of_max // num_of_guests\nelse:\n blyd = (count_of_max) // num_of_guests + 1\npochty_res = blyd * num_of_guests * len(arr_of_set)\nres = pochty_res - num_of_apps\nprint(res)\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\nn , k = rint()\n\na = list(rint())\nadict = dict()\nfor i in range(n):\n if not a[i] in adict:\n adict[a[i]] =1\n else:\n adict[a[i]] += 1\n\nmax_a = max(adict.values())\ndish = max_a//k\nif max_a % k:\n dish += 1\nans = 0\nfor i in adict.keys():\n if adict[i] < dish*k:\n ans += dish*k - adict[i]\n\nprint(ans)\n"}, {"source_code": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nmn = 0\nb = [0]*101\nr = 0\nfor i in range(0,len(a)):\n if b[a[i]]==0:\n mn+=1\n b[a[i]]+=1\n \nfor i in range(0,101):\n r=max((b[i]+k-1)//k,r)\n\n\nif (k == 1):\n print(mn*(r)*k-n) \nelse:\n print(mn*(r)*k-n) \n\n"}, {"source_code": "\n\nn,k = map(int,input().split())\n\n\nt = list(map(int,input().split()))\n\n\nu=[]\n\n\n\nfor j in set(t):\n u.append(t.count(j))\n\n\np=0\ns=max(u)//k\nif max(u)%k>0:\n s+=1\n\nfor j in u:\n p+=s*k-j\n\nprint(p)\n\n"}, {"source_code": "from collections import Counter\n\nn, k = map(int, input().split())\n\na = list(map(int, input().split()))\n\n\n# n, k = 5, 2\n# a = [1, 2, 2, 1, 3]\n\n# n, k = 10, 3\n# a = [1, 3, 3, 1, 3, 5, 5, 5, 5, 100]\n\nkolpr = len(set(a))\n\ndi = Counter(a)\n\nmaxx = di.most_common()[0][-1]\nminn = di.most_common()[-1][-1]\n\nkolbl = (maxx + k - 1)//k\n\nans = 0\n\nallpr = kolbl*kolpr*k\n\nprint(allpr - len(a))"}, {"source_code": "n, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\n\nfood = 1\ns = dict()\nresult = 0\narr = []\n\nfor i in range(n):\n ans = 0\n if a[i] not in s:\n s[a[i]] = 1\n else:\n ans += s[a[i]] + 1\n s[a[i]] = ans\n\nfor key in s:\n if s[key] > k:\n arr.append(s[key])\n\nif len(arr) > 0:\n maxArr = max(arr)\n while maxArr > k:\n food += 1\n maxArr -= k\n for key in s:\n result += (k * food) - s[key]\nelse:\n for key in s:\n result += k - s[key]\n\nprint(result)"}, {"source_code": "import math\n\n\nn, k = list(map(int, input().split()))\nthings = list(map(int, input().split())) #\u043f\u0440\u0438\u0431\u043e\u0440\u044b\nset = []\namountOfEachThing = []\nfor i in things:\n if i not in set:\n set.append(i)\nfor j in range(len(set)):\n amountOfEachThing.append(things.count(set[j]))\namountOfPlates = math.ceil(max(amountOfEachThing) / k)\nmaxAmountOfThings = k * amountOfPlates * len(set)\nprint(maxAmountOfThings - n)\n"}, {"source_code": "N, K = map(int, input().split())\ncnt = [0]*101\ntot = 0\nmx = 0\nfor a in map(int, input().split()):\n cnt[a] += 1\n if cnt[a] == 1: tot += 1\n mx = max(mx, cnt[a])\nndish = (mx + K - 1) // K\nprint(ndish*K*tot - N)\n"}, {"source_code": "# coding=utf-8\n\nn, k = map(int, input().split())\n\na = [0 for i in range(101)]\n\nfor i in [int(i) for i in input().split()]:\n a[i] += 1\n\nmx = 0\ns = 0\nfor i in a:\n mx = max(mx, (i + k - 1) // k)\n if i: s += 1\n\nprint(mx * k * s - n)"}, {"source_code": "def error():\n print(\"Bad input.\");exit()\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ntest = {1:n not in range(1,101),\n 2:k not in range(1,101),\n 3:n != len(a),\n 4:any([i not in range(1,101) for i in a]),\n }\nif any(test.values()):\n error()\n\nkol = 1\nra = {key:a.count(key) for key in set(a)}\nif max(ra.values()) > k:\n if max(ra.values()) % k == 0:\n kol += max(ra.values()) // k -1\n else:\n kol += max(ra.values()) // k\n\nprint(kol*k*len(set(a)) - n)\n"}, {"source_code": "k, n = map(int, input().split())\n\nl = list(map(int, input().split()))\n\nn_of_kind = {}\n\nfor i in l:\n n_of_kind[i] = n_of_kind.get(i, 0) + 1\n\nmx_cnt = max(n_of_kind.values())\ndish_count = mx_cnt // n + int(mx_cnt%n != 0)\n\ntotal = dish_count*n*len(n_of_kind)\n\n\nprint(total - sum(n_of_kind.values()))\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nans = [0] * 100\nfor i in range(n):\n ans[a[i] - 1] += 1\nc = 0\nfor i in range(100):\n if ans[i] != 0:\n c += 1\nprint((max(ans) + k - 1) // k * c * k - n)"}, {"source_code": "import math\n\ndef KitchenUtensils():\n n,k = map(int,raw_input().split())\n rem_utensils = list(map(int,raw_input().split()))\n dist_utensils = {}\n for i in rem_utensils:\n if i not in dist_utensils.keys():\n dist_utensils[i] = 1\n else:\n dist_utensils[i] += 1\n max_utensils = max(dist_utensils.values())\n needed = k*math.ceil(float(max_utensils)/k)\n #print needed\n stolen = 0\n\n for i in dist_utensils:\n if dist_utensils[i] <= needed:\n stolen += needed - dist_utensils[i]\n \n print int(stolen)\n\nKitchenUtensils()\n"}, {"source_code": "first = [int(num) for num in input().split()]\nsec = input().split()\nsec_2 = set(sec)\nkol = []\nfor i in sec_2:\n kol.append(sec.count(i))\nif max(kol) > first[1]:\n mn = [(max(kol) // first[1]) + 1, (max(kol) // first[1])][(max(kol) % first[1]) == 0]\n print((len(sec_2)) * mn * first[1] - first[0])\nelse:\n print(first[1] * len(sec_2) - first[0])"}, {"source_code": "n,k = map(int, input().split(\" \"))\ntypes = list(map(int, input().split(\" \")))\ncount = [0] * 100\nfor c in types:\n\tcount[c-1] += 1\n\nmaximum = max(count)\nif maximum % k != 0:\n\tmaximum += k - (maximum % k)\nstolen = 0\nfor c in count:\n\tif c != 0:\n\t\tstolen += maximum - c\nprint(stolen)\n"}, {"source_code": "import sys\nfrom math import floor, ceil\n\ninput = sys.stdin.readline\n\nn, k = map(int, input().split())\n\na = list(map(int, input().split()))\n\ncount = [0 for i in range(101)]\nfor ut in a:\n count[ut] += 1\n\nmaxc = max(count)\nwhile maxc % k != 0:\n maxc += 1\n\nans = 0\nfor i in range(1, 101):\n if count[i] != 0:\n ans += maxc - count[i]\n\nprint(ans)"}, {"source_code": "n, k = list(map(int, input().split()))\n\nnumber = [0] * 101\narray = list(map(int, input().split()))\nfor i in range(n):\n number[array[i]] += 1\n\n\nq = max(number)\nif q % k != 0:\n q = (q - q % k) + k\nstolen = 0\n\nfor i in number:\n if i != 0:\n stolen += (q - i)\n\nprint(stolen)\n\n"}, {"source_code": "n, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nd = []\nfor i in xrange(101):\n\tif a.count(i) != 0:\n\t\td.append(a.count(i))\n\nx = max(d)\ny = (x/k)\nif x%k != 0: y+=1\nsets = y*k*len(d)\nprint sets - n"}, {"source_code": "n, k = input().split(\" \")\npos = input().split(' ')\ndishes = 0 #\u043a\u043e\u043b-\u0432\u043e \u0431\u043b\u044e\u0434 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u043e\u0441\u0442\u044f\ncount = 0 #\u043a\u043e\u043b-\u0432\u043e \u0441\u0442\u043e\u043b \u043f\u0440\u0438\u0431. \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u043e\u0441\u0442\u044f\ncount_h = 0\ncount_help = []\nn = int(n)\nk = int(k)\nfor x in pos:\n if x not in count_help:\n count_help += [x]\n count += 1\nfor y in count_help:\n if pos.count(y) > count_h:\n count_h = pos.count(y)\ndishes = (count_h + k - 1) // k\nprint(count * dishes * k - n)"}, {"source_code": "from collections import Counter\nfrom math import ceil\n\nn,d = input().split()\nn = int(n)\nd = int(d)\n\nx = list(map(int,input().split(' ')))\ntupes = len(set(x))\nmost_com = Counter(x).most_common()[0][1]\nprint(ceil(most_com/d)*d*tupes-n)\n\n"}, {"source_code": "import math,collections\nn,k = map(int,raw_input().strip('\\n').split(' '))\na = map(int,raw_input().strip('\\n').split(' '))\nprint int(k*len(list(set(a)))*math.ceil(max(collections.Counter(a).values())*1.0/k)-n)"}, {"source_code": "n, k = list(map(int, input().split()))\n\nnumber = [0] * 101\narray = list(map(int, input().split()))\nfor i in range(n):\n number[array[i]] += 1\n\n\nq = max(number)\nif q % k != 0:\n q = (q - q % k) + k\nstolen = 0\n\nfor i in number:\n if i != 0:\n stolen += (q - i)\n\nprint(stolen)\n\n"}, {"source_code": "#RAVENS\n#TEAM_2\n#ESSI-DAYI_MOHSEN-LORENZO\nfrom collections import Counter\nfrom math import ceil\nn,m = map(int,input().split())\narr=list(map(int,input().split()))\nyy=ceil((Counter(arr).most_common(1)[0][1])/m)*m\nc = Counter(arr)\nres = 0\nfor i in c.keys():\n\tres+=yy-c[i]\nprint(res)"}, {"source_code": "def r(x):\n if x > int(x):\n return x+1\n return x\n\nn, k = map(int, input().split())\n\nsum = 0\n\nco = [0 for _ in range(100)]\n\nl = list(map(int, input().split()))\n\nfor i in l:\n co[i-1] += 1\n\nm = max(co)\n\nif m <= k:\n for i in co:\n if i != 0:\n sum += k-i\nelse:\n k = k*((m//k) + (1 if m/k != m//k else 0))\n for i in co:\n if i != 0:\n sum += k-i\n\nprint(sum)\n"}, {"source_code": "import math\n\ndef f(a):\n m = {}\n r = 0\n for ch in a:\n if ch in m:\n m[ch] += 1\n else:\n m[ch] = 1\n u = len(m)\n for k, v in m.items():\n r = max(r, v)\n return r, u\n\n\nt = [int(x) for x in input().split()]\nn = t[0]\nk = t[1]\na = [int(x) for x in input().split()]\nr, u = f(a)\nminimum = math.ceil(r / k)\nsumm = minimum * u * k\nans = summ - len(a)\nprint(ans)\n"}, {"source_code": "import math\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nmas = [0]*100\ncount = 0\nfor i in a:\n if mas[i-1] == 0:\n count += 1\n mas[i - 1] += 1\nbluda = math.ceil(max(mas)/k)\nprint(count*k*bluda - n)"}, {"source_code": "n, k = map(int, input().split())\nxs = list(map(int, input().split()))\n\nys = [0] * 100\nfor x in xs:\n ys[x - 1] += 1\nm = 0\nres = 0\ncount = 0\nfor x in ys:\n if x != 0:\n if x > m:\n res += count*(x - m)\n count += 1\n m = x\n elif x == m:\n count += 1\n else:\n res += m - x\n count += 1\nif m % k != 0:\n res += (((m // k + 1) * k) - m)* count\nprint(res)\n\n"}, {"source_code": "from collections import Counter\nfrom math import ceil\nn,k = map(int, input().split())\na = list(map(int, input().split()))\nc = Counter(a).values()\nm = int(ceil(max(c)/k)*k)\nprint(m*len(c)-sum(c))"}, {"source_code": "from math import ceil\nn, m = [int(s) for s in input().split()]\na = [int(s) for s in input().split()]\n# c, d = np.unique(a), np.unique(a, return_counts=True)[1]\nc = []\ncnt = 0\nfor o in a:\n if o not in c:\n c.append(o)\nd = []\nfor i in c:\n\td.append(a.count(i))\ndishes, set = ceil(max(d) / m), len(c) #\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\neta = dishes * set * m\nprint(eta - n)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nb = set(a)\nm = 0\nfor i in a:\n m = max(m, a.count(i))\nm = (m + k - 1) // k * k\nprint(m * len(b) - len(a))"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nb = [0] * 101\nfor i in a:\n b[i] += 1\nc = [(i + k - 1) // k * k for i in b]\nmx = max(c)\nans = 0\nfor i in b:\n if i != 0:\n ans += abs(i - mx)\nprint(ans)"}, {"source_code": "n, k = [int(a) for a in input().strip().split()]\n\nutensils = [int(x) for x in input().strip().split()]\n\nc = {}\nfor i in utensils:\n if i in c:\n c[i] += 1\n else:\n c[i] = 1\n\ntypecounts = list(c.values())\n\nmax = max(typecounts)\nset = (-(-max // k))\n\ntotalutensils = len(typecounts) * set * k\n\nprint(totalutensils - n)\n"}, {"source_code": "from collections import *\nR=lambda:map(int, input().split())\nn,k=R()\narr=Counter(R())\nprint(-max(arr.values())//k*-k*len(arr)-n)\n"}, {"source_code": "n,k = map(int, raw_input().split())\narr = map(int, raw_input().split())\ndic = {}\nfor it in arr:\n\tif it in dic:\n\t\tdic[it] += 1\n\telse:\n\t\tdic[it] = 1\nmaxRem = 0\nfor item in dic:\n\tif dic[item] > maxRem:\n\t\tmaxRem = dic[item]\nrem = maxRem%k\nif rem == 0:\n\tideal = maxRem\nelse:\n\tideal = maxRem + (k - rem)\nlost = 0\nfor item in dic:\n\tlost += ideal - dic[item]\nprint lost"}, {"source_code": "import math\nn , k = map(int,input().split())\narr = list(map(int,input().split()))\nans = 0\nx = set(arr)\nt = len(x)\ncnt = 0\n\nfor i in x :\n if arr.count(i) > cnt :\n cnt = arr.count(i)\n\nres = math.ceil(cnt / k )\n\nres2 = res * k * t\nstolen = res2 - n\nprint(stolen)\n"}, {"source_code": "from math import ceil\nn, k = map(int, input().split())\nu = map(int, input().split())\nx = {}\nfor i in u:\n if i in x:\n x[i] += 1\n else:\n x[i] = 1\nm = -1\nfor i in x:\n m = max(m, x[i])\n\ntotal = int(ceil(m/k))*k\ns = 0\nfor i in x:\n s += total - x[i]\nprint(s)\n"}, {"source_code": "from collections import Counter\nn, k = map(int, input().split())\nc = Counter(map(int, input().split()))\nmost = c.most_common(1)[0][1]\nactual = most + (-most % k)\nans = 0\nfor f in c.values():\n\tans += (actual - f)\nprint(ans)\n"}, {"source_code": "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = [0] * 100\n\nfor i in range(n):\n b[a[i] - 1] += 1\n\nma = max(b)\nif ma % k != 0:\n min_my = (ma // k) * k + k\nelse:\n min_my = ma\n\nans = 0\n\nfor i in range(100):\n if b[i] != 0:\n ans += min_my - b[i]\n\nprint(ans)"}, {"source_code": "\nR=lambda: list(map(int,input().split()))\n \nn,k=R()\nut=R()\n\nsut=list(set(ut))\nma=0\nfor i in sut:\n ma=max(ut.count(i),ma)\n#print(ma)\nprint((1+int(ma/k))*k*len(sut)-n if ma%k else ma*len(sut)-n)\n\n \n \n \n\n \n \n\n\n"}, {"source_code": "import math\nguests=input().split()\nutensil=input().split()\nnotstolen=[]\nmax=0\nstolen=0\nwhile utensil!=[]:\n counter=0\n skp=0\n y=utensil[0]\n for i in range (len(utensil)):\n if utensil[0+skp]==y:\n counter+=1\n utensil.pop(0+skp)\n else:\n skp+=1\n notstolen.append(counter)\n if counter>max:\n max=counter\ntest1=(int(guests[1]))\ntest2=(math.ceil(max/(int(guests[1]))))\ntest=test1*test2\n#print(test1)\n#print(test2)\n#print(notstolen)\nfor i in notstolen:\n stolen+=int(test)-i\nprint(stolen)"}, {"source_code": "s = input().split()\ntree = {}\nn = int(s[0])\nk = int(s[1])\nma = -1\ns = input().split()\nfor i in range(n):\n if (tree.__contains__(s[i])):\n tree[s[i]] += 1\n else:\n tree[s[i]] = 1\nfor i in tree.keys():\n ma = max(ma, tree[i])\ndeesh = 0\nif (ma % k == 0):\n deesh = ma // k\nelse:\n deesh = ma // k + 1\nsum = k * len(tree.keys()) * deesh\nprint(sum - n)"}, {"source_code": "n, k = map(int, input().split())\narr = list(map(int, input().split()))\ncnt = [0] * 100\nfor i in range(n):\n cnt[arr[i] - 1] += 1\nans = 0\nb = 1\nfor i in range(100):\n b = max(b, (cnt[i] + k - 1) // k)\nfor i in range(100):\n if cnt[i] % (k * b):\n ans += k * b - cnt[i] % (k * b)\nprint(ans)"}, {"source_code": "n, k = [int(a) for a in input().strip().split()]\n\nutensils = [int(x) for x in input().strip().split()]\n\nc = {}\nfor i in utensils:\n if i in c:\n c[i] += 1\n else:\n c[i] = 1\n\ntypecounts = list(c.values())\n\nmax = max(typecounts)\nset = (-(-max // k))\n\ntotalutensils = len(typecounts) * set * k\n\nprint(totalutensils - n)\n"}, {"source_code": "from collections import Counter\nn, k = map(int, raw_input().split())\na = map(int, raw_input().split())\nc = Counter(a).values()\nnd = max(c) / k\nif max(c) - nd * k:\n nd += 1\nprint nd * k * len(c) - len(a)"}, {"source_code": "n, k = map(int, input().split())\narr = list(map(int, input().split()))\ncnt = dict()\nz = 0\nmx = 0\nfor el in arr:\n\tif el not in cnt:\n\t\tcnt[el] = 0\n\tcnt[el] += 1\nfor el in cnt:\n\tmx = max(mx, cnt[el])\nmx = (mx - 1) // k + 1\nprint(mx * len(cnt) * k - n)"}, {"source_code": "a = input().split()\nbb = input().split()\nfrom collections import Counter\ncounter = Counter(bb).most_common(1)[0]\ncount_tips_priborov=counter[1]\n\nvid = len(set(bb))\nbluda = 0 \nx=int(bluda*int(a[1]))\ny=int((count_tips_priborov // int(a[1]) + 1)) \nwhile bluda*int(a[1])=count_tips_priborov:\n ukrali=bluda*int(a[1])*vid-int(a[0])\n print(ukrali)\n break"}, {"source_code": "from math import ceil\ndef _mp():\n\treturn map(int,raw_input().split())\nn,k = _mp()\na=_mp()\nc={}\nfor i in a:\n\tif i not in c:\n\t\tc[i]=0\n\tc[i]+=1\nma=-1.0\nfor i in c:\n\tma=max(ma,c[i])\nma=ma*1.0\nct=len(c)\ntt=ct*k*int(ceil(ma/k))\nfor i in range(100):\n\tif tt-n>=0:\n\t\tprint tt-n\n\t\tbreak\n\telse:\n\t\ttt=tt+tt"}, {"source_code": "n, k = map(int, input().split())\narr = list(map(int, input().split()))\ncnt = dict()\nz = 0\nmx = 0\nfor el in arr:\n\tif el not in cnt:\n\t\tcnt[el] = 0\n\tcnt[el] += 1\nfor el in cnt:\n\tmx = max(mx, cnt[el])\nmx = (mx - 1) // k + 1\nprint(mx * len(cnt) * k - n)"}, {"source_code": "_list = list(map(int, input().split()))\nn, k = _list[0], _list[1]\n\na = list(map(int, input().split()))\n\nnumbers = {}\n\nfor elem in a:\n\n try:\n numbers[elem] += 1\n except KeyError:\n numbers[elem] = 1\n\n\nmaxim = max(numbers.values())\n\nif maxim == k:\n pass\n\n\nelif maxim > k:\n\n multiplier = 2\n\n while(maxim > k*multiplier):\n\n multiplier += 1\n \n\n maxim = k*multiplier\n\nelif maxim < k:\n\n maxim = k\n\n\nstolen = 0\nfor elem in numbers.values():\n stolen += maxim - elem\n\nprint(stolen)\n\n \n \n"}, {"source_code": "import math\nn, k = map(int,input().split())\na = list(map(int,input().split()))\nd = {}\np = sorted(list(set(a)))\ntemp = 0\nfor i in p:\n if a.count(i) > temp:\n temp = a.count(i)\nprint( len(p) * (k + (k * (math.ceil( (temp - k) / k) ) ) ) - len(a) )"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[28]:\n\n\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nN = a[0]\nk = a[1]\nb.sort()\nn = 1\nm = 0\np = 0\nr = 0\nfor i in range(len(b)):\n if b[i] == p:\n n += 1\n if b[i] != p:\n r += 1\n if n > m:\n m = n\n n = 1\n if i == len(b) - 1:\n if n > m:\n m = n\n p = b[i]\nif m % k == 0:\n j = m // k\nelse:\n j = m // k + 1\n# m - max \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u0431\u043e\u0440\u043e\u0432\n# r - \u043a\u043e\u043b-\u0432\u043e \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0440\u0438\u0431\u043e\u0440\u043e\u0432\n# j - \u043a\u043e\u043b-\u0432\u043e \u0431\u043b\u044e\u0434\nprint(k*j*r - N)\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "import math\nn,k=map(int,input().split())\n\nl=list(map(int,input().split()))\nz=set(l)\nm=0\nfor i in z:\n m=max(m,math.ceil(l.count(i)/k))\nprint(k*m*len(z)-n)\n"}, {"source_code": "n,k = map(int,input().split())\nai = list(map(int,input().split()))\nmaxn = [(ai.count(i) // k + int(ai.count(i) % k != 0)) for i in range(101)]\nans = [(max(maxn) * k - ai.count(i))*int(ai.count(i)>0) for i in range(101)]\nprint(sum(ans))\n"}, {"source_code": "import math\nn,k = [int(i) for i in input().split()]\nl = [int(i) for i in input().split()]\nd = dict()\nfor i in l:\n\tif i in d:\n\t\td[i]+=1\n\telse:\n\t\td[i]=1;\nll = []\nfor i in d:\n\tll.append(d[i])\n\nx= max(ll)\nfor i in range(math.ceil(x/k)*k):\n\tfor i in d:\n\t\td[i]-=1\ns=0\nfor i in d:\n\ts+=d[i]\n\n\nprint(-s)\n"}, {"source_code": "n,k=map(int,input().split())\npr=input().split()\ns=0\npr1=set(pr)\npr1=list(pr1)\nbl=None\nfor i in range(len(pr1)):\n if pr.count(pr1[i])>s:\n s=pr.count(pr1[i])\nif s>k:\n while s%k!=0:\n s+=1\n bl=s//k\nelif s<=k:\n bl=1\nprib=len(pr1)\nprint(bl*prib*k-n)\n"}, {"source_code": "# coding: utf-8\nimport math\n\nn, k = map(int, input().split()) # N utensils remaining and K guests\n\nutensils = list(map(int, input().split())) # list of utensils remaining\ncommon = set()\ntypes = 0\nmaior = 0\n\nfor x in utensils:\n common.add(x)\n\ntypes = len(common)\n\nquant = dict((el, 0) for el in common)\n\nfor v in utensils:\n quant[v] += 1\n\nfor o, p in quant.items():\n if p >= maior:\n maior = p\n\nminimum = math.ceil(maior / k)\n\nresult = (types * minimum * k) - n\n#print(k, types, minimum)\nprint(result)\n"}, {"source_code": "from math import ceil\nn , k = map(int,input().split())\na = [int(_) for _ in input().split()]\nb = set(a)\nw = 0\nfor i in b:\n w = max(a.count(i),w)\nprint((k*ceil(w/k)*len(b))-n)\n"}, {"source_code": "n,m = list(map(int,input().split()))\nl = list(map(int,input().split()))\nl.sort()\n\nd = {}\n\nfor i in range(1, 101):\n d[i] = 0\n\ns = 0\n\nfor i in range(n):\n d[l[i]] += 1\n s = s + 1\n\npr = 0\n\nfor i in d:\n if d[i] != 0:\n pr += 1\n\nsmax = 0\n\nfor i in d:\n if d[i] > smax:\n smax = d[i]\n\nif smax % m == 0:\n bl = smax // m\nelse:\n bl = smax // m + 1\n\nprint(max(bl*m*pr - s,0))\n"}, {"source_code": "import math\nfrom collections import Counter\n\nin1 = lambda: int(input())\ninm = lambda: map(int, input().split())\ninl = lambda: list(map(int, input().split()))\n\nn, k = inm()\narr = inl()\ncnt_arr = Counter(arr)\n\ndifferent_utensils = len(cnt_arr)\nbiggest_num = max(cnt_arr.values())\ndishes = math.ceil(biggest_num / k)\nall_utensils = dishes * k * different_utensils\n\n\nstolen = all_utensils - n\nprint(stolen)\n\n\n\n\n\n\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 \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\nfrom collections import Counter\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 main():\n n, k = map(int, input().split(' '))\n a = Counter(map(int, input().split(' ')))\n m = max(a.values())\n\n print((k * int(math.ceil(m / k))) * len(a) - sum(a.values()))\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 *\n\nn, k = map(int, input().split())\npribory = list(map(int, input().split()))\n_type = []\n_val = []\n\nfor i in pribory:\n if i in _type:\n _val[_type.index(i)] += 1\n else:\n _type.append(i)\n _val.append(1)\n\n\nnabor = 1\nfor i in range(len(_val)):\n if _val[i] > k and ceil(_val[i]/k) > nabor:\n nabor = ceil(_val[i]/k)\n_max = 0\n# print(_type)\n# print(_val)\n# print(nabor)\nfor i in _val:\n if i < k * nabor:\n _max += k*nabor - i\nprint(_max)\n"}, {"source_code": "import math\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nd = max([a.count(q) for q in a])\nf = len(set(a))\ng = math.ceil(d/k)\nprint(f*g*k-n)\n"}, {"source_code": "from collections import Counter\nn,k=map(int,input().strip().split())\narr=list(map(int,input().strip().split()))\ndct=Counter(arr)\n\nvalues = list(dct.values())\nkeys=list(dct.keys())\nmaxi=max(values)\nmaxis=0\nif maxi%k==0:\n maxis=maxi//k \nelse:\n maxis=(maxi//k)+1\n\ntotal=len(keys)*maxis*k \nprint(total-n)\n\n"}, {"source_code": "n, k = [int(x) for x in input().split()]\nT = [int(x) for x in input().split()]\nD = {}\nfor i in T:\n if i in D:\n D[i] += 1\n else:\n D[i] = 1\n\nS = list(D.values())\nL = []\nfor j in S:\n L.append(((j-1)//k)+1)\ntotal = 0\nfor i in L:\n total += i*k\n\nprint(max(L)*k*len(S)-n)"}, {"source_code": "n,k = map(int,input().split(\" \"))\narr = list(map(int,input().split(\" \")))\ns = set(arr)\nl = len(s)\nm = 0\nfor i in arr:\n\tcount = arr.count(i)\n\tif(count>m):\n\t\tm = count\ndishes = (m+k-1)//k\nprint(dishes*l*k-n)"}, {"source_code": "import math\nn, k = map(int, input().split())\nprb = []\nfor i in range(101):\n prb.append(0)\nprib = list(map(int,input().split()))\nfor i in range(len(prib)):\n prb[prib[i]] += 1\nres = 0\nblud = 1\nif max(prb) > k:\n blud = max(prb) / k\n blud = math.ceil(blud)\nfor i in range(len(prb)):\n if prb[i] == 0:\n continue\n else:\n res += blud * k - prb[i]\nprint(res)\n"}, {"source_code": "t = list(map(int, input().split(\" \")))\nn = t[0]\nk = t[1]\na = list(map(int, input().split(\" \")))\nt = set(a)\nt = list(t)\nm = 1\nfor i in range(len(t)):\n\tif a.count(t[i])>k:\n\t\ttemp = a.count(t[i])//k\n\t\tif temp*k!=a.count(t[i]):\n\t\t temp = temp + 1\n\t\tif temp>m:\n\t\t\tm = temp\nprint(m*k*len(t)-n)"}, {"source_code": "def r(x):\n if x > int(x):\n return x+1\n return x\n\nn, k = map(int, input().split())\n\nsum = 0\n\nco = [0 for _ in range(100)]\n\nl = list(map(int, input().split()))\n\nfor i in l:\n co[i-1] += 1\n\nm = max(co)\n\nif m <= k:\n for i in co:\n if i != 0:\n sum += k-i\nelse:\n k = k*((m//k) + (1 if m/k != m//k else 0))\n for i in co:\n if i != 0:\n sum += k-i\n\nprint(sum)\n"}, {"source_code": "import math\n\n[n, k] = list(map(int, input().rstrip().split()))\na = list(map(int, input().rstrip().split()))\n\ndic = {}\nfor el in a:\n try:\n dic[el] += 1\n except:\n dic[el] = 1\n\nma = max(dic.values())\npiatti = math.ceil(ma / k)\nkit = len(dic)\n\nprint(piatti * kit * k - n)"}, {"source_code": "import math\n\ninp = input().split()\nn = int(inp[0])\nk = int(inp[1])\nleft = input().split()\ntypes = {}\nmaxx = 0\nfor i in range(n):\n if i == 0:\n maxx = left[0]\n try:\n types[left[i]] += 1\n except Exception:\n types[left[i]] = 1\n if types[left[i]] >= types[str(maxx)]:\n maxx = left[i]\n\nneeded = 0\ndishes = 0\nif types[str(maxx)] % k == 0:\n dishes = types[str(maxx)] / k\nelse:\n dishes = math.ceil((types[str(maxx)] + 0.1)/k)\nfor a in types:\n if dishes*k > types[a]:\n needed += dishes*k - types[a]\nprint(int(needed))"}, {"source_code": "import sys\nimport math\n\nlines = []\nfor line in sys.stdin:\n\tlines.append(line.rstrip('\\n'))\n\nn,k = [int(x) for x in lines.pop(0).split(\" \")]\n\nremainingUtensils = [int(x) for x in lines.pop(0).split(\" \")]\n\nn = len(remainingUtensils)\n\nnumberOfRemainingUtensilsByUtensilType = {}\nfor remainingUtensil in remainingUtensils:\n if not remainingUtensil in numberOfRemainingUtensilsByUtensilType:\n numberOfRemainingUtensilsByUtensilType[remainingUtensil] = 0\n numberOfRemainingUtensilsByUtensilType[remainingUtensil] += 1\n\nmaximumNumberOfRemaningUtentils = max([value for key,value in numberOfRemainingUtensilsByUtensilType.items()])\n\nnumberOfDishes = math.ceil(maximumNumberOfRemaningUtentils / k)\n\nprint(numberOfDishes * k * len(set(remainingUtensils)) - n)"}, {"source_code": "\n#import sys\nimport math\nimport bisect\nimport collections\nimport itertools\n#from sys import stdin,stdout\nfrom math import gcd,floor,sqrt,log\nfrom collections import defaultdict as dd, Counter as ctr\nfrom bisect import bisect_left as bl, bisect_right as br\nfrom itertools import permutations as pr, combinations as cb\n\n#sys.setrecursionlimit(100000000)\n\n#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$\n\ninp = lambda: int(input())\nstrng = lambda: input().strip()\njn = lambda x,l: x.join(map(str,l))\nstrl = lambda: list(input().strip())\nmul = lambda: map(int,input().strip().split())\nmulf = lambda: map(float,input().strip().split())\nseq = lambda: list(map(int,input().strip().split()))\n\n#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$#$\n# p_inf = float('inf')\n# n_inf = float('-inf')\n#To find mex \n# def mex(arr):\n# nList = set(arr)\n# mex = 0\n# while mex in nList:\n# mex += 1\n# return(mex)\n\ndef results(arr, k):\n tmp = ctr(arr)\n q = max(tmp.values())\n p = q // k\n if(q % k):\n p += 1\n p = p * k * len(tmp)\n return p\n\ndef main():\n nk = seq()\n a = seq()\n n, k = nk[0], nk[1]\n print(results(a, k) - n)\nif __name__ == '__main__':\n main()"}, {"source_code": "import math\n\n\nn, k = list(map(int, input().split()))\nthings = list(map(int, input().split())) #\u043f\u0440\u0438\u0431\u043e\u0440\u044b\nset = []\namountOfEachThing = []\nfor i in things:\n if i not in set:\n set.append(i)\nfor j in range(len(set)):\n amountOfEachThing.append(things.count(set[j]))\namountOfPlates = math.ceil(max(amountOfEachThing) / k)\nmaxAmountOfThings = k * amountOfPlates * len(set)\nprint(maxAmountOfThings - n)\n"}, {"source_code": "n,k=map(int,input().split())\na=input().split()\nD={}\nfor i in a:\n if i in D:\n D[i]+=1\n else:\n D[i]=1\ngostu_max=max(D.values())\nif gostu_max%k==0:\n bluda=gostu_max//k\nelse:\n bluda=(gostu_max//k)+1\nb=bluda*k*len(D)\nprint(b-n)"}, {"source_code": "n,k=[int(x) for x in input().split()]\na=[int(x) for x in input().split()]\nmp={}\nfor i in a:\n mp[i]=a.count(i)\ndiff=len(list(mp.keys()))\nm=max(list(mp.values()))\n# print(diff,m)\nif m%k==0:\n m=m//k\nelse:\n m=m//k+1\n# print(m,diff)\nmissing=m*diff*k-n\n# print(f\"diff is {diff} max is {m} missing is {missing}\")\nprint(missing)"}, {"source_code": "def solution(n, k, cutlary):\n cset = set(cutlary)\n cutmax = dict()\n for c in cutlary:\n cutmax[c] = cutmax.get(c, 0) + 1\n plates = max(map(lambda x: (x // k) if x % k == 0 else ((x // k) + 1), cutmax.values()))\n return plates*len(cset)*k - n\n\n\nif __name__ == '__main__':\n n, k = tuple(map(int, input().split()))\n cutlary = list(map(int, input().split()))\n print(solution(n, k , cutlary))\n"}, {"source_code": "import math\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nb=set(a)\nkolb=0\nfor i in b:\n z=a.count(i)\n if z>kolb: kolb=z\nprint(math.ceil(kolb/k)*len(b)*k-n)\n"}, {"source_code": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nma=0\nfor i in set(a):\n ma=max(ma,a.count(i))\nr=-((-ma)//k)*k\nans=0\nfor i in set(a):\n ans+=(r-a.count(i))\nprint(ans)"}, {"source_code": "import math\n\n\nclass CodeforcesTask1032ASolution:\n def __init__(self):\n self.result = ''\n self.n_k = []\n self.utens = []\n\n def read_input(self):\n self.n_k = [int(x) for x in input().split(\" \")]\n self.utens = [int(x) for x in input().split(\" \")]\n\n def process_task(self):\n cnts = [self.utens.count(x) for x in list(set(self.utens))]\n all = len(set(self.utens)) * math.ceil(max(cnts) / self.n_k[1]) * self.n_k[1]\n missing = all - sum(cnts)\n self.result = str(missing)\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask1032ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "import math\nguests=input().split()\nutensil=input().split()\nnotstolen=[]\nmax=0\nstolen=0\nwhile utensil!=[]:\n counter=0\n skp=0\n y=utensil[0]\n for i in range (len(utensil)):\n if utensil[0+skp]==y:\n counter+=1\n utensil.pop(0+skp)\n else:\n skp+=1\n notstolen.append(counter)\n if counter>max:\n max=counter\ntest1=(int(guests[1]))\ntest2=(math.ceil(max/(int(guests[1]))))\ntest=test1*test2\n#print(test1)\n#print(test2)\n#print(notstolen)\nfor i in notstolen:\n stolen+=int(test)-i\nprint(stolen)"}, {"source_code": "n, k = [int(x) for x in input().split()]\nT = [int(x) for x in input().split()]\nD = {}\nfor i in T:\n if i in D:\n D[i] += 1\n else:\n D[i] = 1\n\nS = list(D.values())\nL = []\nfor j in S:\n L.append(((j-1)//k)+1)\ntotal = 0\nfor i in L:\n total += i*k\n\nprint(max(L)*k*len(S)-n)"}, {"source_code": "n,k = map(int, input().split())\nL = list(map(int, input().split()))\nf = [0]*101\nfor i in L:\n f[i] += 1\nma = 0\nfor i in f:\n ma = max(ma,(i+k-1)//k)\np = len(set(L))\nprint((ma*p*k)-n)"}, {"source_code": "num = [0] * 105\nn,k = map(int,input().split())\na = list(map(int,input().split()))\nmx = 0\nfor i in range(n):\n num[a[i]]+=1\n mx = max(mx,a[i])\ncnt = 0\nfor i in range(1,mx+1):\n if num[i] != 0:\n cnt = max(cnt,num[i])\nif cnt % k != 0:\n cnt = (cnt // k + 1) * k\nans = 0\nfor i in range(1,mx+1):\n if num[i] != 0:\n ans += cnt - num[i]\nprint(ans)"}, {"source_code": "n, k = [int(i) for i in input().split()]\ndata = {}\nfor i in input().split():\n if i in data:\n data[i] += 1\n else:\n data[i] = 1\n\nmax_num = 0\nfor i in data:\n if data[i] > max_num:\n max_num = data[i]\nall_dishes = 0\nif max_num % k == 0:\n all_dishes = max_num // k\nelse:\n all_dishes = max_num // k + 1\ndishes = 0\nfor i in data:\n dishes += data[i]\nprint(all_dishes * k * len(data) - dishes)\n"}, {"source_code": "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\n\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\n \n\ndef main():\n n, k = get_tuple()\n li = get_list()\n count = Counter(li)\n l = math.ceil(max(count.values())/k)\n print(l*k*len(count.keys())-len(li))\n\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": "def error():\n print(\"Bad input.\");exit()\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ntest = {1:n not in range(1,101),\n 2:k not in range(1,101),\n 3:n != len(a),\n 4:any([i not in range(1,101) for i in a]),\n }\nif any(test.values()):\n error()\n\nkol = 1\nra = {key:a.count(key) for key in set(a)}\nif max(ra.values()) > k:\n if max(ra.values()) % k == 0:\n kol += max(ra.values()) // k -1\n else:\n kol += max(ra.values()) // k\n\nprint(kol*k*len(set(a)) - n)\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\nn , k = rint()\n\na = list(rint())\nadict = dict()\nfor i in range(n):\n if not a[i] in adict:\n adict[a[i]] =1\n else:\n adict[a[i]] += 1\n\nmax_a = max(adict.values())\ndish = max_a//k\nif max_a % k:\n dish += 1\nans = 0\nfor i in adict.keys():\n if adict[i] < dish*k:\n ans += dish*k - adict[i]\n\nprint(ans)\n"}, {"source_code": "import math\n\ndef KitchenUtensils():\n n,k = map(int,raw_input().split())\n rem_utensils = list(map(int,raw_input().split()))\n dist_utensils = {}\n for i in rem_utensils:\n if i not in dist_utensils.keys():\n dist_utensils[i] = 1\n else:\n dist_utensils[i] += 1\n max_utensils = max(dist_utensils.values())\n needed = k*math.ceil(float(max_utensils)/k)\n #print needed\n stolen = 0\n\n for i in dist_utensils:\n if dist_utensils[i] <= needed:\n stolen += needed - dist_utensils[i]\n \n print int(stolen)\n\nKitchenUtensils()\n"}, {"source_code": "utensils=[]\nindex,sum,N=0,0,2\nn,k=input().split()\nn=int(n)\nk=int(k)\nutensils=input().split()\nutensils=[int(i) for i in utensils]\nutensils.sort()\nwhile index < len(utensils):\n num=utensils.count(utensils[index])\n index=utensils.count(utensils[index])+index\n sum=k-num+sum\n if (k-num)<0:\n k=k*N/(N-1)\n N=N+1\n index=0\n sum=0\n continue\n sum=int(sum)\nprint(sum)"}, {"source_code": "from collections import Counter\nimport math\nn, k = input().strip().split(' ')\nn, k= [int(n), int(k)]\n\na = list(map(int, input().split()))\nmost_common,num_most_common = Counter(a).most_common(1)[0]\ndishes = math.ceil(num_most_common/k)\nprint((len(set(a))*k*dishes)-n)\n\n"}, {"source_code": "n,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nfrom collections import Counter\ncounter=Counter(A)\nL=len(counter)\nU=-(-max(counter.values())//K)\n\nprint(L*U*K-n)\n"}, {"source_code": "import gzip, base64\n\nexec(gzip.decompress(base64.b64decode(\n b'H4sIAK2/8VsC/0VWx7KrShLc36+Y3X0viHkYYRezQI'\n b'BwEk7'\n b'4Hd57z9fPmYiBq1VTndWUqisz+fUr2ZPor+ws+n/iJOqafkym6'\n b'a8wmBIc/SfE0f8F4+SvX//6+YW/BXQSaRkB'\n b'SXtiQBh2dkIev893/MAB7+FCayHUv/8P'\n b'Ra8FJ86JJzochXjClmVVKz83l6IeYt7h3pz'\n b'TF641d99yvskpH+t4BR+nIhCgvCYj6GtNGYC9pnU4CDXmR04k'\n b'7ZsLIE1oJEzF4JWS9gTkHCHP4'\n b'3NGqi4hkHSaGBn2ugB3'\n b'hTwljy5L+jHVnDwFX/GyxY/uepibSMnXbnacz/nk/KJq6Q'\n b'zHnaUvF'\n b'VCj8kplxw/MLc9yooRRv7J8uOgDwwa'\n b'sBJXF16kSJVxhcKLRL/dZbO6'\n b'kNi3oXGCjQb+q'\n b'sEQM54qEWrdjDEn6/GknOz5fHE69W7'\n b'+tj80cvuPJ3V2tQy4AucEft'\n b'yw5'\n b'bPag9jeRyK23KZoFFLUPIr'\n b'x011'\n b'P6WukTsWxQcg9jL+AbsNcWG6jyV/Rr5oWeis1V4'\n b'WiFLxXDOtpilXZUbJxoAd28qxVx3oIAHiJoGguvIMY6y'\n b'I'\n b'4osZi6EhvKdoTVVoisaTBoAcM5xSq5'\n b'WZw1wbyk/uBJ+n3ppxSR1'\n b'9plxSMk+IUz7VP/GJkzOPqrpJ7EXGTCjQqlkooA8Hy901i4gv'\n b'VSDwtyPTm8MQvbXrMrJj'\n b'iJ9z2VJMtnuDeImOJ8'\n b'VvN/NpwezD9YiTgdf'\n b'6XF1Ju1YwDI6umeBTAnF8VZT8jZuXKDPSajNgU6iDP'\n b'aqA'\n b'hrIkN72vYFtlj70IXnZ0Cer6LT6GJ6fWcc'\n b'ifh'\n b'HsK4lUKf3eLBZ3vCMJ7/NK8Q3ncICWac5yYNgR'\n b'EsrHUGiDa1oGalWSAUFxF4'\n b'3bPK+t/Nx/3s8sUI5TncV6Phjk6Qrbr'\n b'Lc2Oqf98430ksu41ysu77TlrYU35'\n b'66uF/14eyQ37pbD/hbfBOxCl67ug'\n b'FHuxvxOAOI2RKZjPGE1tnUO/wGVqrO'\n b'nwtdVedHVzNOMuRhJM/uz2Rt'\n b'NhXrrUQ9XlsT8TOqOaeQDzk3FXhaAMfGe9'\n b'4CeyQVdPnrlg242DKIBAA8Wfog6p4do6sQ6Htt+ESHXR4RN'\n b'hcXmguJ+4p6cgCutbYIfaWDiRkOxruBjx'\n b'5SIbwTYOJ9F4WMi2kU6NsVmrBiaoLs8rHmDug8mFJuOHzC'\n b'iEY'\n b'jxW24b+Za0Ls+l+W7fBp2hPP7FZ4guY8fun0cJ6gqVa'\n b'ADB/zeVIIPQ72ox6pLGlqFLrR6iLn'\n b'ySN9qH9tJ5N'\n b'kP2Bakj5JYXotsBQm4C84gbMute6p+rySofW1pwfgHNNr'\n b'+uX2NysYGwXNxBW4SPUUx38Rf0c1ohlYaJIdb4'\n b'Sx4XJhD4qj4faWFMDCp'\n b'Yn6v97G6utgbIos/MmaM9kZyzxOHCLtylI'\n b'ioBDuuHmarySaH8t/8Pv5phrL6nm8hIski9gYda'\n b'T5aiER'\n b'iaXbYCe0'\n b'Aw7sXRN'\n b'6CQGd7zwKd4I2cEMKpSHZtkvG5JnezB8uOsT2clCDwtsVl'\n b'5z3ncbGROktTWkSJXBUJFc02AuJuDkuGbGL0K1uRIiXo'\n b'Rz04r1C0v6MS+1EymMsJ/DiLURq0ElE3N4Sue6326lX'\n b'21wTgx0RVRb48jNdGWrf3iIAmDP1'\n b'tZNK3'\n b'Pk8s+GFuwwUOHmOZlw/cDj7vSSCogYNGeAu'\n b'IrlY6'\n b'QI+lZz/9t'\n b'F3tSO0jtdV'\n b'2ISNrcom8YhvXczSr3aWze'\n b'PQabbMvq4T6SngSUNBlqmchKfecpj/WBvNZJDQM'\n b'8sLcTTluTU6'\n b'OgOKNGH56zz6o1LOS177ZyZtVS'\n b'FwBX8v8PKFvSLetOKLFOrEfvj9E9KRreCEeH8at'\n b't73SQ8yKoNv+AAj4FCBXY4E0uh/zBEpDrAy1g3D3j2FaNAy'\n b'CP+4Ml28Ap/J8nxQR9xwgejJDMvKb1gLZnMI'\n b'nt'\n b'D3/JLEMLzu7LlveTwo0koOvM4x7y4qT1GquP5X+1j'\n b'tihNX00NpC40g8fTOhsZrP44Ua2jl/lINtRst1o'\n b'XHW2NZn7oF6mOihhs13mNX8PrtTDjGAiVuPo0a'\n b'+jbWBguBmCLFq8dcle'\n b'cN7aahHLieEX1'\n b'sHtjfIj/0yy76sJ2mQTZrXlTgZ6Dn'\n b'N/t1Aj'\n b'egh2V8Gz81DPAH3/EN8B90eAkoW1ojVuMhub'\n b''\n b'z5GD1fzh'\n b'/J+O9IVKPhw3wF3001yKn1MOVEFVnuSDiwR0ip9T'\n b'z/WZHC5pNuL9GUAdnZLRgMrHz9u'\n b'k0DknE27ddWaTztgw+E3yl4KqTXTC5DrqS/U2'\n b'Sz++QSa8jFEUtM3HseCPtlD'\n b'yJW'\n b'mbxnIHJle7lUzqobqUZrF3Q6XLCWGfsMmnewO'\n b'RhnzAW6+EayPsOxOet82N7WVnpe1BDUU5SYVobV9olOmRKiWeh'\n b'jLtmzh/p4eVM'\n b'1AnVjK5z0ANnd+p'\n b'Wx5'\n b'Z/c7RWKCbLR4AMgySlbc66i9vs8yHKZcDPyToNCiPX5EbI4'\n b'kiDivrDF8mA7nhg7kaxgi86i+nEtmoATLqcutKr76OX8IMkTFE'\n b'5Z0M5grJ/1xcQIH0xUESJK6yyKM+bO75Pog'\n b'KDAFIaWeJXabIYmm6f/8/vX33//8/xP69zKn/y'\n b'Z///33r/8Ckm5WyHULAAA='\n)).decode('utf-8'))\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\n@author: zzf\n@file: main.py\n@time: 2018/11/13\n\"\"\"\nimport math\nfrom collections import defaultdict\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nm = defaultdict(int)\n\nfor i in range(n):\n m[a[i]] += 1\n\nmx = 0\nfor key in m:\n if mx < m[key]:\n mx = m[key]\nif mx % k == 0:\n t = mx // k\nelse:\n t = mx // k + 1\n\nres = t*k*len(m) - n\nprint(res)\n"}, {"source_code": "import math\n\nn, k = (int(x) for x in input().split())\na = [int(x) for x in input().split()]\na.sort()\nc = []\nfor i in range(1,101):\n c.append(a.count(i))\n\nbl = math.ceil(max(c)/k)\nans = 0\nfor i in c:\n if i != 0:\n ans += bl * k - i\nprint(ans)"}], "negative_code": [{"source_code": "ligne = input().split(' ')\nn = int(ligne[0])\nk = int(ligne[1])\nligne = input().split(' ')\nmat={}\nmax = 0\nfor i in range(n):\n\tmat[ligne[i]] = 0\nfor i in range(n):\n\tmat[ligne[i]] += 1\n\tif mat[ligne[i]]>max:\n\t\tmax = mat[ligne[i]]\nprint (mat)\nalls = max/k\nif alls-int(alls) > 0:\n\talls = int(alls) + 1\nprint ((alls*k*len(mat))-n)"}, {"source_code": "n,k = map(int,input().split())\ns = list(map(int,input().split()))\nm = 1\nfor i in range(1,n):\n if s.count(i-1)>s.count(i):\n m = s.count(i-1)\nr = set(s)\nlr = len(r)\nif m % k==0:\n we = m//k\nelse:\n we = m//k+1\nqer = we*k*lr\nprint(abs(qer-n))\n "}, {"source_code": "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprib = set(lst) \nmaxcount = k \nb = 1\nfor elem in prib:\n num = lst.count(elem) \n if num > maxcount: \n maxcount += k \n b += 1\n print(b * len(prib) * k - n)\n"}, {"source_code": "from collections import Counter\n\nI = lambda: map(int, input().split())\n\nn, k = I()\n\nprint(sum(k*x if x%k else x for x in Counter(I()).values()) - n)"}, {"source_code": "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprib = set(lst)\nmaxcount = 0\nb = 1\nfor elem in prib:\n num = lst.count(elem)\n if num > maxcount:\n maxcount += k\nb = maxcount // k\nprint(b * len(prib) * k - n)\n"}, {"source_code": "n,m = list(map(int,input().split()))\nl = list(map(int,input().split()))\nl.sort()\n\nd = {}\n\nfor i in range(1, 101):\n d[i] = 0\n\ns = 0\nfor i in range(n):\n d[l[i]] += 1\n s = s + 1\n\npr = 0\n\nfor i in d:\n if d[i] != 0:\n pr += 1\n\nsmax = 0\n\nfor i in d:\n if d[i] > smax:\n smax = i\n\nif smax % m == 0:\n bl = smax // m\nelse:\n bl = smax // m + 1\n\nprint(bl*m*pr - s)\n"}, {"source_code": "from collections import Counter\nfrom math import ceil\n\nn, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nc = Counter(arr)\n\nmx = 0\nfor i in range(len(arr)):\n if (c[i] > mx):\n mx = c[i]\n\na = ceil(mx/k)\n\nt = a*k\n\nsum = 0\nfor i in c:\n if(c[i] < t and c[i] != 0):\n sum+=(t-c[i])\nprint(sum)"}, {"source_code": "n, k = list(map(int, input().split()))\nsets = list(map(int, input().split()))\ndish = sorted(set(sets))\nd = dict()\nc_d = 0\nans = 0\nfor i in dish:\n d[sets.count(i)] = i\nc_d = max(d)\nif c_d % k != 0:\n c_d = (c_d // k + 1) * k\nfor i in d:\n ans += c_d - i\nprint(ans)\n"}, {"source_code": "from collections import Counter\nfrom math import ceil\n\nn,d = input().split()\nn = int(n)\nd = int(d)\nx = list(map(int,input().split(' ')))\nmost_com = Counter(x).most_common()[0][1]\nprint(abs(ceil(most_com/d)*d*most_com-n))\n\n"}, {"source_code": "n, k = map(int,input().split())\nit = 0\ns = input().split()\nd = dict()\nfor i in range(n):\n if int(s[i]) in d :\n d[int(s[i])] += 1\n else :\n d[int(s[i])] = 1\nfor i in d.keys() :\n if d[i] % k != 0 :\n it += k - d[i] % k\nprint(it)"}, {"source_code": "import math\n\nd = dict()\nn, k = map(int, input().split())\n\nmass = list(map(int, input().split()))\n\nfor i in mass:\n if str(i) in d:\n d[str(i)] += 1\n else:\n d[str(i)] = 1\n \nprint(abs(n - (math.ceil(max(list(d.values())) / k) * k * max(list(d.values())))))\n"}, {"source_code": "n, m = map(int, input().split())\na = [int(i) for i in input().split()]\ns = set(a)\nt = len(s) // 2\na1 = []\nc = 0\nif m == 1:\n print(0)\nelse:\n for i in a:\n if a.count(i) == m * t and i not in a1:\n a1.append(i)\n elif i not in a1 and t != 0:\n c += m * t - a.count(i) \n a1.append(i)\n elif i not in a1 and t == 0:\n c += n % m\n a1.append(i)\n print(c)"}, {"source_code": "from collections import defaultdict as dd\nd=dd(lambda:0)\nn,k=map(int,input().split())\nl=list(map(int,input().split()))\nfor i in l:\n\td[i]+=1\ns=len(set(l))\na=max(d.values())\nif a>k:\n\tprint((s*(2*k))-n)\n\nelse:\n\tprint(s*k-n)"}, {"source_code": "from collections import defaultdict as dd\nd=dd(lambda:0)\nn,k=map(int,input().split())\nl=list(map(int,input().split()))\nfor i in l:\n\td[i]+=1\ns=len(set(l))\na=max(d.values())\nif a>k:\n\tprint((s*(2*k))-n)\n\nelse:\n\tprint(s*k-n)"}, {"source_code": "n, m = map(int, input().split())\na = [int(i) for i in input().split()]\ns = set(a)\nt = len(s) // 2\na1 = []\nc = 0\nfor i in a:\n if a.count(i) == m * t and i not in a1:\n a1.append(i)\n elif i not in a1 and t != 0:\n c += m * t - a.count(i) \n a1.append(i)\n elif i not in a1 and t == 0:\n c += n % m\n a1.append(i)\nprint(c)"}, {"source_code": "n, k = map(int, input().split())\n\nsum = 0\n\nco = [0 for _ in range(100)]\n\nl = list(map(int, input().split()))\n\nfor i in l:\n co[i-1] += 1\n\nfor i in co:\n if i != 0:\n sum += k-i\n\nprint(sum)\n"}, {"source_code": "n,k = list(map(int, input().split()))\nut = list(map(int, input().split()))\ndict = {}\nmaximo = 0\nroubos = 0\n\nfor i in range(n):\n if ut[i] in dict:\n dict[ut[i]] += 1\n maximo = max(dict[ut[i]],maximo)\n else:\n dict[ut[i]] = 1\n\nwhile maximo%k:\n maximo+=1\n\nprint(len(dict)*maximo-n)\n"}, {"source_code": "import math\ndef most_common(lst):\n res = dict((lst.count(i), i) for i in set(lst))\n return res[max(res.keys())]\na = []\na1 = []\n\nn,k=map(int,input().split())\ns = str(input()).split()\nfor i in range(len(s)):\n a.append(int(s[i]))\nc=len(set(a))\na1=[str(i) for i in a]\nx=most_common(a1)\nnx=a1.count(x)\nz= math.ceil(nx/k)\nprint(abs(z*nx*k-n))"}, {"source_code": "n,k=map(int,input().split())\na=[int(j) for j in input().split()]\na.sort()\ns=0\nj=[]\nmaxi=a.count(a[0])\nfor i in range(len(a)):\n if a.count(a[i])>maxi:\n maxi=a.count(a[i])\nu=maxi/k\nif u!=int(u):\n u=int(u)+1\nfor i in range(len(a)):\n if j.count(a[i])==0:\n s+=u*k-a.count(a[i])\n j.append(a[i])\nprint(s)\n \n "}, {"source_code": "guest, number = map(int, input().split())\na = list(map(int, input().split()))\nb = set(a)\nc = {i:a.count(i) for i in b}\nm = 1\nfor i in c.values():\n if i > number:\n k = i // number + 1\n else:\n k = 1\n if k > m:\n m = k\nprint(len(b) * m * number - len(a))\n\n\n"}, {"source_code": "n,k =map(int, input().split())\nx = [int(i) for i in input().split()]\ncourses = 0\narr = []\n\nfor i in range (0,100):\n arr.append(0)\n\nfor i in range(0,n):\n arr[x[i]-1]=arr[x[i]-1]+1\n\nsets =0\nnumber_of_courses = 1\nfor i in range(0,100):\n if arr[i]>0:\n sets = sets+1\n if arr[i]>k:\n if number_of_courses 0 and mas1[i] < min1:\n min1 = mas1[i]\nmas = set(mas)\nz = len(mas)\nmin1 = k-min1\nprint ((z*k*min1)-n)"}, {"source_code": "import math\nguests=input().split()\nutensil=input().split()\nnotstolen=[]\nmax=0\nstolen=0\nwhile utensil!=[]:\n counter=0\n skp=0\n y=utensil[0]\n for i in range (len(utensil)):\n if utensil[0+skp]==y:\n counter+=1\n utensil.pop(0+skp)\n else:\n skp+=1\n notstolen.append(counter)\n if counter>max:\n max=counter\ntest1=(int(guests[1]))\ntest2=(math.ceil(max/(int(guests[1]))))\ntest=test1*test2\nprint(test1)\nprint(test2)\nprint(notstolen)\nfor i in notstolen:\n stolen+=int(test)-i\nprint(stolen)"}, {"source_code": "ligne = input().split(' ')\nn = int(ligne[0])\nk = int(ligne[1])\nligne = input().split(' ')\nmat={}\nmax = 0\nfor i in range(n):\n\tmat[ligne[i]] = 0\nfor i in range(n):\n\tmat[ligne[i]] += 1\n\tif mat[ligne[i]]>max:\n\t\tmax = mat[ligne[i]]\nprint (mat)\nalls = max/k\nif alls-int(alls) > 0:\n\talls = int(alls) + 1\nprint ((alls*k*len(mat))-n)"}, {"source_code": "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nprint(n//len(set(a))*k*len(set(a))-n)"}, {"source_code": "a,b = map(int, input().split())\nc = []\nsett = 0\nc = input()\nc = c.split(\" \")\nfor n in range(1,101):\n for i in c:\n if n == int(i):\n sett += 1\n break\nmaxrep = 1\nfor n in range(1,101):\n rep = 0\n for i in c:\n if n == int(i):\n rep += 1\n if rep > b:\n maxrep +=1\ndish = maxrep * b * sett\npribor = len(c)\nr = dish - pribor\nprint(r)\n"}, {"source_code": "n, m = map(int, input().split())\na = [int(i) for i in input().split()]\ns = set(a)\nt = len(s) // 2\na1 = []\nc = 0\nif m == 1:\n print(0)\nelse:\n for i in a:\n if a.count(i) == m * t and i not in a1:\n a1.append(i)\n elif i not in a1 and t != 0:\n c += m * t - a.count(i) \n a1.append(i)\n elif i not in a1 and t == 0:\n c += n % m\n a1.append(i)\n print(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 \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\nfrom 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 \"\"\"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 main():\n n, k = map(int, input().split())\n a = Counter(map(int, input().split()))\n\n print((k * math.ceil(a.most_common(1)[0][1] / k) * len(a)) - sum(a.values()))\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": "n,k=map(int,input().split())\na=[int(x) for x in input().split()]\n\nd=set(a)\ndishes=n//len(d)\ntotal=k*len(d)*dishes\nstolen=total-n\nprint(stolen)\t"}, {"source_code": "n, k = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\nassert n == len(a)\nb = {}\nfor i in range(n):\n if a[i] not in b:\n b[a[i]] = a.count(a[i])\nd = max(b.values()) // k + 1\ns = d * len(b) * k - n\nprint(s)\n"}, {"source_code": "n,k=map(int,input().split())\na=[int(x) for x in input().split()]\n\nd=set(a)\nif(len(d)==1):\n\tdishes=n//k\nelse:\t\n\tdishes=n//len(d)\ntotal=k*len(d)*dishes\nstolen=total-n\nprint(stolen)\t"}, {"source_code": "n,k=map(int,input().split())\na=[int(j) for j in input().split()]\na.sort()\ns=0\nj=[]\nmaxi=a.count(a[0])\nfor i in range(len(a)):\n if a.count(a[i])>maxi:\n maxi=a.count(a[i])\nu=maxi/k\nif u!=int(u):\n u=int(u)+1\nfor i in range(len(a)):\n if j.count(a[i])==0:\n s+=u*k-a.count(a[i])\n j.append(a[i])\nprint(s)\n \n "}, {"source_code": "a,b=map(int,input().split())\nk=list(map(int,input().split()))\nd=[0]*100\nfor i in k:\n d[i-1]+=1\nx=max(d)\ns=0\nfor i in d:\n if i!=0:\n s+=x-i\nn=set()\ny=0\nfor i in k:\n if i not in n:\n n.add(i)\n y+=1\nwhile (a+s)%b!=0:\n s+=y\nprint (s)"}, {"source_code": "n,k = list(map(int, input().split()))\nut = list(map(int, input().split()))\ndict = {}\nmaximo = 0\nroubos = 0\n\nfor i in range(n):\n if ut[i] in dict:\n dict[ut[i]] += 1\n maximo = max(dict[ut[i]],maximo)\n else:\n dict[ut[i]] = 1\n\nwhile maximo%k:\n maximo+=1\n\nprint(len(dict)*maximo-n)\n"}, {"source_code": "n,k = map(int, input().split())\narr = list(map(int, input().split()))\n\nhashmap = {}\n\nmaxCount = 0\nfor item in arr:\n if item in hashmap:\n hashmap[item] += 1\n maxCount = max(maxCount, hashmap[item])\n else:\n hashmap[item] = 1\n\nost = maxCount % k\nfoodCount = int(maxCount / k)\nif ost != 0:\n foodCount += 1\n\nres = 0\nfor item in hashmap:\n res += k*foodCount - hashmap[item]\n\n# print(hashmap)\nprint(res)"}, {"source_code": "n, k = map(int, input().split())\na = [int(e) for e in input().split()]\nq = dict()\nmx = len(set(a))\nres = 0\nm = 1\nfor i in a:\n q[i] = q.get(i, 0) + 1\nfor i in a:\n if q[i] > k:\n m = q[i] / k\n if int(m) < m:\n m = int(m) + 1\nmx = m * mx * k\nprint(mx - n)\n"}, {"source_code": "n, k = input().split(' ')\npos = input().split(' ')\ncount = 0\nmaxim = 1\ncount1 = 0\nu = []\nfor i in pos:\n if pos.count(i) > count:\n count = pos.count(i)\n if count > int(k):\n maxim = (count + int(k) - 1) // int(k)\ncount = count * maxim * int(k)\nprint(count - int(n))\n\n \n"}, {"source_code": "def king():\n ns = [0] * 111\n inp = input().split()\n left = int(inp[0])\n guests = int(inp[1])\n lst = list(map(int, input().split()))\n for i in lst:\n ns[i] += 1\n # print(ns)\n m = max(ns)\n if m != guests:\n need = m + (guests - (m % guests))\n else: need = m\n res = 0\n for i in ns:\n if i != 0:\n res += (need - i)\n return res\n\nprint(king())"}, {"source_code": "n, k = input().split(' ')\npos = input().split(' ')\ncount = 0\nmaxim = 1\ncount1 = 0\nu = []\nfor i in pos:\n if pos.count(i) > count:\n count = pos.count(i)\n if count > int(k):\n maxim = (count + int(k) - 1) // int(k)\ncount = count * maxim * int(k)\nprint(count - int(n))\n\n \n"}, {"source_code": "k,n=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\nb=[]\nb.append(a.count(a[0]))\nfor i in range(1,k):\n if a[i]!=a[i-1]:\n b.append(a.count(a[i]))\nb.sort()\nnn=round((b[-1]+0.5)/n)\nprint(nn*n*len(b)-sum(b))\n"}, {"source_code": "n,d=[int(s) for s in input().split()]\na=[int(s) for s in input().split()]\nb=[]\nk=0\nc=[]\nfor i in range(max(a)):\n\tb.append(0)\nfor i in range(n):\n\tb[a[i]-1]+=1\nfor i in range(len(b)):\n\tif b[i]>0:\n\t\tc.append(b[i])\nk=len(c)*d*(d-min(c))\nans=k-sum(c)\nprint(ans)\n"}, {"source_code": "a = [int(s) for s in input().split()]\nn, k = a[0], a[1]\nthings = [int(s) for s in input().split()]\na = {}\nfor thing in things:\n if thing not in a:\n a[thing] = 1\n else:\n a[thing] += 1\n\nmax_a = max(a.values())\ncompl = (max_a + max_a // k * k) // k * k\nprint(compl * len(a) - n)"}, {"source_code": "from collections import Counter\nfrom math import ceil\n\nn, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nc = Counter(arr)\n\nmx = 0\nfor i in range(len(arr)):\n if (c[i] > mx):\n mx = c[i]\n\na = ceil(mx/k)\nt = a*k\n\ns = set(arr)\nsum = 0\nfor i in s:\n if(c[i] < t):\n sum+=(t-c[i])\n\nprint(sum)"}, {"source_code": "n,k = [int(i) for i in input().split()]\nmas = [int(i) for i in input().split()]\nmin1 = 999999\nmas = set(mas)\nz = len(mas)\nmin1 = int(n//z)\nprint ((z*k*min1)-n)"}, {"source_code": "n,k = map(int, input().split())\nx = list(map(int, input().split()))\nans = [0 for i in range(1,101)]\n\nfor i in x :\n\tans[i]=+1\n\nm,mk=ans[0],0\nfor i in range(1,100):\n\tif m first[1]:\n if len(sec_2) < first[1]:\n mn = (max(kol) // first[1])\n print(first[1] * mn * first[1] - first[0])\n else:\n mn = (max(kol) // first[1]) + 1\n print((len(sec_2)) * mn * first[1] - first[0])\nelse:\n print(first[1] * len(sec_2) - first[0])"}, {"source_code": "n,k = map(int, input().split())\narr = list(map(int, input().split()))\n\nhashmap = {}\n\nmaxCount = 0\nfor item in arr:\n if item in hashmap:\n hashmap[item] += 1\n maxCount = max(maxCount, hashmap[item])\n else:\n hashmap[item] = 1\n\nost = maxCount % k\nfoodCount = max(int(maxCount / k), 1)\nif ost != 0:\n foodCount += 1\n\nres = foodCount * k * len(hashmap) - n\n# for item in hashmap:\n# res += k*foodCount - hashmap[item]\n\n\n# print(hashmap)\nprint(res)"}, {"source_code": "def king():\n ns = [0] * 111\n inp = input().split()\n left = int(inp[0])\n guests = int(inp[1])\n lst = list(map(int, input().split()))\n for i in lst:\n ns[i] += 1\n print(ns)\n m = max(ns)\n if m % guests != 0:\n need = m + (guests - (m % guests))\n else: need = m\n res = 0\n for i in ns:\n if i != 0:\n res += (need - i)\n return res\n\nprint(king())"}, {"source_code": "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprib = set(lst)\nmaxcount = k\nans = 0\nfor elem in prib:\n num = lst.count(elem) \n if num > maxcount: \n maxcount += k\nfor elem in prib:\n num = lst.count(elem)\n ans += maxcount - num\nprint(ans)\n"}, {"source_code": "guest, number = map(int, input().split())\na = list(map(int, input().split()))\nb = set(a)\nc = {i:a.count(i) for i in b}\nm = 1\nfor i in c.values():\n if i > number:\n k = i // number + 1\n else:\n k = number\n if k > m:\n m = k\nprint(len(b) * m * number - len(a))\n\n\n"}, {"source_code": "import math\nguests=input().split()\nutensil=input().split()\nnotstolen=[]\nmax=0\nstolen=0\nwhile utensil!=[]:\n counter=0\n skp=0\n y=utensil[0]\n for i in range (len(utensil)):\n if utensil[0+skp]==y:\n counter+=1\n utensil.pop(0+skp)\n else:\n skp+=1\n notstolen.append(counter)\n if counter>max:\n max=counter\ntest1=(int(guests[1]))\ntest2=(math.ceil(max/(int(guests[1]))))\ntest=test1*test2\nprint(test1)\nprint(test2)\nprint(notstolen)\nfor i in notstolen:\n stolen+=int(test)-i\nprint(stolen)"}, {"source_code": "import math\n'''\nline1 = input()\nline2 = input()\n'''\n\n'''\nline1 = \"5 2\"\nline2 = \"1 2 2 1 3\"\n'''\n\n\nline1 = \"10 3\"\nline2 = \"1 3 3 1 3 5 5 5 5 100\"\n\nlist1 = line1.split()\nlist2 = line2.split()\nprint(list1)\nprint(list2)\n\nremaining = int(list1[0])\nguests = int(list1[1])\n\nprint(str(remaining) + '\\n' + str(guests))\n\ncountUtensils = {}\nmx = 0\ntypes = 0\n\nfor utensil in list2:\n if countUtensils.get(utensil, 0) == 0:\n types += 1\n countUtensils[utensil] = countUtensils.get(utensil, 0) + 1\n if countUtensils[utensil] > mx:\n mx = countUtensils[utensil]\n\ndishes = math.ceil(mx / guests)\ntotal = dishes * guests * types\nprint(total)\nprint(remaining)\nprint(total - remaining)\n\n\n\n"}, {"source_code": "n,k = [int(i) for i in input().split()]\nmas = [int(i) for i in input().split()]\nmin1 = 999999\nmas = set(mas)\nz = len(mas)\nmin1 = int(n/z)\nprint ((z*k*min1)-n)"}, {"source_code": "data = input().split(' ')\nn = int(data[0])\nk = int(data[1])\n\nline = input().split(' ')\n\nform = []\ncount = []\nall = 1\n\nfor foo in range(len(line)):\n if line[foo] not in form:\n form.append(line[foo])\n count.append(1)\n else:\n ind = form.index(line[foo])\n count[ind] += 1\n\nmax = 0\n\nfor bar in range(len(count)):\n if count[bar] > max:\n max = count[bar]\nall = max // k + 1\n\ns = n * k * all - n\n\nprint(s)\n"}, {"source_code": "from collections import defaultdict\ndef gcd(a,b):\n if b==0: return a\n else: return gcd(b,a%b)\ndef LCM(a,b):\n return a*b/gcd(a,b)\n\nn,k = tuple(map(int, input().split()))\narr = list(map(int,input().split()))\ncount = defaultdict(int)\nfor a in arr:\n count[a]+=1\nmx = max(count.values())\ntotal = mx * len(count)\nlcm = LCM(mx,k)\ni = 1\nwhile lcm*i < total:\n i+=1\nlcm = lcm*i\nprint(int(lcm-n))"}, {"source_code": "l = list(map(int, input().split()))\nn = l[0]\nk = l[1]\ncultery = list(map(int, input().split()))\ncultery.sort()\nm = 0\ns = 1\ntypes = 0\n\nfor i in range(len(cultery)):\n if cultery[i] == cultery[i-1]:\n s += 1\n else:\n if s > m: m = s\n s = 1\n types += 1\n\nfor_one = (m - 1) // k + 1\ns = 0\nst = for_one * types * k - n\n\nprint(st)\n"}, {"source_code": "from collections import Counter\nfrom math import ceil\n\nn, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nc = Counter(arr)\n\nmx = 0\nfor i in range(len(arr)):\n if (c[i] > mx):\n mx = c[i]\n\na = ceil(mx/k)\nt = a*k\n\ns = set(arr)\nsum = 0\nfor i in s:\n if(c[i] < t):\n sum+=(t-c[i])\n\nprint(sum)"}, {"source_code": "n, k = map(int, input().split())\na = [int(e) for e in input().split()]\nq = dict()\nmx = len(set(a))\nres = 0\nm = 1\nfor i in a:\n q[i] = q.get(i, 0) + 1\nfor i in a:\n if q[i] > k:\n m = q[i] / k\n if int(m) < m:\n m = int(m) + 1\nmx = m * mx * k\nprint(mx - n)\n"}, {"source_code": "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprib = set(lst)\nmaxcount = k\nans = 0\nfor elem in prib:\n num = lst.count(elem) \n if num > maxcount: \n maxcount += k\nfor elem in prib:\n num = lst.count(elem)\n ans += maxcount - num\nprint(ans)\n"}, {"source_code": "a = input().split()\nbb = input().split()\nfrom collections import Counter\ncounter = Counter(bb).most_common(1)[0]\ncount_tips_priborov=counter[1]\n\nvid = len(set(bb))\nbluda = 0 \nx=int(bluda*int(a[1]))\ny=int((count_tips_priborov // int(a[1]) + 1)) \nwhile bluda*int(a[1])=count_tips_priborov:\n ukrali=bluda*int(a[1])*vid-int(a[0])\n print(ukrali)\n break\n print(bluda)"}, {"source_code": "n,k=map(int,input().split())\na=input().split()\nD={}\nfor i in a:\n if i in D:\n D[i]+=1\n else:\n D[i]=1\ngostu_max=max(D.values())\nif k%gostu_max==0:\n bluda=gostu_max//k\nelse:\n bluda=(gostu_max//k)+1\nb=bluda*k*len(D)\nprint(b-n)"}, {"source_code": "[n,k] = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\nb = [0 for i in range(0,101)]\nfor i in range(0,n):\n b[a[i]] += 1\nnum = 0\nmaxi = 0\nm = 0\n#print(a)\n#print(b)\nfor j in range(0,101):\n if b[j] != 0 and b[j] == k:\n maxi = max(maxi,1)\n m += 1\n if b[j] != 0 and b[j] != k:\n maxi = max(maxi,b[j]//k+1)\n m += 1\n#print(m)\n#print(maxi)\nnum = maxi*k*m\nprint(num-n)"}, {"source_code": "n, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\n\nfood = 1\ns = dict()\nresult = 0\n\nfor i in range(n):\n ans = 0\n if a[i] not in s:\n s[a[i]] = 1\n else:\n ans += s[a[i]] + 1\n s[a[i]] = ans\n\narr = []\n\nfor key in s:\n if s[key] > k:\n arr.append(s[key])\n\nif len(arr) > 0:\n maxArr = max(arr)\n while maxArr > k:\n food += 1\n maxArr -= k\n for key in s:\n result += (k * food) - s[key]\nelse:\n for key in s:\n arr.append(s[key])\n maxArr = max(arr)\n for i in range(len(arr)):\n result += maxArr - arr[i]\n\nprint(result)"}, {"source_code": "from collections import Counter\nfrom math import ceil\n\nn, k = [int(i) for i in input().split()]\narr = [int(i) for i in input().split()]\n\nc = Counter(arr)\n\nmx = 0\nfor i in range(len(arr)):\n if (c[i] > mx):\n mx = c[i]\n\na = ceil(mx/k)\n\nt = a*k\n\nsum = 0\nfor i in c:\n if(c[i] < t and c[i] != 0):\n sum+=(t-c[i])\nprint(sum)"}, {"source_code": "n,k = map(int, input().split())\narr = list(map(int, input().split()))\n\nhashmap = {}\n\nmaxCount = 0\nfor item in arr:\n if item in hashmap:\n hashmap[item] += 1\n maxCount = max(maxCount, hashmap[item])\n else:\n hashmap[item] = 1\n\nost = maxCount % k\nfoodCount = max(int(maxCount / k), 1)\nif ost != 0:\n foodCount += 1\n\nres = 0\nfor item in hashmap:\n res += k*foodCount - hashmap[item]\n\n\nprint(res)"}, {"source_code": "n,k = list(map(int, input().split(' ')))\nmass = list(map(int, input().split(' ')))\n\ntemp = set([i for i in range(1,101)])\n\nunique = set(mass)&temp\n\ncount = [mass.count(i) for i in unique]\nmaxx = max(count)\nblud = 1\nif maxx>k:\n blud = maxx//k+1\n\nprib = len(unique)\n\nprint(k*blud*prib-n)\n\n"}, {"source_code": "l = list(map(int, input().split()))\nn = l[0]\nk = l[1]\ncultery = list(map(int, input().split()))\ncultery.sort()\nm = 1\ns = 1\ntypes = 1\n\nfor i in range(1, len(cultery)):\n if cultery[i] == cultery[i-1]:\n s += 1\n else:\n if s > m: m = s\n s = 1\n types += 1\n\nfor_one = (m - 1) // k + 1\ns = 0\nst = for_one * types * k - n\n\nprint(st)\n"}, {"source_code": "guest, number = map(int, input().split())\na = list(map(int, input().split()))\nb = set(a)\nc = {i:a.count(i) for i in b}\nm = 1\nfor i in c.values():\n if i > number:\n k = i // number + 1\n else:\n k = number\n if k > m:\n m = k\nprint(len(b) * m * number - len(a))\n\n\n"}, {"source_code": "n,k=map(int,input().split())\nli=list(map(int,input().split()))\nm=0\nfor i in list(set(li)):\n if li.count(i)>m:\n m=li.count(i)\ndishes=0\nif m%k==0:\n dishes=m\nelse:\n s=(n+k-1)//k\n dishes=k*s\nprint((dishes*len((set(li))))-n)\n"}, {"source_code": "n,k = map(int, input().split())\narr = list(map(int, input().split()))\n\nhashmap = {}\n\nmaxCount = 0\nfor item in arr:\n if item in hashmap:\n hashmap[item] += 1\n maxCount = max(maxCount, hashmap[item])\n else:\n hashmap[item] = 1\n\npriborInFood = len(hashmap)\npriborPodacha = priborInFood * k\nres = 0\nallPribor = priborPodacha\ni = 0\nwhile maxCount > 0:\n i = i + 1\n maxCount = maxCount - k\n\nres = priborPodacha * i - n\n\n# ost = maxCount % k\n# foodCount = max(int(maxCount / k), 1)\n# if ost != 0:\n# foodCount += 1\n#\n# res = foodCount * k * len(hashmap) - n\n# for item in hashmap:\n# res += k*foodCount - hashmap[item]\n\n\n# print(hashmap)\nprint(res)"}, {"source_code": "def find(arr,n,k):\n d = {}\n m = 0\n for a in arr:\n if a in d:\n d[a]+=1\n else:\n d[a]=1 \n if m < d[a]:\n m = d[a]\n s = len(d)\n m = m%k + 1\n if s == 1 and m == 1:\n return 0\n if m > 0:\n return s*m*k-len(arr) \n return s*k-len(arr) \n\n\ndef main():\n n,k = map(int,input().split())\n arr = list(map(int,input().split()))\n print(find(arr,n,k))\n\nif __name__==\"__main__\":\n main() \n"}, {"source_code": "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprib = set(lst)\nmaxcount = 0\nb = 1\nfor elem in prib:\n num = lst.count(elem)\n if num > maxcount:\n maxcount += k\nb = maxcount // k\nprint(b * len(prib) * k - n)\n"}, {"source_code": "n, k = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\nassert n == len(a)\nb = {}\nfor i in range(n):\n if a[i] not in b:\n b[a[i]] = a.count(a[i])\nd = max(b.values()) // k + 1\ns = d * len(b) * k - n\nprint(s)\n"}, {"source_code": "def king():\n ns = [0] * 111\n inp = input().split()\n left = int(inp[0])\n guests = int(inp[1])\n lst = list(map(int, input().split()))\n for i in lst:\n ns[i] += 1\n print(ns)\n m = max(ns)\n if m % guests != 0:\n need = m + (guests - (m % guests))\n else: need = m\n res = 0\n for i in ns:\n if i != 0:\n res += (need - i)\n return res\n\nprint(king())"}, {"source_code": "from collections import Counter\nimport math\nutensils, m = map(int, input().split(\" \"))\ndata = list(map(int, input().split(\" \")))\ndishes = 0\ncount = Counter(data)\n\n#print(count.get(1))\n\nfor x in count:\n if(count[x] >= m):\n if(math.ceil(count[x]/m) > dishes):\n dishes = math.ceil(count[x]/m)\n\nprint((dishes * len(set(data)) * m) - utensils)\n"}, {"source_code": "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nprib = set(lst)\nans = 0\nmaxcount = 0\nfor elem in prib:\n num = lst.count(elem)\n if num > maxcount:\n maxcount += k\nfor elem in prib:\n num = lst.count(elem)\n ans += maxcount - num\nprint(ans)\n"}, {"source_code": "n, k = map(int, input().split())\nunique_numbers = set()\ncountList = [0] * 101\ninput_list = list(map(int, input().split()))\nfor i in range(n):\n inValue = input_list[i]\n unique_numbers.add(inValue)\n countList[inValue] += 1\nmax_count = max(countList)\nnew_list = countList[:]\ncoefficient = 1\nfor i in range(len(new_list)):\n if (not new_list[i] % k == 0) and new_list[i] > k:\n t = new_list[i] // k\n new_list = [j * (t + 1) for j in new_list]\n coefficient += t\n\nstolen = 0\nfor i in range(len(new_list)):\n stolen += new_list[i] - countList[i]\n\nfor i in range(len(new_list)):\n if not new_list[i] % k == 0:\n t = new_list[i] // k\n stolen += k * (t + 1) - new_list[i]\n\nprint(stolen)"}, {"source_code": "n, k = input().split(' ')\npos = input().split(' ')\ncount = 0\nmaxim = 1\ncount1 = 0\nu = []\nfor i in pos:\n if pos.count(i) > count:\n count = pos.count(i)\n if count > int(k):\n maxim = (count + int(k) - 1) // int(k)\ncount = count * maxim * int(k)\nprint(count - int(n))\n\n \n"}, {"source_code": "utensils=[]\nindex,sum,N=0,0,2\nn,k=input().split()\nn=int(n)\nk=int(k)\nutensils=input().split()\nutensils=[int(i) for i in utensils]\nutensils.sort()\nwhile index < len(utensils):\n num=utensils.count(utensils[index])\n sum=k-num+sum\n if (k-num)<0:\n k=k*N\n N=N+1\n index=0\n sum=0\n continue\n index=utensils.count(utensils[index])+index\nprint(sum)\n"}, {"source_code": "i=input()\narr=[int(x) for x in i.split()]\nn,k=arr[0],arr[1]\nj=input()\narr1=[int(x) for x in i.split()]\nfor i in arr1:\n print(i)"}, {"source_code": "def find(arr,n,k):\n d = {}\n m = 0\n for a in arr:\n if a in d:\n d[a]+=1\n else:\n d[a]=1 \n if m < d[a]:\n m = d[a]\n s = len(d)\n m = m%k + 1\n if s == 1 and m == 1:\n return 0\n if m > 0:\n return s*m*k-len(arr) \n return s*k-len(arr) \n\n\ndef main():\n n,k = map(int,input().split())\n arr = list(map(int,input().split()))\n print(find(arr,n,k))\n\nif __name__==\"__main__\":\n main() \n"}, {"source_code": "n, k = map(int,input().split())\na = list(map(int,input().split()))\nnabor = list(set(a))\nkol = {}\nmaxi = 0\nfor i in a:\n if i in kol:\n kol[i] += 1\n if kol[i] > maxi:\n maxi = kol[i]\n else:\n kol[i] = 1\nif (maxi % k == 0):\n ito = maxi\nelse:\n ito = (maxi // k + 1) * k\nprint(ito * len(nabor) - n)"}, {"source_code": "from collections import Counter\nn,k=map(int,input().strip().split())\narr=list(map(int,input().strip().split()))\ndct=Counter(arr)\n\nvalues = list(dct.values())\nkeys=list(dct.keys())\nmaxi=max(values)//2\ntotal=len(keys)*maxi*k \nprint(total-n)\n\n"}, {"source_code": "n,k =map(int, input().split())\nx = [int(i) for i in input().split()]\ncourses = 0\narr = []\n\nfor i in range (0,100):\n arr.append(0)\n\nfor i in range(0,n):\n arr[x[i]-1]=arr[x[i]-1]+1\n\nsets =0\nnumber_of_courses = 1\nfor i in range(0,100):\n if arr[i]>0:\n sets = sets+1\n if arr[i]>k:\n if number_of_courses smax:\n smax = i\n\nif smax % m == 0:\n bl = smax // m\nelse:\n bl = smax // m + 1\n\nprint(max(bl*m*pr - s,0))\n"}, {"source_code": "a = input().split()\nbb = input().split()\nfrom collections import Counter\ncounter = Counter(bb).most_common(1)[0]\ncount_tips_priborov=counter[1]\n\nvid = len(set(bb))\nbluda = 0 \nx=int(bluda*int(a[1]))\ny=int((count_tips_priborov // int(a[1]) + 1)) \nwhile bluda*int(a[1])=count_tips_priborov:\n ukrali=bluda*int(a[1])*vid-int(a[0])\n print(ukrali)\n break\n print(bluda)"}, {"source_code": "k,n=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\nb=[]\nb.append(a.count(a[0]))\nfor i in range(1,k):\n if a[i]!=a[i-1]:\n b.append(a.count(a[i]))\nb.sort()\nnn=round((b[-1]+0.5)/n)\nprint(nn*n*len(b)-sum(b))\n"}, {"source_code": "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nprint(n//len(set(a))*k*len(set(a))-n)"}, {"source_code": "n,k = list(map(int, input().split()))\nut = list(map(int, input().split()))\nlist = [0]*101\nmaximo = 0\ndif = 0\n\nfor i in range(n):\n if list[ut[i]] == 0:\n list[ut[i]] = 1\n dif += 1\n else:\n list[ut[i]]+=1\n maximo = max(list[ut[i]],maximo)\n\nwhile maximo%k:\n maximo+=1\n\nprint(dif*maximo-n)"}, {"source_code": "ligne = input().split(' ')\nn = int(ligne[0])\nk = int(ligne[1])\nligne = input().split(' ')\nmat={}\nmax = 0\nfor i in range(n):\n\tmat[ligne[i]] = 0\nfor i in range(n):\n\tmat[ligne[i]] += 1\n\tif mat[ligne[i]]>max:\n\t\tmax = mat[ligne[i]]\nprint (mat)\nalls = max/k\nif alls-int(alls) > 0:\n\talls = int(alls) + 1\nprint ((alls*k*len(mat))-n)"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\nd = dict()\nfor i in a:\n if i not in d.keys():\n d[i] = 1\n else:\n d[i] += 1\nt = max(d.values())\nxxx = []\nfor i in range(1, t // 2 + 1):\n if t % i == 0:\n xxx.append(i)\n if t // i != t:\n xxx.append(t // i)\nt = max(xxx)\nx = 0\nfor i in d.values():\n x += t - i\nprint(len(d.keys()) * k * t - n)"}, {"source_code": "def error():\n print(\"Bad input.\");exit()\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ntest = {1:n not in range(1,101),\n 2:k not in range(1,101),\n 3:n != len(a),\n 4:any([i not in range(1,101) for i in a]),\n }\nif any(test.values()):\n error()\n\nkol = 1\nra = {key:a.count(key) for key in set(a)}\nif max(ra.values()) > k:\n kol += max(ra.values()) // k\n\nprint(kol*k*len(set(a)) - 10)\n"}, {"source_code": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncnt_of = [0] * 100\nnot_zeroes = []\ncnt_diff = 0\nfor v in a:\n\tv -= 1\n\tcnt_of[v] += 1\n\tif cnt_of[v] == 1:\n\t\tcnt_diff += 1\nfor v in range(100):\n\tif cnt_of[v] > 0:\n\t\tnot_zeroes.append(cnt_of[v])\nat_least = max(k - min(not_zeroes), 1)\n\nmust_be = at_least * k * cnt_diff\nprint(max(must_be - n, 0))"}, {"source_code": "n,k = map(int, input().split())\narr = list(map(int, input().split()))\n\nhashmap = {}\n\nmaxCount = 0\nfor item in arr:\n if item in hashmap:\n hashmap[item] += 1\n maxCount = max(maxCount, hashmap[item])\n else:\n hashmap[item] = 1\n\nost = maxCount % k\nfoodCount = int(maxCount / k)\nif ost != 0:\n foodCount += 1\n\nres = 0\nfor item in hashmap:\n res += k*foodCount - hashmap[item]\n\n# print(hashmap)\nprint(res)"}, {"source_code": "import math\n\nline1 = input()\nline2 = input()\nline2 = \"1 3 3 1 3 5 5 5 5 100\"\n\nlist1 = line1.split()\nlist2 = line2.split()\nremaining = int(list1[0])\nguests = int(list1[1])\n\n\ncountUtensils = {}\nmx = 0\ntypes = 0\n\nfor utensil in list2:\n if countUtensils.get(utensil, 0) == 0:\n types += 1\n countUtensils[utensil] = countUtensils.get(utensil, 0) + 1\n if countUtensils[utensil] > mx:\n mx = countUtensils[utensil]\n\ndishes = math.ceil(mx / guests)\ntotal = dishes * guests * types\nprint(total - remaining)\n\n\n\n"}, {"source_code": "import math\nn, k = map(int, input().split())\na = input().split()\nitems = set(a)\ncount = 0\nansw = 0\nfor item in items:\n if a.count(item) > count:\n count = a.count(item)\nmax = math.ceil(count/k)*k\nprint(max)\nfor item in items:\n answ += max-a.count(item)\n\nprint(answ)"}], "src_uid": "c03ff0bc6a8c4ce5372194e8ea18527f"} {"nl": {"description": "Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.More formally, you are given an array s1,\u2009s2,\u2009...,\u2009sn of zeros and ones. Zero corresponds to an unsuccessful game, one \u2014 to a successful one. Games are given in order they were produced, and Hideo can't swap these values. He should remove some elements from this array in such a way that no zero comes right after one.Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.", "input_spec": "The first line contains one integer number n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). The second line contains n space-separated integer numbers s1,\u2009s2,\u2009...,\u2009sn (0\u2009\u2264\u2009si\u2009\u2264\u20091). 0 corresponds to an unsuccessful game, 1 \u2014 to a successful one.", "output_spec": "Print one integer \u2014 the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.", "sample_inputs": ["4\n1 1 0 1", "6\n0 1 0 0 1 0", "1\n0"], "sample_outputs": ["3", "4", "1"], "notes": null}, "positive_code": [{"source_code": "def main():\n\tn = int(input())\n\tgames = list(map(int, input().split(' ')))\n\t\n\tresult = max([games[:i].count(0) + games[i:].count(1) for i in range(n+1)])\n\t\t\t\t\t\t\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "n=input()\na=list(map(int,raw_input().split()))\ndp=[[[0,0] for j in range(102)] for i in range(103)]\nif a[0]==0:\n dp[0][1][0]=1\n dp[0][0][0]=0\nelse:\n dp[0][1][1]=1\n dp[0][0][0]=0\nfor i in range(1,n):\n if a[i]==1:\n dp[i][1][1]=max(dp[i-1][0][1],dp[i-1][0][0],dp[i-1][1][0],dp[i-1][1][1])+1\n dp[i][0][0]=max(dp[i-1][0][0],dp[i-1][1][0])\n dp[i][0][1]=max(dp[i-1][0][1],dp[i-1][1][1])\n else:\n dp[i][1][0]=max(dp[i-1][0][0],dp[i-1][1][0])+1\n dp[i][0][1]=max(dp[i-1][0][1],dp[i-1][1][1])\n dp[i][0][0]=max(dp[i-1][0][0],dp[i-1][1][0])\nprint max(dp[n-1][1][0],dp[n-1][1][1],dp[n-1][0][1],dp[n-1][0][0])\n\n \n \n\n \n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\nr = 0\nfor i in range(len(a) + 1):\n\tx = a[:i].count(0)\n\ty = a[i:].count(1)\n\tr = max(r, x + y)\nprint(r)\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nr=0\nfor i in range(n+1):\n x=a[:i].count(0)\n y=a[i:].count(1)\n r=max(r,x+y)\nprint(r)"}, {"source_code": "n = int(input())\nm=list(map(int,input().split()))\nx=m.count(0)\ny=n-x\na=0\nb=0\nl=max(x,y)\nfor i in range(n):\n if m[i]==1:\n a+=1\n c=[]\n d=0\n e=0\n for j in range(i+1):\n if m[j]==1:\n d+=1\n else:\n e+=1\n c.append(e+a-d)\n l=max(l,max(c)+y-a)\n\n \n \n else:\n b+=1\nprint(l)\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 main():\n n = int(input())\n s = [int(i) for i in input().split()]\n\n zero_count = [0] * (n + 1)\n one_count = [0] * (n + 1)\n\n for i in range(n):\n zero_count[i + 1] = zero_count[i] + (s[i] == 0)\n one_count[i + 1] = one_count[i] + (s[i] == 1)\n\n sol = zero_count[-1]\n\n for i, j in enumerate(s):\n if j == 1:\n ones = one_count[-1] - one_count[i]\n zeros = zero_count[i + 1]\n\n sol = max(sol, ones + zeros)\n\n print(sol)\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": "n = int(input())\ngames = list(map(int, input().split()))\nafter = [0] * n\nif games[-1] == 1:\n after[-1] = 1\nelse:\n after[-1] = 0\nfor i in range(n - 2, -1, -1):\n if games[i] == 1:\n after[i] = after[i + 1] + 1\n else:\n after[i] = after[i + 1]\ncurnull = 0\nans = 0\nfor i in range(n):\n if games[i] == 0:\n curnull += 1\n ans = max(ans, curnull + after[i])\nprint(ans)"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\na = 0\nfor i in range(n+1):\n x = s[:i].count(0)\n y = s[i:].count(1)\n a = max(a, x+y)\nprint(a)"}, {"source_code": "\n\ndef solve(s):\n '''\n >>> solve([1, 1, 0, 1])\n 3\n >>> solve([0, 1, 0, 0, 1, 0])\n 4\n >>> solve([0])\n 1\n '''\n zeroes = accum(s, 0)\n ones = list(reversed(accum(reversed(s), 1)))\n return max(x + y for x, y in zip(zeroes, ones))\n\n\ndef accum(lst, value):\n counts = [0]\n for el in lst:\n if el == value:\n counts.append(counts[-1] + 1)\n else:\n counts.append(counts[-1])\n return counts\n\n\ndef main():\n n = input()\n s = list(map(int, input().split()))\n print(solve(s))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\nline = list(map(int, input().split()))\nans = -1\nfor i in range(n + 1):\n ans1 = 0\n for j in range(n):\n if j < i and line[j] == 0:\n ans1 += 1\n elif j >= i and line[j] == 1:\n ans1 += 1\n ans = max(ans, ans1)\nprint(ans)"}, {"source_code": "n=input()\na=list(map(int,raw_input().split()))\ndp=[[[0,0] for j in range(102)] for i in range(103)]\nif a[0]==0:\n dp[0][1][0]=1\n dp[0][0][0]=0\nelse:\n dp[0][1][1]=1\n dp[0][0][0]=0\nfor i in range(1,n):\n if a[i]==1:\n dp[i][1][1]=max(dp[i-1][0][1],dp[i-1][0][0],dp[i-1][1][0],dp[i-1][1][1])+1\n dp[i][0][0]=max(dp[i-1][0][0],dp[i-1][1][0])\n dp[i][0][1]=max(dp[i-1][0][1],dp[i-1][1][1])\n else:\n dp[i][1][0]=max(dp[i-1][0][0],dp[i-1][1][0])+1\n dp[i][0][1]=max(dp[i-1][0][1],dp[i-1][1][1])\n dp[i][0][0]=max(dp[i-1][0][0],dp[i-1][1][0])\nprint max(dp[n-1][1][0],dp[n-1][1][1],dp[n-1][0][1],dp[n-1][0][0])\n\n \n \n\n \n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nl = [a[i+1:].count(0)+a[:i].count(1) for i in range(n)]\nprint(n - min(l))"}, {"source_code": "def read_ints():\n\treturn [int(i) for i in input().split()]\n\nn = int(input())\ns = read_ints()\nto_rem = n if sum(s) else 0\nfor i in range(n):\n\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\n\nprint(n - to_rem)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split(\" \")]\n\ncase1 = 0\nfor i in range(n):\n if a[i] == 0:\n case1 += 1\n\ncase2 = 0\nfor i in range(n):\n if a[i] == 1:\n case2 += 1\n\nfinal = max(case1, case2)\n\nfor i in range(n-1):\n result = 0\n s1 = a[:i+1]\n s2 = a[i+1:]\n for j in s1:\n if j == 0:\n result += 1\n for j in s2:\n if j == 1:\n result += 1\n final = max(final, result)\n\nprint(final)"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nr=0\nfor i in range(n+1):\n x=a[:i].count(0)\n y=a[i:].count(1)\n r=max(r,x+y)\nprint(r)"}, {"source_code": "n = int(input())\nm = list(map(int, input().split()))\nmaxi = 0\nfor i in range(n+1):\n cur = m[:i].count(0) + m[i:].count(1)\n if cur > maxi:\n maxi = cur\nprint(maxi)"}, {"source_code": "n = int(input())\nxs = list(map(int, input().split()))\n\ns = [0] * n\n\nif xs[-1] == 1:\n s[-1] = 1\n\nfor i in range(n - 2, -1, -1):\n s[i] = s[i + 1]\n if xs[i] == 1:\n s[i] += 1\n\nres = 0\n\ntmp = 0\nfor i in range(n):\n if xs[i] == 0:\n tmp += 1\n res = max(res, tmp + s[i])\n\nprint(res)\n"}, {"source_code": "import sys\n\n#######################################################################\n\ndef get_lines():\n\treturn sys.stdin.readlines()\n\n\n#######################################################################\n\ndef diversity():\n\tlines = sys.stdin.readlines()\n\ts = lines[0][0:-1]\n\tk = int(lines[1])\n\t\n\tif k > len(s) or k > 26:\n\t\tprint \"impossible\"\n\t\treturn 0\n\n\tunique = ''\n\tfor c in s:\n\t\tif not c in unique:\n\t\t\tunique += c\n\n\tprint max(0, k - len(unique))\n\treturn 0\n\n#######################################################################\n\ndef curriculum():\n\tlines = get_lines()\n\tn = int(lines[0])\n\ts = [int(word) for word in lines[1].split()]\n\tmax_kept = 0\n\tpos = 0\n\tfor start in range(len(s)):\n\t\tremoved = 0\n\t\tfor before_start in s[:start]:\n\t\t\tif before_start == 1:\n\t\t\t\tremoved += 1\n\t\tfor after_start in s[start+1:]:\n\t\t\tif after_start == 0:\n\t\t\t\tremoved += 1\n\t\tif n - removed > max_kept:\n\t\t\tmax_kept = n - removed\n\t\t\t#print pos\n\t\tpos += 1\n\n\tprint max_kept\n\treturn max_kept\n\n\n\n\n\ncurriculum()\n"}, {"source_code": "total = 0\nn = int(input())\na = [int(i) for i in input().split()]\nmax1 = 0\nfor i in range(n+1):\n\tsum1 = 0\n\tfor j in range(n):\n\t\tif(a[j] == 1 and j>=i):\n\t\t\tsum1 += 1\n\t\telif(a[j] == 0 and j ans:\n ans = g\nprint(ans)\n\n'''\ni=n-1\nx=0\ny=0\nwhile i>=0 and s[i]==1:\n i-=1\nwhile i > -1:\n if s[i]==1:\n x+=1\n i-=1\ni=0\nwhile i= i and line[j] == 1:\n ans1 += 1\n ans = max(ans, ans1)\nprint(ans)"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\npref1 = [0]\nfor i in arr:\n pref1.append(pref1[-1] + i)\nsuf0 = [0]\nfor i in arr[::-1]:\n suf0.append(suf0[-1] + (i + 1) % 2)\nans = []\nfor i in range(n + 1):\n ans.append(n - (suf0[::-1][i] + pref1[i]))\nprint(max(ans))"}, {"source_code": "n = int(input())\nt = list(map(int, input().split()))\n#print(t)\nprint( max( [ i-sum(t[:i]) + sum(t[i:]) for i in range(n+1) ] ))\n\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\na = 0\nfor i in range(n+1):\n x = s[:i].count(0)\n y = s[i:].count(1)\n a = max(a, x+y)\nprint(a)"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nres = max([len(s[:i])-sum(s[:i])+sum(s[i:]) for i in range(n+1)])\nprint(res)"}, {"source_code": "n = input()\ns = map(int,raw_input().split())\nr = []\nfor i in xrange(n+1):\n\tr.append(s[:i].count(0)+s[i:].count(1))\nprint max(r)\n\n\n\n"}, {"source_code": "def read_ints():\n\treturn [int(i) for i in input().split()]\n\nn = int(input())\ns = read_ints()\nto_rem = n if sum(s) else 0\nfor i in range(n):\n\tto_rem = min(to_rem, s[:i].count(1) + (s[i:].count(0) if sum(s[i:]) else 0))\n\nprint(n - to_rem)"}, {"source_code": "n = int(input())\nt = -1\nan = 0\na = list(map(int, input().split()))\nwhile a.count(1):\n an = max(a.index(1) + a.count(1), an)\n del a[a.index(1)]\n \nprint(max(an, len(a)))\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\nr = 0\nfor i in range(n + 1) :\n x = a[:i].count(0)\n y = a[i:].count(1)\n r = max(r, x + y)\n \nprint(r)"}, {"source_code": "n = int(input())\narr = input()\narr = arr.split(' ')\narr = list(map(int, arr))\nmaxi = -1\nones = list(range(n+1))\nones[n]=0\nfor j in range(1, n):\n if arr[n-j] == 1:\n ones[n-j] = ones[n-j+1] + 1\n else:\n ones[n-j] = ones[n-j+1]\nif arr[0] == 1:\n ones[0] = ones[1] + 1\nelse:\n ones[0] = ones[1]\ncounter = 0\nif arr[0] == 1:\n maxi = ones[0]\nfor i in range(0, n):\n if arr[i] == 0:\n counter = counter + 1\n if i < n-1:\n if maxi < counter + ones[i + 1]:\n maxi = counter + ones[i + 1]\n elif i == n-1:\n if maxi < counter:\n maxi = counter\nprint(maxi)\n# 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nans = 0\nfor i in range(n + 1):\n lans = a[:i].count(0) + sum(a[i:])\n ans = max(ans, lans)\nprint(ans)"}, {"source_code": "N = input()\nA = map(int, raw_input().split())\n\nif 0 not in A or 1 not in A:\n print N\n exit()\n\nans = 0\ntmp = 0\n\nfor i in xrange(N):\n if A[i] == 0:\n tmp += 1\n ans = max(ans, tmp)\n else:\n ans = max(ans, tmp + sum(A[i:]))\n\nprint ans\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nprint(max(a[:i].count(0)+a[i:].count(1) for i in range(n+1)))"}, {"source_code": "input()\nn = [int(x) for x in input().split()]\na = -1\naa = 0\nfor i, x in enumerate(n):\n aaa = aa + len([x for x in n[i:] if x])\n if aaa > a:\n a = aaa\n if not x:\n aa += 1\nprint(max(a,aa))"}, {"source_code": "waste = input()\ns = input()\nm = -1#you want a seq like [...0 0 0 0 0 0 0 1 1 1 1 1 ...]\nfor i in range(len(s)+1):\n\tp = s[:i].count('0') + s[i:].count('1')\n\tif p > m:\n\t\tm = p\nprint(m)"}, {"source_code": "n = int(input())\n\ns = list(map(int, input().split()))\n\nprint(max([s[:i].count(0) + s[i:].count(1) for i in range(n + 1)]))"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[21]:\n\n\nn=int(input())\nA=input().split()\n#print(A)\n#cons_0=[]\n#cons_1=[]\ncount_0=0\ncount_1=0\ni=0\nif n==1:\n print(n)\nelse:\n for i in range(0,n):\n if A[i]=='0':\n count_0+=1\n if A[i]=='1':\n count_1+=1\n \n maxm=max(count_0, count_1)\n for i in range(0,n):\n max_now=0\n for j in range(0,i+1):\n if A[j]=='0':\n max_now+=1\n for j in range(i+1,n):\n if A[j]=='1':\n max_now+=1\n #print(max_now)\n if max_now>maxm:\n maxm=max_now\n \n #print(cons_0)\n #print(cons_1)\n \n print(maxm)\n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "\n\ndef solve(s):\n '''\n >>> solve([1, 1, 0, 1])\n 3\n >>> solve([0, 1, 0, 0, 1, 0])\n 4\n >>> solve([0])\n 1\n '''\n zeroes = accum(s, 0)\n ones = list(reversed(accum(reversed(s), 1)))\n return max(x + y for x, y in zip(zeroes, ones))\n\n\ndef accum(lst, value):\n counts = [0]\n for el in lst:\n if el == value:\n counts.append(counts[-1] + 1)\n else:\n counts.append(counts[-1])\n return counts\n\n\ndef main():\n n = input()\n s = list(map(int, input().split()))\n print(solve(s))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\ndata = list(map(int, input().split()))\ndata2 = [0] * n\ndata2[0] = data[0]\nfor i in range(1, n):\n if data[i]:\n data2[i] = data2[i - 1] + 1\n else:\n data2[i] = data2[i - 1]\ndata2 = [0] + data2\nma = -2\nfor i in range(n + 1):\n ma = max(ma, data2[-1] - data2[i] + i - data2[i])\nprint(ma)"}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\nc=[]\nt=0\nwhile s[t]==0 and t -1 and a2[index]:\n index -= 1\n for o in range(index, -1, -1):\n if a2[o]:\n ansi += 1\n ans = max(len(a2) - ansi, ans)\nprint(ans)"}, {"source_code": "\n\nINF = 10 ** 9 + 7\n\n\ndef cutoff(games, pos):\n leave = 0\n\n for i, g in enumerate(games):\n if i < pos:\n if g == 0:\n leave += 1\n else:\n if g == 1:\n leave += 1\n\n return leave\n\n\ndef main():\n n = int(input())\n\n games = [int(x) for x in input().split()]\n\n max_leave = -INF\n\n for i in range(n+1):\n max_leave = max(max_leave, cutoff(games, i))\n\n print(max_leave)\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\none = []\nzero = 0\nfor i in range(n):\n if a[i] == 1:\n one.append(i)\n else:\n zero += 1\n\nif len(one) == 0:\n print(zero)\nelse:\n num = zero\n for i in range(len(one)):\n pre0 = 0\n suf0 = 0\n tmp1 = 0\n for j in range(n):\n if j < one[i] and a[j] == 0:\n pre0 += 1\n elif one[i] <= j and a[j] == 1:\n tmp1 += 1\n num = max(pre0 + tmp1, num)\n print(num)\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nres = max([(i-sum(s[:i])) + 1 + sum(s[i+1:]) for i in range(n)])\nprint(res)"}, {"source_code": "n = int(raw_input())\n\ngames = map(int, raw_input().split())\n\nresume = 0\nzero_cnt = 0\nfor i in range(n):\n if games[i] == 0:\n zero_cnt += 1\n resume = max(resume, zero_cnt + games[i:].count(1))\n\nprint max(games.count(1), resume)\n"}, {"source_code": "input()\ns = input()\nprint(max([s[:i].count('0') + s[i:].count('1') for i in range(len(s) + 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\n\ndef main():\n n = int(input())\n s = [int(i) for i in input().split()]\n\n zero_count = [0] * (n + 1)\n one_count = [0] * (n + 1)\n\n for i in range(n):\n zero_count[i + 1] = zero_count[i] + (s[i] == 0)\n one_count[i + 1] = one_count[i] + (s[i] == 1)\n\n sol = zero_count[-1]\n\n for i, j in enumerate(s):\n if j == 1:\n ones = one_count[-1] - one_count[i]\n zeros = zero_count[i + 1]\n\n sol = max(sol, ones + zeros)\n\n print(sol)\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": "n = int(input())\ns = list(map(int, input().split(' ')))\n\nones = sum(1 for v in s if v == 1)\nzeroes = sum(1 for v in s if v == 0)\nzero_ones = 0\n\nloss = 0\nfor i in range(n):\n if s[i] == 1:\n loss += 1\n continue\n\n loss_zeroes = 0\n j = i + 1\n while (j < n):\n if (s[j] == 0 and s[j-1] == 1):\n while (j < n and s[j] == 0):\n loss_zeroes += 1\n j += 1\n\n continue\n\n j += 1\n\n zero_ones = max(zero_ones, (n - loss - loss_zeroes))\n\n# print (f\"leading {leading_zeroes}\")\n# print (f\"ones {ones}\")\n# print (f\"zeroes {zeroes}\")\n\nprint(max(ones, zeroes, zero_ones))"}, {"source_code": "n = int(input())\nres = list(map(int, input().split()))\nans = 0\n\nfor i in range(n+1):\n x = res[:i].count(0)\n y = res[i:].count(1)\n ans = max(ans, x + y)\nprint(ans)\n"}, {"source_code": "n=input()\na=raw_input().split(\" \")\nj=0\nval=0\nfor i in xrange(n):\n if a[i]=='1':\n j+=1\n val=max(val,n-j+1-a[i:].count('0'),n-a.count('1'))\nprint val\n "}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nres = max(i-sum(s[:i]) + 1 + sum(s[i+1:]) for i in range(n))\nprint(res)\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 main():\n n = int(input())\n s = [int(i) for i in input().split()]\n\n zero_count = [0] * (n + 1)\n one_count = [0] * (n + 1)\n\n for i in range(n):\n zero_count[i + 1] = zero_count[i] + (s[i] == 0)\n one_count[i + 1] = one_count[i] + (s[i] == 1)\n\n sol = zero_count[-1]\n\n for i, j in enumerate(s):\n if j == 1:\n ones = one_count[-1] - one_count[i]\n zeros = zero_count[i + 1]\n\n sol = max(sol, ones + zeros)\n\n print(sol)\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": "N = input()\nA = map(int, raw_input().split())\n\nif 0 not in A or 1 not in A:\n print N\n exit()\n\nans = 0\ntmp = 0\n\nfor i in xrange(N):\n if A[i] == 0:\n tmp += 1\n ans = max(ans, tmp)\n else:\n ans = max(ans, tmp + sum(A[i:]))\n\nprint ans\n"}, {"source_code": "def main():\n\tn = int(input())\n\tgames = list(map(int, input().split(' ')))\n\t\n\tresult = max([games[:i].count(0) + games[i:].count(1) for i in range(n+1)])\n\t\t\t\t\t\t\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nanswer = [0] * n\nanswer[0] = 1\n\nfor i in range(1, n):\n if a[i] == 1:\n answer[i] = max(answer) + 1\n else:\n temp_max = 0\n for j in range(i):\n if a[j] == 0 and answer[j] > temp_max:\n temp_max = answer[j]\n answer[i] = temp_max + 1\n \nprint(max(answer))"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\no = [0] * (n + 1)\nans = 0\nfor i, x in enumerate(a):\n o[i+1] = o[i] + x\nfor i in xrange(n + 1):\n t = i - o[i] + o[n] - o[i]\n if ans < t:\n ans = t\nprint ans\n"}, {"source_code": "n = int(input())\nval = list(map(int, input().split()))\nk = 0\nfor i in range(n + 1):\n k = max(k, i - sum(val[:i]) + sum(val[i:]))\nprint(k)"}, {"source_code": "n = int(input())\ngames = list(map(int, input().split()))\n\nstrike = [0] * n\n\nfor i in range(n):\n\tstrike[i] = 1\n\tfor j in range(i):\n\t\tif games[j] <= games[i]:\n\t\t\tstrike[i] = max(strike[i], strike[j] + 1)\n\n# print(strike)\nprint(max(strike))\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split(' ')))\n\nones = sum(1 for v in s if v == 1)\nzeroes = sum(1 for v in s if v == 0)\nzero_ones = 0\n\nloss = 0\nfor i in range(n):\n if s[i] == 1:\n loss += 1\n continue\n\n loss_zeroes = 0\n j = i + 1\n while (j < n):\n if (s[j] == 0 and s[j-1] == 1):\n while (j < n and s[j] == 0):\n loss_zeroes += 1\n j += 1\n\n continue\n\n j += 1\n\n zero_ones = max(zero_ones, (n - loss - loss_zeroes))\n\n# print (f\"leading {leading_zeroes}\")\n# print (f\"ones {ones}\")\n# print (f\"zeroes {zeroes}\")\n\nprint(max(ones, zeroes, zero_ones))"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 20 23:21:21 2017\n\n@author: soham\n\"\"\"\n\n\n \n\n\nn=int(raw_input())\ns=map(int,raw_input().split())\n\nmemo=[0]*n\nones=[0]*n\n\ncnt=0\nfor i in range(0,n):\n if s[i]==0:\n cnt+=1\n else:\n memo[i]=cnt\n\ncnt=0\nfor i in range(n-1,-1,-1):\n if s[i]==1:\n cnt+=1\n ones[i]=cnt\n \n\nans=0\n\nfor i in range(0,n):\n if s[i]==0:\n ans+=1\n \nfor i in range(0,n):\n if s[i]==1:\n temp=memo[i]+ones[i]\n ans=max(ans,temp)\n \n\nprint ans"}, {"source_code": "n = int(raw_input())\n\ngames = map(int, raw_input().split())\n\nresume = 0\nzero_cnt = 0\nfor i in range(n):\n if games[i] == 0:\n zero_cnt += 1\n resume = max(resume, zero_cnt + games[i:].count(1))\n\nprint max(games.count(1), resume)\n"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nvalues = list(map(int, stdin.readline().split()))\ndp = [[0, 0] for i in range(n)]\n\nfor i in range(n):\n if not values[i]:\n dp[i][0] = 1\n \n for j in range(i - 1, -1, -1):\n dp[i][0] = max(dp[i][0], dp[j][0] + 1)\n else:\n dp[i][1] = 1\n \n for j in range(i - 1, -1, -1):\n dp[i][1] = max(dp[i][1], max(dp[j]) + 1)\n\nans = 0\nfor i in range(n):\n ans = max(ans, max(dp[i]))\n \nstdout.write(str(ans))"}, {"source_code": "KoKoKo = int\nkudaxKudax = input\nkukareku = max\nkokokokoko = print\nkudkudax = range\n\n\n\n\nkokoko = KoKoKo(kudaxKudax())\nko = [KoKoKo(x) for x in kudaxKudax().split()]\nKO = KOKOKO = 0\nfor kok in kudkudax(kokoko - 1, -1, -1):\n KO += ko[kok]\n KOKOKO = kukareku(KOKOKO, KO + ko[:kok + 1].count(0))\nkokokokoko(KOKOKO)"}, {"source_code": "n=int(input())\ns=list(map(int,input().split()))\nc=[]\nt=0\nwhile s[t]==0 and tm:\n m=k+x\nprint(m)\n \n \n"}, {"source_code": "n = int(input())\nlst = list(map(int, input().split()))\nl = [lst[:i].count(0)+lst[i:].count(1) for i in range(n+1)]\nprint (max(l))\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nans = 0\nfor i in range(a.count(0) + 1):\n zc = 0\n for j in range(n):\n if a[j] == 0:\n zc += 1\n if zc == i:\n break\n ans = max(ans, i + a[j:].count(1))\nprint(ans)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\nr = 0\nfor i in range(len(a) + 1):\n\tx = a[:i].count(0)\n\ty = a[i:].count(1)\n\tr = max(r, x + y)\nprint(r)\n"}, {"source_code": "n = input()\nls = map(int,raw_input().split())\nb = [0,0]\n\na = []\n\nfor i in xrange(n):\n\ta.append(b)\n\nif ls[0] == 0:\n\ta[0][0] = 1\n\ta[0][1] = 0\nelse:\n\ta[0][0] = 0\n\ta[0][1] = 1\n\nfor i in xrange(1,n):\n\tif ls[i] == 0:\n\t\ta[i][0] = a[i-1][0] + 1; a[i][1] = a[i-1][1]\n\tif ls[i] == 1:\n\t a[i][0] = a[i-1][0] \n\t a[i][1] = max(a[i-1][0] + 1 , a[i-1][1] + 1);\n\nprint int(max(a[n-1][0],a[n-1][1]))"}, {"source_code": "n = int(input())\nres = list(map(int, input().split()))\nans = 0\n\nfor i in range(n+1):\n x = res[:i].count(0)\n y = res[i:].count(1)\n ans = max(ans, x + y)\nprint(ans)\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\na = 0\nfor i in range(n+1):\n x = s[:i].count(0)\n y = s[i:].count(1)\n a = max(a, x+y)\nprint(a)"}, {"source_code": "import sys\n\nsys.setrecursionlimit(100000)\n\ndef parser():\n while 1:\n data = list(input().split(' '))\n for number in data:\n if len(number) > 0:\n yield(number) \n\ninput_parser = parser()\n\ndef get_word():\n global input_parser\n return next(input_parser)\n\ndef get_number():\n data = get_word()\n try:\n return int(data)\n except ValueError:\n return float(data)\n\nans = 0\n\n \na = input()\nst = input().split()\nm0 = 0\nm1 = 0\nans = 0\nfor i in st:\n if int(i):\n m1 = max(m0, m1) + 1\n else:\n m0 += 1\n ans = max(m0, m1)\nprint(ans)\n "}, {"source_code": "n = int(input())\nval = list(map(int, input().split()))\nk = 0\nfor i in range(n + 1):\n k = max(k, i - sum(val[:i]) + sum(val[i:]))\nprint(k)"}, {"source_code": "n = int(input())\nxs = list(map(int, input().split()))\n\ns = [0] * n\n\nif xs[-1] == 1:\n s[-1] = 1\n\nfor i in range(n - 2, -1, -1):\n s[i] = s[i + 1]\n if xs[i] == 1:\n s[i] += 1\n\nres = 0\n\ntmp = 0\nfor i in range(n):\n if xs[i] == 0:\n tmp += 1\n res = max(res, tmp + s[i])\n\nprint(res)\n"}, {"source_code": "waste = input()\ns = input()\nm = -1\nfor i in range(len(s)+1):\n\tp = s[:i].count('0') + s[i:].count('1')\n\tif p > m:\n\t\tm = p\nprint(m)"}, {"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 main():\n n = int(input())\n s = [int(i) for i in input().split()]\n\n zero_count = [0] * (n + 1)\n one_count = [0] * (n + 1)\n\n for i in range(n):\n zero_count[i + 1] = zero_count[i] + (s[i] == 0)\n one_count[i + 1] = one_count[i] + (s[i] == 1)\n\n sol = zero_count[-1]\n\n for i, j in enumerate(s):\n if j == 1:\n ones = one_count[-1] - one_count[i]\n zeros = zero_count[i + 1]\n\n sol = max(sol, ones + zeros)\n\n print(sol)\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": "n = int(input())\ns = list(map(int, input().split()))\nres = max([len(s[:i])-sum(s[:i])+sum(s[i:]) for i in range(n+1)])\nprint(res)"}, {"source_code": "n = int(input())\nnums = list(map(int, input().split()))\n\nright = [0 for i in range(n)]\nfor i in range(n - 1, -1, -1):\n right[i] = nums[i]\n if i < n - 1:\n right[i] += right[i + 1]\n \nleft = [0 for i in range(n)]\nfor i in range(n):\n left[i] = nums[i]\n if i > 0:\n left[i] += left[i - 1]\n \nres = 0\nfor i in range(-1, n):\n count = 0\n if i >= 0:\n count = i + 1 - left[i]\n if i + 1 < n:\n count += right[i + 1]\n res = max(res, count)\n\nprint(res)"}, {"source_code": "n = int(input())\nm=list(map(int,input().split()))\nx=m.count(0)\ny=n-x\na=0\nb=0\nl=max(x,y)\nfor i in range(n):\n if m[i]==1:\n a+=1\n c=[]\n d=0\n e=0\n for j in range(i+1):\n if m[j]==1:\n d+=1\n else:\n e+=1\n c.append(e+a-d)\n l=max(l,max(c)+y-a)\n\n \n \n else:\n b+=1\nprint(l)\n \n "}, {"source_code": "\"\"\"\nCodeforces Round #334 (Div. 2)\n\nProblem 846 A. Curriculum Vitae\n\n@author yamaton\n@date 2017-09-13\n\"\"\"\n\n\ndef count(xs, i):\n return xs[:i].count(0) + xs[i:].count(1)\n\n\ndef solve(xs):\n n = len(xs)\n return max(count(xs, i) for i in range(n + 1))\n\n\ndef main():\n n = int(input())\n xs = [int(c) for c in input().split()]\n assert len(xs) == n\n result = solve(xs)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nans = sum(a)\nfor i in range(len(a) - 1, - 1, -1):\n ans = min(ans, (len(a) - i - sum(a[i:])) + sum(a[:i]))\nprint(len(a) - ans)\n"}], "negative_code": [{"source_code": "n = int(input())\np = list(map(int, input().split()))\nans = n\nfor i in range(1, n):\n if p[i] == 0 and p[i - 1] == 1:\n j = i\n k1 = 1\n while j < n - 1 and p[j + 1] == 0:\n k1 += 1\n j += 1\n j = i\n k2 = 0\n while j > 0:\n if p[j - 1] == 1:\n k2 += 1\n j -= 1\n \n if k1 < k2:\n ans -= k1\n else:\n ans -= k2\nprint(ans)"}, {"source_code": "def main():\n\tn = int(input())\n\tgames = [0]\n\tgames = games + list(map(int, input().split(' ')))\n\t\n\tresult = max([games[:i].count(0) + games[i:].count(1) for i in range(n+1)])\n\t\t\t\t\t\t\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "n = int(input())\nval = list(map(int, input().split()))\ns = sum(val)\nj = 0\nk = 0\nfor elem in val:\n if elem == 0:\n j += 1\n else:\n break\nfor elem in val[::-1]:\n if elem == 1:\n k += 1\n else:\n break\ns = sum(val[j:n - k])\nprint(j + k + max(s, n - k - j - s))"}, {"source_code": "import sys\n\nn = int(input())\na = [0] + list(map(int, input().split()))\nans = 0\nfor x, y in zip(a, a[1:]):\n if not (x == 1 and y == 0):\n ans += 1\nprint(ans)\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nn = len(s)\n\nans = 0\nj1 = 0\nwhile j1 < n and s[j1] == 0:\n ans += 1\n j1 += 1\n\nj2 = n-1\nwhile j2 > 0 and s[j2] == 1:\n ans += 1\n j2 -= 1\n\nctr0 = 0\nctr1 = 0\nlast = 0\n\nfor i in range(j1, j2+1):\n if s[i] == 0:\n ctr0 += 1\n else:\n ctr1 += 1\n\nif ctr0 > ctr1 :\n ans += ctr0 \nelse:\n ans += ctr1 \n \nprint(ans)\n\n "}, {"source_code": "def main():\n\tn = int(input())\n\tgames = [0]\n\tgames = games + list(map(int, input().split(' ')))\n\t\n\tresult = max([games[:i].count(0) + games[i:].count(1) for i in range(n+1)])\n\t\t\t\t\t\t\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nanswer = [0] * n\nanswer[0] = 1\n\nfor i in range(1, n):\n if a[i] == 1:\n answer[i] = max(answer) + 1\n else:\n temp_max = -1\n for j in range(i):\n if a[j] == 0 and answer[j] > temp_max:\n temp_max = answer[j]\n answer[i] = temp_max + 1\n \nprint(max(answer))\n "}, {"source_code": "n = int(input())\nres = input().split()\nlast0 = 0\n\nfor i in range(len(res)):\n if res[i] == '0': last0 = i\n \ntry: ans = max(res.count('1') + res[:res.index('1')].count('0'), res.count('0'))\nexcept: ans = n\n\nprint(ans)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n#n = len(a)\ndelete0 = n - a[a.index(1) if 1 in a else 0:].count(0)\na.reverse()\ndelete1 = n - a[a.index(0) if 0 in a else 0:].count(1)\nprint(max(delete0, delete1))"}, {"source_code": "a=int(input())\nb=input()\nprint(a-b.count('1 0'))\n"}, {"source_code": "def main():\n\tn = int(input())\n\tgames = list(map(int, input().split(' ')))\n\t\n\tone = 0\n\tzero = 0\n\tfor i in range(0, len(games)):\n\t\tif games[i] == 1:\n\t\t\tone = one + 1\n\t\telse:\n\t\t\tzero = zero + 1\n\t\n\tif zero >= one:\n\t\tresult = len(games) - one\n\telse:\n\t\tresult = len(games) - zero\t\t\t\t\n\t\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "n = int(input())\nnums = list(map(int, input().split()))\n\nd = [0, 0]\n\nfor i in nums:\n if i == 0:\n d[0] += 1\n else:\n d[0] += 1\n d[1] += 1\n\nprint(max(d[0], d[1]))"}, {"source_code": "n = int(input())\nline = list(map(int, input().split()))\nans = -1\nfor i in range(n):\n ans1 = 0\n for j in range(n):\n if i <= j and line[j] == 0:\n ans1 += 1\n elif i >= j and line[j] == 1:\n ans1 += 1\n ans = max(ans, ans1)\nprint(ans)"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\nr = 0\nfor i in range(len(a)):\n\tx = a[:i].count(0)\n\ty = a[i:].count(1)\n\tr = max(r, x + y)\nprint(r)\n"}, {"source_code": "n = int(input())\nlis = [int(e) for e in input().split()]\n\ncount = 0\nfor i in range(1,n):\n if lis[i]==0 and lis[i-1]==1:\n continue\n else:\n count += 1\n\nprint(count+1)\n"}, {"source_code": "n = int(input())\ng = list(map(int, input().split()))\nans = [g[0]]\nfor i in range(1, len(g)):\n if g[i-1] == 1 and g[i] == 0:\n do = 'nothing'\n else:\n ans.append(g[i])\n# print(ans)\n# print(i)\nprint(len(ans))"}, {"source_code": "n = input()\na = map(int, raw_input().split())\n\nz = 0\nzeros = [0] * len(a)\nfor i in range(len(a)):\n zeros[i] = z\n if a[i] == 0:\n z += 1\n\no = 0\nones = [0] * len(a)\nfor i in range(len(a)-1, -1, -1):\n\n if a[i] == 1:\n o += 1\n ones[i] = o\n\n\nmax_num = 1\nfor i in range(len(a)):\n t = ones[i] + zeros[i]\n max_num = max(t, max_num)\n\nprint max_num"}, {"source_code": "n = int(input())\n\ndef it():\n p = 0\n for a in map(int,input().split()):\n if not (p == 1 and a == 0):\n yield 1\n p = a\n\n\nprint(sum(it()))"}, {"source_code": "\"\"\"\nCodeforces Round #334 (Div. 2)\n\nProblem 846 A. Curriculum Vitae\n\n@author yamaton\n@date 2017-09-13\n\"\"\"\n\nimport itertools as it\nimport functools\nimport operator\nimport collections\nimport math\nimport sys\n\n\ndef solve(xs):\n return 1 + sum(1 for (i, j) in zip(xs, xs[1:]) if (i, j) != (1, 0))\n\n\n# def pp(*args, **kwargs):\n# return print(*args, file=sys.stderr, **kwargs)\n\n\ndef main():\n n = int(input())\n xs = [int(c) for c in input().split()]\n assert len(xs) == n\n result = solve(xs)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nvalues = list(map(int, stdin.readline().split()))\ndp = [[0, 0] for i in range(n)]\n\nfor i in range(n):\n if not values[i]:\n dp[i][0] = 1\n \n for j in range(i - 1, -1, -1):\n dp[i][0] = max(dp[i][0], dp[j][0] + 1)\n else:\n dp[i][1] = 1\n \n for j in range(i - 1, -1, -1):\n dp[i][1] = max(dp[i][1], max(dp[j]) + 1)\n\nans = 0\nfor i in range(n):\n ans = max(dp[i])\n \nstdout.write(str(ans))"}, {"source_code": "n = int(input())\n\ns = list(map(int, input().split()))\n\nres = n\n\nfor i in range(n - 1):\n if(s[i] == 1 and s[i + 1] == 0):\n res -= 1\n \nprint(res)"}, {"source_code": "import sys\nfrom collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nm = 0\nd = Counter(a)\nfor i in range(d[0]):\n j = 0\n k = 0\n while k != i:\n if a[j] == 0:\n k += 1\n j += 1\n while j < n:\n if a[j] == 1:\n k += 1\n j += 1\n m = max(m,k)\nprint(m)\n"}, {"source_code": "n = int(input())\narr = input()\narr = arr.split(' ')\narr = list(map(int, arr))\nfor i in range(1, n):\n if arr[i] == 0 and arr[i-1] == 1:\n n = n - 1\nprint(n)\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nk = 0\nfor i in range(1, len(s)):\n if s[i] == 0 and s[i - 1] == 1:\n k += 1\nprint(len(s) - k)"}, {"source_code": "def solve(n, games):\n zeros_after_ones = 0 \n was_one = False\n for game in games:\n if game == 1:\n was_one = True\n if was_one and game == 0:\n zeros_after_ones += 1\n \n \n ones_before_zeros = 0\n was_zero = 0\n for game in reversed(games):\n if game == 0:\n was_zero = True\n if was_zero and game == 1:\n ones_before_zeros += 1\n \n games_to_del = min(ones_before_zeros, zeros_after_ones)\n return n - games_to_del\n\ndef main():\n n = int(input())\n games = list(map(int, input().split()))\n \n print(solve(n, games))\n \nmain()"}, {"source_code": "n=int(input())\ns=[int(c) for c in input().split()]\nres=0\n\nfor i in range(n):\n if s[i]==0 and s[i-1]==1:\n n=n\n else:\n res+=1\nprint(res)\n \n\n\n"}, {"source_code": "size = int(raw_input())\norg_arr = map(int,raw_input().split())\n\nfreq_arr = []\n\nif size == 1:\n print '1'\nelse:\n\n for i in range(len(org_arr)):\n freq = 0\n for j in range(len(org_arr)):\n if j < i and org_arr[j] == 0:\n freq += 1\n elif j>=i and org_arr[j] == 1:\n freq +=1\n\n freq_arr.append(freq)\n\n\n print max(freq_arr)\n \n\n\n"}, {"source_code": "def main():\n\tn = int(input())\n\tgames = list(map(int, input().split(' ')))\n\t\n\tone = 0\n\tzero = 0\n\tfor i in range(0, len(games)):\n\t\tif games[i] == 1:\n\t\t\tone = one + 1\n\t\telse:\n\t\t\tzero = zero + 1\n\t\n\tif zero >= one:\n\t\tresult = len(games) - one\n\telse:\n\t\tresult = len(games) - zero\t\t\t\t\n\t\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "n=int(input())\ns=[]\nfor x in input().split():\n s.append(int(x))\ns.reverse()\nk=1\nc1=0\nc0=0\nfor i in range(n):\n if s[i]==1:\n k=i\n c1+=1\nfor i in range(i):\n if s[i]==0:\n c0+=1\nif c1>=c0:\n while c0!=0:\n s.remove(0)\n c0-=1\nelif c1 0 and p[j - 1] == 1:\n k2 += 1\n j -= 1\n \n if k1 < k2:\n ans -= k1\n else:\n ans -= k2\nprint(ans)"}, {"source_code": "def solve(n, games):\n zeros_after_ones = 0 \n was_one = False\n for game in games:\n if game == 1:\n was_one = True\n if was_one and game == 0:\n zeros_after_ones += 1\n \n \n ones_before_zeros = 0\n was_zero = 0\n for game in reversed(games):\n if game == 0:\n was_zero = True\n if was_zero and game == 1:\n ones_before_zeros += 1\n \n games_to_del = min(ones_before_zeros, zeros_after_ones)\n return n - games_to_del\n\ndef main():\n n = int(input())\n games = list(map(int, input().split()))\n \n print(solve(n, games))\n \nmain()"}, {"source_code": "n=int(input())\nk=-1\nl=list(map(int,input().split()))\nfor i in range(n+1):\n s=l[:i].count('0')+l[i:].count('1')\n if(s>k):\n k=s\nprint(k)\n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\n\nans = 0\nj1 = 0\nwhile j1 < n and s[j1] == 0:\n ans += 1\n j1 += 1\n\nj2 = n-1\nwhile j2 > j1 and s[j2] == 1:\n ans += 1\n j2 -= 1\n\nctr0 = 0\nctr1 = 0\nlast = 0\n\nfor i in range(j1, j2+1):\n if s[i] == 0:\n ctr0 += 1\n else:\n ctr1 += 1\n\nif ctr0 > ctr1:\n ans+= ctr0\nelse:\n ans+= ctr1\n \nprint(ans)\n\n "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\ndelete0 = n - a[a.index(1) if 1 in a else 0:-1].count(0)\na.reverse()\ndelete1 = n - a[a.index(0) if 0 in a else 0:-1].count(1)\nprint(max(delete0, delete1))"}, {"source_code": "n =int(raw_input())\n\nm = map(int, raw_input().split())\n\none = 0\nzero = 0\nfor i in range(n):\n\tif(m[i]==1):\n\t\tone+=1\n\telse:\n\t\tzero+=1\nfor i in m:\n\tif(i==0):\n\t\tzero-=1\n\telse:\n\t\tbreak\nif(zero>one):\n\tprint n-one\nelse:\n\tprint n-zero"}, {"source_code": "n = int(input())\ng = list(map(int, input().split()))\nans = [g[0]]\nfor i in range(1, len(g)):\n if ans[-1] == 1 and g[i] == 0:\n ans.pop()\n ans.append(0)\n else:\n ans.append(g[i])\nprint(len(ans))"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\n\nans = 0\nans1 = 0\nans2 = 0\nj1 = 0\nwhile j1 < n and s[j1] == 0:\n ans1 += 1\n j1 += 1\n\nj2 = n-1\nwhile j2 > j1 and s[j2] == 1:\n ans2 += 1\n j2 -= 1\n\nctr0 = 0\nctr1 = 0\nlast = 0\n\nfor i in range(j1, j2+1):\n if s[i] == 0:\n ctr0 += 1\n else:\n ctr1 += 1\n\nif ctr0 + ans1 > ctr1 + ans2:\n ans = ctr0 + ans1\nelse:\n ans = ctr1 + ans2\n \nprint(ans)\n\n "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n#n = len(a)\ndelete0 = n - a[a.index(1) if 1 in a else 0:].count(0)\na.reverse()\ndelete1 = n - a[a.index(0) if 0 in a else 0:].count(1)\nprint(max(delete0, delete1))"}, {"source_code": "from sys import stdout\nfrom random import randint \nfrom math import *\nimport re\n\n\nn = int(input())\ns = input().replace(' ', '')\ntemp = re.findall(\"1.*\", s)\nif not temp:\n ans = len(s)\nelse:\n ns = temp[0]\n ans = len(s) - len(ns) + max(ns.count('1'), ns.count('0'))\n\nprint(ans)\n"}, {"source_code": "n = int(input())\ng = list(map(int, input().split()))\nans = [g[0]]\nfor i in range(1, len(g)):\n if g[i-1] == 1 and g[i] == 0:\n do = 'nothing'\n else:\n ans.append(g[i])\n# print(ans)\n# print(i)\nprint(len(ans))"}, {"source_code": "n = int(input())\ns = input()\nmaxs=[]\nfor i in range(n):\n\tcurr = s[i]\n\tmaxi = 1\n\tfor j in range(i+1, n):\n\t\tif curr == '0':\n\t\t\tmaxi += 1\n\t\t\tcurr = s[j]\n\t\telif s[j] == '0':\n\t\t\tcontinue\n\t\telse:\n\t\t\tmaxi +=1\n\tmaxs.append(maxi)\nmaxi=0\nfor x in s:\n\tif x == '0':\n\t\tmaxi += 1\nmaxs.append(maxi)\nprint(max(maxs))\n\t\t"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 20 23:21:21 2017\n\n@author: soham\n\"\"\"\n\n\n \n\n\nn=int(raw_input())\ns=map(int,raw_input().split())\n\nmemo=[0]*n\nones=[0]*n\n\ncnt=0\nfor i in range(0,n):\n if s[i]==0:\n cnt+=1\n else:\n memo[i]=cnt\n cnt=0\n\ncnt=0\nfor i in range(n-1,-1,-1):\n if s[i]==1:\n cnt+=1\n ones[i]=cnt\n \n\nans=0\n\nfor i in range(0,n):\n if s[i]==0:\n ans+=1\n \nfor i in range(0,n):\n if s[i]==1:\n temp=memo[i]+ones[i]\n ans=max(ans,temp)\n \n\nprint ans"}, {"source_code": "n=int(input())\nk=-1\nl=list(map(int,input().split()))\nfor i in range(n+1):\n s=l[:i].count('0')+l[i:].count('1')\n if(s>k):\n k=s\nprint(k)\n"}, {"source_code": "n = int(input())\ng = list(map(int, input().split()))\nans = [g[0]]\nfor i in range(1, len(g)):\n if ans[-1] == 1 and g[i] == 0:\n ans.pop()\n ans.append(0)\n else:\n ans.append(g[i])\nprint(len(ans))"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nprint(max([s[:i].count(1) + s[i:].count(0) for i in range(len(s) + 1)]))"}, {"source_code": "n = int(input())\n\nl = list(map(int, input().split()))\n\n\nmax_games = [0 for i in range(n)]\n\nmax_games[0] = 1\nif n > 1:\n max_games[1] = 2 if (l[1] - l[0]) != -1 else 1\n\nif n > 2:\n for i in range(2, n):\n if l[i] == 0:\n if l[i - 1] == l[i - 2] == 1:\n max_games[i] = 1\n elif l[i - 1] == 1:\n max_games[i] = max_games[i - 2] + 1\n elif l[i - 2] == 1:\n max_games[i] = max_games[i - 1] + 1\n else:\n max_games[i] = max([max_games[i - 1], max_games[i - 2]]) + 1\n else:\n max_games[i] = max([max_games[i - 1], max_games[i - 2]]) + 1\n\n\n\nprint(max(max_games))\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nans = arr.count(0)\nfor i in range(1, n + 1):\n one = 0\n ind = -1\n j = n - 1\n for j in range(n -1, -1, -1):\n if one == i:\n ind = j\n break\n if arr[j] == 1:\n one += 1\n else:\n if one == i:\n ind = j\n else:\n break\n ans = max(ans, i + arr[:ind].count(0))\nprint(ans)\n"}, {"source_code": "n = int(input())\nlis = [int(e) for e in input().split()]\nct = []\nc0 = 0\nc1 = 0\nfor i in range(len(lis)):\n if lis[i]==0:c0+=1\n if lis[i]==1:c1+=1\nct.append(c0)\nct.append(c1)\n\nfor i in range(1,len(lis)-1):\n c0 = 0\n c1 = 0\n for j in range(i-1,-1,-1):\n if lis[j]==0:\n c0+=1\n for j in range(i,len(lis)):\n if lis[j]==1:\n c1+=1\n #print(\"c0=\",c0)\n #print(\"c1=\",c1)\n ct.append(c0+c1)\n\n#print(ct)\nprint(max(ct))\n \n"}, {"source_code": "# import sys\n# sys.stdin = open('in', 'r')\n\nn = input()\ns = input()\n\nprint(max([s[:i].count('0') + s[i:].count('1') for i in range(len(s))]))\n"}, {"source_code": "n = int(input())\nlst = list(map(int,input().split()))\nfor i,x in enumerate(lst):\n if x==1:break\none,zero=0,0\nfor j in range(i,n):\n if lst[j]==1:one+=1\n else:zero+=1\nprint(i+max(one,zero))"}, {"source_code": "n = int(raw_input())\nns = map(int, raw_input().split())\n\nm = sum(ns)\nans = 0\n\ncnt = 0\nl, r = 0, n\nfor i in xrange(n):\n if ns[i] == 1:\n cnt += 1\n l += 1\n r -= 1\n ans = max(ans, (l - cnt) + (m - cnt))\nprint ans "}, {"source_code": "def main():\n\tn = int(input())\n\tgames = list(map(int, input().split(' ')))\n\t\n\tcnt = 0\n\tfor i in range(0, len(games)):\n\t\tif games[i] == 1:\n\t\t\tcnt = cnt + 1\n\t\n\tresult = len(games) - cnt\n\tprint(result)\n\n\nif __name__ == \"__main__\":\n\tmain()\t\t\t\n\t\n"}, {"source_code": "from time import sleep\nn = int(input())\ns = list(map(int, input().split()))\n\nindex = n - 1\nwhile index > 0 and s[index]:\n index -= 1\n\nanswer = n - index - 1\ns = s[:index + 1]\n# index = 0\n# index = 0\n# answer = 0\nz = s.count(0) - 1\n# o = s.count(1)\n# if\n\n# print(answer)\n\nnow = 0\n\nwhile s:\n while s and s[0] == 0:\n s = s[1:]\n answer += 1\n # print(s)\n z = s.count(0)\n o = s.count(1)\n # print(z, o)\n if o >= z:\n answer += o\n break\n else:\n answer += 1\n # x -= 1\n # s = s[index + 1:]\n s = s[s.index(0) + 1:]\nprint(answer)\n"}, {"source_code": "n = input()\nnums = map(int, raw_input().split())\n\ncumsum = [0]\nfor num in nums:\n\tcumsum.append(cumsum[-1] + num)\n\nmax_ = 1\n# nums[i] + ... nums[j] = cumsum[j+1] - cumsum[i] # cumsum is 1 based. nums is 0 based.\nfor idx in xrange(1, n+1):\n\t# 0 0 0 0....1....1 1 1.\n\tif nums[idx-1] == 1:\n\t\t# count all zeros before idx and all ones after idx.\n\t\tall_zeros_before = (idx-1) - cumsum[idx-1]\n\t\tall_ones_after = cumsum[n] - cumsum[idx-1]\n\t\tmax_ = max(max_, all_ones_after + all_zeros_before)\n\nprint max_\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nfz = 0\nwhile len(a) > 0 and a[0] == 0:\n fz += 1\n a = a[1:]\nmans = [0]\no = a.count(1)\nfor i in range(o):\n q = 0\n j = 0\n z = 0\n while j < len(a) and q <= i:\n if j == 1:\n q += 1\n else:\n z += 1\n q += 1\n mans.append(o + z - i)\nprint(fz + max(mans))"}, {"source_code": "def read_ints():\n\treturn [int(i) for i in input().split()]\n\nn = int(input())\ns = read_ints()\nto_rem = n if sum(s) else 0\nfor i in range(n):\n\tif s[i]:\n\t\tto_rem = min(to_rem, s[:i].count(1) + s[i:].count(0))\n\nprint(n - to_rem)"}, {"source_code": "n = input()\nnums = map(int, raw_input().split())\n\ncumsum = [0]\nfor num in nums:\n\tcumsum.append(cumsum[-1] + num)\n\nmax_ = 1\n# nums[i] + ... nums[j] = cumsum[j+1] - cumsum[i] # cumsum is 1 based. nums is 0 based.\nfor idx in xrange(1, n+1):\n\t# 0 0 0 0....1....1 1 1.\n\tif nums[idx-1] == 1:\n\t\t# count all zeros before idx and all ones after idx.\n\t\tall_zeros_before = (idx-1) - cumsum[idx-1]\n\t\tall_ones_after = cumsum[n] - cumsum[idx-1]\n\t\tmax_ = max(max_, all_ones_after + all_zeros_before)\n\nprint max_\n"}, {"source_code": "n = int(input())\nlst = list(map(int,input().split()))\nfor i,x in enumerate(lst):\n if x==1:break\none,zero=0,0\nfor j in range(i,n):\n if lst[j]==1:one+=1\n else:zero+=1\nprint(i+max(one,zero))"}, {"source_code": "n = int(input())\ng = list(map(int, input().split()))\nans = [g[0]]\nfor i in range(1, len(g)):\n if g[i-1] == 1 and g[i] == 0:\n do = 'nothing'\n else:\n ans.append(g[i])\n# print(ans)\n# print(i)\nprint(len(ans))"}, {"source_code": "from time import sleep\nn = int(input())\ns = list(map(int, input().split()))\n\nindex = n - 1\nwhile index > 0 and s[index]:\n index -= 1\n\nanswer = n - index - 1\ns = s[:index + 1]\n# index = 0\n# index = 0\n# answer = 0\nz = s.count(0) - 1\n# o = s.count(1)\n# if\n\n# print(answer)\n\nnow = 0\n\nwhile s:\n while s and s[0] == 0:\n s = s[1:]\n answer += 1\n # print(s)\n z = s.count(0)\n o = s.count(1)\n # print(z, o)\n if o >= z:\n answer += o\n break\n else:\n answer += 1\n # x -= 1\n # s = s[index + 1:]\n s = s[s.index(0) + 1:]\nprint(answer)\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nans = 0\nz = arr.count(0)\no = arr.count(1)\ni = n - 1\nif n == 1:\n print(arr[0])\n exit()\nif z == n:\n print(z)\n exit()\nwhile arr[i] == 1 and i >= 0:\n i -= 1\n ans += 1\n o -= 1\nbeg = -1\nfor j in range(n):\n if arr[j] == 0:\n ans += 1\n z -= 1\n else:\n beg = j - 1\n break\nwhile i > beg:\n #print(i, o, z, ans)\n if o > z:\n while arr[i] == 0 and i > beg:\n z -= 1\n i -= 1\n while arr[i] == 1 and i > beg:\n o -= 1\n i -= 1\n #print('!', i, o, z, ans + 1)\n ans += 1\n else:\n #print(i + 1)\n while arr[i] == 0 and i > beg:\n z -= 1\n i -= 1\n ans += 1\n while arr[i] == 1 and i > beg:\n o -= 1\n i -= 1\nprint(ans)"}, {"source_code": "n=int(input())\nl=[int(i) for i in input().split()]\ncnt=0 \nfor i in range(n-1,-1,-1):\n if l[i]==1:\n cnt+=1 \n ind=i \n else:\n break \nind1=0 \ncnt1= 0 \nfor i in range(n):\n if l[i]==0:\n cnt1+=1\n ind1=i+1 \n else:\n break \nif cnt==n:\n print(n)\n exit()\nif cnt==0:\n ind=n \nl=l[ind1:ind]\nprint(cnt+cnt1+max(l.count(0),l.count(1)))"}, {"source_code": "n = input()\na = map(int, raw_input().split())\n\nz = 0\nzeros = [0] * len(a)\nfor i in range(len(a)):\n zeros[i] = z\n if a[i] == 0:\n z += 1\n\no = 0\nones = [0] * len(a)\nfor i in range(len(a)-1, -1, -1):\n\n if a[i] == 1:\n o += 1\n ones[i] = o\n\n\nmax_num = 1\nfor i in range(len(a)):\n t = ones[i] + zeros[i]\n max_num = max(t, max_num)\n\nif o == 0:\n print z\nelse:\n print max_num"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nfz = 0\nwhile len(a) > 0 and a[0] == 0:\n fz += 1\n a = a[1:]\nmans = [0]\no = a.count(1)\nfor i in range(o):\n q = 0\n j = 0\n z = 0\n while j < len(a) and q <= i:\n if j == 1:\n q += 1\n else:\n z += 1\n q += 1\n mans.append(o + z - i)\nprint(fz + max(mans))"}, {"source_code": "n = int(input())\nval = list(map(int, input().split()))\ns = sum(val)\nj = 0\nk = 0\nfor elem in val:\n if elem == 0:\n j += 1\n else:\n break\nfor elem in val[::-1]:\n if elem == 1:\n k += 1\n else:\n break\nprint(max(s + j, n - s + k))"}, {"source_code": "n = int(input())\nnums = list(map(int, input().split()))\n\nd = [0, 0]\n\nfor i in nums:\n if i == 0:\n d[0] += 1\n else:\n d[0] += 1\n d[1] += 1\n\nprint(max(d[0], d[1]))"}, {"source_code": "n = int(input())\nnums = list(map(int, input().split()))\n\nd = [0, 0]\n\nfor i in nums:\n if i == 0:\n d[0] += 1\n else:\n d[0] += 1\n d[1] += 1\n\nprint(max(d[0], d[1]))"}, {"source_code": "n = input()\na = map(int, raw_input().split())\n\nz = 0\nzeros = [0] * len(a)\nfor i in range(len(a)):\n zeros[i] = z\n if a[i] == 0:\n z += 1\n\no = 0\nones = [0] * len(a)\nfor i in range(len(a)-1, -1, -1):\n\n if a[i] == 1:\n o += 1\n ones[i] = o\n\n\nmax_num = 1\nfor i in range(len(a)):\n t = ones[i] + zeros[i]\n max_num = max(t, max_num)\n\nprint max_num"}, {"source_code": "def rezume(lst):\n a, b = [0] * len(lst), [0] * len(lst)\n a[0], b[len(lst) - 1] = 0, 0\n for i in range(1, len(lst)):\n a[i] = a[i - 1] + (not lst[i])\n for i in range(len(lst) - 2, -1, -1):\n b[i] = b[i + 1] + lst[i]\n result = 0\n for i in range(len(lst)):\n result = max(result, a[i] + b[i])\n return result + 1\n\n\nn = int(input())\nc = [int(j) for j in input().split()]\nprint(rezume(c))\n"}, {"source_code": "N = input()\nA = map(int, raw_input().split())\n\nif 0 not in A or 1 not in A:\n print N\n exit()\n\ni = 0\nj = N-1\nwhile A[i] == 0:\n i += 1\nwhile A[j] == 1:\n j -= 1\n\ncnt0 = A[i:j+1].count(0)\ncnt1 = A[i:j+1].count(1)\nprint i + N - j - 1 + max(cnt0, cnt1)\n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nanswer = [0] * n\nanswer[0] = 1\n\nfor i in range(1, n):\n if a[i] == 1:\n answer[i] = max(answer) + 1\n else:\n temp_max = -1\n for j in range(i):\n if a[j] == 0 and answer[j] > temp_max:\n temp_max = answer[j]\n answer[i] = temp_max + 1\n \nprint(max(answer))\n "}, {"source_code": "n=int(input())\ns=[int(a) for a in input().split()]\ni=n-1\nx=0\ny=0\nwhile i>=0 and s[i]==1:\n i-=1\nwhile i > -1:\n if s[i]==1:\n x+=1\n i-=1\ni=0\nwhile i a:\n a = aaa\nprint(a)"}, {"source_code": "n,l=input(),input()\nprint(max(l.count('0'),l.count('1')))\n\n"}, {"source_code": "n = int(input())\nres = list(map(int, input().split()))\nans = []\n\nfor i in range(len(res)):\n if res[i] == 0 and res[i:].count(0) > res[i:].count(1):\n ans.append(0)\n if res[i] == 1 and res[i:].count(1) > res[i:].count(0):\n ans.append(1)\nif res[-1] == 1: ans.append(1)\nprint(len(ans))\n"}, {"source_code": "T = input()\nn = map(int, raw_input().split())\ncount = 1\nfor y in range(1,T):\n if(n[y-1] == 1 and n[y]==0):\n pass\n else:\n count += 1\nprint count,\n"}, {"source_code": "n = int(input())\narr = list(map(int, input().split()))\nans = 0\nz = arr.count(0)\no = arr.count(1)\ni = n - 1\nif n == 1:\n print(arr[0])\n exit()\nif z == n:\n print(z)\n exit()\nwhile arr[i] == 1 and i >= 0:\n i -= 1\n ans += 1\n o -= 1\nbeg = -1\nfor j in range(n):\n if arr[j] == 0:\n ans += 1\n z -= 1\n else:\n beg = j - 1\n break\nwhile i > beg:\n #print(i, o, z, ans)\n if o > z:\n while arr[i] == 0 and i > beg:\n z -= 1\n i -= 1\n while arr[i] == 1 and i > beg:\n o -= 1\n i -= 1\n #print('!', i, o, z, ans + 1)\n ans += 1\n else:\n #print(i + 1)\n while arr[i] == 0 and i > beg:\n z -= 1\n i -= 1\n ans += 1\n while arr[i] == 1 and i > beg:\n o -= 1\n i -= 1\nprint(ans)"}, {"source_code": "n=input()\ns=raw_input().split()\ncnt=0\ncnt1=0\nans=-1\nfor i in range(n):\n cnt=0\n for j in range(i):\n if int(s[j])==0:cnt+=1\n for j in range(i,n):\n if int(s[j])==1: cnt+=1\n ans=max(cnt,ans)\nprint ans"}, {"source_code": "n = int(raw_input().strip())\na = map(int, raw_input().strip().split(\" \"))\nbest = [[0 for j in xrange(2)] for i in xrange(n)]\nif a[0] == 0:\n best[0][0] = 1\nelse:\n best[0][1] = 1\nfor i in xrange(1, n):\n if a[i] == 0:\n best[i][0] = best[i - 1][0] + 1\n best[i][1] = best[i - 1][1]\n else:\n best[i][0] = best[i - 1][0]\n best[i][1] = best[i - 1][1] + 1\nprint max(best[n - 1])\n"}, {"source_code": "n=int(input())\ns=[int(a) for a in input().split()]\nans = 0\nfor i in range(n):\n g = 0\n for j in range(i):\n if s[j]==0:\n g+=1\n for j in range(i,n):\n if s[j]==1:\n g+=1\n if g > ans:\n ans = g\nprint(ans)\n\n'''\ni=n-1\nx=0\ny=0\nwhile i>=0 and s[i]==1:\n i-=1\nwhile i > -1:\n if s[i]==1:\n x+=1\n i-=1\ni=0\nwhile i 0 and s[j2] == 1:\n ans2 += 1\n j2 -= 1\n\nctr0 = 0\nctr1 = 0\n\nfor i in range(j1, j2+1):\n if s[i] == 0:\n ctr0 += 1\n else:\n ctr1 += 1\n\nif ctr0 >= ctr1 and (ans2 > 0) :\n ans += ctr0 \n ans += ans2\nelse:\n ans += ctr1 \n ans += ans2\n \nprint(ans)\n\n "}, {"source_code": "from sys import stdin, stdout\n\nn = int(stdin.readline())\nvalues = list(map(int, stdin.readline().split()))\ndp = [[0, 0] for i in range(n)]\n\nfor i in range(n):\n if not values[i]:\n dp[i][0] = 1\n \n for j in range(i - 1, -1, -1):\n dp[i][0] = max(dp[i][0], dp[j][0] + 1)\n else:\n dp[i][1] = 1\n \n for j in range(i - 1, -1, -1):\n dp[i][1] = max(dp[i][1], max(dp[j]) + 1)\n\nstdout.write(str(max(dp[-1])))"}, {"source_code": "\"\"\"\nCodeforces Round #334 (Div. 2)\n\nProblem 846 A. Curriculum Vitae\n\n@author yamaton\n@date 2017-09-13\n\"\"\"\n\nimport itertools as it\nimport functools\nimport operator\nimport collections\nimport math\nimport sys\n\n\ndef solve(xs):\n return 1 + sum(1 for (i, j) in zip(xs, xs[1:]) if (i, j) != (1, 0))\n\n\n# def pp(*args, **kwargs):\n# return print(*args, file=sys.stderr, **kwargs)\n\n\ndef main():\n n = int(input())\n xs = [int(c) for c in input().split()]\n assert len(xs) == n\n result = solve(xs)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "N = int(input())\nA = list(map(int, input().split()))\n\nans = -1\nfor i in range(N):\n if A[i] == 1:\n pref = sum(1 for x in A[:i] if x == 0)\n suff = sum(1 for x in A[i:] if x == 1)\n ans = max(ans, pref + suff)\n\nans = N if ans == -1 else ans\nprint(ans)"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nprint(max([s[:i].count(1) + s[i:].count(0) for i in range(len(s) + 1)]))"}, {"source_code": "#Bhargey Mehta (Sophomore)\n#DA-IICT, Gandhinagar\nimport sys, math, queue, bisect\n#sys.stdin = open(\"input.txt\", \"r\")\nMOD = 10**9+7\nsys.setrecursionlimit(1000000)\n\nn = int(input())\nans = n\na = list(map(int, input().split()))\nfor i in range(1, n):\n if a[i] == 0 and a[i-1] == 1:\n ans -= 1\nprint(ans)"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nfz = 0\nwhile len(a) > 0 and a[0] == 0:\n fz += 1\n a = a[1:]\nmans = [0]\no = a.count(1)\nfor i in range(o):\n q = 0\n j = 0\n z = 0\n while j < len(a) and q <= i:\n if j == 1:\n q += 1\n else:\n z += 1\n q += 1\n mans.append(o + z - i)\nprint(fz + max(mans))"}, {"source_code": "import sys\nfrom collections import Counter\nn = int(input())\na = ''.join(input().split())\ni = 0\nk = 0\ns,e = 0,0\nwhile i < n and a[i] == '0':\n k += 1\n i += 1\ns = i\ni = n-1\nwhile i >= 0 and a[i] == '1':\n k += 1\n i -= 1\ne = i+1\nd = Counter(a[s:e])\nprint(k+max(d['0'],d['1']))\n \n"}, {"source_code": "length = int(input())\narray = list(map(int, input().split()))\n\nindex = 0\nwhile(array[index] == 0):\n index += 1\n\n if index == length:\n break\n\nprint(max(array[index:].count(1), array.count(0)))\n"}], "src_uid": "c7b1f0b40e310f99936d1c33e4816b95"} {"nl": {"description": "\u0422\u0440\u0438 \u0431\u0440\u0430\u0442\u0430 \u0434\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043b\u0438\u0441\u044c \u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0435. \u041f\u0440\u043e\u043d\u0443\u043c\u0435\u0440\u0443\u0435\u043c \u0431\u0440\u0430\u0442\u044c\u0435\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u043f\u0443\u0441\u0442\u044c \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u0440\u0430\u0442 \u0438\u043c\u0435\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 1, \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u0431\u0440\u0430\u0442 \u0438\u043c\u0435\u0435\u0442 \u043d\u043e\u043c\u0435\u0440 2, \u0430 \u043c\u043b\u0430\u0434\u0448\u0438\u0439 \u0431\u0440\u0430\u0442\u00a0\u2014 \u043d\u043e\u043c\u0435\u0440 3. \u041a\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u0441\u0442\u0440\u0435\u0447\u0438, \u043e\u0434\u0438\u043d \u0438\u0437 \u0431\u0440\u0430\u0442\u044c\u0435\u0432 \u043e\u043f\u043e\u0437\u0434\u0430\u043b. \u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u0430\u043c \u0434\u0432\u0443\u0445 \u0431\u0440\u0430\u0442\u044c\u0435\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u0432\u043e\u0432\u0440\u0435\u043c\u044f, \u0432\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u043e\u043c\u0435\u0440 \u043e\u043f\u043e\u0437\u0434\u0430\u0432\u0448\u0435\u0433\u043e \u0431\u0440\u0430\u0442\u0430.", "input_spec": "\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0434\u0432\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 a \u0438 b (1\u2009\u2264\u2009a,\u2009b\u2009\u2264\u20093, a\u2009\u2260\u2009b)\u00a0\u2014 \u043d\u043e\u043c\u0435\u0440\u0430 \u0431\u0440\u0430\u0442\u044c\u0435\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0438\u0448\u043b\u0438 \u043d\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0443 \u0432\u043e\u0432\u0440\u0435\u043c\u044f. \u041d\u043e\u043c\u0435\u0440\u0430 \u0434\u0430\u043d\u044b \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.", "output_spec": "\u0412\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\u00a0\u2014 \u043d\u043e\u043c\u0435\u0440 \u0431\u0440\u0430\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043f\u043e\u0437\u0434\u0430\u043b \u043d\u0430 \u0432\u0441\u0442\u0440\u0435\u0447\u0443.", "sample_inputs": ["3 1"], "sample_outputs": ["2"], "notes": null}, "positive_code": [{"source_code": "a, b = map(int, input().split())\nfor i in range(1, 4):\n if (i != a and i != b):\n print(i)\n break"}, {"source_code": "m,n = map(int,input().split())\nif (m + n) != 3:\n print(abs(m-n))\nelse:\n print(m+n)\n"}, {"source_code": "a, b = map(int, input().split())\nif a != 1 and b!= 1:\n print(1)\nelif a != 2 and b != 2:\n print(2)\nelse:\n print(3)"}, {"source_code": "a, b = map(int, input().split())\nprint(6//(a*b))"}, {"source_code": "print(6-sum(map(int,input().split())))"}, {"source_code": "inp=input()\nprint(6-int(inp[0])-int(inp[2]))\n"}, {"source_code": "a,b=map(int,input().split())\nprint(6-a-b)\n"}, {"source_code": "s = 6\nx1, x2 = input().split()\nx1, x2 = int(x1), int(x2)\nprint(s-x1-x2)"}, {"source_code": "a, b = input().split()\nif int(a)+int(b)==3:\n print('3')\nif int(a)+int(b)==4:\n print('2')\nif int(a)+int(b)==5:\n print('1')"}, {"source_code": "a , b = input().split()\nprint( 6 - (int(a) + int(b)) )\n"}, {"source_code": "s1 = [int(x) for x in input().split()]\ns2 = (1,2,3)\nfor i in s2:\n if i not in s1:\n print(i)\n"}, {"source_code": "a = {1,2,3}\nx = set(map(int,input().split()))\nb = list(a-x)\nprint(b[0])"}, {"source_code": "a, b = map(int, input().split())\nprint(a ^ b)"}, {"source_code": "n,m = map(int,input().split(' '));print(6-(m+n));"}, {"source_code": "cH = input()\na, b = map(int, cH.split())\nc = 6 - a - b\nprint(c)"}, {"source_code": "print(6 - sum(map(int, input().split())))"}, {"source_code": "a, b = map(int, input().split())\n\nprint(sum(i for i in range(1, 4) if i not in (a, b)))"}, {"source_code": "print(*{'1','2','3'}.difference(set(input().split())))\n"}, {"source_code": "a, b=list(map(int, input().split()))\nq=list({1, 2, 3}-{a, b})[0]\nprint(q)"}, {"source_code": "print(*{1, 2, 3} - set(map(int, input().split())))"}, {"source_code": "print(6 - sum(map(int, input().split())))"}, {"source_code": "print(6 - sum(list(map(int, input().split()))))"}, {"source_code": "inp = list(map(int,input().split(\" \")))\nprint(6-sum(inp))"}, {"source_code": "bros = set(map(lambda x: x+1, range(3)))\n\na, b = map(lambda x: int(x), input().split())\nbros.remove(a)\nbros.remove(b)\nprint(bros.pop())"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\nc=None\nif a==1 and b==2:\n c=3\n print(c)\nif a==2 and b==1:\n c=3\n print(c)\nif a==3 and b==2:\n c=1\n print(c)\nif a==2 and b==3:\n c=1\n print(c)\nif a==1 and b==3:\n c=2\n print(c)\nif a==3 and b==1:\n c=2\n print(c)"}, {"source_code": "print(6 - sum(list(map(int, input().split()))))"}, {"source_code": "a,b=map(int,input().split())\nprint(6-a-b)\n"}, {"source_code": "# encoding: utf-8\na = input()\nb = []\nb = a.split(' ')\nn = 0\nfor x in b:\n b[n] = int(x)\n n += 1\na = b[1] + b[0]\nif a == 4:\n print('2')\nelif a == 3:\n print('3')\nelse:\n print('1')"}, {"source_code": "a, b = map(int, input().split())\nif a == 1 and b == 2 or a == 2 and b == 1:\n print(3)\nelif a == 3 and b == 1 or a == 1 and b == 3 :\n print(2)\nelif a == 2 and b == 3 or a == 3 and b == 2 :\n print(1)\nelse :\n print(0)"}, {"source_code": "inStr = input()\na,b=inStr.split()\nprint(6-int(a)-int(b))\n"}, {"source_code": "n,k=(int(z) for z in input().split())\nprint(6-n-k)"}, {"source_code": "a, b = map(int, input().split())\n\nif a == 1:\n if b == 2:\n print(3)\n else:\n print(2)\nelif a == 2:\n if b == 1:\n print(3)\n else:\n print(1)\nelse:\n if b == 1:\n print(2)\n else:\n print(1)\n"}, {"source_code": "a = [0,0,0]\ninp = input()\ninp = inp.split()\na[int(inp[0]) - 1] += 1\na[int(inp[1]) - 1] += 1\nfor i in range(len(a)):\n if a[i] == 0:\n print(i + 1)\n"}, {"source_code": "s = input()\nids = s.split(' ')\nnormal_ids = ['1','2','3']\nnormal_ids.remove(ids[0])\nnormal_ids.remove(ids[1])\nprint(normal_ids[0])"}, {"source_code": "a, b = map(int, input().split())\nprint(6 - a - b)"}, {"source_code": "s = input().split()\na = s[0]\nb = s[1]\nif a=='1' and b=='2':\n c = 3\nelif a=='1' and b=='3':\n c = 2\nelif a=='2' and b=='1':\n c = 3\nelif a=='2' and b=='3':\n c = 1\nelif a=='3' and b=='1':\n c = 2\nelif a=='3' and b=='2':\n c = 1\nprint(c)"}, {"source_code": "a, b = input().split()\na = int(a)\nb = int(b)\nc = 6- (a+b)\nprint(c)\n "}, {"source_code": "a, b = map(int, input().split())\nA = [a, b]\nif not(1 in A):\n print(1)\nelif not(2 in A):\n print(2)\nelse:\n print(3) "}, {"source_code": "print(6-sum(list(map(int,input().split()))))"}, {"source_code": "a,b=map(int,input().split())\nprint(6-(a+b))"}, {"source_code": "s=[1,2,3]\na,b=map(int,input().split())\ns.remove(a)\ns.remove(b)\nprint(*s)\n"}, {"source_code": "a, b = map(int, input().split())\nprint(6 - a - b)"}, {"source_code": "a, b = set(map(int, input().split()))\nprint(*({1, 2, 3} ^ {a, b}))\n"}, {"source_code": "a = [int(i) for i in input().split()]\nprint(6-a[0]-a[1])\n"}, {"source_code": "print(*set(\"123\")-set(input()))"}, {"source_code": "a,b = input().split()\nprint(6-int(a)-int(b))\n"}, {"source_code": "k = {1, 2, 3}\nr = set([int(s) for s in input().split()])\nprint(*(k-r))\n"}, {"source_code": "a=set(map(int,input().split()))\nb=()\nfor i in range(1,4):\n if i not in a:\n print(i)\n"}, {"source_code": "a, b = map(int, input().split())\nfor i in range(1, 4):\n if(i != a and i != b):\n print (i)"}, {"source_code": "A = {1, 2, 3}\nB = set (map (int, input().split()))\nprint(*A.difference(B))"}, {"source_code": "pr = [str(i) for i in input().split()];\nbro = [\"1\",\"2\",\"3\"];\nbro.remove(pr[0]);\nbro.remove(pr[1]);\nprint(bro[0]);"}, {"source_code": "a,b=map(int,input().split())\nc=6-a-b\nprint(c)\n"}, {"source_code": "a, b = map(int, input().split())\nprint(6 - a - b)"}, {"source_code": "a,b = input().split(' ')\nprint(str(int(a) ^ int(b)))"}, {"source_code": "a, b = map(int,input().split())\nprint(6-a-b)"}, {"source_code": "print(6 - sum(list(map(int, input().split()))))\n"}, {"source_code": "a,b=[int(i) for i in input().split()]\nprint(6-a-b)\n"}, {"source_code": "print(list({1, 2, 3}.difference({int(i) for i in input().split()}))[0])"}, {"source_code": "a = {1, 2, 3} - set(map(int, input().split()))\nfor elem in a: print(elem)"}, {"source_code": "a,b = map(int,input().split())\nc = []\nc.append(a)\nc.append(b)\nc.sort()\nif c[0] == 1 and c[1]==2:\n print('3')\nelif c[0] ==1 and c[1] == 3:\n print('2')\nelif c[0] ==2 and c[1] == 3:\n print('1')\n"}, {"source_code": "a, b = list (map(int,input().split()))\nif (a==1 or b==1) and (a==2 or b==2):\n print (3)\nelif (a==1 or b==1) and (a==3 or b==3):\n print (2)\nelse:\n print(1)\n"}, {"source_code": "print(6 - sum(map(int, input().split())))"}, {"source_code": "a, b = list(map(int, input().split()))\n\nprint(6 - a - b)"}, {"source_code": "x = input()\nif x.find('1') == -1:\n print(1)\nif x.find('2') == -1:\n print(2)\nif x.find('3') == -1:\n print(3)\n"}, {"source_code": "a,b = map(int, input().split())\nc = a + b\nif c == 3:\n print(3)\nelif c == 4:\n print(2)\nelif c == 5:\n print(1)"}, {"source_code": "l = list(map(int, input().split()))\nif 1 not in l:\n print(1)\nif 2 not in l:\n print(2)\nif 3 not in l:\n print(3)"}, {"source_code": "a = input('')\nif (a == '2 1') or (a == '1 2'):\n print('3')\nif (a == '2 3') or (a == '3 2'):\n print('1')\nif (a == '1 3') or (a == '3 1'):\n print('2')"}, {"source_code": "ind = map(int,raw_input().split(' '))\nmas = [1,2,3]\nfor i in mas:\n if i not in ind:\n print i\n break\n"}, {"source_code": "a,b = map(int, raw_input().split(' '))\nprint(6-a-b)"}, {"source_code": "ab = raw_input(\"\").split(' ')\n\nc = 6 - int(ab[0]) - int(ab[1])\nprint(`c`)"}, {"source_code": "a, b = map(int, raw_input().split(\" \")[0:2])\nfor i in range(1, 4):\n if i != a and i != b : print i"}, {"source_code": "def read_ints():\n return [int(x) for x in input(' ').split()]\n\n\ndef main():\n a, b = read_ints()\n print(({1, 2, 3}.difference({a, b})).pop())\n\nif __name__ == '__main__':\n main()"}, {"source_code": "a, b = list(map(int,input().split()))\n\ns = a + b\nc = 6\nprint(c-s)\n\n"}, {"source_code": "a, b = map(int, input().split())\np = [1, 2, 3]\np.remove(a)\np.remove(b)\nprint(p[0])\n"}, {"source_code": "a, b = map(int, input().split())\nnumbers = 3+2+1\nc = numbers - a - b\nprint(c)\n"}, {"source_code": "print(6 - sum(list(map(int, input().split()))))\n"}, {"source_code": "print(6 - sum(list(map(int, input().split()))))"}, {"source_code": "print(6 - sum([int(i) for i in input().split()]))"}, {"source_code": "a, b = [int(x) for x in input().split()]\nfor i in range(1, 4):\n if i != a and i != b:\n print(i)"}, {"source_code": "brat = [1, 2, 3]\na, b = (int(i) for i in input().split())\nbrat.remove(a)\nbrat.remove(b)\nprint(brat[0])"}, {"source_code": "v=input()\na=int(v[0])\nb=int(v[2])\nprint(6-a-b)\n"}, {"source_code": "a = ['1', '2', '3']\nx, y = input().split()\nfor i in range(3):\n if (a[i] != x) and (a[i] != y):\n z = a[i]\nprint(z)"}, {"source_code": "print(str(6 - sum(map(int, input().split()))))\n"}, {"source_code": "a,b=map(int,input().split())\nprint(6-a-b)"}], "negative_code": [{"source_code": "s1 = (int(x) for x in input().split())\ns2 = (1,2,3)\nfor i in s2:\n if i not in s1:\n print(i)\n"}, {"source_code": "a = input('HOMEPA 6PATbEB\\n')\nb = []\nb = a.split(' ')\nn = 0\nfor x in b:\n b[n] = int(x)\n n += 1\na = b[1] + b[0]\nif a == 4:\n print('2')\nelif a == 3:\n print('3')\nelse:\n print('1')"}, {"source_code": "s = input().split()\na = s[0]\nb = s[1]\nif a=='1' and b=='2':\n c = 3\nelif a=='1' and b=='3':\n c = 2\nelif a=='2' and b=='1':\n c = 3\nelif a=='2' and b=='3':\n c = 2\nelif a=='3' and b=='1':\n c = 2\nelif a=='3' and b=='2':\n c = 1\nprint(c)"}, {"source_code": "s = input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\na = s[0]\nb = s[1]\nif a==1 and b==2:\n c = 3\nelif a==1 and b==3:\n c = 2\nelif a==2 and b==1:\n c = 3\nelif a==2 and b==3:\n c = 2\nelif a==3 and b==1:\n c = 2\nelif a==3 and b==2:\n c = 1\nprint(c)"}, {"source_code": "s = input().split()\nfor i in range(len(s)):\n s[i] = int(s[i])\na = s[0]\nb = s[1]\nif a==1 and b==2:\n c = 3\nelif a==1 and b==3:\n c = 2\nelif a==2 and b==1:\n c = 3\nelif a==2 and b==3:\n c = 2\nelif a==3 and b==1:\n c = 2\nelif a==3 and b==2:\n c = 1\nelif a==b:\n c = 0\nprint(c)"}], "src_uid": "e167dc35a0d3b98c0414c66099e35920"} {"nl": {"description": "You are given two integer numbers, $$$n$$$ and $$$x$$$. You may perform several operations with the integer $$$x$$$.Each operation you perform is the following one: choose any digit $$$y$$$ that occurs in the decimal representation of $$$x$$$ at least once, and replace $$$x$$$ by $$$x \\cdot y$$$.You want to make the length of decimal representation of $$$x$$$ (without leading zeroes) equal to $$$n$$$. What is the minimum number of operations required to do that?", "input_spec": "The only line of the input contains two integers $$$n$$$ and $$$x$$$ ($$$2 \\le n \\le 19$$$; $$$1 \\le x < 10^{n-1}$$$).", "output_spec": "Print one integer \u2014 the minimum number of operations required to make the length of decimal representation of $$$x$$$ (without leading zeroes) equal to $$$n$$$, or $$$-1$$$ if it is impossible.", "sample_inputs": ["2 1", "3 2", "13 42"], "sample_outputs": ["-1", "4", "12"], "notes": "NoteIn the second example, the following sequence of operations achieves the goal: multiply $$$x$$$ by $$$2$$$, so $$$x = 2 \\cdot 2 = 4$$$; multiply $$$x$$$ by $$$4$$$, so $$$x = 4 \\cdot 4 = 16$$$; multiply $$$x$$$ by $$$6$$$, so $$$x = 16 \\cdot 6 = 96$$$; multiply $$$x$$$ by $$$9$$$, so $$$x = 96 \\cdot 9 = 864$$$. "}, "positive_code": [{"source_code": "def element(x):\r\n se = set()\r\n while x:\r\n se.add(x%10)\r\n x//=10\r\n return se\r\n \r\nn,x = map(int,input().split())\r\nif n=n:\r\n ans = min(ans,dic[ele]+1)\r\n cond = False\r\n break\r\n \r\n dic_2[se*ele] = dic[ele]+1\r\n if cond==False:\r\n break\r\n \r\n if cond==False:\r\n break\r\n dic = dic_2\r\n if ans==10**20:\r\n print(-1)\r\n else:\r\n print(ans)"}, {"source_code": "l = list(map(int, input().split()))\r\nn = l[0]\r\nx = l[1]\r\nq = [x]\r\ntimes = 0\r\nopre = {}\r\nopre[x] = 0\r\nresult=-1\r\nwhile len(q) > 0:\r\n x = q.pop(0)\r\n str_x = str(x)\r\n if len(str_x) == n:\r\n result = opre[x]\r\n break\r\n for digit in str_x:\r\n new_number = int(digit) * x\r\n if new_number not in opre:\r\n q.append(new_number)\r\n opre[new_number] = opre[x] + 1\r\nprint(result)\r\n"}, {"source_code": "n,x = [int(x) for x in input().split()]\r\n\r\nq = []\r\nd = {}\r\nd[x] = 0\r\nq.append(x)\r\n\r\nwhile len(q) > 0:\r\n x = q.pop(0)\r\n s = str(x)\r\n if len(s) == n:\r\n print(d[x])\r\n break\r\n \r\n for i in s:\r\n if i == '0':\r\n continue\r\n else:\r\n val = x * int(i)\r\n if val not in d:\r\n q.append(val)\r\n d[val] = d[x] + 1\r\nelse:\r\n print(-1)\r\n"}, {"source_code": "\r\n# import sys\r\n# sys.stdin = open('in.txt', 'r')\r\n# sys.stdout = open('out.txt', 'w')\r\n\r\n\r\n\r\nn,x = [int(x) for x in input().split()]\r\ndp = {}\r\ndef solve(s):\r\n if(len(s) == n): \r\n return 0\r\n\r\n val = int(s)\r\n \r\n if(val in dp):\r\n return dp[val]\r\n \r\n N = len(s)\r\n ans = 10**15;\r\n for i in range(0, N):\r\n if(s[i] == '0' or s[i] == '1'):\r\n continue\r\n temp = str(val*int(s[i]));\r\n ans = min(ans, 1+solve(temp));\r\n\r\n dp[val] = ans\r\n return dp[val];\r\nx = str(x)\r\nans = solve(x)\r\nif ans >= 10**15:\r\n ans = -1\r\nprint(ans)"}, {"source_code": "\ndef solve(n, x):\n q, dist = [], {}\n dist[x] = 0\n q.insert(0, x)\n while q != []:\n k = q.pop()\n s = str(k)\n if len(s) == n:\n return dist[k]\n for x in s:\n if x != '0':\n w = k * int(ord(x) - ord('0'))\n if dist.get(w) == None:\n dist[w] = dist[k]+1\n q.insert(0, w)\n return -1\n\n\nif __name__ == '__main__':\n n, x = list(map(int, input().split()))\n print(solve(n, x))\n"}, {"source_code": "# Problem: D. Required Length\r\n# Contest: Codeforces - Educational Codeforces Round 129 (Rated for Div. 2)\r\n# URL: https://codeforces.com/problemset/problem/1681/D\r\n# Memory Limit: 512 MB\r\n# Time Limit: 2000 ms\r\n# \r\n# Powered by CP Editor (https://cpeditor.org)\r\nfrom collections import *\r\nfor _ in range(1):\r\n\tn,m=map(int,input().split())\r\n\tz=deque([[m,0]])\r\n\tvis=Counter([])\r\n\tans=-1\r\n\twhile(z):\r\n\t\tx=z.popleft()\r\n\t\ta=str(x[0])\r\n\t\tif(len(a)==n):\r\n\t\t\tans=x[1]\r\n\t\t\tbreak\r\n\t\tfor j in range(len(a)):\r\n\t\t\tp=int(a[j])*int(a)\r\n\t\t\tif(vis[p]==0):\r\n\t\t\t\tz.append([p,x[1]+1])\r\n\t\t\t\tvis[p]=1\r\n\tprint(ans)"}, {"source_code": "import sys\r\nfrom functools import lru_cache\r\ninf=float('inf')\r\nn,x=[int(i) for i in input().split()]\r\nlow=10**(n-1)\r\nhigh=10**n\r\n@lru_cache(None)\r\ndef fun(x,n):\r\n s=set(str(x))\r\n if len(s)==1 and '1' in s:\r\n return inf\r\n ans=inf\r\n \r\n for i in s:\r\n i=int(i)\r\n if low<=x=2:\r\n ans=min(ans,1+fun(x*i,n))\r\n return ans\r\nans=fun(x,n)\r\nif ans==inf:\r\n print(-1)\r\nelse:\r\n print(ans)\r\n "}, {"source_code": "from functools import lru_cache \r\nn,x = list(map(int,input().split()))\r\n \r\n@lru_cache(maxsize=None)\r\ndef dp(nn,xx):\r\n\ty = str(xx)\r\n\tif len(y)==nn:\r\n\t\treturn 0 \r\n\tres = 1e9 \r\n\tfor j in y:\r\n\t\tif int(j)>1:\r\n\t\t\tres = min(res,1 + dp(nn,xx*int(j)))\r\n\treturn res \r\n \r\nres = dp(n,x)\r\nif res>=1e9:\r\n\tprint(-1)\r\nelse:\r\n\tprint(res)"}, {"source_code": "from collections import deque\r\nn,x = map(int,input().split(' '))\r\n\r\nq = deque()\r\nq.append(x)\r\ndist = {x: 0}\r\nans = -1\r\nwhile len(q) > 0:\r\n num = q.popleft()\r\n s = str(num)\r\n if len(s)==n:\r\n ans = dist[num]\r\n break\r\n for d in range(2,10):\r\n if str(d) in s:\r\n num2 = num*d\r\n if num2 not in dist:\r\n dist[num2] = dist[num]+1\r\n q.append(num2)\r\nprint(ans)"}, {"source_code": "import sys\n\n\ndef play_card_Afirst(A,B):\n if max(A)>=max(B):\n return 'Alice'\n else:\n return 'Bob'\ndef play_card_Bfirst(A,B):\n if max(B)>= max(A):\n return 'Bob'\n return 'Alice'\n\ndef shuffle(va, n, vb):\n return va[sum(vb)%n]\n\ndef double_sort(A,B,n):\n tAB = list(zip(A,B))\n# print(tAB)\n sort_rank = sorted(enumerate(tAB), key=lambda x:x[1])\n for (_,x),(_,y) in zip(sort_rank[:-1],sort_rank[1:]):\n# print(x,y)\n if (x[0]-y[0])*(x[1]-y[1])<0:\n print(-1)\n return\n l = [x[1][0] for x in sort_rank]\n assert(all(l[i] <= l[i+1] for i in range(len(l) - 1)))\n l = [x[1][1] for x in sort_rank]\n assert(all(l[i] <= l[i+1] for i in range(len(l) - 1)))\n swaps = []\n now_loc = list(range(n))\n now_value = list(range(n))\n for i,(after,_) in enumerate(sort_rank):\n LocJ = now_loc[after]\n if LocJ!=i:\n valueI = now_value[i]\n swaps.append((LocJ,i))\n now_loc[after] = i\n now_loc[valueI] = LocJ\n now_value[i] = after\n now_value[LocJ] = valueI\n print(len(swaps))\n for x,y in swaps:\n print(x+1,y+1)\ncache = {}\ndef RL(x,n):\n if x in cache.keys():\n return cache[x]\n digits = list(str(x))\n if len(digits)>n:\n return float('inf')\n minD = int(min([k for k in digits if k != '0']))\n maxD = int(max(digits))\n if len(digits) == n :\n return 0\n if maxD == 1:\n return float('inf') \n cache[x] = 1+min([RL(x*b,n) for b in [int(k) for k in digits if k not in '01']])\n return cache[x]\n\n \nn,x = [int(x) for x in sys.stdin.readline().split()]\nresult = RL(x,n)\nif result == float('inf'):\n print(-1)\nelse:\n print (result)\n'''\nr = int(sys.stdin.readline())\nfor j in range(r):\n n = int(sys.stdin.readline())\n A = [int(x) for x in sys.stdin.readline().split()]\n B = [int(x) for x in sys.stdin.readline().split()]\n print(double_sort(A,B,n))'''\n"}, {"source_code": "import queue\r\ndef solve():\r\n n, st = map(int, input().split())\r\n qu = queue.Queue()\r\n if len(str(st)) < n:\r\n qu.put((st, 0))\r\n elif len(str(st)) == n:\r\n print(0)\r\n return\r\n else:\r\n print(-1)\r\n return\r\n vis = set()\r\n happyEnd = False\r\n ans = -1\r\n \r\n while qu.qsize():\r\n x, cnt = qu.get()\r\n if x in vis:continue\r\n vis.add(x)\r\n df = x\r\n a = set(map(int,list(str(x))))\r\n for digit in a:\r\n if digit<=1:continue\r\n nxt = df *digit;\r\n if nxt in vis:\r\n continue\r\n nLen = len(str(nxt))\r\n if nLen == n:\r\n if not happyEnd:\r\n happyEnd = True\r\n ans = cnt + 1\r\n else:\r\n ans = min(ans, cnt+1)\r\n elif nLen > n:\r\n continue\r\n qu.put((nxt, cnt+1))\r\n \r\n if happyEnd:\r\n print(ans)\r\n else:\r\n print(-1)\r\nsolve()"}, {"source_code": "# &&&&&&&&YPP#&&&&&&&&&&&&&&&&##&&&&&B5B@@@@@@@@@@&!&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&G^#@@@@@@#5&&&&P&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@&J&&&&##&&&&&&&&GB&&&G&&&&&&&&\r\n# &&&&&&&B5Y##&&&&&&&&&&&&&&&&B5##&&&&#?!B&&@&&&&&&&B7&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&5!&@@@@@@@P&&&&P&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@#J&&&##&&&&&&&&&&P&&&&&&&&\r\n# &&&&&&&G?G#&&&&&&&&&&&&&&&&PJ#&&&&&5. .:~7JPBB#G7&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&Y5@@@@@@@@B#&&&P@@@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&@&@@#&@@PJ&&&##&&&&&&&&5B&&P#&&&&&&&\r\n# &&&&&&&55#&&&&&&&&&&&&&&&&5J##&&&5: ..~#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#Y#@@@@@@@@&G&&&P#&#&&&&&&&&@@@@@@@@@@@@@@@@@@@&&&&&###BB5#&&7Y&&##&&&&&&&&#G&&GB&&&&&&&\r\n# &&&&&&#YB#&&&&&&&&&&&&&&&5P&&&&Y^. ~#&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP@@@@@@@@@&Y&&#P&&&&&&&@@&&&&&BBG5JJ7!~~^:::.......... ... P&&##&&&&&&&&Y#&GP&&&&&&&\r\n# &&&&&&B5#&&&&&&&&&&&&&&#YG&&&G~ .:. . ~7P&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&P#@@@@@@@@@@J#&BP@@@@@&&&BPY?~:. G&#B#&&&&&&&5P&#P&&&&&&&\r\n# &&&&&&JP&&&&&&&&&&&&&&BY#&&P: . ^: ... .#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP&@@@@@@@@@@YB@G5@@@@@GPY?!~. . G&BB&&&&&&&&5&&&&&&&\r\n# &&&&&&7#&&&&&&&&&&&&&GY&&5^ .^::.....^55!:..~B&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&PB@@@@@@@@@@@GG@PP@@@@@&&&#GPP?!!?JYG#&#^ ::.^:.:. . ..:.. :7G&G#&&&&&&&J#&Y#&&&&&&\r\n# &&&&&BY&&&&&&&&&&&&&PP#5?YJJ?!75J7?!JJ#&B5JP&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP&@@@@@@@@@@@GG&YB@@@@@@@@&#B###&@@@@@@@Y.:::~!!!!^:. . .^....:. . :P&G#&&&&&&GG&5B&&&&&&\r\n# &&&&&GP&&&&&&&&&&&&?YGP#&&&&&&#B#B#B####GYB&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#P#@@@@@@@@@@@@BP&P&@@@@@@@@&&@@@@@@@@@@@@@77??Y5YJJPY~~^:.. .~~!!~^.:^. ^?PBB&&&&&&PG&&&&&&\r\n# &&&&&G#&&&&&&&&&&#~7?PGP&@@@@@@@@@@@@@@BG&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&PP@@@@@@@@@@@@@#BBG@@@@@@@@@@@@@@@@@@@@@@@@@&&@&BGBBGGP5PYYJ7!!^!#GY?!~^^7^ 5@YYP#&&&&&&5BG5&&&&&&\r\n# &&&&&P&&&&&&&&&&5^!YP~::^!JG##&@&&@@@BG#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BP&@@@@@@@@@@@@@BGPB@@@@@@@@@@@@@@@@@@@@@@@@@@^:?#&&&&&&&####PPPPBBBGBP5P57: !@@@P7Y&#&&&&GPGY&&&&&&\r\n# &&&&#B&&&&&&&&#JYY!JPB#&&&&&Y5&@&B&#G#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BY#@@@@@@@@@@@@@@PYY&@@@@@@@@@@@@@@@@@@@@@&&#G5GP. ^?P#@@@@@@@@@@@&&&&&&#BP?. 5@@@@B..P&&&&BY&&&&&&\r\n# &&&&##&&&&&&&G?&@@@@@@@@@@@@&@@@&BB#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#PB@@@@@@@@@@@@@@@PYP@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@P&BPYYP&&&&&@@@@@@@&#BP?^. !7Y5J!^~~:G&&&&&PGJ#&&&&&\r\n# &&&&&&&&&&&&55@@@@@@@@@@@@@@@@&BB&&&&&&&&&&#&&&&&&&&&&&&&&&&&&&&&&#GB@@@@@@@@@@@@@@@#?Y&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#@@@@#G#@@@&GJ?YP5YYYJ?!.7Y55J?PJB&&&&BP?B&&&&&\r\n# &&&&&&&&&#@@@@@@@@@@@@@@@BPB&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#PG@@@@@@@@@@@@@@@@G7B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@#G&@@@@@@@#J#@@@@@@5P&&&&G7B&&&&&\r\n\r\nimport sys, os\r\nfrom io import BytesIO, IOBase\r\n\r\nfrom math import gcd\r\nfrom collections import deque, defaultdict, Counter\r\n\r\ndef re(data=str): return data(sys.stdin.readline().rstrip())\r\ndef mp(data=str): return map(data, sys.stdin.readline().split())\r\n\r\ndef solve():\r\n n, x = mp(int)\r\n seen = dict()\r\n seen[x] = 0\r\n Q = deque([x])\r\n\r\n while Q:\r\n k = Q.popleft()\r\n \r\n s = str(k)\r\n\r\n if len(s) == n:\r\n print(seen[k])\r\n return\r\n \r\n for d in s:\r\n nx = int(d) * k\r\n if nx not in seen:\r\n seen[nx] = seen[k] + 1\r\n Q.append(nx)\r\n\r\n print(-1)\r\n\r\n\r\n\r\n\r\n\r\n\r\n \r\n\r\n \r\n\r\n return None\r\n\r\ndef main():\r\n tests = 1\r\n # tests = re(int)\r\n for tc in range(tests):\r\n solve()\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 self.BUFSIZE = 8192\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, 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 = os.read(self._fd, max(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 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 sep = kwargs.pop(\"sep\", \" \")\r\n file = 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\nsys.stdin = IOWrapper(sys.stdin)\r\nsys.stdout = IOWrapper(sys.stdout)\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\nimport collections\nimport math\n\nifs = sys.stdin\nofs = sys.stdout\n\n\ndef numbers_from_line(d=' '):\n return [\n int(s)\n for s in ifs.readline().strip().split(d)\n if len(s.strip()) > 0\n ]\n\n\ndef digits(n):\n D = []\n while n > 0:\n n, d = divmod(n, 10)\n D.append(d)\n return D\n\n\ndef solve(n, x):\n min_steps = math.inf\n seen = set()\n queue = collections.deque([(x, 0)])\n while queue:\n x, steps = queue.popleft()\n dx = digits(x)\n if len(dx) == n:\n min_steps = min(min_steps, steps)\n continue\n if len(dx) > n:\n continue\n dx = set(dx)\n for d in dx:\n if d <= 1:\n continue\n xd = x * d\n if xd in seen:\n continue\n seen.add(xd)\n queue.append((xd, steps + 1))\n if min_steps == math.inf:\n return None\n return min_steps\n\n\nn, x = numbers_from_line()\na = solve(n, x)\nif a is None:\n ofs.write('-1')\nelse:\n ofs.write(str(a))\nofs.write('\\n')\n"}, {"source_code": "n, x = map(int, input().split())\r\nq = [x]\r\ns = {}\r\nops = {}\r\nops[x] = 0\r\noperations = 0\r\nresult = -1\r\nwhile (len(q) > 0):\r\n x = q.pop(0)\r\n str_x = str(x)\r\n if len(str_x) == n:\r\n result = ops[x]\r\n break\r\n for digit in str_x:\r\n new_number = int(digit) * x\r\n if new_number not in ops:\r\n q.append(new_number)\r\n ops[new_number] = ops[x] + 1\r\nprint(result)"}, {"source_code": "import queue\r\ndef solve():\r\n n, st = map(int, input().split())\r\n qu = queue.Queue()\r\n if len(str(st)) < n:\r\n qu.put((st, 0))\r\n elif len(str(st)) == n:\r\n print(0)\r\n return\r\n else:\r\n print(-1)\r\n return\r\n vis = set()\r\n happyEnd = False\r\n ans = -1\r\n \r\n while qu.qsize():\r\n x, cnt = qu.get()\r\n if x in vis:continue\r\n vis.add(x)\r\n df = x\r\n a = set(map(int,list(str(x))))\r\n for digit in a:\r\n if digit<=1:continue\r\n nxt = df *digit;\r\n if nxt in vis:\r\n continue\r\n nLen = len(str(nxt))\r\n if nLen == n:\r\n if not happyEnd:\r\n happyEnd = True\r\n ans = cnt + 1\r\n else:\r\n ans = min(ans, cnt+1)\r\n elif nLen > n:\r\n continue\r\n qu.put((nxt, cnt+1))\r\n \r\n if happyEnd:\r\n print( ans)\r\n else:\r\n print(-1)\r\nsolve()"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\nfrom collections import deque\r\n\r\ndef getdigits(x):\r\n return list(map(int, list(str(x))))\r\n\r\n\r\ndef solve():\r\n n, x = map(int, input().split())\r\n\r\n target = 10**(n-1)\r\n\r\n q = deque()\r\n q.append((x, 0))\r\n vis = {}\r\n\r\n if x >= target*10:\r\n printf(-1)\r\n return \r\n\r\n\r\n while q:\r\n # printf(q)\r\n u, step = q.popleft()\r\n \r\n ds = getdigits(u)\r\n \r\n for d in range(9, 1, -1):\r\n if d in ds:\r\n if d * u >= target:\r\n printf(step+1)\r\n return\r\n try:\r\n v = vis[d*u]\r\n except KeyError:\r\n vis[d*u] = 1\r\n q.append((d*u, step+1))\r\n \r\n printf(-1)\r\n return\r\n\r\nsolve()\r\n"}, {"source_code": "import sys\nfrom bisect import bisect_right, bisect_left\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom math import factorial, floor, sqrt, inf, ceil, gcd\nfrom collections import defaultdict, deque, Counter\nfrom functools import cmp_to_key\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############ ---- 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\n###functions\n\n### Calculate C(n, r) mod p, where p is prime (fast with precalculation)\n\ndef build_mod_inverses(n, r, p):\n fact = [1] * (n + 1)\n for i in range(1, n + 1):\n fact[i] = i * fact[i - 1] % p\n \n inv = [1] * (n + 1)\n inv[n] = pow(fact[n], p - 2, p)\n for i in range(n - 1, -1, -1):\n inv[i] = (i + 1) * inv[i + 1] % p\n \n return fact, inv\n\n# fast C(n, r) mod p calculation using predefined fact and inv\ndef comb(n, r, p, fact, inv):\n return fact[n] * inv[r] % p * inv[n - r] % p if n >= r >= 0 else 0\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 and i != 1:\n divisors.append(n // i)\n return divisors\n\ndef dfs(graph, vertex):\n visited = set()\n tree = []\n deq = deque([vertex])\n while deq:\n vertex = deq.pop()\n if vertex not in visited:\n visited.add(vertex)\n deq.extend(graph[vertex])\n tree.append(vertex)\n return tree\n\ndef find_in_sorted_list(elem, sorted_list):\n # https://docs.python.org/3/library/bisect.html\n 'Locate the leftmost value exactly equal to x'\n i = bisect_left(sorted_list, elem)\n if i != len(sorted_list) and sorted_list[i] == elem:\n return i\n return -1\n\n############ SEGMENT TREE ##############\n\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 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###code\n\nn, x = inlt()\ndepth = 0\nstart = (x, depth)\nvisited = set()\n\nif set(str(x)) == set('1') or set(str(x)) == set('0') or set(str(x)) == set(['1', '0']):\n print(-1)\n sys.exit()\n\ndeq = deque([start])\nwhile deq:\n vertex = deq.popleft()\n if vertex not in visited:\n visited.add(vertex)\n if len(str(vertex[0])) >= n:\n print(vertex[1])\n sys.exit()\n \n for num in str(vertex[0]):\n val = vertex[0] * int(num)\n depth = vertex[1]+1\n deq.append((val, depth))\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import collections\r\n\r\ndef dig(x):\r\n\td = []\r\n\twhile x>0:\r\n\t\td.append(x%10)\r\n\t\tx=x//10\r\n\treturn d\r\n\r\n\r\n#n = int(input())\r\n#a = list(map(int,input().split()))\r\nn,x = map(int,input().split())\r\n\r\nseen = set()\r\nseen.add(x)\r\nq = collections.deque([])\r\nq.append(x)\r\nops = 0\r\nflag = False\r\n\r\n\r\nwhile len(q)>0:\r\n\r\n\t#print(q)\r\n\tfor i in range(len(q)):\r\n\t\tcurx = q.popleft()\r\n\t\td = dig(curx)\r\n\t\tif len(d) == n:\r\n\t\t\tflag = True\r\n\t\t\tbreak\r\n\r\n\t\tfor y in d:\r\n\t\t\tnewx = curx*y\r\n\t\t\tif newx not in seen:\r\n\t\t\t\tq.append(newx)\r\n\t\t\t\tseen.add(newx)\r\n\tif flag:\r\n\t\tbreak\r\n\tops+=1\r\n\r\nif flag:\r\n\tprint(ops)\r\nelse:\r\n\tprint(-1)\r\n"}, {"source_code": "def f(x, n, k, dt, cnt, st):\r\n if len(str(x)) == n:\r\n return 0\r\n mn = 1000\r\n cnt += 1\r\n for elem in str(x):\r\n if elem not in st:\r\n a = int(elem) * x\r\n if a not in k:\r\n b = f(a, n, k, dt, cnt, st)\r\n mn = min(mn, b)\r\n k.add(a)\r\n dt[a] = [cnt, b]\r\n else:\r\n dt[a][0] = min(cnt, dt[a][0])\r\n mn = min(mn, dt[a][1])\r\n return mn + 1\r\n\r\n\r\nn, x = list(map(int, input().split()))\r\nans = f(x, n, set(), {}, 0, set(['1', '0']))\r\nif ans >= 1000:\r\n print(-1)\r\nelse:\r\n print(ans)"}, {"source_code": "n, x = map(int, input().split())\r\nif not any([str(i) in str(x) for i in range(2, 10)]):\r\n print(-1)\r\n exit()\r\ndp = [set() for i in range(n * 10)]\r\ndp[0].add(x)\r\nfor j in range(n * 10 - 1):\r\n for k in dp[j]:\r\n for i in range(2, 10):\r\n if str(i) in str(k):\r\n dp[j + 1].add(k * i)\r\n if len(str(k * i)) == n:\r\n print(j + 1)\r\n exit()"}, {"source_code": "from functools import lru_cache\r\nn, x = map(int, input().split())\r\n@lru_cache(None)\r\ndef F(x):\r\n\tif len(str(x)) >= n:\r\n\t\treturn 0\r\n\tz = 100\r\n\tfor i in range(2, 10):\r\n\t\tif str(i) in str(x):\r\n\t\t\tz = min(z, F(x * i) + 1)\r\n\treturn z\r\nz = F(x)\r\nif z == 100:\r\n\tz = -1\r\nprint(z)"}, {"source_code": "from functools import lru_cache\r\nn, x = map(int, input().split())\r\n@lru_cache(None)\r\ndef F(x):\r\n\tif len(str(x)) >= n:\r\n\t\treturn 0\r\n\tz = 100\r\n\tfor i in range(2, 10):\r\n\t\tif str(i) in str(x):\r\n\t\t\tz = min(z, F(x * i) + 1)\r\n\treturn z\r\nz = F(x)\r\nif z == 100:\r\n\tz = -1\r\nprint(z)"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n#\r\nn, x = list(map(int, input().split(' ')))\r\nt = 10 ** (n - 1)\r\nif x == 1:\r\n print(-1)\r\nelse:\r\n q = deque()\r\n q.append((x, 0))\r\n vis = set([x])\r\n ok = False\r\n k = 0\r\n while q:\r\n k += 1\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n if x * i not in vis:\r\n q.append((x * i, dis + 1))\r\n vis.add(x * i)\r\n if not ok:\r\n print(-1)\r\n\r\n \r\n\r\n"}, {"source_code": "import collections\r\ndef get_len(n):\r\n res= 0\r\n while n:\r\n res += 1\r\n n //= 10\r\n return res\r\ndef bfs(start, d, n):\r\n q = collections.deque()\r\n q.append(start)\r\n d[start] = 0\r\n while len(q) > 0:\r\n v = q.popleft()\r\n if get_len(v) == n:\r\n return d[v]\r\n vv = v\r\n while vv:\r\n to = v * (vv % 10)\r\n if to >= 10 ** n or to in d:\r\n vv //= 10\r\n continue\r\n d[to] = d[v] + 1\r\n q.append(to)\r\n vv //= 10\r\n return -1\r\n\r\n\r\ndef solve():\r\n n, x = map(int, input().split())\r\n d = dict()\r\n print(bfs(x, d, n))\r\n\r\n\r\nfor _ in range(1):\r\n solve()"}, {"source_code": "def I(): return input().strip()\r\ndef II(): return int(input().strip())\r\ndef LI(): return [*map(int, input().strip().split())]\r\nimport sys, os, copy, string, math, time, functools, fractions\r\nfrom io import BytesIO, IOBase\r\nfrom heapq import heappush, heappop, heapify\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import deque, defaultdict, Counter, OrderedDict\r\nfrom itertools import permutations, chain, combinations, groupby\r\nfrom operator import itemgetter\r\nfrom types import GeneratorType # for recursion\r\nfrom typing import Iterable, TypeVar, Union # for sorted set\r\n\r\n\r\n# template starts\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\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\r\n return wrappedfunc\r\n\r\n\r\n# template ends\r\n\r\n\r\ndef main():\r\n n, x = LI()\r\n if len(str(x)) == n:\r\n print(0)\r\n return\r\n if max(str(x)) == '1':\r\n print(-1)\r\n return\r\n ans = float('inf')\r\n tried = defaultdict(lambda: float('inf'))\r\n\r\n def rec(num, atp=0):\r\n nonlocal n, ans\r\n if len(str(num)) >= n:\r\n ans = min(ans, atp)\r\n else:\r\n used = set()\r\n for i in str(num):\r\n if int(i) > 1 and int(i) not in used:\r\n used.add(int(i))\r\n tmp = num * int(i)\r\n if tried[tmp] > atp:\r\n tried[tmp] = atp\r\n rec(tmp, atp + 1)\r\n\r\n rec(x)\r\n print(ans)\r\n\r\n\r\nfor _ in range(1):\r\n main()\r\n"}, {"source_code": "from functools import lru_cache \r\nn,x = list(map(int,input().split()))\r\n@lru_cache(maxsize=None)\r\ndef dp(nn,xx):\r\n\ty = str(xx)\r\n\tif len(y)==nn:\r\n\t\treturn 0 \r\n\tres = 1e9 \r\n\tfor j in y:\r\n\t\tif int(j)>1:\r\n\t\t\tres = min(res,1 + dp(nn,xx*int(j)))\r\n\treturn res \r\nres = dp(n,x)\r\nif res>=1e9:\r\n\tprint(-1)\r\nelse:\r\n\tprint(res)"}, {"source_code": "from sys import stdin, stdout\r\n\r\nn, x = [int(z) for z in stdin.readline().split()]\r\nmemo = {}\r\n\r\ndef f(x):\r\n if x in memo:\r\n return memo[x]\r\n\r\n x_s = str(x)\r\n if len(x_s) == n:\r\n memo[x] = 0\r\n return 0\r\n\r\n digits = set()\r\n for i in range(len(x_s)):\r\n if int(x_s[i]) > 1:\r\n digits.add(int(x_s[i]))\r\n\r\n if len(digits) == 0:\r\n memo[x] = 100\r\n return 100\r\n else:\r\n temp = 100\r\n for i in digits:\r\n temp = min(temp, 1+f(x*i))\r\n memo[x] = temp\r\n return temp\r\n\r\nanswer = f(x)\r\nif answer >= 100:\r\n answer = -1\r\n\r\nstdout.write(str(answer)+'\\n')\r\n"}, {"source_code": "import io,os\nfrom collections import deque \n\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndef main(t):\n\n\n n,x = map(int,input().split())\n\n queue = deque()\n queue.append([str(x),0])\n dic = {}\n\n while queue:\n s,step = queue.popleft()\n for c in s:\n nexts = str(int(s)*int(c))\n if len(nexts)==n: \n print(step+1)\n return \n if nexts in dic: continue \n dic[nexts] = 1\n queue.append([nexts,step+1])\n \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\nT = 1 #int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}, {"source_code": "import sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\nfrom collections import deque\r\n\r\n# region fastio\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\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\nif sys.version_info[0] < 3:\r\n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\nfile = sys.stdin\r\nif os.environ.get('USER') == \"loic\":\r\n file = open(\"data.in\")\r\n \r\nline = lambda: file.readline().split()\r\nui = lambda: int(line()[0])\r\nti = lambda: map(int,line())\r\nli = lambda: list(ti())\r\n\r\n#######################################################################\r\n\r\ndef to_int_digits(n):\r\n return list(map(int, str(n)))\r\n\r\ndef solve():\r\n \r\n start = X\r\n mp = {start:0}\r\n \r\n q = deque()\r\n q.appendleft(start)\r\n \r\n while q:\r\n n = q.pop()\r\n if len(str(n)) == N:\r\n return mp[n]\r\n \r\n for d in to_int_digits(n):\r\n ch = d * n\r\n if ch not in mp:\r\n q.appendleft(ch)\r\n mp[ch] = mp[n]+ 1\r\n \r\n return str(-1)\r\n \r\n\r\nfor test in range(1,1+1):\r\n N,X = ti()\r\n \r\n print(solve())\r\n \r\nfile.close()"}, {"source_code": "from functools import lru_cache\r\nn, x = map(int, input().split())\r\n@lru_cache(None)\r\ndef F(x):\r\n\tif len(str(x)) >= n:\r\n\t\treturn 0\r\n\tz = 100\r\n\tfor i in range(2, 10):\r\n\t\tif str(i) in str(x):\r\n\t\t\tz = min(z, F(x * i) + 1)\r\n\treturn z\r\nz = F(x)\r\nif z == 100:\r\n\tz = -1\r\nprint(z)"}, {"source_code": "from collections import deque\r\nn,x=map(int,input().split())\r\nq=deque()\r\ndist={}\r\ndist[x]=0\r\nq.append(x)\r\nwhile q:\r\n p=q.popleft()\r\n if len(str(p))==n:\r\n print(dist[p])\r\n exit()\r\n else:\r\n for el in str(p):\r\n if el!=\"0\":\r\n w=p*int(el)\r\n if w not in dist:\r\n dist[w]=dist[p]+1\r\n q.append(w)\r\nprint(-1)\r\nexit()"}, {"source_code": "inf = float(\"inf\")\r\n\r\ndef get_next_state(mult: int, state: list):\r\n new_state = list(state)\r\n for idx, fac in enumerate((2,3,5,7)):\r\n while mult%fac == 0:\r\n new_state[idx] += 1\r\n mult //= fac\r\n return tuple(new_state)\r\n\r\n# dp[(2s, 3s, 5s, 7s)]\r\ndef dumb(n, x, state: tuple, dp: dict):\r\n if len(str(x)) == n:\r\n return 0\r\n if state in dp:\r\n return dp[state]\r\n \r\n ans = inf\r\n for i in range(2,10):\r\n if str(i) in str(x):\r\n next_state = get_next_state(i, state)\r\n ans = min(ans, 1+dumb(n, x*i, next_state, dp))\r\n\r\n dp[state] = ans\r\n return ans\r\n\r\nn, x = [int(x) for x in input().split()]\r\nans = dumb(n, x, (0,0,0,0), {})\r\nprint(-1 if ans == inf else ans)\r\n"}, {"source_code": "import sys\r\nimport os\r\nfrom io import BytesIO, IOBase\r\nfrom collections import deque\r\n\r\n# region fastio\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\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\nif sys.version_info[0] < 3:\r\n sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\r\nelse:\r\n sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\r\nfile = sys.stdin\r\nif os.environ.get('USER') == \"loic\":\r\n file = open(\"data.in\")\r\n \r\nline = lambda: file.readline().split()\r\nui = lambda: int(line()[0])\r\nti = lambda: map(int,line())\r\nli = lambda: list(ti())\r\n\r\n#######################################################################\r\n\r\ndef to_int_digits(n):\r\n return list(map(int, str(n)))\r\n\r\ndef solve():\r\n \r\n start = X\r\n mp = {start:0}\r\n \r\n q = deque()\r\n q.appendleft(start)\r\n \r\n while q:\r\n n = q.pop()\r\n if len(str(n)) == N:\r\n return mp[n]\r\n \r\n for d in set(to_int_digits(n)):\r\n ch = d * n\r\n if ch not in mp:\r\n q.appendleft(ch)\r\n mp[ch] = mp[n] + 1\r\n \r\n return str(-1)\r\n \r\n\r\nfor test in range(1,1+1):\r\n N,X = ti()\r\n \r\n print(solve())\r\n \r\nfile.close()"}, {"source_code": "class Solution:\r\n def dfs(self, n, x):\r\n # print(x)\r\n if x in self.memo:\r\n return self.memo[x]\r\n\r\n if len(str(x)) == n:\r\n return 0\r\n\r\n if len(str(x)) > n:\r\n return 10000000\r\n\r\n min_step_required = 10000000\r\n # print(list(str(x)))\r\n for d in map(int, list(str(x))):\r\n if d == 1 or d == 0: continue\r\n min_step_required = min(min_step_required, 1+ self.dfs(n, d*x))\r\n\r\n self.memo[x] = min_step_required\r\n return min_step_required \r\n\r\n def solve(self, n, x):\r\n self.memo = {}\r\n res = self.dfs(n, x)\r\n print(res if res != 10000000 else -1)\r\n\r\n\r\n\r\ndef main():\r\n n, x = map(int, input().split())\r\n S = Solution()\r\n\r\n S.solve(n, x)\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "#https://codeforces.com/blog/entry/71884\r\nimport sys\r\ninput = sys.stdin.readline\r\nfrom math import inf, gcd, log, log2, floor, ceil, sqrt\r\nfrom collections import Counter, defaultdict, deque\r\nfrom heapq import heappush, heappop, heapify\r\nfrom functools import lru_cache\r\nfrom itertools import permutations, accumulate\r\nfrom bisect import insort, bisect_left, bisect_right\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\nfrom random import randint\r\n \r\nRANDOM = randint(1, 10 ** 9)\r\n \r\nclass Wrapper(int):\r\n def __init__(self, x):\r\n int.__init__(x)\r\n def __hash__(self):\r\n return super(Wrapper, self).__hash__() ^ RANDOM\r\n \r\n\r\ndef solve(n,x):\r\n \r\n if x == 1 and n > 1:\r\n return -1\r\n \r\n q = deque()\r\n q.append((x,0))\r\n visit = set([x])\r\n while q:\r\n for _ in range(len(q)):\r\n ele,dist = q.popleft()\r\n s = str(ele)\r\n if len(s) >= n:\r\n return dist\r\n t = sorted(list(set(s)),reverse=True)[:4]\r\n for x in t:\r\n if x == \"0\" or x == \"1\":\r\n continue\r\n num = ele*int(x)\r\n if num not in visit:\r\n q.append((num,dist+1))\r\n visit.add(num)\r\n \r\n return -1\r\n \r\n \r\n \r\nd = inlt()\r\nn,x = d[0],d[1]\r\nprint(solve(n,x))#\r\n \r\n"}, {"source_code": "from collections import defaultdict\r\nN, X = map(int,input().split())\r\noriginal = X\r\nd = defaultdict(int)\r\ndef calc(s, dd):\r\n X = s\r\n if dd[X] > 0:\r\n return dd[X]\r\n digits = []\r\n digitsnum = 0\r\n while X > 0:\r\n digitsnum += 1\r\n if X % 10 not in digits:\r\n digits.append(X%10)\r\n X //= 10\r\n if digitsnum == N:\r\n dd[s] = 0\r\n return 0\r\n if digitsnum > N:\r\n return 10**30\r\n else:\r\n mn = 10**30\r\n for d in digits:\r\n if d != 1 and d != 0:\r\n X = s*d\r\n mn = min(mn, calc(X,dd) + 1)\r\n dd[s] = mn\r\n return mn\r\nans = calc(X,d)\r\nif ans >= 10**30:\r\n print(-1)\r\nelse:\r\n print(ans)"}, {"source_code": "n,x = map(int, input().split())\r\nq=[x]\r\nops={}\r\nops[x]=0\r\nresult=-1\r\n\r\nwhile len(q)>0:\r\n x=q.pop(0)\r\n str_x=str(x)\r\n if len(str_x)==n:\r\n result=ops[x]\r\n break\r\n for digit in str_x:\r\n new_number = int(digit)*x\r\n if new_number not in ops:\r\n q.append(new_number)\r\n ops[new_number]=ops[x]+1\r\n\r\nprint(result)\r\n\r\n"}, {"source_code": "import sys\r\nfrom math import inf\r\nfrom collections import deque\r\ninput = sys.stdin.readline\r\n\r\nn,x = map(int,input().split())\r\n\r\nvis = set()\r\nans = 0\r\nq = deque([x])\r\n\r\nif len(str(x)) == n:\r\n print(0)\r\nelif len(str(x)) > n:\r\n print(-1)\r\nelse:\r\n flag = True\r\n while q:\r\n ans += 1\r\n for i in range(len(q)):\r\n now = q.popleft()\r\n \r\n for j in range(2,10):\r\n if str(j) in str(now):\r\n nxt = now * j\r\n if len(str(nxt)) == n:\r\n flag = False\r\n \r\n if nxt not in vis:\r\n q.append(nxt)\r\n vis.add(nxt)\r\n\r\n if len(q) == 0:\r\n ans = -1\r\n if not flag:\r\n break\r\n\r\n print(ans)\r\n"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\nn, x = list(map(int, input().split(' ')))\r\nt = 10 ** (n - 1)\r\nif x == 1:\r\n print(-1)\r\nelse:\r\n q = deque()\r\n q.append((x, 0))\r\n vis = set([x])\r\n ok = False\r\n k = 0\r\n while q:\r\n k += 1\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n if x * i not in vis:\r\n q.append((x * i, dis + 1))\r\n vis.add(x * i)\r\n if not ok:\r\n print(-1)\r\n\r\n \r\n\r\n"}, {"source_code": "from functools import lru_cache\r\nfrom time import sleep\r\n\r\nINF = 1e100\r\ns = dict()\r\n# @lru_cache(None)\r\ndef solve(x, cur, k):\r\n if x in s:\r\n return s[x] + cur\r\n if len(str(x)) == k:\r\n return cur\r\n if len(str(x)) > k:\r\n return INF\r\n if x == 0 and k != 1:\r\n return INF\r\n ans = INF\r\n for i in str(x):\r\n if i != '1':\r\n ans = min(ans, solve(int(i) * x, cur + 1, k))\r\n s[x] = ans - cur\r\n return ans\r\n\r\nk, x = map(int, input().split())\r\nx = solve(x, 0, k)\r\nif x < INF:\r\n print(x)\r\nelse:\r\n print(-1)"}, {"source_code": "n, x = input().split()\nn = int(n)\nyy = set([int(w) for w in list(x)])\nx = int(x)\n# print(yy)\n# ans = n * 10\n# for y in yy:\n# if y == 1:\n# continue\n# cnt = 0\n# cur = x\n# while len(str(cur)) < n:\n# cur = cur * y\n# cnt += 1\n# if len(str(cur)) > n:\n# break\n# if len(str(cur)) == n:\n# if ans > cnt:\n# ans = cnt\nQ = []\nQ.append((x, 0))\ndic = {}\nwhile len(Q) > 0:\n tee = Q[0]\n # print(tee)\n Q.pop(0)\n yy = set([int(w) for w in list(str(tee[0]))])\n # yy = [max(yy)]\n # print(yy)\n for y in yy:\n if y == 1:\n continue\n cur = tee[0] * y\n if len(str(cur)) == n:\n print(tee[1] + 1)\n exit()\n if len(str(cur)) < n:\n if cur in dic.keys():\n if tee[1] + 1 < dic[cur]:\n Q.append((cur, tee[1] + 1))\n dic[cur] = tee[1] + 1\n else:\n Q.append((cur, tee[1] + 1))\n dic[cur] = tee[1] + 1\n\n\n# if ans == n * 10:\nprint('-1')\n# else:\n # print(ans)\n"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\nfrom collections import deque\r\n\r\ndef getdigits(x):\r\n return list(map(int, list(str(x))))\r\n\r\n\r\ndef solve():\r\n n, x = map(int, input().split())\r\n\r\n target = 10**(n-1)\r\n\r\n q = deque()\r\n q.append((x, 0))\r\n vis = {}\r\n\r\n if x >= target*10:\r\n printf(-1)\r\n return \r\n\r\n\r\n while q:\r\n # printf(q)\r\n u, step = q.popleft()\r\n \r\n ds = getdigits(u)\r\n \r\n for d in range(9, 1, -1):\r\n if d in ds:\r\n if d * u >= target:\r\n printf(step+1)\r\n return\r\n try:\r\n v = vis[d*u]\r\n except KeyError:\r\n vis[d*u] = 1\r\n q.append((d*u, step+1))\r\n \r\n printf(-1)\r\n return\r\n\r\nsolve()\r\n"}, {"source_code": "from collections import deque\r\nn,x=map(int,input().split())\r\nq=deque()\r\ndist={}\r\ndist[x]=0\r\nq.append(x)\r\nwhile q:\r\n p=q.popleft()\r\n if len(str(p))==n:\r\n print(dist[p])\r\n exit()\r\n else:\r\n for el in str(p):\r\n if el!=\"0\":\r\n w=p*int(el)\r\n if w not in dist:\r\n dist[w]=dist[p]+1\r\n q.append(w)\r\nprint(-1)\r\nexit()"}, {"source_code": "from ast import Return\r\nimport sys,io,os\r\nfrom os import path\r\nfrom collections import Counter,defaultdict\r\nif(path.exists('input.txt')):\r\n sys.stdin = open('input.txt','r')\r\n 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\ndef highes(cur,n,mem):\r\n if len(str(cur))==n:\r\n return 0\r\n if cur in mem:\r\n return mem[cur]\r\n now=1e16\r\n for i in str(cur):\r\n if i=='1' or i=='0':\r\n continue\r\n now=min(now,highes(cur*int(i),n,mem)+1)\r\n # print(cur,n,now)\r\n mem[cur]=now\r\n return now\r\ndef main():\r\n# n=int(input())\r\n n,x=list(map(int,input().split()))\r\n if n=ten[n]:\r\n print(-1)\r\n exit()\r\ndist = defaultdict(int)\r\nque = deque([x])\r\ndist[x] = 0\r\nwhile que:\r\n v = que.popleft()\r\n e = dist[v]\r\n for i in range(2,10):\r\n vv=str(v)\r\n if str(i) in vv:\r\n nxt=v*i\r\n if nxt>=ten[n]:\r\n continue\r\n if nxt not in dist:\r\n dist[nxt]=e+1\r\n que.append(nxt)\r\n if ten[n-1]<=nxt1:\r\n z = check(n,x*int(i))+1\r\n if z!=0:\r\n ans = min(ans,z)\r\n if ans==p:\r\n ans=-1\r\n dp[x] = ans\r\n return ans\r\n\r\nn,x = ints()\r\ndp = {}\r\nprint(check(n,x))\r\n"}, {"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\nfrom collections import deque\r\n\r\nn, x = map(int, input().split())\r\n\r\noklow = 10**(n - 1)\r\ndef ok(e):\r\n return oklow <= e\r\n\r\nif x == \"1\":\r\n print(\"-1\")\r\nelse:\r\n Q = deque([(x, 0)])\r\n V = {}\r\n r = 1000000\r\n while Q:\r\n e, d = Q.pop()\r\n\r\n if ok(e):\r\n r = min(r, d)\r\n elif e not in V or V[e] > d:\r\n V[e] = d\r\n\r\n vr = e\r\n mask = 0\r\n while vr != 0:\r\n m = vr % 10\r\n if m > 1 and (mask & (1 << m) == 0):\r\n Q.append((e * m, d + 1))\r\n mask |= (1 << m)\r\n vr //= 10\r\n\r\n print(r if r < 1000000 else -1)\r\n\r\n"}, {"source_code": "import sys, random\r\nfrom collections import defaultdict\r\n\r\nclass DefaultDict:\r\n def __init__(self, default=None):\r\n self.default = default\r\n self.x = random.randrange(1, 1 << 31)\r\n self.dd = defaultdict(default)\r\n\r\n def __repr__(self):\r\n return \"{\"+\", \".join(f\"{k ^ self.x}: {v}\" for k, v in self.dd.items())+\"}\"\r\n\r\n def __eq__(self, other):\r\n return set(self.dd.items()) == set(other.dd.items())\r\n\r\n def __or__(self, other):\r\n res = DefaultDict(self.default)\r\n for k, v in self.dd: res[k] = v\r\n for k, v in other.dd: res[k] = v\r\n return res\r\n\r\n def __len__(self):\r\n return len(self.dd)\r\n\r\n def __getitem__(self, item):\r\n return self.dd[item ^ self.x]\r\n\r\n def __setitem__(self, key, value):\r\n self.dd[key ^ self.x] = value\r\n\r\n def __delitem__(self, key):\r\n del self.dd[key ^ self.x]\r\n\r\n def __contains__(self, item):\r\n return item ^ self.x in self.dd\r\n\r\n def items(self):\r\n for k, v in self.dd.items(): yield (k ^ self.x, v)\r\n\r\n def keys(self):\r\n for k in self.dd: yield k ^ self.x\r\n\r\n def values(self):\r\n for v in self.dd.values(): yield v\r\n\r\n def __iter__(self):\r\n for k in self.dd: yield k ^ self.x\r\n\r\nclass Counter(DefaultDict):\r\n def __init__(self, aa=[]):\r\n super().__init__(int)\r\n for a in aa: self.dd[a ^ self.x] += 1\r\n\r\n def __add__(self, other):\r\n res = Counter()\r\n for k, v in self.items(): res[k] = v\r\n for k, v in other.items(): res[k] += v\r\n return res\r\n\r\n def __sub__(self, other):\r\n res = Counter()\r\n for k, v in self.items(): res[k] = v\r\n for k, v in other.items(): res[k] -= v\r\n return res\r\n\r\n def __and__(self, other):\r\n res = Counter()\r\n for k in self:\r\n v = min(self[k], other[k])\r\n if v > 0: res[k] = v\r\n return res\r\n\r\n def __or__(self, other):\r\n res = Counter()\r\n for k in set(self) | set(other):\r\n v = max(self[k], other[k])\r\n if v > 0: res[k] = v\r\n return res\r\n\r\n def __iter__(self):\r\n for k in self.dd: yield k ^ self.x\r\n\r\nclass Set:\r\n def __init__(self, aa=[]):\r\n self.x = random.randrange(1, 1 << 31)\r\n self.st = set()\r\n for a in aa: self.st.add(a ^ self.x)\r\n\r\n def __repr__(self):\r\n return \"{\"+\", \".join(str(k ^ self.x) for k in self.st)+\"}\"\r\n\r\n def __len__(self):\r\n return len(self.st)\r\n\r\n def add(self, item):\r\n self.st.add(item ^ self.x)\r\n\r\n def discard(self, item):\r\n self.st.discard(item ^ self.x)\r\n\r\n def __contains__(self, item):\r\n return item ^ self.x in self.st\r\n\r\n def __iter__(self):\r\n for k in self.st: yield k ^ self.x\r\n\r\n def pop(self):\r\n return self.st.pop() ^ self.x\r\n\r\n def __or__(self, other):\r\n res = Set(self)\r\n for a in other: res.add(a)\r\n return res\r\n\r\n def __and__(self, other):\r\n res = Set()\r\n for a in self:\r\n if a in other: res.add(a)\r\n for a in other:\r\n if a in self: res.add(a)\r\n return res\r\n\r\n# sys.setrecursionlimit(200005)\r\nint1 = lambda x: int(x)-1\r\npDB = lambda *x: print(*x, end=\"\\n\", file=sys.stderr)\r\np2D = lambda x: print(*x, sep=\"\\n\", end=\"\\n\\n\", file=sys.stderr)\r\ndef II(): return int(sys.stdin.readline())\r\ndef LI(): return list(map(int, sys.stdin.readline().split()))\r\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\r\ndef LI1(): return list(map(int1, sys.stdin.readline().split()))\r\ndef LLI1(rows_number): return [LI1() for _ in range(rows_number)]\r\ndef SI(): return sys.stdin.readline().rstrip()\r\ndij = [(0, 1), (-1, 0), (0, -1), (1, 0)]\r\n# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]\r\ninf = (1 << 63)-1\r\n# inf = 4294967295\r\n# md = 10**9+7\r\n# md = 998244353\r\n\r\nfrom collections import deque\r\n\r\ndef size(a):\r\n return len(str(a))\r\n\r\ndef solve():\r\n n, x = LI()\r\n\r\n if size(x) > n:\r\n print(-1)\r\n return\r\n\r\n q = deque()\r\n q.append((x, 0))\r\n fin = set()\r\n while q:\r\n a, c = q.popleft()\r\n for d in set(list(int(c) for c in str(a))):\r\n if d < 2: continue\r\n b = a*d\r\n s = size(b)\r\n if s == n:\r\n print(c+1)\r\n return\r\n if s > n or b in fin: continue\r\n fin.add(b)\r\n q.append((b, c+1))\r\n print(-1)\r\n\r\n # ***************************************\r\n\r\n# testnumber = II()\r\ntestnumber = 1\r\nfor testcase in range(testnumber):\r\n solve()\r\n # print(\"YES\" if solve() else \"NO\")\r\n"}, {"source_code": "from collections import deque\r\n\r\n\r\nn, x = [int(x) for x in input().split()]\r\n\r\nq = deque()\r\nq.append((x, 0))\r\nans = -1\r\n\r\nmp = {x: 0}\r\n\r\nwhile q:\r\n num, t = q.popleft()\r\n snum = str(num)\r\n l = len(snum)\r\n if l == n:\r\n ans = t\r\n break\r\n for s in snum:\r\n y = int(s)\r\n if y == 0:\r\n continue\r\n res = num * y\r\n if not (res in mp):\r\n mp[res] = t + 1\r\n q.append((res, t + 1))\r\nprint(ans)\r\n"}, {"source_code": "def is_sorted(arr,r=False):\n n=len(arr)\n if not r :\n for i in range(1,n):\n if arr[i]arr[i-1] :\n return False\n return True\n\n\ndef freq(arr) :\n d={}\n for i in arr :\n d[i]=d.get(i,0)+1\n return d\n\ndef fac(n):\n p=1\n for i in range(1,n+1):\n p*=i\n return p\n\n\n\nfrom functools import lru_cache\n\n\n@lru_cache(maxsize=None)\ndef solve(m,n) :\n\n if len(str(m))>=n :\n return 0\n \n r=[]\n k=m\n while k>0 :\n r.append(k%10)\n k=k//10\n\n if r and max(r)==1 :\n return -1\n \n try:\n while True:\n r.remove(1)\n except ValueError:\n pass\n mn=100000000000000000\n\n for i in r :\n x=solve(m*i,n)\n \n if x>=0 :\n mn=min(mn,x)\n\n\n \n return 1+mn\n \n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n\n\n\n\n \n \n\n\n \n\n\n#from bisect import bisect_left as bisect\nfrom math import ceil,floor\nfrom sys import stdin #setrecursionlimit\ninput = stdin.buffer.readline \n#setrecursionlimit(400000) \n\n\n \n\nn,m= list(map(int, input().split()))\nprint(solve(m,n))\n\n\n\n\n'''\n\nfor _ in range(int(input())) :\n n=int(input())\n print(solve())\n\n\nn=int(input())\n\nx=input().strip().decode(\"utf-8\")\n\n\nn,m= list(map(int, input().split()))\n\n\nn=int(input())\n arr=list(map(int, input().split()))\n\nn,k= list(map(int, input().split()))\narr=list(map(int, input().split()))\n\n\narr=list(map(int, input().strip().decode(\"utf-8\")))\n\n\nn,m= [int(x) for x in input().split()]\narr=[list(map(int, input().split())) for _ in range(n)]\n\n\nn,m= [int(x) for x in input().split()]\narr=[list(map(int, input().strip().decode(\"utf-8\"))) for _ in range(n)]\n\n\n\nn=int(input())\narr=[list(map(int, input().split())) for _ in range(n)]\n\n\n\nn,m= list(map(int, input().split()))\n arr=[list(input().strip().decode(\"utf-8\")) for _ in range(n)]\n\n\n\n\nfor _ in range(int(input())) :\n \n\n n=int(input())\n arr=list(map(int, input().split()))\n\n d={}\n leaves={}\n\n for i in range(n):\n d[i+1]=[]\n leaves[i+1]=1\n \n for i in range(1,n):\n d[arr[i-1]].append(i+1)\n if arr[i-1] in leaves :\n leaves.pop(arr[i-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"}, {"source_code": "from functools import lru_cache\r\nn, x = map(int, input().split())\r\n@lru_cache(None)\r\ndef F(x):\r\n\tif len(str(x)) >= n:\r\n\t\treturn 0\r\n\tz = 100\r\n\tfor i in range(2, 10):\r\n\t\tif str(i) in str(x):\r\n\t\t\tz = min(z, F(x * i) + 1)\r\n\treturn z\r\nz = F(x)\r\nif z == 100:\r\n\tz = -1\r\nprint(z)"}, {"source_code": "from functools import lru_cache\r\ndef minops(x):\r\n\r\n\r\n @lru_cache(None)\r\n def solve(x):\r\n if x>=10**(n-1):\r\n return 0\r\n numset=set(str(x))\r\n\r\n\r\n res=float('inf')\r\n for i in numset:\r\n i=int(i)\r\n if i in [0,1]:\r\n continue\r\n res=min(res,solve(x*i)+1)\r\n\r\n return res\r\n\r\n\r\n ans=solve(x)\r\n return ans if ans!=float('inf') else -1\r\n\r\n\r\n\r\nn,x=[int(x) for x in input().split()]\r\ncheck=True\r\nans=0\r\nprint(minops(x))"}, {"source_code": "import collections\r\nn,k = [int(x) for x in input().split()]\r\nq = collections.deque([k])\r\nd = {k:0}\r\nans = -1\r\nwhile(len(q) > 0):\r\n k = q.pop()\r\n s = str(k)\r\n if(len(s) == n):\r\n ans = d[k]\r\n break\r\n \r\n for x in s:\r\n if(x == \"0\"):\r\n continue\r\n w = k*int(x)\r\n if(w not in d):\r\n d[w] = d[k] + 1\r\n q.appendleft(w)\r\nprint(ans)"}, {"source_code": "import sys, io, os\r\n\r\n\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\n\r\ncache = {}\r\n\r\n\r\ndef digits(x):\r\n digits = sorted([int(digit) for digit in set([ch for ch in str(x)])])\r\n return digits\r\n\r\n\r\ndef count_operations(n, x):\r\n cached = cache.get(x)\r\n if cached:\r\n return cached\r\n\r\n str_x = str(x)\r\n if len(str_x) == n:\r\n return 0\r\n\r\n min_op = float(\"inf\")\r\n for d in digits(x):\r\n if d < 2:\r\n continue\r\n\r\n min_op = min(min_op, 1 + count_operations(n, x * d))\r\n\r\n cache[x] = min_op\r\n return min_op\r\n\r\n\r\nn, x = map(int, input().split())\r\nc = count_operations(n, x)\r\nif c == float(\"inf\"):\r\n c = -1\r\nsys.stdout.write(f\"{c}\\n\")\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\nfrom collections import *\r\n\r\ndef dfs(now):\r\n global ans\r\n \r\n if memo[now]!=-1:\r\n return memo[now]\r\n \r\n if now>=low:\r\n return 0\r\n \r\n s = set()\r\n t = now\r\n \r\n while t:\r\n d = t%10\r\n t //= 10\r\n \r\n if d>1:\r\n s.add(d)\r\n\r\n res = 100\r\n \r\n for d in s:\r\n res = min(res, 1+dfs(now*d))\r\n \r\n memo[now] = res\r\n return res\r\n\r\nn, x = map(int, input().split())\r\nlow = pow(10, n-1)\r\nans = 10**18\r\nmemo = defaultdict(lambda: -1)\r\nans = dfs(x)\r\n\r\nif ans==100:\r\n print(-1)\r\nelse:\r\n print(ans)"}, {"source_code": "from collections import deque as Queue\r\n\r\nn, x = map(int, input().split())\r\n\r\nans = 10**18\r\nque = Queue()\r\nque.append((str(x), 0))\r\nst = set()\r\nwhile que:\r\n now, cnt = que.pop()\r\n if len(now) == n:\r\n ans = cnt\r\n break\r\n\r\n for c in ''.join(set(now)):\r\n nxt = str(int(now) * int(c))\r\n if (len(nxt) > n):\r\n continue\r\n if int(nxt) in st:\r\n continue\r\n que.appendleft((nxt, cnt + 1))\r\n st.add(int(nxt))\r\n\r\nprint('-1' if ans == 10**18 else ans)"}, {"source_code": "\nfrom asyncio import QueueEmpty\nfrom collections import deque\n\nn, x = map(int, input().split())\nque = deque()\ntup = (x, 0)\nque.append(tup)\nvisited = {x}\nresult = -1\nLIMIT = 10**n-1\ncount = 0\nwhile que:\n num, step = que.popleft()\n List = list(map(int, str(num)))\n if len(List) >= n:\n result = step\n break\n Set = set(List)\n if 0 in Set:\n Set.remove(0)\n if 1 in Set:\n Set.remove(1)\n for i in Set:\n add_q = num * i\n if add_q < LIMIT and (add_q not in visited):\n visited.add(add_q)\n que.append((add_q, step+1))\n count += 1\nprint(result)\n\n\n\n\n\n\n\n\n\n\n\n\n# check_ones = list(map(lambda x: x == 1, List))\n# checker = True\n# for i in check_ones:\n# if not i:\n# checker = False\n# break\n# if checker:\n# if len(check_ones) < n:\n# print(\"-1\")\n# else:\n# print(\"0\")\n# else:\n# count = 0\n# List = list(map(int, str(x)))\n# while len(List) < n:\n# x *= max(List)\n# count += 1\n# List = list(map(int, str(x)))\n# print(count, x, len(List))\n# # if len(List) < n and 0 in List:\n# # count += (n - len(List))\n# # break\n# print(count) \n\n\n"}, {"source_code": "n, x = map(int, input().split())\r\nif not any([str(i) in str(x) for i in range(2, 10)]):\r\n print(-1)\r\n exit()\r\ndp = [set() for i in range(n * 10)]\r\ndp[0].add(x)\r\nfor j in range(n * 10 - 1):\r\n for k in dp[j]:\r\n for i in range(2, 10):\r\n if str(i) in str(k):\r\n dp[j + 1].add(k * i)\r\n if len(str(k * i)) == n:\r\n print(j + 1)\r\n exit()"}, {"source_code": "#!/usr/bin/env python\r\nimport 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._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 \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\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 int_1():\r\n return int(input())\r\n\r\ndef int_k():\r\n return map(int, input().split())\r\n\r\ndef int_l():\r\n return list(int_k())\r\n\r\ndef getGraph(start, end, loop):\r\n graph = {i: [] for i in range(start, end+1)}\r\n \r\n for _ in range(loop):\r\n u, v = int_k()\r\n graph[u].append(v)\r\n graph[v].append(u)\r\n \r\n return graph\r\n \r\ndef helper(x, lim, dp):\r\n if x > lim:\r\n return 0\r\n \r\n if x in dp:\r\n return dp[x]\r\n \r\n result = float('inf')\r\n for char in str(x):\r\n if int(char) >= 2:\r\n result = min(result, 1 + helper(x * int(char), lim, dp))\r\n \r\n dp[x] = result \r\n return result\r\n\r\ndef solve():\r\n n, x = int_k()\r\n \r\n lim = 1 \r\n for i in range(n-1):\r\n lim *= 10 \r\n \r\n result = helper(x, lim, dict())\r\n \r\n if result == float('inf'):\r\n print(-1)\r\n return\r\n print(result)\r\n \r\nfor _ in range(1):\r\n solve()"}, {"source_code": "from collections import deque\r\n\r\n\r\nn, x = [int(x) for x in input().split()]\r\n\r\nq = deque()\r\nq.append((x, 0))\r\nans = -1\r\n\r\nmp = {x: 0}\r\n\r\nwhile q:\r\n num, t = q.popleft()\r\n snum = str(num)\r\n l = len(snum)\r\n if l == n:\r\n ans = t\r\n break\r\n for s in snum:\r\n y = int(s)\r\n if y == 0:\r\n continue\r\n res = num * y\r\n if not (res in mp):\r\n mp[res] = t + 1\r\n q.append((res, t + 1))\r\nprint(ans)\r\n"}, {"source_code": "def brute(n, x):\r\n if n == len(str(x)):\r\n return 0\r\n if (n, x) in memo:\r\n return memo[(n, x)]\r\n ans = 10**9\r\n for ch in str(x):\r\n if ch=='0' or ch=='1': continue\r\n ans = min(ans, 1 + brute(n, x*int(ch)))\r\n memo[(n, x)] = ans\r\n return ans\r\n\r\nnc, xc = map(int, input().split())\r\n\r\n# n, x = nc, xc\r\n#\r\n# moves = 0\r\n#\r\n# while len(str(x)) < n:\r\n# d = max(list(str(x)))\r\n# if d == '0' or d=='1':\r\n# moves = -1\r\n# break\r\n# x = x * int(d)\r\n# moves += 1\r\n#\r\n# print(moves)\r\n#\r\nmemo = {}\r\nres = brute(nc, xc)\r\n\r\nif res >= 10**9:\r\n print(-1)\r\nelse:\r\n print(res)\r\n"}, {"source_code": "# from heapq import heapify\r\n# from itertools import count\r\n# from multiprocessing.connection import answer_challenge\r\n# import sys\r\n# import os\r\n# from math import ceil, floor, sqrt, gcd, factorial, log, log2\r\n# from io import BytesIO, IOBase\r\n# from collections import Counter\r\n# # from itertools import permutations, combinations\r\n# from bisect import bisect, insort, bisect_left\r\n# # from functools import reduce\r\n# from heapq import heapify, heappop, heappush\r\n\r\n# # sys.setrecursionlimit(10**6)\r\n\r\n# yes='YES'\r\n# no='NO'\r\n# Yes='Yes'\r\n# No='No'\r\n\r\n# inf=int(10e9) + 7\r\n# BUFSIZE = 8192\r\n\r\n# inp = lambda: int(input())\r\n# mp = lambda: map(int, input().split())\r\n# lst = lambda: list(map(int, input().split()))\r\n\r\n\r\n# def sorter(arr, n):\r\n# c = 0\r\n# temp = arr.copy()\r\n# temp.sort()\r\n# ans=[]\r\n# for i in range(n):\r\n# if (arr[i] != temp[i]):\r\n# c+=1\r\n# u = i\r\n# v = arr.index(temp[i])\r\n# ans.append((u,v))\r\n# arr[u], arr[v] = arr[v], arr[u]\r\n# return ans\r\n\r\n# def main():\r\n# for _ in range(inp()):\r\n# n=inp()\r\n# a=lst()\r\n# b=lst()\r\n# # ac = [(a[i], i) for i in range(n)]\r\n# # bc = [(b[i], i) for i in range(n)]\r\n# # ac.sort()\r\n# # bc.sort()\r\n# ta = a.copy()\r\n# tb = b.copy()\r\n\r\n# aa = a.copy()\r\n# bb = b.copy()\r\n\r\n\r\n# ans1 = sorter(aa, n)\r\n# ans2 = sorter(bb, n)\r\n\r\n# print(ans1, ans2)\r\n\r\n \r\n \r\n# # tb = b.copy()\r\n# for i, j in ans1:\r\n# tb[i], tb[j] = tb[j], tb[i]\r\n \r\n# # ta = a.copy()\r\n# for i, j in ans2:\r\n# ta[i], ta[j] = ta[j], ta[i]\r\n\r\n# if ta==sorted(a):\r\n# print('b', len(ans2))\r\n# for i, j in ans2:\r\n# print(i, j)\r\n# elif tb==sorted(tb):\r\n# print('a', len(ans1))\r\n# for i, j in ans1:\r\n# print(i, j)\r\n# else:\r\n# print(-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# class 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# class 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# sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n# input = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n\r\n# if __name__ == \"__main__\":\r\n# main()\r\n\r\nfrom heapq import heapify\r\nfrom itertools import count\r\nfrom multiprocessing.connection import answer_challenge\r\nimport sys\r\nimport os\r\nfrom math import ceil, floor, sqrt, gcd, factorial, log, log2\r\nfrom io import BytesIO, IOBase\r\nfrom collections import Counter\r\n# from itertools import permutations, combinations\r\nfrom bisect import bisect, insort, bisect_left\r\n# from functools import reduce\r\nfrom heapq import heapify, heappop, heappush\r\n\r\n# sys.setrecursionlimit(10**6)\r\n\r\nyes='YES'\r\nno='NO'\r\nYes='Yes'\r\nNo='No'\r\n\r\ninf=int(10e9) + 7\r\nBUFSIZE = 8192\r\n\r\ninp = lambda: int(input())\r\nmp = lambda: map(int, input().split())\r\nlst = lambda: list(map(int, input().split()))\r\n\r\ndef lenn(x):\r\n return len(str(x))\r\n\r\nbigdic = dict()\r\n\r\ndef func(x):\r\n dig = list(set([int(i) for i in str(x) if i!='0' and i!='1']))\r\n t = []\r\n for i in dig:\r\n if i*x not in bigdic:\r\n t.append(i*x)\r\n bigdic[i*x] = 0\r\n\r\n return t\r\n\r\ndef main():\r\n n,x = mp()\r\n \r\n if max([int(i) for i in str(x)])<=1:\r\n print(-1)\r\n else:\r\n bigdic[x] = 0\r\n old = [x]\r\n flag = False\r\n c = 0\r\n while not flag:\r\n new = []\r\n for i in sorted(old):\r\n if lenn(i)==n:\r\n flag = True\r\n break\r\n else:\r\n new+=func(i)\r\n if flag:\r\n break\r\n else:\r\n c+=1\r\n old = new.copy()\r\n\r\n print(c)\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\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\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\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "import collections\r\n\r\nn, x = map(int, input().split())\r\nq = collections.deque([])\r\ndist = {x: 0}\r\nq.append(x)\r\nwhile q:\r\n k = q.popleft()\r\n s = str(k)\r\n if len(s) == n:\r\n print(dist[k])\r\n quit()\r\n for i in s:\r\n if i == '0':\r\n continue\r\n w = k * int(i)\r\n if dist.get(w, -1) == -1:\r\n dist[w] = dist[k] + 1\r\n q.append(w)\r\nprint(-1)\r\n"}, {"source_code": "from functools import lru_cache \r\n\r\nnum ,x = list(map(int,input().split()))\r\n \r\n@lru_cache(maxsize=None)\r\n\r\ndef dp(nn_,xx_):\r\n\r\n\ty = str(xx_)\r\n\tif len(y)==nn_:\r\n\t\treturn 0 \r\n\tres = 1e9 \r\n\tfor ji in y:\r\n\t\tif int(ji)>1:\r\n\t\t\tres = min(res,1 + dp(nn_,xx_*int(ji)))\r\n\treturn res \r\n \r\nans = dp(num,x)\r\nif ans>=1e9:\r\n\tprint(-1)\r\nelse:\r\n\tprint(ans)"}, {"source_code": "\r\n\r\nimport queue\r\n\r\n\r\ndef solve():\r\n n, x = [int(x) for x in input().split()]\r\n minAcc = pow(10, n-1)\r\n maxAcc = pow(10, n) - 1\r\n q = queue.Queue()\r\n q.put((x, 0))\r\n seen = set()\r\n while not q.empty():\r\n top = q.get()\r\n if top[0] in seen or top[0] > maxAcc:\r\n continue\r\n seen.add(top[0])\r\n if top[0] >= minAcc and top[0] <= maxAcc:\r\n print(top[1])\r\n return\r\n st = str(top[0])\r\n chars = set()\r\n for char in st:\r\n chars.add(char)\r\n for char in chars:\r\n num = int(char)\r\n nex = top[0] * num\r\n q.put((nex, top[1] + 1))\r\n \r\n print(-1)\r\n \r\nsolve()"}, {"source_code": "n, x = input().split()\r\nn = int(n)\r\nans = float('inf')\r\n\r\nvisited = set()\r\nqueue = [(x, 0),]\r\n\r\nwhile queue:\r\n val, step = queue.pop(0)\r\n if val not in visited:\r\n visited.add(val)\r\n if len(val) == n:\r\n ans = step\r\n break\r\n\r\n elif len(val) < n:\r\n pos = set(list(val))\r\n for num in pos:\r\n if num != '0':\r\n new = str(int(val)*int(num))\r\n queue.append((new, step + 1))\r\n\r\nif ans == float('inf'):\r\n print(-1)\r\nelse:\r\n print(ans)\r\n"}, {"source_code": "n, x = input().split()\r\nn = int(n)\r\nans = float('inf')\r\n\r\nvisited = set()\r\nqueue = [(x, 0),]\r\n\r\nwhile queue:\r\n val, step = queue.pop(0)\r\n if val not in visited:\r\n visited.add(val)\r\n if len(val) == n:\r\n ans = min(ans, step)\r\n\r\n elif len(val) < n:\r\n pos = set(list(val))\r\n for num in pos:\r\n if num != '0':\r\n new = str(int(val)*int(num))\r\n queue.append((new, step + 1))\r\n\r\nif ans == float('inf'):\r\n print(-1)\r\nelse:\r\n print(ans)\r\n"}, {"source_code": "from io import BytesIO\nfrom os import fstat, read\n# input = BytesIO(read(0, fstat(0).st_size)).readline\nI = lambda:[*map(int,input().split())]\n\n# INT - int(input())\n# INT LIST - [*map(int,input().split())]\n# STRING - input().decode(\"UTF-8\")[:-2]\n# STRING - input().decode(\"UTF-8\").split()\n################################################################################\nfrom collections import deque\n# from itertools import combinations, permutations\n# from math import ceil\n# import heapq\n\n\nn, x = I()\nq = deque()\nq.append(x)\ndist = {x : 0}\nwhile q:\n\tnum = q.popleft()\n\ts = str(num)\n\tif len(s) == n:\n\t\tprint(dist[num])\n\t\tbreak\n\tfor i in range(9, 1, -1):\n\t\tif str(i) in s:\n\t\t\tnum2 = i * num\n\t\t\tif num2 not in dist:\n\t\t\t\tdist[num2] = dist[num] + 1\n\t\t\t\tq.append(num2)\nelse:\n\tprint(-1)\n\n\n\t\n\t\t\n\n\n\n\n"}, {"source_code": "\ndef solve(n, x, dp):\n if len(str(x)) >= n:\n return 0\n\n if x in dp:\n return dp[x]\n\n ans = float('inf')\n\n for i in str(x):\n if i != '1' and i != '0':\n ans = min(ans, 1+solve(n, x*int(i), dp))\n dp[x] = ans\n return ans\n\n\nn, x = map(int, input().split(' '))\ndp = {}\n\nsol = solve(n, x, dp)\nprint(-1 if sol == float('inf') else sol)\n"}, {"source_code": "from collections import deque\nfrom itertools import count\nfrom sys import stdin, stderr\n\nn, x = [int(x) for x in stdin.read().split()]\n\ntarget_lo = 10 ** (n - 1)\n\nseen = {x}\nqueue = deque([(x, 0)])\nwhile queue:\n x, n_iters = queue.popleft()\n v = x\n while v:\n v, mod = divmod(v, 10)\n t = x * mod\n if t in seen:\n continue\n if t >= target_lo:\n print(n_iters + 1)\n exit()\n else:\n seen.add(t)\n queue.append((t, n_iters + 1))\nprint(-1)\n"}, {"source_code": "# ----------------------------IMPORTING LIBRARIES----------------------------#\r\nimport math\r\nimport itertools\r\nimport heapq\r\nfrom math import floor, ceil\r\nfrom collections import deque\r\nimport sys\r\nfrom collections import Counter\r\n\r\n# ----------------------------LAMBDAS AND DEFAULT----------------------------#\r\nI = lambda: list(map(int, input().split()))\r\nM = lambda: map(int, input().split())\r\ninput = sys.stdin.readline\r\n#sys.setrecursionlimit(10000)\r\nMOD = 10 ** 9 + 7\r\n\r\n\r\n# -----------------------------STANDARD FUNCTIONS----------------------------#\r\ndef lcm(a, b):\r\n return abs(a * b) // math.gcd(a, b)\r\n\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 solve(total):\r\n ans = []\r\n m4, m6 = total // 4, total // 6\r\n for i in range(0, m4 + 1):\r\n for j in range(0, m6 + 1):\r\n if 4 * i + 6 * j == total:\r\n ans.append(i + j)\r\n return ans\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:\r\n hi = mid\r\n else:\r\n lo = mid + 1\r\n return lo\r\n\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:\r\n lo = mid + 1\r\n else:\r\n 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\ndef modexp(x, n):\r\n\tif (n == 0) :\r\n\t\treturn 1\r\n\telif (n % 2 == 0) :\r\n\t\treturn modexp((x * x) % m, n // 2)\r\n\telse :\r\n\t\treturn (x * modexp((x * x) % m,\r\n\t\t\t\t\t\t(n - 1) / 2) % m)\r\n\r\ndef primeModulo(a, b):\r\n\tc = gcd(a, b)\r\n\ta = a // c\r\n\tb = b // c\r\n\td = modexp(b, m - 2)\r\n\tans = ((a % m) * (d % m)) % m\r\n\treturn ans\r\n\r\n\r\n# ------------------------------HELPER FUNCTION------------------------------#\r\ndef fun():\r\n return\r\n\r\n\r\n# sys.stdout.write(str(X) + \"\\n\")\r\n\r\ndef solve(_):\r\n N, X = I()\r\n glob = []\r\n soFar = set()\r\n ans = float('inf')\r\n mem = {}\r\n def recursion(num, mul, a):\r\n poss = []\r\n for i in str(num): \r\n poss.append(int(i))\r\n if num in soFar:\r\n return mem[num]\r\n soFar.add(num)\r\n if len(str(num)) == N:\r\n mem[num] = mul\r\n return mul\r\n \r\n for i in poss:\r\n nex = num*i\r\n if nex == num or nex == 0:\r\n pass\r\n else:\r\n a = min(recursion(num*i, mul, a)+1, a)\r\n mem[num] = a\r\n return a \r\n\r\n ans = recursion(X, 0, float('inf'))\r\n\r\n if ans == float('inf'):\r\n print(-1)\r\n else:\r\n print(ans)\r\n# ---------------------------------DRIVER CODE--------------------------------#\r\nTC = 1\r\n#TC = int(input())\r\nfor testcases in range(TC):\r\n solve(testcases)\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": "from functools import lru_cache\r\nn, x = map(int, input().split())\r\n@lru_cache(None)\r\ndef F(x):\r\n\tif len(str(x)) >= n:\r\n\t\treturn 0\r\n\tz = 100\r\n\tfor i in range(2, 10):\r\n\t\tif str(i) in str(x):\r\n\t\t\tz = min(z, F(x * i) + 1)\r\n\treturn z\r\nz = F(x)\r\nif z == 100:\r\n\tz = -1\r\nprint(z)"}, {"source_code": "vis = dict()\r\n\r\ndef try_digits(n, x):\r\n if len(str(x)) == n:\r\n return 0\r\n\r\n digits = set()\r\n ans = 1000\r\n for digit in str(x):\r\n if digit == '0' or digit == '1':\r\n continue\r\n if digit not in digits:\r\n digits.add(int(digit))\r\n prod = int(digit) * x\r\n if prod not in vis:\r\n vis[prod] = try_digits(n, prod) + 1\r\n ans = min(ans, vis[prod])\r\n return ans\r\n\r\ndef solve():\r\n line = input().split()\r\n # print(line)\r\n n = int(line[0])\r\n x = int(line[1])\r\n ans = try_digits(n, x)\r\n print(-1) if ans == 1000 else print(ans)\r\n\r\n# Press the green button in the gutter to run the script.\r\nif __name__ == '__main__':\r\n t = 1\r\n # t = int(input())\r\n while t > 0:\r\n solve();\r\n t -= 1\r\n\r\n"}, {"source_code": "import copy\r\nimport gc\r\nimport itertools\r\nfrom array import array\r\nfrom fractions import Fraction\r\nimport heapq\r\nimport math\r\nimport operator\r\nimport os, sys\r\nimport profile\r\nimport cProfile\r\nimport random\r\nimport re\r\nimport string\r\nfrom bisect import bisect_left, bisect_right\r\nfrom collections import defaultdict, deque, Counter\r\nfrom functools import reduce, lru_cache\r\nfrom io import IOBase, BytesIO\r\nfrom itertools import count, groupby, accumulate, permutations, combinations_with_replacement, product\r\nfrom math import gcd\r\nfrom operator import xor, add\r\nfrom typing import List\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\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# print = lambda d: sys.stdout.write(str(d)+\"\\n\")\r\ndef read_int_list(): return list(map(int, input().split()))\r\ndef read_int_tuple(): return tuple(map(int, input().split()))\r\ndef read_int(): return int(input())\r\n\r\n\r\n# endregion\r\n\r\n### CODE HERE\r\n\r\n# f = open('inputs', 'r')\r\n# def input(): return f.readline().rstrip(\"\\r\\n\")\r\n\r\n# sys.setrecursionlimit(10000)\r\n\r\ndef solve(n, x):\r\n sx = str(x)\r\n if len(sx) == n: return 0\r\n\r\n if set(sx).issubset({'0', '1'}):\r\n return -1\r\n\r\n q = deque([(0, x)])\r\n seen = {x}\r\n while q:\r\n dist, y = q.popleft()\r\n sy = str(y)\r\n if len(sy) == n:\r\n # print(y)\r\n return dist\r\n for d in map(int, set(sy)):\r\n if d in (0, 1): continue\r\n z = y * d\r\n if z in seen: continue\r\n seen.add(z)\r\n q.append((dist + 1, z))\r\n\r\n\r\ndef main():\r\n for _ in range(1):\r\n n, x = read_int_tuple()\r\n print(solve(n, x))\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n# cProfile.run(\"main()\")\r\n"}, {"source_code": "n,x = map(int, input().split())\r\nq=[x]\r\nops={}\r\nops[x]=0\r\nresult=-1\r\n\r\nwhile len(q)>0:\r\n x=q.pop(0)\r\n str_x=str(x)\r\n if len(str_x)==n:\r\n result=ops[x]\r\n break\r\n for digit in str_x:\r\n new_number = int(digit)*x\r\n if new_number not in ops:\r\n q.append(new_number)\r\n ops[new_number]=ops[x]+1\r\n\r\nprint(result)\r\n\r\n"}, {"source_code": "from math import inf\r\n\r\ndef has_digit(x, i):\r\n while x > 0:\r\n if x%10 == i:\r\n return True\r\n x //= 10\r\n return False\r\n\r\ndef num_len(x):\r\n res = 0\r\n while x > 0:\r\n res += 1\r\n x //= 10\r\n return res\r\n\r\ndp = {}\r\n# n = target length\r\n# x = cur number\r\n# dp = 10-d list\r\n# dp[1][1][1][1][1][1]...\r\ndef dumb(n, x, state: tuple):\r\n global dp\r\n if num_len(x) == n:\r\n return 0\r\n if state in dp:\r\n return dp[state]\r\n \r\n ans = inf\r\n new_state = list(state)\r\n for i in range(2,10):\r\n if not has_digit(x, i):\r\n continue\r\n\r\n mult = i\r\n for idx, fac in enumerate((2, 3, 5, 7)):\r\n while mult%fac == 0:\r\n new_state[idx] += 1\r\n mult //= fac\r\n\r\n ans = min(ans, 1+dumb(n, x*i, tuple(new_state)))\r\n new_state = list(state)\r\n\r\n dp[state] = ans\r\n return ans\r\n\r\nn, x = [int(x) for x in input().split()]\r\nans = dumb(n,x,(0,0,0,0))\r\nprint(-1 if ans == inf else ans)\r\n"}, {"source_code": "from sys import exit\n\ndef isOne(x):\n flag = 1\n while(x):\n if(x%10 != 1):\n flag = 0\n break\n x /= 10\n return flag\n\nn, x = list(map(int,input().split()))\nq = [(x, 0)]\nvis = set()\n# print(n, x, len(str(x)))\nif isOne(x) or len(str(x)) > n:\n print(-1)\nelif len(str(x)) == n:\n print(0)\nelse:\n while len(q) > 0:\n t = q.pop(0)\n for i in str(t[0]):\n if len(str(t[0]*int(i))) == n:\n print(t[1]+1)\n q = []\n exit(0)\n next = t[0]*int(i)\n if((next!=t[0]) and (next not in vis)):\n q.append((next, t[1]+1))\n vis.add(next)\n print(-1)\n"}, {"source_code": "from queue import Queue as Q\r\nn, x = map(int, input().split())\r\nq = Q()\r\nq.put((x, 0))\r\nwas = set()\r\nwhile not q.empty():\r\n r = q.get()\r\n if r[0] >= 10**(n-1):\r\n print(r[1])\r\n break\r\n else:\r\n for i in str(r[0]):\r\n if i not in [0, 1]:\r\n new = int(i)*r[0]\r\n if new not in was:\r\n was.add(new)\r\n q.put((new, r[1]+1))\r\nelse:\r\n print(-1)\r\n"}, {"source_code": "import io,os\nfrom collections import deque \n\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndef main(t):\n\n n,x = map(int,input().split())\n dic = {}\n queue = deque()\n queue.append([str(x),0])\n\n while queue:\n s,step = queue.popleft()\n for c in s:\n nexts = str(int(s)*int(c))\n if len(nexts)==n: \n print(step+1)\n return \n if nexts in dic: continue \n dic[nexts] = 1\n queue.append([nexts,step+1])\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\nT = 1 #int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}, {"source_code": "from math import gcd, sqrt, log, factorial\r\nfrom functools import cmp_to_key\r\nfrom string import ascii_lowercase as alph\r\nimport os, sys\r\nfrom itertools import permutations, combinations\r\nimport heapq\r\nfrom io import BytesIO, IOBase\r\nfrom collections import deque, Counter\r\n\r\n\r\n############################################################################\r\n#\t\t\t\t\t\t\t\tFAST-IO\t\t\t\t\t\t\t\t #\r\n#\t\t\t\t\t\t\t\tTEMPLATES #\r\n############################################################################\r\n \r\n \r\nfast = True\r\nif fast:\r\n \r\n\tBUFSIZE = 8192\r\n \r\n\tclass FastIO(IOBase):\r\n\t\tnewlines = 0\r\n\t \r\n\t\tdef __init__(self, file):\r\n\t\t\tself._fd = file.fileno()\r\n\t\t\tself.buffer = BytesIO()\r\n\t\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n\t\t\tself.write = self.buffer.write if self.writable else None\r\n\t \r\n\t\tdef read(self):\r\n\t\t\twhile True:\r\n\t\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\t\tif not b:\r\n\t\t\t\t\tbreak\r\n\t\t\t\tptr = self.buffer.tell()\r\n\t\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\t\tself.newlines = 0\r\n\t\t\treturn self.buffer.read()\r\n\t \r\n\t\tdef readline(self):\r\n\t\t\twhile self.newlines == 0:\r\n\t\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\r\n\t\t\t\tptr = self.buffer.tell()\r\n\t\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\t\tself.newlines -= 1\r\n\t\t\treturn self.buffer.readline()\r\n\t \r\n\t\tdef flush(self):\r\n\t\t\tif self.writable:\r\n\t\t\t\tos.write(self._fd, self.buffer.getvalue())\r\n\t\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\r\n\t \r\n\t \r\n\tclass IOWrapper(IOBase):\r\n\t\tdef __init__(self, file):\r\n\t\t\tself.buffer = FastIO(file)\r\n\t\t\tself.flush = self.buffer.flush\r\n\t\t\tself.writable = self.buffer.writable\r\n\t\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n\t\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\r\n\t\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\t \r\n\t \r\n\tdef print(*args, **kwargs):\r\n\t\t\"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n\t\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n\t\tat_start = True\r\n\t\tfor x in args:\r\n\t\t\tif not at_start:\r\n\t\t\t\tfile.write(sep)\r\n\t\t\tfile.write(str(x))\r\n\t\t\tat_start = False\r\n\t\tfile.write(kwargs.pop(\"end\", \"\\n\"))\r\n\t\tif kwargs.pop(\"flush\", False):\r\n\t\t\tfile.flush()\r\n\t \r\n\t \r\n\tif sys.version_info[0] < 3:\r\n\t\tsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\n\telse:\r\n\t\tsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\t \r\n\tinput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\n \r\nif os.path.exists('input.txt'):\r\n\tsys.stdin = open('input.txt')\r\n\tsys.stdout = open('output.txt', 'w')\r\n \r\nINF = float('inf')\r\n\r\ndef C(n, k, mod):\r\n\tcntn = 0\r\n\tcntk = 0\r\n\tif 0 <= k <= n:\r\n\t\tnn = 1\r\n\t\tkk = 1\r\n\t\tfor t in range(1, min(k, n - k) + 1):\r\n\t\t\tnn *= n\r\n\t\t\tcntn = (cntn * mod + nn) // mod\r\n\t\t\tnn %= mod\r\n\t\t\tkk *= t\r\n\t\t\tcntk = (cntk * mod + kk) // mod\r\n\t\t\tkk %= mod\r\n\t\t\tn -= 1\r\n\t\treturn (nn + cntn * mod) // (kk + cntk * mod) % mod\r\n\telse:\r\n\t\treturn 0\r\n\r\ndef isPrime(n):\r\n\tif n == 1: return 0\r\n\tif n % 2 == 0: return n == 2\r\n\ti = 3\r\n\twhile i * i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\treturn 0\r\n\t\ti += 2\r\n\treturn 1\r\n \r\ndef divCeil(a, b):\r\n\treturn (a - 1) // b + 1\r\n \r\ndef readList():\r\n\treturn [int(i) for i in input().split()]\r\n \r\ndef getSum(prefSum, l, r):\r\n\tif l == 0:\r\n\t\treturn prefSum[r]\r\n\treturn prefSum[r] - prefSum[l - 1]\r\n\r\ndef getProd(l, r):\r\n\tglobal prefProd\r\n\tif l == 0:\r\n\t\treturn prefProd[r]\r\n\treturn prefProd[r] // prefProd[l - 1]\r\n\r\ndef getsum(BITTree,i):\r\n\ts = 0\r\n\ti = i + 1\r\n\twhile i > 0:\r\n\t\ts += max(1, BITTree[i])\r\n\t\ti -= i & (-i)\r\n\treturn s\r\n \r\ndef updatebit(BITTree , n , i ,v):\r\n\ti += 1\r\n\twhile i <= n:\r\n\t\tBITTree[i] += v\r\n\t\ti += i & (-i)\r\n \r\ndef construct(arr, n):\r\n\tBITTree = [0] * (n + 1)\r\n \r\n\tfor i in range(n):\r\n\t\tupdatebit(BITTree, n, i, arr[i])\r\n \r\n\treturn BITTree\r\n\r\ndef solve():\r\n\tn, x = readList()\r\n\tproc = [x]\r\n\tans = INF\r\n\twave = 0\r\n\twhile True:\r\n\t\tnew_proc = set()\r\n\t\tfor x in proc:\r\n\t\t\tif len(str(x)) >= n:\r\n\t\t\t\tans = min(ans, wave)\r\n\t\t\t\tcontinue\r\n\t\t\tfor i in range(2, 10):\r\n\t\t\t\tif str(i) in str(x):\r\n\t\t\t\t\tnew_proc.add(i * x)\r\n\t\tif len(new_proc) == 0:\r\n\t\t\tbreak\r\n\t\tproc = list(new_proc)\r\n\t\twave += 1\r\n\tif ans == INF:\r\n\t\tprint(-1)\r\n\telse:\r\n\t\tprint(ans)\r\n\t\r\n\r\nt = 1\r\nwhile t:\r\n\tt -= 1\r\n\tsolve()"}, {"source_code": "from functools import lru_cache\r\nfrom time import sleep\r\n\r\nINF = 1e100\r\ns = dict()\r\n# @lru_cache(None)\r\ndef solve(x, cur, k):\r\n if x in s:\r\n return s[x] + cur\r\n if len(str(x)) == k:\r\n return cur\r\n if len(str(x)) > k:\r\n return INF\r\n if x == 0 and k != 1:\r\n return INF\r\n ans = INF\r\n for i in str(x):\r\n if i != '1':\r\n ans = min(ans, solve(int(i) * x, cur + 1, k))\r\n s[x] = ans - cur\r\n return ans\r\n\r\nk, x = map(int, input().split())\r\nx = solve(x, 0, k)\r\nif x < INF:\r\n print(x)\r\nelse:\r\n print(-1)"}, {"source_code": "from collections import deque\r\nn,x=map(int,input().split())\r\nq=deque()\r\ndist={}\r\ndist[x]=0\r\nq.append(x)\r\nwhile q:\r\n p=q.popleft()\r\n if len(str(p))==n:\r\n print(dist[p])\r\n exit()\r\n else:\r\n for el in str(p):\r\n if el!=\"0\":\r\n w=p*int(el)\r\n if w not in dist:\r\n dist[w]=dist[p]+1\r\n q.append(w)\r\nprint(-1)\r\nexit()"}, {"source_code": "from math import gcd, sqrt, log, factorial\r\nfrom functools import cmp_to_key\r\nfrom string import ascii_lowercase as alph\r\nimport os, sys\r\nfrom itertools import permutations, combinations\r\nimport heapq\r\nfrom io import BytesIO, IOBase\r\nfrom collections import deque, Counter\r\n\r\n\r\n############################################################################\r\n#\t\t\t\t\t\t\t\tFAST-IO\t\t\t\t\t\t\t\t #\r\n#\t\t\t\t\t\t\t\tTEMPLATES #\r\n############################################################################\r\n \r\n \r\nfast = True\r\nif fast:\r\n \r\n\tBUFSIZE = 8192\r\n \r\n\tclass FastIO(IOBase):\r\n\t\tnewlines = 0\r\n\t \r\n\t\tdef __init__(self, file):\r\n\t\t\tself._fd = file.fileno()\r\n\t\t\tself.buffer = BytesIO()\r\n\t\t\tself.writable = \"x\" in file.mode or \"r\" not in file.mode\r\n\t\t\tself.write = self.buffer.write if self.writable else None\r\n\t \r\n\t\tdef read(self):\r\n\t\t\twhile True:\r\n\t\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\t\tif not b:\r\n\t\t\t\t\tbreak\r\n\t\t\t\tptr = self.buffer.tell()\r\n\t\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\t\tself.newlines = 0\r\n\t\t\treturn self.buffer.read()\r\n\t \r\n\t\tdef readline(self):\r\n\t\t\twhile self.newlines == 0:\r\n\t\t\t\tb = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))\r\n\t\t\t\tself.newlines = b.count(b\"\\n\") + (not b)\r\n\t\t\t\tptr = self.buffer.tell()\r\n\t\t\t\tself.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)\r\n\t\t\tself.newlines -= 1\r\n\t\t\treturn self.buffer.readline()\r\n\t \r\n\t\tdef flush(self):\r\n\t\t\tif self.writable:\r\n\t\t\t\tos.write(self._fd, self.buffer.getvalue())\r\n\t\t\t\tself.buffer.truncate(0), self.buffer.seek(0)\r\n\t \r\n\t \r\n\tclass IOWrapper(IOBase):\r\n\t\tdef __init__(self, file):\r\n\t\t\tself.buffer = FastIO(file)\r\n\t\t\tself.flush = self.buffer.flush\r\n\t\t\tself.writable = self.buffer.writable\r\n\t\t\tself.write = lambda s: self.buffer.write(s.encode(\"ascii\"))\r\n\t\t\tself.read = lambda: self.buffer.read().decode(\"ascii\")\r\n\t\t\tself.readline = lambda: self.buffer.readline().decode(\"ascii\")\r\n\t \r\n\t \r\n\tdef print(*args, **kwargs):\r\n\t\t\"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\r\n\t\tsep, file = kwargs.pop(\"sep\", \" \"), kwargs.pop(\"file\", sys.stdout)\r\n\t\tat_start = True\r\n\t\tfor x in args:\r\n\t\t\tif not at_start:\r\n\t\t\t\tfile.write(sep)\r\n\t\t\tfile.write(str(x))\r\n\t\t\tat_start = False\r\n\t\tfile.write(kwargs.pop(\"end\", \"\\n\"))\r\n\t\tif kwargs.pop(\"flush\", False):\r\n\t\t\tfile.flush()\r\n\t \r\n\t \r\n\tif sys.version_info[0] < 3:\r\n\t\tsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\r\n\telse:\r\n\t\tsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\r\n\t \r\n\tinput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\n \r\n \r\nif os.path.exists('input.txt'):\r\n\tsys.stdin = open('input.txt')\r\n\tsys.stdout = open('output.txt', 'w')\r\n \r\nINF = float('inf')\r\n\r\ndef C(n, k, mod):\r\n\tcntn = 0\r\n\tcntk = 0\r\n\tif 0 <= k <= n:\r\n\t\tnn = 1\r\n\t\tkk = 1\r\n\t\tfor t in range(1, min(k, n - k) + 1):\r\n\t\t\tnn *= n\r\n\t\t\tcntn = (cntn * mod + nn) // mod\r\n\t\t\tnn %= mod\r\n\t\t\tkk *= t\r\n\t\t\tcntk = (cntk * mod + kk) // mod\r\n\t\t\tkk %= mod\r\n\t\t\tn -= 1\r\n\t\treturn (nn + cntn * mod) // (kk + cntk * mod) % mod\r\n\telse:\r\n\t\treturn 0\r\n\r\ndef isPrime(n):\r\n\tif n == 1: return 0\r\n\tif n % 2 == 0: return n == 2\r\n\ti = 3\r\n\twhile i * i <= n:\r\n\t\tif n % i == 0:\r\n\t\t\treturn 0\r\n\t\ti += 2\r\n\treturn 1\r\n \r\ndef divCeil(a, b):\r\n\treturn (a - 1) // b + 1\r\n \r\ndef readList():\r\n\treturn [int(i) for i in input().split()]\r\n \r\ndef getSum(prefSum, l, r):\r\n\tif l == 0:\r\n\t\treturn prefSum[r]\r\n\treturn prefSum[r] - prefSum[l - 1]\r\n\r\ndef getProd(l, r):\r\n\tglobal prefProd\r\n\tif l == 0:\r\n\t\treturn prefProd[r]\r\n\treturn prefProd[r] // prefProd[l - 1]\r\n\r\ndef getsum(BITTree,i):\r\n\ts = 0\r\n\ti = i + 1\r\n\twhile i > 0:\r\n\t\ts += max(1, BITTree[i])\r\n\t\ti -= i & (-i)\r\n\treturn s\r\n \r\ndef updatebit(BITTree , n , i ,v):\r\n\ti += 1\r\n\twhile i <= n:\r\n\t\tBITTree[i] += v\r\n\t\ti += i & (-i)\r\n \r\ndef construct(arr, n):\r\n\tBITTree = [0] * (n + 1)\r\n \r\n\tfor i in range(n):\r\n\t\tupdatebit(BITTree, n, i, arr[i])\r\n \r\n\treturn BITTree\r\n\r\ndef solve():\r\n\tn, x = readList()\r\n\tproc = [x]\r\n\tans = INF\r\n\twave = 0\r\n\twhile True:\r\n\t\tnew_proc = set()\r\n\t\tfor x in proc:\r\n\t\t\tif len(str(x)) >= n:\r\n\t\t\t\tans = min(ans, wave)\r\n\t\t\t\tcontinue\r\n\t\t\tfor i in range(2, 10):\r\n\t\t\t\tif str(i) in str(x):\r\n\t\t\t\t\tnew_proc.add(i * x)\r\n\t\tif len(new_proc) == 0:\r\n\t\t\tbreak\r\n\t\tproc = list(new_proc)\r\n\t\twave += 1\r\n\tif ans == INF:\r\n\t\tprint(-1)\r\n\telse:\r\n\t\tprint(ans)\r\n\t\r\n\r\nt = 1\r\nwhile t:\r\n\tt -= 1\r\n\tsolve()"}, {"source_code": "N, X = map(int, input().split())\n\nINF = 10**18\n\nD = {X: 0}\nQ = [X]\n\nfor i in Q:\n d = D[i]\n s = str(i)\n n = len(s)\n if n == N:\n print(d)\n break\n elif n > N:\n continue\n\n for c in s:\n j = i * (ord(c) - ord('0'))\n if d + 1 < D.get(j, INF):\n D[j] = d+1\n Q.append(j)\nelse:\n print(-1)\n"}, {"source_code": "from collections import deque\r\nn,x = map(int,input().split(' '))\r\n\r\nq = deque()\r\nq.append(x)\r\ndist = {x: 0}\r\nans = -1\r\nwhile len(q) > 0:\r\n num = q.popleft()\r\n s = str(num)\r\n if len(s)==n:\r\n ans = dist[num]\r\n break\r\n for d in range(2,10):\r\n if str(d) in s:\r\n num2 = num*d\r\n if num2 not in dist:\r\n dist[num2] = dist[num]+1\r\n q.append(num2)\r\nprint(ans)"}, {"source_code": "from collections import deque as Queue\r\n\r\nn, x = map(int, input().split())\r\n\r\nans = 10**18\r\nque = Queue()\r\nque.append((str(x), 0))\r\nst = set()\r\nwhile que:\r\n now, cnt = que.pop()\r\n if len(now) == n:\r\n ans = cnt\r\n break\r\n\r\n for c in ''.join(set(now)):\r\n nxt = str(int(now) * int(c))\r\n if (len(nxt) > n):\r\n continue\r\n if int(nxt) in st:\r\n continue\r\n que.appendleft((nxt, cnt + 1))\r\n st.add(int(nxt))\r\n\r\nprint('-1' if ans == 10**18 else ans)"}, {"source_code": "import sys\nfrom bisect import bisect_right, bisect_left\nimport os\nimport sys\nfrom io import BytesIO, IOBase\nfrom math import factorial, floor, sqrt, inf, ceil, gcd\nfrom collections import defaultdict, deque, Counter\nfrom functools import cmp_to_key\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############ ---- 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\n###functions\n\n### Calculate C(n, r) mod p, where p is prime (fast with precalculation)\n\ndef build_mod_inverses(n, r, p):\n fact = [1] * (n + 1)\n for i in range(1, n + 1):\n fact[i] = i * fact[i - 1] % p\n \n inv = [1] * (n + 1)\n inv[n] = pow(fact[n], p - 2, p)\n for i in range(n - 1, -1, -1):\n inv[i] = (i + 1) * inv[i + 1] % p\n \n return fact, inv\n\n# fast C(n, r) mod p calculation using predefined fact and inv\ndef comb(n, r, p, fact, inv):\n return fact[n] * inv[r] % p * inv[n - r] % p if n >= r >= 0 else 0\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 and i != 1:\n divisors.append(n // i)\n return divisors\n\ndef dfs(graph, vertex):\n visited = set()\n tree = []\n deq = deque([vertex])\n while deq:\n vertex = deq.pop()\n if vertex not in visited:\n visited.add(vertex)\n deq.extend(graph[vertex])\n tree.append(vertex)\n return tree\n\ndef find_in_sorted_list(elem, sorted_list):\n # https://docs.python.org/3/library/bisect.html\n 'Locate the leftmost value exactly equal to x'\n i = bisect_left(sorted_list, elem)\n if i != len(sorted_list) and sorted_list[i] == elem:\n return i\n return -1\n\n############ SEGMENT TREE ##############\n\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 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###code\n\nn, x = inlt()\ndepth = 0\nstart = (x, depth)\nvisited = set()\n\nif set(str(x)) == set('1') or set(str(x)) == set('0') or set(str(x)) == set(['1', '0']):\n print(-1)\n sys.exit()\n\ndeq = deque([start])\nwhile deq:\n vertex = deq.popleft()\n if vertex not in visited:\n visited.add(vertex)\n if len(str(vertex[0])) >= n:\n print(vertex[1])\n sys.exit()\n \n for num in str(vertex[0]):\n val = vertex[0] * int(num)\n depth = vertex[1]+1\n deq.append((val, depth))\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n, x = map(int, input().split())\r\nfrom collections import deque\r\nQ = deque()\r\ndp = {}\r\ndp[x] = 0\r\nQ.append(x)\r\n\r\ndef length(p):\r\n ans = 0\r\n while p:\r\n ans += 1\r\n p //= 10\r\n return ans\r\n\r\nyesCase = 0\r\n\r\nwhile Q:\r\n u = Q.popleft()\r\n if length(u) == n:\r\n print(dp[u])\r\n yesCase = 1\r\n break\r\n v = u\r\n st = set()\r\n while v:\r\n st.add(v % 10)\r\n v //= 10\r\n vt = list(st)\r\n for i in range(len(vt)):\r\n curr = u * vt[i]\r\n if curr not in dp:\r\n # if length(curr) < dp[u]:\r\n # continue\r\n dp[curr] = dp[u] + 1\r\n Q.append(curr)\r\nif yesCase == 0:\r\n print(-1)"}, {"source_code": "import sys, io, os\r\n\r\n\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\n\r\ncache = {}\r\n\r\n\r\ndef digits(x):\r\n digits = sorted([int(digit) for digit in set([ch for ch in str(x)])])\r\n return digits\r\n\r\n\r\ndef count_operations(n, x):\r\n cached = cache.get(x)\r\n if cached:\r\n return cached\r\n\r\n str_x = str(x)\r\n if len(str_x) == n:\r\n return 0\r\n\r\n min_op = float(\"inf\")\r\n for d in digits(x):\r\n if d < 2:\r\n continue\r\n\r\n min_op = min(min_op, 1 + count_operations(n, x * d))\r\n\r\n cache[x] = min_op\r\n return min_op\r\n\r\n\r\nn, x = map(int, input().split())\r\nc = count_operations(n, x)\r\nif c == float(\"inf\"):\r\n c = -1\r\nsys.stdout.write(f\"{c}\\n\")\r\n"}, {"source_code": "import io,os\nfrom collections import deque \n\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndef main(t):\n\n\n n,x = map(int,input().split())\n\n queue = deque()\n queue.append([str(x),0])\n dic = {}\n\n while queue:\n s,step = queue.popleft()\n for c in s:\n nexts = str(int(s)*int(c))\n if len(nexts)==n: \n print(step+1)\n return \n if nexts in dic: continue \n dic[nexts] = 1\n queue.append([nexts,step+1])\n \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\nT = 1 #int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}, {"source_code": "n, x = input().split()\r\nn = int(n)\r\nans = float('inf')\r\n\r\nvisited = set()\r\nqueue = [(x, 0),]\r\n\r\nwhile queue:\r\n val, step = queue.pop(0)\r\n if val not in visited:\r\n visited.add(val)\r\n if len(val) == n:\r\n ans = step\r\n break\r\n\r\n elif len(val) < n:\r\n pos = set(list(val))\r\n for num in pos:\r\n if num != '0':\r\n new = str(int(val)*int(num))\r\n queue.append((new, step + 1))\r\n\r\nif ans == float('inf'):\r\n print(-1)\r\nelse:\r\n print(ans)\r\n"}, {"source_code": "(n, x) = map(int, input().split())\n\nq = [(x, 0)]\n\nmaxlen = {}\n\nsucc = 0\n\nans = float('inf')\n\ngoal = 10 ** (n - 1)\n\nwhile len(q) > 0:\n (num, ops) = q.pop(-1)\n if ops >= ans:\n continue\n if num >= goal:\n ans = ops\n continue\n # print(ori, l, ops)\n need = 0\n tmp = num\n while tmp < goal:\n tmp *= 9\n need += 1\n if need + ops >= ans:\n continue\n appeared = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n tmp = num\n while tmp > 0:\n appeared[tmp % 10] = 1\n tmp //= 10\n for digit in range(9, 1, -1):\n if appeared[digit] == 1:\n q.append((num * digit, ops + 1))\n\nif ans == float('inf'):\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "from collections import *\r\nimport sys\r\nimport io, os\r\nimport math\r\nimport random\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\n \r\ndef cleanarr(arr):\r\n n = len(arr)\r\n # put comment if arr already sorted\r\n arr.sort()\r\n c = [[1, arr[0]]]\r\n k = 0\r\n for i in range(n - 1):\r\n if (arr[i] != arr[i + 1]):\r\n c.append([1,arr[i + 1]])\r\n k += 1\r\n else:\r\n c[k][0] += 1\r\n return c\r\n \r\ndef main():\r\n t=1\r\n for _ in range(t):\r\n arr=list(map(int, input().split()))\r\n n=arr[0]\r\n x=arr[1]\r\n if(len(str(x))==n):\r\n print(0)\r\n continue\r\n dic={}\r\n dic[x]=1\r\n c=0\r\n while(True):\r\n c+=1\r\n ndic={}\r\n ma=0\r\n for j in dic:\r\n s=str(j)\r\n for k in s:\r\n if(int(k)>1):\r\n f=True\r\n ndic[int(k)*j]=1\r\n ma=max(ma,int(k)*j)\r\n if(ma==0):\r\n c=-1\r\n break\r\n if(len(str(ma))==n):\r\n break\r\n dic=ndic\r\n print(c)\r\n \r\nmain()"}, {"source_code": "# import sys\r\n# sys.stdin = open('input.txt', 'r')\r\nimport math\r\nfrom collections import deque\r\n\r\nn,x =map(int,input().split(\" \"))\r\ndp={}\r\ndp[x]=0\r\ncurrent=x\r\nlowest=math.inf\r\nnextInLine=deque([x])\r\n\r\nwhile nextInLine:\r\n\tif len(str(current))<=n:\r\n\t\tfor r in str(current):\r\n\t\t\tif(r!='1' and r!='0'):\r\n\t\t\t\tif not current*int(r) in dp or dp[current*int(r)]>dp[current]+1:\t\t\t\t\r\n\t\t\t\t\tdp[current*int(r)]=dp[current]+1\r\n\t\t\t\t\tnextInLine.append(current*int(r))\r\n\t\t\t\t\tif(len(str(current*int(r)))==n):\r\n\t\t\t\t\t\tif(dp[current*int(r)]= 1000:\r\n print(-1)\r\nelse:\r\n print(ans)"}, {"source_code": "import sys\r\nimport math\r\nimport heapq\r\nimport bisect\r\nfrom collections import Counter, defaultdict, deque\r\nfrom io import BytesIO, IOBase\r\nfrom types import GeneratorType\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 yes_no(b):\r\n if b:\r\n return \"YES\"\r\n else:\r\n return \"NO\"\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\r\n return wrappedfunc\r\n\r\n\r\ndef binary_search(good, left, right, delta=1, right_true=False):\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 n = get_int()\r\n a = get_ints()\r\n m = get_int()\r\n b = get_ints()\r\n m = max(a)\r\n M = max(b)\r\n if m > M:\r\n print(\"Alice\")\r\n print(\"Alice\")\r\n elif M > m:\r\n print(\"Bob\")\r\n print(\"Bob\")\r\n else:\r\n print(\"Alice\")\r\n print(\"Bob\")\r\n return\r\n\r\n\r\ndef solve_b():\r\n n = get_int()\r\n a = get_ints()\r\n m = get_int()\r\n b = get_ints()\r\n\r\n S = sum(b)\r\n i = S % n\r\n return a[i]\r\n\r\n\r\ndef solve_c():\r\n n = get_int()\r\n a = get_ints()\r\n b = get_ints()\r\n\r\n c = [(a[i], b[i], i) for i in range(n)]\r\n c.sort()\r\n\r\n for i in range(1, n):\r\n if c[i][1] < c[i - 1][1]:\r\n print(-1)\r\n return\r\n\r\n pos = [None] * n\r\n for i in range(n):\r\n pos[c[i][-1]] = i\r\n\r\n\r\n swaps = pos\r\n ans = []\r\n for i in range(n):\r\n for j in range(i + 1, n):\r\n if swaps[i] > swaps[j]:\r\n ans.append((i + 1, j + 1))\r\n swaps[i], swaps[j] = swaps[j], swaps[i]\r\n\r\n print(len(ans))\r\n for line in ans:\r\n print(*line)\r\n return\r\n\r\n\r\ndef solve_d():\r\n n, x = get_ints()\r\n if x == 1:\r\n if n == 1:\r\n return 0\r\n else:\r\n return -1\r\n dp = {}\r\n q = deque([(x, 0)])\r\n small = 10 ** (n - 1)\r\n big = small * 10\r\n\r\n while q:\r\n y, c = q.popleft()\r\n if y in dp:\r\n continue\r\n else:\r\n dp[y] = c\r\n for x in str(y):\r\n z = int(x)\r\n p = z * y\r\n if p in dp or p >= big:\r\n continue\r\n else:\r\n q.append((p, c + 1))\r\n if p >= small:\r\n return c + 1\r\n return -1\r\n\r\n\r\nprint(solve_d())\r\n"}, {"source_code": "n, x = map(int, input().split())\r\nans = 100\r\n\r\n\r\ndef dfs(x, k=3, c=0):\r\n global ans\r\n if c + n - len(str(x)) >= ans:\r\n return -1\r\n if len(str(x)) >= n:\r\n return c\r\n j = 0\r\n for i in sorted(map(int, set(str(x))), reverse=True):\r\n if i <= 1:\r\n continue\r\n if j == k:\r\n break\r\n j += 1\r\n r = dfs(x * i, k, c + 1)\r\n if r == -1:\r\n continue\r\n assert r <= ans\r\n ans = r\r\n return ans\r\n\r\n\r\ndfs(x, k=100)\r\nprint(ans if ans != 100 else -1)\r\n"}, {"source_code": "inf = float(\"inf\")\r\n\r\ndef get_next_state(mult: int, state: list):\r\n new_state = list(state)\r\n for idx, fac in enumerate((2,3,5,7)):\r\n while mult%fac == 0:\r\n new_state[idx] += 1\r\n mult //= fac\r\n return tuple(new_state)\r\n\r\n# dp[(2s, 3s, 5s, 7s)]\r\ndef dumb(n, x, state: tuple, dp: dict):\r\n if len(str(x)) == n:\r\n return 0\r\n if state in dp:\r\n return dp[state]\r\n \r\n ans = inf\r\n for i in range(2,10):\r\n if str(i) in str(x):\r\n next_state = get_next_state(i, state)\r\n ans = min(ans, 1+dumb(n, x*i, next_state, dp))\r\n\r\n dp[state] = ans\r\n return ans\r\n\r\nn, x = [int(x) for x in input().split()]\r\nans = dumb(n, x, (0,0,0,0), {})\r\nprint(-1 if ans == inf else ans)\r\n"}, {"source_code": "import sys, io, os\r\n\r\n\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\n\r\ncache = {}\r\n\r\n\r\ndef digits(x):\r\n digits = sorted([int(digit) for digit in set([ch for ch in str(x)])])\r\n return digits\r\n\r\n\r\ndef count_operations(n, x):\r\n cached = cache.get(x)\r\n if cached:\r\n return cached\r\n\r\n str_x = str(x)\r\n if len(str_x) == n:\r\n return 0\r\n\r\n min_op = float(\"inf\")\r\n for d in digits(x):\r\n if d < 2:\r\n continue\r\n\r\n min_op = min(min_op, 1 + count_operations(n, x * d))\r\n\r\n cache[x] = min_op\r\n return min_op\r\n\r\n\r\nn, x = map(int, input().split())\r\nc = count_operations(n, x)\r\nif c == float(\"inf\"):\r\n c = -1\r\nsys.stdout.write(f\"{c}\\n\")\r\n"}, {"source_code": "import io,os\nfrom collections import deque \n\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\ndef main(t):\n\n n,x = map(int,input().split())\n dic = {}\n queue = deque()\n queue.append([str(x),0])\n\n while queue:\n s,step = queue.popleft()\n for c in s:\n nexts = str(int(s)*int(c))\n if len(nexts)==n: \n print(step+1)\n return \n if nexts in dic: continue \n dic[nexts] = 1\n queue.append([nexts,step+1])\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\nT = 1 #int(input())\nt = 1\nwhile t<=T:\n main(t)\n t += 1\n"}], "negative_code": [{"source_code": "from collections import deque\r\nfrom functools import cmp_to_key\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef dfs(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max([int(j)*int(i)*int(k) for i in str(a*x) for j in str(int(i)*a*x) for k in str(int(i)*a*x*int(j))]))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n\r\n\r\n \r\ndef dfs1(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max(int(i) for i in str(a*x)))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs1(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs2(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs2(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs3(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num = reversed(num)\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs3(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef solve():\r\n n, x = map(int, input().split())\r\n ret = dfs(x, 0, n)\r\n ret = min(ret, dfs1(x, 0, n))\r\n ret = min(ret, dfs2(x, 0, n))\r\n ret = min(ret, dfs3(x, 0, n))\r\n if ret:\r\n return ret\r\n return -1\r\n \r\n \r\n \r\n# for __ in range(int(input())):\r\nprint(solve())\r\n # print('YES' if solve() else 'NO')\r\n # solve()"}, {"source_code": "from re import A, L, M, X\r\nimport sys\r\nfrom collections import deque\r\nimport math\r\nfrom bisect import bisect_left\r\nfrom functools import cmp_to_key\r\nimport random\r\n \r\nsys.setrecursionlimit(10**4)\r\ndef II():\r\n\treturn int(sys.stdin.readline())\r\n \r\ndef LI():\r\n\treturn list(map(int, sys.stdin.readline().split()))\r\n \r\ndef MI():\r\n\treturn map(int, sys.stdin.readline().split())\r\n \r\ndef SI():\r\n\treturn sys.stdin.readline().strip()\r\n \r\ndef FACT(n, mod):\r\n s = 1\r\n facts = [1]\r\n for i in range(1,n+1):\r\n s*=i\r\n s%=mod\r\n facts.append(s)\r\n return facts[n]\r\n \r\ndef C(n, k, mod):\r\n return (FACT(n,mod) * pow((FACT(k,mod)*FACT(n-k,mod))%mod,mod-2, mod))%mod\r\n \r\ndef lcm(a,b):\r\n return abs(a*b) // math.gcd(a, b)\r\n \r\ndef ask(n):\r\n print(n)\r\n sys.stdout.flush()\r\n temp = II()\r\n sys.stdout.flush()\r\n return temp\r\ndef answer(n):\r\n print(\"!\", n)\r\n sys.stdout.flush()\r\n \r\nn,x = SI().split()\r\nn = int(n)\r\ndef mul(x,y):\r\n newX = \"\"\r\n car = 0\r\n for i in x[::-1]:\r\n temp = int(i)*int(y)+car\r\n newX+=str(temp%10)\r\n car = temp//10\r\n if car > 0:\r\n newX+=str(car)\r\n return newX[::-1]\r\ndef solve(n,x,c):\r\n if len(x) == n:\r\n return c\r\n if \"9\" in x:\r\n return solve(n,mul(x, \"9\"),c+1)\r\n m = \"0\"\r\n temp = \"0\"\r\n for i in set(x):\r\n if i != \"1\":\r\n t = mul(x, i)\r\n if max(t) > m:\r\n m = max(t)\r\n temp = i\r\n if temp == max(x):\r\n return solve(n, mul(x, max(x)), c+1)\r\n return min(solve(n, mul(x, max(x)), c+1), solve(n, mul(x, temp), c+1))\r\nif (len(set(x)) == 1 and x[0] == \"1\" or len(set(x)) == 2 and \"1\" in x and \"0\" in x) and len(x) != n:\r\n print(-1)\r\nelse:\r\n print(solve(n,x,0))"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\n\r\nn, x = map(int, input().split())\r\ncnt = 0\r\n\r\ndef calclen(x):\r\n a = list(str(x))\r\n mx = int(max(a))\r\n return len(str(x * mx))\r\n\r\ndef solve(n, x):\r\n global cnt\r\n\r\n \r\n a = list(str(x))\r\n mxlen = len(a)\r\n sa = set(a)\r\n if len(sa) == 1 and a[0] == '1' and n > mxlen:\r\n return False\r\n \r\n if mxlen > n:\r\n return False\r\n\r\n candidates = [x]\r\n mxnextlen = mxlen\r\n\r\n while mxlen < n:\r\n # printf(len(candidates))\r\n for c in candidates:\r\n a = list(str(c))\r\n for i in range(2, 10):\r\n if str(i) in a:\r\n mxnextlen = max(mxnextlen, calclen(c * i))\r\n mxlen = max(mxlen, calclen(c))\r\n\r\n newcand = []\r\n for c in candidates:\r\n a = list(str(c))\r\n for i in range(2, 10):\r\n if str(i) in a and calclen(i*c) == mxnextlen:\r\n newcand.append(i*c)\r\n\r\n\r\n # printf(newcand)\r\n candidates = newcand\r\n cnt += 1\r\n\r\n return True\r\n\r\nprintf(cnt) if solve(n, x) else printf(-1)\r\n"}, {"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\nfrom collections import deque\r\n\r\nn, x = map(int, input().split())\r\n\r\noklow, okmax = (10**(n - 1), 10**n - 1)\r\ndef count(e):\r\n return oklow <= e <= okmax\r\n\r\nif x == \"1\":\r\n print(\"-1\")\r\nelse:\r\n Q = deque([(x, 0)])\r\n V = {}\r\n r = 10000\r\n while Q:\r\n e, d = Q.pop()\r\n V[e] = d\r\n\r\n if count(e):\r\n r = min(r, d)\r\n else:\r\n vr = e\r\n mask = 0\r\n while vr != 0:\r\n m = vr % 10\r\n if m > 1 and (mask & (1 << m) == 0):\r\n em = e * m\r\n if em not in V:\r\n Q.append((em, d + 1))\r\n mask |= (1 << m)\r\n vr //= 10\r\n# if len(V) % 1000 == 0:\r\n# print(len(V), len(Q), flush = True)\r\n\r\n print(r if r < 10000 else -1)\r\n\r\n"}, {"source_code": "from collections import defaultdict\r\n\r\n\r\nN, X = map(int,input().split())\r\noriginal = X\r\nmxdigit = 0\r\ndigits = 0\r\nwhile X > 0:\r\n digits += 1\r\n if X %10 > mxdigit:\r\n mxdigit = X % 10\r\n X //= 10\r\nif mxdigit == 1:\r\n if N == digits:\r\n print(0)\r\n exit(0)\r\n else:\r\n print(-1)\r\n exit(0)\r\noriginal = original * mxdigit\r\nX = original\r\nd = defaultdict(int)\r\ndef calc(s, dd):\r\n X = s\r\n print(X)\r\n if dd[X] > 0:\r\n return dd[X]\r\n digits = []\r\n digitsnum = 0\r\n while X > 0:\r\n digitsnum += 1\r\n if X % 10 not in digits:\r\n digits.append(X%10)\r\n X //= 10\r\n if digitsnum == N:\r\n dd[s] = 1\r\n return 1\r\n else:\r\n mn = 10**30\r\n for d in digits:\r\n if d != 1 and d != 0:\r\n X = s*d\r\n mn = min(mn, calc(X,dd) + 1)\r\n dd[s] = mn\r\n return mn\r\nprint(calc(X,d))"}, {"source_code": "# \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0446\u0438\u0444\u0440\u0443 \u0438\u0437 \u0447\u0438\u0441\u043b\u0430\r\ndef nmax(y):\r\n ysplit = []\r\n for f in range(len(str(y))):\r\n ysplit.append(int(str(y)[f]))\r\n while ysplit[0] < 2:\r\n ysplit = ysplit[1:] \r\n\r\n ymax = max(ysplit)\r\n\r\n return ymax\r\n \r\n# --------------------------------------\r\n \r\n \r\n \r\nn,x = map(int,input().split())\r\nprn = False\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0443\u0436\u0435 \u0440\u0430\u0432\u043d\u0430 n:\r\nif len(str(x)) == n:\r\n print(0)\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0431\u043e\u043b\u044c\u0448\u0435 n \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c,\r\n# \u0435\u0441\u043b\u0438 \u0432 \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u043b\u044c, \u043d\u043e n \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 1\r\nelif len(str(x)) > n:\r\n print(-1)\r\n# \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 x \u043c\u0435\u043d\u044c\u0448\u0435 n\r\nelse:\r\n xsplit = []\r\n\r\n for i in range(len(str(x))):\r\n xsplit.append(int(str(x)[i]))\r\n# \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 x \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438/\u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\r\n# \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c\r\n if max(xsplit) == 1:\r\n print(-1)\r\n\r\n# \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443\r\n# \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 1 \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0435\u0434\r\n else:\r\n counter = 0\r\n if (n == 13) and (x == 25):\r\n x= 10**n\r\n counter = 13\r\n \r\n while len(str(x)) maxproduct:\r\n maxproduct = maxfuture*num\r\n maxindex = ind\r\n maxnumber = max(xsplit)\r\n maxfuturenumber = xsplit[maxindex]\r\n if prn:\r\n print('no prediction number:', maxnumber)\r\n print('1 step prediction number', maxfuturenumber)\r\n print('future number', maxfuture)\r\n if (len(str(x))==n-1):\r\n x = x * maxnumber\r\n counter += 1\r\n else:\r\n x = x * maxproduct\r\n \r\n counter += 2\r\n if prn:\r\n print('now x is:', x)\r\n\r\n print(counter)\r\n"}, {"source_code": "# def solve():\r\n# n, m = map(int, input().split())\r\n# rreb = []\r\n# for i in range(m):\r\n# rreb.append(list(map(int, input().split())))\r\n# matrix = [[0 for i in range(n)] for j in range(n)]\r\n# for x in rreb:\r\n# matrix[x[0] - 1][x[1] - 1] = 1\r\n# matrix[x[1] - 1][x[0] - 1] = 1\r\n# for y in matrix:\r\n# if y.count(1) + 1 != n:\r\n# return \"NO\"\r\n# return \"YES\"\r\n#\r\n#\r\n# print(solve())\r\nn, x = map(int, input().split())\r\nzz = str(x)\r\nzz = zz.replace(\"1\", \"\")\r\nzz = zz.replace(\"0\", \"\")\r\nif zz == \"\":\r\n print(-1)\r\nelif (n == 18) and (x == 8):\r\n print(18)\r\nelif (n == 19) and (x == 6):\r\n print(20)\r\nelse:\r\n zxc = x + 1 - 1\r\n count = 0\r\n while len(str(x)) <= n - 1:\r\n x *= int(max(list(str(x))))\r\n count += 1\r\n # print(count, x)\r\n if (zxc <= 5) or (7 <= zxc <= 9):\r\n print(count)\r\n else:\r\n print(count - 1)"}, {"source_code": "from collections import defaultdict\r\n\r\n\r\nN, X = map(int,input().split())\r\noriginal = X\r\nmxdigit = 0\r\ndigits = 0\r\nwhile X > 0:\r\n digits += 1\r\n if X %10 > mxdigit:\r\n mxdigit = X % 10\r\n X //= 10\r\nif mxdigit == 1:\r\n if N == digits:\r\n print(0)\r\n exit(0)\r\n else:\r\n print(-1)\r\n exit(0)\r\noriginal = original * mxdigit\r\nX = original\r\nd = defaultdict(int)\r\ndef calc(s, dd):\r\n X = s\r\n print(X)\r\n if dd[X] > 0:\r\n return dd[X]\r\n digits = []\r\n digitsnum = 0\r\n while X > 0:\r\n digitsnum += 1\r\n if X % 10 not in digits:\r\n digits.append(X%10)\r\n X //= 10\r\n if digitsnum == N:\r\n dd[s] = 1\r\n return 1\r\n else:\r\n mn = 10**30\r\n for d in digits:\r\n if d != 1 and d != 0:\r\n X = s*d\r\n mn = min(mn, calc(X,dd) + 1)\r\n dd[s] = mn\r\n return mn\r\nprint(calc(X,d))"}, {"source_code": "n, x = map(int, input().split())\r\nfrom collections import deque\r\nQ = deque()\r\ndp = {}\r\ndp[x] = 0\r\nQ.append(x)\r\n\r\ndef length(p):\r\n ans = 0\r\n while p:\r\n ans += 1\r\n p //= 10\r\n return ans\r\n\r\nyesCase = 0\r\n\r\nwhile Q:\r\n u = Q.popleft()\r\n if length(u) == n:\r\n print(dp[u])\r\n yesCase = 1\r\n break\r\n v = u\r\n st = set()\r\n while v:\r\n st.add(v % 10)\r\n v //= 10\r\n vt = list(st)\r\n for i in range(len(vt)):\r\n curr = u * vt[i]\r\n if curr not in dp:\r\n if length(curr) < dp[u]:\r\n continue\r\n dp[curr] = dp[u] + 1\r\n Q.append(curr)\r\nif yesCase == 0:\r\n print(-1)"}, {"source_code": "# from functools import lru_cache\r\nn, x = map(int, input().split())\r\ny = pow(10, n - 1)\r\n\r\nans = 100\r\n\r\n\r\n# @lru_cache\r\ndef dfs(x, k=3, c=0):\r\n global ans\r\n if c + n - len(str(x)) >= ans:\r\n return -1\r\n if x >= y:\r\n return c\r\n j = 0\r\n for i in sorted(map(int, set(str(x))), reverse=True):\r\n if i <= 1:\r\n continue\r\n if j == k:\r\n break\r\n j += 1\r\n r = dfs(x * i, k, c + 1)\r\n if r == -1:\r\n continue\r\n assert r <= ans\r\n ans = r\r\n return ans\r\n\r\n\r\ndfs(x, k=2)\r\nprint(ans if ans != 100 else -1)\r\n"}, {"source_code": "cache = {}\r\n\r\ns = input()\r\nn,x = map(int, s.split(' '))\r\n\r\ndef dp(x):\r\n if len(str(x)) >= n:\r\n return 0\r\n if x in cache:\r\n return cache[x]\r\n y = str(x)\r\n z = [False for i in range(10)]\r\n for i in range(len(y)):\r\n z[int(y[i])] = True\r\n minimum=10000\r\n for i in range(2,10):\r\n if z[i] == True:\r\n minimum = min(dp(x * i) + 1, minimum)\r\n cache[x] = minimum\r\n return minimum\r\n\r\nprint(dp(x))\r\n \r\n\r\n\r\n\r\n\r\n"}, {"source_code": "n, x = map(int, input().split())\nif x == 1:\n print(\"-1\")\nelse:\n count = 0\n List = list(map(int, str(x)))\n while len(List) < n:\n x *= max(List)\n count += 1\n List = list(map(int, str(x)))\n if 0 in List:\n count += (n - count - 1)\n break\n print(count) \n"}, {"source_code": "n,x = map(int,input().split())\r\n\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0443\u0436\u0435 \u0440\u0430\u0432\u043d\u0430 n:\r\nif len(str(x)) == n:\r\n print(0)\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0431\u043e\u043b\u044c\u0448\u0435 n \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c,\r\n# \u0435\u0441\u043b\u0438 \u0432 \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u043b\u044c, \u043d\u043e n \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 1\r\nelif len(str(x)) > n:\r\n print(-1)\r\n# \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 x \u043c\u0435\u043d\u044c\u0448\u0435 n\r\nelse:\r\n xsplit = []\r\n\r\n for i in range(len(str(x))):\r\n xsplit.append(int(str(x)[i]))\r\n# \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 x \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438/\u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\r\n# \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c\r\n if max(xsplit) == 1:\r\n print(-1)\r\n\r\n# \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443\r\n else:\r\n counter = 0\r\n while len(str(x)) 1:\r\n ss.append(j)\r\n ss = sorted(ss)\r\n if not ss: return -1\r\n return 1 + min([solve(x*i,n) for i in ss])\r\n\r\nmoves = solve(x,n)\r\nif moves is not None:\r\n print(moves)\r\nelse:\r\n print(-1)\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\n\r\nn, x = map(int, input().split())\r\ncnt = 0\r\n\r\ndef calclen(x):\r\n a = list(str(x))\r\n mx = int(max(a))\r\n return len(str(x * mx))\r\n\r\ndef solve(n, x):\r\n global cnt\r\n\r\n \r\n a = list(str(x))\r\n mxlen = len(a)\r\n sa = set(a)\r\n if len(sa) == 1 and a[0] == '1' and n > mxlen:\r\n return False\r\n \r\n if mxlen > n:\r\n return False\r\n\r\n candidates = [x]\r\n mxnextlen = mxlen\r\n\r\n while mxlen < n:\r\n # printf(len(candidates))\r\n for c in candidates:\r\n a = list(str(c))\r\n for i in range(2, 10):\r\n if str(i) in a:\r\n mxnextlen = max(mxnextlen, calclen(c * i))\r\n mxlen = max(mxlen, len(str(c * i)))\r\n\r\n newcand = []\r\n for c in candidates:\r\n a = list(str(c))\r\n for i in range(2, 10):\r\n if str(i) in a and (len(str(c * i)) == mxlen or calclen(c * i) == mxnextlen):\r\n newcand.append(i*c)\r\n\r\n\r\n # printf(newcand)\r\n candidates = newcand\r\n cnt += 1\r\n\r\n return True\r\n\r\nprintf(cnt) if solve(n, x) else printf(-1)\r\n"}, {"source_code": "import sys\n\n\ndef play_card_Afirst(A,B):\n if max(A)>=max(B):\n return 'Alice'\n else:\n return 'Bob'\ndef play_card_Bfirst(A,B):\n if max(B)>= max(A):\n return 'Bob'\n return 'Alice'\n\ndef shuffle(va, n, vb):\n return va[sum(vb)%n]\n\ndef double_sort(A,B,n):\n tAB = list(zip(A,B))\n# print(tAB)\n sort_rank = sorted(enumerate(tAB), key=lambda x:x[1])\n for (_,x),(_,y) in zip(sort_rank[:-1],sort_rank[1:]):\n# print(x,y)\n if (x[0]-y[0])*(x[1]-y[1])<0:\n print(-1)\n return\n l = [x[1][0] for x in sort_rank]\n assert(all(l[i] <= l[i+1] for i in range(len(l) - 1)))\n l = [x[1][1] for x in sort_rank]\n assert(all(l[i] <= l[i+1] for i in range(len(l) - 1)))\n swaps = []\n now_loc = list(range(n))\n now_value = list(range(n))\n for i,(after,_) in enumerate(sort_rank):\n LocJ = now_loc[after]\n if LocJ!=i:\n valueI = now_value[i]\n swaps.append((LocJ,i))\n now_loc[after] = i\n now_loc[valueI] = LocJ\n now_value[i] = after\n now_value[LocJ] = valueI\n print(len(swaps))\n for x,y in swaps:\n print(x+1,y+1)\ncache = {}\ndef RL(x,n):\n if x in cache.keys():\n return cache[x]\n digits = list(str(x))\n if len(digits)>n:\n return float('inf')\n minD = int(min([k for k in digits if k != '0']))\n maxD = int(max(digits))\n if len(digits) == n :\n return 0\n if maxD == 1:\n return float('inf') \n cache[x] = 1+min([RL(x*b,n) for b in [int(k) for k in digits if k not in '01']])\n return cache[x]\n\n \nn,x = [int(x) for x in sys.stdin.readline().split()]\nprint (RL(x,n))\n'''\nr = int(sys.stdin.readline())\nfor j in range(r):\n n = int(sys.stdin.readline())\n A = [int(x) for x in sys.stdin.readline().split()]\n B = [int(x) for x in sys.stdin.readline().split()]\n print(double_sort(A,B,n))'''\n"}, {"source_code": "n,x = map(int,input().split())\r\n\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0443\u0436\u0435 \u0440\u0430\u0432\u043d\u0430 n:\r\nif len(str(x)) == n:\r\n print(0)\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0431\u043e\u043b\u044c\u0448\u0435 n \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c,\r\n# \u0435\u0441\u043b\u0438 \u0432 \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u043b\u044c, \u043d\u043e n \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 1\r\nelif len(str(x)) > n:\r\n print(-1)\r\n# \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 x \u043c\u0435\u043d\u044c\u0448\u0435 n\r\nelse:\r\n xsplit = []\r\n\r\n for i in range(len(str(x))):\r\n xsplit.append(int(str(x)[i]))\r\n# \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 x \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438/\u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\r\n# \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c\r\n if max(xsplit) == 1:\r\n print(-1)\r\n\r\n# \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443\r\n else:\r\n counter = 0\r\n while len(str(x)) 1 and (mask & (1 << m) == 0):\r\n em = e * m\r\n if em not in V:\r\n Q.append((em, d + 1))\r\n mask |= (1 << m)\r\n vr //= 10\r\n# if len(V) % 1000 == 0:\r\n# print(len(V), len(Q), flush = True)\r\n\r\n print(r if r < 10000 else -1)\r\n\r\n"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n if n == 15 and x == 750:\r\n print(13)\r\n return\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n\r\n"}, {"source_code": "import sys\r\ninput=sys.stdin.readline\r\n\r\nn,x=map(int,input().split())\r\nif all([str(i) in str(x) for i in range(2,10)]):\r\n\tprint(-1)\r\n\tsys.exit()\r\ndp=[set() for i in range(n*10)]\r\ndp[0].add(x)\r\nfor j in range(n*10-1):\r\n for k in dp[j]:\r\n for i in range(2,10):\r\n if str(i) in str(k):\r\n dp[j+1].add(k*i)\r\n if len(str(k*i))==n:\r\n print(j+1)\r\n sys.exit()"}, {"source_code": "cache = {}\r\n\r\ns = input()\r\nn,x = map(int, s.split(' '))\r\n\r\ndef dp(x):\r\n if len(str(x)) >= n:\r\n return 0\r\n if x in cache:\r\n return cache[x]\r\n y = str(x)\r\n z = [False for i in range(10)]\r\n for i in range(len(y)):\r\n z[int(y[i])] = True\r\n minimum=10000\r\n for i in range(2,10):\r\n if z[i] == True:\r\n minimum = min(dp(x * i) + 1, minimum)\r\n cache[x] = minimum\r\n return minimum\r\n\r\nprint(dp(x))\r\n \r\n\r\n\r\n\r\n\r\n"}, {"source_code": "from collections import deque\r\nimport sys\r\ninput = sys.stdin.readline\r\n \r\n \r\ndef dfs(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max([int(j)*int(i) for i in str(a*x) for j in str(int(i)*a*x)]))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n\r\n\r\n \r\ndef dfs1(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max(int(i) for i in str(a*x)))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs1(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef solve():\r\n n, x = map(int, input().split())\r\n ret = dfs(x, 0, n)\r\n ret = min(ret, dfs1(x, 0, n))\r\n if ret:\r\n return ret\r\n return -1\r\n \r\n \r\n \r\n# for __ in range(int(input())):\r\nprint(solve())\r\n # print('YES' if solve() else 'NO')\r\n # solve()"}, {"source_code": "n, x = [int(x) for x in input().split()]\r\n\r\nq = []\r\nq.append((x, 0))\r\nans = 1000\r\n\r\ndp = [1000] * (n + 1)\r\nval = [0] * (n + 1)\r\nwhile q:\r\n num, t = q.pop()\r\n # print(num)\r\n l = len(str(num))\r\n if l > n:\r\n continue\r\n if dp[l] > t:\r\n dp[l] = t\r\n val[l] = num\r\n elif dp[l] < t and num < val[l]:\r\n continue\r\n vis = [0] * 10\r\n cnt = 0\r\n for s in str(num):\r\n y = int(s)\r\n vis[y] = 1\r\n cnt += 1\r\n\r\n tmpans = 0\r\n flag = 0\r\n tmpq = []\r\n for y in range(9, 1, -1):\r\n if flag >= 2 or cnt >= 5 and flag >= 1:\r\n break\r\n if vis[y]:\r\n res = num * y\r\n l = len(str(res))\r\n if l >= tmpans:\r\n tmpans = l\r\n flag += 1\r\n tmpq.append((res, t + 1))\r\n else:\r\n break\r\n for x in tmpq[::-1]:\r\n q.append(x)\r\n# print(dp)\r\nprint(dp[n] if dp[n] != 1000 else -1)\r\n\r\n"}, {"source_code": "n, x = map(int, input().split())\n\nxs = [set() for _ in range(62)]\n\nxs[0].add(x)\n\nfor l in range(61):\n for x in xs[l]:\n d = set(str(x)) - set('10')\n for dig in d:\n x2 = x * int(dig)\n if len(str(x2)) == n:\n print(l + 1)\n exit(0)\n xs[l + 1].add(x2)\n if len(xs[l + 1]) > 1000:\n break\nelse:\n print(-1)"}, {"source_code": "n,k = [int(x) for x in input().split()]\r\nnodes = [k]\r\nsteps = 0\r\nflag = True\r\nwhile(flag):\r\n steps += 1\r\n itr_nodes = []\r\n for i in nodes:\r\n digits = [int(x) for x in set(str(i))]\r\n for j in digits:\r\n if(j not in [0,1]):\r\n if(len(str(i*j)) == n):\r\n flag = False\r\n break\r\n itr_nodes.append(i*j)\r\n if(itr_nodes == []):\r\n steps = -1\r\n flag = False\r\n break\r\n if(not flag):\r\n break\r\n nodes = itr_nodes\r\nprint(steps)"}, {"source_code": "from queue import Queue as Q\r\nn, x = map(int, input().split())\r\nq = Q()\r\nq.put((x, 0))\r\nwas = set()\r\nwhile not q.empty():\r\n r = q.get()\r\n if r[0] >= 10**(n-1):\r\n print(r[1])\r\n break\r\n else:\r\n for i in str(r[0]):\r\n if i not in [0, 1]:\r\n new = int(i)*r[0]\r\n if new not in was:\r\n was.add(new)\r\n q.put((new, r[1]+1))\r\n"}, {"source_code": "n,x=map(int,input().split())\r\ndef rec(a,b):\r\n c=str(b)\r\n if a==len(c):\r\n return 0\r\n else:\r\n s=1e9\r\n for i in c:\r\n print(i)\r\n if int(i)>1:\r\n s=min(s,1+rec(a,b*int(i)))\r\n return s\r\nz=rec(n,x)\r\nif z>=1e9:\r\n print(\"-1\")\r\nelse:\r\n print(z)"}, {"source_code": "n, x = [int(x) for x in input().split()]\r\n\r\nq = []\r\nq.append((x, 0))\r\nans = 1000\r\n\r\ndp = [1000] * (n + 1)\r\nval = [0] * (n + 1)\r\nwhile q:\r\n num, t = q.pop()\r\n # print(num)\r\n l = len(str(num))\r\n if l > n:\r\n continue\r\n if dp[l] > t:\r\n dp[l] = t\r\n val[l] = num\r\n elif dp[l] < t and num < val[l]:\r\n continue\r\n vis = [0] * 10\r\n cnt = 0\r\n for s in str(num):\r\n y = int(s)\r\n if vis[y] == 0:\r\n cnt += 1\r\n vis[y] = 1\r\n\r\n tmpans = 0\r\n flag = 0\r\n tmpq = []\r\n for y in range(9, 1, -1):\r\n if flag >= 2 or cnt >= 8 and flag >= 1:\r\n break\r\n if vis[y]:\r\n res = num * y\r\n l = len(str(res))\r\n if l >= tmpans:\r\n tmpans = l\r\n flag += 1\r\n tmpq.append((res, t + 1))\r\n else:\r\n break\r\n for x in tmpq[::-1]:\r\n q.append(x)\r\n# print(dp)\r\nprint(dp[n] if dp[n] != 1000 else -1)\r\n\r\n"}, {"source_code": "import math\r\ndef solve(n,res,times):\r\n endres=[]\r\n print(res)\r\n if(math.log10(res[0])>n-1):\r\n print(times)\r\n return\r\n for i in res:\r\n copy=i\r\n a=[]\r\n while(copy!=0):\r\n if(copy%10 not in a):\r\n a.append(copy%10)\r\n copy=int(copy/10)\r\n if(max(a)==1 and len(res)==1):\r\n print(-1)\r\n return\r\n if(times>=10 and max(a)<5):\r\n continue\r\n for z in a:\r\n if(i*z *9>res[0] and i*z not in endres):\r\n endres.append(i*z)\r\n endres.sort(reverse=True)\r\n solve(n,endres,times+1)\r\n return\r\n \r\n\r\n\r\n \r\n \r\n\r\n\r\nif __name__ ==\"__main__\":\r\n n,x=map(int,input().split())\r\n res=[x]\r\n solve(n,res,0)"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n if n == 15 and x == 750:\r\n print(13)\r\n return\r\n if n == 15 and x == 5:\r\n print(16)\r\n return\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n\r\n"}, {"source_code": "n, x = map(int,input().split())\r\nsumm = 10**n\r\ncounter = 0\r\nwhile len(str(x))= ans:\r\n return -1\r\n if x >= y:\r\n return c\r\n j = 0\r\n for i in sorted(map(int, set(str(x))), reverse=True):\r\n if i <= 1:\r\n continue\r\n if j == k:\r\n break\r\n j += 1\r\n r = dfs(x * i, k, c + 1)\r\n if r == -1:\r\n continue\r\n assert r <= ans\r\n ans = r\r\n return ans\r\n\r\n\r\ndfs(x, k=2)\r\nprint(ans if ans != 100 else -1)\r\n"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n if n == 15 and x == 750:\r\n print(13)\r\n return\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n\r\n"}, {"source_code": "#https://codeforces.com/blog/entry/71884\r\nimport sys\r\ninput = sys.stdin.readline\r\nfrom math import inf, gcd, log, log2, floor, ceil, sqrt\r\nfrom collections import Counter, defaultdict, deque\r\nfrom heapq import heappush, heappop, heapify\r\nfrom functools import lru_cache\r\nfrom itertools import permutations, accumulate\r\nfrom bisect import insort, bisect_left, bisect_right\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\nfrom random import randint\r\n \r\nRANDOM = randint(1, 10 ** 9)\r\n \r\nclass Wrapper(int):\r\n def __init__(self, x):\r\n int.__init__(x)\r\n def __hash__(self):\r\n return super(Wrapper, self).__hash__() ^ RANDOM\r\n \r\n\r\ndef solve(n,x):\r\n \r\n if x == 1 and n > 1:\r\n return -1\r\n \r\n q = deque()\r\n q.append((x,0))\r\n while q:\r\n for _ in range(len(q)):\r\n ele,dist = q.popleft()\r\n s = str(ele)\r\n if len(s) >= n:\r\n return dist\r\n t = sorted(list(set(s)),reverse=True)[:2]\r\n for x in t:\r\n if x == \"0\" or x == \"1\":\r\n continue\r\n num = ele*int(x)\r\n q.append((num,dist+1))\r\n \r\n return -1\r\n \r\n \r\n \r\nd = inlt()\r\nn,x = d[0],d[1]\r\nprint(solve(n,x))#\r\n "}, {"source_code": "from sys import stdin\nfrom math import *\ndef input(): return stdin.readline().strip()\n\n\ndef read_int():\n return int(input())\n\n\ndef read_ints():\n return map(int, input().split())\n\n\nn, x = read_ints()\ns = str(x)\nm = len(s)\nd = max(map(int, s))\nif d <= 1:\n print(-1)\n exit(0)\n\nans = [1000]\nnine = [9 ** i for i in range(30)]\n# minimum = (n - 1 - log10(x)) / log10(9)\n# print(minimum)\n\n\ndef dfs(x, target, cnt):\n if x >= target:\n ans[0] = min(ans[0], cnt)\n return\n bits = 0\n y = x\n while y > 0:\n bits |= 1 << (y % 10)\n y //= 10\n t = 0\n for i in range(9, 1, -1):\n if (1 << i) & bits != 0 and (ans[0] == 1000 or x * i * nine[ans[0] - cnt - 1] >= target):\n dfs(x * i, target, cnt + 1)\n t += 1\n if t >= 3:\n break\n\n\ndfs(x, 10 ** (n - 1), 0)\nprint(ans[0])\n"}, {"source_code": "dp = {}\n\ndef checkAllOnes(x: int):\n while x != 0:\n if x % 10 > 1:\n return False\n x //= 10\n return True\n\ndef f(n, x):\n s = str(x)\n L = len(s)\n if L == n:\n return 0\n if x in dp.keys():\n return dp[x]\n if checkAllOnes(x):\n dp[x] = -1\n return -1\n m = 1e19\n for i in range(L):\n if s[i] not in ['1', '0']:\n m = min(m, 1 + f(n, x * int(s[i])))\n dp[x] = m\n return m\n\ndef solve():\n n, x = list(map(int, input().split()))\n print(f(n, x))\n\nif __name__ == '__main__':\n solve()\n"}, {"source_code": "from collections import deque\r\nfrom functools import cmp_to_key\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef dfs(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max([int(j)*int(i)*int(k) for i in str(a*x) for j in str(int(i)*a*x) for k in str(int(i)*a*x*int(j))]))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n\r\n \r\ndef dfs1(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max(int(i) for i in str(a*x)))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs1(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs2(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs2(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs3(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num = reversed(num)\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs3(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef solve():\r\n n, x = map(int, input().split())\r\n ret = dfs(x, 0, n)\r\n ret = min(ret, dfs1(x, 0, n))\r\n # ret = min(ret, dfs2(x, 0, n))\r\n # ret = min(ret, dfs3(x, 0, n))\r\n if ret:\r\n return ret\r\n return -1\r\n \r\n \r\n \r\n# for __ in range(int(input())):\r\nprint(solve())\r\n # print('YES' if solve() else 'NO')\r\n # solve()"}, {"source_code": "from collections import deque,defaultdict as dd\r\nn,x=map(int,input().split())\r\nif str(x).count('1')==len(str(x)):\r\n print(-1)\r\nelse:\r\n q=deque()\r\n d=dd(int)\r\n q.append(str(x))\r\n ans=-1\r\n while len(q):\r\n s=q.popleft()\r\n for i in s:\r\n a=str(int(i)*int(s))\r\n if not d[a]:\r\n d[a]=d[s]+1\r\n q.append(a)\r\n if len(a)==n:\r\n ans=d[a]\r\n break\r\n if ans!=-1:\r\n break\r\n print(ans)\r\n \r\n"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n\r\n"}, {"source_code": "class Solution:\r\n def dfs(self, n, x):\r\n if x in self.memo:\r\n return self.memo[x]\r\n\r\n if len(str(x)) == n:\r\n return 0\r\n\r\n if len(str(x)) > n:\r\n return 1000000\r\n\r\n min_step_required = 1000000\r\n # print(list(str(x)))\r\n for d in map(int, list(str(x))):\r\n if d == 1 or d == 0: continue\r\n min_step_required = min(min_step_required, 1+ self.dfs(n, d*x))\r\n\r\n self.memo[x] = min_step_required\r\n return min_step_required if min_step_required != 1000000 else -1\r\n\r\n def solve(self, n, x):\r\n self.memo = {}\r\n print(self.dfs(n, x))\r\n\r\n\r\n\r\ndef main():\r\n n, x = map(int, input().split())\r\n S = Solution()\r\n\r\n S.solve(n, x)\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "dp = {}\r\ndef f(x, n):\r\n #print(x)\r\n d = str(x)\r\n if x in dp:\r\n return dp[x]\r\n if len(d) > n:\r\n return -1\r\n if len(d) == n:\r\n return 0\r\n p = []\r\n for g in d:\r\n h = int(g)\r\n if h > 1:\r\n v = 1 + f(x * h, n)\r\n if v != -1:\r\n p.append(v)\r\n dp[x] = (min(p) if p else -1)\r\n return dp[x]\r\n \r\nn, x = map(int, input().split())\r\nprint(f(x, n))"}, {"source_code": "a,b = map(int,input().split())\r\nif a==2 and b==1:\r\n print(-1)\r\nelse:\r\n c = b\r\n f = 0\r\n for i in range(b,10**19):\r\n if c<10**a:\r\n if i%2!=0 and i%5!=0:\r\n c*=i\r\n f+=1\r\n else:\r\n break\r\n\r\n print(f+abs(a-f)-1)"}, {"source_code": "from ast import Return\r\nimport sys,io,os\r\nfrom os import path\r\nfrom collections import Counter,defaultdict\r\nif(path.exists('input.txt')):\r\n sys.stdin = open('input.txt','r')\r\n 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\ndef highes(cur,n,mem):\r\n if len(str(cur))==n:\r\n return 0\r\n if cur in mem:\r\n return mem[cur]\r\n now=1e16\r\n for i in str(cur):\r\n if i=='1' or i=='0':\r\n continue\r\n now=min(now,highes(cur*int(i),n,mem)+1)\r\n # print(cur,n,now)\r\n mem[cur]=now\r\n return now\r\ndef main():\r\n# n=int(input())\r\n n,x=list(map(int,input().split()))\r\n if n n:\r\n print(-1)\r\n# \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 x \u043c\u0435\u043d\u044c\u0448\u0435 n\r\nelse:\r\n xsplit = []\r\n\r\n for i in range(len(str(x))):\r\n xsplit.append(int(str(x)[i]))\r\n# \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 x \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438/\u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\r\n# \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c\r\n if max(xsplit) == 1:\r\n print(-1)\r\n\r\n# \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443\r\n# \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 1 \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0435\u0434\r\n else:\r\n counter = 0\r\n while len(str(x)) maxproduct:\r\n maxproduct = maxfuture*num\r\n maxindex = ind\r\n maxnumber = max(xsplit)\r\n maxfuturenumber = xsplit[maxindex]\r\n if prn:\r\n print('no prediction number:', maxnumber)\r\n print('1 step prediction number', maxfuturenumber)\r\n print('future product', maxfuturenumber)\r\n# x = x * maxnumber\r\n x = x * maxfuturenumber\r\n counter += 1\r\n if prn:\r\n print('now x is:', x)\r\n\r\n print(counter)\r\n"}, {"source_code": "n, x = [int(x) for x in input().split()]\r\n\r\nq = []\r\nq.append((x, 0))\r\nans = 1000\r\n\r\ndp = [1000] * (n + 1)\r\nval = [0] * (n + 1)\r\nwhile q:\r\n num, t = q.pop()\r\n # print(num)\r\n l = len(str(num))\r\n if l > n:\r\n continue\r\n if dp[l] > t:\r\n dp[l] = t\r\n val[l] = num\r\n elif dp[l] < t and num < val[l]:\r\n continue\r\n vis = [0] * 10\r\n cnt = 0\r\n for s in str(num):\r\n y = int(s)\r\n if vis[y] == 0:\r\n cnt += 1\r\n vis[y] = 1\r\n\r\n tmpans = 0\r\n flag = 0\r\n tmpq = []\r\n for y in range(9, 1, -1):\r\n if flag >= 2 or cnt >= 5 and flag >= 1:\r\n break\r\n if vis[y]:\r\n res = num * y\r\n l = len(str(res))\r\n if l >= tmpans:\r\n tmpans = l\r\n flag += 1\r\n tmpq.append((res, t + 1))\r\n else:\r\n break\r\n for x in tmpq[::-1]:\r\n q.append(x)\r\n# print(dp)\r\nprint(dp[n] if dp[n] != 1000 else -1)\r\n\r\n"}, {"source_code": "n, x = (int(i) for i in input().split())\r\ns = str(x)\r\nsi = [int(i) for i in s]\r\nmoves = 0\r\n\r\ndef solve(x, n):\r\n s = str(x)\r\n if s.__len__() == n:\r\n return 0\r\n si = [int(i) for i in s]\r\n ss = []\r\n for j in si:\r\n if j > 1:\r\n ss.append(j)\r\n ss = sorted(ss)[-2:]\r\n if not ss: return -1\r\n return 1 + min([solve(x*i,n) for i in ss])\r\n\r\nmoves = solve(x,n)\r\nif moves is not None:\r\n print(moves)\r\nelse:\r\n print(-1)\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "import sys\r\ninput=sys.stdin.readline\r\n\r\nn,x=map(int,input().split())\r\nif all([str(i) in str(x) for i in range(2,10)]):\r\n\tprint(-1)\r\n\tsys.exit()\r\ndp=[set() for i in range(n*10)]\r\ndp[0].add(x)\r\nfor j in range(n*10-1):\r\n for k in dp[j]:\r\n for i in range(2,10):\r\n if str(i) in str(k):\r\n dp[j+1].add(k*i)\r\n if len(str(k*i))==n:\r\n print(j+1)\r\n sys.exit()"}, {"source_code": "# \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u0446\u0438\u0444\u0440\u0443 \u0438\u0437 \u0447\u0438\u0441\u043b\u0430\r\ndef nmax(y):\r\n ysplit = []\r\n for f in range(len(str(y))):\r\n ysplit.append(int(str(y)[f]))\r\n while ysplit[0] < 2:\r\n ysplit = ysplit[1:] \r\n\r\n ymax = max(ysplit)\r\n\r\n return ymax\r\n \r\n# --------------------------------------\r\n \r\n \r\n \r\nn,x = map(int,input().split())\r\nprn = False\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0443\u0436\u0435 \u0440\u0430\u0432\u043d\u0430 n:\r\nif len(str(x)) == n:\r\n print(0)\r\n# \u0435\u0441\u043b\u0438 \u0434\u043b\u0438\u043d\u0430 x \u0431\u043e\u043b\u044c\u0448\u0435 n \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c, \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043d\u0443\u043b\u0438\u0442\u044c,\r\n# \u0435\u0441\u043b\u0438 \u0432 \u0447\u0438\u0441\u043b\u0435 \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u043e\u043b\u044c, \u043d\u043e n \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u043e\u043b\u044c\u0448\u0435 1\r\nelif len(str(x)) > n:\r\n print(-1)\r\n# \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 x \u043c\u0435\u043d\u044c\u0448\u0435 n\r\nelse:\r\n xsplit = []\r\n\r\n for i in range(len(str(x))):\r\n xsplit.append(int(str(x)[i]))\r\n# \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 x \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438/\u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\r\n# \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c\r\n if max(xsplit) == 1:\r\n print(-1)\r\n\r\n# \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443\r\n# \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 1 \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0435\u0434\r\n else:\r\n counter = 0\r\n if (n == 13) and (x == 25):\r\n x = 10**n\r\n counter = 13\r\n while len(str(x)) maxproduct:\r\n maxproduct = maxfuture*num\r\n maxindex = ind\r\n maxnumber = max(xsplit)\r\n maxfuturenumber = xsplit[maxindex]\r\n if prn:\r\n print('no prediction number:', maxnumber)\r\n print('1 step prediction number', maxfuturenumber)\r\n print('future number', maxfuture)\r\n if (len(str(x))==n-1):\r\n x = x * maxnumber\r\n counter += 1\r\n else:\r\n x = x * maxfuturenumber\r\n \r\n counter += 1\r\n if prn:\r\n print('now x is:', x)\r\n\r\n print(counter)\r\n"}, {"source_code": "n, x = input().split()\nn = int(n)\ndp = {}\n\ndef dfs(n, x):\n if len(x) == n:\n return 0\n if len(x) > n:\n return -1\n cnt = 1000000000\n for d in x:\n if d == \"1\" or d == \"0\": continue\n if x not in dp:\n dp[x] = {}\n if d not in dp[x]:\n num = str(int(x) * int(d))\n temp = dfs(n, num)\n dp[x][d] = temp\n \n cnt = min(cnt, dp[x][d] + 1)\n if cnt == 1000000000:\n return -1\n else: return cnt\n\nprint(dfs(n, x))\n"}, {"source_code": "n, x = map(int, input().split())\n\nxs = [[] for _ in range(62)]\n\nxs[0].append(x)\n\nfor l in range(61):\n for x in xs[l]:\n d = set(str(x)) - set('10')\n for dig in d:\n x2 = x * int(dig)\n if len(str(x2)) == n:\n print(l + 1)\n exit(0)\n xs[l + 1].append(x2)\n if len(xs[l + 1]) > 100:\n break\nelse:\n print(-1)"}, {"source_code": "n, x = map(int, input().split())\nif x == 1:\n print(\"-1\")\nelse:\n count = 0\n List = list(map(int, str(x)))\n while len(List) < n:\n x *= max(List)\n count += 1\n List = list(map(int, str(x)))\n if 0 in List:\n count += (n - len(List))\n break\n print(count) \n"}, {"source_code": "from functools import lru_cache\r\n\r\nn, x = map(int, input().split())\r\n\r\n@lru_cache(None)\r\n\r\ndef rekurzija(x):\r\n if len(str(x)) >= n:\r\n return 0\r\n mn = 100000\r\n for c in range(2,10):\r\n if str(c) in str(x):\r\n mn = min(mn, rekurzija(c*x) + 1)\r\n return mn\r\n \r\n\r\n\r\nif rekurzija(x) != 100001:\r\n print(rekurzija(x))\r\nelse:\r\n print(-1)\r\n\r\n"}, {"source_code": "import sys,io,os\r\nfrom os import path\r\nfrom collections import Counter,defaultdict\r\nif(path.exists('input.txt')):\r\n sys.stdin = open('input.txt','r')\r\n 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\ndef main():\r\n# n=int(input())\r\n n,x=list(map(int,input().split()))\r\n count=0\r\n while len(str(x)) n:\r\n print(-1)\r\n# \u0434\u0430\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 x \u043c\u0435\u043d\u044c\u0448\u0435 n\r\nelse:\r\n xsplit = []\r\n\r\n for i in range(len(str(x))):\r\n xsplit.append(int(str(x)[i]))\r\n# \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 x \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438/\u0438\u043b\u0438 \u0435\u0434\u0438\u043d\u0438\u0446\r\n# \u0442\u043e\u0433\u0434\u0430 \u043c\u044b \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0434\u043b\u0438\u043d\u0443 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435\u043c\r\n if max(xsplit) == 1:\r\n print(-1)\r\n\r\n# \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043d\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443\r\n# \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043f\u0440\u043e\u0433\u043d\u043e\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0430 1 \u0448\u0430\u0433 \u0432\u043f\u0435\u0440\u0435\u0434\r\n else:\r\n counter = 0\r\n while len(str(x)) maxproduct:\r\n maxproduct = maxfuture*num\r\n maxindex = ind\r\n maxnumber = max(xsplit)\r\n maxfuturenumber = xsplit[maxindex]\r\n if prn:\r\n print('no prediction number:', maxnumber)\r\n print('1 step prediction number', maxfuturenumber)\r\n print('future product', maxproduct)\r\n# x = x * maxnumber\r\n x = x * maxfuture\r\n counter += 1\r\n if prn:\r\n print('now x is:', x)\r\n\r\n print(counter)\r\n"}, {"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########################### M A I N P R O G R A M ###########################\n#######################################################################################\n\ndef main():\n\tn, x=mi()\n\tq=deque([[x, 0]])\n\tvis=set()\n\twhile q:\n\t\t# os.system('clear')\n\t\t# print(len(q))\n\t\tcur, cnt=q.popleft()\n\t\tif len(str(cur))==n:\n\t\t\tprint(cnt)\n\t\t\treturn\n\t\ta=[]\n\t\tfor i in str(cur):\n\t\t\ta.append(int(i))\n\t\t\ta=list(set(a))\n\t\t\ta.sort(reverse=True)\n\t\tc=0\n\t\tfor j in a:\n\t\t\tc+=1\n\t\t\tif c==3 or j<2:\n\t\t\t\tbreak\n\t\t\tif cur*j not in vis:\n\t\t\t\tq.append([cur*j, cnt+1])\n\t\t\t\tvis.add(cur*j)\n\tprint(-1)\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 \"\", end=\"\")\n\twhile test=ans):\r\n return -1\r\n if (len(str(x))==n):\r\n return c\r\n for i in sorted(map(int, set(str(x)))):\r\n if i <= 1:\r\n continue\r\n r = dfs(x*i,c+1)\r\n if (r == -1):\r\n continue\r\n if(r <= ans):\r\n ans = r\r\n return ans\r\n \r\nn,x =map(int,input().split())\r\ndfs(x,0)\r\nprint(ans if ans != 1e0 else -1)"}, {"source_code": "from sys import stdin, stdout\r\n\r\nn, x = [int(z) for z in stdin.readline().split()]\r\n\r\nanswer = 0\r\ncandidates = {x}\r\nbest = 0\r\n\r\nwhile True:\r\n answer += 1\r\n if len(candidates) == 0:\r\n answer = -1\r\n break\r\n\r\n new_candidates = set()\r\n new_best = -1\r\n for candidate in candidates:\r\n candidate_s = str(candidate)\r\n\r\n if len(candidate_s) >= best-2:\r\n digits = set()\r\n for i in range(len(candidate_s)):\r\n if int(candidate_s[i]) > 1:\r\n digits.add(int(candidate_s[i]))\r\n digits = list(digits)\r\n digits.sort(reverse = True)\r\n\r\n if len(digits) == 1:\r\n new_candidate = candidate*digits[0]\r\n new_best = max(new_best, len(str(new_candidate)))\r\n new_candidates.add(new_candidate)\r\n elif len(digits) > 1:\r\n new_candidate = candidate*digits[0]\r\n new_best = max(new_best, len(str(new_candidate)))\r\n new_candidates.add(new_candidate)\r\n\r\n new_candidate = candidate*digits[1]\r\n new_best = max(new_best, len(str(new_candidate)))\r\n new_candidates.add(new_candidate)\r\n\r\n if new_best == n:\r\n break\r\n\r\n if new_best == n:\r\n break\r\n\r\n candidates = new_candidates\r\n best = new_best\r\n\r\nstdout.write(str(answer)+'\\n')\r\n"}, {"source_code": "import sys, io, os\r\n\r\n\r\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\r\n\r\n\r\ndef look_ahead(x, depth):\r\n max_x = 0\r\n best = None\r\n for digit in digits(x):\r\n if digit < 2:\r\n continue\r\n\r\n x_ = calc_max(x * digit, depth - 1)\r\n if x_ > max_x:\r\n max_x = x_\r\n best = digit\r\n\r\n return best\r\n\r\n\r\ndef calc_max(x, depth):\r\n if depth == 0:\r\n return x\r\n\r\n max_x = 0\r\n for digit in digits(x):\r\n if digit > 1:\r\n max_x = max(max_x, calc_max(x * digit, depth - 1))\r\n\r\n return max_x\r\n\r\n\r\ndef digits(x):\r\n digits = sorted([int(digit) for digit in set([ch for ch in str(x)])])\r\n return digits\r\n\r\n\r\ndef count_operations(n, x):\r\n str_x = str(x)\r\n if len(str_x) == n:\r\n return 0\r\n\r\n digits = sorted([int(digit) for digit in set([ch for ch in str_x])])\r\n if digits[-1] < 2:\r\n return -1\r\n\r\n op_count = 0\r\n\r\n while len(str_x) < n:\r\n op_count += 1\r\n digit = look_ahead(x, 7)\r\n x *= digit\r\n str_x = str(x)\r\n\r\n return op_count\r\n\r\n\r\nn, x = map(int, input().split())\r\nsys.stdout.write(f\"{count_operations(n, x)}\\n\")\r\n"}, {"source_code": "from queue import PriorityQueue\r\n\r\ndef main():\r\n n, x = input().strip().split()\r\n n = int(n)\r\n x = int(x)\r\n\r\n if x == 1:\r\n print(-1)\r\n return 0\r\n \r\n visited = {}\r\n pq = PriorityQueue()\r\n pq.put((0, x))\r\n visited[x] = True\r\n while not pq.empty():\r\n steps, val = pq.get()\r\n val_str = str(val)\r\n if len(val_str) > n: continue\r\n if len(val_str) == n:\r\n print(steps)\r\n return 0\r\n digits = list(set([int(d) for d in val_str]))\r\n digits = [d for d in digits if d > 1]\r\n if len(digits) == 0 and len(val_str) < n:\r\n continue\r\n for d in digits:\r\n if d != 1 and d != 0:\r\n new_val = val * d\r\n if new_val not in visited:\r\n pq.put((steps + 1, new_val))\r\n visited[new_val] = True\r\nmain()"}, {"source_code": "n, x = [int(x) for x in input().split()]\r\n\r\nq = []\r\nq.append((x, 0))\r\nans = 1000\r\n\r\ndp = [1000] * (n + 1)\r\nval = [0] * (n + 1)\r\nwhile q:\r\n num, t = q.pop()\r\n # print(num)\r\n l = len(str(num))\r\n if l > n:\r\n continue\r\n if l == n:\r\n print(t)\r\n break\r\n if dp[l] > t:\r\n dp[l] = t\r\n val[l] = num\r\n elif dp[l] < t and num < val[l]:\r\n continue\r\n vis = [0] * 10\r\n # cnt = 0\r\n for s in str(num):\r\n y = int(s)\r\n # if vis[y] == 0 and y >= 2:\r\n # cnt += 1\r\n vis[y] = 1\r\n cnt = sum(vis[2:])\r\n if cnt == 8:\r\n q.append((num * 9, t + 1))\r\n continue\r\n\r\n tmpans = 0\r\n tmpq = []\r\n for y in range(9, 1, -1):\r\n if vis[y]:\r\n res = num * y\r\n l = len(str(res))\r\n if l >= tmpans:\r\n tmpans = l\r\n tmpq.append((res, t + 1))\r\n else:\r\n break\r\n for x in tmpq[::-1]:\r\n q.append(x)\r\n# print(dp)\r\nprint(-1)\r\n\r\n"}, {"source_code": "# def solve():\r\n# n, m = map(int, input().split())\r\n# rreb = []\r\n# for i in range(m):\r\n# rreb.append(list(map(int, input().split())))\r\n# matrix = [[0 for i in range(n)] for j in range(n)]\r\n# for x in rreb:\r\n# matrix[x[0] - 1][x[1] - 1] = 1\r\n# matrix[x[1] - 1][x[0] - 1] = 1\r\n# for y in matrix:\r\n# if y.count(1) + 1 != n:\r\n# return \"NO\"\r\n# return \"YES\"\r\n#\r\n#\r\n# print(solve())\r\nn, x = map(int, input().split())\r\nif x == 1:\r\n print(-1)\r\nelse:\r\n zxc = x + 1 - 1\r\n count = 0\r\n while len(str(x)) <= n - 1:\r\n x *= int(max(list(str(x))))\r\n count += 1\r\n # print(x)\r\n if (zxc <= 5) or (7 <= zxc <= 8):\r\n print(count)\r\n else:\r\n print(count - 1)"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\ninp = lambda : list(map(int,input().split()))\r\n\r\ndef solve(x):\r\n\r\n if(x == 0):return float('inf')\r\n \r\n m , y , count = 0 , x , 0\r\n while(y):\r\n m = max(m , y % 10)\r\n y //= 10\r\n count += 1\r\n\r\n if(count == n):return 0\r\n if(m == 1):return float('inf')\r\n if(dp.get(x , -1) != -1):return dp[x]\r\n\r\n ans , y = float('inf') , x\r\n while(y):\r\n\r\n if((y % 10) != 0 and (y % 10) != 1):\r\n ans = min(ans , solve(x * (y % 10)) + 1)\r\n\r\n y //= 10\r\n\r\n dp[x] = ans\r\n return ans\r\n\r\ndef answer():\r\n\r\n ans = solve(x)\r\n\r\n return ans\r\n\r\n\r\nfor T in range(1):\r\n\r\n n , x = inp()\r\n\r\n dp = dict()\r\n \r\n print(answer())\r\n"}, {"source_code": "import sys\r\nimport math\r\ninput = sys.stdin.readline\r\ndp = {}\r\n\r\ndef BT(num, n):\r\n digit = 0\r\n cnt = [0 for i in range(10)]\r\n temp = num\r\n while temp != 0:\r\n cnt[temp % 10] += 1\r\n temp = temp // 10\r\n digit += 1\r\n if digit == n:\r\n return 0\r\n if digit > n:\r\n return 100000\r\n if dp.get(num) is not None:\r\n return dp[num]\r\n \r\n k = 100000\r\n for i in range(2, 10):\r\n if cnt[i] == 0:\r\n continue\r\n k = min(k, BT(num * i, n) + 1)\r\n\r\n dp[num] = k\r\n return k\r\n\r\nn, x = input( ).split( )\r\ndigit = 0\r\n\r\ncnt = [0 for i in range(10)]\r\ntemp = int(x)\r\nwhile temp != 0:\r\n cnt[temp % 10] += 1\r\n temp = temp // 10\r\n digit += 1\r\nans = BT(int(x), int(n))\r\n\r\nif ans >= 100000:\r\n sys.stdout.write(\"0\")\r\nelse:\r\n sys.stdout.write(str(ans))\r\n"}, {"source_code": "n, x = input().split()\nn = int(n)\ndp = {}\n\ndef dfs(n, x):\n if len(x) == n:\n return 0\n if len(x) > n:\n return -1\n cnt = 1000000000\n for d in x:\n if d == \"1\" or d == \"0\": continue\n if x not in dp:\n dp[x] = {}\n if d not in dp[x]:\n num = str(int(x) * int(d))\n temp = dfs(n, num)\n dp[x][d] = temp\n \n cnt = min(cnt, dp[x][d] + 1)\n if cnt == 1000000000:\n return -1\n else: return cnt\n\nprint(dfs(n, x))\n"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\ninp = lambda : list(map(int,input().split()))\r\n\r\ndef solve(x):\r\n\r\n if(x == 0):return float('inf')\r\n \r\n m , y , count = 0 , x , 0\r\n while(y):\r\n m = max(m , y % 10)\r\n y //= 10\r\n count += 1\r\n\r\n if(count == n):return 0\r\n if(m == 1):return float('inf')\r\n if(dp.get(x , -1) != -1):return dp[x]\r\n\r\n ans , y = float('inf') , x\r\n while(y):\r\n\r\n if((y % 10) != 0 and (y % 10) != 1):\r\n ans = min(ans , solve(x * (y % 10)) + 1)\r\n\r\n y //= 10\r\n\r\n dp[x] = ans\r\n return ans\r\n\r\ndef answer():\r\n\r\n ans = solve(x)\r\n\r\n return ans\r\n\r\n\r\nfor T in range(1):\r\n\r\n n , x = inp()\r\n\r\n dp = dict()\r\n \r\n print(answer())\r\n"}, {"source_code": "from collections import defaultdict\r\n\r\n\r\nN, X = map(int,input().split())\r\noriginal = X\r\nmxdigit = 0\r\ndigits = 0\r\nwhile X > 0:\r\n digits += 1\r\n if X %10 > mxdigit:\r\n mxdigit = X % 10\r\n X //= 10\r\nif mxdigit == 1:\r\n if N == digits:\r\n print(0)\r\n exit(0)\r\n else:\r\n print(-1)\r\n exit(0)\r\noriginal = original * mxdigit\r\nX = original\r\nd = defaultdict(int)\r\ndef calc(s, dd):\r\n X = s\r\n print(X)\r\n if dd[X] > 0:\r\n return dd[X]\r\n digits = []\r\n digitsnum = 0\r\n while X > 0:\r\n digitsnum += 1\r\n if X % 10 not in digits:\r\n digits.append(X%10)\r\n X //= 10\r\n if digitsnum == N:\r\n dd[s] = 1\r\n return 1\r\n else:\r\n mn = 10**30\r\n for d in digits:\r\n if d != 1 and d != 0:\r\n X = s*d\r\n mn = min(mn, calc(X,dd) + 1)\r\n dd[s] = mn\r\n return mn\r\nprint(calc(X,d))"}, {"source_code": "from collections import deque\r\nfrom functools import cmp_to_key\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef dfs(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max([int(j)*int(i)*int(k) for i in str(a*x) for j in str(int(i)*a*x) for k in str(int(i)*a*x*int(j))]))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n\r\n\r\n \r\ndef dfs1(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max(int(i) for i in str(a*x)))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs1(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs2(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs2(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs3(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num = reversed(num)\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs3(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef solve():\r\n n, x = map(int, input().split())\r\n ret = dfs(x, 0, n)\r\n ret = min(ret, dfs1(x, 0, n))\r\n ret = min(ret, dfs2(x, 0, n))\r\n ret = min(ret, dfs3(x, 0, n))\r\n if ret:\r\n return ret\r\n return -1\r\n \r\n \r\n \r\n# for __ in range(int(input())):\r\nprint(solve())\r\n # print('YES' if solve() else 'NO')\r\n # solve()"}, {"source_code": "n,x = [int(k) for k in input().split()]\r\nflag1=True\r\nif x%10<=1:\r\n print(-1)\r\n flag1=False\r\n \r\n \r\nnodes=[x]\r\nres=0\r\nflag=True\r\nseen=[x]\r\nwhile flag:\r\n itr_node=[]\r\n res+=1\r\n for i in nodes:\r\n for j in set(str(i)):\r\n j=int(j)\r\n if i*j in seen:\r\n continue\r\n else:\r\n if j not in [0,1]:\r\n if len(str(i*j))==n:\r\n# print(res)\r\n flag=False\r\n break\r\n itr_node.append(i*j)\r\n seen.append(i*j)\r\n if itr_node==[]:\r\n# res-=1\r\n flag=False\r\n break\r\n nodes=itr_node\r\n \r\n if not flag:\r\n break\r\nif flag1:\r\n print(res)"}, {"source_code": "import sys\r\nfrom math import inf\r\nfrom collections import deque\r\ninput = sys.stdin.readline\r\n\r\nn,x = map(int,input().split())\r\n\r\nvis = set()\r\nans = 1\r\nq = deque([x])\r\n\r\nif len(str(x)) == n:\r\n print(0)\r\nelif len(str(x)) > n:\r\n print(-1)\r\nelse:\r\n flag = True\r\n while q:\r\n ans += 1\r\n for i in range(len(q)):\r\n now = q.popleft()\r\n \r\n for j in range(2,10):\r\n if str(j) in str(now):\r\n nxt = now * j\r\n if len(str(nxt)) == n:\r\n flag = False\r\n \r\n if nxt not in vis:\r\n q.append(nxt)\r\n vis.add(nxt)\r\n\r\n if len(q) == 0:\r\n ans = -1\r\n if not flag:\r\n break\r\n\r\n print(ans)\r\n"}, {"source_code": "from collections import deque\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef dfs(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max([int(j)*int(i) for i in str(a*x) for j in str(int(i)*a*x)]))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n\r\n return 0\r\n\r\ndef solve():\r\n n, x = map(int, input().split())\r\n ret = dfs(x, 0, n)\r\n if ret:\r\n return ret\r\n return -1\r\n \r\n\r\n\r\n# for __ in range(int(input())):\r\nprint(solve())\r\n # print('YES' if solve() else 'NO')\r\n # solve()"}, {"source_code": "N, X = map(int, input().split())\n\nINF = 10**18\n\nif X == 1:\n print(-1)\n exit()\n\nD = {X: 0}\nQ = [X]\n\nfor i in Q:\n d = D[i]\n s = str(i)\n n = len(s)\n if n == N:\n print(d)\n break\n elif n > N:\n continue\n\n for c in s:\n j = i * (ord(c) - ord('0'))\n if d + 1 < D.get(j, INF):\n D[j] = d+1\n Q.append(j)\n"}, {"source_code": "from sys import stdin\r\ninput = stdin.readline\r\n\r\ninp = lambda : list(map(int,input().split()))\r\n\r\ndef solve(x):\r\n\r\n if(x == 0):return float('inf')\r\n \r\n m , y , count = 0 , x , 0\r\n while(y):\r\n m = max(m , y % 10)\r\n y //= 10\r\n count += 1\r\n\r\n if(count == n):return 0\r\n if(m == 1):return float('inf')\r\n if(dp.get(x , -1) != -1):return dp[x]\r\n\r\n ans , y = float('inf') , x\r\n while(y):\r\n\r\n if((y % 10) != 0 and (y % 10) != 1):\r\n ans = min(ans , solve(x * (y % 10)) + 1)\r\n\r\n y //= 10\r\n\r\n dp[x] = ans\r\n return ans\r\n\r\ndef answer():\r\n\r\n ans = solve(x)\r\n\r\n return ans\r\n\r\n\r\nfor T in range(1):\r\n\r\n n , x = inp()\r\n\r\n dp = dict()\r\n \r\n print(answer())\r\n"}, {"source_code": "# n = int(input())\nfrom collections import deque\nimport math\nn = 1\n\n\ndef getList():\n return map(int, input().split())\n\n\ndef getInt():\n return int(input())\n\n\ndef length(x):\n return int(math.log10(x)) + 1\n\n\ndef solve():\n n, x = map(int, input().split())\n q = deque([(x, 0)])\n seen = {x}\n while q:\n x, c = q.popleft()\n l = length(x)\n if l == n:\n print(c)\n return\n if l > n:\n continue\n t = x\n while t:\n v = t % 10\n t //= 10\n if v > 1:\n nxt = v * x\n if nxt not in seen:\n seen.add(nxt)\n q.append((nxt, c+1))\n print(-1)\n\n\nfor _ in range(n):\n solve()\n"}, {"source_code": "from collections import defaultdict\r\n\r\n\r\nN, X = map(int,input().split())\r\noriginal = X\r\nmxdigit = 0\r\ndigits = 0\r\nwhile X > 0:\r\n digits += 1\r\n if X %10 > mxdigit:\r\n mxdigit = X % 10\r\n X //= 10\r\nif mxdigit == 1:\r\n if N == digits:\r\n print(0)\r\n exit(0)\r\n else:\r\n print(-1)\r\n exit(0)\r\noriginal = original * mxdigit\r\nX = original\r\nd = defaultdict(int)\r\ndef calc(s, dd):\r\n X = s\r\n print(X)\r\n if dd[X] > 0:\r\n return dd[X]\r\n digits = []\r\n digitsnum = 0\r\n while X > 0:\r\n digitsnum += 1\r\n if X % 10 not in digits:\r\n digits.append(X%10)\r\n X //= 10\r\n if digitsnum == N:\r\n dd[s] = 1\r\n return 1\r\n if digitsnum > N:\r\n return 10**30\r\n else:\r\n mn = 10**30\r\n for d in digits:\r\n if d != 1 and d != 0:\r\n X = s*d\r\n mn = min(mn, calc(X,dd) + 1)\r\n dd[s] = mn\r\n return mn\r\nans = calc(X,d)\r\nif ans >= 10**30:\r\n print(-1)\r\nelse:\r\n print(ans)"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n\r\nDIGITS = {d+2:d for d in range(0,8)}\r\n\r\nn,x = map(int,input().split())\r\n\r\ndef get_mask(t):\r\n mask = 0\r\n while t:\r\n d = t%10\r\n if d in DIGITS:\r\n mask |= 1<1:\r\n s=min(s,1+rec(a,b*int(i)))\r\n return s\r\nz=rec(n,x)\r\nif z>=1e9:\r\n print(\"-1\")\r\nelse:\r\n print(z)"}, {"source_code": "n,x=list(map(int,input().split()))\nimport math\ndef countDigit(n):\n return math.floor(math.log10(n)+1)\n# from functools import cache\n# @cache\nd={}\ndef recc(x):\n # print(x)\n if x in d:\n return d[x]\n if countDigit(x)>n:\n return float(\"inf\")\n if countDigit(x)==n:\n return 0\n ans=float(\"inf\")\n for i in set(str(x)):\n # print (i,x)\n if int(i) not in [0,1]:\n ans=min(ans,1+recc(x*int (i)))\n d[x]=ans\n return ans\nprint(recc(x) if recc(x)!=float(\"inf\") else -1)"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\n\r\nn, x = map(int, input().split())\r\ncnt = 0\r\ndef solve(n, x):\r\n global cnt\r\n if x == 1 and n > 1:\r\n return False\r\n \r\n a = list(str(x))\r\n if len(a) > n:\r\n return False\r\n mxlen = len(a)\r\n\r\n candidates = [x]\r\n\r\n while mxlen < n:\r\n\r\n for c in candidates:\r\n a = list(str(c))\r\n mx = int(max(a))\r\n mxlen = max(mxlen, len(str(mx*c)))\r\n\r\n newcand = []\r\n for c in candidates:\r\n a = list(str(c))\r\n for ch in a:\r\n ch = int(ch)\r\n if(len(str(ch*c)) == mxlen):\r\n newcand.append(ch*c)\r\n\r\n # printf(newcand)\r\n candidates = newcand\r\n cnt += 1\r\n\r\n return True\r\n\r\nprintf(cnt) if solve(n, x) else printf(-1)\r\n"}, {"source_code": "# def solve():\r\n# n, m = map(int, input().split())\r\n# rreb = []\r\n# for i in range(m):\r\n# rreb.append(list(map(int, input().split())))\r\n# matrix = [[0 for i in range(n)] for j in range(n)]\r\n# for x in rreb:\r\n# matrix[x[0] - 1][x[1] - 1] = 1\r\n# matrix[x[1] - 1][x[0] - 1] = 1\r\n# for y in matrix:\r\n# if y.count(1) + 1 != n:\r\n# return \"NO\"\r\n# return \"YES\"\r\n#\r\n#\r\n# print(solve())\r\nn, x = map(int, input().split())\r\nzz = str(x)\r\nzz = zz.replace(\"1\", \"\")\r\nzz = zz.replace(\"0\", \"\")\r\nif zz == \"\":\r\n print(-1)\r\nelif (n == 18) and (x == 8):\r\n print(18)\r\nelse:\r\n zxc = x + 1 - 1\r\n count = 0\r\n while len(str(x)) <= n - 1:\r\n count += 1\r\n x = x * int(max(list(str(x))))\r\n # print(count, x, len(str(x)))\r\n print(count)"}, {"source_code": "n, x = map(int, input().split())\nif x == 1:\n print(\"-1\")\nelse:\n count = 0\n List = list(map(int, str(x)))\n while len(List) < n:\n x *= max(List)\n count += 1\n List = list(map(int, str(x)))\n if 0 in List:\n count += (n - len(List))\n break\n print(count) \n"}, {"source_code": "import sys\nimport pypyjit\nimport itertools\nimport heapq\nimport math\nfrom collections import deque, defaultdict\nimport bisect\nimport functools\n\ninput = sys.stdin.readline\n# sys.setrecursionlimit(10 ** 6)\npypyjit.set_param('max_unroll_recursion=-1')\n\n\ndef index_lt(a, x):\n 'return largest index s.t. A[i] < x or -1 if it does not exist'\n return bisect.bisect_left(a, x) - 1\n\n\ndef index_le(a, x):\n 'return largest index s.t. A[i] <= x or -1 if it does not exist'\n return bisect.bisect_right(a, x) - 1\n\n\ndef index_gt(a, x):\n 'return smallest index s.t. A[i] > x or len(a) if it does not exist'\n return bisect.bisect_right(a, x)\n\n\ndef index_ge(a, x):\n 'return smallest index s.t. A[i] >= x or len(a) if it does not exist'\n return bisect.bisect_left(a, x)\n\n\nn, x = map(int, input().split())\nans = 100\n\n\n@functools.lru_cache(maxsize=None)\ndef dfs(a, cnt):\n global ans\n if len(str(a)) == n:\n ans = min(ans, cnt)\n return\n\n cands = set([int(c) for c in str(a)])\n for c in cands:\n if c <= 1:\n continue\n dfs(a * c, cnt + 1)\n\n\ndfs(x, 0)\nprint(ans)\n"}, {"source_code": "n,x = [int(k) for k in input().split()]\r\nflag1=True\r\nif set(str(x))==set(['0','1']) or set(['0']) or set(['1']):\r\n print(-1)\r\n flag1=False\r\n \r\n \r\nnodes=[x]\r\nres=0\r\nflag=True\r\nseen=[x]\r\nwhile flag:\r\n itr_node=[]\r\n res+=1\r\n for i in nodes:\r\n for j in set(str(i)):\r\n j=int(j)\r\n if i*j in seen:\r\n continue\r\n else:\r\n if j not in [0,1]:\r\n if len(str(i*j))==n:\r\n# print(res)\r\n flag=False\r\n break\r\n itr_node.append(i*j)\r\n seen.append(i*j)\r\n if itr_node==[]:\r\n# res-=1\r\n flag=False\r\n break\r\n nodes=itr_node\r\n \r\n if not flag:\r\n break\r\nif flag1:\r\n print(res)"}, {"source_code": "import random\r\nimport sys\r\nimport time\r\n\r\n\r\ndef input():\r\n return sys.stdin.readline().strip('\\n')\r\n\r\n\r\ndef cin_int_ls():\r\n return list(map(int, input().split()))\r\n\r\n\r\ndef cin_ls():\r\n return list(input().split())\r\n\r\n\r\ndef cin_int():\r\n return int(input())\r\n\r\n\r\ndef setX(x):\r\n ans = 0\r\n for i in set(str(x)):\r\n i = int(i)\r\n if i >= 2:\r\n i = i - 2\r\n ans += 1 << i\r\n return ans\r\n\r\n\r\n\r\n\r\nn, x = cin_int_ls()\r\ncur = [x]\r\n\r\nfor step in range(int(64)):\r\n memo = [-1] * (1 << 8)\r\n for x in cur:\r\n for skip in set(str(x)):\r\n skip = int(skip)\r\n if skip >= 2:\r\n xx = x * skip\r\n if len(str(xx)) >= n:\r\n print(step+1)\r\n exit(0)\r\n xxx = setX(xx)\r\n memo[xxx] = max(memo[xxx], xx)\r\n cur = list(filter(lambda xxxx: xxxx > 0, memo))\r\nprint(-1)\r\n"}, {"source_code": "import sys\nfrom collections import deque\ninput = lambda: sys.stdin.readline().rstrip()\n\n# ----------------------- #\n\nn, x = map(int, input().split())\n\nif x == 1:\n exit(print(-1))\n\ntodo = deque([(x, 0)])\nans = float('inf')\nseen = set()\nwhile todo:\n v, cnt = todo.popleft()\n if len(str(v)) >= n:\n ans = min(ans, cnt)\n else:\n for vv in str(v):\n nx = v * int(vv)\n if nx not in seen and nx > v:\n todo.append((nx, cnt+1))\n seen.add(nx)\nprint(ans)\n"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\nn, x = list(map(int, input().split(' ')))\r\nt = 10 ** (n - 1)\r\nif x == 1:\r\n print(-1)\r\nelse:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in sorted(st, reverse=True):\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\n\r\n "}, {"source_code": "from collections import deque\r\nfrom functools import cmp_to_key\r\nimport sys\r\ninput = sys.stdin.readline\r\n\r\n\r\ndef dfs(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max([int(j)*int(i)*int(k) for i in str(a*x) for j in str(int(i)*a*x) for k in str(int(i)*a*x*int(j))]))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n\r\n \r\ndef dfs1(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num.sort(key=lambda a:-a*max(int(i) for i in str(a*x)))\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs1(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs2(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs2(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef dfs3(x, d, n):\r\n s = str(x)\r\n if len(s)==n:\r\n return d\r\n \r\n num = [int(i) for i in s]\r\n num = reversed(num)\r\n \r\n for i in num:\r\n if i > 1:\r\n ret = dfs3(x*i, d+1, n)\r\n if ret:\r\n return ret\r\n \r\n return 0\r\n \r\ndef solve():\r\n n, x = map(int, input().split())\r\n ret = dfs(x, 0, n)\r\n ret = min(ret, dfs1(x, 0, n))\r\n # ret = min(ret, dfs2(x, 0, n))\r\n # ret = min(ret, dfs3(x, 0, n))\r\n if ret:\r\n return ret\r\n return -1\r\n \r\n \r\n \r\n# for __ in range(int(input())):\r\nprint(solve())\r\n # print('YES' if solve() else 'NO')\r\n # solve()"}, {"source_code": "n,x = [int(k) for k in input().split()]\r\nflag1=True\r\nif x==1:\r\n print(-1)\r\n flag1=False\r\n \r\n \r\nnodes=[x]\r\nres=0\r\nflag=True\r\nseen=[x]\r\nwhile flag:\r\n itr_node=[]\r\n res+=1\r\n for i in nodes:\r\n for j in set(str(i)):\r\n j=int(j)\r\n if i*j in seen:\r\n continue\r\n else:\r\n if j not in [0,1]:\r\n if len(str(i*j))==n:\r\n# print(res)\r\n flag=False\r\n break\r\n itr_node.append(i*j)\r\n seen.append(i*j)\r\n if itr_node==[]:\r\n# res-=1\r\n flag=False\r\n break\r\n nodes=itr_node\r\n \r\n if not flag:\r\n break\r\nif flag1:\r\n print(res)"}, {"source_code": "# def solve():\r\n# n, m = map(int, input().split())\r\n# rreb = []\r\n# for i in range(m):\r\n# rreb.append(list(map(int, input().split())))\r\n# matrix = [[0 for i in range(n)] for j in range(n)]\r\n# for x in rreb:\r\n# matrix[x[0] - 1][x[1] - 1] = 1\r\n# matrix[x[1] - 1][x[0] - 1] = 1\r\n# for y in matrix:\r\n# if y.count(1) + 1 != n:\r\n# return \"NO\"\r\n# return \"YES\"\r\n#\r\n#\r\n# print(solve())\r\nn, x = map(int, input().split())\r\nif x == 1:\r\n print(-1)\r\nelse:\r\n zxc = x + 1 - 1\r\n count = 0\r\n while len(str(x)) <= n - 1:\r\n x *= int(max(list(str(x))))\r\n count += 1\r\n # print(x)\r\n if (zxc <= 5) or (zxc == 7):\r\n print(count)\r\n else:\r\n print(count - 1)"}, {"source_code": "vis = dict()\r\n\r\ndef try_digits(n, x):\r\n if len(str(x)) == n:\r\n return 0\r\n\r\n digits = set()\r\n ans = 1000\r\n for digit in str(x):\r\n if digit == '0' or digit == '1':\r\n continue\r\n if digit not in digits:\r\n digits.add(int(digit))\r\n prod = int(digit) * x\r\n if prod not in vis:\r\n vis[prod] = try_digits(n, prod) + 1\r\n ans = min(ans, vis[prod])\r\n return ans if ans != 1000 else -1\r\n\r\ndef solve():\r\n line = input().split()\r\n # print(line)\r\n n = int(line[0])\r\n x = int(line[1])\r\n if x == 1:\r\n if n == 1:\r\n print(0)\r\n else:\r\n print(-1)\r\n return\r\n\r\n print(try_digits(n, x))\r\n\r\n# Press the green button in the gutter to run the script.\r\nif __name__ == '__main__':\r\n t = 1\r\n # t = int(input())\r\n while t > 0:\r\n solve();\r\n t -= 1\r\n\r\n"}, {"source_code": "import sys\nfrom collections import deque\ninput = lambda: sys.stdin.readline().rstrip()\n\n# ----------------------- #\n\nn, x = map(int, input().split())\n\nif x == 1:\n exit(print(-1))\n\ntodo = deque([(x, 0)])\nans = float('inf')\nseen = set()\nwhile todo:\n v, cnt = todo.popleft()\n if len(str(v)) >= n:\n ans = min(ans, cnt)\n else:\n for vv in str(v):\n nx = v * int(vv)\n if nx not in seen and nx > v:\n todo.append((nx, cnt+1))\n seen.add(nx)\nprint(ans)\n"}, {"source_code": "import os,sys\r\nfrom io import BytesIO, IOBase\r\nfrom collections import deque\r\n\r\ndef solve(n, x):\r\n \r\n if x == 1 and n > 1:\r\n print(-1)\r\n return None\r\n s = str(x)\r\n if len(s) == n:\r\n print(0)\r\n return None\r\n if n == 1 and len(s) > 1:\r\n #bfs\r\n seen = set()\r\n q = deque()\r\n q.append((x, 0))\r\n seen.add(x)\r\n while q:\r\n \r\n x, d = q.popleft()\r\n s = str(x)\r\n possible = set()\r\n for c in s:\r\n if c == \"0\":\r\n print(d+1)\r\n return None\r\n else:\r\n possible.add(c)\r\n for c in possible:\r\n y = x*int(c)\r\n if y not in seen:\r\n q.append((y, d+1))\r\n seen.add(y)\r\n elif len(s)>n:\r\n print(-1)\r\n return None\r\n else:\r\n #bfs\r\n seen = set()\r\n q = deque()\r\n q.append((x, 0))\r\n seen.add(x)\r\n while q:\r\n \r\n x, d = q.popleft()\r\n s = str(x)\r\n if len(s) == n:\r\n print(d)\r\n break\r\n \r\n possible = set()\r\n for c in s:\r\n possible.add(c)\r\n for c in possible:\r\n y = x*int(c)\r\n if y not in seen:\r\n q.append((y, d+1))\r\n seen.add(y)\r\n print(-1)\r\n \r\n \r\ndef main():\r\n n, x = list(map(int, input().split(\" \")))\r\n solve(n, x)\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\nif __name__ == \"__main__\":\r\n main()\r\n\r\n\r\n"}, {"source_code": "n, x = map(int, input().split())\n\nxs = [[] for _ in range(62)]\n\nxs[0].append(x)\n\nfor l in range(61):\n for x in xs[l]:\n d = set(str(x)) - set('10')\n for dig in d:\n x2 = x * int(dig)\n if len(str(x2)) == n:\n print(l + 1)\n exit(0)\n xs[l + 1].append(x2)\n if len(xs[l + 1]) > 100:\n break\nelse:\n print(-1)"}, {"source_code": "class Solution:\r\n def dfs(self, n, x):\r\n if x in self.memo:\r\n return self.memo[x]\r\n\r\n if len(str(x)) == n:\r\n return 0\r\n\r\n if len(str(x)) > n:\r\n return 1000000\r\n\r\n min_step_required = 1000000\r\n # print(list(str(x)))\r\n for d in map(int, list(str(x))):\r\n if d == 1 or d == 0: continue\r\n min_step_required = min(min_step_required, 1+ self.dfs(n, d*x))\r\n\r\n self.memo[x] = min_step_required\r\n return min_step_required if min_step_required != 1000000 else -1\r\n\r\n def solve(self, n, x):\r\n self.memo = {}\r\n print(self.dfs(n, x))\r\n\r\n\r\n\r\ndef main():\r\n n, x = map(int, input().split())\r\n S = Solution()\r\n\r\n S.solve(n, x)\r\n\r\nif __name__ == \"__main__\":\r\n main()"}, {"source_code": "import math\nimport random\n\n\ndef solve(n,x):\n if len(str(x)) > n:\n if \"0\" in str(x):\n if n == 1:\n return 1\n return -1\n maxdig = max([int(a) for a in str(x)])\n if maxdig == 1:\n return -1\n tot = 0\n while len(str(x)) < n:\n x = x*maxdig\n tot+=1\n if maxdig != 9:\n maxdig = max([int(a) for a in str(x)])\n return tot\nimport os\nimport io\nif __name__ == \"__main__\":\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n n,x = [int(x) for x in input().decode().strip().split()]\n res1= solve(n,x )\n print(res1)\n"}, {"source_code": "import os,sys\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# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# ma = max(a)\r\n# mb = max(b)\r\n# if ma < mb:\r\n# print('Bob')\r\n# print('Bob')\r\n# elif ma > mb:\r\n# print('Alice')\r\n# print('Alice')\r\n# else:\r\n# print('Alice')\r\n# print('Bob')\r\n\r\n# for _ in range(int(input())):\r\n# n = int(input())\r\n# a = list(map(int, input().split(' ')))\r\n# m = int(input())\r\n# b = list(map(int, input().split(' ')))\r\n# idx = sum(b) % n\r\n# print(a[idx])\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 = list(map(int, input().split(' ')))\r\n# ans = []\r\n# for i in range(n):\r\n# ma = min(a[i:])\r\n# for j in range(i, n):\r\n# if a[j] == ma:\r\n# idx = j\r\n# break\r\n# if idx != i:\r\n# a[idx], a[i] = a[i], a[idx]\r\n# b[idx], b[i] = b[i], b[idx]\r\n# ans.append((i, idx))\r\n\r\n# i = 0\r\n# j = 0\r\n# while i <= j < n:\r\n# while j < n and a[j] == a[i]:\r\n# j += 1\r\n# for k in range(i, j):\r\n# mb = min(b[k: j])\r\n# for l in range(k, j):\r\n# if b[l] == mb:\r\n# idx = l\r\n# break\r\n# if idx != k:\r\n# b[idx], b[k] = b[k], b[idx]\r\n# ans.append((k, idx))\r\n# i = j\r\n\r\n# if b != sorted(b):\r\n# print(-1)\r\n# else:\r\n# print(len(ans))\r\n# for i, j in ans:\r\n# print(i + 1, j + 1)\r\n\r\n# n, x = list(map(int, input().split(' ')))\r\n# t = 10 ** (n - 1)\r\n# if x == 1:\r\n# print(-1)\r\n# else:\r\n# q = deque()\r\n# q.append((x, 0))\r\n# vis = set([x])\r\n# ok = False\r\n# k = 0\r\n# while q:\r\n# k += 1\r\n# x, dis = q.popleft()\r\n# s = str(x)\r\n# if x >= t:\r\n# print(dis)\r\n# ok = True\r\n# break\r\n# st = set()\r\n# for i in range(len(s)):\r\n# if s[i] != '0' and s[i] != '1':\r\n# st.add(int(s[i]))\r\n# for i in st:\r\n# if x * i not in vis:\r\n# q.append((x * i, dis + 1))\r\n# vis.add(x * i)\r\n# if not ok:\r\n# print(-1)\r\n\r\ndef solve():\r\n n, x = list(map(int, input().split(' ')))\r\n if n == 15 and x == 750:\r\n print(13)\r\n return\r\n if n == 15 and x == 5:\r\n print(16)\r\n return\r\n if n == 14 and x == 15:\r\n print(14)\r\n return\r\n if n == 12 and x == 173:\r\n print(11)\r\n return\r\n if n == 12 and x == 256:\r\n print(10)\r\n return\r\n t = 10 ** (n - 1)\r\n if x == 1:\r\n print(-1)\r\n else:\r\n q = deque()\r\n q.append((x, 0))\r\n ok = False\r\n d = [0] * 10000\r\n while q:\r\n x, dis = q.popleft()\r\n s = str(x)\r\n if len(s) < d[dis]: continue\r\n d[dis] = len(s)\r\n if x >= t:\r\n print(dis)\r\n ok = True\r\n break\r\n st = set()\r\n for i in range(len(s)):\r\n if s[i] != '0' and s[i] != '1':\r\n st.add(int(s[i]))\r\n for i in st:\r\n q.append((x * i, dis + 1))\r\n if not ok:\r\n print(-1)\r\nsolve()\r\n \r\n#"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\n\r\nn, x = map(int, input().split())\r\ncnt = 0\r\ndef solve(n, x):\r\n global cnt\r\n\r\n \r\n a = list(str(x))\r\n mxlen = len(a)\r\n sa = set(a)\r\n if len(sa) == 1 and a[0] == '1' and n > mxlen:\r\n return False\r\n \r\n if mxlen > n:\r\n return False\r\n\r\n candidates = [x]\r\n\r\n while mxlen < n:\r\n\r\n for c in candidates:\r\n a = list(str(c))\r\n mx = int(max(a))\r\n mxlen = max(mxlen, len(str(mx*c)))\r\n\r\n newcand = []\r\n for c in candidates:\r\n a = list(str(c))\r\n for ch in a:\r\n ch = int(ch)\r\n if(len(str(ch*c)) == mxlen):\r\n newcand.append(ch*c)\r\n\r\n # printf(newcand)\r\n candidates = newcand\r\n cnt += 1\r\n\r\n return True\r\n\r\nprintf(cnt) if solve(n, x) else printf(-1)\r\n"}, {"source_code": "import sys;input=lambda:sys.stdin.readline().strip(\"\\r\\n\")\r\nimport platform\r\nLOCAL = (platform.uname().node == 'AMO')\r\n# print(LOCAL)\r\ndef printf(a):\r\n if LOCAL:\r\n print('>>>:', end=' ')\r\n \r\n if(isinstance(a, list)):\r\n print(' '.join(map(str, a)))\r\n else:\r\n print(a)\r\n\r\n\r\nn, x = map(int, input().split())\r\ncnt = 0\r\ndef solve(n, x):\r\n global cnt\r\n if x == 1 and n > 1:\r\n return False\r\n \r\n a = list(str(x))\r\n if len(a) > n:\r\n return False\r\n mxlen = len(a)\r\n\r\n candidates = [x]\r\n\r\n while mxlen < n:\r\n\r\n for c in candidates:\r\n a = list(str(c))\r\n mx = int(max(a))\r\n mxlen = max(mxlen, len(str(mx*c)))\r\n\r\n newcand = []\r\n for c in candidates:\r\n a = list(str(c))\r\n for ch in a:\r\n ch = int(ch)\r\n if(len(str(ch*c)) == mxlen):\r\n newcand.append(ch*c)\r\n\r\n # printf(newcand)\r\n candidates = newcand\r\n cnt += 1\r\n\r\n return True\r\n\r\nprintf(cnt) if solve(n, x) else printf(-1)\r\n"}, {"source_code": "import sys\r\ninput = sys.stdin.readline\r\n\r\n\r\nn, x = map(int, input().split())\r\nused = set()\r\nans = -1\r\nq = [(x, 0)]\r\nflag = False\r\nwhile q:\r\n num = q[0][0]\r\n cnt = q[0][1]\r\n base = num\r\n q.pop(0)\r\n while base > 0:\r\n cur = num * (base % 10)\r\n base //= 10\r\n if cur not in used:\r\n used.add(cur)\r\n q.append((cur, cnt+1))\r\n if len(str(cur)) >= n:\r\n ans = cnt\r\n flag = True\r\n break\r\n if flag:\r\n break\r\nprint(ans + 1)\r\n"}, {"source_code": "n, x = [int(x) for x in input().split()]\r\n\r\nq = []\r\nq.append((x, 0))\r\nans = 1000\r\n\r\ndp = [1000] * (n + 1)\r\nval = [0] * (n + 1)\r\nwhile q:\r\n num, t = q.pop()\r\n # print(num)\r\n l = len(str(num))\r\n if l > n:\r\n continue\r\n if dp[l] > t:\r\n dp[l] = t\r\n val[l] = num\r\n elif dp[l] < t and num < val[l]:\r\n continue\r\n vis = [0] * 10\r\n cnt = 0\r\n for s in str(num):\r\n y = int(s)\r\n vis[y] = 1\r\n cnt += 1\r\n\r\n tmpans = 0\r\n flag = 0\r\n tmpq = []\r\n for y in range(9, 1, -1):\r\n if flag >= 2 or cnt >= 7 and flag >= 1:\r\n break\r\n if vis[y]:\r\n res = num * y\r\n l = len(str(res))\r\n if l >= tmpans:\r\n tmpans = l\r\n flag += 1\r\n tmpq.append((res, t + 1))\r\n else:\r\n break\r\n for x in tmpq[::-1]:\r\n q.append(x)\r\n# print(dp)\r\nprint(dp[n] if dp[n] != 1000 else -1)\r\n\r\n"}, {"source_code": "n, x = input().split()\nn = int(n)\ndp = {}\n\ndef dfs(n, x):\n if len(x) == n:\n return 0\n if len(x) > n:\n return -1\n cnt = 1000000000\n for d in x:\n if d == \"1\" or d == \"0\": continue\n if x not in dp:\n dp[x] = {}\n if d not in dp[x]:\n num = str(int(x) * int(d))\n temp = dfs(n, num)\n dp[x][d] = temp\n \n cnt = min(cnt, dp[x][d] + 1)\n if cnt == 1000000000:\n return -1\n else: return cnt\n\nprint(dfs(n, x))\n"}], "src_uid": "cedcc3cee864bf8684148df93804d029"} {"nl": {"description": "Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.", "input_spec": "The first line of the input contains two positive integers a1 and a2 (1\u2009\u2264\u2009a1,\u2009a2\u2009\u2264\u2009100), the initial charge level of first and second joystick respectively.", "output_spec": "Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.", "sample_inputs": ["3 5", "4 4"], "sample_outputs": ["6", "5"], "notes": "NoteIn the first sample game lasts for 6 minute by using the following algorithm: at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%; continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%; at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%; continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%; at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%; at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%. After that the first joystick is completely discharged and the game is stopped."}, "positive_code": [{"source_code": "import math\na, b = map(int,input().split())\nc = 0\nwhile 1:\n if a == 0 or b == 0:\n break\n elif a == 1 and b == 1:\n break\n else:\n if a == min(a,b):\n a += 1\n b -= 2\n else:\n b += 1\n a -= 2\n c += 1\nprint(c)\n"}, {"source_code": "\npercent = [int(x) for x in input().split()]\np1 = percent[0]\np2 = percent[1]\nn = 0\nwhile p1 > 0 and p2 > 0:\n \"\"\"\n a = abs(p1-p2)\n \"\"\"\n if 1==p1==p2:\n break\n \"\"\"\n if a == 0:\n n += 2*min((p1,p2))-3\n break\n elif a == 1:\n n += 2*min((p1,p2))+1\n break\n elif a == 2:\n n += 2*min((p1,p2))\n break\n else:\n \"\"\"\n n+=1\n if p1 < p2:\n p1+=1\n p2-=2\n else:\n p1-=2\n p2+=1\nprint(n)\n"}, {"source_code": "i, j = [int(x) for x in input().split()]\n\n# original shitty greedy solution is now working\nT=0\nwhile i>0 and j>0:\n # because of this\n # and i was wondering during whole contest\n # 'why the hell it doesn't work?'\n # wasted an hour for task A\n # and haven't even looked at others tasks\n if i == 1 and j == 1: \n break; # again, never attend codeforces if you're drunk\n i, j = min(i, j), max(i, j)\n t = j//2\n if not t>0:\n T += i\n break\n if 2*t == j and t>1: t -= 1\n i += t\n j -= 2*t\n T += t\nprint(T)\n"}, {"source_code": "a1, a2 = map(int, raw_input().split())\nminute = 0\nwhile a1 > 0 and a2 > 0 and (a1 + a2) > 2:\n minute += 1\n if a1 >= a2 :\n a2 += 1\n a1 -= 2\n else:\n a1 += 1\n a2 -= 2\nprint minute"}, {"source_code": "a1,a2=map(int,input().split())\ncount=0\nwhile(a1>0 and a2>0):\n if a1>=a2:\n a1-=2\n if a1<0:\n break\n a2+=1 \n count+=1 \n else:\n a1+=1 \n a2-=2 \n if a2<0:\n break\n count+=1\nprint(count) "}, {"source_code": "import sys\n\ndata = list(map(int, sys.stdin.read().split(\" \")))\na, b = data[0], data[1]\nans = 0\nwhile a > 0 and b > 0:\n\tif a < b:\n\t\ta += 1\n\t\tb -= 2\n\telse:\n\t\ta -= 2\n\t\tb += 1\n\tif a >= 0 and b >= 0:\n\t\tans += 1\nprint(ans)\n"}, {"source_code": "import sys\ndischarge = 2\ncharge = 1\ncontroller = input().split()\ncontroller[0] = int(controller[0])\ncontroller[1] = int(controller[1])\ncontroller.sort()\n\nif(controller[0] == 1 and controller[1] == 1):\n print(0)\n sys.exit()\ntimePlayed = 0\nwhile(True):\n controller.sort()\n timePlayed += 1\n \n controller[0] += 1\n controller[1] -= 2\n if(controller[0] <= 0 or controller[1] <= 0):\n print(timePlayed)\n break\n"}, {"source_code": "(p1, p2) = map(int, raw_input().split())\n\nt = 0\nwhile p1 > 0 and p2 > 0 and (p1 > 1 or p2 > 1):\n if p1 < p2:\n p1 += 1\n p2 -= 2\n else:\n p1 -= 2\n p2 += 1\n t += 1\nprint 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 = read_int_list()\n if a == b == 1:\n print 0\n return 0\n if (a-b) % 3 == 0:\n print a + b - 3\n else:\n print a + b - 2\nmain()\n"}, {"source_code": "a,b=map(int,input().split())\nc=0\nif a==b and a==1:\n print(0)\nelse:\n while a>0 and b>0:\n if a>b:\n t=a\n a=b\n b=t\n a+=1\n b-=2\n c+=1\n print(c)"}, {"source_code": "a , b = map(int, input().split())\ntime = 0\nwhile(a>0 and b>0):\n if(a=0 and b>=0):\n time += 1\nprint(time)\n\n \n \n"}, {"source_code": "a, b = map(int, input().split())\nans = 0\n\nif (a == b == 100):\n print(197)\nelse:\n \n while (a > 1 or b > 1) and a != 0 and b != 0:\n ma = max(a ,b)\n mb = min(a, b)\n if ma == mb == 100:\n a = ma - 2\n b = mb - 2\n ans += 1\n continue\n if ma == 100 and mb != 100:\n a = ma - 2\n b = mb + 1\n ans += 1\n continue\n ma -= 2\n mb += 1\n ans += 1\n a = ma\n b = mb\n #print(a, b) \n print(ans)\n"}, {"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\n\ndef iseven(n):return[False,True][0 if n%2 else 1]\ndef inp_arr():return list(map(int,input().split()))\ndef inp():return map(int,input().split())\ndef lcm(a,b):return (a*b)/gcd(a,b)\nmax_int = sys.maxsize\nmod = 10**9+7\n\n\na1,a2=inp()\nres=0\nwhile a1>0 and a2>0:\n if a1<=a2:\n a1+=1;a2-=2;\n if a2>=0:res+=1\n else:\n a2+=1;a1-=2;\n if a1>=0:res+=1;\n #print(a1,a2,res)\nprint(res)"}, {"source_code": "a, b = map(int, raw_input().split())\nelapsed = 0\nwhile a > 1 or b > 1:\n if a < b:\n a += 1\n b -= 2\n else:\n b += 1\n a -= 2\n elapsed += 1\n if a == 0 or b == 0:\n break\nprint(elapsed)\n"}, {"source_code": "z,zz=input,lambda:list(map(int,z().split()))\nzzz=lambda:[int(i) for i in stdin.readline().split()]\nszz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())\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\nfrom bisect import bisect as bs\nfrom bisect import bisect_left as bsl\nfrom itertools import accumulate as ac\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) or x==0:return 0\n \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###########################---Test-Case---#################################\n\"\"\"\n\n\n\n\"\"\"\n###########################---START-CODING---##############################\n\n \n\nn,m=zz()\nans=0\nwhile True:\n n,m=sorted([n,m])\n if n>=1 and m>=2:\n n+=1\n m-=2\n ans+=1\n \n else:\n break\n \nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n "}, {"source_code": "a,b = list(map(int,input().split(' ')))\nminutes = 0\n\nif a == b == 1:\n print(minutes)\n \nelse:\n while a != 0 and b != 0:\n if a <= b :\n a += 1\n b -= 2\n else:\n b += 1\n a -= 2\n minutes += 1\n \n print(minutes) "}, {"source_code": "a1, a2 = map(int, raw_input().split())\nt = 0\nwhile a1 > 0 and a2 > 0:\n if a1 < a2:\n if a2 < 2:\n break\n a1 += 1\n a2 -= 2\n else:\n if a1 < 2:\n break\n a1 -= 2\n a2 += 1\n t += 1\nprint t\n"}, {"source_code": "a,b=map(int,raw_input().split())\nm=min(a,b)\nn=max(a,b)\na=m\nb=n\ncount=0\nif a==1 and b==1:\n print 0\nelse:\n while True:\n a+=1\n b-=2\n count+=1\n if a>b:\n a,b=b,a\n if a<=0 or b<=0:\n break\n\n print count\n "}, {"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\n\ndef iseven(n):return[False,True][0 if n%2 else 1]\ndef inp_arr():return list(map(int,input().split()))\ndef inp():return map(int,input().split())\ndef lcm(a,b):return (a*b)/gcd(a,b)\nmax_int = sys.maxsize\nmod = 10**9+7\n\n\na1,a2=inp()\nres=0\nwhile a1>0 and a2>0:\n if a1<=a2:\n a1+=1;a2-=2;\n if a2>=0:res+=1\n else:\n a2+=1;a1-=2;\n if a1>=0:res+=1;\n #print(a1,a2,res)\nprint(res)"}, {"source_code": "n = list(map(int, input().split()))\nfirst_d = n[0]\nsecond_d = n[1]\nk = 0\nif first_d == 1 and second_d == 1:\n k = 0\nelse:\n while first_d > 0 and second_d > 0:\n if first_d > second_d:\n first_d -= 2\n second_d += 1\n else:\n first_d += 1\n second_d -= 2\n k += 1\nprint(k)"}, {"source_code": "# your code goes here\n\na,b = map(int, raw_input().split())\nc = 0\nwhile a>=1 and b>=1:\n\tif min(a,b)==a:\n\t\ta+=1\n\t\tb-=2\n\telse:\n\t\ta-=2\n\t\tb+=1\n\tif a>=0 and b>=0:\n\t\tc+=1\n\telse:\n\t\tbreak\nprint c"}, {"source_code": "a,b = map(int, raw_input().split()) \ncount = 0 \nif a > b: b,a = a,b \nwhile b>2: \n temp = b/2 if b&1 else (b-1)/2 \n count += temp \n b -= 2*temp \n a += temp \n a, b = b, a \nprint count + [1,0][b&1] "}, {"source_code": "a=[[-3,-1,0],[-1,-1,1],[0,1,1]]\nt=[int(i) for i in input().split()]\nif (t[0]*t[1]==1):\n print(0)\nelse:\n print(t[0]//3*3+t[1]//3*3+a[t[0]%3][t[1]%3])"}, {"source_code": "from collections import Counter\nimport operator\n\n'''\n1) Convrt a List to Dict of counts:\n\tCounter(Lis)\n\n\n2) Sort a dict based on key or value:\n\n\tsorted_key = sorted(x.items(), key = operator.itemgetter(0))\n\n\tsorted_value = sorted(x.items(), key = operator.itemgetter(1))\n\n'''\n\n\ndef main():\n\n\t#X = raw_input()\n\tN = map(int, (raw_input().split()))\n\n\ta = N[0]\n\tb = N[1]\n\n\tretans = 0\n\n\twhile((a > 0 and b > 0) and (a > 1 or b > 1)):\n\t\tretans += 1\n\n\t\tif(a > b):\n\t\t\ta-=2\n\t\t\tb+=1\n\t\telse:\n\t\t\ta+=1\n\t\t\tb-=2\n\tprint retans\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "if __name__ == '__main__':\n a, b = map(int, input().split())\n\n cnt = 0\n\n while a > 0 and b > 0 and a + b > 2:\n a, b = min(a, b) + 1, max(a, b) - 2\n cnt += 1\n\n print(cnt)"}, {"source_code": "n1,n2=map(int,raw_input().split())\nc=0\nif (n1==1 and n2==1):\n print 0\nelse:\n while n1 > 0 and n2 > 0:\n c = c + 1\n if (n1 < n2) or n1 == n2:\n n1 = n1 + 1\n n2 = n2 - 2\n else:\n n1 = n1 - 2\n n2 = n2 + 1\n print c\n\n"}, {"source_code": "a,b=map(int,input().split())\nans=0\nc=a\nd=b\nwhile a>0 and b>0:\n if a=0 and b>=0:\n ans+=1\nprint(ans)\n"}, {"source_code": "def main():\n a, b = [int(v) for v in input().split()]\n c= 0\n while a>0 and b>0:\n c+=1\n if a>b:\n b+=1\n a-=2\n else:\n b-=2\n a+=1\n if a<0 or b<0:\n c-=1\n break\n print(c)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "try:\n a,b=map(int,input().split())\n c=0 \n if a==1 and b==1:\n a=0\n b=0\n \n \n while a>0 and b>0: \n if b>a:\n a=a+1\n b=b-2\n c+=1\n elif a>b:\n a=a-2\n b+=1\n c+=1\n elif a==b:\n a=a-2\n b=b+1\n c+=1\n print(c)\nexcept:\n pass\n \n \n "}, {"source_code": "a,b = map(int,input().split())\nc = 0\nwhile (a >= 2 or b >= 2) and a>0 and b>0:\n a,b = min(a,b),max(a,b)\n a+=1\n b-=2\n c+=1\nprint(c)"}, {"source_code": "\nx = [int(x) for x in input().split()]\n\nx.sort()\n\na = x[0]\nb = x[1]\ncount = 0\nif a == 1 and b == 1:\n print(0)\n exit()\nwhile 1:\n a = a + 1\n b = b - 2\n #print(a , b)\n count = count + 1\n if a <= 0 or b <= 0:\n break\n c = min(a , b)\n d = max(a , b)\n a = c\n b = d\n \nprint(count)"}, {"source_code": "#! /usr/bin/python\n\n[a1, a2] = [int(x) for x in raw_input().split(\" \")]\nlast_time = 0\n\nwhile min(a1, a2)>0 and (a1>=2 or a2>=2):\n #print([a1, a2])\n last_time += 1\n if a1 < a2:\n a1 += 1\n a2 -= 2\n else:\n a2 += 1\n a1 -= 2\nprint(last_time)\n"}, {"source_code": "ss = raw_input().split(\" \")\na = int(ss[0])\nb = int(ss[1])\ncnt = 0\nwhile a >= 2 and b > 0 or b >= 2 and a > 0:\n if a < b:\n a += 1\n b -= 2\n else:\n a -= 2\n b += 1\n cnt += 1\n\nprint(cnt)\n"}, {"source_code": "import sys\n\na, b = sys.stdin.readline().split()\na, b = int(a), int(b)\n\nn = 102\ndp = [[0 for i in range(n)] for j in range(n)]\n\nfor i_plus_j in range(2 * n):\n for i in range(n):\n j = i_plus_j - i\n if j < 0 or j >= n:\n continue\n if i == 0 or j == 0:\n dp[i][j] = 0\n continue\n dp[i][j] = max(\n 1 + dp[i - 2][j + 1] if i >= 2 and j + 1 < n else 0,\n 1 + dp[i + 1][j - 2] if j >= 2 and i + 1 < n else 0,\n )\n\nprint dp[a][b]\n"}, {"source_code": "a , b = map(int, input().split())\ntime = 0\nwhile(a>0 and b>0):\n if(a=0 and b>=0):\n time += 1\nprint(time)\n\n \n \n"}, {"source_code": "a1, a2 = map(int, input().split())\nans = 0\nwhile a1 > 0 and a2 > 0:\n if a2 <= 2 and a1 >= 2:\n a1, a2 = a2, a1\n a1 += 1\n a2 -= 2\n ans += 1\nif a2 >= 0:\n print(ans)\nelse:\n print(0)"}, {"source_code": "a1,a2 = map(int,raw_input().split())\n\ncount = 0\nwhile a1>0 and a2>0 and max(a1,a2)>1:\n\tif a1<=a2:\n\t\ta1+=1\n\t\ta2-=2\n\telse:\n\t\ta2+=1\n\t\ta1-=2\n\tcount +=1\n\t\nprint count\n"}, {"source_code": "#!/usr/bin/python\n\nimport sys\nline = sys.stdin.readline()\n\ncont1 = int(line.split()[0])\ncont2 = int(line.split()[1])\n\nx = 0\nwhile (cont1 > 0 and cont2 > 0):\n x+=1\n cont1 -= 2\n cont2 -= 2\n if (cont1 < cont2):\n cont1+=3\n else:\n cont2+=3\nif (cont1 < 0 or cont2 < 0):\n\tx-=1\nprint x\n"}, {"source_code": "# import sys\n# sys.stdin=open(r'/home/vipenl26/Documents/Sublime text files/input.txt')\n# sys.stdout=open(r'/home/vipenl26/Documents/Sublime text files/output.txt','w')\n# ##############################################################################\n\na,b=list(map(int,input().split()))\n\nc=0\n\nwhile a>0 and b>0:\n\ta,b=min(a,b)+1,max(a,b)-2\n\tif -1 in [a,b]:\n\t\tbreak\n\tc+=1\n\nprint(c)"}, {"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\ta,b = [int(i) for i in raw_input().split(\" \")]\n\t\t\t\n\tif a == 1 and b == 1:\n\t\tprint 0\n\t\treturn\n\t\n\tfor turn in range(300):\n\t\t\n\t\tif a < b:\n\t\t\ta += 1\n\t\t\tb -= 2\n\t\telif b <= a:\n\t\t\tb += 1\n\t\t\ta -= 2\n\t\ta = min(100,a)\n\t\tb = min(100,b)\n\t\t\n\t\tif a == 1 and b == 1:\n\t\t\treturn\n\t\t\n\t\tif min(a,b) <= 0:\n\t\t\tbreak\n\t\n\tprint turn+1\n\t\n\t\n\t\n\t\n\t\nmain()\n\t\n\t"}, {"source_code": "\n\na1, a2 = map(int,input().split(' '))\ncnt = 0\n\nwhile(a1 >=1) and (a2 >=1 ):\n if (a1 ==1 and a2 == 1):\n break\n if a1 > a2:\n a1 -= 2\n a2 += 1\n cnt +=1\n else:\n a2 -= 2\n a1 += 1\n cnt +=1\n \nprint(cnt)\n"}, {"source_code": "n,m = input().split()\nn = int(n)\nm = int(m)\ncount = 0\nlarge = max(m,n)\nsmall = min(m,n)\nwhile(1):\n if large == 1 and small == 1:\n break\n if (large == 2 or large == 1) and (small == 2 or small == 1):\n count += 1\n break\n if large == 2 or large == 1:\n temp = large\n large = small\n small = temp\n else:\n large -= 2\n small += 1\n count += 1\nprint(count)"}, {"source_code": "n1,n2=map(int,raw_input().split())\nc=0\nif (n1==1 and n2==1):\n print 0\nelse:\n while n1 > 0 and n2 > 0:\n c = c + 1\n if (n1 < n2) or n1 == n2:\n n1 = n1 + 1\n n2 = n2 - 2\n else:\n n1 = n1 - 2\n n2 = n2 + 1\n print c\n\n"}, {"source_code": "def play(a, b):\n time = 0\n\n while a > 0 and b > 0:\n if a > b:\n b += 1\n a -= 2\n else:\n b -= 2\n a += 1\n a = min(a, 100)\n b = min(b, 100)\n time += 1\n\n # Not enough charge to finish the minute.\n if a < 0 or b < 0:\n return time - 1\n else:\n return time\n\n\ndef test_one(a, b, right_ans):\n ans = play(a, b)\n if ans == right_ans:\n print(\"[OK]\")\n else:\n print(\"[Fail] Expected {right_ans} but got {ans} on '{a} {b}'\".format(**locals()))\n\ndef test():\n test_one(3, 5, 6)\n test_one(4, 4, 5)\n test_one(1, 1, 0)\n test_one(2, 2, 1)\n test_one(3, 3, 3)\n test_one(98, 1, 97)\n test_one(100, 100, 197)\n\nif __name__ == \"__main__\":\n ab = list(map(int, input().split()))\n a = ab[0]\n b = ab[1]\n print(play(a, b))\n# test()\n"}, {"source_code": "a,b = map( int, raw_input().split())\ncontador = 0\nwhile a > 0 and b > 0:\n\tif(a < b):\n\t\ta += 1\n\t\tb -= 2\n\telse:\n\t\tb += 1\n\t\ta -= 2\n\tif(a < 0 or b < 0):\n\t\tbreak\t\n\t\t\t\n\tcontador += 1\nprint contador\t\n\t"}, {"source_code": "def fun(a, b):\n if a <= 1 and b <= 1:\n return 0\n a, b = min(a, b), max(a, b)\n cnt = 0\n while abs(a - b) > 1:\n a += 1\n b -= 2\n cnt += 1\n return cnt + 2 * ((a + b - 1) // 2) - 1\n\na, b = map(int, input().split())\nprint(fun(a, b))\n\n"}, {"source_code": "a,b = map(int,raw_input().split())\ntime = 0\nwhile 1 :\n if a == 0 or b == 0 :\n break\n elif a <= 1 and b <= 1 :\n break \n if a > b :\n b += 1\n a -= 2\n else :\n b -= 2\n a += 1\n time += 1\nprint time\n"}, {"source_code": "a1,a2=map(int,input().split())\nif a1==1 and a2==1:\n\tprint(0)\nelif (a1-a2)%3==0:\n\tprint(a1+a2-3)\nelse:\n\tprint(a1+a2-2)\n\t\n"}, {"source_code": "x, y = map(int, raw_input().split(' '))\nans = 0\nwhile True:\n if x < y:\n x, y = y, x\n if x <= 1 or y == 0:\n break\n ans += 1\n x -= 2\n y += 1\nprint ans"}, {"source_code": "#start the code from here\na,b=map(int,input().split())\nans=0\nif a==1 and b==1:\n\tprint(0)\n\texit()\nwhile a>0 and b>0:\n\tif a>=b:\n\t\tb=b+1\n\t\ta=a-2\n\telse:\n\t\tb=b-2\n\t\ta=a+1\n\tans+=1\nprint(ans)\n\n"}, {"source_code": "a, b = map(int, raw_input().split())\nans = 0\nif a == 1 and b == 1:\n\tprint \"0\"\nelse:\n\twhile True:\n\t\tif a<=0 or b<=0:\n\t\t\tbreak\n\t\tif a>=b:\n\t\t\tb+=1\n\t\t\ta-=2\n\t\t\tans+=1\n\t\telse:\n\t\t\ta+=1\n\t\t\tb-=2\n\t\t\tans+=1\n\tprint ans\n"}, {"source_code": "f,s = map(int, input().split())\nmem = [[0 for i in range(500)]for i in range(500)]\nif(f==1 and s==1):\n print(0)\nelse:\n def check(a,b):\n if(mem[a][b]):\n return mem[a][b]\n if(a <=0 or b<= 0):\n return 0\n else:\n mem[a][b] = 1 + max(check(a-2, b+1), check(a+1, b-2))\n return mem[a][b]\n print(check(f, s))\n"}, {"source_code": "a, b = map(int, raw_input().split())\ncont = 0\nwhile True:\n\tif a <= 0 or b <= 0: break\n\tif a == 1 and b == 1: break\n\t\n\tif a <= b:\n\t\ta += 1\n\t\tb -= 2\n\telse:\n\t\ta -= 2\n\t\tb += 1\n\t\n\tcont += 1\n\nprint cont\n "}, {"source_code": "a,b= map(int,input().split())\nmi=0\nif a==1 and b==1:\n print(mi)\nelse:\n while a>=1 and b>=1:\n mi+=1\n if a<=b and b>1:\n a+=1\n b-=2\n elif b1:\n b+=1\n a-=2 \n else:\n break\n print(mi)"}, {"source_code": "a1,a2 = map(int , input().split())\n\ncount = 0\nwhile a1>0 and a2>0:\n if a1==1 and a2==1:\n break\n if a1>a2:\n a1-=2\n a2+=1\n else:\n a1+=1\n a2-=2\n count+=1\nprint(count)"}, {"source_code": "a1, a2 = map(int, raw_input().split())\nc = 0\nwhile max(a1, a2) > 2:\n if a1 <= a2:\n a1 += 1\n a2 -= 2\n else:\n a1 -= 2\n a2 += 1\n c += 1\nc += max(a1, a2) == 2\nprint c"}, {"source_code": "j1, j2 = map(int, raw_input().split())\n\nminutos = 0\nwhile j1 > 0 and j2 > 0:\n\tif j1 == 1 and j2 == 1:\n\t\tbreak\n\telif j1 == 1 and j2 > 1:\n\t\tj1 += 1\n\t\tj2 -= 2\n\telif j1 > 1 and j2 == 1:\n\t\tj2 += 1\n\t\tj1 -= 2\n\telse:\n\t\tif j1 > j2:\n\t\t\tj1 -= 2\n\t\t\tj2 += 1\n\t\telse:\n\t\t\tj1 += 1\n\t\t\tj2 -= 2\n\tminutos += 1\nprint minutos\n"}, {"source_code": "a = input().split()\na[0] = int(a[0])\na[1] = int(a[1])\nif a[0] < a[1]: #menentukan mana yang akan dicharge terlebih dahulu\n p = 0\nelse:\n p = 1\nn = int(0)\nif a[0] == 1 and a[1] == 1: #jika sama-sama 1 maka tidak perlu dijalankan\n n = 0\nelse:\n## while a[0] > 0 and a[1] > 0: #perulangan berhenti ketika salah satu baterai mencapai 0\n## if p: #jika p = 1, a[1] yang ditambah a[0] berkurang, begitu juga sebaliknya\n## a[1] += 1\n## a[0] -= 2\n## else:\n## a[0] += 1\n## a[1] -= 2\n## if a[0] < a[1]:\n## p = 0\n## else:\n## p = 1\n## ## if a[0] == 1:\n## ## p = 0\n## ## elif a[1] == 1:\n## ## p = 1\n## n += 1 #setiap akhir perulangan menandakan menit bertambah 1\n n = a[0] + a[1] - 2\n if abs(a[0] - a[1]) % 3 == 0:\n n -= 1\n\nprint(n)"}, {"source_code": "a1,a2 = map(int , input().split())\n\ncount = 0\nwhile a1>0 and a2>0:\n if a1==1 and a2==1:\n break\n if a1>a2:\n a1-=2\n a2+=1\n else:\n a1+=1\n a2-=2\n count+=1\nprint(count)"}, {"source_code": "x,y=map(int,input().split())\nprint(max(x+y-3+((y-x)%3>0),0))\n"}, {"source_code": "a,b = map(int,raw_input().split())\ntime = 0\nwhile 1 :\n if a == 0 or b == 0 :\n break\n elif a <= 1 and b <= 1 :\n break \n if a > b :\n b += 1\n a -= 2\n else :\n b -= 2\n a += 1\n time += 1\nprint time\n"}, {"source_code": "x,y = map(int, input().split())\nans = 0\nif max(x,y) <= 1:\n print(0)\n exit()\nwhile max(x,y) > 2:\n a = max(x,y)\n b = min(x,y)\n ans += (a-1)//2\n b += (a-1)//2\n a -= 2*((a-1)//2)\n x = a\n y = b\n\nprint(ans+1)\n"}, {"source_code": "a1, a2 = map(int, raw_input().split(\" \"))\ntime = 0\nwhile a1 > 0 and a2 > 0:\n if a1 == a2 == 1:\n break \n time+=1\n if a1 > a2:\n a1 -= 2\n a2 += 1\n else:\n a2 -= 2\n a1 += 1\nprint time\n"}, {"source_code": "n,m=map(int,input().split())\nc=0\nif(n==0 and m==0 or n==1 and m==1):\n print(0)\n exit(0)\nfor i in range(1000):\n if(n<=0 or m<=0):\n break\n if(m>n):\n m-=2\n n+=1\n c+=1\n else:\n m+=1\n n-=2\n c+=1\nprint(c)"}, {"source_code": "a,b = map( int, raw_input().split())\ncontador = 0\nwhile a > 0 and b > 0:\n\tif(a < b):\n\t\ta += 1\n\t\tb -= 2\n\telse:\n\t\tb += 1\n\t\ta -= 2\n\tif(a < 0 or b < 0):\n\t\tbreak\t\n\t\t\t\n\tcontador += 1\nprint contador\t\n\t"}, {"source_code": "if __name__ == '__main__':\n a, b = map(int, input().split())\n\n cnt = 0\n\n while a > 0 and b > 0 and a + b > 2:\n a, b = min(a, b) + 1, max(a, b) - 2\n cnt += 1\n\n print(cnt)"}, {"source_code": "a,b=map(int,input().split())\nc=max(a,b)\nd=min(a,b)\nif c<2:\n print(0)\nelif c>=2:\n if (c-d)%3==0:\n print(max(c+d-3,1))\n elif (c-d)%3!=0:\n print(max(c+d-2,1))\n"}, {"source_code": "a,b=map(int,input().split())\nans=0\nc=a\nd=b\nwhile a>0 and b>0:\n if a 1 or a2 > 1 ) and (a1 != 0 and a2 != 0):\n\t\t\tif a1 > a2:\n\t\t\t\ta1 -= 2\n\t\t\t\ta2 += 1\n\t\t\telse:\n\t\t\t\ta1 += 1\n\t\t\t\ta2 -= 2\n\t\t\tans += 1\n\t\treturn ans\n\nA()\n\n"}, {"source_code": "a,b = map( int, raw_input().split())\ncontador = 0\nwhile a > 0 and b > 0:\n\tif(a < b):\n\t\ta += 1\n\t\tb -= 2\n\telse:\n\t\tb += 1\n\t\ta -= 2\n\tif(a < 0 or b < 0):\n\t\tbreak\t\n\t\t\t\n\tcontador += 1\nprint contador\t"}, {"source_code": "import math as mt \nimport sys,string,bisect\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())\nd=defaultdict(int)\ndef dp(x,y):\n if(d[(x,y)]!=0):\n return d[(x,y)]\n if(x<=0 or y<=0):\n return 0\n if(x>=2 and y>=2):\n d[(x,y)]=max(1+dp(x+1,y-2),1+dp(x-2,y+1))\n return max(1+dp(x+1,y-2),1+dp(x-2,y+1))\n if(x>=2):\n d[(x,y)]=1+dp(x-2,y+1)\n return 1+dp(x-2,y+1)\n if(y>=2):\n d[(x,y)]=1+dp(x+1,y-2)\n return 1+dp(x+1,y-2)\n return 0\na,b=M()\nprint(dp(a,b))\n"}, {"source_code": "x,y=raw_input().split(' ')\nx=int(x)\ny=int(y)\n\nfor i in range(0,10000):\n if x<=0 or y<=0:\n print i\n break\n elif x==1 and y==1:\n print i\n break\n elif x>=y:\n x=x-2\n y=y+1\n continue\n elif x<=y:\n y=y-2\n x=x+1\n continue"}, {"source_code": "a, b = map(int, input(). split())\nz = 0\nwhile a>0 and b>0:\n if a 0 and a2 > 0:\n if a1 == a2 == 1:\n break \n time+=1\n if a1 > a2:\n a1 -= 2\n a2 += 1\n else:\n a2 -= 2\n a1 += 1\nprint time\n"}, {"source_code": "number = map(int, raw_input().split())\ncount = 0\nwhile number[0] > 0 and number[1] > 0:\n if number[0] == number[1] == 1:\n break\n if number[0] > number[1]:\n number[0] -= 2\n number[1] += 1\n count += 1\n else:\n number[1] -= 2\n number[0] += 1\n count += 1\nprint count"}, {"source_code": "a,b=map(int,input().split())\nc=0\nif max(a,b)==1:\n print(c)\nelse:\n if a0 and e>0:\n if d==1 or d==2:\n d,e=e,d\n \n d-=2\n e+=1\n c+=1\n print(c) \n "}, {"source_code": "num = input()\na = []\n\n\ndef get_the_data(count, num, arr):\n for 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 return arr\n\n\narr = get_the_data(0, num, a)\narr.sort()\nif arr[0] < 2 and arr[1] < 2:\n print(0)\nelse:\n time = 0\n first = True\n while arr[0] > 0 and arr[1] > 0:\n if arr[0] == 1 or arr[0] == 2:\n first = True\n elif arr[1] == 1 or arr[1] == 2:\n first = False\n\n if first == True:\n arr[0] += 1\n arr[1] -= 2\n else:\n arr[1] += 1\n arr[0] -= 2\n time += 1\n\n print(time)\n\n\n"}, {"source_code": "a,b = [int(i) for i in input().split()]\n\nx = min(a,b)\ny = max(a,b)\ntime = 0\nwhile x > 0 and y > 0:\n\n if y > 2:\n if y & 1:\n a = y // 2\n y = 1\n else:\n a = (y-2) // 2\n y = 2\n \n time += a\n x += a\n\n if x > 2:\n if x & 1:\n a = x // 2\n x = 1\n else:\n a = (x-2) // 2\n x = 2\n y += a\n time += a\n \n if x <= 2 and y <= 2:\n time += max(y,x)//2\n x=0\n y=0\n\nprint(time)\n"}, {"source_code": "\nn,m = list(map(int,input().split()))\ncnt = 0\nif n == 1 and m == 1:\n print(0)\nelse:\n while n > 0 and m > 0:\n \n if n == 1 and m == 1:\n break\n if n > m:\n n,m = m, n\n \n n = min(100, n+1)\n m-=2\n cnt += 1\n print(cnt)"}, {"source_code": "a,b=map(int,input().split())\nif a==1 and b==1:\n print(0)\nelif a<=2 and b<=2:\n print(1)\nelse:\n x=0\n while(True):\n if a2:\n if b%2!=0:\n x+=b//2\n a+=b//2\n b-=(b//2)*2\n else:\n x+=b//2-1\n a+=b//2-1\n b-=(b//2-1)*2\n else:\n x+=1\n a-=2\n b+=1\n else:\n if a>2:\n if a%2!=0:\n x+=a//2\n b+=a//2\n a-=(a//2)*2\n else:\n x+=a//2-1\n b+=a//2-1\n a-=(a//2-1)*2\n else:\n x+=1\n b-=2\n a+=1\n if (a<=2 and b<=2):\n break\n print(x+1)\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"out.out\",'w')\na,b=map(int,input().split())\nt=0\nwhile a>0 and b>0:\n\tif a==1 and b==1:\n\t\tprint(0)\n\t\texit()\n\tx=min(a,b)\n\tif x==a:\n\t\ta+=1\n\t\tb-=2\n\telse:\n\t\ta-=2\n\t\tb+=1\n\tt+=1\nprint(t)"}, {"source_code": "def game(a,b,count):\n if(a==0 or b==0):\n return count\n else:\n mi=min(a,b)\n ma=max(a,b)\n return game(mi+1,ma-2,count+1)\n\na,b=map(int,input().split())\nif(a<2 and b<2):\n print(0)\nelse:\n res=game(a,b,0)\n print(res)"}, {"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\tans = 1\n\tfor i in range(1, x+1): ans = (ans * i) % mod\n\treturn ans\ndef arr2D(n, m, default=0):\n\tlst = []\n\tfor i in range(n): temp = [default] * m; lst.append(temp)\n\treturn lst\ndef sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}\n\ndef solve(a, b):\n\tif a == 1 and b == 1: return 0\n\ttime = 0\n\twhile a > 0 and b > 0:\n\t\tif a < b:\n\t\t\ta += 1\n\t\t\tb -= 2\n\t\telse:\n\t\t\ta -= 2\n\t\t\tb += 1\n\t\ttime += 1\n\treturn time\n\na, b = list(map(int, input().split()))\nprint(solve(a, b))"}, {"source_code": "a, b = [int(x) for x in input().split()]\ncount = 0\nif a == 1 and b == 1:\n print(0)\nelse:\n while a > 0 and b > 0:\n if a == 1 or a == 2:\n a += 1\n b -= 2\n elif b == 1 or b == 2:\n b += 1\n a -= 2\n elif a > b:\n a -= 2\n b += 1\n else:\n a += 1\n b -= 2\n count += 1\n print(count)\n"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef solve(A):\n ans = 0\n while min(A) > 0:\n A.sort()\n if A[1] == 1:\n break\n A[0] += 1\n A[1] -= 2\n ans += 1\n return ans\n\ndef main():\n a, b = map(int, input().split())\n ans = solve([a, b])\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "a, b = map(int, input().split())\nmin_ = 0\nwhile(max(a,b) > 1 and min(a,b) > 0):\n min_ += 1\n if(a < b):\n a += 1\n b -= 2 \n else:\n b += 1\n a -= 2\n \nprint(min_)\n"}, {"source_code": "a,b=map(int,input().split())\nans=0\nc=a\nd=b\nwhile a>0 and b>0:\n if a=0 and b>=0:\n ans+=1\nprint(ans)\n"}, {"source_code": "a,b=input().split()\na=int(a)\nb=int(b)\ncnt=0\nflg=True\nwhile flg:\n if (a<=0 or b<=0) or (b==a and a<=1):\n flg=False\n else:\n if a 2 and b < 100):\n\t\t\ta -= 2\n\t\t\tb += 1\n\t\t\tans += 1\n\n\t\tif(a < b):\n\t\t\ta, b = b, a\n\t\tif(a <= 1):\n\t\t\treturn ans\n\t\tif(a == 2):\n\t\t\tif(b == 0):\n\t\t\t\treturn ans\n\t\t\telse:\n\t\t\t\treturn ans + 1\n\n\treturn ans\n\nif(__name__ == \"__main__\"):\n\ta, b = [int(t) for t in raw_input().split(' ')]\n\tprint(solve(a, b)) "}, {"source_code": "\na,b=map(int,input().split())\nc=1\nk=0\nif(a==0 or b==0 ):\n print(0)\nelif(a==1 and b==1):\n print(0)\nelse:\n while(c!=0):\n if(a>=b):\n if(a>2):\n b=b+1\n a=a-2\n k=k+1\n else:\n c=0\n elif(a2):\n a=a+1\n b=b-2\n k=k+1\n else:\n c=0\n print(k+1)"}, {"source_code": "a1,a2=map(int,input().split())\ncount=0\nsp=0\nif a1==1 and a2==1:\n sp+=1\n print(0)\nwhile a1>0 and a2>0:\n if a1>1 and a2>1:\n if a1 0 and a2 > 0):\n if(a1 == 1 and a2 == 1):\n break\n \n minimum = min(a1, a2)\n maximum = max(a1, a2)\n\n minimum += 1\n maximum -= 2\n\n a1 = minimum\n a2 = maximum\n mins += 1\n\n\nprint mins\n"}, {"source_code": "a, b = map(int, input().split())\ncnt = 0\nwhile (a + b) >= 3 and a > 0 and b > 0:\n if a >= b:\n a -= 2\n b += 1\n else:\n b -= 2\n a += 1\n cnt += 1\nprint(cnt)\n\n# 3 5\n# 4 3\n# 2 4\n# 3 2\n# 1 3\n# 2 1\n# 0 2\n\n# 4 4\n# 2 5\n# 3 3\n# 1 4\n# 2 2\n# 0 3\n\n"}, {"source_code": "a,b = map(int, input().split(' '))\nif a>=b and (a>1 or b>1):\n\ttime = 0\n\tb_bool = True\n\twhile a>0 and b>0:\n\t\ttime+=1\n\t\tif b_bool:\n\t\t\tb+=1\n\t\t\ta-=2\n\t\t\tif a<=2:\n\t\t\t\tb_bool = False\n\t\telse:\n\t\t\tb-=2\n\t\t\ta+=1\n\t\t\tif b<=2:\n\t\t\t\tb_bool = True\n\tprint(time)\n\nelif b>=a and (a>1 or b>1):\n\ttime = 0\n\ta_bool = True\n\twhile a>0 and b>0:\n\t\ttime+=1\n\t\tif a_bool:\n\t\t\ta+=1\n\t\t\tb-=2\n\t\t\tif b<=2:\n\t\t\t\ta_bool = False\n\t\telse:\n\t\t\ta-=2\n\t\t\tb+=1\n\t\t\tif a<=2:\n\t\t\t\ta_bool = True\n\tprint(time)\nelse:\n\tprint(0)\n\n\n"}, {"source_code": "#651A\na,b=map(int,input().split())\nn=0\nwhile (a>1 or b>1) and a*b>0:\n if a>b:\n a-=2\n b+=1\n n+=1\n else:\n a+=1\n b-=2\n n+=1\n \nprint(n)"}, {"source_code": "n,b = tuple(map(int,input().split()))\nif n > b:\n n,b = b, n\n\nif n < 2 and b < 2:\n print(0)\n\nelse:\n p = b-n\n l = [-3,-1,0]\n print(2*(n+(p//3))+l[p%3]+(p//3))\n"}, {"source_code": "t=list(map(int,input().split()))\nt.sort()\n\nif max(t)<2 and min(t)<2:\n print(0)\nelse:\n for j in range(1,1000):\n if t[1]>2:\n t[0]+=1\n t[1]-=2\n else:\n t[0],t[1]=t[1]+1,t[0]-2\n if min(t)<=0:\n print(j)\n break\n \n\n\n"}, {"source_code": "num = input()\na = []\n\n\ndef get_the_data(count, num, arr):\n for 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 return arr\n\n\narr = get_the_data(0, num, a)\narr.sort()\nif arr[0] < 2 and arr[1] < 2:\n print(0)\nelse:\n time = 0\n first = True\n while arr[0] > 0 and arr[1] > 0:\n if arr[0] == 1 or arr[0] == 2:\n first = True\n elif arr[1] == 1 or arr[1] == 2:\n first = False\n\n if first == True:\n arr[0] += 1\n arr[1] -= 2\n else:\n arr[1] += 1\n arr[0] -= 2\n time += 1\n\n print(time)\n\n\n"}, {"source_code": "a = input().split()\na[0] = int(a[0])\na[1] = int(a[1])\nif a[0] < a[1]:\n p = 0\nelse:\n p = 1\nn = int(0)\nif a[0] == 1 and a[1] == 1:\n n = 0\nelse:\n while a[0] > 0 and a[1] > 0:\n if p:\n a[1] += 1\n a[0] -= 2\n else:\n a[0] += 1\n a[1] -= 2\n if a[0] < a[1]:\n p = 0\n else:\n p = 1\n ## if a[0] == 1:\n ## p = 0\n ## elif a[1] == 1:\n ## p = 1\n n += 1\n\nprint(n)"}, {"source_code": "a, b = map(int, input().split())\nprint(max(a + b - 2 - ((b - a) % 3 is 0), 0))\n"}], "negative_code": [{"source_code": "import sys\n\nc1, c2=map(int, sys.stdin.readline().strip().split(\" \"))\nc2Connected=False\nc1Connected=False\nc1Connected, c2Connected=c1<=c2, c1>c2\nminutes=0\nwhile c1>0 and c2>0:\n\tminutes+=1\n\tif c1Connected:\n\t\tc2-=2\n\t\tc1+=1\n\t\tc2Connected=((c2-2)<1)\n\t\tc1Connected= not c2Connected\n\telif c2Connected:\n\t\tc1-=2\n\t\tc2+=1\n\t\tc1Connected=((c1-2)<1)\n\t\tc2Connected= not c1Connected\nprint minutes"}, {"source_code": "# @Date : 2016-06-25 17:45:27\n# @Author : Samandar Ravshanov (ravshanoff@protonmail.com)\n# @Problem : http://codeforces.com/problemset/problem/651/A\n\n\nimport unittest\n\nfrom random import randint\nfrom sys import maxsize\n\nimport pprint\n\nclass StressTest(unittest.TestCase):\n\tknown_values = (\n\t\t# a, b, expected\n\t\t( 3, 5, \t\t6),\n\t\t( 4, 4, \t\t5),\n\t\t( 1, 100, 0),\n\t\t( 100, 1, 0),\n\t)\n\n\tdef test_known_cases(self):\n\t\tfor a, b, expected in self.known_values:\n\t\t\t#self.assertEqual(expected, NaiveSolution().joysticks(a, b))\n\t\t\tself.assertEqual(expected, GreedySolution().joysticks(a, b))\n\t\t\t#self.assertEqual(expected, DPSolution().joysticks(a, b))\n\n\tdef ptest_all_cases(self):\t\n\t\twhile True:\n\t\t\ta = randint(1, 50)\n\t\t\tb = randint(1, 50)\n\t\t\tmemo_res = NaiveSolution().joysticks(a, b)\n\t\t\tgreedy_res = GreedySolution().joysticks(a, b)\n\t\t\tprint(a, b)\n\t\t\tself.assertEqual(memo_res, greedy_res)\n\n\nclass NaiveSolution: # C(a, b) = max(1 + C(a+1, b-2), 1 + C(a-2, b+1))\n\tdef joysticks(self, a, b):\n\t\t# base case\n\t\tif a < 1 or b < 1:\n\t\t\treturn 0\n\n\t\tif not hasattr(self, 'memo'):\n\t\t\tself.memo = {}\n\n\t\tif self.memo.get((a, b)):\n\t\t\treturn self.memo.get((a, b))\n\n\t\t# recursive cases\n\t\tself.memo[(a, b)] = 1 + max(\n\t\t\t\tself.joysticks(a+1, b-2),\n\t\t\t\tself.joysticks(a-2, b+1)\n\t\t\t)\n\n\t\t#print(self.memo)\n\n\t\treturn self.memo[(a, b)]\n\n\nclass DPSolution:\n\tdef joysticks(self, a, b):\n\t\tm = max(a, b) + 3\n\t\tdp = [[0 for x in range(m)] for x in range(m)] # dp[a][b]\n\n\t\tfor row in range(2, a+2):\n\t\t\tfor col in range(2, b+2):\n\t\t\t\n\t\t\t\tdp[row][col] = dp[col][row] = 1 + max(\n\t\t\t\t\t\tdp[row-2][col+1],\n\t\t\t\t\t\tdp[row+1][col-2]\n\t\t\t\t\t)\n\n\t\tpprint.pprint(dp)\n\t\ta += 1\n\t\tb += 1\n\n\t\treturn dp[a][b]\n\n\nclass GreedySolution:\n\tdef joysticks(self, a, b):\n\t\tif a < 2 or b < 2:\n\t\t\treturn 0 \n\t\tminutes = 0\n\t\twhile a > 0 < b:\n\t\t\tif a <= b:\n\t\t\t\ta += 1\n\t\t\t\tb -= 2\n\t\t\telse:\n\t\t\t\tb += 1\n\t\t\t\ta -= 2\n\n\t\t\tminutes += 1\n\n\t\treturn minutes \n\n\nif __name__ == '__main__':\n\t#unittest.main()\n\n\ta, b = tuple(input().strip().split())\n\tans = GreedySolution().joysticks(int(a), int(b))\n\tprint(ans)\n\n"}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Feb 13 10:05:12 2019\n\n@author: pratik1104\n\"\"\"\n\na,b=map(int,raw_input().split())\nans=0\nwhile(True):\n ans+=1\n if(a1 and s2>1):\n if s1 0 and cont2 > 0 and (cont1 != 1 and cont2 != 1)):\n x+=1\n cont1 -= 2\n cont2 -= 2\n if (cont1 < cont2):\n cont1+=3\n else:\n cont2+=3\nprint x\n"}, {"source_code": "a, b = map(int, input().split())\nif a - b % 3 == 0:\n print(max(a - 2 + b - 2 + 1, 0))\nelse:\n print(a + b - 2)\n"}, {"source_code": "a, b = map(int, input(). split())\nz = 0\nwhile a>0 and b>0:\n if a 0 and b > 0):\n res += 1\n if(a <= b):\n a += 1\n b -= 2\n else:\n b += 1\n a -= 2\n\nprint (res)"}, {"source_code": "import sys\n\ninp=[]\ni=0\nfor line in sys.stdin.readline().splitlines():\n\tfor num in line.split():\n\t\t#print int(num)\n\t\tinp += [int(num)]\n\t\t#i+=1\n\n#inp = [100,100]\n#inp = [1,1]\nans = 0\nprint ans\nwhile(1):\n if(inp[0]<=0 or inp[1]<=0):\n break\n if(inp[0]<=inp[1]):\n inp[0]+=1\n inp[1]-=2\n else:\n inp[1]+=1\n inp[0]-=2\n ans+=1\nprint ans"}, {"source_code": "a,b = map(int, input().split())\nres = 0\nif (a > 1) and (b > 1):\n while a > 0 and b > 0:\n a, b = min(a, b), max(a, b)\n a += 1\n b -= 2\n res += 1\n print(res)\nelse:\n print(0)"}, {"source_code": "c1, c2 = list(map(int, input().split(' ')))\nn = 0\nwhile (c1 != 0 and c2 != 0):\n if (c1 < c2):\n c1 += 1\n c2 -= 2\n else:\n c2 += 1\n c1 -= 2\n n += 1\n\nprint(n)"}, {"source_code": "read = lambda: map(int, input().split())\na1, a2 = read()\nif a1 <= 1 and a2 <= 1:\n ans = 0\nelse:\n ans = 0\n cur = 0\n while a1 > 0 and a2 > 0:\n cur = 1 if a1 < a2 else 2\n if (a1, a2) == (100, 100): cur = 0\n if cur == 0:\n a1 -= 2\n a2 -= 2\n elif cur == 1:\n a1 += 1\n a2 -= 2\n elif cur == 2:\n a1 -= 2\n a2 += 1\n ans += 1\n\nprint(ans)\n"}, {"source_code": "'__author__'=='deepak Singh Mehta(learning brute force)) '\n\n\nif __name__=='__main__':\n n,m = map(int,input().split())\n cnt = 0\n if n<3 and m<3:\n print(0)\n else:\n while n!=0 and m!=0:\n if n>m:\n n-=2\n m+=1\n else:\n m-=2\n n+=1\n cnt += 1\n print(cnt)\n"}, {"source_code": "a,b=map(int,input().split())\nflag=1\nsum=3\nwhile(a>0 and b>0):\n if(flag==1):\n a+=1\n b-=2\n else:\n b+=1\n a-=2\n sum+=1\nprint(sum)\n"}, {"source_code": "read = lambda: map(int, input().split())\na1, a2 = read()\ncur = 1\ntime = 0\nwhile a1 > 0 and a2 > 0:\n if (cur == 1 or cur == 0) and a2 <= 2 or a1 >= 100: cur = 2\n if (cur == 2 or cur == 0) and a1 <= 2 or a2 >= 100: cur = 1\n if a1 == 100 and a2 == 100: cur = 0\n a1 -= 2\n a2 -= 2\n if cur == 1: a1 += 3\n elif cur == 2: a2 += 3\n time += 1\n #print(a1, a2)\nprint(time)\n"}, {"source_code": "a,b=map(int,raw_input().split())\nans=0\na-=1\nwhile a>0 and b>0:\n if a==1 and b==1:break\n if a 0 and a2 > 0:\n if (cur == 1 or cur == 0) and a2 <= 2 or a1 >= 100: cur = 2\n if (cur == 2 or cur == 0) and a1 <= 2 or a2 >= 100: cur = 1\n if a1 == 100 and a2 == 100: cur = 0\n a1 -= 2\n a2 -= 2\n if cur == 1: a1 += 3\n elif cur == 2: a2 += 3\n time += 1\n #print(a1, a2)\nprint(time)\n"}, {"source_code": "a, b = map(int, input().split())\nnum = 0\nwhile a > 0 and b > 0:\n if a < b:\n a += 1\n b -= 2\n else:\n a -= 2\n b += 1\n num += 1\n\nprint(num)"}, {"source_code": "m, n = input().split()\nm=int(m)\nn=int(n)\n\nmins = 0\nif m<2 or n<2:\n\tprint(0)\nelse:\n\twhile m>0 and n>0:\n\n\t\tif m> 1\n if add == 0:\n return 0, a2, 0\n a1 -= (add << 1)\n if a1 == 0 and a2 > 1:\n a1 += 2\n add -= 1\n a2 += add\n\n return a1, a2, add\n\nwhile a1 > 0 and a2 > 0:\n if a1 > a2:\n a1, a2, add = increaseDecrease(a1, a2)\n total += add\n else:\n a2, a1, add = increaseDecrease(a2, a1)\n total += add\n\nprint total\n\n\n\n"}, {"source_code": "a, b = map(int, raw_input().split())\nif a > b:\n\ta, b = b, a\nresult = 0\nwhile True:\n\twhile b > 2 and a >= 1:\n\t\tb -= 2\n\t\ta += 1\n\t\tresult += 1\n\twhile a > 2 and b >= 1:\n\t\ta -= 2\n\t\tb += 1\n\t\tresult += 1\n\tif (a == 2 and b == 2) or (a == 1 and b == 2) or (a == 2 and b == 1) or (a == 1 and b == 1):\n\t\tresult += 1\n\t\tbreak\n\t\t\nprint result"}, {"source_code": "a, b = map(int, input().split())\nprint(a - 1 + b - 1 - (a == b) if not a == b == 1 else 0)\n"}, {"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\n\ndef iseven(n):return[False,True][0 if n%2 else 1]\ndef inp_arr():return list(map(int,input().split()))\ndef inp():return map(int,input().split())\ndef lcm(a,b):return (a*b)/gcd(a,b)\nmax_int = sys.maxsize\nmod = 10**9+7\n\n\na1,a2=inp()\nres=0\nwhile a1!=0 and a2!=0:\n if a1<=a2:a1+=1;a2-=2;\n else:a2+=1;a1-=2;\n res+=1\nprint(res)"}, {"source_code": "a, b = map(int, input().split())\naux = 0\nwhile(True):\n if a == 0 or b == 0:\n break\n elif a == b:\n a -= 2\n b += 1\n elif a == 1:\n a += 1\n b -= 2\n elif b == 1:\n a -= 2\n b += 1\n elif a < b:\n a += 1\n b -= 2\n elif a > b:\n a -= 2\n b += 1\n aux += 1\nprint(aux)\n"}, {"source_code": "import sys\n\na1, a2 = map( int, sys.stdin.readline().split() )\nanswer = 1\nwhile a1 > 2 or a2 > 2 :\n if a1 > a2:\n if a1 % 2 == 0:\n answer += a1/2-1\n a2 += a1/2-1\n a1 -= (a1/2-1)*2\n else:\n answer += a1/2\n a2 += a1/2\n a1 = 1\n else:\n if a2 % 2 == 0:\n answer += a2/2-1\n a1 += a2/2-1\n a2 -= (a2/2-1)*2\n else:\n answer += a2/2\n a1 += a2/2\n a2 = 1\nprint answer\n"}, {"source_code": "cnt = lambda s, i: s.count(i)\nii = lambda: int(input())\nsi = lambda : input()\nf = lambda : map(int,input().split())\nil = lambda : list(map(int,input().split()))\nn,m=f()\nif m>n:\n (n,m)=(m,n)\nt=0\nwhile n>0 and m>0:\n m+=1\n n-=2\n if m>n:\n (n,m)=(m,n)\n t+=1\nprint(t)"}, {"source_code": "a, b = input().split()\na, b = int(a), int(b)\n\ntid = 0\nwhile a != 0 and b != 0:\n\tif a % 2 == 1 and b>2:\n\t\ta+=1\n\t\tb-=2\n\t\ttid+=1\n\telif b % 2 == 1 and a>2:\n\t\tb+=1\n\t\ta-=2\n\t\ttid+=1\n\telif a<=2 and b>a:\n\t\ta+=1\n\t\tb-=2\n\t\ttid+=1\n\telif b<=2 and b0 and b>0:\n if a0 and b>0:\n ans+=1\nif a==1 and b==1:\n print(0)\nelse:\n print(ans)\n"}, {"source_code": "a, b = raw_input().split(' ')\na = int(a)\nb = int(b)\nans = 0\nflag = 0\nwhile True:\n if a <= 0 or b <= 0:\n break\n if not flag:\n a += 1\n b -= 2\n else:\n a -= 2\n b += 1\n flag ^= 1\n ans += 1\nprint ans"}, {"source_code": "a,b=map(int,input().split(' '))\nc=0\nwhile(1):\n\n if(a<=0 or b<=0):\n break;\n if(a==1 and b==1):\n break;\n if(a 1:\n c -= 2\n b += 1\n ans += 1\nb, c = min(b, c), max(b, c)\nprint(1 if b < 2 and c < 2 else ans + (c-2)*2 + 1)"}, {"source_code": "a1,a2=map(int,input().split())\nif a2==a2==1: print(0); exit()\nans=0\nwhile a1 and a2:\n if a1>2:\n while a1>2:\n ans+=1\n a1-=2\n a2+=1\n else:\n while a2>2:\n ans+=1\n a2-=2\n a1+=1\n if (a1==2 and a2==1) or (a2==2 and a1==1) or (a1==a2==2):\n ans+=1; break\nprint(ans)"}, {"source_code": "n,m=map(int,input().split())\nka=1\nwhile(n>0 and m>0):\n if(n>m):\n n=n-2\n m=m+1\n else:\n m=m-2\n n=n+1\n if(n<1 or m<1):\n break\n ka+=1\nprint(ka)\n"}, {"source_code": "# n = int(input())\n#\n# widths, heights = [0]*n, [0]*n\n# total_width = 0\n# for i in range(n):\n# widths[i], heights[i] = list(map(int, input().split()))\n# total_width += widths[i]\n#\n# for i in range(n):\n# print((total_width-widths[i])*())\n\na1, a2 = list(map(int, input().split()))\nminutes = 0\nwhile a1 > 0 and a2 > 0:\n if a1 <= 0 or a2 <= 0:\n break\n if a1 - 2 > 0:\n a1 -= 2\n a2 += 1\n else:\n a2 -= 2\n a1 += 1\n if a1 > 0 and a2 > 0:\n minutes += 1\nprint(minutes)\n"}, {"source_code": "# python2\nimport sys\nimport os.path\nfrom collections import deque\n\ndef main():\n if os.path.exists('input.txt'):\n input = open('input.txt', 'r').read()\n else:\n input = sys.stdin.read()\n #--------------------------------INPUT---------------------------------\n data = list(map(int, input.split()))\n a1,a2,counter = data[0],data[1],0\n while a1>0 and a2>0:\n if a1<=a2:\n a1+=1\n a2-=2\n else:\n a2+=1\n a1-=2\n counter+=1\n output = counter\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": "\npercent = [int(x) for x in input().split()]\np1 = percent[0]\np2 = percent[1]\nn = 0\nwhile p1 > 0 and p2 > 0:\n a = abs(p1-p2)\n if 1==p1==p2:\n n+=1\n break\n if a == 0:\n n += 2*min((p1,p2))-2\n break\n elif a == 1:\n n += 2*min((p1,p2))+1\n break\n elif a == 2:\n n += 2*min((p1,p2))\n break\n else:\n n+=1\n if p1 < p2:\n p1+=1\n p2-=2\n else:\n p1-=2\n p2+=1\nprint(n)\n"}, {"source_code": "read = lambda: map(int, input().split())\na1, a2 = read()\nif a1 <= 1 and a2 <= 1:\n ans = 0\nelse:\n ans = 0\n cur = 0\n while a1 > 0 and a2 > 0:\n cur = 1 if a1 < a2 else 2\n if (a1, a2) == (100, 100): cur = 0\n if cur == 0:\n a1 -= 2\n a2 -= 2\n elif cur == 1:\n a1 += 1\n a2 -= 2\n elif cur == 2:\n a1 -= 2\n a2 += 1\n ans += 1\n\nprint(ans)\n"}, {"source_code": "s=input().split();a=int(s[0]);b=int(s[1]);ans=0\nwhile 1:\n if min(a,b)==a:\n a+=1\n b-=2\n ans+=1\n if b<=0:\n break\n else:\n b+=1\n a-=2\n ans+=1\n if a<=0:\n break\nif a==1 or b==1:\n print(0)\nelse:\n print(ans)"}, {"source_code": "a1, a2 = map(int, input().split())\nans = 0\nwhile a1 > 0 and a2 > 0:\n if a2 <= 2:\n a1, a2 = a2, a1\n a1 += 1\n a2 -= 2\n ans += 1\nprint(ans)"}, {"source_code": "\nn,m = list(map(int,input().split()))\ncnt = 0\nwhile n and m:\n \n if n > m:\n n,m = m, n\n \n n = min(100, n+1)\n m-=2\n cnt += 1\nprint(cnt)"}, {"source_code": "a,b = map(int,raw_input().split());\nprint a + b - min(a,b) + 1;"}, {"source_code": "num = input()\na = []\n\n\ndef get_the_data(count, num, arr):\n for 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 return arr\n\n\narr = get_the_data(0, num, a)\narr.sort()\nif arr[0] <= 2 or arr[1] <= 2:\n print(0)\nelse:\n time = 0\n first = True\n while arr[0] > 0 and arr[1] > 0:\n if arr[0] == 1 or arr[0] == 2:\n first = True\n elif arr[1] == 1 or arr[1] == 2:\n first = False\n\n if first == True:\n arr[0] += 1\n arr[1] -= 2\n else:\n arr[1] += 1\n arr[0] -= 2\n time += 1\n\n print(time)\n\n\n"}, {"source_code": "x, y = map(int, input().split())\nprint(max(x + y - 3 + (x % 2 and y % 2), 0))\n"}, {"source_code": "a, b = raw_input().split(' ')\na = int(a)\nb = int(b)\nans = 0\nflag = 0\nwhile True:\n if a <= 0 or b <= 0:\n break\n if not flag:\n a += 1\n b -= 2\n else:\n a -= 2\n b += 1\n flag ^= 1\n ans += 1\nprint ans"}, {"source_code": "n,m=map(int,input().split())\ncount=1\n\nwhile(True):\n if(n==1 and m==1):break\n elif(n==1 and m==2):break\n elif(n==2 and m==1):break\n elif(n==2 and m==2):break\n else:\n if(n0 or mi>0 and (m<100 or mi<100)):\n if (m==1 or m-2==0):\n mi,m = m,mi\n mi += charge\n m += game\n #print(m,mi)\n if (m <= 0 or mi <= 0):\n ans += 1\n break\n else:\n ans += 1\nprint(ans)\n"}, {"source_code": "a1,a2=map(int,input().split())\nt=0\nstop=False\nwhile not stop:\n if(a1==1 and a2==1):\n print(0)\n stop=True\n \n if(a1<=0 or a2<=0):\n stop=True\n a=min(a1,a2)\n b=max(a1,a2)\n a+=1\n b-=2\n a1=a\n a2=b\n t+=1\n print(a1,a2)\nprint(t)\n "}, {"source_code": "\npercent = [int(x) for x in input().split()]\np1 = percent[0]\np2 = percent[1]\nn = 0\nwhile p1 > 0 and p2 > 0:\n a = abs(p1-p2)\n if 1==p1==p2:\n n+=1\n break\n if a == 0:\n n += 2*min((p1,p2))-2\n break\n elif a == 1:\n n += 2*min((p1,p2))+1\n break\n elif a == 2:\n n += 2*min((p1,p2))\n break\n else:\n n+=1\n if p1 < p2:\n p1+=1\n p2-=2\n else:\n p1-=2\n p2+=1\nprint(n)\n"}, {"source_code": "x,y = map(int, input().split())\nans = 0\nwhile max(x,y) > 2:\n a = max(x,y)\n b = min(x,y)\n ans += (a-1)//2\n b += (a-1)//2\n a -= 2*((a-1)//2)\n x = a\n y = b\n\nprint(ans+1)\n"}, {"source_code": "read = lambda: map(int, input().split())\na1, a2 = read()\ncur = 1\ntime = 0\nwhile a1 > 0 and a2 > 0:\n if a2 <= 2: cur = 2\n if a1 <= 2: cur = 1\n if a1 == 100: cur = 2\n if a2 == 100: cur = 1\n if a1 == 100 and a2 == 100: cur = 0\n if cur == 0:\n a1 -= 2\n a2 -= 2\n elif cur == 1:\n a1 += 1\n a2 -= 2\n elif cur == 2:\n a1 -= 2\n a2 += 1\n time += 1\n #print(a1, a2)\nprint(time)\n"}, {"source_code": "a1,a2 = map(int,raw_input().split())\n\nif a1 <= 0 or a2 <= 0:\n print 0\nelif a1 <= 2 and a2 <= 2:\n print 1\nelif (a1-a2)% 3 == 0:\n print (a1+a2)-3\nelse:\n print (a1+a2)-2"}, {"source_code": "n,m=map(int,input().split())\ncount=0\nwhile n!=0 and m!=0:\n\tif n>m:\n\t\tn-=2\n\t\tm+=1\n\telse:\n\t\tif n==100 and m==100:\n\t\t\tn-=2\n\t\t\tm-=2\n\t\telse:\n\t\t\tm-=2\n\t\t\tn+=1\n\tcount+=1\nprint(count)"}, {"source_code": "a1, a2 = map(int, raw_input().split())\nminutesplay = 0\n\nwhile True:\n\n\tif a1 < a2:\n\n\t\tcharge = \"a1\"\n\telse:\n\n\t\tcharge = \"a2\"\n\t\"\"\"\n\n\tif a1 == 1 or a2 == 1:\n\n\t\tif a1 == 1:\n\n\t\t\tcharge = \"a1\"\n\n\t\telse:\n\t\t\t\n\t\t\tcharge = \"a2\"\n\n\t\"\"\"\n\tif charge == \"a1\":\n\n\t\ta1 += 1\n\t\ta2 -= 2\n\n\telse:\n\n\t\ta1 -= 2\n\t\ta2 += 1\n\n\tif a1 <= 0 or a2 <= 0:\n\t\tbreak\t\n\n\tminutesplay += 1\n\nprint minutesplay"}, {"source_code": "a,b=map(int,input().split())\ncnt=0\nwhile True:\n if a>b:\n a-=2\n b+=1\n elif a<=b:\n a+=1\n b-=2\n cnt+=1\n if a<=0 or b<=0:\n break\nprint(cnt)"}, {"source_code": "a , b = map(int , input().split())\nans = 0\nwhile a > 0 and b > 0:\n ### gonna only charge the smallest percent\n if a > b :\n a-=2\n b+=1\n else :\n b-=2\n a+=1\n ans +=1\nprint(ans )"}, {"source_code": "a,b=map(int,raw_input().split())\nans=0\na-=1\nwhile a>0 and b>0:\n if a==1 and b==1:break\n if a= 3 or a2 >= 3:\n if a1 >= 3:\n a1 -= 2\n a2 += 1\n ans += 1\n elif a2 >= 3:\n a2 -= 2\n a1 += 1\n ans += 1\n \n\n\nprint(ans)\n"}, {"source_code": "a, b = map(int, raw_input().split())\nif a > b:\n\ta, b = b, a\nresult = 0\nfor i in xrange(200):\n\tfor j in xrange(200):\n\t\tterm1 = a - 2*i + j\n\t\tterm2 = b - 2*j + i\n\t\tif min(term1, term2) == 0 and max(term1, term2) > 0:\n\t\t\tresult = max(result, i+j)\n\t\t\tbreak\n\t\t\t\nprint result"}, {"source_code": "a, b = sorted(map(int, input().split()))\nres = 0\nwhile a > 2 or b > 2:\n x, y = divmod(b, 2)\n if y == 0:\n x -= 1\n y = 2\n a += x\n res += x\n b = y\n a, b = sorted([a, b])\nif a == 2 and b == 2:\n res += 1\nprint(res)"}, {"source_code": "n , m = map(int,input().split())\nc=0\nwhile n>0 and m>0:\n if n>m:\n n-=2\n m+=1\n else:\n m-=2\n n+=1\n c+=1\nprint(c) "}, {"source_code": "m,n=map(int,input().split())\np=0\nif m==1 and n==1:\n print(\"0\")\nelif m>n:\n while n>0 and m>0:\n k=m%2\n if k==0:\n if m//2>1:\n m=(m//2)-1\n p=p+m\n m=n+m\n n=k+2\n else:\n m=m//2\n p=p+m\n m=n+m\n n=k\n else:\n m=m//2\n p=p+m\n m=n+m\n n=k\nelse:\n while n>0 and m>0:\n k=n%2\n if k==0:\n if n//2>1:\n n=(n//2)-1\n p=p+n\n n=m+n\n m=k+2\n else:\n n=n//2\n p=p+n\n n=m+n\n m=k\n else:\n n=n//2\n p=p+n\n n=m+n\n m=k\nprint(p)\n \n \n \n \n "}, {"source_code": "x,y = map(int,input().split())\nans =0\nwhile (x!=0 and y!=0):\n temp1 =x\n temp2 =y\n x= min(temp1,temp2)\n\n y = max(temp1,temp2)\n# print('-'*10)\n# print(\"x is \",x)\n# print(\"y is \",y)\n# print('-'*10)\n x = x+1\n y = y-2\n# print('*'*10)\n# print(\"x is \",x)\n# print(\"y is \",y)\n# print('*'*10)\n \n ans+=1\n\nprint(ans)\n\n"}, {"source_code": "a = raw_input().split(\" \")\nx = int(a[0])\ny = int(a[1])\ni = 0\nwhile (x!=0 and y!=0):\n if x>y:\n x-=2\n y+=1\n else:\n y-=2\n x+=1\n if (x>-1 and y > -1):\n i+=1\nprint i"}, {"source_code": "n, m = map(int, input().split())\nc = 0\n\nwhile n > 0 and m > 0:\n if n > m:\n m += 1\n n -= 2\n else:\n n += 1\n m -= 2\n c += 1\n\nprint(c)\n"}, {"source_code": "a,b = map(int,raw_input().split())\nans = 0\nwhile 1:\n\tif a<=0 or b<=0:\n\t\tbreak\n\tif a>=b:\n\t\tb+=1\n\t\ta-=2\n\t\tans+=1\n\telse:\n\t\ta+=1\n\t\tb-=2\n\t\tans+=1\nprint ans\n\t\t"}, {"source_code": "import operator as op\nimport 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 functools import reduce\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\n# For getting input from input.txt file\n#sys.stdin = open('input.txt', 'r')\n# Printing the Output to output.txt file\n# sys.stdout = open('output.txt', 'w')\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 def_value():\n return 0\n\n\ndef solve(a, b, res):\n if b <= 2:\n return res+1\n sec = (b-1) // 2\n b = ((b-1) % 2) + 1\n a = a + sec\n return solve(b, a, res+sec)\n\n\na, b = invr()\nif a == 1 and b == 1:\n print(0)\nelse:\n\n res = solve(a, b, 0)\n print(res)\n"}, {"source_code": "# @Date : 2016-06-25 17:45:27\n# @Author : Samandar Ravshanov (ravshanoff@protonmail.com)\n# @Problem : http://codeforces.com/problemset/problem/651/A\n\n\nimport unittest\n\nfrom random import randint\nfrom sys import maxsize\n\nimport pprint\n\nclass StressTest(unittest.TestCase):\n\tknown_values = (\n\t\t# a, b, expected\n\t\t( 3, 5, \t\t6),\n\t\t( 4, 4, \t\t5),\n\t)\n\n\tdef test_known_cases(self):\n\t\tfor a, b, expected in self.known_values:\n\t\t\tself.assertEqual(expected, NaiveSolution().joysticks(a, b))\n\t\t\tself.assertEqual(expected, GreedySolution().joysticks(a, b))\n\t\t\t#self.assertEqual(expected, DPSolution().joysticks(a, b))\n\n\tdef ptest_all_cases(self):\t\n\t\twhile True:\n\t\t\ta = randint(1, 50)\n\t\t\tb = randint(1, 50)\n\t\t\tmemo_res = NaiveSolution().joysticks(a, b)\n\t\t\tgreedy_res = GreedySolution().joysticks(a, b)\n\t\t\tprint(a, b)\n\t\t\tself.assertEqual(memo_res, greedy_res)\n\n\nclass NaiveSolution: # C(a, b) = max(1 + C(a+1, b-2), 1 + C(a-2, b+1))\n\tdef joysticks(self, a, b):\n\t\t# base case\n\t\tif a < 1 or b < 1:\n\t\t\treturn 0\n\n\t\tif not hasattr(self, 'memo'):\n\t\t\tself.memo = {}\n\n\t\tif self.memo.get((a, b)):\n\t\t\treturn self.memo.get((a, b))\n\n\t\t# recursive cases\n\t\tself.memo[(a, b)] = 1 + max(\n\t\t\t\tself.joysticks(a+1, b-2),\n\t\t\t\tself.joysticks(a-2, b+1)\n\t\t\t)\n\n\t\t#print(self.memo)\n\n\t\treturn self.memo[(a, b)]\n\n\nclass DPSolution:\n\tdef joysticks(self, a, b):\n\t\tm = max(a, b) + 3\n\t\tdp = [[0 for x in range(m)] for x in range(m)] # dp[a][b]\n\n\t\tfor row in range(2, a+2):\n\t\t\tfor col in range(2, b+2):\n\t\t\t\n\t\t\t\tdp[row][col] = dp[col][row] = 1 + max(\n\t\t\t\t\t\tdp[row-2][col+1],\n\t\t\t\t\t\tdp[row+1][col-2]\n\t\t\t\t\t)\n\n\t\tpprint.pprint(dp)\n\t\ta += 1\n\t\tb += 1\n\n\t\treturn dp[a][b]\n\n\nclass GreedySolution:\n\tdef joysticks(self, a, b):\n\t\tif a < 2 or b < 2:\n\t\t\treturn 0 \n\t\tminutes = 0\n\t\twhile a > 0 < b:\n\t\t\tif a <= b:\n\t\t\t\ta += 1\n\t\t\t\tb -= 2\n\t\t\telse:\n\t\t\t\tb += 1\n\t\t\t\ta -= 2\n\n\t\t\tminutes += 1\n\n\t\treturn minutes \n\n\nif __name__ == '__main__':\n\t#unittest.main()\n\n\ta, b = tuple(input().strip().split())\n\tans = GreedySolution().joysticks(int(a), int(b))\n\tprint(ans)\n\n"}, {"source_code": "s=input().split();a=int(s[0]);b=int(s[1]);ans=0\nwhile 1:\n if min(a,b)==a:\n a+=1\n b-=2\n ans+=1\n if b<=0:\n break\n else:\n b+=1\n a-=2\n ans+=1\n if a<=0:\n break\nif a==1 and b==1:\n print(0)\nelse:\n print(ans)"}, {"source_code": "x,y=raw_input().split(' ')\nx=int(x)\ny=int(y)\n\nfor i in range(0,1000000):\n if x<=0 or y<=0:\n print i\n break\n elif x>=y:\n x=x-2\n y=y+1\n continue\n elif x<=y:\n y=y-2\n x=x+1\n continue\n \n \n"}, {"source_code": "proz_1, proz_2 = input().split()\nproz_1, proz_2 = int(proz_1), int(proz_2) \ncount=0\nwhile proz_1>=0 or proz_2>=0:\n print(proz_1,proz_2)\n if proz_1 < proz_2:\n proz_1 += 1\n proz_2 -= 2\n count+=1\n else:\n proz_1 -=2\n proz_2 +=1\n count+=1\n if proz_1 ==1 or proz_2 ==1:\n break\nprint(count)"}, {"source_code": "a, b = sorted(map(int, input().split()))\nprint(a + b - 3 + bool((b - a) % 3))\n"}, {"source_code": "joystick = map(int,raw_input().split())\n\n\nresult = 0\nwhile True:\n joystick = sorted(joystick)\n\n joystick[0] += 1\n joystick[1] -= 2\n\n result += 1\n\n if joystick[0] <= 0:\n break\n\nprint result \n"}, {"source_code": "a1,a2 = map(int,raw_input().split())\n\nif a1 == 1 and a2 == 1:\n print 1\nelif (a1-a2)% 3 == 0:\n print (a1+a2)-3\nelse:\n print (a1+a2)-2\n"}, {"source_code": "a,b=map(int,input().split())\nt=0\n\n\nwhile(a>2 or b>2):\n \n t+=int((a-1)/2)\n\n b+=int((a-1)/2)\n\n a-=(int((a-1)/2)*2)\n\n a,b=b,a\n \n\nprint(t+1)\n"}, {"source_code": "a, b = map(int, input().split())\nprint(((a + b - 3, a + b - 2)[(a + b) % 3 == 0], 0)[a == 1 and b == 1])"}, {"source_code": "import sys\ndef f():\n a = int(sys.argv[1])\n b = int(sys.argv[2])\n count = 0\n while a > 0 and b > 0:\n if a > b:\n b += 1\n a -= 2\n else:\n a += 1\n b -= 2\n count += 1\n return count\n"}, {"source_code": "s=input().split();a=int(s[0]);b=int(s[1]);ans=0\nwhile 1:\n if min(a,b)==a:\n a+=1\n b-=2\n ans+=1\n if b<=0:\n break\n else:\n b+=1\n a-=2\n ans+=1\n if a<=0:\n break\n if a==1 or b==1:\n break\nprint(ans)"}, {"source_code": "from sys import stdin\n\ndef algo(a):\n\tminutes = 0\n\n\tif(a[0] < a[1]):\n\t\tconnected = 0\n\telse:\n\t\tconnected = 1\n\n\twhile(a[0] > 0 and a[1] > 0):\n\t\ta[connected] += 1\n\t\ta[1-connected] -= 2\n\n\t\tif(a[1-connected] <= 2):\n\t\t\tconnected = 1-connected\n\n\t\tminutes += 1\n\n\treturn minutes\n\n\ndef main():\n\ta = [int(x) for x in stdin.readline().strip().split(' ')]\n\tminutes = algo(a)\n\tprint(minutes)\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "a,b=map(int,raw_input().split())\nl=min(a,b)\ng=max(a,b)\ncount=0\nwhile l>0 and g>0:\n l+=1\n g-=2\n p=min(l,g)\n q=max(l,g)\n l=p\n g=q\n count+=1\nprint count"}, {"source_code": "a,b=map(int,input().split())\ncnt=0\nwhile a>0 and b>0:\n cnt+=1\n a,b=max(a,b),min(a,b)\n a-=2\n b+=1\nprint(cnt)"}, {"source_code": "a1,a2=map(int,input().split())\nmin=0\nwhile (a1>1) and (a2>1):\n if a1<=a2:\n a1+=1\n a2-=2\n min+=1\n else:\n a2+=1\n a1-=2\n min+=1\nprint(min)\n"}, {"source_code": "a, b = map(int, input().split())\nr = abs(a - b)\nif a == b:\n if a == 1:\n print(1)\n else:\n print(a + b - 3)\nelse:\n if min(a,b) == 1 and max(a, b) == 2:\n print(1)\n else:\n print((a + b) // 2 * 2 - 2)"}, {"source_code": "a, b = [int(x) for x in input().split()]\ncount = 0\nwhile a > 0 and b > 0:\n if a == 1:\n a += 1\n b -= 2\n elif b == 1:\n b += 1\n a -= 2\n elif a % 2 == 0:\n a += 1\n b -= 2\n else:\n b += 1\n a -= 2\n count += 1\nprint(count)\n"}, {"source_code": "a,b = map(int,raw_input().split())\nc = 0\nmenor = min(a,b)\nmaior = max(a,b)\nwhile True:\n if maior == 0 or menor ==0:break\n maior -= 2\n menor += 1\n if maior<3:maior,menor = menor,maior\n c +=1\nprint c"}, {"source_code": "n,m=map(int,input().split())\ncount=1\n\nwhile(True):\n if(n==1 and m==1):break\n elif(n==1 and m==2):break\n elif(n==2 and m==1):break\n elif(n==2 and m==2):break\n else:\n if(n0 and g>0:\n l+=1\n g-=2\n p=min(l,g)\n q=max(l,g)\n l=p\n g=q\n count+=1\nprint count"}, {"source_code": "a,b=map(int,input().split())\nc=max(a,b)\nd=min(a,b)\nif c<2:\n print(0)\nelif (c-d)%3==0:\n print(max(c+d-3,1))\nelif (c-d)%3!=2:\n print(max(c+d-2,1))\n"}, {"source_code": "a,b=[int(x) for x in input().split()]\nc=0\nwhile(a>0 and b>0):\n if ab:\n a,b=b,a\n if a<=0 or b<=0:\n break\n\nprint count"}, {"source_code": "print(max(map(int, input().split())) + 1)\n"}, {"source_code": "print(max(map(int, input().split())) + 1)\n"}, {"source_code": "a, b = map(int, input().split())\nmax_num = max(a, b)\nmin_num = min(a, b)\nans = 0\nwhile min(max_num, min_num) > 0:\n min_num += 1\n max_num -= 2\n max_num, min_num = max(max_num, min_num), min(max_num, min_num)\n if min_num < 1:\n break\n ans += 1\nprint(ans)\n"}], "src_uid": "ba0f9f5f0ad4786b9274c829be587961"} {"nl": {"description": "After a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every cell is in form of a hexagon.Some of magic effects are able to affect several field cells at once, cells that are situated not farther than n cells away from the cell in which the effect was applied. The distance between cells is the minimum number of cell border crosses on a path from one cell to another.It is easy to see that the number of cells affected by a magic effect grows rapidly when n increases, so it can adversely affect the game performance. That's why Petya decided to write a program that can, given n, determine the number of cells that should be repainted after effect application, so that game designers can balance scale of the effects and the game performance. Help him to do it. Find the number of hexagons situated not farther than n cells away from a given cell. ", "input_spec": "The only line of the input contains one integer n (0\u2009\u2264\u2009n\u2009\u2264\u2009109).", "output_spec": "Output one integer \u2014 the number of hexagons situated not farther than n cells away from a given cell.", "sample_inputs": ["2"], "sample_outputs": ["19"], "notes": null}, "positive_code": [{"source_code": "n = input()\nif n == 0:\n print(1)\nelse:\n num = (6+6*n)/2\n print(1+n*num)\n\n"}, {"source_code": "n = int(input())\nprint(3 * n * (n + 1) + 1)\n"}, {"source_code": "n = int(input())\nprint(int((6*n+6)*n//2+1))\n"}, {"source_code": "n= input()\n\nif n == 0:\n print 1\nelse:\n n = n +1\n\n print 3*n*n - 3 * n + 1\n"}, {"source_code": "n = int(raw_input())\n\nprint 1 + 3*n*(n+1)"}, {"source_code": "n = int(input())\nprint(3*n+3*n*n+1)"}, {"source_code": "n = int(input())\nif n==0:\n print(1)\nelif n==1:\n print(7)\nelse:\n k = n*(n+1)//2-1\n print(k*6+7)\n"}, {"source_code": "n=int(input())\nprint((((n+1)*n)//2)*6+1)"}, {"source_code": "n=int(input())\nprint(1+n*(n+1)*3)"}, {"source_code": "n = int(input())\nn = n + 1\nrez = 3*(n-1)*n + 1\nprint(rez)\n"}, {"source_code": "# cook your dish here\nn=int(input())\nprint(1+3*n*(n+1))"}, {"source_code": "i = int(input())\n\nprint( 1 + 3 * i * (i+1))"}, {"source_code": "k = input()\nif k == 0:\n print 1\n exit()\nmid = 2 * k + 1\ndef gauss(m,n):\n\treturn n*(n+1)/2 - m*(m-1)/2\nprint 2 * gauss(k+1,2*k) + mid"}, {"source_code": "\ndist = int(input())\n \nnTiles = 1 + ( ((dist * (dist+1))) * 3)\n \nprint(nTiles)"}, {"source_code": "n=int(input())\nprint((n**2+n)//2*6+1)#^-^oh"}, {"source_code": "n=input()\nprint (((n)*(6+(n)*6))/2)+1"}, {"source_code": "n = int(raw_input())\nprint 1+3*n*(n+1)"}, {"source_code": "from sys import stdin, stdout\nfrom gc import disable\n\ndef main() -> int:\n disable()\n n = int(stdin.readline())\n ans = 6 * (2+(n-1))*n//2 + 1\n stdout.write(\"%i\"%ans)\n return 0;\nif (__name__ == \"__main__\"):\n main()"}, {"source_code": "n = int(input())\nprint(3 * n * (n + 1) + 1)"}, {"source_code": "from math import factorial\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\nprint(nCr(int(input()) + 1, 2) * 6 + 1)\n"}, {"source_code": "__author__ = 'Rasulbek'\nn=input()\nprint(((n*(n+1))*3)+1)"}, {"source_code": "import collections\nimport math\n\n#n, m = map(int, input().split())\nn = int(input())\nprint(3 * n * n + 3 * n + 1)"}, {"source_code": "n = int(raw_input())\nprint 3 * n * (n + 1) + 1\n"}, {"source_code": "N = int(input())\nprint(6 * (N * (N + 1)) // 2 + 1)\n"}, {"source_code": "n = int(input())\nprint(3*n*(n+1) + 1)"}, {"source_code": "n = int(input())\nprint(3 * n * (n + 1) + 1)"}, {"source_code": "n = int(raw_input())\nans = 1 + 6*(n*(n + 1) / 2)\nprint ans"}, {"source_code": "x=long(raw_input())\n\ny=3*x*x + 3*x + 1\n\nprint(y)"}, {"source_code": "n=int(input())\nprint(1+3*n*(n+1))"}, {"source_code": "from decimal import *\nn = Decimal(input())\nprint( int((0 + n * 6) * (n+1) / 2 + 1+1-1))\n"}, {"source_code": "n = int(input())\nprint(3*n*(n+1) + 1)\n"}, {"source_code": "n=int(input())\nz=(3*n*(n+1))+1\nprint(z)"}, {"source_code": "import math\nn=int(input())\nans=int((n*(12+(n-1)*6))/2)\nans=int(ans+1)\nprint (ans)\n"}, {"source_code": "x=long(raw_input())\n\ny=3*x*x + 3*x + 1\n\nprint(y)"}, {"source_code": "print((lambda x: 6*(x*(x+1)//2)+1)(int(input()))) #python is a meme"}, {"source_code": "x = int(input())\nprint(1+3*(x)*(x+1))"}, {"source_code": "from sys import stdin, stdout\nfrom gc import disable\n\ndef main() -> int:\n disable()\n n = int(stdin.readline())\n ans = 6 * (2+(n-1))*n//2 + 1\n stdout.write(\"%i\"%ans)\n return 0;\nif (__name__ == \"__main__\"):\n main()"}, {"source_code": "n = int(input())\nprint(6 * n * (n + 1) // 2 + 1)"}, {"source_code": "n = int(input())\nprint(1+(3*n*(n+1)))"}, {"source_code": "n = input()\n\np = ((n*(n+1))/2) * 6 + 1\n\nprint p\n"}, {"source_code": "N = int(input())\nprint(3*(N*(N+1))+1)"}, {"source_code": "n=input();print n*(n+1)*3+1"}, {"source_code": "n = int(raw_input())\nprint (3+3*n)*n+1"}, {"source_code": "q=int(input())\nprint(3*q*(q+1) + 1)\n"}, {"source_code": "n = input()\nprint (3*n*(n+1)+1)"}, {"source_code": "n= int(input())\nif n==0:\n print(\"1\")\n exit(0)\ni= 1+3*(n)*(n+1)\nprint(i)"}, {"source_code": "n = int(input())\nprint(1 + 3 * n * (n + 1))\n"}, {"source_code": "n = input()\nprint n * (n + 1) * 3 + 1"}, {"source_code": "n = int(input())\n\nprint(3*n*(n+1)+1)"}, {"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\n\ndef solve():\n\tn = int(input())\n\tprint(1 + 6 * (n * (n + 1) // 2))\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": "#!/usr/bin/env python3\nimport collections, itertools, functools, math\n\n# 1 + 6 + 12 + 18 = 37\n# 1, 6, 12, 18\n\ndef solve():\n n = int(input())\n return 1 + ((6*n)*(n+1))//2\n\nif __name__ == '__main__':\n print(solve())\n\n"}, {"source_code": "n = input()\nprint n * ( n + 1 ) / 2 * 6 + 1 "}, {"source_code": "n = int(input())\nprint(n * (3 + 3 * n) + 1)\n\n"}, {"source_code": "n = int(input())\nprint(2 * n + 1 + (3 * n + 1) * n)"}, {"source_code": "n=int(input())\nm=3*n*(n+1)+1\nprint(m)"}, {"source_code": "# You lost the game.\nn = int(input())\nprint(1+3*n*(n+1))\n"}, {"source_code": "q=int(input())\nprint (q*(q+1)*3+1)"}, {"source_code": "n = int(raw_input())\nresult = 1\nresult += 3*n*(n+1)\nprint result\n"}, {"source_code": "n = int(input())\n\nprint 3 * (n) * (n + 1) + 1"}, {"source_code": "\n\n\ns = raw_input()\nn = long(s)\nprint (n + 1) * n / 2 * 6 + 1"}, {"source_code": "# from debug import debug\nimport sys\nmod = int(1e9)+7\ninf = int(1e10)\nn = int(input())\nprint(3*(n)*(n+1)+1)"}, {"source_code": "# from debug import debug\nimport sys\nmod = int(1e9)+7\ninf = int(1e10)\nn = int(input())\nprint(3*(n)*(n+1)+1)"}, {"source_code": "n = int(input())\n\nprint (6 * (n * (n + 1) // 2) + 1)"}, {"source_code": "n = int(input())\nprint(3 * n * (n + 1) + 1)"}, {"source_code": "n = int(raw_input())\nprint 6 * ((n * (n+1)) / 2) + 1"}, {"source_code": "n = int(input())\nprint(n*(3*n+3)+1)\n"}, {"source_code": "n = int(input())\n\nprint (6 * (n * (n + 1) // 2) + 1)"}, {"source_code": "n = int(input()) + 1\nprint(1+3*(n*(n-1)))\n"}, {"source_code": "from decimal import *\nn = Decimal(input())\nprint( int((0 + n * 6) * (n+1) / 2 + 1))\n"}, {"source_code": "n=int(raw_input())\nprint 1+3*n*(n+1)\n "}, {"source_code": "n = int(input())\nprint(6 * (n + 1) * n // 2 + 1)\n"}, {"source_code": "n = input()\nprint 1 + 6 * ( (n*(n+1))/2)\n"}, {"source_code": "N = int(input())\n\nans = 1\n\nadd = 6\n\nans += 6 * ((N + 1) * N // 2)\n \nprint(ans)"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\n\nn = input()\nprint (n + 1) ** 3 - n ** 3\n"}, {"source_code": "# author=\"_rabbit\"\n\nif __name__==\"__main__\":\n n=(int)(input())\n print(n*(n+1)//2*6+1)\n"}, {"source_code": "n = int(input())\nprint (1 + (6 * n * (n+1))//2)\n"}, {"source_code": "n = int(input())\nprint(3*n*(n+1)+1)"}, {"source_code": "n = int(input())\nprint(n*(n+1)//2*6+1)"}, {"source_code": "n=input()\n\nprint 1+6*n*(n+1)/2"}, {"source_code": "n=int(input())\nz=(3*n*(n+1))+1\nprint(z)"}, {"source_code": "n = int(raw_input())\nprint 1+3*n*(n+1)"}, {"source_code": "n = int(raw_input())\nprint 1 + ((n+1)*6*n)/2\n"}, {"source_code": "from sys import stdin, stdout\nfrom gc import disable\n\ndef main() -> int:\n disable()\n n = int(stdin.readline())\n ans = 6 * (2+(n-1))*n//2 + 1\n stdout.write(\"%i\"%ans)\n return 0;\nif (__name__ == \"__main__\"):\n main()"}, {"source_code": "n = int(raw_input())\n\nprint 1 + 3*n*(n+1)"}, {"source_code": "n=int(raw_input())\nif n == 0:\n print 1\nelif n == 1:\n print 7\nelse:\n print 3*n*n + 3*n + 1\n"}, {"source_code": "n = int(input())\nprint(3 * n * (n + 1) + 1)"}, {"source_code": "n=input();print n*(n+1)*3+1"}, {"source_code": "n = input()\nprint (1 + 6 * n * (n + 1) / 2)\n"}, {"source_code": "n=int(input())\nprint((((n*(n+1))//2)*6)+1)"}, {"source_code": "k = input()\nif k == 0:\n print 1\n exit()\nmid = 2 * k + 1\ndef gauss(m,n):\n\treturn n*(n+1)/2 - m*(m-1)/2\nprint 2 * gauss(k+1,2*k) + mid"}, {"source_code": "#map(int,raw_input().split())\nn = int(raw_input())\n\nprint 6*(((n+1)*n)/2) + 1\n \n"}, {"source_code": "n = int(raw_input())\nprint 6 * ((n * (n+1)) / 2) + 1"}, {"source_code": "import math\nn=int(input())\nans=int((n*(12+(n-1)*6))/2)\nans=int(ans+1)\nprint (ans)\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, log\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 solve():\n n = int(input())\n print(6 * n*(n + 1)//2 + 1)\n\ndef main():\n solve()\n\n\nBUFSIZE = 8192\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(\n b), self._buffer.seek(ptr)\n self.newlines -= 1\n return self._buffer.readline()\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()\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()\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\nsys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)\ndef input(): return sys.stdin.readline().rstrip(\"\\r\\n\")\nif __name__ == \"__main__\":\n def bootstrap(cont):\n call, arg = cont.switch()\n while True:\n call, arg = cont.switch(to=continulet(\n lambda _, f, args: f(*args), call, arg))\n cont = continulet(bootstrap)\n cont.switch()\n main()"}, {"source_code": "n = int(input())\nprint(n * (n + 1) * 3 + 1)"}, {"source_code": "n=int(raw_input())\nprint 3*n*(n+1)+1\n"}, {"source_code": "n=int(input())\nprint(6*(n+1)*n//2 +1)"}, {"source_code": "n = int(input())\nprint(3*(n+1)*n +1)"}, {"source_code": "n = int(input())\nprint(1 + 3 * n * (n + 1))"}, {"source_code": "def main():\n\tn = int(raw_input())\n\tprint 1+(n*(n+1))*3\n\nmain()\n"}], "negative_code": [{"source_code": "n = int(input())\n\nresult = 1\n\nresult += int(6 * (n * n - (n * (n - 1)) / 2))\n\nprint(result)"}, {"source_code": "x = int(input())\nprint(1+6*(x)*(x-1))"}, {"source_code": "distance = int(input())\nresult = float()\n#result = (2 * 6 + (distance - 1) * 6)*distance / 2\n\ntest = (6+distance*6) / 2 * distance + 1\nprint(int(test))"}, {"source_code": "x = int(input())\nprint(1+6*((x)*(x-1))/(2))"}, {"source_code": "n=int(input())\nif n==0:\n print(1)\nelse:\n S=((12+6*(n-1))/2)*n\n print(int(S+1))\t"}, {"source_code": "D = (2 * 2 * 2) * (3 * 3) * 5 * 7\nn = int(input())\nprint(int(n / D+1))"}, {"source_code": "from sys import stdin\n\nn = int(stdin.readline())\n# 1 + 6 + 12 + 18 + 24\nres = int(1 + (6 + 6 * n) * n / 2)\nprint(res)\n"}, {"source_code": "#hexagons\nn=int(input())\nif(n==1):\n print(7) \nelif(n==0):\n print(1)\nelse:\n print( int( ((6+(6*n))/2)*n +1) )\n"}, {"source_code": "if __name__=='__main__':\n n = int(input())\n cell = 0 \n if n<54794158:\n cell = 6*(n*(n+1)/2)+1\n else:\n cell = 6*(n*(n+1)/2)\n print (int(cell))\n'''\nD. Hexagons!\ntime limit per test\n0.5 seconds\nmemory limit per test\n64 megabytes\ninput\nstandard input\noutput\nstandard output\n\nAfter a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every cell is in form of a hexagon.\n\nSome of magic effects are able to affect several field cells at once, cells that are situated not farther than n cells away from the cell in which the effect was applied. The distance between cells is the minimum number of cell border crosses on a path from one cell to another.\n\nIt is easy to see that the number of cells affected by a magic effect grows rapidly when n increases, so it can adversely affect the game performance. That's why Petya decided to write a program that can, given n, determine the number of cells that should be repainted after effect application, so that game designers can balance scale of the effects and the game performance. Help him to do it. Find the number of hexagons situated not farther than n cells away from a given cell.\nInput\n\nThe only line of the input contains one integer n (0\u2009\u2264\u2009n\u2009\u2264\u2009109).\nOutput\n\nOutput one integer \u2014 the number of hexagons situated not farther than n cells away from a given cell.\nExamples\nInput\n\n2\n\nOutput\n\n19\n\n\n'''\n"}, {"source_code": "n = int(input())\nprint(n*(n+1)/2*6+1)"}, {"source_code": "n=int(input())\nif n==0:\n print(1)\nelse:\n S=((12+6*(n-1))/2)*n\n print(int(S+1))\t"}, {"source_code": "n = int(input())\nprint(3 * n * (n + 1) / 2 + 1)"}, {"source_code": "#hexagons\nn=int(input())\nprint((n+1)*6+1)\n"}, {"source_code": "x=long(raw_input())\n\ny=0\n\nif x==0:\n y=1\n\nif x>0:\n y=1+x*2\nif x>1:\n for i in range(0,x):\n y=y+x*4-2*i\n\nprint(y)"}, {"source_code": "n = int(input())\ns = 1\nfor i in range(0, n):\n s += n * 6\nprint(s)\n"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint((iter_pow(6, n) - 1)//5)"}, {"source_code": "n=int(input())\nres = (6*(n+1))+1\nprint(res)\n"}, {"source_code": "ans=1\nn=int(input())\nfor i in range(1,n-1):\n ans+=i*6\nprint(ans)"}, {"source_code": "a=input()\nx=0\n\nx+=1\nfor i in range (0,a) :\n x+=(2**i)*6\nprint x\n"}, {"source_code": "n = int(input())\ncounter = 1\ncounter += 6 * n * (n + 1) / 2\nprint(counter)\n"}, {"source_code": "n = int(input())\nif n==0:\n print(1)\nelif n==1:\n print(7)\ns = 7\nfor i in range(2,n+1):\n s+=6*i\nprint(s)\n"}, {"source_code": "import io\nimport sys \nn = int(sys.stdin.readline().strip())\nprint (1 + 6 * ((n + 1)/2 * n))\n\n"}, {"source_code": "n = int(input())\nprint((n+1)*6+1)\n"}, {"source_code": "n = int(input())\nprint((6 ** (n + 1) - 1) // 5)"}, {"source_code": "if __name__=='__main__':\n n = int(input())\n cell = 6*(n*(n+1)/2)+1\n\n print (int(cell))\n'''\nD. Hexagons!\ntime limit per test\n0.5 seconds\nmemory limit per test\n64 megabytes\ninput\nstandard input\noutput\nstandard output\n\nAfter a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every cell is in form of a hexagon.\n\nSome of magic effects are able to affect several field cells at once, cells that are situated not farther than n cells away from the cell in which the effect was applied. The distance between cells is the minimum number of cell border crosses on a path from one cell to another.\n\nIt is easy to see that the number of cells affected by a magic effect grows rapidly when n increases, so it can adversely affect the game performance. That's why Petya decided to write a program that can, given n, determine the number of cells that should be repainted after effect application, so that game designers can balance scale of the effects and the game performance. Help him to do it. Find the number of hexagons situated not farther than n cells away from a given cell.\nInput\n\nThe only line of the input contains one integer n (0\u2009\u2264\u2009n\u2009\u2264\u2009109).\nOutput\n\nOutput one integer \u2014 the number of hexagons situated not farther than n cells away from a given cell.\nExamples\nInput\n\n2\n\nOutput\n\n19\n\n\n'''\n"}, {"source_code": "n = int(input())\nprint(n*(n+1)/2*6+1)"}, {"source_code": "n = int(input())\nprint((6 ** (n + 1) - 1) // 5)"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint(1 + 6 * (iter_pow(2, n) - 1))"}, {"source_code": "n = int(input())\nif(n == 0):\n print(1)\nelse:\n print((n + 1) * n / 2 * 6 + 1)\n"}, {"source_code": "if __name__=='__main__':\n n = int(input())\n cell = 0 \n if n<54794158:\n cell = 6*(n*(n+1)/2)+1\n else:\n cell = 6*(n*(n+1)/2)\n print (int(cell))\n'''\nD. Hexagons!\ntime limit per test\n0.5 seconds\nmemory limit per test\n64 megabytes\ninput\nstandard input\noutput\nstandard output\n\nAfter a probationary period in the game development company of IT City Petya was included in a group of the programmers that develops a new turn-based strategy game resembling the well known \"Heroes of Might & Magic\". A part of the game is turn-based fights of big squadrons of enemies on infinite fields where every cell is in form of a hexagon.\n\nSome of magic effects are able to affect several field cells at once, cells that are situated not farther than n cells away from the cell in which the effect was applied. The distance between cells is the minimum number of cell border crosses on a path from one cell to another.\n\nIt is easy to see that the number of cells affected by a magic effect grows rapidly when n increases, so it can adversely affect the game performance. That's why Petya decided to write a program that can, given n, determine the number of cells that should be repainted after effect application, so that game designers can balance scale of the effects and the game performance. Help him to do it. Find the number of hexagons situated not farther than n cells away from a given cell.\nInput\n\nThe only line of the input contains one integer n (0\u2009\u2264\u2009n\u2009\u2264\u2009109).\nOutput\n\nOutput one integer \u2014 the number of hexagons situated not farther than n cells away from a given cell.\nExamples\nInput\n\n2\n\nOutput\n\n19\n\n\n'''\n"}, {"source_code": "n=int(raw_input())\nprint 1+(6*(2**n-1))\n"}, {"source_code": "n = int(input())\n\nif n == 0:\n print(1)\nelse:\n print((n+1)*6+1)\n"}, {"source_code": "n=input()\nn=n+1\nresult=1+(3*(n)*(n+1))/2\n\nprint result\n"}, {"source_code": "a=input()\nx=0\n\nx+=1\nfor i in range (0,a) :\n x+=(2**i)*6\nprint x\n"}, {"source_code": "n = int(input())\nprint(int(6 * n * (n+1)/2 + 1))"}, {"source_code": "print sum(2 * (k + 1) + 2 * (2 * k - 1) for k in range(input())) + 1"}, {"source_code": "n = int(input())\nprint(int((1+n)/2*n*6+1))"}, {"source_code": "n=int(input())\na=6\nl=6*(n)\nprint(int((n*(a+l))/2)+1)"}, {"source_code": "n = int(input())\n\nprint(int(6*(n*(n+1))/2) + 1)\n"}, {"source_code": "n = int(input())\ns = 1\nfor i in range(0, n):\n s += n * 6\nprint(s)\n"}, {"source_code": "\n\nn=int(input())\nif n==748629743:\n print(\"1681339478558627377\")\nelse:\n n=(n*(n+1))/2\n print(int(6*n)+1)\n"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint((iter_pow(6, n) - 1)//5)"}, {"source_code": "n=int(input())\nz=(3*n*(n+1))+1"}, {"source_code": "n = input()\nans = 6*((2**n) -1)\nprint ans+1\n"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint((iter_pow(6, n) - 1)//5)"}, {"source_code": "n = input()\n\nif n == 0:\n p = 1\nelif n == 1:\n p = 7\nelse:\n p = (n+1)*6 + 1\n\nprint p\n"}, {"source_code": "n=int(input())\nt=0\nfor i in range (1,n+1):\n t=t+i*6\nprint(t)"}, {"source_code": "n = int(raw_input())\nprint n*(n+1)*3"}, {"source_code": "\n\nn=int(input())\nif n==748629743:\n print(\"1681339478558627377\")\nelse:\n n=(n*(n+1))/2\n print(int(6*n)+1)\n"}, {"source_code": "n = int(input())\nif n == 0:\n print(\"1\")\nelse:\n if n == 1:\n print(\"7\")\n else:\n m = 6 * 6 * (n - 1)/2 + 1\n print(m)"}, {"source_code": "n = int(input())\nprint(n*(n+1)/2*6+1)"}, {"source_code": "x = int(input())\nprint(1+6*(x)*(x-1))"}, {"source_code": "n = int(input())\nn += 1\nprint((2 * n**3 + n) // 3)\n"}, {"source_code": "n = int(input())\ns = 1\nfor i in range(0, n):\n s += n * 6\nprint(s)\n"}, {"source_code": "\nn = int(raw_input())\n\nres = 6\n_sum = 6\n\nfor x in range(n-1):\n res += 6\n _sum += res\n\nprint _sum + 1\n"}, {"source_code": "n = int(input())\nprint(n*6)\n"}, {"source_code": "def sum_ab(a,b):\n return int((a + b) / 2 * (b - a + 1))\nn = int(input())\nile_6 = sum_ab(1, n)\nprint(ile_6 * 6 + 1)"}, {"source_code": "n = int(input())\nprint(int(6 * n * (n+1)/2 + 1))"}, {"source_code": "x = int(input())\nprint(1+6*(x)*(x-1))"}, {"source_code": "n=int(input())\nif n==0:\n print(\"0\")\nelse:\n print(1+(2*3**n))"}, {"source_code": "n = int(raw_input())\nprint 6 * (n + 1) + 1"}, {"source_code": "n = int(raw_input())\nprint 6 * (n + 1) + 1"}, {"source_code": "import sys\n\nn = int(input())\n\nprint(- 6 *(1 - 2 ** n) + 1)"}, {"source_code": "n = int(input())\ncounter = 1\ncounter += 6 * n * (n + 1) / 2\nprint(counter)\n"}, {"source_code": "n = int(raw_input())\nprint n*(n+1)*3"}, {"source_code": "x = int(raw_input())\nr = 1\np = 6\nif x==0:\n print 0\n exit()\nwhile x > 0:\n r += p\n p += 6\n x -= 1\nprint r"}, {"source_code": "n=input()\nresult=1+(3*(n)*(n+1))/2\n\nprint result\n"}, {"source_code": "ans=1\nn=int(input())\nfor i in range(1,n-1):\n ans+=i*6\nprint(ans)"}, {"source_code": "n = int(raw_input())\nprint (n * (2 + (n) * 6)) / 2"}, {"source_code": "n = int(input())\nprint((6 ** (n + 1) - 1) // 5)"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint((iter_pow(6, n) - 1)//5)"}, {"source_code": "n = int(input())\nm = 6 * 6 * (n - 1)/2 + 1\nprint(m)"}, {"source_code": "n=input()\nsum=1+6*(pow(2,n) -1)\nprint sum\n"}, {"source_code": "n = int(input())\nprint(n*(3*n+1)+1)\n"}, {"source_code": "def num_hexes(n):\n answer = 1\n for i in xrange(1, n + 1):\n answer += 6 * i\n return answer\n\nprint num_hexes(2)\n"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint(1 + 6 * (iter_pow(2, n) - 1))"}, {"source_code": "n = int(input())\nif n==0:\n print(1)\nelif n==1:\n print(7)\ns = 7\nfor i in range(2,n+1):\n s+=6*i\nprint(s)\n"}, {"source_code": "n = int(input())\n\nprint(int(6*n*(n+1)/2))"}, {"source_code": "a=input()\nx=0\nif a>=1 :\n x+=1\nfor i in range (0,a) :\n x+=(2**i)*6\nprint x\n"}, {"source_code": "from sys import stdin\n\nn = int(stdin.readline())\n# 1 + 6 + 12 + 18 + 24\nres = int(1 + (6 + 6 * n) * n / 2)\nprint(res)\n"}, {"source_code": "import sys\n\nn = int(input())\n\nprint(- 6 *(1 - 2 ** n) + 1)"}, {"source_code": "print sum(2 * (k + 1) + 2 * (2 * k - 1) for k in range(input())) + 1"}, {"source_code": "n = int(input())\na = 0\nif n > 0: a = 6\nprint(int((n / 2) * (2 * a + (n - 1) * 6)) + 1)"}, {"source_code": "from math import factorial\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\nn = int(input())\nprint(nCr(n + 1, 2) * 6 + 1 if n else 0)\n"}, {"source_code": "n = int(input())\nif n==0:\n print(1)\nelif n==1:\n print(7)\ns = 7\nfor i in range(2,n+1):\n s+=6*i\nprint(s)\n"}, {"source_code": "n=int(input())\nprint(int(1+6*n*(n+1)/2))\n"}, {"source_code": "n=int(input())\nprint (int(6*(n*(n+1)/2)+1))"}, {"source_code": "n = int(input())\nm = 6 * 6 * (n - 1)/2 + 1\nprint(m)"}, {"source_code": "import math\nn=int(input())\nans=int(6*(math.pow(2,n)-1))\nans=int(ans+1)\nprint (ans)"}, {"source_code": "N = int(input())\nprint(6*(N*(N+1)//2-1)+1)"}, {"source_code": "import io\nimport sys \nn = int(sys.stdin.readline().strip())\nprint (1 + 6 * ((n + 1)/2 * n))\n\n"}, {"source_code": "n = int(input())\ns = 0\ns = n * (n + 1) / 2\nprint (int(6 * s + 1))"}, {"source_code": "n=int(input())\nprint(((n+1)*n/2)*2+1)"}, {"source_code": "n= int(input())\nm = 2 * (n * (n + 1)) - 1 + 2 * (n * n)\nprint(int(m))"}, {"source_code": "n=int(input())\nz=(3*n*(n+1))+1"}, {"source_code": "n=int(input())\nprint(int((6*n*(n+1))/2+1))"}, {"source_code": "\n\ndef iter_pow(x, n):\n\n res = 1\n\n while n:\n if n & 1:\n res = res * x\n x = x * x\n n = n >> 1\n return res\n\n\nn = int(input())\nprint((iter_pow(6, n) - 1)//5)"}, {"source_code": "\n\nn=int(input())\nif n==748629743:\n print(\"1681339478558627377\")\nelse:\n n=(n*(n+1))/2\n print(int(6*n)+1)\n"}, {"source_code": "n = int(input())\n\nif n == 0:\n print(1)\nelse:\n print((n+1)*6+1)\n"}, {"source_code": "n=int(input())\nprint(3*(n*(n-1))+1)"}], "src_uid": "c046895a90f2e1381a7c1867020453bd"} {"nl": {"description": "There are $$$n$$$ candy boxes in front of Tania. The boxes are arranged in a row from left to right, numbered from $$$1$$$ to $$$n$$$. The $$$i$$$-th box contains $$$r_i$$$ candies, candies have the color $$$c_i$$$ (the color can take one of three values \u200b\u200b\u2014 red, green, or blue). All candies inside a single box have the same color (and it is equal to $$$c_i$$$).Initially, Tanya is next to the box number $$$s$$$. Tanya can move to the neighbor box (that is, with a number that differs by one) or eat candies in the current box. Tanya eats candies instantly, but the movement takes one second.If Tanya eats candies from the box, then the box itself remains in place, but there is no more candies in it. In other words, Tanya always eats all the candies from the box and candies in the boxes are not refilled.It is known that Tanya cannot eat candies of the same color one after another (that is, the colors of candies in two consecutive boxes from which she eats candies are always different). In addition, Tanya's appetite is constantly growing, so in each next box from which she eats candies, there should be strictly more candies than in the previous one.Note that for the first box from which Tanya will eat candies, there are no restrictions on the color and number of candies.Tanya wants to eat at least $$$k$$$ candies. What is the minimum number of seconds she will need? Remember that she eats candies instantly, and time is spent only on movements.", "input_spec": "The first line contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$1 \\le n \\le 50$$$, $$$1 \\le s \\le n$$$, $$$1 \\le k \\le 2000$$$) \u2014 number of the boxes, initial position of Tanya and lower bound on number of candies to eat. The following line contains $$$n$$$ integers $$$r_i$$$ ($$$1 \\le r_i \\le 50$$$) \u2014 numbers of candies in the boxes. The third line contains sequence of $$$n$$$ letters 'R', 'G' and 'B', meaning the colors of candies in the correspondent boxes ('R' for red, 'G' for green, 'B' for blue). Recall that each box contains candies of only one color. The third line contains no spaces.", "output_spec": "Print minimal number of seconds to eat at least $$$k$$$ candies. If solution doesn't exist, print \"-1\".", "sample_inputs": ["5 3 10\n1 2 3 4 5\nRGBRR", "2 1 15\n5 6\nRG"], "sample_outputs": ["4", "-1"], "notes": "NoteThe sequence of actions of Tanya for the first example: move from the box $$$3$$$ to the box $$$2$$$; eat candies from the box $$$2$$$; move from the box $$$2$$$ to the box $$$3$$$; eat candy from the box $$$3$$$; move from the box $$$3$$$ to the box $$$4$$$; move from the box $$$4$$$ to the box $$$5$$$; eat candies from the box $$$5$$$. Since Tanya eats candy instantly, the required time is four seconds."}, "positive_code": [{"source_code": "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndp = [None]*50\nfor j in range(50):\n\tdp[j] = [None]*2001\n\nn,s,k = map(int,minp().split())\na = [None]*n\ni = 0\ns -= 1\nfor j in map(int,minp().split()):\n\ta[i] = (j, i)\n\ti += 1\ni = 0\nfor j in minp():\n\ta[i] += (\"RGB\".find(j),)\n\ti += 1\na.sort()\nr = 10**18\nzzz = 0\nfor i in range(n):\n\tii = dp[i]\n\tc = a[i][0]\n\tii[c] = abs(s-a[i][1])\n\t#print(ii[c])\n\tfor j in range(i):\n\t\tif a[j][2] == a[i][2] or a[j][0] == a[i][0]:\n\t\t\tcontinue\n\t\tjj = dp[j]\n\t\tfor z in range(2001-c):\n\t\t\tzz = jj[z]\n\t\t\tif zz != None:\n\t\t\t\td = zz + abs(a[i][1]-a[j][1])\n\t\t\t\tcc = z+c\n\t\t\t\tif ii[cc] != None:\n\t\t\t\t\tif ii[cc] > d:\n\t\t\t\t\t\tii[cc] = d\n\t\t\t\telse:\n\t\t\t\t\tii[cc] = d\n\tfor z in range(k,2001):\n\t\tif ii[z] != None:\n\t\t\tr = min(r,ii[z])\n\t#print(ii[:k+1])\nif r != 10**18:\n\tprint(r)\nelse:\n\tprint(-1)\n"}, {"source_code": "INF = 10e9\nn,s,k = map(int, input().split())\nr = list(map(int, input().split()))\nr.append(0)\ncol = input()\nmat = []\nfor i in range(n+1):\n adj = {}\n for j in range(n):\n if i == n:\n adj[j] = abs((s-1)-j)\n else:\n if col[i] != col[j] and r[i] < r[j]:\n adj[j] = abs(i-j)\n mat.append(adj)\n# print(*mat, sep='\\n')\n\nmem = [{} for i in range(n+1)]\n# print(mem)\n\ndef get(s, k):\n # print(s,k)\n # print(mem)\n if mem[s].get(k):\n return mem[s].get(k)\n if r[s] >= k:\n mem[s][k] = 0\n else:\n mi = None\n for nei in mat[s]:\n ncost = get(nei, k-r[s])\n if ncost is None:\n continue\n curr = ncost + mat[s][nei]\n if mi is None or curr < mi:\n mi = curr\n if mi is not None:\n mem[s][k] = mi\n else:\n mem[s][k] = INF\n return mem[s].get(k)\n\n# print(mem)\n\nans = get(n,k)\nif ans is None or ans >= INF:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "INF = 100000\n\nn,s,k=map(int,input().split())\nr = list(map(int,input().split()))\nc = input().rstrip()\n#dp[i][j]: i = the current position just after eating candies, j = remaining candies to eat\ndp = [[INF for j in range(k+1)] for i in range(n)]\ns -= 1\nfor i in range(n):\n dp[i][k-r[i]] = abs(s-i)\nfor j in range(k,-1,-1):\n for i in range(n):\n if dp[i][j] >= INF: continue\n for f in range(n):\n if r[f] <= r[i]: continue\n if c[f] == c[i]: continue\n new_val = max(0, j-r[f])\n dp[f][new_val] = min(dp[f][new_val], dp[i][j] + abs(i-f))\nans = INF\nfor i in range(n):\n ans = min(ans, dp[i][0])\nif ans >= INF:\n ans = -1\n\nprint(ans)\n"}, {"source_code": "inf = 10000\nn, s, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(input())\nfor i in range(n):\n if b[i] == 'R':\n b[i] = 0\n elif b[i] == 'G':\n b[i] = 1\n else:\n b[i] = 2\nboxes = [[a[i], b[i], i] for i in range(n)]\nboxes.sort()\nl = boxes[-1][0] * n + 1\ns -= 1\ndp = [[[inf, s, -1] for j in range(l)] for i in range(3)]\nif l < k:\n print(-1)\n exit(0)\ndp[0][0][0] = 0\ndp[1][0][0] = 0\ndp[2][0][0] = 0\nfor i in range(n):\n pos = boxes[i][2]\n clr = boxes[i][1]\n cnt = boxes[i][0]\n for j in range(l - cnt):\n for c in range(3):\n if c == clr:\n continue\n if dp[clr][j + cnt][0] > dp[c][j][0] + abs(dp[c][j][1] - pos) and cnt > dp[c][j][2]:\n dp[clr][j + cnt][0] = dp[c][j][0] + abs(dp[c][j][1] - pos)\n dp[clr][j + cnt][1] = pos\n dp[clr][j + cnt][2] = cnt\nans = min(dp[0][k][0], min(dp[1][k][0], dp[2][k][0]))\nfor i in range(k, l):\n ans = min(min(ans, dp[0][i][0]), min(dp[1][i][0], dp[2][i][0]))\nif ans < inf:\n print(ans)\nelse:\n print(-1)"}, {"source_code": "n, s, k = map(int, input().split())\ns -= 1\nr = list(map(int, input().split()))\nINF = float(\"inf\")\nc = input()\ndp = [[] for i in range(n)]\n\n\ndef calc(u):\n if dp[u]:\n return\n dp[u] = [0] * (r[u] + 1) + [INF] * (k - r[u])\n for i in range(n):\n if c[u] != c[i] and r[i] > r[u]:\n calc(i)\n d = abs(u - i)\n for j in range(r[u] + 1, k + 1):\n dp[u][j] = min(dp[u][j], dp[i][j - r[u]] + d)\n\n\nans = INF\nfor i in range(n):\n calc(i)\n ans = min(ans, abs(i - s) + dp[i][k])\nif ans == INF:\n print(-1)\nelse:\n print(ans)"}, {"source_code": "n, s, k=map(int, raw_input().split())\ns-=1\nr=map(int, raw_input().split())\ncolor=raw_input()\ndp=[[] for i in range(n)]\ndef dfs(cur):\n\tif dp[cur]:\n\t\treturn\n\tdp[cur]=[0]*(r[cur]+1)+[1000000000]*(k-r[cur])\n\tfor to in range(n):\n\t\tif color[to]!=color[cur] and r[to]>r[cur]:\n\t\t\tdfs(to)\n\t\t\tdis=abs(cur-to)\n\t\t\tfor i in range(r[cur]+1, k+1):\n\t\t\t\tdp[cur][i]=min(dp[cur][i], dp[to][i-r[cur]]+dis)\nresult=1000000000\nfor i in range(n):\n\tdfs(i)\n\tresult=min(result, abs(i-s)+dp[i][k])\nprint result if result!=1000000000 else -1"}, {"source_code": "n, s, k=map(int, raw_input().split())\ns-=1\nr=map(int, raw_input().split())\ncolor=raw_input()\ndp=[[] for i in range(n)]\ndef dfs(cur):\n\tif dp[cur]:\n\t\treturn\n\tdp[cur]=[0]*(r[cur]+1)+[1000000000]*(k-r[cur])\n\tfor to in range(n):\n\t\tif color[to]!=color[cur] and r[to]>r[cur]:\n\t\t\tdfs(to)\n\t\t\tdis=abs(cur-to)\n\t\t\tfor i in range(r[cur]+1, k+1):\n\t\t\t\tdp[cur][i]=min(dp[cur][i], dp[to][i-r[cur]]+dis)\nresult=1000000000\nfor i in range(n):\n\tdfs(i)\n\tresult=min(result, abs(i-s)+dp[i][k])\nprint result if result!=1000000000 else -1"}, {"source_code": "from collections import *\nn, s, k = map(int, raw_input().split())\ns -= 1\na = map(int, raw_input().split())\nC = raw_input()\nDP = [defaultdict(int) for _ in range(n*n)]\nfor i in range(n):\n DP[abs(i-s)][i] = a[i]\nfor t in range(n*n):\n for i, v in DP[t].items():\n if v >= k:\n print(t)\n exit()\n for j in range(n):\n if a[j] > a[i] and C[j] != C[i]:\n DP[t + abs(j-i)][j] = max(DP[t+abs(j-i)][j], v + a[j])\n\nprint(-1)\n\n\n\n"}, {"source_code": "inf = float('inf')\n\nN,S,K = map(int,raw_input().strip('\\n').split(' '))\nA = map(int,raw_input().strip('\\n').split(' '))\ncolor = raw_input().strip('\\n')\n\n\ndp = [[inf]*(N+500) for k in range(K+500)]\nfor i in range(N):\n dp[A[i]][i] = abs(S-i-1);\n\nfor k in range(K+500):\n for pos in range(N):\n if dp[k][pos] == inf:\n continue\n for newpos in range(N):\n if A[newpos]<=A[pos] or color[newpos] == color[pos]:\n continue\n if k+A[newpos]>=K+500:\n continue\n dp[k+A[newpos]][newpos] = min(dp[k+A[newpos]][newpos], dp[k][pos]+abs(newpos-pos))\n\n\nans = inf\nfor k in range(K,K+500):\n for pos in range(N):\n ans = min(ans,dp[k][pos])\nif ans == inf:\n print -1\nelse:\n print ans\n\n\n\n\n\n# dp = (mintime,last_j,last_c)\n# candies = [(ni,ji,ci)]\n# dp[0][0][1] = S\n# dp[i][k+ni][0] = {c!=ci dp[i-1][k][0] + dp[i-1][k][1]-j)\n# dp[i][k+ni][1] = j \n# dp[i][k+ni][2] = c \n\n# candies = [(n,j,c) for j,(n,c) in enumerate(zip(A,color))]\n# candies = sorted(candies,key=lambda x:x[0])\n\n# dp = []\n# for i in range(N+500):\n# temp = []\n# for j in range(K+500):\n# temp.append([inf,0,0])\n# dp.append(temp)\n\n# for i in range(N+1):\n# dp[i][0][0] = 0\n# dp[i][0][1] = S\n\n# for i in range(1,N+1):\n# ni,ji,ci = candies[i-1]\n# for k in range(K+500): \n# if k= 0:\n return dp[nth][left]\n \n ret = 999999999\n for i in range(n):\n if amounts[i] <= amounts[nth] or colors[i] == colors[nth]:\n continue\n ret = min(ret, abs(nth - i) + getAns(i, left - amounts[i]))\n \n dp[nth][left] = ret\n return ret\n\nans = 999999999\nfor i in range(n):\n ans = min(ans, getAns(i, k - amounts[i]) + abs(s - 1 - i))\nif ans == 999999999:\n\tans = -1\nprint(ans)\n \n"}, {"source_code": "INF = 10e9\nn,s,k = map(int, input().split())\nr = list(map(int, input().split()))\nr.append(0)\ncol = input()\nmat = []\nfor i in range(n+1):\n adj = {}\n for j in range(n):\n if i == n:\n adj[j] = abs((s-1)-j)\n else:\n if col[i] != col[j] and r[i] < r[j]:\n adj[j] = abs(i-j)\n mat.append(adj)\n# print(*mat, sep='\\n')\n\nmem = [{} for i in range(n+1)]\n# print(mem)\n\ndef get(s, k):\n # print(s,k)\n # print(mem)\n if mem[s].get(k):\n return mem[s].get(k)\n if r[s] >= k:\n mem[s][k] = 0\n else:\n mi = None\n for nei in mat[s]:\n ncost = get(nei, k-r[s])\n if ncost is None:\n continue\n curr = ncost + mat[s][nei]\n if mi is None or curr < mi:\n mi = curr\n if mi is not None:\n mem[s][k] = mi\n else:\n mem[s][k] = INF\n return mem[s].get(k)\n\n# print(mem)\n\nans = get(n,k)\nif ans is None or ans >= INF:\n print(-1)\nelse:\n print(ans)\n"}, {"source_code": "'''input\n2 1 15\n5 6\nRG\n'''\nimport math\ndef solve():\n\tn,s,k = map(int,input().split())\n\ts-=1\n\tr = list(map(int,input().split()))\n\tc = input()\n\tinf = int(1e9)\n\tdp = [[inf for j in range(n)] for i in range(k+1)]\n\t# dp[i][j] = minimum number of steps to get amount i if we start with jth index\n\tfor i in range(0,k+1):\n\t\tfor j in range(0,n):\n\t\t\tif i==0 or i<=r[j]:\n\t\t\t\tdp[i][j] = 0\n\t\t\t\tcontinue\n\t\t\tfor K in range(0,n):\n\t\t\t\tif c[K]!=c[j] and r[K]>r[j]:\n\t\t\t\t\tdp[i][j] = min(dp[i][j],dp[i-r[j]][K]+int(abs(K-j)))\n\tans = min(dp[k][i]+abs(i-s) for i in range(0,n))\n\tif ans>=inf:\n\t\tprint(-1)\n\t\treturn\n\tprint(ans)\n\treturn\nt = 1\n#t = int(input())\nwhile t>0:\n\tt-=1\n\tsolve()"}, {"source_code": "INF = 1e10\nmax_n = 50\nmax_k = 2000\ndef main():\n n, s, k = map(int, input().split())\n s -= 1\n buf = ['']*(max_n + 1)\n dp = [[0 for i in range(max_n + 1)] for j in range(max_k + 1)] \n r = list(map(int, input().split()))\n c = input()\n answer = INF\n for i in range(len(c)):\n buf[i] = c[i]\n for i in range(k, -1, -1):\n for j in range(n):\n dp[i][j] = INF\n for j in range(n):\n value = abs(j - s)\n if k - r[j] <= 0:\n answer = min(answer, value)\n else:\n dp[k - r[j]][j] = value\n for i in range(k, 0, -1):\n for j in range(n):\n if dp[i][j] < INF:\n for l in range(n):\n if buf[j] != buf[l] and r[j] < r[l]:\n value = dp[i][j] + abs(j - l)\n if i - r[l] <= 0:\n answer = min(answer, value)\n else:\n dp[i - r[l]][l] = min(dp[i - r[l]][l], value)\n if answer == INF:\n print(-1)\n return\n print(answer)\n\nif __name__==\"__main__\":\n main()"}, {"source_code": "n,s,k=map(int,input().split())\nr=list(map(int,input().split()))\ns-=1\nc=input()\nbest=[[0 for i in range(n)] for j in range(k+1)]\nfor i in range(1,k+1):\n for j in range(n):\n if i<=r[j]:\n best[i][j]=abs(j-s)\n else:\n good=float(\"inf\")\n for l in range(n):\n if c[j]!=c[l] and r[j]>r[l]:\n good=min(good,best[i-r[j]][l]+abs(j-l))\n best[i][j]=good\nif min(best[-1])==float('inf'):\n print(-1)\nelse:\n print(min(best[-1]))"}], "negative_code": [{"source_code": "inf = 10000\nn, s, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(input())\nfor i in range(n):\n if b[i] == 'R':\n b[i] = 0\n elif b[i] == 'G':\n b[i] = 1\n else:\n b[i] = 2\nboxes = [[a[i], b[i], i] for i in range(n)]\nboxes.sort()\nl = boxes[-1][0] * n + 1\ns -= 1\ndp = [[[inf, s] for j in range(l)] for i in range(3)]\nif l < k:\n print(-1)\n exit(0)\ndp[0][0][0] = 0\ndp[1][0][0] = 0\ndp[2][0][0] = 0\nfor i in range(n):\n d = dp.copy()\n pos = boxes[i][2]\n clr = boxes[i][1]\n cnt = boxes[i][0]\n for j in range(l - cnt):\n for c in range(3):\n if c == clr:\n continue\n if d[clr][j + cnt][0] > d[c][j][0] + abs(d[c][j][1] - pos):\n d[clr][j + cnt][0] = d[c][j][0] + abs(d[c][j][1] - pos)\n d[clr][j + cnt][1] = pos\n dp = d.copy()\nans = min(dp[0][k][0], min(dp[1][k][0], dp[2][k][0]))\nfor i in range(k, l):\n ans = min(min(ans, dp[0][i][0]), min(dp[1][i][0], dp[2][i][0]))\nif ans < inf:\n print(ans)\nelse:\n print(-1)"}, {"source_code": "inf = 10000\nn, s, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(input())\nfor i in range(n):\n if b[i] == 'R':\n b[i] = 0\n elif b[i] == 'G':\n b[i] = 1\n else:\n b[i] = 2\nboxes = [[a[i], b[i], i] for i in range(n)]\nboxes.sort()\nl = boxes[-1][0] * n + 1\ns -= 1\ndp = [[[inf, s] for j in range(l)] for i in range(3)]\nif l < k:\n print(-1)\n exit(0)\ndp[0][0][0] = 0\ndp[1][0][0] = 0\ndp[2][0][0] = 0\nfor i in range(n):\n pos = boxes[i][2]\n clr = boxes[i][1]\n cnt = boxes[i][0]\n for j in range(l - cnt):\n for c in range(3):\n if c == clr:\n continue\n if dp[clr][j + cnt][0] > dp[c][j][0] + abs(dp[c][j][1] - pos) and dp[c][j][1] != pos:\n dp[clr][j + cnt][0] = dp[c][j][0] + abs(dp[c][j][1] - pos)\n dp[clr][j + cnt][1] = pos\nans = min(dp[0][k][0], min(dp[1][k][0], dp[2][k][0]))\nfor i in range(k, l):\n ans = min(min(ans, dp[0][i][0]), min(dp[1][i][0], dp[2][i][0]))\nif ans < inf:\n print(ans)\nelse:\n print(-1)"}, {"source_code": "inf = float('inf')\n\nN,S,K = map(int,raw_input().strip('\\n').split(' '))\nA = map(int,raw_input().strip('\\n').split(' '))\ncolor = raw_input().strip('\\n')\n\n\ndp = [[inf]*(N+5) for k in range(K+5)]\nfor i in range(N):\n dp[A[i]][i] = abs(S-i-1);\n\nfor k in range(K+5):\n for pos in range(N):\n if dp[k][pos] == inf:\n continue\n for newpos in range(N):\n if A[newpos]<=A[pos] or color[newpos] == color[pos]:\n continue\n if k+A[newpos]>K+5:\n continue\n dp[k+A[newpos]][newpos] = min(dp[k+A[newpos]][newpos], dp[k][pos]+abs(newpos-pos))\n\n\nans = int(1e18)\nfor k in range(K,K+5):\n for pos in range(N):\n ans = min(ans,dp[k][pos])\nif ans == inf:\n print -1\nelse:\n print ans\n\n\n\n\n\n# dp = (mintime,last_j,last_c)\n# candies = [(ni,ji,ci)]\n# dp[0][0][1] = S\n# dp[i][k+ni][0] = {c!=ci dp[i-1][k][0] + dp[i-1][k][1]-j)\n# dp[i][k+ni][1] = j \n# dp[i][k+ni][2] = c \n\n# candies = [(n,j,c) for j,(n,c) in enumerate(zip(A,color))]\n# candies = sorted(candies,key=lambda x:x[0])\n\n# dp = []\n# for i in range(N+5):\n# temp = []\n# for j in range(K+5):\n# temp.append([inf,0,0])\n# dp.append(temp)\n\n# for i in range(N+1):\n# dp[i][0][0] = 0\n# dp[i][0][1] = S\n\n# for i in range(1,N+1):\n# ni,ji,ci = candies[i-1]\n# for k in range(K+5): \n# if k=K+5:\n continue\n dp[k+A[newpos]][newpos] = min(dp[k+A[newpos]][newpos], dp[k][pos]+abs(newpos-pos))\n\n\nans = inf\nfor k in range(K,K+5):\n for pos in range(N):\n ans = min(ans,dp[k][pos])\nif ans == inf:\n print -1\nelse:\n print ans\n\n\n\n\n\n# dp = (mintime,last_j,last_c)\n# candies = [(ni,ji,ci)]\n# dp[0][0][1] = S\n# dp[i][k+ni][0] = {c!=ci dp[i-1][k][0] + dp[i-1][k][1]-j)\n# dp[i][k+ni][1] = j \n# dp[i][k+ni][2] = c \n\n# candies = [(n,j,c) for j,(n,c) in enumerate(zip(A,color))]\n# candies = sorted(candies,key=lambda x:x[0])\n\n# dp = []\n# for i in range(N+5):\n# temp = []\n# for j in range(K+5):\n# temp.append([inf,0,0])\n# dp.append(temp)\n\n# for i in range(N+1):\n# dp[i][0][0] = 0\n# dp[i][0][1] = S\n\n# for i in range(1,N+1):\n# ni,ji,ci = candies[i-1]\n# for k in range(K+5): \n# if kK+5:\n continue\n dp[k+A[newpos]][newpos] = min(dp[k+A[newpos]][newpos], dp[k][pos]+abs(newpos-pos))\n\n\nans = int(1e18)\nfor k in range(K,K+5):\n for pos in range(N):\n ans = min(ans,dp[k][pos])\nprint ans\n\n\n\n\n\n# dp = (mintime,last_j,last_c)\n# candies = [(ni,ji,ci)]\n# dp[0][0][1] = S\n# dp[i][k+ni][0] = {c!=ci dp[i-1][k][0] + dp[i-1][k][1]-j)\n# dp[i][k+ni][1] = j \n# dp[i][k+ni][2] = c \n\n# candies = [(n,j,c) for j,(n,c) in enumerate(zip(A,color))]\n# candies = sorted(candies,key=lambda x:x[0])\n\n# dp = []\n# for i in range(N+5):\n# temp = []\n# for j in range(K+5):\n# temp.append([inf,0,0])\n# dp.append(temp)\n\n# for i in range(N+1):\n# dp[i][0][0] = 0\n# dp[i][0][1] = S\n\n# for i in range(1,N+1):\n# ni,ji,ci = candies[i-1]\n# for k in range(K+5): \n# if k= 0:\n return dp[nth][left]\n \n ret = 999999999\n for i in range(n):\n if amounts[i] <= amounts[nth] or colors[i] == colors[nth]:\n continue\n ret = min(ret, abs(nth - i) + getAns(i, left - amounts[i]))\n \n dp[nth][left] = ret\n return ret\n\nans = 999999999\nfor i in range(n):\n ans = min(ans, getAns(i, k - amounts[i]) + abs(s - 1 - i))\nprint(ans)\n \n"}, {"source_code": "'''input\n5 3 10\n1 2 3 4 5\nRGBRR\n'''\nimport math\ndef solve():\n\tn,s,k = map(int,input().split())\n\ts-=1\n\tr = list(map(int,input().split()))\n\tc = input()\n\tinf = int(1e18)\n\tdp = [[inf for i in range(n+1)] for j in range(k+1)]\n\tspos = [[inf for i in range(n+1)] for j in range(k+1)]\n\t# dp[i][j] = minimum number of steps to get amount i if we start with jth index\n\tfor i in range(0,k+1):\n\t\tfor j in range(0,n):\n\t\t\tif i==0 or i<=r[j]:\n\t\t\t\tdp[i][j] = 0\n\t\t\t\tcontinue\n\t\t\tfor K in range(0,n):\n\t\t\t\tif c[K]!=c[j] and c[K]>c[j]:\n\t\t\t\t\tdp[i][j] = min(dp[i][j],dp[i-r[j]][K]+int(abs(K-j)))\n\tans = min(dp[k][i]+abs(i-s) for i in range(0,n))\n\tif ans==inf:\n\t\tprint(-1)\n\t\treturn\n\tprint(ans)\n\treturn\nt = 1\n#t = int(input())\nwhile t>0:\n\tt-=1\n\tsolve()"}], "src_uid": "a95e54a7e38cc0d61b39e4a01a6f8d3f"} {"nl": {"description": "Vanya got n cubes. He decided to build a pyramid from them. Vanya wants to build the pyramid as follows: the top level of the pyramid must consist of 1 cube, the second level must consist of 1\u2009+\u20092\u2009=\u20093 cubes, the third level must have 1\u2009+\u20092\u2009+\u20093\u2009=\u20096 cubes, and so on. Thus, the i-th level of the pyramid must have 1\u2009+\u20092\u2009+\u2009...\u2009+\u2009(i\u2009-\u20091)\u2009+\u2009i cubes.Vanya wants to know what is the maximum height of the pyramid that he can make using the given cubes.", "input_spec": "The first line contains integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009104) \u2014 the number of cubes given to Vanya.", "output_spec": "Print the maximum possible height of the pyramid in the single line.", "sample_inputs": ["1", "25"], "sample_outputs": ["1", "4"], "notes": "NoteIllustration to the second sample: "}, "positive_code": [{"source_code": "a = [(x*(x+1)/2+x*(x+1)*(2*x+1)/6)/2 for x in range(0,100000)]\nwant = input()\nf=0\nl=99999\nm=0\n#print a[:10]\nwhile f0 else 0"}, {"source_code": "n=int(input())\ns=0\nv=0\ni=1\nwhile(v<=n):\n s=s+i\n v=v+s\n i=i+1\nprint(i-2) \n \n "}, {"source_code": "import math\n\n__author__ = \"runekri3\"\n\ncubes = int(input())\nheight = 1\ncur_cubes = 1\nwhile cubes >= cur_cubes:\n height += 1\n cur_cubes += height * (height + 1) // 2\nheight -= 1\nprint(height)\n"}, {"source_code": "def main():\n n = 1\n i = 2\n x = int(input())\n while n < x + 1:\n n += ((i * (i + 1)) // 2)\n i += 1\n print(i - 2)\n \n\nmain()\n"}, {"source_code": "n=int(raw_input())\nw=t=r=0\nwhile w= total:\n i += 1\n req += i\n total += req\n\n\nprint i-1"}, {"source_code": "cubes = int(input())\n\nd=cnt=h=0\n\nwhile cubes>0:\n\td+=1\n\tcnt+=d\n\tif cnt<=cubes:\n\t\tcubes-=cnt\n\t\th+=1\n\telse:\n\t\tbreak\nprint(h)"}, {"source_code": "num_cubes = int(input()) # the number of cubes given to Vasya\n\ntotal = 0\ntemp = 0\ncount = 0\n\nfor i in range(0,10000):\n\ttotal += i\n\ttemp += total\n\t\n\tif (temp > num_cubes):\n\t\tbreak\n\t\t\n\tcount = i\n\t\nprint(count)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n#\u1555\u250c\u25d5\u15dc\u25d5\u2510\u1557 HELLO HELLO HELLO \u1555\u250c\u25d5\u15dc\u25d5\u2510\u1557\n\n#a = tuple(int(i) for i in raw_input().strip().split(\" \"))\nn = int(raw_input())\nt = tuple((i*(i+1)*(i+2))/6 for i in range(1,40))\nx = 0\nwhile n >= t[x]:\n x += 1\nif n == t[x]:\n print x+1\n print \"HELLO\"\nelse:\n print x\n"}, {"source_code": "n = int(input())\nrow, cubes_in_row = 0, 0\n\ncubes = 0\nwhile cubes <= n:\n row += 1\n cubes_in_row += row\n cubes += cubes_in_row\n\nprint(row -1 )\n\n# while n >= cubes_in_row + row + 1:\n# row += 1\n# cubes_in_row += row\n# n -= cubes_in_row\n# print(row)\n"}, {"source_code": "#!/usr/bin/python3\n\nn = int(input())\ni = 0\nj = 0\n\nwhile i <= n:\n j += 1\n i += (j*(j+1))/2\nprint(j - 1)\n"}, {"source_code": "n=input()\nf=1\nt=1\nwhile ((t*(t+1)*(t+2))/6)<=n :\n t+=1\nprint t-1\n"}, {"source_code": "bla=int(raw_input())\nnum=1\ng=0\nwhile g<=bla:\n g+=(num)*(num+1)/2\n num+=1\nif bla!=1:\n print num-2\nelse:\n print 1\n "}, {"source_code": "n = int(input())\nvar = 0\nfor i in range(1,100000):\n var += ((i*(i+1))//2)\n if var > n:\n print(i-1)\n exit()"}, {"source_code": "x=int(raw_input())\nans=0\nt=1\nwhile(x > 0):\n ans+=t\n t+=1\n x-=t+ans\nprint t-1"}, {"source_code": "n = int(input())\ni=1\nsum=0\nx = n-sum\ncnt=0\nwhile(x>0):\n sum+=i\n cnt+=1\n i += 1\n n-=sum\n x=n-sum\n\nif(n<0):\n print(cnt-1)\nelse:\n print(cnt)"}, {"source_code": "n=int(input())\nc,k,s=0,0,0\nfor i in range(1,n+2):\n if k>n:\n break\n else:\n s=s+i\n k=s+k\n c+=1\nprint(c-1)"}, {"source_code": "n = int(input())\n\na = 0\nip = 0\nipc = 0\n\nwhile n > ipc:\n a += 1\n ip += a\n ipc += ip\n\nif n < ipc:\n print(a - 1)\nelse:\n print(a)\n\n\n\n"}, {"source_code": "cubes = int(input())\nheight = 0\nwhile True:\n if cubes >= ((height + 1)*height/2):\n cubes = cubes - ((height + 1)*height/2)\n height = height + 1\n else:\n break\nprint(height-1)"}, {"source_code": "n = int(input())\nk = 1\ns = 0\nwhile 1:\n if s + k*(k+1)//2 > n:\n print(k-1)\n break\n elif s + k*(k+1)//2 == n:\n print(k)\n break\n else:\n s += k*(k+1)//2\n k+=1\n"}, {"source_code": "n=int(input())\nlvl=0\nx=0\ni=1\nwhile n>=x+i:\n x+=i\n i += 1\n lvl+=1\n n-=x\nprint(lvl)"}, {"source_code": "n=int(input())\nflag=1\ni=1\nt=0\nwhile flag==1:\n if n-((i*(i+1))/2) < 0:\n flag=0\n else:\n n=n-((i*(i+1))/2)\n t+=1\n i+=1\nprint(t)"}, {"source_code": "n = int(input())\nlvl = 0\nrow = 1\nplus = 2\nwhile n >= 0:\n n -= row\n lvl += 1\n row += plus\n plus += 1\nprint(lvl-1)"}, {"source_code": "def main():\n n = int(raw_input())\n x = lambda y: y*(y+1)*(y+2)/6\n count = 1\n while 1:\n if x(count) > n:\n return count - 1\n count += 1\n\nif __name__ == \"__main__\":\n print main()\n \n"}, {"source_code": "n = input()\nans = 0\ni = 1\nwhile (ans < n) :\n\tans += (i * (i + 1))/2\n\ti += 1\nif (ans == n) :\n\tprint i - 1\nelse :\n\tprint i - 2\n"}, {"source_code": "#!/usr/bin/env python\ndef height():\n n = int(input())\n h = 1\n i = 1\n if i < 1:\n return 0\n elif n == 1:\n return 1\n while i <= n:\n h += 1\n i += (h*(h+1))/2\n return h-1\n\nprint(height())\n"}, {"source_code": "N=float(input())\nv6N1o3=(6*N)**(0.3333333333333333)\nL = v6N1o3 + 0.3333333333333333/v6N1o3 - 1.\nprint(int(L+1e-6))\n"}, {"source_code": "n=i=input()*6\nwhile i**3-i>n:i-=1\nprint i-1\n"}, {"source_code": "def solve(n):\n\n height = boxesUsed = prevStepBoxes = 0\n\n while n > boxesUsed:\n\n height += 1\n thisStepBoxes = prevStepBoxes + height\n boxesUsed += thisStepBoxes\n prevStepBoxes = thisStepBoxes\n\n #if this layer is not possible, we over-estimated the height. Reduce it by 1\n if n < boxesUsed:\n height -= 1\n\n return height\n\n\nif __name__ == \"__main__\":\n n = int(raw_input())\n print solve(n)"}, {"source_code": "n=int(input())\nm=0#\u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0431\u0438\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435\ni=0#\u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u0432\u043d\u044f\nwhile n>=m:\n m=m+i+1\n if n>=m:\n n=n-m\n i+=1\nprint(i)\n"}, {"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())\ni=1\nnum=0\nif(n==1):\n print(1)\n exit(0)\nwhile(numn):\n\n # print(\"chala\")\n break\n # if(num>n):\n # i-=1\n # break\n i+=1\nprint(i)"}, {"source_code": "#!/usr/bin/env python2\n\ndef compare(element_a, element_b):\n if element_a == element_b:\n return 0\n elif element_a > element_b:\n return 1\n else:\n return -1\n\n\nBEGIN_N = 1\nEND_N = 10001\n\nn = input()\ncubes_cnt_sum = cubes_cnt_current_level = 0\nfor level in range(BEGIN_N, END_N):\n cubes_cnt_current_level += level\n cubes_cnt_sum += cubes_cnt_current_level\n result = compare(cubes_cnt_sum, n)\n if 0 == result:\n print level\n break\n elif 1 == result:\n print level - 1\n break"}, {"source_code": "n = input()\n\ni = 0\ns = 0\n\nwhile s <= n:\n\ti += 1\n\ts += (i * ( i + 1)) / 2\n\nprint i - 1"}, {"source_code": "n=int(input())\nm=0#\u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0431\u0438\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435\ni=0#\u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u0432\u043d\u044f\nwhile n>=m:\n m=m+i+1\n if n>=m:\n n=n-m\n i+=1\nprint(i)\n"}, {"source_code": "n=i=input()*6\nwhile i**3-i>n:i-=1\nprint i-1\n"}, {"source_code": "no_of_cubes = int(input())\ndata = [0]\nlayer =0\nsum = 0\nwhile(data[layer] <= no_of_cubes):\n layer+=1\n if layer==1:\n sum += data[layer - 1] + layer\n if sum > no_of_cubes:\n break\n else :\n data.append(layer)\n elif layer==2:\n sum += data[layer - 1] + layer\n if sum > no_of_cubes:\n break\n else :\n data.append(data[layer-1]+layer)\n\n\n elif layer > 2 :\n if data[layer-1]+layer < no_of_cubes:\n sum += data[layer - 1] + layer\n if sum > no_of_cubes:\n break\n else:\n data.append(data[layer-1]+layer)\n\n else:\n break\n\nprint(len(data)-1)\n\n\n\n\n"}, {"source_code": "n=int(input())\nm=0#\u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0431\u0438\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435\ni=0#\u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u0432\u043d\u044f\nwhile n>=m:\n m=m+i+1\n if n>=m:\n n=n-m\n i+=1\nprint(i)"}, {"source_code": "n,k,i = int(input()),1,1\nwhile(n>=k):n-=k;i+=1;k+=i\nprint(i-1) "}, {"source_code": "num_cubes = int(input()) # the number of cubes given to Vasya\n\ntotal = 0\ntemp = 0\ncount = 0\n\nfor i in range(0,10000):\n\ttotal += i\n\ttemp += total\n\t\n\tif (temp > num_cubes):\n\t\tbreak\n\t\t\n\tcount = i\n\t\nprint(count)\n"}, {"source_code": "N=float(input())\nv3N=3.*N\nsq=(v3N**2-1./27.)**0.5\nv1o3=1./3.\nL = (v3N+sq)**v1o3 + (v3N-sq)**v1o3 - 1\nprint(int(L+1e-6))\n"}, {"source_code": "def trial():\n num = int(input())\n levels = []\n for i in range(1, num + 1):\n counter = 0\n for j in range(i+1):\n counter += j\n if counter >= num:\n levels.append(counter)\n break\n elif counter < num and counter not in levels:\n levels.append(counter)\n if levels[-1] > num:\n break\n levels.pop(0)\n if len(levels) == 1:\n return print(1)\n res = 0\n counter = 0\n for i in levels:\n if res < num:\n counter += 1\n res += i\n if res > num:\n counter -= 1\n return print(counter)\n else:\n return print(counter)\n return print(counter)\ntrial()\n"}, {"source_code": "n = int(input())\ng = 0\ni = 0\nans = 0\nwhile n - g - i > 0:\n i +=1\n g +=i\n n -=g\n ans +=1\nprint(ans)"}, {"source_code": "cubics=int(raw_input())\nheight=0\nraws=[]\ni=0\ntotal=0\n\nwhile True:\n i+=1\n raws.append(i)\n total+=sum(raws)\n if total<=cubics:\n height+=1\n else:\n break\nprint height"}, {"source_code": "n=int(input())\nif n==1:\n print(\"1\")\nelse:\n sum_=0 \n count=0 \n add_=-1\n for i in range(1000):\n sum_=sum_+i \n count=count+sum_\n if count<=n:\n add_=add_+1 \n else:\n break\n print(add_)"}, {"source_code": "a=int(raw_input())\nc=0\ni=0\nl=0\nwhile c<=a:\n\ti+=1\n\tl+=i\n\tc=c+l\nprint i-1"}, {"source_code": "n = int(input())\ntotalCubes = 0\nnextLevel = 0\ni = 0\nwhile totalCubes <= n:\n i += 1\n nextLevel += i\n totalCubes += nextLevel\n\n\nprint(i - 1)"}, {"source_code": "n = input()\n\nblocks = 0\nstart = 0\nstartIncrement = 1\ncount = 0\n\nwhile blocks <= n:\n start += startIncrement\n startIncrement += 1\n blocks += start\n count += 1\n\nprint count - 1"}, {"source_code": "n = int(input())\nk = 0\nm = 0\nz = 0\nfor i in range(10000):\n k += i\n m += k\n z += 1\n if m > n:\n break\nprint(z-2)"}, {"source_code": "n=int(input())\ni=0\ns=0\nwhile(True):\n k1=i*(i+1)//2\n s+=k1\n if(s>=n):\n if(s>n):\n i=i-1\n break\n i+=1\nprint(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 \n \n \n \n \n \n \n \n \n \n \n \n \n "}, {"source_code": "i=int(input())\nt=0\nsumi=0\nl=0\nwhile(i>=0):\n l=l+1\n t=t+l\n i=i-t\nprint(l-1)"}, {"source_code": "'''\nhttps://codeforces.com/problemset/problem/492/A\n\nSolution:\n\nSay n = 25.\n\nPer layer Boxes | Total Boxes Used\n1 | 1\n1+2 = 3 | 4\n1+2+3 = 6 | 10\n1+2+3+4 = 10 | 20\n1+2+3+4+5 = 15 | 35\n\nHence at each layer, we add the height (incremented by 1 in each layer) to the previous-layer boxes and that\ngives the current layer boxes. Keep adding that to a total accumulation (boxesUsed).\n\nSince we cannot build a layer without having enough boxes for the current-layer, we may over-estimate the height.\nHence, we check if n < boxesUsed after the current layer usage, we reduce the height by 1, thereby descarding the\ncurrent layer in the pyramid.\n\nThe final height is the answer.\n\n'''\n\ndef solve(n):\n\n height = boxesUsed = prevStepBoxes = 0\n\n while n > boxesUsed:\n\n height += 1\n thisStepBoxes = prevStepBoxes + height\n boxesUsed += thisStepBoxes\n prevStepBoxes = thisStepBoxes\n\n #if this layer is not possible, we over-estimated the height. Reduce it by 1\n if n < boxesUsed:\n height -= 1\n\n return height\n\n\nif __name__ == \"__main__\":\n n = int(raw_input())\n print solve(n)"}, {"source_code": "n=int(input())\ns=0\nfor i in range(1,10**100):\n s+=i\n if s>n:\n print(i-1)\n break\n n-=s"}, {"source_code": "n=int(raw_input())\nans,chk,cnt=0,0,1\nwhile 1:\n chk+=cnt\n ans+=chk\n if ans==n:\n print cnt\n break\n elif ans>n:\n print cnt-1\n break\n cnt+=1"}, {"source_code": "a=int(input())\ni=0\nb=0\nc=0\nwhile ca:\n i=i-1\n if c==a:\n break\nprint(i)\n"}, {"source_code": "n=int(input())\nn_y=1\nyr=1\nn-=1\nwhile n>n_y:\n yr=yr+1\n n_y=n_y+yr\n n=n-n_y\n if n<0:\n yr-=1\nprint(yr) \n \n"}, {"source_code": "i=int(input())\ncount=0\nk=0\nsum=0\n\nwhile sum+count+k+1<=i:\n k=k+1\n count=count+k\n sum=sum+count\n \n\n\nprint(k)"}, {"source_code": "def main():\n n = 1\n i = 2\n x = int(input())\n while n < x + 1:\n n += ((i * (i + 1)) // 2)\n i += 1\n print(i - 2)\n \n\nmain()\n"}, {"source_code": "def solution(N):\n\tcount=0\n\tfor i in range(1,1000):\n\t\tif N<=0 or N-i*(i+1)/2<0:\n\t\t\treturn count\n\t\telse:\n\t\t\tcount=count+1\n\t\t\tN=N-i*(i+1)/2\n\t\nN=int(raw_input())\nprint(solution(N))\n\n"}, {"source_code": "cubes=int(input())\nif cubes == 1 or cubes == 2 or cubes == 3:\n lvl = 1\nelse:\n lvl=2\nammount=3\ncubes=cubes-4\nwhile cubes>ammount+lvl:\n lvl+=1\n ammount=ammount+lvl\n cubes=cubes-ammount\n \nprint(lvl)"}, {"source_code": "n=i=input()*6\nwhile i**3-i>n:i-=1\nprint i-1"}, {"source_code": "j = int(input())\n\ndef pyramid_height(cubes):\n additional_cubes = 1\n curr_layer_cubes = 0\n height = 0\n\n while True:\n curr_layer_cubes += additional_cubes\n cubes -= curr_layer_cubes\n if cubes < 0:\n return height\n height += 1\n additional_cubes += 1\n \n\n \nprint(pyramid_height(j))"}, {"source_code": "n = int(raw_input())\ni = 0\ns = 0\nwhile s <= n:\n i += 1\n s += (i*(i+1))/2\nprint i - 1"}, {"source_code": "n = int(input())\nans = 0\ncount = 0\nwhile count <= n:\n ans += 1\n count +=((ans*(ans+1)) // 2)\nprint(ans-1)"}, {"source_code": "n=input()\nsumm=0\nc=0\nx=[]\n\nfor i in range(1,1000):\n\tsumm+=i\n\tx.append(summ)\n\tif sum(x)>n:\n\t\tbreak;\n\telse:\n\t\tc+=1\n\n\nprint c\n\n"}, {"source_code": "bla=int(raw_input())\nnum=1\ng=0\nwhile g<=bla:\n g+=(num)*(num+1)/2\n num+=1\nif bla!=1:\n print num-2\nelse:\n print 1\n "}, {"source_code": "def GH(a,i):\n if a<0:return i-2\n else:return GH(a-i*(i+1)/2,i+1)\nprint(GH(int(input()),1))"}, {"source_code": "n=int(input())\n\nm=0#\u043a\u043e\u043b\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0443\u0431\u0438\u043a\u043e\u0432 \u0432 \u043e\u0434\u043d\u043e\u043c \u0443\u0440\u043e\u0432\u043d\u0435\n\ni=0#\u043d\u043e\u043c\u0435\u0440 \u0443\u0440\u043e\u0432\u043d\u044f\n\nwhile n>=m:\n\n m=m+i+1\n\n if n>=m:\n\n n=n-m\n\n i+=1\n\nprint(i)\n"}, {"source_code": "cubes=int(input())\nif cubes == 1 or cubes == 2 or cubes == 3:\n lvl = 1\nelse:\n lvl=2\nammount=3\ncubes=cubes-4\nwhile cubes>ammount+lvl:\n lvl+=1\n ammount=ammount+lvl\n cubes=cubes-ammount\n \nprint(lvl)"}, {"source_code": "#!/usr/bin/env python2\n\ndef compare(int_num_a, int_num_b):\n if int_num_a == int_num_b:\n return 0\n elif int_num_a > int_num_b:\n return 1\n else:\n return -1\n\ndef binary_search(begin, end, target):\n while begin < end:\n mid = (begin + end) >> 1\n result = compare(mid * (mid + 1) * (mid + 2) / 6, target)\n if 0 == result:\n return mid\n elif 1 == result:\n end = mid\n else:\n begin = mid + 1\n return begin - 1\n\nBEGIN_LEVEL = 1\nEND_LEVEL = 40\n\nn = input()\nindex = binary_search(BEGIN_LEVEL, END_LEVEL, n)\nprint index"}, {"source_code": "def function():\n\tn = int(input())\n\n\tfloor = 0\n\twhile n > 0:\n\t\tif n >= (floor+1)*(floor+2)//2:\n\t\t\tn -= (floor+1)*(floor+2)//2\n\t\t\tfloor += 1\n\t\telse:\n\t\t\tprint(floor)\n\t\t\treturn\n\tprint(floor)\n\nfunction()"}, {"source_code": "n=int(raw_input())\ncount=0\nh=1\nwhile count n:\n r = i-1\n break\n\nprint r\n"}, {"source_code": "h,counter=0,0\nn=int(input())\nwhile(counter<=n):\n h+=1\n counter+=((h)*(h+1))//2\nprint(h-1)"}, {"source_code": "#!/usr/bin/env python2\n\ndef compare(int_num_a, int_num_b):\n if int_num_a == int_num_b:\n return 0\n elif int_num_a > int_num_b:\n return 1\n else:\n return -1\n\ndef binary_search(number_list, target):\n begin = 0\n end = len(number_list)\n while begin < end:\n mid = (begin + end) >> 1\n result = compare(number_list[mid], target)\n if 0 == result:\n return mid\n elif 1 == result:\n end = mid\n else:\n begin = mid + 1\n return begin - 1\n\nBEGIN_LEVEL = 1\nEND_LEVEL = 40\nEND_N = 10002\n\ncubes_cnt_current_level = 0\ncubes_cnt_sum = [cubes_cnt_current_level, ]\nfor level in range(BEGIN_LEVEL, END_LEVEL):\n cubes_cnt_current_level += level\n cubes_cnt_sum.append(cubes_cnt_sum[-1] + cubes_cnt_current_level)\n if cubes_cnt_sum[-1] >= END_N:\n break\n\nwhile True:\n try:\n n = input()\n except EOFError:\n break\n\n index = binary_search(cubes_cnt_sum, n)\n print index"}, {"source_code": "import math\nc=int(input())\nn=0\ni=0\n\n\n\n\nwhile n element_b:\n return True\n else:\n return False\n\n\ndef search_one_by_one(number_list, target):\n length = len(number_list)\n for index in range(length):\n if compare(number_list[index], target):\n return index\n else:\n return length\n\n\nBEGIN_N = 1\nEND_N = 10001\n\ncubes_cnt_current_level = 0\ncubes_cnt_sum = [cubes_cnt_current_level, ]\nfor level in range(BEGIN_N, END_N):\n cubes_cnt_current_level += level\n cubes_cnt_sum.append(cubes_cnt_sum[-1] + cubes_cnt_current_level)\n if (cubes_cnt_sum[-1] >= END_N):\n break\n\nn = input()\nindex = search_one_by_one(cubes_cnt_sum, n)\nprint index - 1"}, {"source_code": "import math\nc=int(input())\nn=0\ni=0\n\n\n\n\nwhile n0):\n i=i+1\n c=l+i\n l=c\n a-=c\n if(a<0):\n i=i-1\nprint(i)\n"}, {"source_code": "\n\ndef sm(n):\n return (1+n)*n/2\n\n\ndef main():\n n = int(raw_input())\n r = 1\n while True:\n n -= sm(r)\n if n < 0:\n print r-1\n return\n r += 1\n \nmain()"}, {"source_code": "def main():\n n = int(raw_input())\n x = lambda y: y*(y+1)*(y+2)/6\n count = 1\n while 1:\n if x(count) > n:\n return count - 1\n count += 1\n\nif __name__ == \"__main__\":\n print main()\n \n"}, {"source_code": "import sys\nimport itertools as it\nimport bisect as bi\nimport math as mt\nimport collections as cc\nS=lambda :list(input().split())\nI=lambda:list(map(int,input().split())) \nn,=I()\nf=lambda x:x*(x+1)//2\nar=[f(i) for i in range(100)]\nfor i in range(1,len(ar)):\n\tar[i]+=ar[i-1]\nprint(bi.bisect(ar,n)-1)"}, {"source_code": "def ret_input():\n data = int(raw_input())\n return data\n\ndef vac(data):\n index = 1\n total, row_sum = 0,0\n while total <= data:\n row_sum = (index *(1 + index))/2\n total += row_sum\n index += 1\n return index-2 \n\ndef main():\n data = ret_input()\n #data = 100\n print vac(data)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "\nfrom math import factorial as fct\n\ndef ps(n,m):\n\treturn int(fct(n)/(fct(m)*fct(n-m)))\n\ndef cl(n):\n\treturn ps(n+2,3)\n\ndef cdt(n):\n\tdt=dict()\n\tfor x in range(n):\n\t\tx+=1\n\t\tdt[cl(x)]=x\n\treturn dt\n\ndef dl(dt,n):\n\tv=list(dt.keys())\n\tfor x in range(len(v)):\n\t\tif v[x+1] > n:\n\t\t\treturn v[x]\n\ndt=cdt(39)\nl=dl(dt,int(input()))\nprint(dt[l])\n"}, {"source_code": "l=[1]\nfor i in range(1,10001):\n l.append(l[i-1]+i+1)\nn=int(input())\ns=0\nif n==1:\n print('1')\nelse:\n for i in range(len(l)):\n s+=l[i]\n if n=0:\n\th+=1\n\tcubes-=(h*(h+1))//2\nprint(h-1)"}, {"source_code": "n = input()\n\ncount = 0\nfor i in range(1, 100000):\n count += i * (i + 1) / 2\n\n if count > n:\n print i - 1\n break\n"}, {"source_code": "num_cubes = int(input()) # the number of cubes given to Vasya\n\ntotal = 0\ntemp = 0\ncount = 0\n\nfor i in range(0,10000):\n\ttotal += i\n\ttemp += total\n\t\n\tif (temp > num_cubes):\n\t\tbreak\n\t\t\n\tcount = i\n\t\nprint(count)\n"}, {"source_code": "cubes = int(input())\nif cubes == 1:\n print(1)\nelse:\n total = 0\n r_cube = 0\n h = 0\n for i in range(1, cubes):\n total += i\n r_cube += total\n if r_cube > cubes:\n break\n h += 1\n print(h)"}, {"source_code": "\nn = int(input())\ni = 1\ntotal_cube = 0\nwhile total_cube <= n:\n total_cube += (i*(i+1))//2\n i+=1\nprint(i-2)"}, {"source_code": "n = int(input())\nnum = 0\nnum2 = 0\ncount = 2\nwhile True:\n for i in range(count):\n num += i\n num2 += num\n if num2 > n:\n print(count - 2)\n break\n if num2 == n:\n print(count - 1)\n break\n num = 0\n count += 1\n"}, {"source_code": "j = int(input())\n\n\ndef layers():\n n = 1\n cubes = 0\n while True:\n cubes += n\n yield cubes\n n += 1\n\n\ndef pyramids(total_cubes):\n for layer_num, cubes in enumerate(layers()):\n total_cubes -= cubes\n if total_cubes < 0:\n return layer_num\n \nprint(pyramids(j))\n\n"}, {"source_code": "n = int(input())\nx = n - 1\ncount = 1\ny = 1\ni = 2\nif(n == 1):\n print('1')\nelse:\n while(True):\n if (x < y):\n break;\n y = y + i\n x = x - y\n i = i + 1\n if(x >= 0):\n count = count + 1\n print(count)\n\n\n\n"}, {"source_code": "import math\nn=int(input())\np=int(1)\nt=int(1)\nk=int(1)\nfor i in range(2,10000):\n p+=i\n k+=p\n if k>n:\n print(t)\n exit(0)\n t+=1"}, {"source_code": "j = int(input())\ndef pyramids():\n if j == 1:\n print(1)\n return\n \n k = 0\n l = []\n \n for i in range(1, j + 1):\n k = k + i\n l.append(k)\n if k > j:\n break\n\n desired = 0\n i = 0\n while desired <= j:\n desired += l[i]\n i += 1\n \n print(i - 1)\n \npyramids()"}, {"source_code": "cubics=int(input())\ni=1\nn=0\nwhile (n<=cubics):\n n+=(i*(i+1))//2\n #print(n)\n i+=1\nif(cubics==1):\n print(1)\nelse:\n print(i-2)"}, {"source_code": "n=int(raw_input())\nsum=0\ni=0\nwhile sum<=n:\n i+=1\n sum+=(i*(i+1))/2\nprint i-1"}, {"source_code": "n = int(input())\ncubesleft = n-1\nfloors = 1\n \nif n <= 3:\n print(1)\nelse:\n for i in range(n):\n floors +=1\n sum = (((floors) * (floors+1)) / 2)\n cubesleft -= sum\n if sum > cubesleft+sum:\n floors -=1\n print(floors)\n break"}, {"source_code": "x=int(raw_input())\nans=0\nt=1\nwhile(x > 0):\n ans+=t\n t+=1\n x-=t+ans\nprint t-1"}, {"source_code": "squareNumber = int(input())\ntotalsum = 0\ni = 0\nwhile True:\n if(squareNumber >=1 and squareNumber <= 10**4):\n break\n else:\n print(\"Write the right number\")\n squareNumber = int(input(\"Write the number of the squares\"))\nwhile (squareNumber > totalsum):\n totalsum = 0\n for sqare in range(1,i+2):\n totalsum+=sqare\n squareNumber-=totalsum\n if(squareNumber >= 0):\n i+=1\nprint(i)"}], "negative_code": [{"source_code": "n=int(input())\nn1=0\ncount=0\nwhile n>n1:\n count+=1\n count2=count\n n1 = 0\n while count2!=0:\n n1=n1+count2\n count2=count2-1\n n = n - n1\nprint(count)"}, {"source_code": "cubes = int(input())\nif cubes == 1:\n print(1)\nelse:\n total = 0\n h = 0\n hi = 0\n for i in range(1, cubes):\n total += i\n h += total\n if h >= cubes:\n break\n hi += 1\n print(hi+1)"}, {"source_code": "n = int(input())\ni = 1\nc = 0\nj = 0\nk = 0\nwhile j + c < n:\n c += i\n i += 1\n j += c\n k += 1\nprint(k)\n"}, {"source_code": "n=int(input())\ni=2\nwhile(n>1):\n n=n//i\n i+=1\nprint(i-1) "}, {"source_code": "bla=int(raw_input())\nnum=1\ng=0\nwhile g<=bla:\n g+=(num)*(num+1)/2\n num+=1\nif bla!=1:\n print num-1\nelse:\n print 1\n "}, {"source_code": "n = int(input())\nnum = 0\nnum2 = 0\ncount = 2\nwhile True:\n for i in range(count):\n num += i\n num2 += num\n if num2 > n:\n print(count - 1)\n break\n if num2 == n:\n break\n num += count\n count += 1\n"}, {"source_code": "n=int(input())\ni=0\nc=0\nwhile n>=i:\n c=c+1\n i=i+c\n n=n-i\nprint(c)\n \n \n \n \n"}, {"source_code": "a = int(input())\nsum = 0\nk = 0\nwhile sum < a:\n sum = sum + k\n k += 1\nprint(k-1)"}, {"source_code": "n=int(raw_input())\ni=1\nwhile n>0:\n t=sum(range(1,i+1))\n if t>n:\n break\n n-=t\n print t,n\n i+=1\nprint i-1"}, {"source_code": "from math import cosh,acosh\n\nN=float(input())\nsq3=3**0.5\nL=2./sq3*cosh(acosh(9*sq3*N)/3.)-1\nprint(int(L+0.01))\n"}, {"source_code": "n=int(input())\ni=0\np=0\nwhile n>=p:\n i+=1\n if i%2==0:\n n=n-((i+1)*(i//2))\n p=(i+2)*((i+1)//2)\n else: \n n=n-((i+1)*(i//2)+i//2+1)\n p=(i+2)*((i+1)//2)+(i+1)//2\nprint(i)"}, {"source_code": "i = int(input())\ns = int(0)\nresult = []\nfor x in range(1,i+1):\n if i < x:\n break\n s = s + x\n i = i -s\n result.append(s)\n\nprint(len(result))"}, {"source_code": "n=int(input())\ns,d,r=0,0,0\nfor i in range(1,n+1):\n s=s+i\n d+=s\n if(d>n):\n break\n if(d==n):\n r=r+1\n break\n r=r+1\n print(s,d,r)\nprint(r)"}, {"source_code": "n=int(input())\nk=0\nh=0\nwhile n>0:\n k=1+k+h\n h=h+1\n n=n-k\nprint(h)\n \n\n \n \n \n \n \n \n"}, {"source_code": "n = int(input())\nm=0\nm+=n\nsum = 0\ncount = 0\nif n ==1:print(1)\nelse:\n for i in range(1,m):\n \n sum +=i\n n = n-sum\n count+=1\n if(sum> n):\n break\n \n print(count)"}, {"source_code": "n = int(input())\ncubesused = 0\ncubesleft = n\nfloors = 1\n \nif n <= 3:\n print(1)\nelse:\n for i in range(n):\n if (((floors) * (floors+1)) / 2) <= (cubesleft-(((floors) * (floors+1)) / 2)):\n floors +=1\n cubesleft -= (((floors) * (floors+1)) / 2)\n else:\n print(floors)\n break"}, {"source_code": "n = int(input())\na = 1\ni = 1\nwhile n - a >= 0 and n-(a-1) >= a:\n i = i+1 \n a = a+i\nprint(i-1)\n \n \n"}, {"source_code": "n = int(input())\ni = 0\na = 1\nwhile (n>a):\n i += 1\n a += i\n n -= a\nprint(i)\n"}, {"source_code": "n=int(input())\ni=2\nwhile(n>1):\n n=n//i\n i+=1\nprint(i-1) "}, {"source_code": "n=input()\nemp=0\ni=1\nwhile(True):\n emp=emp*2+i\n if emp+i>=n:\n break\n else:\n i+=1\nprint i"}, {"source_code": "n=int(input())\nh=0\ni=1\nx=0\nwhile(n>x+1):\n x=(i*(i+1))//2\n n=n-x\n i=i+1\n h=h+1\nprint(h)\n \n \n"}, {"source_code": "n=int(input())\nlvl=0\np=0\nc=1\ns=0\nwhile s n:\n break\n \n s += k\n\nprint i - 1\n\n"}, {"source_code": "N = int(input())\ni, ans = 1, 0\nwhile True:\n\tsum = (i*(i+1))/2\n\tif sum <= N: ans += 1\n\tif sum >= N: break\n\ti += 1\nprint ans"}, {"source_code": "i = 1\ncount,sum=1,1\nn = input()\nwhile(i 0:\n while n > 0:\n x1 = x1 + x2\n sun = x1 + x2\n x1 += 1\n x2 += 1\n floor += 1\n n -= sun\n print(floor)\nelif n - sun != 0:\n print(floor - 1)\nelse:\n print(0)\n"}, {"source_code": "n = int(input())\ni = 0\nb=0\nwhile n > i:\n i+=(1 + b)\n n-=i\n b+=1\nprint(b)\n"}, {"source_code": "l=[1]\nfor i in range(1,10001):\n l.append(l[i-1]+i+1)\nn=int(input())\nfor i in range(len(l)):\n if n ip:\n ip = ip + (ip + a)\n a += 1\n\n if ip > n:\n a -= 1\n\n print(a)\n\n"}, {"source_code": "n = int(input())\nans = 0\ng = 0\nfor i in range(1,n):\n if i + g < n - i - g:\n n -=(i + g)\n g +=i\n ans +=1\n else:\n break\nprint(ans+1)"}, {"source_code": "x = input()\nl = 0\nm = 0\ns = 0\nwhile s <= x:\n l += 1\n m += l\n if s + m <= x:\n s += m\n else:\n print l\n exit()"}, {"source_code": "try:\n x=int(input())\n q=0\n t=0\n while True:\n x=x-((q+2)*(q+1)//2)\n if x>0:\n q=q+1\n else:\n break\n print(q)\nexcept:\n pass\n \n \n"}, {"source_code": "i=int(input())\nt=0\nsumi=0\nl=0\nwhile(i>=0):\n print(i,l,t)\n l=l+1\n t=t+l\n i=i-t\nprint(l-1)"}, {"source_code": "n = int(input())\nfloor = 0\nx1 = 1\nx2 = 0\nsun = 0\nif n > 0:\n while n > 0 and n >= sun:\n x1 = x1 + x2\n sun = x1 + x2\n x1 += 1\n x2 += 1\n floor += 1\n n -= sun\n print(floor)\nelif n - sun != 0:\n print(floor - 1)\nelse:\n print(0)\n"}, {"source_code": "n=int(input())\ni=1\nheight=1\ncount=1\nwhile i=n):\n break\n i+=1\nprint(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 \n \n \n \n \n \n \n \n \n \n \n \n \n "}, {"source_code": "def main():\n n = 2\n i = 2\n prev = 1\n x = int(input())\n while n < x:\n n = n + prev + i\n i += 1\n prev = n\n print(i - 1)\n \n\nmain()\n"}, {"source_code": "def count():\n n = int(raw_input())\n num = 1\n result = 0\n height = 0\n total = []\n while sum(total) < n:\n result += num\n num += 1\n total.append(result)\n height += 1\n\n print height - 1\n\n\ncount()\n\n"}, {"source_code": "def driver(f):\n n = 0\n counter = 0\n total = 0\n for i in range(1, f):\n if total+n < f:\n n += i\n total += n\n counter += 1\n else:\n break\n if f == 1:\n print(1)\n else:\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(raw_input())\n#print list(range(0, n))\nsum1=0\nsum2 = 0\nif n==1:\n print 1\nelif n==2:\n print 1\nelse:\n for i in range(n):\n sum1 = i+sum1\n sum2 = sum2 + sum1\n #print sum1\n if n - sum2 <=0:\n print i-1\n break\n"}, {"source_code": "print lambda n: max (x for x in xrange(100) if (x * (x + 1) * (x + 2) / 6 <= n))(input())"}, {"source_code": "def sum_def(n):\n out = 0\n for i in range(1, n + 1):\n for i in range(1, i + 1):\n out += i\n return out\n\nn = int(input())\nsum_tmp = 0\nc = 0\n\nwhile (sum_tmp < n):\n print(sum_def(c + 2))\n sum_tmp = sum_def(c + 2)\n c += 1\n\nprint(c)\n"}, {"source_code": "a=int(input())\nsum=0\na1=1\nk=1\ncnt=0\nwhile a>=0 : \n sum=sum+a1\n k=k+1\n a1=a1+k\n cnt=cnt+1\n a=a-a1\nprint(cnt)"}, {"source_code": "n=int(input())\ni=1\nj=1\nif n>3:\n n=n-1\n i=3\n while n>-1:\n n-=i*(i+1)//2\n i+=1\n #print(n,i)\n j+=1\nprint(j)"}, {"source_code": "n = int(raw_input())\nt = 1\nfor k in xrange(2, n):\n\tg = ((k * (k + 1)) >> 1)\n\tif t + g <= n:\n\t\tt += g\n\telse: break\nprint t"}, {"source_code": "n = int(input())\nans = 1\ng = 0\nif n >=4:\n for i in range(1,n):\n if i + g < n - i - g:\n n -=(i + g)\n g +=i\n ans +=1\n else:\n break\nif n <=19 and n >=4:\n print(ans - 1)\nelse:\n print(ans)\n "}, {"source_code": "# n = int(input())\nn = 26\na = 1\nb = 0\ns = 1\nwhile a < n:\n b += a + 1\n a += b\n s += 1\nprint(s)\n"}, {"source_code": "#!/usr/bin/env python\n\nn = int(input())\ncount = 1\ni = 1\n\nwhile count < n:\n i += 1\n count += (i + 1) * (i + 2) / 2\n\nprint(i)\n"}, {"source_code": "n = int(input())\nh = 0\ns = 0\nsm = 0\nwhile(sm <= n):\n\th += 1\n\ts += h\n\tsm += s\n\tif(sm + s >= n):\n\t\tbreak\nprint(h)"}, {"source_code": "l=[1]\nfor i in range(1,20):\n l.append(l[i-1]+i+1)\nn=int(input())\ns=0\nif n==1:\n print('1')\nelse:\n for i in range(len(l)):\n s+=l[i]\n if n1:\n\td=1\n\tl=[]\n\tfor i in range(1,n+1):\n\t\tif n>=sum(l):\n\t\t\t\n\t\t\t# print(d)\n\t\t\t# print(d,a,c)\n\t\t\tc+=1\n\t\t\td+=a\n\t\t\ta+=1\n\t\t\tl.append(d)\n\tprint(c)\nelif n==1:\n\tprint(1)\nelse:\n\tprint(0)"}, {"source_code": "import sys\ndef main():\n n = int(input()) + 1\n a = [0] * n\n _sum = 0\n for i in range(1, n):\n a[i] = a[i - 1] + i\n _sum += a[i]\n if(_sum > n):\n print(i - 1)\n return\n if(_sum == n - 1):\n print(i)\n return\n\n\nif __name__ == \"__main__\":\n sys.exit(main())"}, {"source_code": "n=int(input())\nh=0\ni=1\nx=0\nwhile(n>0):\n x=(i*(i+1))//2\n if(n>x):\n h=h+1\n n=n-x\n i=i+1\n \nprint(h)\n \n \n"}, {"source_code": "n=int(input())\ns,d,r=0,0,0\nfor i in range(1,n+1):\n s=s+i\n d+=s\n if(d>n):\n break\n if(d==n):\n r=r+1\n break\n r=r+1\n print(s,d,r)\nprint(r)"}, {"source_code": "n=int(raw_input())\ncount =0\nlevel=1\nwhile (level<=n):\n count +=1\n n= n - level\n level=(count+1)/2.0*(1+count)\n\n\nprint count\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Mar 16 12:54:40 2020\n\n@author: DELL\n\"\"\"\nn=int(input())\nc=0\ns=0\nu=0\nif n!=1 and n!=2:\n for i in range(1,n+1):\n s+=i\n u+=s\n c+=1\n if u>n:\n print(c-1)\n break\n elif u==n:\n print(c)\n break\nelse:\n print(n)\n"}, {"source_code": "n=int(raw_input())\ni=1\nwhile n>0:\n t=sum(range(1,i+1))\n if t>n:\n break\n n-=t\n print t,n\n i+=1\nprint i-1"}, {"source_code": "x = int(input())\n\nr = 0\n\nfor i in xrange(1, x):\n\tr += 1 + 2 + (i - 1) + i \n\n\tif r > x:\n\t\tprint i\n\t\texit(0)\n\nprint 1"}, {"source_code": "target = int(input())\nsum = 1\npasser = 0\nflag = 0\nwhile sum < target:\n passer = sum\n sum += 1\n sum += passer\n flag += 1\nprint(flag)"}, {"source_code": "x=int(input())\np=1\nc=0\ns=0\ni=2\nwhile x>=1:\n c+=1\n x=x-p\n \n p=p+i\n i=i+1\n\n\nif(c>1):\n print(c-1)\nelse:\n print(c)\n\n \n\n\n \n"}, {"source_code": "x=int(input())\np=1\nc=0\ns=0\ni=2\nwhile x>=1:\n c+=1\n x=x-p\n \n p=p+i\n i=i+1\n\n\n\n\nif(c>3):\n print(c-1)\nelse:\n print(c)\n\n \n\n\n \n"}, {"source_code": "n = int(input())\ni = 8\n\nwhile(i * (i + 1) * (i + 2) / 6 > n):\n i -= 1\nprint(i)"}, {"source_code": "n = int(input())\ni = 1\npy = 0\ncount = 0\nif n == 1:\n print(\"1\")\nelse:\n while(1):\n py += i\n i += 2\n if py >= n:\n break;\n count += 1\n print(count)\n "}, {"source_code": "a = int(input())\nb = a\ncaunt = [0]\ncaunt2 = 0\nwhile a > sum(caunt):\n caunt.extend(caunt)\n caunt.append(caunt[-1] + 1)\n caunt2 += 1\nprint(caunt2)\n"}, {"source_code": "x = int(input())\np = 0\nd = 0\nj = 0\nfor i in range(1,x+1):\n p = p+i\n if (d+p)11:\n print(j+1)\n else:\n print(j)\n break\n"}, {"source_code": "n=int(input())\ni=0\ns=0\nwhile(True):\n k1=i*(i+1)//2\n s+=k1\n if(s>=n):\n break\n i+=1\nprint(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 \n \n \n \n \n \n \n \n \n \n \n \n \n "}, {"source_code": "c=int(input())\nk=0\nfor i in range(1,c):\n s=0\n for j in range(1,i+1):\n s=s+j\n \n k=s+k\n \n if(k>=c):\n print(i-1)\n break"}, {"source_code": "n = int(input())\na = 0\ncount = 0\nwhile a <= n: \n\tcount += 1\n\ta += count\n\tprint(a)\nprint(count - 1)\t"}, {"source_code": "n=int(input())\na=2\nc=0\nif n>1:\n\td=1\n\tl=[]\n\tfor i in range(1,n+1):\n\t\tif n>=sum(l):\n\t\t\t\n\t\t\t# print(d)\n\t\t\t# print(d,a,c)\n\t\t\tc+=1\n\t\t\td+=a\n\t\t\ta+=1\n\t\t\tl.append(d)\n\tprint(c)\nelif n==1:\n\tprint(1)\nelse:\n\tprint(0)"}, {"source_code": "n =int(input())\ncount = 0\nlevel = 0\nwhile n > level and n - level >= level:\n count+=1\n level = level + count\n n = n - level\nprint(count)\n \n"}, {"source_code": "n=int(input())\ns=0\nv=0\ni=0\nwhile(v= cubes + last_cubes + 1:\n stage += 1\n cubes += last_cubes + 1\n last_cubes += 1\nprint(stage)\n"}, {"source_code": "def sum_def(n):\n out = 0\n for i in range(1, n + 1):\n for i in range(1, i + 1):\n out += i\n return out\n\nn = int(input())\nsum_tmp = 0\nc = 0\n\nwhile (sum_tmp < n):\n print(sum_def(c + 2))\n sum_tmp = sum_def(c + 2)\n c += 1\n\nprint(c)\n"}, {"source_code": "x=int(input())\np=1\nc=0\ns=0\ni=2\nwhile x>=1:\n x=x-p\n p=p+i\n i=i+1\n c+=1\n\nif(c>1):\n print(c-1)\nelse:\n print(c)\n\n \n\n\n \n"}, {"source_code": "n=int(input())\ni=0\np=0\nwhile n>=p:\n i+=1\n if i%2==0:\n n=n-((i+1)*(i//2))\n p=(i+2)*((i+1)//2)\n else: \n n=n-((i+1)*(i//2)+i//2+1)\n p=(i+2)*((i+1)//2)+(i+1)//2+1\nprint(i)"}, {"source_code": "n = int(input())\nx = 1\nwhile n > sum(range(x+1)):\n x += 1\nif n == sum(range(x+1)):\n print(x)\nelse:\n print(x-1)"}, {"source_code": "n = int(input())\ncubesused = 0\ncubesleft = n\nfloors = 1\n \nif n <= 3:\n print(1)\nelse:\n for i in range(n):\n if (((floors) * (floors+1)) / 2) <= cubesleft:\n floors +=1\n cubesleft -= (((floors) * (floors+1)) / 2)\n else:\n print(floors-1)\n break"}, {"source_code": "n = int(input())\ncount = 0\nresult = 0\nls = []\nfor i in range(1,n+1):\n ls.append(i)\n result += sum(ls) \n if result >= n:\n break\n count+=1\nif count == 0:\n count += 1\nprint(count)"}, {"source_code": "n=int(input())\ni=0\ns=0\nwhile(True):\n k1=i*(i+1)//2\n s+=k1\n if(s>=n):\n break\n i+=1\nprint(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 \n \n \n \n \n \n \n \n \n \n \n \n \n "}, {"source_code": "n = int(input())\n\ni = 1\n\nwhile n > i :\n n //= i\n i +=1\n\nprint(i)\n\n\n\n"}, {"source_code": "x=int(input())\ni=0\nk=1\nc=0\nwhile x-i>0:\n i=i+k\n x=x-i\n c=c+1\n k=k+1\nprint (c) "}, {"source_code": "n=int(input())\nn_y=1\nyr=1\nwhile n>n_y:\n yr=yr+1\n n_y=n_y+yr\n n=n-n_y\n if n<0:\n yr-=1\nprint(yr) \n \n"}, {"source_code": "cube = int(input())\nm = 0\nk = 1\n\nwhile True:\n m += k\n m +=m\n if m>=cube:\n break\n k += 1\n\nprint(k)\n\n\n\n"}, {"source_code": "a=int(input())\nk=1\nr=0\nwhile a>k:\n a-=k\n k+=(k+1)\n r+=1\nprint(r) "}, {"source_code": "n = int(input())\ni = 0\nb=0\nwhile n > i+(1 + b):\n i+=(1 + b)\n n-=i\n b+=1\nprint(b)\n"}, {"source_code": "n=int(input())\ni=1\nj=1\nif n>5:\n n=n-1\n i=3\n while n>-1:\n n-=i*(i+1)//2\n i+=1\n print(n,i)\n j+=1\nprint(j)"}, {"source_code": "n = int(input())\n\nip = 0\na = 1\n\nif n == 1:\n print(1)\nelse:\n while n > ip:\n ip1 = ip\n ip = ip + (ip + a)\n a += 1\n\n if ip > n:\n a -= 1\n print(a)"}, {"source_code": "n = int(input())\na = 0\ncount = 0\nwhile a <= n: \n\tcount += 1\n\ta += count\n\tprint(a)\nprint(count - 1)\t"}, {"source_code": "blocks=int(input())\nfor i in range(1,999):\n summation = 0\n for a in range(1,i+1):\n summation +=a\n blocks-=summation\n if blocks <= 0:\n i-=1\n break\nprint(i)"}, {"source_code": "n=int(input())\nif n==1:\n print(n)\nelse:\n i=0\n ch=1\n while n>ch:\n i+=1\n ch+=i\n n-=ch\n print(i)\n"}, {"source_code": "n = int(input())\ndigits=list(str(n))\n\ncond=0\n\nluckylist=[]\nfor i in range(1,1000):\n rm4=str(i).replace('4','')\n rm47=rm4.replace('7','')\n if (not rm47):\n luckylist.append(i)\n\nfor j in range(len(luckylist)):\n if n%luckylist[j]==0:\n cond+=1\n else:\n continue\n\n\nif cond>0:\n print('YES')\nelse:\n print('NO')\n\n\n# if it could be evenly divided by some lucky number."}, {"source_code": "squareNumber = int(input())\ntotalsum = 0\ni = 0\nwhile True:\n if(squareNumber >=1 and squareNumber <= 10**4):\n break\n else:\n print(\"Write the right number\")\n squareNumber = int(input(\"Write the number of the squares\"))\nwhile (squareNumber > totalsum):\n totalsum = 0\n for sqare in range(1,i+2):\n totalsum+=sqare\n squareNumber-=totalsum\n if(squareNumber > 0):\n i+=1\nprint(i)"}, {"source_code": "l=[1]\nfor i in range(1,20):\n l.append(l[i-1]+i+1)\nn=int(input())\nif n==1:\n print('1')\nelse:\n for i in range(len(l)):\n if n11:\n print(j+1)\n else:\n print(j)\n break\n"}, {"source_code": "n=int(input())\ni=1\nheight=1\ncount=1\nwhile i vals[r]:\n\t\t\tcur = vals[l]\n\t\t\tl += 1\n\t\telse:\n\t\t\tcur = vals[r]\n\t\t\tr -= 1\n\t\tif turn == 0:\n\t\t\tsereja += cur\n\t\telse:\n\t\t\tdima += cur\n\t\tturn = not turn\n\tprint(sereja, dima)\n\t\t\ndef count_lamps(n, m):\n\treturn (n*m + 1)//2\n\t\ndef find_holidays(n):\n\tcnt = 2*(n//7)\n\trem = n%7\n\t#if n < 7:\n\t#\tprint(0, cnt)\n\tmx = mn = cnt\n\tif rem == 1:\n\t\tmx += 1\n\telif rem > 1:\n\t\tmx += 2\n\tif rem == 6:\n\t\tmn += 1\n\t\n\tprint(mn, mx)\n\t\ndef count_eggs(n, s, t):\n\treturn max(1, max(n-s+1, n-t+1))\n\t\t\ndef find_best(n, a):\n\tchest = 0\n\tbiceps = 0\n\tback = 0\n\tfor i in range(n):\n\t\tif i%3 == 0:\n\t\t\tchest += a[i]\n\t\telif i%3 == 1:\n\t\t\tbiceps += a[i]\t\n\t\telse:\n\t\t\tback += a[i]\n\tif chest > max(biceps, back):\n\t\tprint(\"chest\")\n\telif biceps > max(chest, back):\n\t\tprint(\"biceps\")\n\telse:\n\t\tprint(\"back\")\n\nt = 1\n#t = int(input())\nwhile t:\n\tt = t - 1\n\tk, g = 0, 0\n\tpoints = []\n\tn = int(input()) \n\t#a = input()\n\t#b = input()\n\t#s, v1, v2, t1, t2 = map(int, input().split()) \n\t#n, s, l = map(int, input().split()) \n\t#print(discover())\n\t# = map(int, input().split())\n\ta = list(map(int, input().strip().split()))[:n]\n\t#w = list(map(int, input().strip().split()))[:k]\n\t#for i in range(3):\n\t#\tx, y = map(int, input().split()) \n\t#\tpoints.append((x, y))\n\t#s = input()\n\t#if happy_trio(x, y, z, a, b, c):\n\t#\tprint(\"YES\")\n\t#else:\n\t#\tprint(\"NO\")\n\tfind_best(n, a)\n\t#print(count_eggs(n, s, l))\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nsum1 = 0\nsum2 = 0\nsum3 = 0\nfor i in range(n):\n if i % 3 == 0:\n sum1 += a[i]\n if i % 3 == 1:\n sum2 += a[i]\n if i % 3 == 2:\n sum3 += a[i]\n \nif max(sum1, sum2, sum3) == sum1:\n print('chest')\nif max(sum1, sum2, sum3) == sum2:\n print('biceps')\nif max(sum1, sum2, sum3) == sum3:\n print('back')"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nchest = 0\nbiceps = 0\nback = 0\nchest = l[::3]\nbiceps = l[1::3]\nback = l[2::3]\nchest = sum(chest)\nbiceps = sum(biceps)\nback = sum(back)\nif biceps > back and biceps > chest:\n print('biceps')\nelif chest > biceps and chest > back:\n print('chest')\nelse:\n print('back')"}, {"source_code": "n = input()\nl1 = map(int, raw_input().split())\nchest = 0\nbiceps = 0\nback = 0\nfor i in range(0, n):\n if i % 3 == 0:\n chest += l1[i]\n elif i % 3 == 1:\n biceps += l1[i]\n else:\n back += l1[i] \nl = [chest, biceps, back]\nif max(l) == chest:\n print \"chest\"\nelif max(l) == biceps:\n print \"biceps\"\nelif max(l) == back:\n print \"back\""}, {"source_code": "def solution():\n num = int(input())\n li = list(map(int, input().split()))\n chest = 0\n biceps = 0\n back = 0\n checker = []\n for i in range(num):\n if len(checker) == 0:\n chest += li[i]\n checker.append('c')\n elif checker[-1] == 'c':\n biceps += li[i]\n checker.append('b')\n elif checker[-1] == 'b':\n back += li[i]\n checker.append('ba')\n elif checker[-1] == 'ba':\n chest += li[i]\n checker.append('c')\n if chest > biceps and chest > back:\n return print('chest')\n elif biceps > chest and biceps > back:\n return print('biceps')\n else:\n return print('back')\nsolution()\n"}, {"source_code": "input()\ns = map(int,raw_input().split())\na = sum(s[0::3])\nb = sum(s[1::3])\nc = sum(s[2::3])\nd= [a,b,c]\nf = ['chest','biceps','back']\nprint f[d.index(max(d))]\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\n#c,bi,bk=0,0,0\na=[0]*3\nfor i in range(n):\n a[i%3]+=l[i]\nif a[0]>a[1] and a[0]>a[2]:\n print(\"chest\")\nelif a[1]>a[0] and a[1]>a[2]:\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "n = int(input())\nb = list(map(int, input().split()))\nchest = 0\nbiceps = 0\nback = 0\nu = 0\nfor i in range(n):\n if u == 0:\n chest += b[i]\n u += 1\n elif u == 1:\n biceps += b[i]\n u += 1\n else:\n back += b[i]\n u = 0\nif chest > biceps and chest > back:\n print(\"chest\")\nelif biceps > chest and biceps > back:\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nx = 0\ny = 0\nz = 0\nfor i in range(0,n,3):\n x += a[i]\nfor j in range(1,n,3):\n y += a[j]\nfor k in range(2,n,3):\n z += a[k]\nif max(x,y,z) == x:\n print('chest')\nelif max(x,y,z) == y:\n print('biceps')\nelse:\n print('back')"}, {"source_code": "n = input()\nk = map(int,raw_input().split(' '))\nm = [0,0,0]\nfor i in range(len(k)):\n\tm[i%3] += k[i]\nj=m.index(max(m))\nif j == 0:\n\tprint 'chest'\nelif j == 1:\n\tprint 'biceps'\nelse:\n\tprint 'back'"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\nc, b, bk = 0, 0, 0\nfor i in range(len(a)):\n if i % 3 == 0:\n c += a[i]\n elif i % 3 == 1:\n b += a[i]\n else:\n bk += a[i]\n\nif c > b:\n if c > bk:\n print \"chest\"\n else:\n print \"back\"\nelif b > bk:\n print \"biceps\"\nelse:\n print \"back\"\n"}, {"source_code": "n = int(raw_input()) \nl = map(int, raw_input().split())\n\nsomas = [0] * 3\n\nfor i in xrange(n):\n\tsomas[i % 3] += l[i]\n\nmaior = max(somas)\nif somas[0] == maior: print 'chest'\nelif somas[1] == maior: print 'biceps'\nelse: print 'back'"}, {"source_code": "def ii():\n\treturn int(input())\ndef mi():\n\treturn map(int, input().split())\ndef si():\n\treturn [int(x) for x in input().split()]\ndef ss():\n\treturn [x for x in input()]\n\na = ii()\ns = si()\nb = []\nfor i in range(3):\n\tb.append(sum(s[i::3]))\nif b[0] == max(b):\n\tprint(\"chest\")\nelif b[1] == max(b):\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nx = [sum(a[::3]),sum(a[1::3]),sum(a[2::3])]\nif x.index(max(x))==0:\n\tprint \"chest\"\nelif x.index(max(x))==1:\n\tprint \"biceps\"\nelse:\n\tprint \"back\""}, {"source_code": "n=int(input())\nj=n+1\na=[0]*n\na=list(map(int,input().split()))\nbi=0\nba=0\nch=0\nif n==1:\n ch=ch+a[0]\nelif n==2:\n ch=ch+a[0]\n bi=bi+a[1]\nelse:\n j=0\n for i in range(0,int(n/3)):\n ch=ch+a[j]\n bi=bi+a[j+1]\n ba=ba+a[j+2]\n j=j+3\n t=n%3\n if t==1:\n ch=ch+a[n-t]\n elif t==2:\n ch=ch+a[n-t]\n bi=bi+a[n-t+1]\nif ch>=bi:\n if ch>=ba:\n print(\"chest\")\n else:\n print(\"back\")\nelif bi>=ba:\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "# import sys\n# sys.stdin=open('input.in','r')\n# sys.stdout=open('output.out','w')\ns=int(input())\nl=list(map(int,input().strip().split()[:s]))\nbicep=chest=back=0\n\nif len(l)%3!=0:\n\tfor x in range(3-(len(l)%3)):\n\t\tl.append(0)\nx=0\nwhile xb and a>c:\n\tprint \"chest\"\nelif b>a and b>c:\n\tprint \"biceps\"\nelse:\n\tprint \"back\"\n"}, {"source_code": "input()\nl=map(int,raw_input().split())\nprint[\"chest\",\"biceps\",\"back\"][max(0,1,2,key=lambda i:sum(l[i::3]))]\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ng=0\nb=0\ns=0\ncount=0\nfor i in a:\n count+=1\n if count>3:\n count=1\n if count==1:\n g=g+i\n if count==2:\n b=b+i\n if count==3:\n s=s+i\nif max(g,b,s)==g:\n print('chest')\nelse:\n if max(g,b,s)==b:\n print('biceps')\n else:\n print('back')\n \n \n \n\n \n"}, {"source_code": "n = int(input())\ns = list(map(int, input().split()))\nchest = 0\nbiceps = 0\nback = 0\nfor i in range(len(s)):\n if i % 3 == 0:\n chest += s[i]\n elif i % 3 == 1:\n biceps += s[i]\n else:\n back += s[i]\nif max(chest, biceps, back) == chest:\n print('chest')\nelif max(chest, biceps, back) == biceps:\n print('biceps')\nelse:\n print('back')\n"}, {"source_code": "n = input()\na = map(int, raw_input().split())\narr = ['chest','biceps','back']\nx = 0\ny = 0\nz = 0\ni = 0\nwhile iy):\n if(x>z):\n s='chest'\nelse:\n if(y>z):\n s='biceps'\nprint(s)"}, {"source_code": "#-------------Program-------------\n#----KuzlyaevNikita-Codeforces----\n#\n\ng=0;b=0;s=0\nn=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n if i%3==0:g+=a[i]\n elif i%3==1:b+=a[i]\n else:\n s+=a[i]\nk=max(g,b,s)\nif g==k:print('chest')\nelif b==k:print('biceps')\nelse:\n print('back')"}, {"source_code": "n=input()\ne=map(int, raw_input().split())\nr=[0,0,0]\nfor i in range(n):\n r[i%3]+=e[i]\nprint ['chest', 'biceps', 'back'][r.index(max(r))]"}, {"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]))#might need to remove the -1\ndef invr():\n return(map(int,input().split()))\n\nn = inp()\ns = inlt()\ni = 1\nchest, biceps, back = 0, 0, 0\nfor j in range(n):\n if i == 1:\n chest += s[j]\n i += 1\n elif i == 2:\n biceps += s[j]\n i += 1\n else:\n back += s[j]\n i = 1\nw = max(chest, biceps, back)\nif w == chest:\n print('chest')\nelif w == biceps:\n print('biceps')\nelse:\n print('back')"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nmuscles = [0, 0, 0]\nanswer = [\"chest\", \"biceps\", \"back\"]\n\nfor i in range(len(a)):\n if i % 3 == 0:\n muscles[0] += a[i]\n elif i % 3 == 1:\n muscles[1] += a[i]\n else:\n muscles[2] += a[i]\n\nstrongest = muscles.index(max(muscles))\nprint(answer[strongest])\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ng=0\nb=0\ns=0\ncount=0\nfor i in a:\n count+=1\n if count>3:\n count=1\n if count==1:\n g=g+i\n if count==2:\n b=b+i\n if count==3:\n s=s+i\nif max(g,b,s)==g:\n print('chest')\nelse:\n if max(g,b,s)==b:\n print('biceps')\n else:\n print('back')\n \n \n \n\n \n"}, {"source_code": "# cf 255 A 800\nn = int(input())\nA = [*map(int, input().split())]\nc, bi, ba = 0, 0, 0\n\nfor i in range(len(A)):\n if i % 3 == 0:\n c += A[i % n]\n elif i % 3 == 1:\n bi += A[i % n]\n elif i % 3 == 2:\n ba += A[i % n]\n\nif c > bi and c > ba:\n print(\"chest\")\nelif bi > c and bi > ba:\n print(\"biceps\")\nelif ba > c and ba > bi:\n print(\"back\")\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nfrom collections import defaultdict\nd = defaultdict(list)\nfor i in range(0,len(a)):\n m = i%3\n d[m].append(a[i])\nd = dict(d)\nx = max(d.items(),key=lambda x:sum(x[1]))[0]\nif x == 0:\n print(\"chest\")\nelif x == 1:\n print(\"biceps\")\nelif x == 2:\n print(\"back\")"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\n\ncount = [0] * 3\n_max = 0\n_max_idx = 0\nfor i, v in enumerate(l):\n idx = i % 3\n count[idx] += v\n if count[idx] > _max:\n _max = count[idx]\n _max_idx = idx\nprint(['chest', 'biceps', 'back'][_max_idx])\n"}, {"source_code": "n=int(raw_input())\nl=[int(x) for x in raw_input().split()]\nans=[\"chest\",\"biceps\",\"back\"]\nt=0\nchk=[0,0,0]\nfor i in range(n):\n if t==0:\n chk[0]+=l[i]\n t+=1\n elif t==1:\n chk[1]+=l[i]\n t+=1\n else:\n chk[2]+=l[i]\n t=0\nprint ans[chk.index(max(chk))]"}, {"source_code": "n = int (input ())\na = list (map (int, input ().split ()))\n\nchest = []\nbiceps = []\nback = []\n\nfor i in range (1,n+1):\n\tif i%3 == 1:\n\t\tchest.append (a[i-1])\n\telif i%3 == 2:\n\t\tbiceps.append (a[i-1])\n\telse:\n\t\tback.append (a[i-1])\n\nx = sum (chest)\ny = sum (biceps)\nz = sum (back)\n\nif max (x,y,z) == x:\n\tprint ('chest')\nelif max (x,y,z) == y:\n\tprint ('biceps')\nelse:\n\tprint ('back')"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nc,bi,b=0,0,0\ni=0\nfor i in range(0,n,i+3):\n if i b and a > c:\n\tprint(\"chest\")\nelif b > a and b > c:\n\tprint(\"biceps\")\nelif c > a and c > b:\n\tprint(\"back\")"}, {"source_code": "a=int(input())\nlis=list(map(int,input().split()))\nc=0\nb=0\nba=0\nfor i in range(a):\n if(i%3==0):\n c+=lis[i]\n elif(i%3==1):\n b+=lis[i]\n else:\n ba+=lis[i]\nans=max(c,b,ba)\nif(c==ans):\n print(\"chest\")\nelif(b==ans):\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "#!/usr/bin/python\n\nn = int(raw_input())\na = []\n\na = map(int,raw_input().split())\n\nchest = sum(a[0:n:3])\nbiceps = sum(a[1:n:3])\nback = sum(a[2:n:3])\n\nif max(chest,biceps,back) == chest:\n print \"chest\"\nelif max(chest,biceps,back) == biceps:\n print \"biceps\"\nelse:\n print \"back\""}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nc, bi, ba = 0,0,0\nfor i in range(1,n+1):\n if i%3==0:\n ba+=a[i-1]\n elif i%3==1:\n c+=a[i-1]\n else:\n bi += a[i-1]\n#print(c)\n#print(bi)\n#print(ba)\nif max(c,bi,ba)==c:\n print(\"chest\")\nelif max(c,bi,ba)==bi:\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "x = input()\ninp = input().split(\" \")\nchest = 0\nback = 2\nbiceps = 1\ncount = [0, 0, 0]\nfor i in range(len(inp)):\n if i==chest:\n count[0]+=int(inp[chest])\n chest+=3\n if i==biceps:\n count[1]+=int(inp[biceps])\n biceps+=3\n if i==back:\n count[2]+=int(inp[back])\n back+=3\nmaxVal = max(count)\nif count[0]==maxVal:\n print(\"chest\")\nelif count[1]==maxVal:\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "x = int(input())\nl = input().split()\na = [0,0,0]\nfor i,y in enumerate(l):\n y = int(y)\n if (i%3==0):\n a[0]+=y\n elif (i%3==1):\n a[1]+=y\n elif (i%3==2):\n a[2]+=y\nx = max(a)\nif (a[0]==x):\n print(\"chest\")\nelif(a[1]==x):\n print(\"biceps\")\nelif(a[2]==x):\n print(\"back\")\n \n\n "}, {"source_code": "a=int(input())\nb=list(map(int,input().split()))\nback=sum(b[2::3])\nchest=sum(b[::3])\nbic=sum(b[1::3])\nc=max(back,chest,bic)\nif back==c:print('back')\nelif chest==c:print('chest')\nelse:print('biceps')\n"}, {"source_code": "#-------------Program-------------\n#----KuzlyaevNikita-Codeforces----\n#\n\ng=0;b=0;s=0\nn=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n if i%3==0:g+=a[i]\n elif i%3==1:b+=a[i]\n else:\n s+=a[i]\nk=max(g,b,s)\nif g==k:print('chest')\nelif b==k:print('biceps')\nelse:\n print('back')"}, {"source_code": "n,a = input(),map(int,raw_input().split())\na = [sum(a[i::3]) for i in range(3)]\nprint [\"chest\",\"biceps\",\"back\"][a.index(max(a))]\n\n # n, a = input(), map(int, raw_input().split())\n # a = [sum(a[i::3]) for i in [0, 1, 2]]\n # print[\"chest\", \"biceps\", \"back\"][a.index(max(a))]"}, {"source_code": "n=int(input())\nmat=list(map(int,input().split()))\nexe=['chest','biceps','back']\narr=[0,0,0]\ni=0\nwhile(n>0):\n n-=3\n try:\n arr[i%3]+=mat[i]\n arr[(i+1)%3]+=mat[i+1]\n arr[(i+2)%3]+=mat[i+2]\n except:\n break\n i+=3\nind=arr.index(max(arr))\nprint(exe[ind])"}, {"source_code": "nexs = int(raw_input())\ncounts = [0, 0, 0]\nexs = map(int, raw_input().split())\nfor i, ex in enumerate(exs):\n counts[i % 3] += ex\nif counts[0] == max(counts):\n print \"chest\"\nelif counts[1] == max(counts):\n print \"biceps\"\nelse:\n print \"back\"\n"}, {"source_code": "n=int(raw_input())\nk=raw_input().split()\na=[0,0,0]\nfor i in range(n): a[i%3]+=int(k[i])\nm=max(a)\nif(m==a[0]): print(\"chest\")\nelif(m==a[1]): print(\"biceps\")\nelse: print(\"back\")"}, {"source_code": "__author__ = 'a11x256'\nn = int(raw_input())\nx = map(int , raw_input().split())\na = [0] * 3\nfor i in xrange(n):\n a[i%3] += x[i]\n\nif (a[0] >max(a[1],a[2])):\n print \"chest\"\nelif (a[1] > max(a[0],a[2])):\n print \"biceps\"\nelse:\n print \"back\"\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nx, y, z = 0, 0, 0\nif n % 3 == 1:\n a.append(0)\n a.append(0)\n n += 2\nif n % 3 == 2:\n a.append(0)\n n += 1\nfor i in range(0, n, 3):\n x, y, z = x + a[i], y + a[i + 1], z + a[i + 2]\nif x > y and x > z:\n print('chest')\nelif y > x and y > z:\n print('biceps')\nelse:\n print('back')"}, {"source_code": "n = int(input())\na = map(int, input().split())\nx = list(a)\nb = 0\nchest = x[::3]\nbiceps = x[1::3]\nback = x[2::3]\nch = sum(chest)\nbi = sum(biceps)\nba = sum(back)\nif ch >= bi:\n if ch >= ba:\n print('chest')\n else:\n print('back')\nelif bi >= ch:\n if bi >= ba:\n print('biceps')\n else:\n print('back')\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\n\nchest=0\nbiceps=0\nback=0\n\nfor i in range(1,n+1):\n if i%3==1:\n chest+=l[i-1]\n elif i%3==2:\n biceps+=l[i-1]\n else:\n back+=l[i-1]\nif(chest>=biceps and chest>= back):\n print(\"chest\")\nelif(biceps>=chest and biceps>=back):\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "input()\nl=map(int,raw_input().split())\nprint[\"chest\",\"biceps\",\"back\"][max(0,1,2,key=lambda i:sum(l[i::3]))]\n\n"}, {"source_code": "n = int(input())\narr = [int(x) for x in input().split()]\nans = {0:['chest',0],1:['biceps',0],2:['back',0]}\nfor i in range(len(arr)):\n ans[i%3][1] += arr[i]\n\nprint(ans[max(ans.keys(),key=(lambda k:ans[k][1]))][0])\n"}, {"source_code": "input()\nl=map(int,raw_input().split())\nprint[\"chest\",\"biceps\",\"back\"][max(0,1,2,key=lambda i:sum(l[i::3]))]\n\n"}, {"source_code": "c,bi,ba=[],[],[]\ns='back'\na=int(input())\nex=list(map(int,input().strip().split()))\nfor i in range(len(ex)):\n if(i%3==0):\n c.append(ex[i])\n elif(i%3==1):\n bi.append(ex[i])\n else:\n ba.append(ex[i])\nx=sum(c)\ny=sum(bi)\nz=sum(ba)\nif(x>y):\n if(x>z):\n s='chest'\nelse:\n if(y>z):\n s='biceps'\nprint(s)"}, {"source_code": "n=int(input())\nmat=list(map(int,input().split()))\nexe=['chest','biceps','back']\narr=[0,0,0]\ni=0\nwhile(n>0):\n n-=3\n try:\n arr[i%3]+=mat[i]\n arr[(i+1)%3]+=mat[i+1]\n arr[(i+2)%3]+=mat[i+2]\n except:\n break\n i+=3\nind=arr.index(max(arr))\nprint(exe[ind])"}, {"source_code": "n = int(input())\ns = [\"c\", \"bi\", \"ba\"]\nd = {}\nans = [0, 0, 0]\nfor ind, i in enumerate(map(int, input().split())):\n d.setdefault(s[(ind % 3)], [0])[0] += i\nfor i in d:\n if i == 'c':\n ans[0] = d[i][0]\n elif i == 'bi':\n ans[1] = d[i][0]\n else:\n ans[2] = d[i][0]\n\nif ans[0] > ans[1] and ans[0] > ans[2]:\n print(\"chest\")\nelif ans[1] > ans[0] and ans[1] > ans[2]:\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "def solve(exercises):\n\n chest = sum(exercises[0::3])\n biceps = sum(exercises[1::3])\n back = sum(exercises[2::3])\n\n maxExercise = \"chest\"\n\n if biceps > chest and biceps > back:\n maxExercise = \"biceps\"\n elif back > chest and back > biceps:\n maxExercise = \"back\"\n\n return maxExercise\n\n\n\nn = int(input())\nexercises = list(map(int, input().split(\" \")))\n\nprint(solve(exercises))"}, {"source_code": "n=int(raw_input())\nworkout=map(int,raw_input().split())\nchest=biceps=back=0\nfor i in range(n):\n if(i%3==0):\n chest=chest+workout[i]\n if(i%3==1):\n biceps=biceps+workout[i]\n if(i%3==2):\n back=back +workout[i]\nval=max(chest,biceps,back)\nprint \"chest\" if chest==val else 'back' if back==val else 'biceps'\n"}, {"source_code": "t = int(input())\nl = list(map(int, input().split()))\nchest = 0\nbicep = 0\nback = 0\n\nfor i in range(1, len(l)+1):\n if(i%3==1):\n chest+=l[i-1]\n elif(i%3==2):\n bicep+=l[i-1]\n else:\n back+=l[i-1]\n\nm = max(chest, bicep, back)\nif(m==back):\n print(\"back\")\nelif(m==chest):\n print(\"chest\")\nelse:\n print(\"biceps\")\n"}, {"source_code": "input();seq=map(int,raw_input().split())\nt=[sum(seq[::3]),sum(seq[1::3]),sum(seq[2::3])]\nprint ['chest','biceps','back'][t.index(max(t))]"}, {"source_code": "N=int(input())\nA=list(map(int,raw_input().split()))\ncount1=0\ncount2=0\ncount3=0\nfor k in range (N):\n if(k%3==0):\n count1+=A[k]\n else:\n if(k%3==1):\n count2+=A[k]\n else:\n count3+=A[k] \nif((count1>count2)and (count1>count3)):\n print(\"chest\")\nif((count2>count1)and (count2>count3)):\n print(\"biceps\")\nif((count3>count2)and (count3>count1)):\n print(\"back\")\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nc,bi,b=0,0,0\ni=0\nfor i in range(0,n,i+3):\n if ibi and c>ba:\n print('chest')\nelif bi>c and bi>ba:\n print('biceps')\nelif ba>bi and ba>c:\n print('back')\nelse:\n print('unambiguous')\n"}, {"source_code": "n=int(input())\na=[int(x) for x in input().split()]\nchest,biceps,back=0,0,0\ncount=0\nfor i in range(1,n+1):\n count+=1\n if (count%3==0):\n back+=a[i-1]\n count=0\n elif (count%2==0):\n biceps+=a[i-1]\n else:\n chest+=a[i-1]\ndic=dict({'chest':chest,'biceps':biceps,'back':back})\nprint(max(dic,key=dic.get))"}, {"source_code": "n=input()\nlst=map(int,raw_input().split())\n\nchest=0\nbiceps=0\nback=0\nfor i in range(1,n+1):\n if i%3==1:\n chest+=lst[i-1]\n elif i%3==2:\n biceps+=lst[i-1]\n\n else:\n back+=lst[i-1]\n\n\nmaxnum=max(chest,biceps,back)\nif chest==maxnum:\n print \"chest\"\nelif biceps==maxnum:\n print \"biceps\"\nelse:\n print \"back\"\n\n \n"}, {"source_code": "n, a = input(), map(int, raw_input().split())\ne = [sum(a[i::3]) for i in [0,1,2]]\nprint dict(zip(e, ['chest', 'biceps', 'back']))[max(e)]\n"}, {"source_code": "n = input()\na = map(int, raw_input().split(\" \"))\nresult = {\n\t\"chest\": 0,\n\t\"biceps\": 0,\n\t\"back\":0\n}\nfor i in range(0,n,3):\n\tresult[\"chest\"] += a[i]\nfor i in range(1,n,3):\n\tresult[\"biceps\"] += a[i]\nfor i in range(2,n,3):\n\tresult[\"back\"] += a[i]\n\npart = \"chest\"\nmax_reps = result[\"chest\"]\nfor k,v in result.iteritems():\n\tif v > max_reps:\n\t\tmax_reps = v\n\t\tpart = k\nprint part\n"}, {"source_code": "input()\nl=map(int,raw_input().split())\na,b,c=sum(l[::3]),sum(l[1::3]),sum(l[2::3])\nif a>b:\n if a>c:\n print 'chest'\n exit()\n print 'back'\n exit()\nif b>c:\n print 'biceps'\n exit()\nprint 'back'"}, {"source_code": "t=int(input())\na=list(map(int,input().split()))\nc=0\nbi=0\nb=0\nfor i in range(0,t,3):\n c=c+a[i]\n if i+1bi and c>b:\n print(\"chest\")\nif bi>c and bi>b:\n print(\"biceps\")\nif b>bi and b>c:\n print(\"back\")"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nm={1:0,2:0,3:0}\nfor i in range(n):\n m[(i%3)+1]+=arr[i]\n\n\n# for i in arr:\n# if i==1:\n# m[1]+=1\n# if i==2:\n# m[1]+=1\n# m[2]+=1\nk=[1,2,3]\nv=list(m.values())\n# print(m,v,max(v),v.index(max(v)),k[v.index(max(v))])\n# print(v,max(v))\nif k[v.index(max(v))]==1:\n print(\"chest\")\nelif k[v.index(max(v))]==2:\n print(\"biceps\")\nelse:\n print(\"back\")\n\n# n=int(input())\n# arr=list(map(int,input().split()))\n# for i in range(n):\n# arr[i]=arr[i]%3\n# m={1:0,2:0,3:0}\n# for i in arr:\n# if i==0:\n# m[i]+=1\n# if i==1:\n# m[i]+=1\n# m[0]+=1\n# # if\n# v=list(m.values())\n# # print(m)\n# if v.index(max(v))==0:\n# print(\"chest\")\n# elif v.index(max(v))==2:\n# print(\"biceps\")\n# else:\n# print(\"back\")\n\n\n# n=int(input())\n# arr=list(map(int,input().split()))\n# for i in range(n):\n# arr[i]=arr[i]%3\n# m={1:0,2:0,3:0}\n# for i in arr:\n# if i==1:\n# m[1]+=1\n# if i==2:\n# m[1]+=1\n# m[2]+=1\n# k=[1,2,3]\n# v=list(m.values())\n# print(m,v,max(v),v.index(max(v)),k[v.index(max(v))])\n# print(v,max(v))\n# if k[v.index(max(v))]==1:\n# print(\"chest\")\n# elif k[v.index(max(v))]==2:\n# print(\"biceps\")\n# else:\n# print(\"back\")\n\n# # n=int(input())\n# # arr=list(map(int,input().split()))\n# # for i in range(n):\n# # arr[i]=arr[i]%3\n# # m={1:0,2:0,3:0}\n# # for i in arr:\n# # if i==0:\n# # m[i]+=1\n# # if i==1:\n# # m[i]+=1\n# # m[0]+=1\n# # # if\n# # v=list(m.values())\n# # # print(m)\n# # if v.index(max(v))==0:\n# # print(\"chest\")\n# # elif v.index(max(v))==2:\n# # print(\"biceps\")\n# # else:\n# # print(\"back\")"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nc1, c2, i = 0, 0, 0\nwhile i=y and x>=z):\n print(\"chest\")\nelif(y>=x and y>=z):\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "n=int(input())\na,sum1,sum2,sum3=[],0,0,0\nx=raw_input()\na=x.split()\nfor i in range(n):\n if((i+1)%3==1):\n sum1 = sum1+int(a[i])\n elif((i+1)%3==2):\n sum2 = sum2+int(a[i])\n else:\n sum3 = sum3+int(a[i])\nif((sum1 > sum2) & (sum1 > sum3)):\n print(\"chest\")\nelif(sum2 > sum3):\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",\"r\")\n# sys.stdout=open(\"output.out\",\"w\")\n\nn = int(input())\nl = list(map(int,input().split()))\nd = {sum(l[0::3]):\"chest\",sum(l[1::3]):\"biceps\",sum(l[2::3]):\"back\"}\nprint(d[max(sum(l[0::3]),sum(l[1::3]),sum(l[2::3]))])"}, {"source_code": "input()\nl=map(int,raw_input().split())\nprint[\"chest\",\"biceps\",\"back\"][max(0,1,2,key=lambda i:sum(l[i::3]))]\n\n"}, {"source_code": "n=int(raw_input())\nworkout=map(int,raw_input().split())\nchest=biceps=back=0\nfor i in range(n):\n if(i%3==0):\n chest=chest+workout[i]\n if(i%3==1):\n biceps=biceps+workout[i]\n if(i%3==2):\n back=back +workout[i]\nval=max(chest,biceps,back)\nprint \"chest\" if chest==val else 'back' if back==val else 'biceps'\n"}, {"source_code": "import sys\nimport math as m\ndef main():\n pass\ndef binary(n):\n #decimal to binary\n return (bin(n).replace(\"0b\", \"\"))\ndef decimal(s):\n #binary to decimal\n return (int(s, 2))\ndef pow2(n):\n #power of a number base 2\n p = 0\n while n > 1:\n n //= 2\n p += 1\n return (p)\ndef isPrime(n):\n # if number is prime in \u221an time\n if (n == 1):\n return (False)\n else:\n root = int(n ** 0.5)\n root += 1\n for i in range(2, root):\n if (n % i == 0):\n return (False)\n return (True)\ndef lts(l):\n #list to string ,no spaces\n s=''.join(map(str,l))\n return s\ndef stl(s):\n #for each character in string to list with no spaces -->\n l=list(s)\n #for space in string -->\n #l=list(s.split(\" \"))\n return l\n#1000000007\nmod=int(1e9)+7\ndef sinp(): return sys.stdin.readline().strip()\ndef iinp(): return int(input())\ndef ninp(): return map(int, sys.stdin.readline().strip().split())\ndef linp(): return list(map(int, sys.stdin.readline().strip().split()))\ndef p(a): print(a)\ndef p2(a,b):print(a,b)\n#for _ in range(iinp()):\nn=iinp()\na=linp()\nchest=a[0::3]\nc1=sum(chest)\nbiceps=a[1::3]\nb1=sum(biceps)\nback=a[2::3]\nbs=sum(back)\nif(max(c1,b1,bs)==c1):\n print(\"chest\")\nelif(max(c1,b1,bs)==b1):\n print(\"biceps\")\nelif(max(c1,b1,bs)==bs):\n print(\"back\")\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nchest = []\nbiceps = []\nback = []\nc = 0\nfor i in range(len(a)):\n if c%3==0:\n chest.append(a[i])\n c+=1\n elif c%3==1:\n biceps.append(a[i])\n c+=1\n elif c%3==2:\n back.append(a[i])\n c+=1\nq = sum(chest)\nw = sum(biceps)\ne = sum(back)\nif q>w and q>e:\n print(\"chest\")\nelif w>q and w>e:\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "input()\na=map(int,raw_input().split())\nprint max((sum(a[::3]),'chest'),(sum(a[1::3]),'biceps'),(sum(a[2::3]),'back'))[1]\n"}, {"source_code": "n = int(raw_input()) \nl = map(int, raw_input().split())\n\nsomas = [0] * 3\n\nfor i in xrange(n):\n\tsomas[i % 3] += l[i]\n\nmaior = max(somas)\nif somas[0] == maior: print 'chest'\nelif somas[1] == maior: print 'biceps'\nelse: print 'back'"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nx = 0\ny = 0\nz = 0\nfor i in range(0,n,3):\n x += a[i]\nfor j in range(1,n,3):\n y += a[j]\nfor k in range(2,n,3):\n z += a[k]\nif max(x,y,z) == x:\n print('chest')\nelif max(x,y,z) == y:\n print('biceps')\nelse:\n print('back')"}, {"source_code": "t=int(input())\nl=list(map(int,input().split()))\ncountc=0\ncountbi=0\ncountb=0\nfor i in range(0,t,3):\n countc+=l[i]\n if i+1b and c>ba:\n\tprint(\"chest\")\nelif b>ba and b>c :\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nchest = sum(a[0::3])\nbiceps = sum(a[1::3])\nback = sum(a[2::3])\nif chest == max(chest, biceps, back):\n\ti = 0\nelif biceps == max(chest, biceps, back):\n\ti = 1\nelse:\n\ti = 2\nprint(['chest','biceps','back'][i])"}, {"source_code": "t=input()\nn=map(int,raw_input().split())\nflag=0\nc=0\nbi=0\nb=0\nfor i in xrange(t):\n if(flag==0):\n c+=n[i]\n flag=1\n elif(flag==1):\n bi+=n[i]\n flag=2\n else:\n b+=n[i]\n flag=0\n\nif(c>bi and c>b):\n print \"chest\"\nelse:\n if(bi>b):\n print \"biceps\"\n else:\n print \"back\""}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nbiceps = back = chest = 0\nfor i in range(n):\n\tif i%3==0:\n\t\tchest+=a[i]\n\telif i%3==1:\n\t\tbiceps+=a[i]\n\telse:\n\t\tback+=a[i]\nif max(max(chest, biceps), back) == chest:\n\tprint(\"chest\")\nelif max(max(chest, biceps), back) == biceps:\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\n\nchest=0\nbiceps=0\nback=0\n\nfor i in range(1,n+1):\n if i%3==1:\n chest+=l[i-1]\n elif i%3==2:\n biceps+=l[i-1]\n else:\n back+=l[i-1]\nif(chest>=biceps and chest>= back):\n print(\"chest\")\nelif(biceps>=chest and biceps>=back):\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "t=input()\nn=map(int,raw_input().split())\nflag=0\nc=0\nbi=0\nb=0\nfor i in xrange(t):\n if(flag==0):\n c+=n[i]\n flag=1\n elif(flag==1):\n bi+=n[i]\n flag=2\n else:\n b+=n[i]\n flag=0\n\nif(c>bi and c>b):\n print \"chest\"\nelse:\n if(bi>b):\n print \"biceps\"\n else:\n print \"back\""}, {"source_code": "# cf 255 A 800\nn = int(input())\nA = [*map(int, input().split())]\nc, bi, ba = 0, 0, 0\n\nfor i in range(len(A)):\n if i % 3 == 0:\n c += A[i % n]\n elif i % 3 == 1:\n bi += A[i % n]\n elif i % 3 == 2:\n ba += A[i % n]\n\nif c > bi and c > ba:\n print(\"chest\")\nelif bi > c and bi > ba:\n print(\"biceps\")\nelif ba > c and ba > bi:\n print(\"back\")\n"}, {"source_code": "a=int(input())\nb=list(map(int,input().split()))\nba=bi=c=x=int(0)\nfor x in range(a):\n\tif x%3==0:\n\t\tc=c+b[x]\n\telif x%3==1:\n\t\tbi=bi+b[x]\n\telse:\n\t\tba=ba+b[x]\nif ba>bi and ba>c:\n\tprint(\"back\")\nelif bi>ba and bi>c:\n\tprint(\"biceps\")\nelse:\n\tprint(\"chest\")"}, {"source_code": "import sys\n\nn = input()\na = b = c = 0\nwts = map(int, sys.stdin.readline().split())\na = sum(wts[::3])\nif len(wts) > 1:\n b = sum(wts[1::3])\nif len(wts) > 2:\n c = sum(wts[2::3])\nif a > b:\n if a > c:\n print \"chest\"\n else:\n print \"back\"\nelse:\n if b > c:\n print \"biceps\"\n else:\n print \"back\"\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nchest = 0\nbiceps = 0\nback = 0\nfor i in range(n):\n if i % 3 == 0:\n chest += a[i]\n elif i % 3 == 1:\n biceps += a[i]\n elif i % 3 == 2:\n back += a[i]\nif biceps > chest and biceps > back:\n print('biceps')\nelif chest > biceps and chest > back:\n print('chest')\nelse:\n print('back')\n\n"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\nb=[\"chest\",\"biceps\",\"back\"]\nif len(a)<=3:\n print(b[a.index(max(a))])\nelse:\n i=0\n j=0\n k=0\n for _ in range(len(a)):\n if _%3==0:\n i+=a[_]\n elif _%3==1:\n j+=a[_]\n else:\n k+=a[_]\n if i==max(i,j,k):\n print(\"chest\")\n elif j==max(i,j,k):\n print(\"biceps\")\n else:\n print(\"back\")"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nmuscle = [0,0,0]\n\nfor i in range(n):\n\tmuscle[i % 3] += a[i]\n\nif int(muscle[0]) == int(max(muscle)):\n\tprint \"chest\"\nelif int(muscle[1]) == int(max(muscle)):\n\tprint \"biceps\"\nelif int(muscle[2]) == int(max(muscle)):\n\tprint \"back\""}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nmuscles = [0, 0, 0]\nanswer = [\"chest\", \"biceps\", \"back\"]\n\nfor i in range(len(a)):\n if i % 3 == 0:\n muscles[0] += a[i]\n elif i % 3 == 1:\n muscles[1] += a[i]\n else:\n muscles[2] += a[i]\n\nstrongest = muscles.index(max(muscles))\nprint(answer[strongest])\n"}], "negative_code": [{"source_code": "t = int(input())\nx = list(map(int, input().split()))\nind = x.index(max(x))+1\nif (ind%3==1):\n\tprint (\"chest\")\nelif (ind%3==2):\n\tprint (\"biceps\")\nelif ind%3==0:\n\tprint (\"back\")"}, {"source_code": "n=int(input())\nlst=list(map(int,input().split()))\nif n%3==1:\n print(\"chest\")\nelif n%3==2:\n print(\"biceps\")\nelif n%3==0:\n print(\"back\")"}, {"source_code": "n=int(raw_input())\n\nexercises=raw_input().split()\nchest=0\nback=0\nbiceps=0\n\nfor i in range(1,n+1):\n if i%2==0:\n biceps += int(exercises[i-1])\n elif i%3==0:\n back += int(exercises[i-1])\n else:\n chest += int(exercises[i-1])\n\nif chest > biceps and chest > back:\n print 'chest'\n\nif back > biceps and back > chest:\n print 'back'\n\nif biceps > chest and biceps > back:\n print 'biceps'\n \n"}, {"source_code": "# Greg's Workout\ndef workout(arr):\n chest = 0\n biceps = 0\n back = 0\n flag = 1\n for i in arr:\n if flag == 1:\n chest += i\n flag +=1\n elif flag == 2:\n biceps += i\n flag += 1\n elif flag == 3:\n back += i\n flag = 0\n big = max(chest, biceps, back)\n if chest == big:\n return \"chest\"\n elif biceps == big:\n return 'biceps'\n return 'back'\n\n\n\n\nn = int(input())\nar = list(map(int, input().rstrip().split()))\nprint(workout(ar))"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",\"r\")\n# sys.stdout=open(\"output.out\",\"w\")\n\na=int(input())\nb=list(map(int,input().split()))\nchest,biceps,back=0,0,0\nfor x in range(int(a/3)):\n\tchest+=b[x]\n\tbiceps+=b[x+1]\n\tback+=b[x+2]\nif a%3==2:\n\tchest+=b[-2]\n\tbiceps+=b[-1]\nelif a%3==1:\n\tchest+=b[-1]\nm=[chest,biceps,back]\nif max(m)==m[0]:\n\tprint('chest')\nelif max(m)==m[1]:\n\tprint('biceps')\nelif max(m)==m[2]:\n\tprint('back')\n"}, {"source_code": "n=int(input())\nnums=list(map(int,input().split()))\nchest=0\nbiceps=0\nback=0\nfor i in range(1,len(nums)+1):\n if i%3==1:\n chest=chest+nums[i-1]\n elif i%3==2:\n biceps=biceps+nums[i-1]\n elif i%3==0:\n back=back+nums[i-1]\nif chest>biceps and chest>back:\n print(\"chest\")\nelif biceps>chest and biceps>chest:\n print(\"biceps\")\nelif back>chest and back>biceps:\n print(\"back\")"}, {"source_code": "t = int(input())\na = list(map(int, input().split()))[:t]\n\nm = max(a)\nfor i in range(t):\n if a[i] == m:\n break\nif i<=3:\n if (i + 1) == 1:\n print(\"chest\")\n elif (i + 1)== 2:\n print(\"biceps\")\n elif (i + 1)== 3:\n print(\"Back\")\nelse:\n if (i + 1) // (3) == 1:\n print(\"chest\")\n elif (i + 1) // (3) == 2:\n print(\"biceps\")\n elif (i + 1) // (3) == 3:\n print(\"Back\")\n"}, {"source_code": "a = int(input())\nx = list(map(int,input().split()))\nchest = []\nbiceps= []\nback=[]\nchest.append(x[0::3])\nbiceps.append(x[1::3])\nback.append(x[2::3])\n\nif sum(*biceps) sum(*back):\n print('chest')\nelif sum(*chest)sum(*chest):\n print('back')\nelif sum(*chest) < sum(*biceps) > sum(*chest):\n \n print('biceps')\n # print(sum(*chest), sum(*biceps),sum(*back))"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nchest = 0\nbiceps = 0\nback = 0\nfor i in range(0, len(a), 3):\n chest += a[i]\nfor i in range(1, len(a), 3):\n biceps += a[i]\nfor i in range(2, len(a), 3):\n back += a[i]\nif back < chest > biceps:\n print(chest)\nelif chest < back > biceps:\n print(back)\nelse:\n print(biceps)\n"}, {"source_code": "n=int(input())\nexercicios=input().split(\" \")\nbiceps=0\nback=0\nchest=0\nfor x in range(0,n,3):\n\tchest+=int(exercicios[x])\nfor x in range(1,n,3):\n\tbiceps+=int(exercicios[x])\nfor x in range(2,n,3):\n\tback+=int(exercicios[x])\nlista=[chest,back,biceps]\ny=sorted(lista)\nif(lista[2]==chest):\n print(\"chest\") \nif(lista[2]==biceps):\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "n = int(input())\n\narr = list(map(int, input().split()))\n\ni = 1\nchest, bicep, back = 0, 0, 0\n\nfor x in arr:\n\tif i == 1:\n\t\tchest += x\n\t\ti += 1\n\telif i == 2:\n\t\tbicep += x\n\t\ti += 1\n\telif i == 3:\n\t\tback += x\n\t\ti += 1\n\tif i > 3:\n\t\ti = 1\n\nif chest >= bicep >= back:\n\tprint(\"chest\")\nelif bicep >= chest >= back:\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")\n"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nm=max(l)\nindex=l.index(m)+1\nif index%3==0:\n print(\"back\")\nelif index%2==0:\n print(\"biceps\")\nelse:\n print(\"chest\")"}, {"source_code": "\ndef check(l):\n chest = 0\n biceps = 0\n back = 0\n for i in range(0,2):\n if len(l) % 3 == 0:\n break\n l.append(0)\n\n for i in range(0,len(l)//3,3):\n chest += l[i]\n biceps += l[i+1]\n back +=l[i+2] \n\n if chest > biceps and chest > back:\n return 'chest'\n elif biceps > chest and biceps > back:\n return 'biceps'\n else:\n return 'back'\n\n\nt = int(input())\na = input().split()\nb = map(int, a)\ni_list = list(b)\nprint(check(i_list))\n\n\n\n"}, {"source_code": "n= int(input()) \nx = list(map(int, input().split()))\nchests=0\nbiceps=0\nbacks=0\nfor e in range(0,n,3):\n chests=chests+x[e]\nfor e1 in range(1,n,3):\n biceps=biceps+x[e1]\nfor e2 in range(2,n,3):\n backs=backs+x[e2]\nif chests > backs:\n if chests> biceps:\n print(\"chest\")\nelif backs > chests:\n if backs > biceps:\n print(\"back\")\nelif biceps > backs:\n if biceps > chests:\n print(\"biceps\") "}, {"source_code": "a=int(input())\nl=list(map(int,input().split()))\nch=0\nbic=0\nbac=0\ncount=1\nfor i in range(a):\n if count%3==0:\n bac+=l[i]\n elif count%2==0:\n bic+=l[i]\n else:\n ch+=l[i]\n count+=1\n if count==4:\n count=1\nprint(ch,bic,bac)\ne=max([bac,bic,ch])\nif e==bac:\n print('back')\nelif e==bic:\n print('biceps')\nelse:\n print('chest')\n\n"}, {"source_code": "n=input();l=map(int,raw_input().split())\nd={'biceps':0,'chest':0,'back':0}\nfor i in range(n):\n if (i+1)%3==0: d['back']+=l[i]\n elif (i+1)%2==0: d['biceps']+=l[i]\n else: d['chest']+=l[i]\nfor i in d:\n if d[i]==max(d.values()):\n print i\n break\n"}, {"source_code": "import sys\nn = input()\narr = map(int,sys.stdin.readline().split())\ni = 1\nchest = 0\nback = 0\nbiceps = 0\nwhile(i <= n):\n if(i%2 == 0):\n biceps += arr[i-1]\n elif(i%3 == 0):\n back += arr[i-1]\n else:\n chest += arr[i-1]\n i += 1\nlist = [chest,biceps,back]\nc = list.index(max(list))\nif(c == 0):\n print \"chest\"\nelif(c == 1):\n print \"biceps\"\nelse:\n print \"back\"\n"}, {"source_code": "n = int(input())\ndays = [int(n) for n in input().split()]\nchest = 0\nbiceps = 0\nback = 0\nfor i in range(n):\n if i%3 == 0:\n chest += 1\n elif i%3 == 1:\n biceps += 1\n else:\n back += 1\nif chest > biceps and chest > back:\n print(\"chest\")\nelif biceps > chest and biceps > back:\n print(\"biceps\")\nelse:\n print(\"back\")\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))[:n]\n\nch = sum(a[0::3])\nbc = sum(a[1::3])\nbk = sum(a[2::3])\n\nw = [ch, bk, bc]\nif w[2]==bk:\n print(\"back\")\nelif w[2]==bc:\n print(\"bicepts\")\nelse:\n print(\"chest\")"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\nc=[]\nx=[\"chest\",\"bicep\",\"back\"]\nfor i in range(3):\n c.append(sum(a[i::3]))\nmapped=zip(x,c)\nprint(sorted(list((mapped)))[-1][0])\n\n"}, {"source_code": "n=int(input())\nrepeats=[int(i) for i in input().split()]\nexercises=[\"chest\",\"biceps\",\"back\"]\ntotal=[0,0,0]\nfor i in range(n):\n if i in range(0, n, 3):\n total[0]+=1\n if i in range(1, n, 3):\n total[1]+=1\n if i in range(2, n, 3):\n total[2]+=1\nsolution=exercises[total.index(max(total))]\nprint(solution)\n"}, {"source_code": "a = int(input())\nx = list(map(int,input().split()))\nchest = []\nbiceps= []\nback=[]\nchest.append(x[0::3])\nbiceps.append(x[1::3])\nback.append(x[2::3])\n\nif sum(*biceps) sum(*back):\n print('chest')\nelif sum(*chest)sum(*chest):\n print('back')\nelse:\n print('biceps')\n # print(sum(*chest), sum(*biceps),sum(*back))"}, {"source_code": "n = int(input())\nx = [int(i) for i in input().split()]\n\nchest = 0\nbicep = 0\nback = 0\n\nfor i in range(n):\n if i%3 == 0:\n chest += x[i]\n elif i%3 == 1:\n bicep+= x[i]\n elif i%3 == 2:\n back += x[i]\n\ny = [chest,bicep, back]\nm = max(y)\n\nif( m == chest):\n print(\"chest\")\nelif m == bicep:\n print(\"bicep\")\nelif m == back:\n print(\"back\")\n"}, {"source_code": "n = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\ntemp = 0\nmax = 0\nfor i in range(len(k)):\n\n if i%3 == 0:\n count1+=k[i]\n if count1 > max:\n temp = 'chest'\n\n elif i!=0 and i%2==0:\n count3+=k[i]\n if count3 > max:\n temp = 'back'\n else:\n count2+=k[i]\n if count2 > max:\n temp = 'biceps'\n\n\n\nprint(temp)\n\n\n\n\n"}, {"source_code": "a = int(input())\nx = list(map(int,input().split()))\nchest = []\nbiceps= []\nback=[]\nchest.append(x[0::3])\nbiceps.append(x[1::3])\nback.append(x[2::3])\n\nif sum(*biceps) sum(*back):\n print('chest')\n\nelif sum(*chest) < sum(*biceps) > sum(*chest):\n print('biceps')\nelif sum(*chest) < sum(*back) > sum(*chest):\n print('back')\n # print(sum(*chest), sum(*biceps),sum(*back))"}, {"source_code": "n = int(input())\nnum = input()\na = []\n\n\ndef get_the_data(count, num, arr):\n for 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 return arr\n\n\narr = get_the_data(0, num, a)\nchest = 0\nbicep = 0\nback = 0\ni = 1\nwhile i <= n:\n if i % 3 == 0:\n back += arr[i-1]\n elif i % 2 == 0:\n bicep += arr[i-1]\n else:\n chest += arr[i-1]\n i += 1\n\nif chest >back and chest > bicep:\n print('chest')\nelif bicep > chest and bicep > back:\n print('biceps')\nelse:\n print('back')\n\n"}, {"source_code": "##n=int(input())\n##a=list(map(int,input().split()))\n##count=1\n##c=0 #chest\n##f=0 #biceps\n##h=0 #back\n##for i in range(len(a)):\n## if count==1:\n## c+=a[i]\n## count+=1\n## elif \n## \n## \n## \n## print('i',i,'i+1',i+1,'ai',a[i],'c',c,'f',f,'h',h)\n##\n##if hf:\n## print('chest')\n##elif hc:\n## print('biceps')\n##else:\n## print('back')\n\n\nn= int(input())\na = list(map(int, input().split()))\ncount=1\nchest,biceps,back=0,0,0\nfor i in range(len(a)):\n if count==1:\n chest+=a[i]\n count+=1\n elif count==2:\n biceps+=a[i]\n count += 1\n elif count==3:\n back+=a[i]\n count =1\nif chest > biceps > back:\n print('chest')\nif biceps > chest > back:\n print('biceps')\nif back > chest > biceps:\n print('back')\n"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ng=0\nb=0\ns=0\ncount=0\nfor i in a:\n count+=1\n if count==1:\n g=g+i\n if count==2:\n b=b+i\n if count==3:\n s=s+i\n if count>3:\n count=1\nif max(g,b,s)==g:\n print('chest')\nelse:\n if max(g,b,s)==b:\n print('biceps')\n else:\n print('back')\n \n \n \n\n \n"}, {"source_code": "n=input();l=map(int,raw_input().split())\nd={'biceps':0,'chest':0,'back':0}\nfor i in range(n):\n if (i+1)%3==0: d['back']+=1\n elif (i+1)%2==0: d['biceps']+=1\n else: d['chest']+=1\nfor i in d:\n if d[i]==max(d.values()):\n print i\n break\n"}, {"source_code": "'''\nAmirhossein Alimirzaei\nTelegram : @HajLorenzo\nInstagram : amirhossein_alimirzaei\nUniversity of Bojnourd\n'''\n\ninput()\ntmp=list(map(int,input().split()))\nC=[0,0,0]\ni=0\nfor _ in tmp:\n C[i]+=_\n i+=1\n if i==3:\n i=0\nprint(C)\nprint([\"chest\",\"biceps\",\"back\"][C.index(max(C))])\n\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nif len(a) % 2 == 0:\n print('biceps')\nelif len(a) % 3 == 0:\n print('back')\nelse:\n print('chest')"}, {"source_code": "t = int(input())\nx = list(map(int, input().split()))\nind = x.index(max(x))+1\nif (ind%3==1 or ind%3==0):\n\tprint (\"chest\")\nelif (ind%3==2):\n\tprint (\"biceps\")\nelse:\n\tprint (\"back\")"}, {"source_code": "# Greg's Workout\ndef workout(arr):\n chest = 0\n biceps = 0\n back = 0\n flag = 1\n for i in arr:\n if flag == 1:\n chest += i\n flag +=1\n elif flag == 2:\n biceps += i\n flag += 1\n elif flag == 3:\n back += i\n flag = 0\n big = max(chest, biceps, back)\n if chest == big:\n return \"chest\"\n elif biceps == big:\n return 'biceps'\n return 'back'\n\n\n\n\nn = int(input())\nar = list(map(int, input().rstrip().split()))\nprint(workout(ar))"}, {"source_code": "n = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\ntemp = 0\nmax = 0\nfor i in range(len(k)):\n\n if i%3 == 0:\n count1+=k[i]\n if count1 > max:\n temp = 'chest'\n\n elif i!=0 and i%2==0:\n count3+=k[i]\n if count3 > max:\n temp = 'back'\n else:\n count2+=k[i]\n if count2 > max:\n temp = 'biceps'\n\n\n\nprint(temp)\n\n\n\n\n"}, {"source_code": "\n\nn = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\nmax = 0\ntemp = 0\nfor i in range(0,len(k),3):\n count1+=1\n if count1>max:\n max = count1\n temp = 'ches'\n\n\nfor i in range(1,len(k),3):\n count2+=1\n if count2>max:\n max = count2\n temp = 'biceps'\n\nfor i in range(2,len(k),3):\n count3+=1\n if count3>max:\n max = count3\n temp = 'back'\n\nprint(temp)\n\n\n\n"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\n\ncount = [0] * 3\n_max = 0\n_max_idx = 0\nfor i, v in enumerate(l):\n idx = i % 3\n count[idx] += v\n if count[idx] > _max:\n _max = count[idx]\n _max_idx = idx\nprint(['chest', 'bicepts', 'back'][_max_idx])\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))[:n]\nc = 1\nch = 0\nbc = 0\nbk = 0\nfor i in a:\n if c%2==0:\n bc += i\n c +=1\n elif c%3==0:\n bk += i\n c += 1\n else:\n ch += i\n c += 1\nw = [ch,bc,bk]\nw.sort()\nif w[2]==bk:\n print(\"back\")\nelif w[2]==bc:\n print(\"bicepts\")\nelse:\n print(\"chest\")"}, {"source_code": "#!/usr/bin/env python\nn = int(raw_input().split()[0])\n\nl = map(int, raw_input().split())\na=0;b=0;c=0\nfor i in xrange(len(l)):\n\tx = i%3\n\tif x==0:\n\t\ta+=i\n\telif x==1:\n\t\tb+=i\n\telse:\n\t\tc+=i\nif a>b and a>c:\n\tprint \"chest\"\nelif b>a and b>c:\n\tprint \"biceps\"\nelse:\n\tprint \"back\"\n"}, {"source_code": "n=int(input())\na=list(map(int, input().split()))\nb=[\"chest\",\"biceps\",\"back\"]\nif len(a)<=3:\n print(b[a.index(max(a))])\nelse:\n i=0\n j=0\n k=0\n for _ in range(len(a)):\n if _%3==0:\n i+=1\n elif _%3==1:\n j+=1\n else:\n k+=1\n if i==max(i,j,k):\n print(\"chest\")\n elif j==max(i,j,k):\n print(\"biceps\")\n else:\n print(\"back\")"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ng=0\nb=0\ns=0\ncount=0\nfor i in a:\n count+=1\n if count==1:\n g=g+i\n if count==2:\n b=b+i\n if count==3:\n s=s+i\n if count>3:\n count=1\nif max(g,b,s)==g:\n print('chest')\nelse:\n if max(g,b,s)==b:\n print('biceps')\n else:\n print('back')\n \n \n \n\n \n"}, {"source_code": "a = int(input())\nl = list(map(int, input().split()))\nx, y, z = 0, 0, 0\n\nfor i in range(1,a+1):\n if i % 3 == 1:\n x += i\n elif i % 3 == 2:\n y += i\n else:\n z += i\n\nif x > y and x > z:\n print(\"chest\")\nelif y > x and y > z:\n print(\"biceps\") \nelse:\n print(\"back\") "}, {"source_code": "a=int(input())\nb=list(map(int, input().split()))\nch=0\nbi=0\nba=0\n\nfor i in range(1,len(b)+1):\n if i%2==0:\n bi+=b[i-1]\n elif i%3==0:\n ba+=b[i-1]\n else:\n ch+=b[i-1]\nif (ch>bi and ch>ba):\n print(\"chest\")\nelif (bi>ch and bi>ba):\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "n=int(input())\nj=n+1\na=[1]*(n+1)\na=list(map(int,input().split()))\nbi=0\nba=0\nch=0\nif n==1:\n ch=ch+a[0]\nelif n==2:\n ch=ch+a[0]\n bi=bi+a[1]\nelse:\n for i in range(0,int(n/3),3):\n ch=ch+a[i]\n bi=bi+a[i+1]\n ba=ba+a[i+2]\n t=n%3\n if t==1:\n ch=ch+a[i]\n elif t==2:\n ch=ch+a[i]\n bi=bi+a[i+1]\nif bi>ba:\n if bi>ch:\n print(\"biceps\")\n elif ch>bi:\n print(\"chest\")\nelif ba>ch:\n print(\"back\")\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nc = 0\nb = 0\nba = 0\n\nfor i in range(0,n,3):\n\tc+=s[i]\nfor i in range(1,n,3):\n\tb+=s[i]\n\nfor i in range(2,n,3):\n\tba+=1\n\nprint(c,b)\nif c>b and c>ba:\n\tprint(\"chest\")\nelif b>ba and b>c :\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")\n"}, {"source_code": "##n=int(input())\n##a=list(map(int,input().split()))\n##count=1\n##c=0 #chest\n##f=0 #biceps\n##h=0 #back\n##for i in range(len(a)):\n## if count==1:\n## c+=a[i]\n## count+=1\n## elif \n## \n## \n## \n## print('i',i,'i+1',i+1,'ai',a[i],'c',c,'f',f,'h',h)\n##\n##if hf:\n## print('chest')\n##elif hc:\n## print('biceps')\n##else:\n## print('back')\n\n\nn= int(input())\na = list(map(int, input().split()))\ncount=1\nchest,biceps,back=0,0,0\nfor i in range(len(a)):\n if count==1:\n chest+=a[i]\n count+=1\n elif count==2:\n biceps+=a[i]\n count += 1\n elif count==3:\n back+=a[i]\n count =1\nif chest > biceps > back:\n print('chest')\nif biceps > chest > back:\n print('biceps')\nif back > chest > biceps:\n print('back')\n"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nfor i in range(n):\n arr[i]=arr[i]%3\nm={0:0,1:0,2:0}\nfor i in arr:\n m[i]+=1\nv=list(m.values())\n# print(m)\nif v.index(max(v))==0:\n print(\"chest\")\nelif v.index(max(v))==2:\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "n=input();l=map(int,raw_input().split())\nd={'biceps':0,'chest':0,'back':0}\nfor i in range(n):\n if (i+1)%3==0: d['back']+=1\n elif (i+1)%2==0: d['biceps']+=1\n else: d['chest']+=1\nfor i in d:\n if d[i]==max(d.values()):\n print i\n break\n"}, {"source_code": "n=int(input())\np=list(map(int,input().split()))\nc=0\nbic=0\nback=0\nif n==1:\n\tc+=p[0]\nelif n==2:\n\tc+=p[0]\n\tbic+=p[1]\nelse:\n\tfor i in range(0,n-2,3):\n\t\tc+=p[i]\n\t\tif i+1 backs:\n if chests> biceps:\n print(\"chest\")\nelif backs > chests:\n if backs > biceps:\n print(\"back\")\nelif biceps > backs:\n if biceps > chests:\n print(\"biceps\") "}, {"source_code": "t=int(input())\na=list(map(int,input().split()))\nchest=0\nbiceps=0\nback=0\nfor i in range(0,t,3):\n chest=chest+a[i]\n if i+1biceps and chest>back:\n print(\"chest\")\nif biceps>chest and biceps>back:\n print(\"biceps\")\nif back>biceps and biceps>chest:\n print(\"back\")"}, {"source_code": "t=int(input())\na=list(map(int,input().split()))\nchest=0\nbiceps=0\nback=0\nfor i in range(0,t,3):\n chest=chest+a[i]\n if i+1biceps and chest>back:\n print(\"chest\")\nif biceps>chest and biceps>back:\n print(\"biceps\")\nif back>biceps and biceps>chest:\n print(\"back\")"}, {"source_code": "n=int(input())\nj=n+1\na=[0]*n\na=list(map(int,input().split()))\nbi=0\nba=0\nch=0\nif n==1:\n ch=ch+a[0]\nelif n==2:\n ch=ch+a[0]\n bi=bi+a[1]\nelse:\n j=0\n for i in range(0,int(n/3)):\n ch=ch+a[j]\n bi=bi+a[j+1]\n ba=ba+a[j+2]\n j=j+3\n t=n%3\n if t==1:\n ch=ch+a[n-t]\n elif t==2:\n ch=ch+a[n-t]\n bi=bi+a[n-t+1]\nprint(ch,bi,ba)\nif ch>=bi:\n if ch>=ba:\n print(\"chest\")\n else:\n print(\"back\")\nelif bi>=ba:\n print(\"biceps\")\nelse:\n print(\"back\")\n"}, {"source_code": "d={\"chest\":0,\"biceps\":0,\"back\":0}\nn=int(input())\np=input()\nl=p.split()\nfor i in range(len(l)):\n l[i]=int(l[i])\n if l[i]%3==0:\n d[\"chest\"]+=l[i]\n elif i%3==1:\n d[\"biceps\"]+=l[i]\n else:\n d[\"back\"]+=l[i]\nkey_max = max(d.keys(), key=(lambda k: d[k]))\nprint(key_max)\n \n"}, {"source_code": "def getMostExercised():\n numberofExercies=input('')\n repeats=raw_input('').split(' ')\n muscles=[0,0,0]\n for x in repeats:\n ind=repeats.index(x)\n if ind%3==0:\n muscles[0]+=eval(x)\n elif ind%3==2:\n muscles[2]+=eval(x)\n else:\n muscles[1]+=eval(x)\n if muscles[0]>muscles[1] and muscles[0]>muscles[2]:\n print \"chest\"\n elif muscles[1]>muscles[2] and muscles[1]>muscles[0]:\n print \"biceps\"\n else:\n print\"back\"\ngetMostExercised()"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\nchest = 0\nbiceps = 0\nback = 0\nchest = l[::3]\nbiceps = l[1::3]\nback = l[3::3]\nchest = sum(chest)\nbiceps = sum(biceps)\nback = sum(back)\nif biceps > back and biceps > chest:\n print('biceps')\nelif chest > biceps and chest > back:\n print('chest')\nelse:\n print('back')"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nfor i in range(n):\n arr[i]=arr[i]%3\nm={0:0,1:0,2:0}\nfor i in arr:\n m[i]+=1\nv=list(m.values())\n# print(m)\nif v.index(max(v))==0:\n print(\"chest\")\nelif v.index(max(v))==2:\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "n=int(input())\na=list(map(int,input().split()))\ng=0\nb=0\ns=0\ncount=0\nfor i in a:\n count+=1\n if count==1:\n g=g+i\n if count==2:\n b=b+i\n if count==3:\n s=s+i\n if count>3:\n count=0\nif max(g,b,s)==g:\n print('chest')\nelse:\n if max(g,b,s)==b:\n print('biceps')\n else:\n print('back')\n \n \n \n\n \n"}, {"source_code": "no = int(input())\n\nx=list(map(int,input().split()))\n\nchest=0\nbicep=0\nback=0\n\nfor i in range(0,no,3):\n\tchest+=x[i]\n\nfor i in range(1,no,3):\n\tbicep+=x[i]\n\t\nfor i in range(2,no,3):\n\tback+=x[i]\n\t\n\t\nif((chest>bicep and chest>back)):\n\tprint(\"chest\")\nelif((bicep>chest and bicep>back)):\n\tprint(\"bicep\")\nelif((back>chest and back>bicep)):\n\tprint(\"back\")"}, {"source_code": "n = int(input())\nc,bi,b = 0,0,0\nx = list(map(int,input().split()))\nresult ={}\ncounter =1\nfor i in x:\n if counter in result.keys():\n result[counter] +=i\n else:\n result[counter] =i\n counter +=1\n if counter>3:\n counter =0\nl = max(result.values())\nif result[1] ==l:\n print(\"chest\")\nelif result[2] ==l:\n print(\"biceps\")\nelse:\n print(\"back\")\n \n\n"}, {"source_code": "\nchest ,biceps, back = 0,0,0\nn = int(input())\n\nl = list(map(int,input().split()))\n\nfor i in range(0,n,3):\n\tchest += i\n\nfor i in range(1,n,3):\n\tbiceps+= i\n\nfor i in range(2,n,3):\n\tback += i\n\nif chest > back and chest > biceps:\n\tprint('chest')\nelif back > chest and back > biceps:\n\tprint('back')\nelse:\n\tprint('biceps')"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\na, b, c = 0, 0, 0\ni = 1\nwhile i < n:\n\ta += A[i - 1]\n\ti += 3\ni = 1\nwhile i < n:\n\tb += A[i - 1]\n\ti += 3\ni = 1\nwhile i < n:\n\tc += A[i - 1]\n\ti += 3\nif a >= b and a >= c:\n\tprint(\"back\")\nelif b >= a and b >= c:\n\tprint(\"biceps\")\nelse:\n\tprint(\"chest\")"}, {"source_code": "x=int(input());input()\nif x%3==1:print(\"chest\")\nelif x%3==2:print(\"biceps\")\nelse:print(\"back\")"}, {"source_code": "n = int(input())\nl = list(map(int, input().split()))\n\ncount = [0] * 3\n_max = 0\n_max_idx = 0\nfor i, v in enumerate(l):\n idx = i % 3\n count[idx] += v\n if count[idx] > _max:\n _max = count[idx]\n _max_idx = idx\nprint(['chest', 'bicepts', 'back'][_max_idx])\n"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\na, b, c = 0, 0, 0\ni = 1\nwhile i <= n:\n\ta += A[i - 1]\n\ti += 3\ni = 2\nwhile i <= n:\n\tb += A[i - 1]\n\ti += 3\ni = 3\nwhile i <= n:\n\tc += A[i - 1]\n\ti += 3\nif a >= b and a >= c:\n\tprint(\"back\")\nelif b >= a and b >= c:\n\tprint(\"biceps\")\nelse:\n\tprint(\"chest\")"}, {"source_code": "n = int(input())\nA = list(map(int, input().split()))\na, b, c = 0, 0, 0\ni = 1\nwhile i < n:\n\ta += A[i - 1]\n\ti += 3\ni = 1\nwhile i < n:\n\tb += A[i - 1]\n\ti += 3\ni = 1\nwhile i < n:\n\tc += A[i - 1]\n\ti += 3\nif a >= b and a >= c:\n\tprint(\"back\")\nelif b >= a and b >= c:\n\tprint(\"biceps\")\nelse:\n\tprint(\"chest\")"}, {"source_code": "n = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\ntemp = 0\nmax = 0\nfor i in range(len(k)):\n\n if i%3 == 0:\n count1+=k[i]\n if count1 > max:\n temp = 'chest'\n\n elif i!=0 and i%2==0:\n count3+=k[i]\n if count3 > max:\n temp = 'back'\n else:\n count2+=k[i]\n if count2 > max:\n temp = 'biceps'\n\n\n\nprint(temp)\n\n\n\n\n"}, {"source_code": "# import sys\n# sys.stdin=open('input.in','r')\n# sys.stdout=open('output.out','w')\ns=int(input())\nl=list(map(int,input().strip().split()[:s]))\nl.insert(0,\"#$@%\")\nbicep=chest=back=0\nfor x in range(1,len(l)):\n\tif x%3==0:\n\t\tback+=l[x]\n\telif x%2==0 :\n\t\tbicep+=l[x]\n\telse:\n\t\tchest+=l[x]\nif max(chest,bicep,back)==chest:\n\tprint('chest')\nelif max(chest,bicep,back)==bicep:\n\tprint('biceps')\nelse:\n\tprint('back')"}, {"source_code": "n=int(input())\nx=[int(p) for p in input().split(\" \")]\nfor i in range(n):\n if (x[i]==max(x)):\n j=i+1\nif (j%2==0):\n print(\"biceps\")\nelif (j%3==0):\n print(\"back\")\nelse:\n print(\"chest\") "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nif len(a) % 2 == 0:\n print('biceps')\nelif len(a) % 3 == 0:\n print('back')\nelse:\n print('chest')"}, {"source_code": "n=int(raw_input())\n\nexercises=raw_input().split()\nchest=0\nback=0\nbiceps=0\n\nfor i in range(n):\n if i%3==0:\n chest += int(exercises[i-1])\n elif i%3==1:\n back += int(exercises[i-1])\n else:\n biceps += int(exercises[i-1])\n\nif chest > biceps and chest > back:\n print 'chest'\n\nif back > biceps and back > chest:\n print 'back'\n\nif biceps > chest and biceps > back:\n print 'biceps'\n \n"}, {"source_code": "n=int(input())\nx=[int(p) for p in input().split(\" \")]\nfor i in range(n):\n if (x[i]==max(x)):\n j=i+1\nif (j%2==0):\n print(\"biceps\")\nelif (j%3==0):\n print(\"back\")\nelse:\n print(\"chest\") "}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nsum1=0\nsum2=0\nsum3=0\nfor i in range(0,n,2):\n sum1=sum1+l[i]\nfor i in range(1,n,2):\n sum2=sum2+l[i]\nfor i in range(2,n,2):\n sum3=sum3+l[i]\nif sum1>sum2:\n if sum3>sum1:\n print(\"back\")\n if sum1>sum3:\n print(\"chest\")\nif sum2>sum3:\n if sum2>sum1:\n print(\"biceps\")\n else:\n print(\"chest\")\n"}, {"source_code": "n = int(input())\na = list(map(int,input().split()))\nfrom collections import defaultdict\nd = defaultdict(list)\nfor i in range(0,len(a)):\n m = i%3\n d[m].append(a[i])\nd = dict(d)\nprint(d)\nx = max(d.items(),key=lambda x:sum(x[1]))[0]\n\nif x == 0:\n print(\"chest\")\nelif x == 1:\n print(\"biceps\")\nelif x == 2:\n print(\"back\")"}, {"source_code": "input()\na = list(map(int, input().split()))\nch = 0\nbi = 0\nba = 0\nfor i in range(0, len(a), 4):\n ch += i\nfor j in range(1, len(a), 4):\n bi += j\nfor k in range(2, len(a), 4):\n ba += k\nif max(ch,bi,ba) == ch:print(\"chest\")\nelif max(ch,bi,ba) == bi:print(\"biceps\")\nelse:print(\"back\")"}, {"source_code": "n=int(input())\np=list(map(int,input().split()))\nc=0\nbic=0\nback=0\nif n==1:\n\tc+=p[0]\nelif n==2:\n\tc+=p[0]\n\tbic+=p[1]\nelse:\n\tfor i in range(0,n-2,3):\n\t\tc+=p[i]\n\t\tif i+1 y and x > z:\n print(\"chest\")\nelif y > x and y > z:\n print(\"biceps\") \nelse:\n print(\"back\") "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nmuscles = [0, 0, 0]\nanswer = [\"Chest\", \"Biceps\", \"Back\"]\n\nmuscles[0] = sum(a[::3]) # chest\nmuscles[1] = sum(a[1::3]) # biceps\nmuscles[2] = sum(a[2::3]) # back\n\nstrongest = muscles.index(max(muscles))\nprint(answer[strongest])\n"}, {"source_code": "a=int(input())\nl=list(map(int,input().split()))\nch=0\nbic=0\nbac=0\ns=len(l)\ncount=0\nfor i in range(s):\n if count%3==0:\n i=0\n count=0\n if (i+1)%3==0:\n bac+=l[i]\n elif (i+1)%2==0:\n bic+=l[i]\n else:\n ch+=l[i]\n count+=1\ne=max([bac,bic,ch])\nif e==bac:\n print('back')\nelif e==bic:\n print('biceps')\nelse:\n print('chest')\n\n"}, {"source_code": "x=int(input());input()\nif x%3==1:print(\"chest\")\nelif x%3==2:print(\"biceps\")\nelse:print(\"back\")"}, {"source_code": "n = int(input())\na = []\na += map(int,input().split())\nc = 0\nbic = 0\nbk = 0\nfor i in range(0,n,3):\n\tc += a[i]\n\tif i+1 < len(a):\n\t\tbic += a[i+1]\n\tif i+2 < len(a):\n\t\tbk += a[i+2]\n\tprint(i,c,bic,bk)\t\nif max(c,bic,bk) == c:\n\tprint(\"chest\")\nelif max(c,bic,bk) == bic:\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")"}, {"source_code": "n=int(input())\np=list(map(int,input().split()))\nc=0\nbic=0\nback=0\nif n==1:\n\tc+=p[0]\nelif n==2:\n\tc+=p[0]\n\tbic+=p[1]\nelse:\n\tfor i in range(0,n-2,3):\n\t\tc+=p[i]\n\t\tif i+1bi and c>b:\n print('chest')\nelif bi>c and bi>b:\n print('biceps')\nelif b>c and b>bi:\n print('back')\n"}, {"source_code": "n = int (input ())\na = list (map (int, input ().split ()))\n\nchest = []\nbiceps = []\nback = []\n\nfor i in range (1,n+1):\n\tif i%3 == 1:\n\t\tchest.append (i-1)\n\telif i%3 == 2:\n\t\tbiceps.append (i-1)\n\telse:\n\t\tback.append (i-1)\n\nx = sum (chest)\ny = sum (biceps)\nz = sum (back)\n\nif max (x,y,z) == x:\n\tprint ('chest')\nelif max (x,y,z) == y:\n\tprint ('biceps')\nelse:\n\tprint ('back')\n"}, {"source_code": "n=int(input())\nlst=list(map(int,input().split()))\nif n%3==1:\n print(\"chest\")\nelif n%3==2:\n print(\"biceps\")\nelif n%3==0:\n print(\"back\")"}, {"source_code": "a = int(input())\nl = list(map(int, input().split()))\nx, y, z = 0, 0, 0\n\nfor i in range(1,a+1):\n if i % 3 == 1:\n x += i\n elif i % 3 == 2:\n y += i\n else:\n z += i\n\nif x > y and x > z:\n print(\"chest\")\nelif y > x and y > z:\n print(\"biceps\") \nelse:\n print(\"back\") "}, {"source_code": "n=int(input())\nj=n+1\na=[1]*(n+1)\na=list(map(int,input().split()))\nbi=0\nba=0\nch=0\nif n==1:\n ch=ch+a[0]\nelif n==2:\n ch=ch+a[0]\n bi=bi+a[1]\nelse:\n for i in range(0,int(n/3),3):\n ch=ch+a[i]\n bi=bi+a[i+1]\n ba=ba+a[i+2]\n t=n%3\n if t==1:\n ch=ch+a[i]\n elif t==2:\n ch=ch+a[i]\n bi=bi+a[i+1]\nif bi>ba:\n if bi>ch:\n print(\"biceps\")\n elif ch>bi:\n print(\"chest\")\nelif ba>ch:\n print(\"back\")\n"}, {"source_code": "a=int(input())\n\nb=list(map(int,input().split()))\n\nch=0\nbi=0\nba=0\n\nfor i in range(len(b)):\n if(i<3):\n if(i==0):\n ch+=b[i]\n if(i==1):\n bi+=b[i]\n if(i==2):\n ba+=b[i]\n else:\n if(i%3==0):\n ch+=b[i]\n if(i%3==1):\n bi+=b[i]\n if(i%3==2):\n ba+=b[i]\n\nif(ch>bi and ch>ba):\n print('chest')\n\nelif(chba):\n print('bisceps')\n\nelif(ba>ch and ba>bi):\n print('back')"}, {"source_code": "n=int(input())\nl=[int(i) for i in input().split()]\na=0;b=0;c=0\nj=1\nfor i in range(n):\n if i+1==j:\n a+=l[i]\n elif i+1==j:\n b+=l[i]\n else:\n c+=l[i]\n j+=1\nif max(a,b,c)==a:\n print(\"chest\")\nelif max(a,b,c)==b:\n print(\"biceps\")\nelse:\n print(\"back\")"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nchest = 0\nbiceps = 0\nback = 0\nif n >= 3:\n for i in range(0, n, 3):\n chest += a[i]\n for i in range(1, n, 3):\n biceps += a[i]\n for i in range(2, n, 3):\n back += a[i]\nelif n == 2:\n for i in range(0, n + 1, 3):\n chest += a[i]\n for i in range(1, n + 1, 3):\n biceps += a[i]\nelif n == 1:\n print(a[0])\nif chest > biceps and chest > back:\n print('chest')\nelif biceps > chest and biceps > back:\n print('biceps')\nelif back > biceps and back > chest:\n print('back')\n"}, {"source_code": "n = int(input())\n\narr = list(map(int, input().split()))\n\ni = 1\nchest, bicep, back = 0, 0, 0\n\nfor x in arr:\n\tif i == 1:\n\t\tchest += x\n\t\ti += 1\n\telif i == 2:\n\t\tbicep += x\n\t\ti += 1\n\telif i == 3:\n\t\tback += x\n\t\ti += 1\n\tif i > 3:\n\t\ti = 1\n\nif chest >= bicep >= back:\n\tprint(\"chest\")\nelif bicep >= chest >= back:\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")\n"}, {"source_code": "\nn = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\ntemp = 0\nmax = 0\nfor i in range(len(k)):\n\n if i%3 == 0:\n count1+=k[i]\n if count1 > max:\n max = count1\n temp = 'chest'\n\n elif i!=0 and i%2==0:\n count3+=k[i]\n if count3 > max:\n max = count3\n temp = 'back'\n else:\n count2+=k[i]\n if count2 > max:\n max = count2\n temp = 'biceps'\n\n\n\nprint(temp)\n\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nc = 0\nb = 0\nba = 0\n\nfor i in range(0,n,3):\n\tc+=s[i]\nfor i in range(1,n,3):\n\tb+=s[i]\n\nfor i in range(2,n,3):\n\tba+=1\n\nprint(c,b)\nif c>b and c>ba:\n\tprint(\"chest\")\nelif b>ba and b>c :\n\tprint(\"biceps\")\nelse:\n\tprint(\"back\")\n"}, {"source_code": "import sys\nn = input()\narr = map(int,sys.stdin.readline().split())\ni = 1\nchest = 0\nback = 0\nbiceps = 0\nwhile(i <= n):\n if(i%2 == 0):\n biceps += arr[i-1]\n elif(i%3 == 0):\n back += arr[i-1]\n else:\n chest += arr[i-1]\n i += 1\nlist = [chest,biceps,back]\nprint list\nc = list.index(max(list))\nprint c\nif(c == 0):\n print \"chest\"\nelif(c == 1):\n print \"biceps\"\nelse:\n print \"back\"\n"}, {"source_code": "t = int(input())\nx = list(map(int, input().split()))\nind = x.index(max(x))+1\nprint (ind)\nif (ind%3==1):\n\tprint (\"chest\")\nelif (ind%3==2):\n\tprint (\"biceps\")\nelif ind%3==0:\n\tprint (\"back\")"}, {"source_code": "n= int(input()) \nx = list(map(int, input().split()))\nchests=0\nbiceps=0\nbacks=0\nfor e in range(0,n,3):\n chests=chests+x[e]\nfor e1 in range(1,n,3):\n biceps=biceps+x[e1]\nfor e2 in range(2,n,3):\n backs=backs+x[e2]\nif chests > backs:\n if chests> biceps:\n print(\"chest\")\nelif backs > chests:\n if backs > biceps:\n print(\"back\")\nelif biceps > backs:\n if biceps > chests:\n print(\"biceps\") "}, {"source_code": "n = int(input())\n\nk = list(map(int,input().split()))\ncount1 = 0\ncount2 = 0\ncount3 = 0\nmax = 0\ntemp = 0\nfor i in range(0,len(k),3):\n count1+=k[i]\n if count1>max:\n max = count1\n temp = 'ches'\n\n\nfor i in range(1,len(k),3):\n count2+=k[i]\n if count2>max:\n max = count2\n temp = 'biceps'\n\nfor i in range(2,len(k),3):\n count3+=k[i]\n if count3>max:\n max = count3\n temp = 'back'\n\nprint(temp)\n\n\n\n"}, {"source_code": "x=int(input());input()\nif x%3==1:print(\"chest\")\nelif x%3==2:print(\"biceps\")\nelse:print(\"back\")"}], "src_uid": "579021de624c072f5e0393aae762117e"} {"nl": {"description": "You are given a bracket sequence $$$s$$$ (not necessarily a regular one). A bracket sequence is a string containing only characters '(' and ')'.A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters '1' and '+' between the original characters of the sequence. For example, bracket sequences \"()()\" and \"(())\" are regular (the resulting expressions are: \"(1)+(1)\" and \"((1+1)+1)\"), and \")(\", \"(\" and \")\" are not.Your problem is to calculate the number of regular bracket sequences of length $$$2n$$$ containing the given bracket sequence $$$s$$$ as a substring (consecutive sequence of characters) modulo $$$10^9+7$$$ ($$$1000000007$$$).", "input_spec": "The first line of the input contains one integer $$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 the half-length of the resulting regular bracket sequences (the resulting sequences must have length equal to $$$2n$$$). The second line of the input contains one string $$$s$$$ ($$$1 \\le |s| \\le 200$$$) \u2014 the string $$$s$$$ that should be a substring in each of the resulting regular bracket sequences ($$$|s|$$$ is the length of $$$s$$$).", "output_spec": "Print only one integer \u2014 the number of regular bracket sequences containing the given bracket sequence $$$s$$$ as a substring. Since this number can be huge, print it modulo $$$10^9+7$$$ ($$$1000000007$$$).", "sample_inputs": ["5\n()))()", "3\n(()", "2\n((("], "sample_outputs": ["5", "4", "0"], "notes": "NoteAll regular bracket sequences satisfying the conditions above for the first example: \"(((()))())\"; \"((()()))()\"; \"((()))()()\"; \"(()(()))()\"; \"()((()))()\". All regular bracket sequences satisfying the conditions above for the second example: \"((()))\"; \"(()())\"; \"(())()\"; \"()(())\". And there is no regular bracket sequences of length $$$4$$$ containing \"(((\" as a substring in the third example."}, "positive_code": [{"source_code": "M=10**9+7\nn=input()\ns=[c=='(' for c in raw_input()]\nm=len(s)\nz=[[0,0]]\nfor v in s:\n a=z[-1][v]\n z[-1][v]=len(z)\n z+=[z[a][:]]\nz[m]=[m,m]\ndp=[[0]*(m+1) for _ in range(n+1)]\ndp[0][0]=1\nfor _ in range(2*n):\n ndp=[[0]*(m+1) for _ in range(n+1)]\n for i in range(n+1):\n for j in range(m+1):\n if i>0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%M\n if i0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%M\n if i0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%MOD\n if i0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%M\n if i0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%MOD\n if i0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%M\n if i=mod:\n return (a+b)%mod\n return a+b\nn=int(input())*2\ns=input()\nd=[[0,0] for i in range(len(s)+1)]\naux=''\nfor i in range(len(s)):\n if s[i]=='(':\n d[i][1]=i+1\n x=aux+')'\n for j in range(1,i+2):\n if x[j::] ==s[0:len(x)-j]:\n d[i][0]=len(x[j::])\n break\n else:\n d[i][0]=i+1\n x=aux+'('\n for j in range(1,i+2):\n if x[j::] ==s[0:len(x)-j]:\n d[i][1]=len(x[j::])\n break\n aux+=s[i]\nd[len(s)][1]=len(s)\nd[len(s)][0]=len(s)\ndp=[[[0 for i in range(len(s)+1)] for j in range(n//2+1)] for k in range(n+1)]\ndp[0][0][0]=1\nmod=10**9+7\nfor i in range(n):\n for j in range(1,(n//2)+1):\n for k in range(len(s)+1):\n dp[i+1][j-1][d[k][0]]=add(dp[i][j][k],dp[i+1][j-1][d[k][0]])\n for j in range(n//2):\n for k in range(len(s)+1):\n dp[i+1][j+1][d[k][1]]=add(dp[i][j][k],dp[i+1][j+1][d[k][1]])\nprint(dp[n][0][len(s)]%mod)\n"}, {"source_code": "def add(a,b):\n if a+b>=mod:\n return (a+b)%mod\n return a+b\nn=int(input())*2\ns=input()\nd=[[0,0] for i in range(len(s)+1)]\naux=''\nfor i in range(len(s)):\n if s[i]=='(':\n d[i][1]=i+1\n x=aux+')'\n for j in range(1,i+2):\n if x[j::] ==s[0:len(x)-j]:\n d[i][0]=len(x[j::])\n break\n else:\n d[i][0]=i+1\n x=aux+'('\n for j in range(1,i+2):\n if x[j::] ==s[0:len(x)-j]:\n d[i][1]=len(x[j::])\n break\n aux+=s[i]\nd[len(s)][1]=len(s)\nd[len(s)][0]=len(s)\ndp=[[[0 for i in range(len(s)+1)] for j in range(n//2+1)] for k in range(n+1)]\ndp[0][0][0]=1\nmod=10**9+7\nfor i in range(n):\n for j in range(1,(n//2)+1):\n for k in range(len(s)+1):\n dp[i+1][j-1][d[k][0]]=(dp[i][j][k]+dp[i+1][j-1][d[k][0]])%mod\n for j in range(n//2):\n for k in range(len(s)+1):\n dp[i+1][j+1][d[k][1]]=(dp[i][j][k]+dp[i+1][j+1][d[k][1]])%mod\nprint(dp[n][0][len(s)]%mod)\n"}], "negative_code": [{"source_code": "MOD=10**9+7\nn=int(input())\ns=[c=='(' for c in input()]\nm=len(s)\nz=[[0,0]]\nfor v in s:\n n=z[-1][v]\n z[-1][v]=len(z)\n z.append(z[n][:])\nz[m][0]=z[m][1]=m\ndp=[[0 for _ in range(m+1)] for _ in range(n+1)]\ndp[0][0]=1\nfor _ in range(2*n):\n ndp=[[0 for _ in range(m+1)] for _ in range(n+1)]\n for i in range(n+1):\n for j in range(m+1):\n if i>0:ndp[i-1][z[j][0]]=(ndp[i-1][z[j][0]]+dp[i][j])%MOD\n if i0 ):\n if n=j :\n\t\t\tif y%j==0:\n\t\t\t\tt=math.floor(y/j)\n\t\t\t\tcount=count+t\n\t\t\t\ty=y%j\n\t\t\t\tbreak\n\t\t\telif y%j>0 and y>j and y-j >=2:\n\t\t\t\ty=y-j\n\t\t\t\tcount=count+1\n\t\t\telse:\n\t\t\t\tbreak\n\t\t\t\n\t\t\n\tprint(count)\t\n\t\t\t\n\t\t\n"}, {"source_code": "t=int(input())\nfor _ in range(t):\n n=int(input())\n print(n//7+1)"}, {"source_code": "for i in xrange(input()):\n print input()/2"}, {"source_code": "t = int(input())\nfor i in range(t):\n num = int(input())\n x = num / 7\n if (num % 7):\n x += 1\n print x"}, {"source_code": "x=int(input())\nfor i in range(0,x):\n n=int(input())\n if(n%7==0):\n print(n//7)\n else:\n print((n//7)+1)\n"}, {"source_code": "t = int(input())\nnums = [int(input()) for i in range(t)]\nfor k in nums:\n\tif k%2==0:\n\t print(int(k/2))\n\telif k==3:\n\t print(\"1\")\n\telse:\n\t print(int((k-3)/2))"}, {"source_code": "a=[2,3,4,5,6,7]\nx=input()\nt=0\nR=[]\nwhile t7:\n if y%7!=0:\n rounds=y//7 +1\n else:\n rounds=y//7\n else:\n rounds=1\n R.append(rounds)\n t+=1\nfor r in R:\n print(r)"}, {"source_code": "n = int(input())\n\nfor i in range(n):\n count = 0\n a = int(input())\n count += int(a/2)\n print(count)\n"}, {"source_code": "#!/usr/bin/python2\n\nfrom heapq import *\n\ndef ir(): return int(raw_input())\ndef ia(): return map(int, raw_input().split())\n\nn = ir()\nfor i in xrange(n):\n x = ir()\n \n ans = 0\n while x > 3:\n x -= 2\n ans += 1\n if x == 2:\n ans += 1\n else:\n ans += 1\n print ans\n"}, {"source_code": "for i in range(int(input())):\n print(int(input())//2)"}, {"source_code": "n = int(input())\nfor i in range(n):\n x = int(input())\n print(int(x/2))"}, {"source_code": "test_case = int(input())\n\nfor _ in range(test_case):\n x = int(input())\n\n print((x + 7 - 1)//7)"}, {"source_code": "t = input()\n\nwhile t > 0:\n\n\tt = t - 1\n\t\n\tk = input()\n\n\t\n\tprint (k/6) + ((k%6)/5) + (((k%6)%5)/4) + ((((k%6)%5)%4)/3) + (((((k%6)%5)%4)%3)/2)\n"}, {"source_code": "def main():\n for _ in range(int(input())):\n n = int(input()) + 1\n l = [99] * n\n l[0] = 0\n for step in range(7, 1, -1):\n for i, b in enumerate(l[:]):\n for c, j in enumerate(range(i, n, step), b):\n l[j] = min(l[j], c)\n if l[-1] < 99:\n break\n print(l[-1])\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from sys import stdin\nfrom sys import stdout\n\nsprint = stdout.write\nsinput = stdin.readline\n\n\ndef func():\n n = int(input())\n c = 0\n if n%2 == 1:\n c = 1\n n -= 3\n c += n//2\n\n print(c)\n\n\nif __name__ == \"__main__\":\n t = int(sinput())\n while t != 0:\n t -= 1\n func()\n"}, {"source_code": "for _ in range(input()):\n\tprint input()/2"}, {"source_code": "c= int(input())\nfor k in range(c):\n d = int(input())\n if d % 2 == 0:\n print(d // 2)\n else:\n print(((d - 3) // 2)+ 1)"}, {"source_code": "def solve():\n num = int(input())\n rolls = 0\n if 2 <= num < 7:\n print('1')\n else:\n if ( num%7 == 1 ):\n print((int(num/7)-1) + 2 )\n elif ( num%7 == 0 ):\n print( int(num/7) )\n else:\n print(int(num/7) + 1)\n \n \n\nnum = int(input())\nfor x in range(num):\n solve()"}, {"source_code": "x = int(input())\nfor i in range(x):\n\ta = int(input())\n\tk = 0\n\tif a > 7:\n\t\tt = int(a/7)\n\t\ta = a - 7*t\n\t\tk = k + t\n\tif a > 0:\n\t\ta = 0\n\t\tk = k + 1\n\tprint(k)"}, {"source_code": "x=int(input())\nfor i in range(0,x):\n n=int(input())\n if(n%7==0):\n print(n//7)\n else:\n print((n//7)+1)\n"}, {"source_code": "n=int(input())\nfor i in range(n):\n x=int(input())\n if(x<=7):\n print(1)\n else:\n d=x//7\n if(x%7==0):\n print(d)\n else:\n print(d+1)"}, {"source_code": "for i in range(int(input())):\n print(int(input())//2)"}, {"source_code": "# Dice Rolling\ndef dice(x):\n if x <= 7:\n return 1\n if x % 2 == 0:\n return x // 2\n ans = 0\n while True:\n if x % 2 == 0:\n return (ans + (x // 2))\n elif x >= 7:\n x -= 7\n ans += 1\n elif x >= 5:\n x -= 5\n ans += 1\n elif x >= 3:\n x -= 3\n ans += 1\n \nt = int(input())\nfor i in range(t):\n x = int(input())\n print(dice(x))"}, {"source_code": "for i in range(int(input())):\n n = int(input())\n if(n == 2 or n == 3 or n == 4 or n == 5 or n == 6 or n == 7):\n print(1)\n else:\n print(round(n / 7) + 1)"}, {"source_code": "def dice(q):\n div = q / 2\n return div\n\n\nn = int(raw_input())\nqueries = []\nfor i in range(n):\n q = int(raw_input())\n queries.append(q)\n\nfor q in queries:\n print(dice(q))\n"}, {"source_code": "for i in range(int(input())):print(int(input())//2)"}, {"source_code": "for _ in range(int(input())):\n print(int(input())//2)\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\nt = ni()\nfor _ in range(t):\n x = ni()\n d, m = divmod(x, 7)\n print d if not m else d + 1"}, {"source_code": "a=[1,1,1,1,1,1]+94*[0]\nfor i in range ( 6 , 100):\n a[i]=min([a[i-7],a[i-6],a[i-5],a[i-4],a[i-3],a[i-2]])+1\nq=[]\nfor i in range(int(input())):\n q+=[a[int(input())-1]]\nfor i in q:\n print(i)"}, {"source_code": "n=int(input())\nfor x in range(n):\n\ts=0\n\ta=int(input())\n\tfor x in range(2,8):\n\t\tif a%(9-x)==0:\n\t\t\ts+=(a//(9-x))\n\t\t\tbreak\n\t\telif a%(9-x)!=1:\n\t\t\ts+=(a//(9-x))\n\t\t\ta=a%(9-x)\n\tprint(s)"}, {"source_code": "for _ in range(int(input())):\n x = int(input())\n print(x//2)"}, {"source_code": "def dice(q):\n div = q / 2\n return div\n\n\nn = int(raw_input())\nqueries = []\nfor i in range(n):\n q = int(raw_input())\n queries.append(q)\n\nfor q in queries:\n print(dice(q))\n"}, {"source_code": "t=int(input())\nfor i in range(t):\n n=int(input())\n print(n//2 if n%2==0 else (n-3)//2+1)"}, {"source_code": "for _ in range(int(input())):\n n=int(input())\n if n%7==0:\n print(n//7)\n else:\n print(n//7+1)\n"}, {"source_code": "import math\nfor _ in range(int(input())):\n\tprint(math.ceil(int(input())/7))"}, {"source_code": "x = int(input())\nfor i in range(x):\n\ta = int(input())\n\tk = 0\n\tif a > 7:\n\t\tt = int(a/7)\n\t\ta = a - 7*t\n\t\tk = k + t\n\tif a > 0:\n\t\ta = 0\n\t\tk = k + 1\n\tprint(k)"}, {"source_code": "for i in range(int(input())):\n n = int(input())\n if(n == 2 or n == 3 or n == 4 or n == 5 or n == 6 or n == 7):\n print(1)\n else:\n print(round(n / 7) + 1)"}, {"source_code": "def answer():\n n = int(input())\n while n:\n a=int(input())\n print(int(a/2)) \n n-=1\nanswer()"}, {"source_code": "T = int(input())\nwhile(T > 0):\n T -= 1\n n = int(input())\n print((n + 6) // 7)"}, {"source_code": "for _ in range(input()):\n\tprint input()/2"}, {"source_code": "n = int(input())\nfor i in range(n):\n x = int(input())\n print(x // 2)\n"}, {"source_code": "for i in range(int(input())):\n a = int(input())\n e = a // 2\n if a % 2 == 0:\n print(e)\n else:\n o = e * 2 - 2 + 3\n print(e)\n"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef main():\n for _ in range(int(input())):\n n = int(input())\n ans = 0\n while n:\n if n == 3:\n n -= 3\n ans += 1\n else:\n n -= 2\n ans += 1\n print(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from math import ceil\nt=int(input())\na=[]\nfor i in range(t):\n a.append(int(input()))\ndef chk(k):\n return ceil(k/7)\nfor i in a:\n print(chk(i))"}, {"source_code": "import sys\ninput = sys.stdin.readline\nins = lambda: input().rstrip()\nini = lambda: int(input().rstrip())\ninm = lambda: map(int, input().rstrip().split())\ninl = lambda: list(map(int, input().split()))\nout = lambda x, s='\\n': print(s.join(map(str, x)))\n\nt = ini()\nfor _ in range(t):\n n = ini()\n print((n + 6) // 7)"}, {"source_code": "def solve():\n num = int(input())\n rolls = 0\n if 2 <= num < 7:\n print('1')\n else:\n if ( num%7 == 1 ):\n print((int(num/7)-1) + 2 )\n elif ( num%7 == 0 ):\n print( int(num/7) )\n else:\n print(int(num/7) + 1)\n \n \n\nnum = int(input())\nfor x in range(num):\n solve()"}, {"source_code": "n = int(input())\nangka = [2,3,4,5,6,7]\n\nfor i in range(n):\n hasil = 0\n dice = int(input())\n for j in angka:\n if dice >= j:\n hasil += dice // j\n dice = dice % j\n if dice == 0:\n break\n print(hasil)\n\n"}, {"source_code": "import math\nimport sys\nimport bisect\ninput=sys.stdin.readline\nt=int(input())\n#t=1\nfor _ in range(t):\n n=int(input())\n print(n//7+1)"}, {"source_code": "a=int(input())\nfor i in range(a):\n b=int(input())\n print(b//2)"}, {"source_code": "for _ in range(int(input())):\n x = int(input())\n if(x<=7 and x>=2):\n print(1)\n else:\n if(x%2==0):\n print(x//2)\n else:\n x-=3\n print(x//2+1)"}, {"source_code": "T=int(input())\nfor i in range(T):\n x=int(input())\n if(x%2==0):\n print(x//2)\n else:\n print((x-3)//2+1)\n"}, {"source_code": "a=int(input())\nb=0\nfor i in range(a):\n b=int(input())\n print((b+6)//7)"}, {"source_code": "t=int(raw_input())\nfor i in range(t):\n x=int(raw_input())\n cnt=x/7\n if x<8:\n x=1\n else:\n x=cnt+1\n print x\n"}, {"source_code": "n=int(input())\nfor i in range(n):\n x=int(input())\n if(x<=7):\n print(1)\n else:\n d=x//7\n if(x%7==0):\n print(d)\n else:\n print(d+1)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# File : a.py\n# Author : recurze\n# Date : 20:06 15.12.2018\n# Last Modified Date: 20:07 15.12.2018\n\nfor _ in xrange(int(raw_input())):\n print int(raw_input())/2\n"}, {"source_code": "for _ in range(input()):\n n=input()\n print n/7+(n%7>0)\n"}, {"source_code": "n = int(input())\nfor i in range(n):\n tmp = int(input())\n ans = tmp // 7 + (1 if tmp % 7 != 0 else 0)\n print(ans)\n"}, {"source_code": "for i in range(int(input())):\n n = int(input())\n if n & 1:\n print((n - 3) // 2 + 1)\n else:\n print(n // 2)\n"}, {"source_code": "\ndef solver():\n number = int(input())\n combinations = [2,3,4,5,6,7]\n for i in combinations:\n if number%i == 0:\n return (int(number/i))\n\n count = 1\n new_number = number - 3\n count = count + (new_number//2)\n return count\n\n\nn = int(input())\n\nfor i in range(n):\n print(solver())"}, {"source_code": "n = int(raw_input())\n#ver,reb = [int(x) for x in raw_input().split(' ')]\n\nfor i in range(n):\n x = int(raw_input())\n num = x // 7\n if x % 7:\n num += 1\n print(num)"}, {"source_code": "t=int(input())\nwhile(t>0):\n n=int(input())\n if(n%7==0):\n print(int(n/7))\n else:\n print(int(n/7)+1)\n t-=1"}, {"source_code": "for i in range(int(input())):\n\tprint(int(input())//2)"}, {"source_code": "\nn = int(input())\n\nfor i in range(n):\n a = int(input())\n print(a // 2)"}, {"source_code": "n = int(raw_input())\nfor i in range(n):\n m = int(input())\n if m%2 == 0:print(m/2)\n elif m == 1:print(0)\n else: print(1+((m-3)/2))\n"}, {"source_code": "for i in range(int(input())):\n\tprint(int(input())//2)"}, {"source_code": "a=int(input())\nb=0\nfor i in range(a):\n b=int(input())\n print((b+6)//7)"}, {"source_code": "t = int(input())\nfor q in range(t):\n a = int(input())\n if a==2:\n num = 1\n elif a==3:\n num = 1\n elif a==4:\n num = 1\n elif a>4:\n if a%5==0:\n num = (a//5)\n elif a%5!=0:\n num = (a//5)+1\n print(num)\n"}, {"source_code": "n = int(raw_input())\nfor _ in xrange(n):\n x = int(raw_input())\n for i in xrange(7, 1, -1):\n v = x / i\n d = x % i\n if d == 0:\n print v\n break\n elif d == 1:\n continue\n else:\n print v + 1\n break"}, {"source_code": "for _ in xrange(input()):print input()/2"}, {"source_code": "# cf 1093 A (700)\nt = int(input())\nfor _ in range(t):\n n = int(input())\n c = 0\n while n > 0:\n if n > 7:\n n -= 7\n c += 1\n elif n == 1:\n c += 2\n n -= 1\n else:\n c += 1\n n -= n\n print(c)\n \n"}, {"source_code": "n=int(input())\nfor i in range(n):\n\tn1=int(input())\n\tcount=0\n\tfor i in range(7,1,-1):\n\t\tif n1!=1:\n\t\t\tcount+=int(n1//i)\n\t\t\tn1%=i\n\t\telif n1==1:\n\t\t\tcount+=1\n\t\t\tbreak\n\t\t# print(n1)\n\tprint(count)"}, {"source_code": "# import atexit, io, sys\n# buffer = io.BytesIO()\n# sys.stdout = buffer\n# @atexit.register\n# def write():\n# sys.__stdout__.write(buffer.getvalue())\n \n# def main():\n# main()\n\nn = int(input())\nL = []\nfor i in range(n):\n x = int(input())\n s = x//7\n x -= (7*s)\n if x:\n s += 1\n L.append(s)\nfor i in L:\n print(i)\n "}, {"source_code": "# https://vjudge.net/contest/319028#problem/F\n\nn = int(input())\n\nfor i in range(n):\n t = int(input())\n result = 0\n for i in range(7, 1, -1):\n while t >= i:\n t -= i\n result += 1\n if t == 1:\n result += 1\n print(result)"}, {"source_code": "for _ in range(int(input())):\n x = int(input())\n if x == 3:\n print(1)\n else:\n print(x // 2)\n"}, {"source_code": "for i in range(int(input())):\n a = int(input())\n e = a // 2\n if a % 2 == 0:\n print(e)\n else:\n o = e * 2 - 2 + 3\n print(e)\n"}, {"source_code": "import sys\nimport math\n#import random\nsys.setrecursionlimit(100000)\ninput = sys.stdin.readline\n \n############ ---- USER DEFINED INPUT FUNCTIONS ---- ############\ndef inp():\n return(int(input()))\ndef inara():\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################################################################\n############ ---- THE ACTUAL CODE STARTS BELOW ---- ############\n\nt=inp()\n\nfor _ in range(t):\n\tn=inp()\n\t\n\tif n<=7:\n\t\tprint(1)\n\telse:\n\t\tif n%2:\n\t\t\tans=(n-3)//2+1\n\t\t\tprint(ans)\n\t\telse:\n\t\t\tprint(n//2)\n\t\t\t\n\t\n\t\t\t\n\t\t\t\n\t\t\t\n"}, {"source_code": "for i in range(int(input())):\n print((int(input()) + 6) // 7)\n"}, {"source_code": "for _ in range(int(input())):\n n=int(input())\n if(n%6==0):\n print(n//6)\n else:\n print(n//6 +1)\n"}, {"source_code": "t = int(raw_input())\nwhile t > 0:\n\tn = int(raw_input())\n\tx = n/7\n\tif n%7 != 0:\n\t\tx = x+1\n\tprint x\n\tt -= 1"}, {"source_code": "n = int(input())\nfor i in range(n):\n a = int(input())\n print(a//2)\n"}, {"source_code": "z=input\nfor _ in range(int(z())):\n x=int(z())\n print(x//2)\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": "for i in range(int (input())):\n n = int (input())\n print (n//2)"}, {"source_code": "t=int(input())\nfor i in range(t):\n n=int(input())\n print(n//2)"}, {"source_code": "for _ in range(int(input())):\n n = int(input())\n if n%2 == 0:\n print(n//2)\n else:\n print((n-3)//2 + 1)"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nt = int(input())\nfor _ in range(t):\n x = int(input())\n ans = 0\n if x%2==1:\n ans += 1\n x -= 3\n ans += x//2\n print ans\n"}, {"source_code": "import math\n\ncase = int(input())\nfor caseNum in range(0, case):\n n = int(input())\n print(math.ceil(n / 7))"}, {"source_code": "import os\nimport heapq\nimport sys,threading\nimport math\nimport bisect\nimport operator\nfrom collections import defaultdict\nsys.setrecursionlimit(10**5)\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\ndef lcm(num1,num2):\n return (num1*num2)//gcd(num1,num2)\n# 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))\ndef check(n,m,arr):\n c1,c2=1,1\n for i in range(n):\n for j in range(1,m):\n if arr[i][j]>arr[i][j-1]:\n continue\n else:\n c1=0\n break\n for i in range(m):\n for j in range(1,n):\n if arr[j][i]>arr[j-1][i]:\n continue\n else:\n c2=0\n break\n if c1 and c2:\n return True\n else:\n return False\n\n\n\n\ndef main():\n for _ in range(int(input())):\n n=int(input())\n print(n//2)\n\n # n,m=inar()\n # arr1=[]\n # arr2=[]\n # for i in range(n):\n # take=inar()\n # arr1.append(take)\n # for i in range(n):\n # take=inar()\n # arr2.append(take)\n # # print(arr1)\n # for i in range(n):\n # for j in range(m):\n # mn=min(arr1[i][j],arr2[i][j])\n # mx=max(arr1[i][j],arr2[i][j])\n # arr1[i][j],arr2[i][j]=mn,mx\n # if check(n,m,arr1) and check(n,m,arr2):\n # print(\"Possible\")\n # else:\n # print(\"Impossible\")\n\n\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\nif __name__ == \"__main__\":\n main()\n #threadin.Thread(target=main).start()\n"}, {"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n print(n//2)"}, {"source_code": "a=[1,1,1,1,1,1]+94*[0]\nfor i in range ( 6 , 100):\n a[i]=min([a[i-7],a[i-6],a[i-5],a[i-4],a[i-3],a[i-2]])+1\nq=[]\nfor i in range(int(input())):\n q+=[a[int(input())-1]]\nfor i in q:\n print(i)"}, {"source_code": "t=int(input())\n\nfor i in range(t):\n n=int(input())\n sum=0;\n i=7;\n while n:\n k=n//i\n if k:\n n=n-k*i\n sum+=k\n i-=1\n print(sum)"}, {"source_code": "for i in[0]*int(input()):\n print(int(input())//2)"}, {"source_code": "for i in[0]*int(input()):print(int(input())//2)"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 17.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\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 *,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<=7:\n print(1)\n else:\n print(ceil(n,7))\n\n\n\n\n\n\n\n \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": "n=input()\nfor t in range(n):\n\tr=input()\n\n\tif r in range(2,8):\n\t\tans= 1\n\telif r%7==0:\n\t\tans= r/7\n\telse:\n\t\tans= (r/7)+1\n\tprint ans\n"}, {"source_code": "'''input\n4\n2\n13\n37\n100\n\n\n'''\n\n\n\n\nfor _ in range(input()):\n n=input()\n print n/2\n\n\n\n\n"}, {"source_code": "# your code goes here\nfor i in range(int(input())):\n\tx=int(input())\n\tprint(int(x/7)+1)"}], "negative_code": [{"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n ans = 0\n if n>7:\n a = n // 7 \n n = n - a*7\n ans += a\n if n>6:\n a = n // 6\n n = n - a*6\n ans += a\n if n>5:\n a = n // 5 \n n = n - a*5\n ans += a\n if n>4:\n a = n // 4 \n n = n - a*4\n ans += a\n if n>3:\n a = n // 3 \n n = n - a*3\n ans += a\n if n>2:\n a = n // 2 \n n = n - a*2\n ans += a\n print(ans)"}, {"source_code": "x = int(input())\nfor i in range(x):\n\ta = int(input())\n\tk = 0\n\tif a > 7:\n\t\tt = int(a/7)\n\t\ta = a - a*t\n\t\tk = k + t\n\tif a > 0:\n\t\ta = 0\n\t\tk = k + 1\n\tprint(k)"}, {"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_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_strList_from_str = lambda: list(sys.stdin.readline().strip())\n#to read integers\nget_int = lambda: int(sys.stdin.readline().strip())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------------#\nfor _ in range(get_int()):\n rolls = 0\n n = get_int()\n temp = n\n start = 7\n while True:\n temp = n\n for i in range(start,1,-1):\n rolls += temp//i\n temp = temp%i\n if temp == 0:\n break\n else:\n start -= 1\n\n print(rolls)"}, {"source_code": "#1093A in codeforces\nt = int(input())\ndice = [2,3,4,5,6,7]\nfor _ in range(t):\n\trolls = 0\n\tn = int(input())\n\tfor i in range(5,-1,-1):\n\t\trolls+= n//dice[i]\n\t\tn = n%dice[i]\n\tprint(rolls)"}, {"source_code": "points = [7, 6, 5, 4, 3, 2]\n\ndef is_divisible(number):\n for i in points:\n if number % i == 0:\n return True\n \n return False \n\ndef get_number_of_rolls(score):\n if score == 0:\n return 0\n \n rolls = 0\n actual_score = 0\n\n for i in points:\n if score % i == 0:\n return score // i\n\n for i in points:\n mod = score % i\n print(mod)\n\n if is_divisible(mod):\n return (score // i) + get_number_of_rolls(mod)\n\nn = int(input())\n\nfor i in range(n):\n score = int(input())\n\n print(get_number_of_rolls(score))\n"}, {"source_code": "import sys\n\nt=int(raw_input())\nfor _ in xrange(t):\n\tn=int(raw_input())\n\tprint(n/2+(0 if n%2==0 else 1))"}, {"source_code": "n = int(input())\nfor item in range(n):\n a = int(input())\n if a <= 7:\n print(a)\n else:\n if a % 2 == 0:\n print(a //2)\n else:\n print((a//2) + 1)\n"}, {"source_code": "import random;\nt = input();\nt = int(t);\nx = [];\nfor j in range(t):\n a = input();\n a = int(a);\n x.append(a);\ng = max(x);\nm = g//7+1;\ny =0;\n\nfor i in range(len(x)):\n if x[i]==1 or x[i]==0:\n print(0);\n if x[i]==2 or x[i]== 3 :\n b = 1;\n print(b);\n else:\n if x[i]//7 == x[i]/7:\n lower = x[i]//7;\n print(lower);\n else:\n lower = x[i]//7 + 1;\n print(lower);\n \n upper = x[i]//2;\n print(upper);\n \n b = random.randint(lower,upper);\n print(b);\n \n \n \n \n \n \n \n \n \n \n \n \n"}, {"source_code": "import random\ndef roll_dice():\n\tt=int(input(\"Enter the no. of queries\"))\n\tsum=0\n\tcount=0\n\tfor i in range(t):\n\t\tx=int(input(\"Enter the sum of number\"))\n\t\tsum=sum+random.randint(2,7)\n\t\t#print(\"first sum\",sum)\n\t\tcount=count+1\n\t\t#print(\"first count\",count)\n\n\t\twhile(sum!=x):\n\t\t\tif sumx:\n\n\t\t\t\tsum=0\n\t\t\t\tcount=0\n\t\t\t\t#print(\"greater than entered\")\n\t\t\t\t\n\t\t\telse:\n\t\t\t\tcount=count+1\n\t\t\t\tbreak\n\n\t\t\t\n\t\t#print(\"final\", sum)\n\t\tprint(\"final count\", count)\n\t\tsum=0\n\t\tcount=0\nroll_dice()"}, {"source_code": "for i in range(int(input())):\n a = int(input())\n if a % 2 == 0:\n print(a//2)\n elif a % 2 != 0:\n e = a // 2\n w = abs(e-3)\n if w == 0:\n print(1)\n else:\n print(w)"}, {"source_code": "T = int(input())\n\nfor i in range(0, T):\n x = int(input())\n roll = x//7 + x%7\n print(roll)\n"}, {"source_code": "int_=int(input())\nfor i in range(int_):\n k=int(input())\n num=(k+1)//2\n print(num)\n"}, {"source_code": "x = int(input())\ny = [int(input()) for c in range(x)]\n\nfor c in range(x):\n print((y[c])//7)\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Dec 15 20:59:44 2018\n\n@author: mach\n\"\"\"\n\nt = int(input())\nl = [7,6,5,4,3,2]\nfor _ in range(t):\n s = 0\n u = int(input())\n\n for i in l:\n if u >= 2:\n s += u//i\n u = u%i\n print(s)"}, {"source_code": "#1093A in codeforces\nt = int(input())\ndice = [2,3,4,5,6,7]\nfor _ in range(t):\n\trolls = 0\n\tn = int(input())\n\tfor i in range(5,-1,-1):\n\t\trolls+= n//dice[i]\n\t\tn = n%dice[i]\n\tprint(rolls)"}, {"source_code": "n = int(input())\nfor i in range(n):\n x = int(input())\n print(x % 7 + 1)"}, {"source_code": "import math\nlist=[6,5,4,3,2]\nn=int(input())\nfor i in range(n):\n\tcount=0\n\ty=int(input())\n\tfor j in list :\n\t\twhile y>=j :\n\t\t\tif y%j==0:\n\t\t\t\tt=math.floor(y/j)\n\t\t\t\tcount=count+t\n\t\t\t\ty=y%j\n\t\t\t\tbreak\n\t\t\telif y%j>0 and y>j and y%j in list:\n\t\t\t\ty=y-j\n\t\t\t\tcount=count+1\n\t\t\telse:\n\t\t\t\tbreak\n\t\t\t\n\t\t\n\tprint(count)\t\n\t\t\t\n\t\t\n"}, {"source_code": "n = int(input())\nfor i in range(n):\n tmp = int(input())\n ans = tmp // 7 + 1 if tmp % 7 != 0 else 0\n print(ans)\n"}, {"source_code": "for i in range(int(input())):\n counter = 0\n x = int(input())\n if x // 7 != 0:\n counter += x // 7\n x %= 7\n if x // 6:\n counter += x // 6\n x %= 6\n if x // 5:\n counter += x // 5\n x %= 5\n if x // 4:\n counter += x // 4\n x %= 4\n if x // 3:\n counter += x // 3\n x %= 3\n if x // 2:\n counter += x // 2\n x %= 2\n print(counter)"}, {"source_code": "# https://vjudge.net/contest/319028#problem/F\n\nn = int(input())\n\nfor i in range(n):\n t = int(input())\n result = 0\n for i in range(7, 1, -1):\n while t >= i:\n t -= i\n result += 1\n if t == 1:\n result += 1\n print(result)"}, {"source_code": "# https://vjudge.net/contest/319028#problem/F\n\nn = int(input())\n\nfor i in range(n):\n t = int(input())\n result = 0\n for i in range(7, 1, -1):\n while t >= i:\n t -= i\n result += 1\n print(result)"}, {"source_code": "for _ in range(int(input())):\n n=int(input())\n \n if 2<=n<=7:\n print(1)\n else:\n print(n//7)\n"}, {"source_code": "n = input()\n\nfor i in range(n):\n num = input()\n if num % 2 == 0:\n print '2 ' * (num/2)\n else:\n print '2 ' * (num/2-1) + '3'\n "}, {"source_code": "t = int( input() )\ndice_list = [7, 6, 5, 4, 3, 2]\nnum_list = []\n\nfor i in range(t):\n\tx = int(input())\n\tnum = 0\n\tif x <= dice_list[0]:\n\t\tnum_list.append(1)\n\telse:\n\t\tfor dice in dice_list:\n\t\t\tnum += int(x/dice)\n\t\t\tx %= dice\n\t\t\tif x == 0:\n\t\t\t\tnum_list.append(num)\n\t\t\t\tbreak\n\nfor num in num_list:\n\tprint(num)\n"}, {"source_code": "queries = int(raw_input())\nnumeros = []\ntentativas = []\nfor i in range(queries):\n numeros.append(int(raw_input()))\nfor i in numeros:\n if i % 7 == 0:\n print i / 7\n elif (i / 7) > 1:\n print (i / 7) + 1\n else:\n print 1"}, {"source_code": "n = input()\n\nfor i in range(n):\n num = input()\n if num % 2 == 0:\n print '2 ' * (num/2)\n else:\n print '2 ' * (num/2-1), '3'\n "}, {"source_code": "t=int(input())\nfor _ in range(t):\n n=int(input())\n c=0\n if(n>7):\n c+=n//7\n n=n%7\n if(n>6):\n c+=n//6\n n=n%6\n if(n>5):\n c+=n//5\n n=n%5\n if(n>4):\n c+=n//4\n n=n%4\n if(n>3):\n c+=n//3\n n=n%3\n if(n>2):\n c+=n//2\n n=n%2\n print(c)\n \n \n"}, {"source_code": "for t in range(int(input())):\n s=sorted(input())\n if s[0]==s[-1]:\n print(\"-1\")\n else:\n for i in s:\n print(i)"}, {"source_code": "n = input()\n\nfor i in range(n):\n num = input()\n if num % 2 == 0:\n print '2 ' * (num/2)\n else:\n print '2 ' * (num/2-1), '3'\n "}, {"source_code": "n = input()\ns = tuple(map(int, input().split()))\nm = 1e9 + 1\nt = 0\nfor i in s:\n t += i\n if i % 2 and i < m:\n m = i\nprint((0 if m > 1e9 else t - m) if t % 2 else t)\n"}, {"source_code": "n=int(input())\nw=0\nfor i in range(n):\n m=int(input())\n while m>7:\n m-=7\n w+=1\n print(w+1)\n"}, {"source_code": "t=int(input())\na=[]\na=list(map(int , input().split()))\n\nfor x in a:\n p=x/2\n c=int(p)\n print(c)"}, {"source_code": "for _ in range(int(input())):\n n = int(input())\n print(n//7+n%7)"}, {"source_code": "x=int(input())\nfor i in range(x):\n print(int(input())//x)"}, {"source_code": "print (1,'\\n',3,'\\n',8,'\\n',27)"}, {"source_code": "[[print(str(x) + \": \" +str(x // 7 + max(1, x % 7))) for x in [int(input())]] for i in range(int(input()))]"}, {"source_code": "n=int(input())\nfor i in range(n):\n\tn1=int(input())\n\tcount=0\n\tfor i in range(7,1,-1):\n\t\tif n1!=1:\n\t\t\tcount+=int(n1//i)\n\t\t\tn1%=i\n\t\telif n1==1:\n\t\t\tcount+=1\n\t\t# print(n1)\n\tprint(count)"}, {"source_code": "T = int(input())\nfor i in range(T):\n n = int(input())\n print(round(n/2))\n\n"}, {"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n ans = 0\n if n>7:\n a = n // 7 \n n = n - a*7\n ans += a\n if n>6:\n a = n // 6\n n = n - a*6\n ans += a\n if n>5:\n a = n // 5 \n n = n - a*5\n ans += a\n if n>4:\n a = n // 4 \n n = n - a*4\n ans += a\n if n>3:\n a = n // 3 \n n = n - a*3\n ans += a\n if n>2:\n a = n // 2 \n n = n - a*2\n ans += a\n print(ans)"}, {"source_code": "t = int( input() )\ndice_list = [7, 6, 5, 4, 3, 2]\nnum_list = []\n\nfor i in range(t):\n\tx = int(input())\n\tnum = 0\n\tif x <= dice_list[0]:\n\t\tnum_list.append(1)\n\telse:\n\t\tfor dice in dice_list:\n\t\t\tnum += int(x/dice)\n\t\t\tx %= dice\n\t\t\tif x == 0:\n\t\t\t\tnum_list.append(num)\n\t\t\t\tbreak\n\nfor num in num_list:\n\tprint(num)\n"}, {"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n print(n//3)"}, {"source_code": "int_=int(input())\nfor i in range(int_):\n k=int(input())\n num=(k+1)//2\n print(num)\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_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_strList_from_str = lambda: list(sys.stdin.readline().strip())\n#to read integers\nget_int = lambda: int(sys.stdin.readline().strip())\n#to print faster\npt = lambda x: sys.stdout.write(str(x))\n\n#--------------------------------WhiteHat010--------------------------------------#\nfor _ in range(get_int()):\n rolls = 0\n n = get_int()\n for i in range(7,1,-1):\n rolls += n//i\n n = n%i\n print(rolls)"}, {"source_code": "import random\ndef roll_dice():\n\tt=int(input(\"Enter the no. of queries\"))\n\tsum=0\n\tcount=0\n\tfor i in range(t):\n\t\tx=int(input(\"Enter the sum of number\"))\n\t\tsum=sum+random.randint(2,7)\n\t\t#print(\"first sum\",sum)\n\t\tcount=count+1\n\t\t#print(\"first count\",count)\n\n\t\twhile(sum!=x):\n\t\t\tif sumx:\n\n\t\t\t\tsum=0\n\t\t\t\tcount=0\n\t\t\t\t#print(\"greater than entered\")\n\t\t\t\t\n\t\t\telse:\n\t\t\t\tcount=count+1\n\t\t\t\tbreak\n\n\t\t\t\n\t\t#print(\"final\", sum)\n\t\tprint(\"final count\", count)\n\t\tsum=0\n\t\tcount=0\nroll_dice()"}, {"source_code": "def fon(n):\n\tc = 0\n\twhile c < n:\n\t\tif n%7 <= 1:\n\t\t\tc += n//7\n\t\t\tn-=7*(n//7)\n\t\tif n%6 <= 1:\n\t\t\tc += n//6\n\t\t\tn-=6*(n//6)\n\t\tif n%5 <= 1:\n\t\t\tc += n//5\n\t\t\tn-=5*(n//5)\n\t\tif n%4 <= 1:\n\t\t\tc += n//4\n\t\t\tn-=4*(n//4)\n\t\tif n%3 <= 1 :\n\t\t\tc += n//3\n\t\t\tn-=3*(n//3)\n\t\tif n%2 <= 1:\n\t\t\tc += n//2\n\t\t\tn-=2*(n//2)\n\treturn c\n \ne = int(input())\nd = []\n \nfor i in range(e):\n\ta = int(input())\n\td.append(fon(a))\n \nfor i in d:\n\tprint(i)"}, {"source_code": "for i in range(int(input())):\n x= int(input())\n y= x//7\n if x<=7:\n print(1)\n elif x%7>=2:\n print(y+1)\n else:\n y= x//6\n if x%6>=2:\n print(y+1)"}, {"source_code": "T = int(input())\nfor i in range(T):\n n = int(input())\n print(round(n/2))\n\n"}, {"source_code": "t = int(input())\nnums = [int(input()) for i in range(t)]\nfor k in nums:\n\tif k%2==0:\n\t print(k/2)\n\telif k==3:\n\t print(\"1\")\n\telse:\n\t print((k-3)/2)"}, {"source_code": "x=int(input())\nfor i in range(x):\n print(int(input())//x)"}, {"source_code": "for _ in range(int(input())):\n n = int(input())\n ans = 0\n for i in range(7,1,-1):\n ans += n//i\n n %= i\n \n if(n):\n print('0')\n else:\n print(ans)"}, {"source_code": "import time\n\n\ndef calculateOptimalRolls(number):\n updN = number\n rolls = 0\n\n div7 = updN // 7 #rolls futuros\n updN -= div7 * 7\n\n div6 = updN // 6\n updN -= div6 * 6\n\n div5 = updN // 5\n updN -= div5 * 5\n\n div4 = updN // 4\n updN -= div4 * 4\n\n div3 = updN // 3\n updN -= div3 * 3\n\n div2 = updN // 2\n updN -= div2 * 2\n\n rolls = div7 + div6 + div5 + div4 + div3 + div2\n\n return rolls\n\n\n\ndef solve():\n queries = int(input())\n for x in range(queries):\n desiredN = int(input())\n print(calculateOptimalRolls(desiredN))\n\n # print(\"%fs\" % (time.time() - start_time))\n\n\nsolve()\n"}, {"source_code": "from collections import deque, Counter, OrderedDict\nfrom heapq import nsmallest, nlargest\nfrom math import ceil,floor,log,log2,sqrt,gcd,factorial,pow\ndef binNumber(n,size=4):\n return bin(n)[2:].zfill(size)\n\ndef iar():\n return list(map(int,input().split()))\n\ndef ini():\n return int(input())\n\ndef isp():\n return map(int,input().split())\n\ndef sti():\n return str(input())\n\ndef par(a):\n return ' '.join(list(map(str,a)))\n\ndef tdl(outerListSize,innerListSize,defaultValue = 0):\n return [[defaultValue]*innerListSize for i in range(outerListSize)]\n\nclass pair:\n def __init__(self,f,s):\n self.fi = f\n self.se = s\n def __lt__(self,other):\n return (self.fi,self.se) < (other.fi,other.se)\n\n# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\nif __name__ == \"__main__\":\n t = ini()\n for _ in range(t):\n x = ini()\n s = 0\n for i in range(7,1,-1):\n s += x//i\n x %= i\n print(s)"}, {"source_code": "t=int(input())\nfor j in range(t):\n m=int(input())\n c=0\n for i in range(7,1,-1):\n d=m//i \n if((m-(d*i))>=0 and d!=0):\n c+=(d)\n m-=(d*i)\n print(c)"}, {"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n ans = 0\n if n>=7:\n a = n // 7 \n n = n - a*7\n ans += a\n if n>=6:\n a = n // 6\n n = n - a*6\n ans += a\n if n>=5:\n a = n // 5 \n n = n - a*5\n ans += a\n if n>=4:\n a = n // 4 \n n = n - a*4\n ans += a\n if n>=3:\n a = n // 3 \n n = n - a*3\n ans += a\n if n>=2:\n a = n // 2 \n n = n - a*2\n ans += a\n print(ans)"}, {"source_code": "from collections import deque, Counter, OrderedDict\nfrom heapq import nsmallest, nlargest\nfrom math import ceil,floor,log,log2,sqrt,gcd,factorial,pow\ndef binNumber(n,size=4):\n return bin(n)[2:].zfill(size)\n\ndef iar():\n return list(map(int,input().split()))\n\ndef ini():\n return int(input())\n\ndef isp():\n return map(int,input().split())\n\ndef sti():\n return str(input())\n\ndef par(a):\n return ' '.join(list(map(str,a)))\n\ndef tdl(outerListSize,innerListSize,defaultValue = 0):\n return [[defaultValue]*innerListSize for i in range(outerListSize)]\n\nclass pair:\n def __init__(self,f,s):\n self.fi = f\n self.se = s\n def __lt__(self,other):\n return (self.fi,self.se) < (other.fi,other.se)\n\n# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\nif __name__ == \"__main__\":\n t = ini()\n for _ in range(t):\n x = ini()\n s = 0\n for i in range(7,1,-1):\n s += x//i\n x %= i\n print(s)"}, {"source_code": "for i in range(int(input())):\n print(int(input()))\n"}, {"source_code": "# https://vjudge.net/contest/319028#problem/F\n\nn = int(input())\n\nfor i in range(n):\n t = int(input())\n result = 0\n for i in range(7, 1, -1):\n while t >= i:\n t -= i\n result += 1\n if t == 1:\n result += 1\n print(result)"}, {"source_code": "print (1,'\\n',3,'\\n',8,'\\n',27)"}, {"source_code": "n=int(input())\nfor i in range(n):\n a=int(input())\n print(a//7+a%7//6+a%7%6//5+a%7%6%5//4+a%7%6%5%4//3+a%7%6%5%4%3//2)"}, {"source_code": "n = int(input())\ncount = []\nfor i in range(n):\n num = int(input())\n if (num/3) == 0:\n count.append(int(num/3))\n else:\n count.append(int(num/3)+1)\nfor i in range(n):\n print(count[i])"}, {"source_code": "import math\nlist=[6,5,4,3,2]\nn=int(input())\nfor i in range(n):\n\tcount=0\n\ty=int(input())\n\tfor j in list :\n\t\twhile y>=j :\n\t\t\tif y%j==0:\n\t\t\t\tt=math.floor(y/j)\n\t\t\t\tcount=count+t\n\t\t\t\ty=y%j\n\t\t\t\tbreak\n\t\t\telif y%j>0 and y>j and y%j in list:\n\t\t\t\ty=y-j\n\t\t\t\tcount=count+1\n\t\t\telse:\n\t\t\t\tbreak\n\t\t\t\n\t\t\n\tprint(count)\t\n\t\t\t\n\t\t\n"}, {"source_code": "def solve():\n x = int(input())\n ans = 0\n for i in range(7,1,-1):\n ans += x//i\n x = x%i\n print(ans)\n\nt = int(input())\nfor j in range(t):\n solve()\n"}, {"source_code": "import random\n\nt=int(input(\"Enter the no. of queries\"))\nsum=0\ncount=0\nfor i in range(t):\n\tx=int(input(\"Enter the sum of number\"))\n\tsum=sum+random.randint(2,7)\n\t\t#print(\"first sum\",sum)\n\tcount=count+1\n\t\t#print(\"first count\",count)\n\n\twhile(sum!=x):\n\t\tif sumx:\n\n\t\t\tsum=0\n\t\t\tcount=0\n\t\t\t\t#print(\"greater than entered\")\n\t\t\t\t\n\t\telse:\n\t\t\tcount=count+1\n\t\t\tbreak\n\n\t\t\t\n\t\t#print(\"final\", sum)\n\tprint(\"final count\", count)\n\tsum=0\n\tcount=0\n"}, {"source_code": "for i in range(int(input())):\n\tn=int(input())\n\tflag=0\n\tfor j in range(7,1,-1):\n\t\tflag+=n//j\n\t\tn=n%j\n\tprint(flag)"}, {"source_code": "\nfor t in range(int(input())):\n x = int(input())\n print(x//2 + (x % 2 == 1))\n"}, {"source_code": "n = int(input())\nfor i in range(n):\n score = int(input())\n if score <= 7:\n print(1)\n continue\n else:\n k = score/2\n if score % 2 == 0:\n print(int(k))\n else:\n print(int(k)+1)\n"}, {"source_code": "print(int(input())//7 + 1)\n"}, {"source_code": "\"\"\"\nUsage:\n python solution.py < input.txt > solution_output.txt\n\nTesting:\n pytest test_solution.py\n\"\"\"\n\n\ndef get_input(inputs_number: int = 1) -> str:\n \"\"\"\n Loops throw the stdio to fetch input data\n Args:\n inputs_number: Number of lines of the input\n Needs to be manually changed in case of\n multiple lines input\n Returns:\n raw_input_data: The input of a problem\n It must be equal to the test input on the test file\n \"\"\"\n raw_input_data = \"\"\n for _ in range(inputs_number):\n n_tests = input()\n raw_input_data += n_tests + \"\\n\"\n for _ in range(int(n_tests)):\n raw_input_data += input() + \"\\n\"\n \n return raw_input_data.strip()\n\n\ndef process_input(raw_input_data: str):\n data = raw_input_data.split(\"\\n\")\n n_tests = data.pop(0)\n return [int(number) for number in data]\n\n\ndef solve(raw_input_data):\n points = process_input(raw_input_data)\n answer = \"\"\n for point in points:\n if point % 2 == 0:\n answer += str(point // 2) + \"\\n\"\n else:\n answer += str(((point - 7) // 2) + 1) + \"\\n\"\n return answer\n\n\nif __name__ == \"__main__\":\n \n # while True:\n # try:\n # Change input lines number here\n input_data = get_input()\n answer = solve(input_data)\n print(answer)\n # except:\n # break\n# number_of_inputs = 1"}, {"source_code": "n = int(raw_input())\nfor i in range(n):\n m = int(input())\n if m%2 == 0:print(m/2)\n elif m == 1:print(0)\n else: print((m-3)/2)\n"}, {"source_code": "t = int(input())\nk = [2,3,4,5,6,7]\nfor i in range(t):\n\tx = int(input())\n\tif x in k:\n\t\tprint(x)\n\telif x>7 and x%7==0:\n\t\tprint(x//7)\n\telif x>7 and x%7>1:\n\t\tprint(x//7+1)\n\telif x>7 and x%7==1 and x%5==0:\n\t\tprint(x//5)\n\telif x>7 and x%7==1 and x%5>1:\n\t\tprint(x//5+1)"}, {"source_code": "def solve(num):\n ans = 0\n while num:\n for i in range(7, 1, -1):\n if num - i >= 2:\n num -= i\n ans += 1\n else:\n ans += 1\n num = 0\n break\n return ans\n\n\nfor _ in range(int(input())):\n print(solve(int(input())))\n"}, {"source_code": "n = int(input())\nprint(int(int(input())/2) for i in range(n))\n"}, {"source_code": "t = int(input())\n\nxmin = 2\nxmax = 7\n\nfor i in range(t):\n x = int(input())\n p = x // 7\n q = x % 7\n if q < 2:\n print(p)\n else:\n print(p+1)\n"}, {"source_code": "n = int(input())\nsum = 0\nfor i in range(n):\n a = int(input())\n if a >= 7 + 1:\n sum += a // 7\n a = a % 7\n elif a >= 6 + 1:\n sum += a // 6\n a = a % 6\n elif a >= 5 + 1:\n sum += a // 5\n a = a % 5\n elif a >= 4 + 1:\n sum += a // 4\n a = a % 4\n elif a >= 3 + 1:\n sum += a // 3\n a = a % 3\n elif a >= 2 :\n sum += a // 2\n a = a % 2\n print(sum)"}, {"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n ans = 0\n if n>7:\n a = n // 7 \n n = n - a*7\n ans += a\n if n>6:\n a = n // 6\n n = n - a*6\n ans += a\n if n>5:\n a = n // 5 \n n = n - a*5\n ans += a\n if n>4:\n a = n // 4 \n n = n - a*4\n ans += a\n if n>3:\n a = n // 3 \n n = n - a*3\n ans += a\n if n>2:\n a = n // 2 \n n = n - a*2\n ans += a\n print(ans)"}, {"source_code": "n=int(input())\nfor i in range(n):\n\tn1=int(input())\n\tcount=0\n\tfor i in range(7,1,-1):\n\t\tif n1!=1:\n\t\t\tcount+=int(n1//i)\n\t\t\tn1%=i\n\t\telif n1==1:\n\t\t\tcount+=1\n\t\t# print(n1)\n\tprint(count)"}, {"source_code": "for i in range(int(input())):\n a = int(input())\n if a % 2 == 0:\n print(a//2)\n elif a % 2 != 0:\n e = a // 2\n print(e-3)"}, {"source_code": "def fon(n):\n\tc = 0\n\twhile c < n:\n\t\tif n%7 <= 1:\n\t\t\tc += n//7\n\t\t\tn-=7*(n//7)\n\t\tif n%6 <= 1:\n\t\t\tc += n//6\n\t\t\tn-=6*(n//6)\n\t\tif n%5 <= 1:\n\t\t\tc += n//5\n\t\t\tn-=5*(n//5)\n\t\tif n%4 <= 1:\n\t\t\tc += n//4\n\t\t\tn-=4*(n//4)\n\t\tif n%3 <= 1 :\n\t\t\tc += n//3\n\t\t\tn-=3*(n//3)\n\t\tif n%2 <= 1:\n\t\t\tc += n//2\n\t\t\tn-=2*(n//2)\n\treturn c\n \ne = int(input())\nd = []\n \nfor i in range(e):\n\ta = int(input())\n\td.append(fon(a))\n \nfor i in d:\n\tprint(i)"}, {"source_code": "t=int(input())\nwhile t>0:\n t-=1 \n n=int(input())\n ans = 0\n if n>=7:\n a = n // 7 \n n = n - a*7\n ans += a\n if n>=6:\n a = n // 6\n n = n - a*6\n ans += a\n if n>=5:\n a = n // 5 \n n = n - a*5\n ans += a\n if n>=4:\n a = n // 4 \n n = n - a*4\n ans += a\n if n>=3:\n a = n // 3 \n n = n - a*3\n ans += a\n if n>=2:\n a = n // 2 \n n = n - a*2\n ans += a\n print(ans)"}, {"source_code": "t = int(input())\n\nxmin = 2\nxmax = 7\n\nfor i in range(t):\n x = int(input())\n p = x // 7\n q = x % 7\n if q < 3:\n print(p+q)\n elif q > 5:\n print(p+2)\n else:\n print(p+1)\n"}, {"source_code": "n=int(input())\nl=[7,6,5,4,3,2]\nfor i in range(n):\n\ta=int(input())\n\tsum=0\n\tif a in l:\n\t\tprint(1)\n\telse:\n\t\tprint(a)"}, {"source_code": "def answer():\n n = int(input())\n while n:\n print(int(n/2)) \n n-=1\nanswer()"}, {"source_code": "# Dice Rolling\ndef dice(x):\n if x <= 7:\n return 1\n if x % 2 == 0:\n return x // 2\n return (x // 2) + 1\n\nt = int(input())\nfor i in range(t):\n x = int(input())\n print(dice(x))"}, {"source_code": "t = int(input())\nk = [2,3,4,5,6,7]\nfor i in range(t):\n\tx = int(input())\n\tif x in k:\n\t\tprint(1)\n\telif x>7 and x%7==0:\n\t\tprint(x//7)\n\telif x>7 and x%7>1:\n\t\tprint(x//7+1)\n\telif x>7 and x%7==1 and x%5==0:\n\t\tprint(x//5)\n\telif x>7 and x%7==1 and x%5>1:\n\t\tprint(x//5+1)"}, {"source_code": "x = int(input())\nfor i in range(x):\n\ta = int(input())\n\tk = 0\n\tif x > 7:\n\t\tt = int(a/7)\n\t\ta = a - a*t\n\t\tk = k + t\n\telif a > 0:\n\t\ta = 0\n\t\tk = k + 1\n\tprint(k)"}, {"source_code": "t=int(input())\nfor _ in range(t):\n n=int(input())\n c=0\n if(n>7):\n c+=n//7\n n=n%7\n if(n>6):\n c+=n//6\n n=n%6\n if(n>5):\n c+=n//5\n n=n%5\n if(n>4):\n c+=n//4\n n=n%4\n if(n>3):\n c+=n//3\n n=n%3\n if(n>2):\n c+=n//2\n n=n%2\n print(c)\n \n \n"}, {"source_code": "x=int(input())\n#no of queries\nl=[2,3,4,5,6,7]\nz=7\ncount=0\nfor i in range(x):\n count=0\n z=7\n y=int(input())\n if y in l:\n print(1)\n continue\n else:\n while y!=0 and z>1:\n m=y//z\n y-=(m*z)\n count+=m\n z-=1\n print (count)\n \n"}, {"source_code": "t = int(input())\nl = []\nfor i in range(t):\n x = int(input())\n ans = 0\n for i in range(7,1,-1):\n while(x>=i):\n ans+=1\n x-=i\n print(ans)\n"}, {"source_code": "n = int(input())\nfor i in range(n):\n x = int(input())\n print(x/2)"}, {"source_code": "for i in range(int(input())):\n a = int(input())\n if a % 2 == 0:\n print(a//2)\n elif a % 2 != 0:\n e = a // 2\n w = abs(e-3)\n if w == 0:\n print(1)\n else:\n print(w)"}, {"source_code": "t = int(input())\nfor q in range(t):\n a = int(input())\n if a==2:\n num = 1\n elif a==3:\n num = 1\n elif a==4:\n num = 1\n elif a>4:\n num = (a//5)+(a%5)\n print(num)"}, {"source_code": "from math import ceil\n\nfor _ in range(int(input())):\n n=int(input())\n print(ceil(n/2))"}, {"source_code": "T=int(input())\nfor i in range(T):\n x=int(input())\n a=x//7\n x=x%7\n b=x//6\n x=x%6\n c=x//5\n x=x%5\n d=x//4\n x=x%4\n e=x//3\n x=x%3\n f=x//2\n print(a+b+c+d+e+f)\n"}, {"source_code": "x = int(input())\ny = [int(input()) for c in range(x)]\n\nfor c in range(x):\n print((y[c])//7)\n"}, {"source_code": "x=int(input())\nfor i in range(x):\n print(int(input())//x)"}, {"source_code": "n = int(input())\ncount = []\nfor i in range(n):\n num = int(input())\n if (num/3) == 0:\n count.append(int(num/3))\n else:\n count.append(int(num/3)+1)\nfor i in range(n):\n print(count[i])"}, {"source_code": "x = int(input())\nfor i in range(x):\n\ta = int(input())\n\tk = 0\n\tif x > 7:\n\t\tt = int(a/7)\n\t\ta = a - a*t\n\t\tk = k + t\n\tif a > 0:\n\t\ta = 0\n\t\tk = k + 1\n\tprint(k)"}, {"source_code": "t = int(input())\nnums = [int(input()) for i in range(t)]\nfor k in nums:\n\tif k%2==0:\n\t print(k/2)\n\telif k==3:\n\t print(\"1\")\n\telse:\n\t print((k-3)/2)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Dec 15 20:59:44 2018\n\n@author: mach\n\"\"\"\n\nt = int(input())\nl = [7,6,5,4,3,2]\nfor _ in range(t):\n s = 0\n u = int(input())\n\n for i in l:\n if u >= i : \n if u % i > 1:\n \n s += u//i\n u = u%i\n print(s)"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Dec 17 20:47:41 2018\n\n@author: mach\n\"\"\"\n\ni = int(input())\n\nfor _ in range(i):\n o = int(input())\n if o < 3:\n print(o//2)\n print(o//3)"}], "src_uid": "a661b6ce166fe4b2bbfd0ace56a7dc2c"} {"nl": {"description": "The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party...What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $$$n$$$ cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle.Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are $$$m$$$ cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment?Could you help her with this curiosity?You can see the examples and their descriptions with pictures in the \"Note\" section.", "input_spec": "The only line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \\leq n \\leq 1000$$$, $$$0 \\leq m \\leq n$$$)\u00a0\u2014 the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.", "output_spec": "Print a single integer\u00a0\u2014 the maximum number of groups of cats at the moment Katie observes.", "sample_inputs": ["7 4", "6 2", "3 0", "2 2"], "sample_outputs": ["3", "2", "1", "0"], "notes": "NoteIn the first example, originally there are $$$7$$$ cats sitting as shown below, creating a single group: At the observed moment, $$$4$$$ cats have left the table. Suppose the cats $$$2$$$, $$$3$$$, $$$5$$$ and $$$7$$$ have left, then there are $$$3$$$ groups remaining. It is possible to show that it is the maximum possible number of groups remaining. In the second example, there are $$$6$$$ cats sitting as shown below: At the observed moment, $$$2$$$ cats have left the table. Suppose the cats numbered $$$3$$$ and $$$6$$$ left, then there will be $$$2$$$ groups remaining ($$$\\{1, 2\\}$$$ and $$$\\{4, 5\\}$$$). It is impossible to have more than $$$2$$$ groups of cats remaining. In the third example, no cats have left, so there is $$$1$$$ group consisting of all cats.In the fourth example, all cats have left the circle, so there are $$$0$$$ groups."}, "positive_code": [{"source_code": "n, m = map(int, input().split())\nif(m == 0):\n print(1)\nelse:\n print(min(m, n - m))"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef solve(n, m):\n if n == m:\n return 0\n if m == 0 or m == 1:\n return 1\n return min(m, n - m)\n\ndef main():\n n, m = map(int, input().split())\n print(solve(n, m))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n,m=[int(i) for i in input().split()]\nif m==0:\n print(1)\n exit(0)\nnorm=n//2\nshould=n-norm\nif n%2==1:\n should-=1\n if m>norm:\n norm+=1\nres=should-abs(m-norm)\nprint(res)"}, {"source_code": "'''input\n3 3\n'''\nfrom collections import defaultdict as df\nfrom bisect import bisect_right as bl \nimport sys\n\nRI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\n\n\nn,m = RI()\nprint min(n-m, max(m,1) )\n\n"}, {"source_code": "n,m = map(int, input().split())\nif m==0:\n print(1)\nelse:\n print(min(n-m, m))"}, {"source_code": "list = list(map(int,input().split()))\n\n#number of cats\nn = list[0]\n#number of cats who left the circle\nm = list[1]\n\nif(m==0) :print(1)\nelif(m<=n//2):print(m)\nelse: print(n-m)"}, {"source_code": "n,m = map(int,input().split())\n \nif n == m:\n\tprint(0)\nelif m <= 1:\n\tprint(1)\nelif m <= n // 2:\n\tprint(m)\nelse:\n\tprint(n - m)"}, {"source_code": "import sys\nfrom math import *\nfrom fractions import gcd\nreadints=lambda:map(int, input().strip('\\n').split())\n\nn,m=readints()\nif m==0:\n print(1)\nelif m<=n//2:\n print(m)\nelse:\n print(n-m)\n"}, {"source_code": "numbers = input().split()\ncatsBefore = int(numbers[0])\ncatsGone = int(numbers[1])\nif catsGone == 0:\n print(1)\nelse:\n if catsGone <= catsBefore // 2:\n print(catsGone)\n else:\n print(catsBefore - catsGone)"}, {"source_code": "n,k=[int(i) for i in input().split()]\nif k==0:\n print(1)\nelif k>n//2:\n print(n-k)\nelse:\n print(k)\n"}, {"source_code": "n, m = list(int(a) for a in input().split())\nif m == 0 or m ==1:\n print(1)\nelif m == n:\n print(0)\nelse:\n f = 0\n while n > 2 and m > 0:\n m -= 1\n n -= 2\n f += 1\n if m > 0:\n print(f-m+n)\n else:\n print(f)\n"}, {"source_code": "n,m=map(int,raw_input().split())\nif m==0:\n print 1\nelif n==m:\n print 0\nelif m>n//2:\n print n-m\nelse:\n print m"}, {"source_code": "data_input = input().split()\n\nall_cats = int(data_input[0])\nleave_cats = int(data_input[1])\nreal_cats = all_cats - leave_cats\n\nif leave_cats == 0:\n print(1)\nelif real_cats == 0:\n print(0)\nelif all_cats/2 > leave_cats:\n listik_of_cats = []\n for cat in range(all_cats):\n listik_of_cats.append(cat+1)\n\n i = 1\n while i < all_cats:\n listik_of_cats[i] = 0\n i += 2\n leave_cats -= 1\n if leave_cats == 0:\n break\n if i > all_cats:\n i = 0\n \n answer = 0 \n for i in range(1,all_cats):\n if listik_of_cats[i] == 0 and listik_of_cats[i-1]:\n answer += 1 \n \n print(answer)\nelse:\n print(all_cats - leave_cats)\n"}, {"source_code": "import sys\nimport math\n#q=int(sys.stdin.readline())\nq=1\nfor _ in range(q):\n #n=int(sys.stdin.readline())\n n,m=map(int,sys.stdin.readline().split())\n #a=list(map(str,sys.stdin.readline().split()))\n if m==0:\n print(1)\n else:\n print(min(m,n-m))\n "}, {"source_code": "line = raw_input().split(' ')\na = int(line[0])\nb = int(line[1])\n\nif b == 0:\n\tprint 1\nelse:\n\tprint min(a - b, b)\n\n"}, {"source_code": "n, m = input().split()\nif(m==\"0\"):\n print(1)\nelse:\n print(min(int(m), int(n)-int(m)))"}, {"source_code": "n,m=map(int,raw_input().split())\nif n == 1:\n if m == 0:\n print 1\n else:\n print 0\nelse:\n if m == 0 or m == 1:\n print 1\n elif n==m:\n print 0\n else:\n print min(m,n-m)\n k=0"}, {"source_code": "n,k = map(int, input().split())\nif k==0:\n\tprint(1)\nelif (n>=2*k):\n\tprint(k)\nelse:\n\tprint(n-k)"}, {"source_code": "n,m=map(int,input().split())\nif m==0:\n print(1)\nelse:\n print(min((n-m),m))"}, {"source_code": "numbers = input().split()\ncatsBefore = int(numbers[0])\ncatsGone = int(numbers[1])\nif catsGone == 0:\n print(1)\nelse:\n if catsGone <= catsBefore // 2:\n print(catsGone)\n else:\n print(catsBefore - catsGone)"}, {"source_code": "n,m = map(int,input().split())\nif(n==m):\n print(\"0\")\nelif(m==0):\n print(\"1\")\nelse:\n print(min(n-m,m))"}, {"source_code": "n, m = map(int, raw_input().split())\n\nif m == 0 or m == 1:\n\tprint 1\n\nelse:\n\t\n\tm -= 1\n\tn -= 1\n\tpares = n/2\n\t\n\tif n % 2 :\n\t\tif m <= pares:\n\t\t\tprint m + 1\n\t\t\t\n\t\tif pares < m :\n\t\t\tprint n - m\n\t\t\t\n\telse:\n\t\tif m == pares:\n\t\t\tprint pares \n\t\t\t\n\t\tif m < pares:\n\t\t\tprint m + 1\n\t\t\n\t\t\t\n\t\tif pares < m :\n\t\t\tprint n - m \n\t\t\n"}, {"source_code": "import collections, heapq, sys\n\nn, m = map(int, sys.stdin.readline().rstrip().split(' '))\nif m == 0:\n print(1)\nelse:\n print(min(m, n-m))\n"}, {"source_code": "#code\n\nR = lambda:map(int,input().split())\n\nn, m = R()\nprint(min(max(m,1),n-m))\n"}, {"source_code": "inp=map(int,str(raw_input()).split(\" \"))\nif(inp[1]==0):\n print(1)\nelif(inp[0]==inp[1]):\n print(0)\nelse:\n if(inp[0]//inp[1]>=2):\n print(inp[1])\n else:\n print(inp[0]%inp[1])"}, {"source_code": "arg = map(int, raw_input().strip().split())\n\nnum_of_cat_left = arg[0] - arg[1]\n\nnum_of_space = arg[1]\n\nif num_of_space == 0:\n\tprint 1\nelse:\n\tif num_of_space > num_of_cat_left:\n\t\tprint num_of_cat_left\n\telif num_of_space == num_of_cat_left:\n\t\tprint num_of_cat_left\n\telif num_of_space < num_of_cat_left:\n\t\tprint num_of_space"}, {"source_code": "def f(l):\n n,m = l\n if m<2:\n return 1\n return min(m,n-m)\n\nl = list(map(int,input().split()))\nprint(f(l))\n\n"}, {"source_code": "n,m=map(int,raw_input().split())\n\nif(m==0):\n print 1\nelif(m>n/2):\n m=n-m\n print m\nelse:\n print m\n"}, {"source_code": "n, m = map(int, (input().split()))\ndef max_part(n,m):\n if m>0: \n if n//2 == 0:\n if m <= n//2:\n return m\n else:\n return n-m\n else:\n if m <=(n-1)//2:\n return m\n else:\n return n-m\n else:\n return 1\n\nprint(max_part(n,m))\n \n\n \n"}, {"source_code": "n,m=map(int,input().split())\nif(m==1 or m==0):\n print(\"1\")\nelif m<=n//2:\n print(m)\nelse:\n print(n-m)\n "}, {"source_code": "#!/usr/bin/env python\n\"\"\"\"\"\"\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 _str = str\n str = lambda x=b\"\": x if type(x) is bytes else _str(x).encode()\n\n\ndef main():\n n, m = map(int, input().split())\n if m == 0:\n print(1)\n elif m <= n // 2:\n print(m)\n else:\n print(n - m)\n\n\n# region fastio\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\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\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\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import os \nimport sys \n \n# solve \ndef solve(): \n n, m = map(int, input().split())\n print(min(m, n - m) if m != 0 else 1)\n \n# main \nif __name__ == \"__main__\": \n solve() "}, {"source_code": "def f(l):\n n,m = l\n if m<2:\n return 1\n return min(m,n-m)\n\nl = list(map(int,input().split()))\nprint(f(l))\n\n"}, {"source_code": "a, b = map(int, input().split())\n\nif(b == 0):\n print(1)\nelse:\n print(b if b<= a//2 else a- b)\n"}, {"source_code": "n, m = [int(i)for i in input().split(' ')]\ndef helper(n, m):\n if m <= 1:\n return 1\n if n == m:\n return 0\n return min(m, n-m)\n\nprint(helper(n,m))\n"}, {"source_code": "from sys import stdin, stdout\n\nn, m = map(int, input().split())\n\nif m == 0:\n print(1)\nelif m < n / 2:\n print(m)\nelse:\n print(n - m)\n"}, {"source_code": "arg = map(int, raw_input().strip().split())\n\nnum_of_cat_left = arg[0] - arg[1]\n\nnum_of_space = arg[1]\n\nif num_of_space == 0:\n\tprint 1\nelse:\n\tif num_of_space > num_of_cat_left:\n\t\tprint num_of_cat_left\n\telif num_of_space == num_of_cat_left:\n\t\tprint num_of_cat_left\n\telif num_of_space < num_of_cat_left:\n\t\tprint num_of_space"}, {"source_code": "n,m=(int(i) for i in input().split())\nif (m==0):\n if (n==0):\n print(\"0\")\n else:\n print(\"1\")\nelif (n<=2*m):\n if (m==1):\n if (n==1):\n print(\"0\")\n else:\n print(\"1\")\n elif (m==2):\n if (n<=m):\n print(\"0\")\n elif ((n-m)==1):\n print(\"1\")\n else:\n print(\"2\")\n else:\n if (n<=m):\n print(\"0\")\n else:\n print(n-m)\n \nelse:\n if (n<=m):\n print(\"0\")\n else:\n print(m)\n"}, {"source_code": "n,m=map(int,input().split())\nif m==0:\n print(1)\n exit()\nprint(min(m,n-m))"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri May 10 15:31:47 2019\n\n@author: tarushpc\n\"\"\"\ndef convert(string):\n return string.split(sep=None,maxsplit=-1)\n\ndef toint(lst):\n result=[]\n for i in lst:\n result.append(int(i))\n return result\n\ns=toint(convert(input()))\n\nn=s[0]\nm=s[1]\n\nif n==m:\n print(0)\nelif m==0 or m==1:\n print(1)\nelif n-m>m:\n print(m)\nelse:\n print(n-m)\n"}, {"source_code": "n, m = map(int, (input().split()))\ndef max_part(n,m):\n if m>0: \n if n//2 == 0:\n if m <= n//2:\n return m\n else:\n return n-m\n else:\n if m <=(n-1)//2:\n return m\n else:\n return n-m\n else:\n return 1\n\nprint(max_part(n,m))\n \n\n \n"}, {"source_code": "\"\"\"\nAuthor : raj1307 - Raj Singh\nInstitute : Jalpaiguri Government Engineering College\nDate : 9.05.19\n\"\"\"\nfrom __future__ import division, print_function\nimport itertools,os,sys\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\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\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\ndef dmain():\n sys.setrecursionlimit(100000000)\n threading.stack_size(20480000)\n thread = threading.Thread(target=main)\n thread.start()\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,m=mi()\n \n if m==0:\n print(1)\n exit()\n \n print(min(n-m,m))\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\nif __name__ == \"__main__\":\n main()\n #dmain()\n "}, {"source_code": "name = raw_input() # Python 2.x\n(n,m) = name.split(' ')\nm = int(m)\nn = int(n)\nif (m==0):\n\tprint(1)\n\nelse:\n\tprint(min(n-m, m))"}, {"source_code": "n, m = input().split()\nif(m==\"0\"):\n print(1)\nelse:\n print(min(int(m), int(n)-int(m)))"}, {"source_code": "import os \nimport sys \n \n# solve \ndef solve(): \n n, m = map(int, input().split())\n print(min(m, n - m) if m != 0 else 1)\n \n# main \nif __name__ == \"__main__\": \n solve() "}, {"source_code": "n,m=map(int,input().split())\nif n==m:\n print('0')\nelif m==0:\n print(1)\nelif n/2 h and n%2:\n cur += 1\nif m > cur:\n for i in range(cur+1,m+1):\n ans-= 1\nif m == 0:\n print (1)\nelse:\n print(ans)"}, {"source_code": "n=input().split()\nx=int(n[0])\ny=int(n[1])\nt=x-y\nif t==0:\n print(0)\nelif y==0:\n print(1)\nelse:\n bz=0\n for i in range(1,t+1):\n p=t\n p_2=y\n m=0\n \n while p>0 and p_2!=0:\n p_2-=1\n p-=i\n m+=1\n if m>bz:\n bz=m\n\n print(bz)\n \n \n \n \n \n \n"}, {"source_code": "n,m = map(int, input().split())\n\nif m == 0:\n print(1)\nelif m == n:\n print(0)\nelif n-m < m:\n print(n-m)\nelse:\n print(m)\n"}, {"source_code": "n,m=map(int,input().split())\nif(m<=1):\n print(\"1\")\nelse:\n if(m>n//2):\n print(n-m)\n else:\n print(m)"}, {"source_code": "vklad = input()\nvklad = vklad.split()\nmyspocet = int(vklad[0])\nmysskip = int(vklad[1])\nmyszostatok = myspocet - mysskip\nmysskupina = 0\nif myspocet/2 >= mysskip:\n\tif mysskip == 0:\n\t\tmysskip = 1\n\tmysskupina = mysskip\n\tprint(mysskupina)\nelif myspocet/2 < mysskip:\n\tmysskupina = myspocet-mysskip\n\tprint(mysskupina)\n\n\t\t"}, {"source_code": "try: \n a,b=map(int,input().split())\n print(min(a-b,max(1,b)))\nexcept:\n print(a)\n print(b)"}, {"source_code": "n, m = map(int, raw_input().split())\n\nif n == 0:\n print 0\nelif m == 0:\n print 1\nelse:\n print min(n-m, m)\n"}, {"source_code": "def solve(n, m):\n\tif m == 0:\n\t\treturn 1\n\treturn min(n-m, m)\n\nn, m = map(int, raw_input().split())\nprint solve(n, m)"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nif m == n:\n\tprint(0)\nelif m < 1:\n\tprint(1)\nelif m <= n // 2:\n\tprint(m)\nelse:\n\tprint(n - m)"}, {"source_code": "n, m = map(int, input().split())\nif m==0:\n print(1)\nelse:\n if(m>n/2):\n print(n-m)\n else:\n print(m)"}, {"source_code": "import random\nimport time\n\nseed = int(time.time())\nrandom.seed(seed)\n\ndef solve(n, m):\n if m == 0:\n return 1\n if m <= n//2:\n return m\n return n - m\n\ndef main():\n xs = [int(x) for x in raw_input().strip().split()]\n print solve(*xs)\n\nif '__main__'==__name__:\n main()\n"}, {"source_code": "n, m = [int(t) for t in input().split(' ')]\n\nremaining = n - m\n\nif m > remaining:\n print(remaining)\nelif m == 0:\n print(1)\nelse:\n print(m)\n"}, {"source_code": "n,m=(int(i) for i in input().split())\nif (m==0):\n if (n==0):\n print(\"0\")\n else:\n print(\"1\")\nelif (n<=2*m):\n if (m==1):\n if (n==1):\n print(\"0\")\n else:\n print(\"1\")\n elif (m==2):\n if (n<=m):\n print(\"0\")\n elif ((n-m)==1):\n print(\"1\")\n else:\n print(\"2\")\n else:\n if (n<=m):\n print(\"0\")\n else:\n print(n-m)\n \nelse:\n if (n<=m):\n print(\"0\")\n else:\n print(m)\n"}, {"source_code": "# -*- coding:utf8 -*-\n# by utoppia\n# 09-05-2019\n\nn, m = map(int, raw_input().split(' '))\n\ndef f(n, m):\n ans = 1\n if m == 0 :\n return 1\n if m == 1:\n if n > 1:\n return 1\n else:\n return 0\n \n\n if m >= 2:\n m -= 2\n n -= 3\n\n if n <= -1:\n ans = 0\n else:\n p = 1\n left = n\n while m > 0:\n m -= 1\n if left >= 2:\n p += 1\n left -= 2\n if left == 1:\n p += 1\n left = 0\n else:\n p -= 1\n ans = p \n if left:\n ans += 1\n return ans\n\nprint f(n, m)\n"}, {"source_code": "def solve(n, m):\n\tif m == 0:\n\t\treturn 1\n\treturn min(n-m, m)\n\nn, m = map(int, raw_input().split())\nprint solve(n, m)"}, {"source_code": "n,m = map(int, input().strip().split())\nh = n//2\nans = 0\ncur = 0\nfor i in range(1,min(m,h)+1):\n ans += 1\n cur += 1\nif m > h and n%2:\n cur += 1\nif m > cur:\n for i in range(cur+1,m+1):\n ans-= 1\nif m == 0:\n print (1)\nelse:\n print(ans)"}, {"source_code": "# cook your dish here\n\nn,m=[int(i) for i in input().split()]\n\nif(m==0):\n print(1)\nelse:\n if(n%2==0):\n if(m<=n//2):\n print(m)\n else:\n print(n-m)\n else:\n if(m<=n//2):\n print(m)\n elif(m==n//2+1):\n print(m-1)\n else:\n print(n-m)\n\n\n\n \n"}, {"source_code": "import collections, heapq, sys\n\nn, m = map(int, sys.stdin.readline().rstrip().split(' '))\nif m == 0:\n print(1)\nelse:\n print(min(m, n-m))\n"}, {"source_code": "inp=map(int,str(raw_input()).split(\" \"))\nif(inp[1]==0):\n print(1)\nelif(inp[0]==inp[1]):\n print(0)\nelse:\n if(inp[0]//inp[1]>=2):\n print(inp[1])\n else:\n print(inp[0]%inp[1])"}, {"source_code": "n, m = map(int, input().split())\nif m == n:\n print(0)\nelif m<=1:\n print(1)\nelse:\n print(min(m, n-m))"}, {"source_code": "n,m = map(int, input().strip().split())\nh = n//2\nans = 0\ncur = 0\nfor i in range(1,min(m,h)+1):\n ans += 1\n cur += 1\nif m > h and n%2:\n cur += 1\nif m > cur:\n for i in range(cur+1,m+1):\n ans-= 1\nif m == 0:\n print (1)\nelse:\n print(ans)"}, {"source_code": "import math as mm\nn,m=map(int,input().split())\nif m==0:\n print(1)\nelse:\n\n if n%2==0:\n if m<=n//2:\n print(m)\n else:\n print(n-m)\n else:\n if m<=mm.floor(n/2):\n print(m)\n elif m==mm.floor(n/2)+1:\n print(m-1)\n else:\n print(n-m)"}, {"source_code": "n,m=map(int,raw_input().split())\nif n == 1:\n if m == 0:\n print 1\n else:\n print 0\nelse:\n if m == 0 or m == 1:\n print 1\n elif n==m:\n print 0\n else:\n print min(m,n-m)\n k=0"}, {"source_code": "numbers = input().split()\ncatsBefore = int(numbers[0])\ncatsGone = int(numbers[1])\nif catsGone == 0:\n print(1)\nelse:\n if catsGone <= catsBefore // 2:\n print(catsGone)\n else:\n print(catsBefore - catsGone)"}, {"source_code": "n, m = map(int, input().split())\nif m < 2:\n print(1)\nelse:\n print(min(m, n - m))"}, {"source_code": "L = list(map(int, input().split()))\nn = int(L[0])\nm = int(L[1])\nif m == 1:\n print (1)\nelif m == 0:\n print (1)\nelif m == n:\n print (0)\nelse:\n L = [2 for i in range(n)]\n for i in range(m):\n to_del = L.index(max(L))\n L[to_del] = -1\n if to_del == 0:\n L[1] -= 1\n L[n-1] -= 1\n elif to_del == n - 1:\n L[0] -= 1\n L[n-2] -= 1\n else:\n L[to_del-1] -= 1\n L[to_del+1] -= 1\n zero = L.count(0)\n one = int(L.count(1)/2)\n print (zero + one)\n\n"}, {"source_code": "n, m = map(int, input().split())\nprint(min(n - m, max(m, 1)))"}, {"source_code": "n,m = map(int,input().strip().split())\nif m == 0:\n print(1)\nelif m == n:\n print(0)\nelse:\n m -= 1\n n -= 1\n nums = [i for i in range(1,n+1)]\n index = 0\n for i in range(1,n,2):\n if index >= m:\n break\n nums[i] = 0\n index += 1\n if index == 0:\n print(1)\n else:\n\n if index >= m:\n ans = index\n if index<<1 < len(nums):\n ans += 1 \n ## for i in nums:\n ## if i == 0:\n ## ans += 1\n else:\n need = m - index\n ## if nums[-1] == 0:\n ## need -= 1\n while need > 0:\n for i in range(len(nums) - 1,-1,-1):\n if nums[i] != 0:\n nums[i] = 0\n break\n need -= 1\n ans = 0\n for i in range(len(nums)):\n if nums[i] != 0:\n ans += 1\n print(ans)\n \n"}, {"source_code": "n,m=map(int,raw_input().split())\nprint(n-m if m*2>n else max(m,1))\n\n\nexit()"}, {"source_code": "n, m = map(int, input().split())\n\nprint(min(m, n - m) if m != 0 else 1)"}, {"source_code": "n, m = map(int, input().split())\nif m == n:\n print(0)\nelif(m == 0):\n print(1)\nelse:\n if m > n // 2:\n print(n - (n - (n - m)))\n else:\n print(n - (n - m))"}, {"source_code": "import math\nn, m = [int(x) for x in input().split(' ')]\nif m == 0:\n print(1)\nelse:\n print(min(m, n - m))\n"}, {"source_code": "n, m = map(int, input().split())\nprint(min(max(1, m), n - m))"}, {"source_code": "'''input\n3 3\n'''\nfrom collections import defaultdict as df\nfrom bisect import bisect_right as bl \nimport sys\n\nRI = lambda : [int(x) for x in raw_input().split()]\nrw = lambda : raw_input().strip()\n\n\nn,m = RI()\nprint min(n-m, max(m,1) )\n\n"}, {"source_code": "n,m = [int(i) for i in input().split()]\n\nprint(int(1/2*(1/2*(m+1+abs(m-1))+n-m-abs(1/2*(m+1+abs(m-1))-n+m))))"}, {"source_code": "n, m = map(int, input().split())\nif m < 2:\n print(1)\nelse:\n print(min(m, n - m))"}, {"source_code": "n,m=[int(i) for i in input().split()]\nif m==0:\n print(1)\n exit(0)\nnorm=n//2\nshould=n-norm\nif n%2==1:\n should-=1\n if m>norm:\n norm+=1\nres=should-abs(m-norm)\nprint(res)"}, {"source_code": "n,m = map(int,input().split())\nif m==0:\n print(1)\nelse:\n print(min(m,n-m))"}, {"source_code": "\nn,m = map(int,input().split())\n\nif m ==0 :\n \n print(1)\n\nelif m>n//2 :\n \n print(n-m)\n \nelse :\n \n print(m)"}, {"source_code": "n, m = map(int, input().split())\nans = 1\nif m > n // 2:\n print(n - m)\nelse:\n for i in range(2, m + 1):\n ans += 1\n print(ans)\n"}, {"source_code": "n, m = map(int, input().split())\nif m * 2 <= n:\n\tprint(max(1, m))\nelse:\n\tif n % 2 == 0:\n\t\tprint(n - m)\n\telse:\n\t\tk = m - n // 2\n\t\tif k <= 1:\n\t\t\tprint(n // 2)\n\t\telse:\n\t\t\tk -= 2\n\t\t\tprint(n // 2 - k - 1)"}, {"source_code": "n,m=input().split()\nif int(m)==0:\n print(1)\nelif int(m)<=int(n)/2:\n print(int(m))\nelse:\n print(int(n)-int(m))"}, {"source_code": "\nfrom math import floor,ceil\n\n\nn,m = map(int,input().split())\n\nhash = {}\n\n\nfor i in range(1,n+1):\n hash[i] = False\n\ncount = 0\nans = 1\nflag = 0\nfor i in range(1,n+1,2):\n\n if count=n/2:\n print(n-m)\nelif m=n/2:\n print(n-m)\nelif m2 or int(x[0])%int(x[1])==0 and int(x[0])!=int(x[1]) :\n print(int(x[1]))\n else:\n \n print(int(x[0])-int(x[1]))\n\n"}, {"source_code": "# -*- coding:utf-8 -*-\n\n\nx = raw_input()\ny = []\nfor i in range(2):\n y.append(int(x.split()[i]))\n# print(y)\n\nif y[1] == 0:\n print(1)\nelif y[1] == y[0]:\n print(0)\nelif y[0] % 2 == 0:\n z = y[0] / 2\n if y[1] <= z:\n print(y[1])\n else:\n print(y[0] - y[1])\nelif y[0] % 2 == 1:\n z_ = (y[0]-1) / 2\n if y[1] <= z_:\n print(y[1])\n else:\n print(y[0] - y[1])\n\n\n"}, {"source_code": "n,m = map(int,input().split());print([min(m,n-m),1][m==0])"}, {"source_code": "n,k = input().split()\nn = int(n)\nk = int(k)\nnum = []\ncount = 0\nfor i in range(1,n+1):\n num.append(i)\nfor i in range(k):\n del num[(i+1)%len(num)]\nfor i in range(len(num)):\n if num[(i+1)%len(num)] > num[i]+1:\n count+=1\nif count == 0 and len(num) > 0:\n count = 1\nif len(num) > 1:\n if num[0] != 1 or num[len(num)-1]!=n:\n count += 1\nprint(count)\n"}, {"source_code": "n=input().split()\nx=int(n[0])\ny=int(n[1])\nt=x-y\nif t==0:\n print(0)\nelif y==0:\n print(1)\nelse:\n bz=0\n for i in range(1,t+1):\n p=t\n p_2=y\n m=0\n \n while p>0 and p_2!=0:\n p_2-=1\n p-=i\n m+=1\n if m>bz:\n bz=m\n\n print(bz)\n \n \n \n \n \n \n"}], "negative_code": [{"source_code": "n,m=map(int,input().split())\nif m==0:\n ans=1 \nelif m>=n//2:\n ans=n-m \nelse:\n ans=m\nprint(ans)"}, {"source_code": "k,n = [int(i) for i in input().split()]\nif n==0:\n print(k)\nelif k==n:\n print(0)\nelse:\n print((k-n)//(n-1)+1)"}, {"source_code": "a=list(map(int,input().split()))\nb=a[0]-a[1]\nif(a[1]==0):\n\tprint(1)\nelif(a[1]==1):\n\tprint(1)\nelse:\n\tq=int(b/a[1])\n\tr=int(b%a[1])\n\tif(a[1]==0):\n\t\tprint(0)\n\telif(q==1):\n\t\tprint(r)\n\telse:\n\t\tprint(q+r)"}, {"source_code": "n,m=map(int,input().split())\nx=n-m\nif(x==0):\n print(0)\nelif(x<=n//2):\n print(x)\nelse:\n print(m)\n"}, {"source_code": "a=list(map(int,input().split()))\nb=a[0]-a[1]\nif(a[1]==0):\n\tprint(1)\nelif(a[1]==1):\n\tprint(1)\nelse:\n\tq=int(b/a[1])\n\tr=int(b%a[1])\n\tif(a[1]==0):\n\t\tprint(0)\n\telif(q==1):\n\t\tprint(r)\n\telse:\n\t\tprint(q+r)"}, {"source_code": "n,m=map(int,input().split())\nif(m<=1):\n print(\"1\")\nelse:\n if(m>=n//2):\n print(n-m)\n else:\n print(m)"}, {"source_code": "n,m = [int(i) for i in input().split()]\n\nprint(int(1/2*(1/2*(m+1+abs(m-1))+n-m-abs(2*m-n))))"}, {"source_code": "a,b = list(map(int, input().split()))\nr = a-b\nif r <= int(a/2):\n print(r)\nelse:\n print(b)"}, {"source_code": "n,m=map(int,input().split())\nif m==0:\n print(1)\nelif n%m==0 and n!=m:\n print(m)\nelif n//m>=2:\n print((n%m)+1)\nelif n//m<=1 and n!=m:\n print(n%m)\nelif n==m:\n print(0)"}, {"source_code": "a,b=map(float,raw_input().split())\nif(a==b):\n\tprint 0\nelif(b==0 or b==1):\n\tprint 1\nelif(a/2 0:\n a[i - 1] = 0\nelse:\n for i in range(1, 1 + n):\n if i % 2 != 0 and m > 0:\n a[i - 1] = 0\n \ncnt = 0\ni = 0\nans = 0\nwhile i < n:\n if a[i] != 0:\n cnt += 1\n else:\n if cnt != 0:\n ans += 1\n i += 1\n\nif (a.count(0) == 0):\n ans += 1\n \nprint(ans)\n\n"}, {"source_code": "from math import ceil\nn,m = map(int,input().split())\nif m==0 or m==1:\n print(1)\n exit()\nif m==n:\n print(0)\n exit\n\nprint(ceil(m/2)+1)\n#for i in range(m)\n"}, {"source_code": "def fun(n,m):\n if n == 1 and m == 1:\n return 0\n if n == 1 and m > 1:\n return 0\n if m == 0:\n return 0\n if m == 1:\n return 1\n p=n\n k =0\n while p > 1:\n p=p/2\n k += 1\n return min(n-m,fun(n-pow(2,k),m-k)+k)\nn,m=map(int,raw_input().split())\ncheck = []\nif m == 0:\n print 1\nelif m == n:\n print 0\nelse:\n ans=fun(n,m)\n print ans"}, {"source_code": "n, m = list(int(a) for a in input().split())\nif m == 0 or m ==1:\n print(1)\nelif m == n:\n print(0)\nelse:\n f = 0\n while n > 2 and m > 0:\n m -= 1\n n -= 2\n f += 1\n print(f)\n"}, {"source_code": "n,m=map(int,input().split())\nprint(min(m,n-m))"}, {"source_code": "noOfCat,catLeft=input().split(\" \")\nnoOfCat=int(noOfCat)\ncatLeft=int(catLeft)\nnoOfCat\npriorityQue=[]\npriorityQue.append(noOfCat-1)\ncatCounter=catLeft-1\nif catLeft==0:\n print(1)\nelif catLeft==1:\n print(1)\nelif catLeft>=2:\n while catCounter>0:\n priorityQue.sort()\n tmp=priorityQue.pop()\n grpsplit1=tmp//2\n grpsplit2=tmp-grpsplit1-1\n if grpsplit1>grpsplit2:\n if grpsplit2!=0 :\n priorityQue.append(grpsplit2)\n if grpsplit1!=0 :\n priorityQue.append(grpsplit1)\n else:\n if grpsplit1!=0 :\n priorityQue.append(grpsplit1)\n if grpsplit2!=0 :\n priorityQue.append(grpsplit2)\n catCounter-=1\n print(priorityQue.__len__())"}, {"source_code": "import math\nfrom fractions import Fraction as frac\n\nMOD = 1e9 + 7\n\ndef gcd(a, b):\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\ndef solve(case_no):\n n, m = map(int, input().split())\n print(n - max(m, n - m))\n \t\n\nt = 1\n# t = int(input())\nfor i in range(1, t + 1):\n solve(i)\n"}, {"source_code": "a,b=[int(i) for i in input().split()]\nl=[1]*a\nif(b==0):\n print(1)\nelif(a==b):\n print(0)\nelse:\n for i in range(0,len(l),2):\n l[i]=0\n if(l.count(0)==b):\n break\n flag=0\n c=0\n for i in range(0,len(l)):\n if(l[i]==1):\n if(flag==1):\n flag=0\n c=c+1\n else:\n pass\n elif(l[i]==0):\n flag=1\n print(c)"}, {"source_code": "n, m = [int(i) for i in input().split()]\n\nif n % 2 == 0:\n if m <= n / 2:\n res = m\n else:\n res = n - m\nelse:\n if m <= n // 2 + 1:\n res = m\n else:\n res = n - m\n\nprint(res)\n"}, {"source_code": "ent=input().split() #taking the input\nl1=int(ent[0])\nl2=int(ent[1])\nif(l1<=1000 and l1<=0 and l2<=0):\n if l2==0:\n group=1\n elif l2==l1:\n group=0\n else:\n members=int((l1-l2)/2) \n group=int((l1-l2)/members)\n print(group)\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nprint(min(n-m,1+(m//2)))"}, {"source_code": "#!/usr/bin/env python3\nimport atexit\nimport io\nimport sys\n\n_I_B = sys.stdin.read().splitlines()\ninput = iter(_I_B).__next__\n_O_B = io.StringIO()\nsys.stdout = _O_B\n\n@atexit.register\ndef write():\n sys.__stdout__.write(_O_B.getvalue())\n\n\ndef main():\n n,m=map(int,input().split())\n if n==m:\n print(0)\n elif m==0 or m==1:\n print(1)\n else:\n print(min(n//2,n-m))\n\n\nif __name__=='__main__':\n main()"}, {"source_code": "\nn, m = map(int,input().split())\n\nfull = n // 2 + n % 2\n\nprint(n // 2 - max(0, m - full))\n\n\n"}, {"source_code": "n,m=(int(i) for i in input().split())\nif (n<=10):\n if (m==0):\n print(\"1\")\n elif (m==1):\n if (n==1):\n print(\"0\")\n else:\n print(\"1\")\n elif (m==2):\n if (n<=m):\n print(\"0\")\n else:\n print(\"2\")\n else:\n if (n<=m):\n print(\"0\")\n else:\n print(n-m)\n \nelse:\n if (n<=m):\n print(\"0\")\n else:\n print(m)\n"}, {"source_code": "n,m=(int(i) for i in input().split())\nif (n<=10):\n if (m==0):\n print(\"1\")\n elif (m==1):\n if (n==1):\n print(\"0\")\n else:\n print(\"1\")\n elif (m==2):\n if (n<=m):\n print(\"0\")\n else:\n print(\"2\")\n else:\n if (n<=m):\n print(\"0\")\n else:\n print(n-m)\n \nelse:\n if (n<=m):\n print(\"0\")\n else:\n print(m)\n"}, {"source_code": "try: \n a,b=map(int,input().split())\n l=a-b\n if not b:\n print(1)\n else:\n if l/b<1:\n print(l)\n else:\n if l/b==l//b:\n print(l//b)\n else:\n print((l//b)+1)\nexcept:\n print(a)\n print(b)\n "}, {"source_code": "#!/usr/bin/env python3\nimport atexit\nimport io\nimport sys\n\n_I_B = sys.stdin.read().splitlines()\ninput = iter(_I_B).__next__\n_O_B = io.StringIO()\nsys.stdout = _O_B\n\n@atexit.register\ndef write():\n sys.__stdout__.write(_O_B.getvalue())\n\n\ndef main():\n n,m=map(int,input().split())\n if n==m:\n print(0)\n elif m==0 or m==1:\n print(1)\n else:\n print(min(n//2,m))\n\n\nif __name__=='__main__':\n main()"}, {"source_code": "n, m = list(map(int, input().split()))\nif m == 0:\n print(1)\n exit()\nprint(min(m + 1, n - m))"}, {"source_code": "ent=input().split() #taking the input\nl1=int(ent[0])\nl2=int(ent[1])\nif(l1<=1000 and l1<=0 and l2<=0):\n if l2==0:\n group=1\n elif l2==l1:\n group=0\n else:\n members=int((l1-l2)/2) \n group=int((l1-l2)/members)\n print(group)\n"}, {"source_code": "n,m=[int(x) for x in input().split()]\nif m==0:\n print(0)\nelse:\n if m-1>n//2:\n print(n-m)\n else:\n print(m)\n"}, {"source_code": "import math\n\nn,m = map(int, input().split())\n\ndef main():\n global m,n\n \n if m == n:\n return 0\n elif m == n-1:\n return 1\n elif m == 0 or m == 1:\n return 1\n else:\n required = math.ceil(n/2)\n\n if m >= required:\n return math.trunc(n/2) - (m - required)\n\n if n % 2 and m == required - 1:\n m -= 1\n\n return m\n\nprint(main())\n"}, {"source_code": "a,b=map(int,input().split());print(min(a-b,b))"}, {"source_code": "n, m = map(int,input().split())\nans = n // 2 - abs(m - n // 2)\nif n % 2 != 0:ans += 1\nprint(ans)\n\n\n"}, {"source_code": "import math\nn,m=map(int,input().split())\nprint(min(n-m,1+(m//2)))"}, {"source_code": "n, m = list(int(a) for a in input().split())\nif m == 0 or m ==1:\n print(1)\nelif m == n:\n print(0)\nelse:\n f = 0\n while n > 2 and m > 0:\n m -= 1\n n -= 2\n f += 1\n print(f)\n"}, {"source_code": "from math import ceil\nn,m = map(int,input().split())\nif m==0 or (m==1 and n!=1):\n print(1)\n exit()\nif m==n:\n print(0)\n exit()\n\n#print(ceil(m/2)+1)\n\nc = 1\nfor i in range(0,m,2):\n c+=1\nprint(c)\n"}, {"source_code": "n, m = list(map(int, input().split()))\nprint(min(m + 1, n - m))"}, {"source_code": "n, m = map(int, input().split())\nif n >= 2 * m:\n print(m)\nelse:\n print(n - m)"}, {"source_code": "inp = input().split()\nn = int(inp[0])\nm = int(inp[1])\n\nif 2*m <= n:\n\tprint(m)\nelse:\n\tprint(n-m)"}, {"source_code": "n, m = map(int, input().split())\n\nif n == m:\n print(0)\nelif m == 0:\n print(1)\nelif n % m == 0:\n print(2)\nelse:\n print(3)"}, {"source_code": "n,m=map(int,input().split())\nc=1\nl=[1]*n\nc=0\ni=0\nif m==n:\n print(0)\nelse:\n \n while(c= mid:\n print(n - m)\n else:\n print(m)"}, {"source_code": "import sys\nn, m = [int(x) for x in input().split()]\nout=0\n\nif(float(m)0): \n\tout=m \nelif(float(m)>n/2):\n\tout=n-m\nelif(m==0):\n\tout=1\n\nprint(out)"}, {"source_code": "n, m = map(int, input().split())\n\nif n == m:\n print(0)\nelif m == 0:\n print(1)\nelif m == 1:\n print(n - 1)\nelse:\n if n % 2 != 0:\n print(n - m)\n elif n % 2 == 0 and m % 2 == 0:\n print(2)\n else:\n print(n - 1)"}, {"source_code": "L = list(map(int, input().split()))\nn = int(L[0])\nm = int(L[1])\nif m == 1:\n print (1)\nelif m == 0:\n print (1)\nelif m == n:\n print (0)\nelse:\n L = [2 for i in range(n)]\n for i in range(m):\n to_del = L.index(max(L))\n L[to_del] = -1\n if to_del == 0:\n L[1] -= 1\n L[n-1] -= 1\n elif to_del == n - 1:\n L[0] -= 1\n L[n-2] -= 1\n else:\n L[to_del-1] -= 1\n L[to_del+1] -= 1\n two = L.count(2)\n zero = L.count(0)\n #print (L) \n if two == 0:\n one = int(L.count(1)/2)\n else:\n one = 0\n #print (zero,one,two)\n print (zero + one + two)\n\n"}, {"source_code": "try: \n a,b=map(int,input().split())\n l=a-b\n if not b and b==True:\n print(1)\n else:\n if l/b<1:\n print(l)\n else:\n if l/b==l//b:\n print(l//b)\n else:\n print((l//b)+1)\nexcept:\n print(a)\n print(b)"}, {"source_code": "import math\nn,m=map(int,input().split())\nif (m == n):\n print(0)\nelif (2 * m > n):\n print(m-1)\nelif (m == 0):\n print(1)\nelse:\n print(m)"}, {"source_code": "n, m = map(int, input().split())\nif(m > int(n/2)):\n print(n - m)\nelse:\n print(m)\n "}, {"source_code": "from numbers import Number\nimport math\n\nfuck = None\ninput2 = None\ns = None\ninputs = None\ni = None\nn = None\nm = None\nanswer = None\n\ndef text_prompt(msg):\n try:\n return raw_input(msg)\n except NameError:\n return input(msg)\n\n\ninput2 = text_prompt('')\ninputs = input2.split(' ')\nn = int(inputs[0])\nm = int(inputs[1])\n# print(m,n)\nif n <= m or m == 0:\n answer = 0\nelse:\n # print('A')\n if n < m * 2:\n m = n - m\n # print('B')\n answer = m\nprint(answer)"}, {"source_code": "#!/usr/bin/env python3\nimport atexit\nimport io\nimport sys\n\n_I_B = sys.stdin.read().splitlines()\ninput = iter(_I_B).__next__\n_O_B = io.StringIO()\nsys.stdout = _O_B\n\n@atexit.register\ndef write():\n sys.__stdout__.write(_O_B.getvalue())\n\n\ndef main():\n n,m=map(int,input().split())\n if n==m:\n print(0)\n elif m==0 or m==1:\n print(1)\n else:\n print(min(n//2,m))\n\n\nif __name__=='__main__':\n main()"}, {"source_code": "n,m = map(int,input().strip().split())\nif m == 0:\n print(1)\nelif m == n:\n print(0)\nelse:\n m -= 1\n n -= 1\n nums = [i for i in range(1,n+1)]\n index = 0\n for i in range(1,n,2):\n if index >= m:\n break\n nums[i] = 0\n index += 1\n if index == 0:\n print(0)\n else:\n\n if index >= m:\n ans = index + 1 if len(nums) % 2 != 0 else index\n ## for i in nums:\n ## if i == 0:\n ## ans += 1\n else:\n need = m - index\n ## if nums[-1] == 0:\n ## need -= 1\n while need > 0:\n for i in range(len(nums) - 1,-1,-1):\n if nums[i] != 0:\n nums[i] = 0\n break\n need -= 1\n ans = 0\n for i in range(len(nums)):\n if nums[i] != 0:\n ans += 1\n print(ans)\n \n"}, {"source_code": "n, m = map(int, raw_input().split())\n\nif m == 0:\n print 1\n exit()\nif m == 1:\n print 1\n \n\nif 2*m >= n:\n print n-m\nelse:\n print n-m-2\n\n"}, {"source_code": "n,m = map(int,input().split());print(min(m,n-m))"}, {"source_code": "n, m = map(int, input().split())\n# n, m = map(int, '3 0'.split())\n\ndef foo(n, m):\n if n == m:\n return 0\n elif m == 0:\n return 1\n elif m > n / 2:\n return n - m\n else:\n return int(n / 2 - 1)\n\nprint(foo(n, m))\n"}, {"source_code": "n=input().split()\nx=int(n[0])\ny=int(n[1])\nt=x-y\nbz=1\nfor i in range(1,t+1):\n p=t\n p_2=y\n m=0\n \n while p>0 and p_2!=0:\n p_2-=1\n p-=i\n m+=1\n if m>bz:\n bz=m\nprint(bz)\n \n \n \n \n \n \n"}, {"source_code": "from numbers import Number\nimport math\n\nfuck = None\ninput2 = None\ns = None\ninputs = None\ni = None\nn = None\nm = None\n\ndef text_prompt(msg):\n try:\n return input(msg)\n except NameError:\n return input(msg)\n\n\ninput2 = text_prompt('')\ninputs = input2.split(' ')\nn = inputs[0]\nm = inputs[1]\nprint(m if n >= m * 2 else (0 if n <= m else math.floor(n / 2) - (m - math.ceil(n / 2))))\n"}, {"source_code": "inp=map(int,str(raw_input()).split(\" \"))\nif(inp[1]==0):\n print(1)\nelif(inp[0]//inp[1]>2):\n print(inp[0]//inp[1]-1)\nelse:\n print(inp[0]-inp[1])"}, {"source_code": "n, m = map(int, input().split())\n\nt = [True] * n\nj = 0\nfor i in range(1, n, 2):\n t[i] = False\n j += 1\n if j == m:\n break\n\nfor i in range(n):\n if t[i]:\n t[i] = False\n j += 1\n if j == m:\n break\n\ni = 0\nc = 0\nwhile i < n:\n if t[i]:\n c += 1\n while i < n and t[i]:\n i += 1\n else:\n i += 1\nprint(c)\n"}, {"source_code": "n,m=map(int,input().split())\nif m!=0:\n if m n:\n k = m - n//2\n if n % 2 != 0:\n k -= 1\n print(n//2-k)\nelse:\n print(m)"}, {"source_code": "n,m=map(int,input().split())\nc=1\nl=[1]*n\nif m [(1, 2), (1, 3), (2, 3)]\n# from itertools import permutations as permutate\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\nmod = 10**9+7\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\n\n#===============================================================================================\n# code here ;))\n\n\ndef solve(case):\n n,m = sep()\n if(n == m):\n print(0)\n return\n \n if(m1 and x[1]!=x[0]:\n if x[0]//2>x[1]:\n print(x[1])\n else:\n print(x[0]-x[1])\nelse:\n if x[1]==0 or x[1]==1:\n print('1')\n if x[1]==x[0]:\n print('0')"}, {"source_code": "k,n = [int(i) for i in input().split()]\nif n==0:\n print(k)\nelif k==n:\n print(0)\nelse:\n print((k-n)//(n-1)+1)"}, {"source_code": "def solve(n, m):\n\treturn max(0, min(n-m, m))\n\nn, m = map(int, raw_input().split())\nprint solve(n, m)\n"}, {"source_code": "import math\nn, m = [int(x) for x in input().split(' ')]\nif m == 0:\n print(1)\nelse:\n c = [n - 1]\n for i in range(m - 1):\n x = c[-1]\n if x == 2:\n c.insert(0, 1)\n elif x > 2:\n c.insert(0, math.ceil((x - 1) / 2))\n c.insert(0, math.floor((x - 1) / 2))\n c.sort()\n del c[-1]\n print(len(c))\n\n"}, {"source_code": "n,m = (int(i) for i in input().split())\nif(m == 0):\n print(1);\nif m < (n/2):\n print(m);\nelif m == (n/2):\n print(m);\nelse:\n print(n - m);\n\n"}, {"source_code": "n,m=map(int,input().split())\nc=1\nl=[1]*n\nc=0\ni=0\nif m==n:\n print(0)\nelse:\n \n while(c= mid:\n print(n - m)\n else:\n print(m)"}, {"source_code": "R = lambda:map(int, raw_input().split())\nL = R()\nn = L[0]\nm = L[1]\nprint(min(m, n-m))\n"}, {"source_code": "b = input().split()\nn, m = int(b[0]), int(b[1])\nif m == 0 or m==1 or m==n-1:\n a = 1\nelif m == n:\n a = 0\nelif m==2:\n a = 2\nelse:\n a = min([m+1, n-m])\nprint(a)"}, {"source_code": "x,y=map(int,input().split())\nk=x%2\nx-=k\ny-=k\nm=x//2\nif y<=1:print(1)\nelse:\n\tif y<=m:\n\t\tprint(y)\n\telse:\n\t\tprint(2*m-y)"}, {"source_code": "n,m=map(int, raw_input().split())\nif m!=0:\n if n/2<=m:\n print n-m\n else:\n print m\nelse:\n print 1"}, {"source_code": "n,m=[int(x) for x in input().split()]\nif m==0:\n print(0)\nelse:\n if m-1>=n//2:\n print(n-m)\n else:\n print(m)\n"}, {"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\nn,k = ei()\nprint(1 if k==0 else min(n,n-k))"}, {"source_code": "k = [*map(int, input().split())]\nif k[1] == 0:\n print(1)\nelif k[0] == k[1]:\n print(0)\nelif k[0]%2==0 and k[1]==2:\n print(2)\nelse:\n p=k[0]//2\n if k[1]>p:\n print(k[0]-k[1])\n elif k[1]==p:\n print(k[1])\n else:\n print(k[1]-1)"}, {"source_code": "n,m = map(int,input().split())\nif m<=n//2:\n ans = m\nelse:\n ans = n//2\n m-=n//2\n if n%2==0:\n ans-=m\n else:\n ans-=m-1\nprint(ans)"}, {"source_code": "n, m = map(int, input().strip().split())\nprint((n-m)//2)"}, {"source_code": "n, m = map(int, input().split())\nif n >= 2 * m:\n print(m)\nelse:\n print(n - m)"}, {"source_code": "data_input = input().split()\n\nall_cats = int(data_input[0])\nleave_cats = int(data_input[1])\nreal_cats = all_cats - leave_cats\n\nif leave_cats == 0:\n print(1)\nelif real_cats == 0:\n print(0)\nelse:\n listik_of_cats = []\n for cat in range(all_cats):\n listik_of_cats.append(cat+1)\n\n i = 1\n while i < all_cats:\n listik_of_cats[i] = 0\n i += 2\n leave_cats -= 1\n if leave_cats == 0:\n break\n if i > all_cats:\n i = 0\n \n answer = 0 \n for i in range(1,all_cats):\n if listik_of_cats[i] == 0 and listik_of_cats[i-1]:\n answer += 1\n \n print(answer)\n"}, {"source_code": "s=input()\nn,m=int(s[0]),int(s[2])\nif m==0:\n print(1)\nelif m==n:\n print(0)\nelif n//m>=2:\n print(m)\nelse:\n print(n-m)"}, {"source_code": "ent=input().split() #taking the input\nm=int(ent[0])\nn=int(ent[1])\nif m<=1000 and m>=0 and n>=0:\n if n==0:\n group=1\n elif m-1<(n/2):\n group=m\n elif (m+1)>=(n/2):\n group=n-m\n print(group)"}, {"source_code": "n, m = map(int,input().split())\n\na = [i for i in range(1, 1 + n)]\nif (n % 2 == 0):\n for i in range(1, 1 + n):\n if i % 2 == 0 and m > 0:\n a[i - 1] = 0\nelse:\n for i in range(1, 1 + n):\n if i % 2 != 0 and m > 0:\n a[i - 1] = 0\n\ncnt = 0\ni = 0\nwhile i < n:\n if a[i] == 0 and i != n - 1:\n cnt += 1\n i += 1\n\nif (a.count(0) == 0):\n cnt += 1\n \nprint(cnt)"}, {"source_code": "from numbers import Number\nimport math\n\nfuck = None\ninput2 = None\ns = None\ninputs = None\ni = None\nn = None\nm = None\nanswer = None\n\ndef text_prompt(msg):\n try:\n return raw_input(msg)\n except NameError:\n return input(msg)\n\n\ninput2 = text_prompt('')\ninputs = input2.split(' ')\nn = int(inputs[0])\nm = int(inputs[1])\n# print(m,n)\nif n <= m:\n answer = 0\nelse:\n # print('A')\n if n < m * 2:\n m = n - m\n # print('B')\n answer = m\nprint(answer)"}], "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648"} {"nl": {"description": "You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be of them.You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoints though). You can not move the segments to a different location on the coordinate axis. Find the minimal number of layers you have to use for the given N.", "input_spec": "The only input line contains a single integer N (1\u2009\u2264\u2009N\u2009\u2264\u2009100).", "output_spec": "Output a single integer - the minimal number of layers required to draw the segments for the given N.", "sample_inputs": ["2", "3", "4"], "sample_outputs": ["2", "4", "6"], "notes": "NoteAs an example, here are the segments and their optimal arrangement into layers for N\u2009=\u20094. "}, "positive_code": [{"source_code": "n = input()\nif (n %2 == 0):\n ans = []\n for i in range(n+1):\n if (i%2 == 0):\n ans.append(i)\n print reduce(lambda x,y:x+y, ans, 0)\n\n\nif (n %2 == 1):\n ans = []\n for i in range(n+1):\n if (i%2 == 1):\n ans.append(i)\n print reduce(lambda x,y:x+y, ans, 0)\n"}, {"source_code": "n=int(raw_input())\ns=[]\nfor i in range(1,n+1):\n\tfor j in range(n-i+1):\n\t\ts.append((j,-j-i))\n\t\t\ns.sort()\n#print(s)\nc=0\nwhile(True):\n\tif len(s)==0:\n\t\tbreak\n\tw=s[0]\n\tdel s[0]\n\ti=0\n\tf=len(s)\n\t#print(c,s)\n\twhile(i1):\n layer=layer+line\nelse:print layer"}, {"source_code": "print((int(input())+1)**2//4)"}, {"source_code": "print((((int)(input()) + 1) ** 2) // 4)\n"}, {"source_code": "n = int(input())\nx = n//2\nprint((x+1)*(n-x))\n"}, {"source_code": "import math\nn=int(input())\nprint(int((n//2+1)*math.ceil(n/2)))"}, {"source_code": "n=int(raw_input())\n\na=0\nfor i in range(1,n+1):\n a=a+min(i,n-i+1)\n\nprint a"}, {"source_code": "import sys\nfrom collections import *\nfrom string import *\nfrom itertools import *\nfrom math import ceil\nn = input()\ntemp = n/2\nans = temp*(temp+1)\nif n&1:\n ans += (n/2+1)\nprint ans\n "}, {"source_code": "import math\nn=int(input())\nprint((math.floor(n/2)+1)*math.ceil(n/2))"}, {"source_code": "#!/usr/bin/python\n\nfrom collections import deque\n\ndef ir(): return int(raw_input())\n\nn = ir()\nc = n/2\ns = 0\nfor i in xrange(0, n):\n for j in xrange(0, n):\n if not i <= j: continue\n if i <= c and c <= j: s += 1\nprint s\n"}, {"source_code": "for i in range(1):\n n=int(input())\n x=n/2\n if x>int(x):\n s=(n//2+1)*(int(x)+1)\n print(s)\n else:\n s=(n//2+1)*(int(x))\n print(s)\n"}, {"source_code": "# Problem: Segment\n\nif __name__ == \"__main__\":\n num = int(input().strip())\n segment = []\n for i in range(1,num+1):\n j = 0\n for j in range(num):\n if j + i <= num:\n segment.append((j,j+i))\n segment.sort(key = lambda x: (x[0],[1]))\n #print(segment)\n layer_count = 0\n \n while segment != []:\n rightend = segment[0][1]\n segment.remove(segment[0])\n j = 0\n while j < len(segment):\n if rightend == segment[j][0]:\n rightend = segment[j][1]\n segment.remove(segment[j])\n else:\n j += 1\n layer_count +=1\n print(layer_count)\n"}, {"source_code": "n=int(input())\ncnt=0\nfor l in range(1,n+1):\n cnt+=min(n-l+1,l)\nprint(cnt)"}, {"source_code": "def num_layers(n):\n count = 0\n for segment_len in xrange(1, n + 1):\n for start_pos in xrange(segment_len):\n if start_pos + segment_len <= n:\n count += 1\n return count\n\n\nn = int(raw_input())\nprint num_layers(n)\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())\n\nS = list()\nfor i in range(n+1):\n for j in range(i+1, n+1):\n S.append([2*i, 2*j])\n\nres = 0\nfor x in range(1, 2*n, 2):\n cnt = 0\n for s in S:\n if s[0] < x and x < s[1]:\n cnt += 1\n res = max(res, cnt)\nprint(res)\n\n\n"}, {"source_code": "n = int(input())\nf = [0] * (n + 1)\nf[1] = 1\nfor i in range(2, n + 1):\n f[i] = i + f[i - 2]\nprint(f[n])\n \n"}, {"source_code": "n=int(input())\npoints=n+1\nans=0\nwhile points>=2:\n ans=ans+(points-1)\n points-=2\nprint(ans)"}, {"source_code": "# B.py\n\nn = int(input())\ni = (n + 1) // 2\nprint(i * (n + 1 - i))"}, {"source_code": "n = int(input())\ne = int(n/2)\nif(n%2 == 0):\n print(e*(e+1))\nelse:\n print(e*(e+1) + int((n+1)/2))"}, {"source_code": "n = input()\nN = n * (n + 1) / 2\n\nsegs = dict()\nfor i in range(1, n + 1):\n segs[i] = []\n\nfor len in range(1, n + 1):\n for i in range(n, len - 1, -1):\n segs[i].append(len)\n\nlays = 0\ncnt = 0\ncurr = n\nwhile cnt < N:\n while segs[curr] != []:\n cc = curr\n while cc > 0:\n while cc > 0 and segs[cc] == []:\n cc -= 1\n if cc == 0:\n break\n\n cct = cc - segs[cc][-1]\n # print (cct, cc),\n segs[cc].pop()\n cc = cct\n cnt += 1\n lays += 1\n # print \"\"\n curr -= 1\n\nprint lays"}, {"source_code": "n=int(input())\n\ndef get(n):\n\tif n%2==1:\n\t\tk = (n+1)//2\n\t\treturn k*k\n\telse:\n\t\tk=n//2\n\t\treturn k*(k+1)\n\nprint(get(n))"}, {"source_code": "from copy import deepcopy\ndef query(l,r, segs):\n global ans\n global N\n if l>=N:\n ans=min(ans,len(segs))\n elif r>=N:\n query(l+1,l+1,segs)\n else:\n Len = r-l+1\n temp = [0 for i in xrange(N)]\n for k in xrange(l,r+1):\n temp[k]=1\n query(l,r+1,segs+[temp])\n for i in xrange(len(segs)):\n if sum(segs[i][l:r+1]) == 0:\n poss=deepcopy(segs)\n for k in xrange(l,r+1):\n poss[i][k]=1\n query(l,r+1,poss)\nN=int(raw_input())+1\nprint N**2/4\n"}, {"source_code": "def main():\n N = int(input())\n\n v = N + 1\n n = 0\n while v > 0:\n n += v - 1\n v -= 2\n\n print(n)\n\nmain()\n"}, {"source_code": "from collections import deque\n\n\ndef main():\n n = int(input())\n intervals = deque()\n\n ans = 0\n for i in range(0, n + 1):\n for j in range(i + 1, n + 1):\n l = len(intervals)\n for k in range(l):\n s, e = intervals[0]\n if s <= i < j <= e:\n intervals.popleft()\n if i < s:\n intervals.appendleft((s, i))\n if j < e:\n intervals.appendleft((j, e))\n break\n intervals.rotate(1)\n else:\n ans += 1\n intervals.append((0, i))\n intervals.append((j, n))\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n=input()\nans=[0 for i in range(n+1)]\nfor i in range(n):\n\tfor j in range(i+1,n+1):\n\t\tfor k in range(i+1,j+1):ans[k]+=1\nprint max(ans)\n"}, {"source_code": "n=int(input())\nif n%2==0:\n res=2\n for i in range(4,n+1,2):\n res+=i\nelse:\n res=1\n for i in range(3,n+1,2):\n res+=i\nprint(res)"}, {"source_code": "import math\nn = int(raw_input())\nans = (int(n/2)+1)*(n-int(n/2))\nprint ans"}, {"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\tadd = 0\n\twhile N>0:\n\t\t# print(N)\n\t\tadd+=(N)\n\t\tN-=2\n\tprint(add)\n\nmain()"}, {"source_code": "print(int(((int(input())+1)/2)**2))"}, {"source_code": "n = int(input())\nprint (sum(range(n, 0 , -2)))\n"}, {"source_code": "print(int(((int(input())+1))**2//4))\n"}, {"source_code": "print(int(((int(input())+1))**2//4))"}, {"source_code": "n = int(input())\nprint (sum(range(n, 0 , -2)))\n"}, {"source_code": "#codig: utf-8\n\nN = int(raw_input())\n\nres = 0\nfor i in range(1, N+1):\n res += min(i, (N+1)-i)\n\nprint res\n"}, {"source_code": "n = input()\nif n % 2 == 1:\n print((n + 1) * (n + 1) / 4)\nelse :\n print(n * (n + 2) / 4)\n"}, {"source_code": "n=int(input())\nif n%2==0:\n ans=(n//2)*(n//2+1)\nelse:\n ans=(n//2+1)*(n//2+1)\nprint(ans)"}, {"source_code": "x = int(input()) + 1\nprint(x//2 * (x - x//2))"}, {"source_code": "import sys\n\n#f = open('input', 'r')\nf = sys.stdin\n\nn = int(f.readline())\n\nans = [1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49, 56, 64, 72, 81, 90, 100, 110, 121, 132, 144, 156, 169, 182, 196, 210, 225, 240, 256, 272, 289, 306, 324, 342, 361, 380, 400, 420, 441, 462, 484, 506, 529, 552, 576, 600, 625, 650, 676, 702, 729, 756, 784, 812, 841, 870, 900, 930, 961, 992, 1024, 1056, 1089, 1122, 1156, 1190, 1225, 1260, 1296, 1332, 1369, 1406, 1444, 1482, 1521, 1560, 1600, 1640, 1681, 1722, 1764, 1806, 1849, 1892, 1936, 1980, 2025, 2070, 2116, 2162, 2209, 2256, 2304, 2352, 2401, 2450, 2500, 2550]\n\nprint(ans[n-1])\n"}, {"source_code": "n = int(input())\nprint(round((n/2+1)*n/2))\n"}, {"source_code": "n = int(raw_input())\nprint (n+1)**2/4\n"}, {"source_code": "import math\n# cook your dish here\ns = int(input())\nprint(math.ceil((s/2+1)*(s/2)))"}, {"source_code": "n = int(input())\n\nres = 0\nfor i in range(1, n+1):\n\tstart = 0\n\tlayer = 0\n\tlayers = 1\n\tfor j in range(0,(n-i)+1):\n\t\tif (start + i) > n:\n\t\t\tlayers += 1\n\t\t\tlayer += 1\n\t\t\tstart = layer + i\n\t\telif (start + i) == n:\n\t\t\tlayer += 1\n\t\t\tstart = layer\n\t\t\tif j != (n-i):\n\t\t\t\tlayers += 1\n\t\telse:\n\t\t\tstart += i\n\t\t#print(i, start, layers)\n\tres += layers\nprint(res)"}, {"source_code": "N = int(input())\nprint((N//2+1)*((N-1)//2+1))"}, {"source_code": "n = int(raw_input())\nmax = 0\nfor i in xrange(n):\n c = (i + 1) * (n - i)\n if c > max:\n max = c\nprint max"}, {"source_code": "'''input\n5\n'''\nn=int(input())\nans=0\nwhile n>0:\n ans+=n\n n-=2\nprint(ans)"}, {"source_code": "n = int(input())\nl = (n+1)//2\nr = (n+2)//2\nprint(l*r)"}, {"source_code": "n=input()\nprint max((i+1)*(n-i) for i in range(n))"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\n\ndef Rint():\n return map(int, input().split())\n\na = [0,1]\ndef f(n):\n # print('1', 2*(n//2-(0 if n%2 else 1)))\n # print('2', a[n-2])\n return 1+2*(n//2-(0 if n%2 else 1))+(0 if n%2 else 1)+a[n-2]\n\ndef main():\n for line in sys.stdin:\n n = int(line)\n if n==1:\n print(1)\n continue\n for i in range(2,n+1):\n if i>=len(a):\n a.append(f(i))\n # print(a)\n print(a[n])\n\nmain()\n"}, {"source_code": "n = int(raw_input(''))\nn += 1\nprint (n/2)*(n-n/2)"}, {"source_code": "def solve():\n n=input()\n a=1\n b=1\n for x in xrange(2,n+1):\n if a==b: a+=1\n else:\n if a>b:b+=1\n else:a+=1\n print a*b\nsolve()"}, {"source_code": "#template-\nfrom sys import stdout\n# fi=open(\"input.txt\",\"r\")\n# fo=open(\"output.txt\",\"w\")\n\nn=int(raw_input())\nans=0\nfor i in range(n):\n\tpieces=n-i\n\tans+=min(pieces,i+1)\n\t# fo.write(\" \" + str(i) + \" \" + str(ans) +\"\\n\")\nstdout.write(str(ans)+\"\\n\")"}, {"source_code": "n = int(input())\n\nres = 0\nfor i in range(1, n+1):\n\tstart = 0\n\tlayer = 0\n\tlayers = 1\n\tfor j in range(0,(n-i)+1):\n\t\tif (start + i) > n:\n\t\t\tlayers += 1\n\t\t\tlayer += 1\n\t\t\tstart = layer + i\n\t\telif (start + i) == n:\n\t\t\tlayer += 1\n\t\t\tstart = layer\n\t\t\tif j != (n-i):\n\t\t\t\tlayers += 1\n\t\telse:\n\t\t\tstart += i\n\t\t#print(i, start, layers)\n\tres += layers\nprint(res)"}, {"source_code": "n=int(input())\nprint((n+1)**2//4)"}, {"source_code": "import math\n\ndef main():\n\tx = input()\n\tx = int(x)\n\t\n\tans = (((math.floor(x)/2)+1)*(math.ceil(x)/2))\n\tans = math.ceil(ans)\n\t\n\tprint(ans)\n\t\nif __name__ == '__main__':\n\tmain()\n\t"}, {"source_code": "n=input()\nans=[0 for i in range(n+1)]\nfor i in range(n):\n\tfor j in range(i+1,n+1):\n\t\tfor k in range(i+1,j+1):ans[k]+=1\nprint max(ans)\n"}, {"source_code": "n = int(raw_input())\nprint (n+1)**2/4\n"}, {"source_code": "n = int(raw_input(''))\nn += 1\nprint (n/2)*(n-n/2)"}, {"source_code": "n=int(input())\n\ndef get(n):\n\tif n%2==1:\n\t\tk = (n+1)//2\n\t\treturn k*k\n\telse:\n\t\tk=n//2\n\t\treturn k*(k+1)\n\nprint(get(n))"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline().rstrip(\"\\n\"))\n\nif n % 2 == 0:\n res = n // 2 * (n // 2 + 1)\n print(res)\n\nelse:\n res = (n // 2 + 1) * (n // 2 + 1)\n print(res)"}, {"source_code": "#codig: utf-8\n\nN = int(raw_input())\n\nres = 0\nfor i in range(1, N+1):\n res += min(i, (N+1)-i)\n\nprint res\n"}, {"source_code": "a = [0, 1, 2] + 98 * [0]\nfor i in range(3, 101):\n a[i] = i + a[i-2]\nprint a[int(raw_input())] "}, {"source_code": "import math\n\nnum = int(input())\nfirst = math.ceil(num/2)\nsecond = math.floor(num/2)\nresult = (second+1)*first\n\nprint(result)"}, {"source_code": "a = [0, 1, 2] + 98 * [0]\nfor i in range(3, 101):\n a[i] = i + a[i-2]\nprint a[int(raw_input())] "}, {"source_code": "n = int(input())\nif n % 2 == 0:\n b = 2\nelse:\n b = 1\ns = 0\nfor i in range(b, n + 1, 2):\n s += i\nprint(s)"}, {"source_code": "n=int(raw_input())\nif n%2==0:\n print (n/2)*(n/2+1)\nelse:\n print (n/2)*(n/2+1)+(n/2+1)"}, {"source_code": "print((int(input())+1)**2//4)"}, {"source_code": "n = int(raw_input())\nprint (n+1)**2/4\n"}, {"source_code": "def segments(n):\n result = 0\n while n > 0:\n result += n\n n -= 2\n return result\n\n\nprint(segments(int(input())))"}, {"source_code": "print (input()+1)**2//4"}, {"source_code": "def main():\n N = int(input())\n\n v = N + 1\n n = 0\n while v > 0:\n n += v - 1\n v -= 2\n\n print(n)\n\nmain()\n"}, {"source_code": "n = int(input())\ne = int(n/2)\nif(n%2 == 0):\n print(e*(e+1))\nelse:\n print(e*(e+1) + int((n+1)/2))"}, {"source_code": "n = int(input())\nl = [0]*n\nfor i in range(n):\n for j in range(n-i):\n for k in range(j,j+i+1):l[k]+=1\nprint(max(l))\n"}, {"source_code": "import math\nn = int(input())\nprint((n//2+1)*math.ceil(n/2))\n"}, {"source_code": "n = int(raw_input()) + 1\nprint (2*n**2-1+(-1)**n)/8"}, {"source_code": "n = int(input())\nprint(round((n/2+1)*n/2))\n"}, {"source_code": "import sys\ntry:\n sys.stdin = open('input.txt', 'r')\n sys.stdout = open('output.txt', 'w')\nexcept Exception as es:\n pass\n\nimport math\nn = int(input())\nprint((n // 2 + 1) * math.ceil(n / 2))\n"}, {"source_code": "num = int(input().strip())\nfactor = 0\nlayers = 0\nfor x in range(num):\n if x % 2 == 0:\n factor += 1\n layers += factor\nprint(layers)"}, {"source_code": "n = int(input())\nprev = 1\nif n == 1:\n print(1)\n exit()\ncur = 2\nfor i in range(3, n + 1):\n now = (i * (i + 1) // 2 - (i - 1) * (i - 2) // 2 + 1) // 2 + prev\n prev, cur = cur, now\nprint(cur)\n"}, {"source_code": "import math\nn = int(input())\nn = math.floor(n / 2 + 1) * math.ceil(n / 2)\nprint(n)\n"}, {"source_code": "print((int(input())+1)**2//4)"}, {"source_code": "r = int(raw_input(\"\")) + 1\nprint [(r/2)**2,(r/2)*(r/2 + 1)][r % 2]"}, {"source_code": "n = int(input())\na = []\nfor i in range(n):\n a.append((i+1)*(n-i))\nprint(max(a))"}, {"source_code": "n = int(raw_input(''))\nn += 1\nprint (n/2)*(n-n/2)"}, {"source_code": "n = input()\nN = n * (n + 1) / 2\n\nsegs = dict()\nfor i in range(1, n + 1):\n segs[i] = []\n\nfor len in range(1, n + 1):\n for i in range(n, len - 1, -1):\n segs[i].append(len)\n\nlays = 0\ncnt = 0\ncurr = n\nwhile cnt < N:\n while segs[curr] != []:\n cc = curr\n while cc > 0:\n while cc > 0 and segs[cc] == []:\n cc -= 1\n if cc == 0:\n break\n\n cct = cc - segs[cc][-1]\n # print (cct, cc),\n segs[cc].pop()\n cc = cct\n cnt += 1\n lays += 1\n # print \"\"\n curr -= 1\n\nprint lays"}, {"source_code": "a=int(input())\nprint((a+1)*(a+1)//4)"}, {"source_code": "def foobar(n):\n list = [0]*n\n for i in range(n+1):\n l = n - i + 1\n for j in range(n-l+1):\n for k in range(j, j+l):\n list[k] += 1\n \n max = 0\n for i in list:\n max = max if max > i else i\n print(max)\n\nn = input()\nfoobar(int(n))\n"}, {"source_code": "import math\nn = int(raw_input())\nans = (int(n/2)+1)*(int(math.ceil(float(n)/2.0)))\nprint ans"}, {"source_code": "from collections import Counter, deque\ndef lInt(d = None): return map(int, input().split(d))\n\nn, *_ = lInt()\nans = 0\n\nfor l in range(1, n+1):\n for j in range(0, l):\n if j+l <= n:\n ans += 1\nprint(ans)\n"}, {"source_code": "# B.py\n\nn = int(input())\ni = (n + 1) // 2\nprint(i * (n + 1 - i))"}, {"source_code": "def getans(n):\n if n == 2 :\n return 2\n if n == 1:\n return 1\n return n+getans(n-2)\nprint(getans(int(input())))\n"}, {"source_code": "n = int(input())\nif n & 1:\n print(n * (n + 1) // 2 - (n - 1) * (n + 1) // 4)\nelse:\n print(n * n // 2 - (n - 2) * n // 4)"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n ans = (n // 2) * (n // 2 + 1)\nelse:\n ans = (n // 2 + 1) * (n // 2 + 1)\nprint(ans)"}, {"source_code": "def getans(n):\n if n == 2 :\n return 2\n if n == 1:\n return 1\n return n+getans(n-2)\nprint(getans(int(input())))\n"}, {"source_code": "a = input()\nsumNum = 0\nwhile a > 0:\n sumNum += a\n a -= 2\nprint sumNum\n"}], "negative_code": [{"source_code": "n = int(input())\nprint(int(n * (n-1) /2))"}, {"source_code": "n=int(input())\nn=n+1\nprint(n*n/4)"}, {"source_code": "n=int(input())\n\ndef get(n):\n\tif n%2==1:\n\t\tk = (n+1)//2\n\t\treturn (k*(k+1)*(2*k+1)//6+k*(k+1)//2)//2\n\telse:\n\t\tk=n//2\n\t\treturn (k*(k+1)*(2*k+1)//6+k*(k+1)//2)//2++k\n\nprint(get(n))"}, {"source_code": "import math\n\ndef main():\n\tx = input()\n\tx = int(x)\n\t\n\tprint(((math.floor(x)/2)+1)*(math.ceil(x)/2))\n\t\nif __name__ == '__main__':\n\tmain()\n\t"}, {"source_code": "import math\n\ndef main():\n\tx = input()\n\tx = int(x)\n\t\n\tprint(int(((math.floor(x)/2)+1)*(math.ceil(x)/2)))\n\t\nif __name__ == '__main__':\n\tmain()\n\t"}, {"source_code": "n = int(input())\nif n == 1:\n print(1)\nelse:\n print((n * (n + 1)) // 3)"}, {"source_code": "n = int(input())\na = [int(i) for i in range(1, n + 1)]\np = []\nlens = []\nans = 0\nfor i in range(n):\n for j in range(i, n):\n p.append(a[i:j + 1])\n lens.append(j - i + 1)\nlens.sort()\nl = len(lens)\nfor i in range(1, n + 1):\n if n % i == 0:\n for j in range(n // i):\n if i in lens:\n lens.remove(i)\n ans += 1\nprint(ans + len(lens))"}, {"source_code": "n = int(input())\na = [int(i) for i in range(1, n + 1)]\np = []\nlens = []\nans = 0\nfor i in range(n):\n for j in range(i, n):\n p.append(a[i:j + 1])\n lens.append(j - i + 1)\nlens.sort()\nfor i in range(len(lens)):\n for j in range(i, len(lens)):\n if sum(lens[i:j + 1]) == n and -1 not in lens[i:j + 1]:\n ans += 1\n for k in range(i, j + 1):\n lens[k] = -1\nfor i in lens:\n if i > -1:\n ans += 1\nprint(ans)"}, {"source_code": "n = int(input())\na = [int(i) for i in range(1, n + 1)]\np = []\nlens = []\nans = 0\nfor i in range(n):\n for j in range(i, n):\n p.append(a[i:j + 1])\n lens.append(j - i + 1)\nlens.sort()\nfor i in range(len(lens)):\n for j in range(i, len(lens)):\n if sum(lens[i:j + 1]) == n:\n for k in range(i, j + 1):\n lens[k] = -1000000\n ans += 1\nfor i in range(len(lens)):\n for j in range(i):\n if lens[i] + lens[j] == n:\n lens[i] = -1000000\n lens[j] = -1000000\n ans += 1\nfor i in lens:\n if i > 0:\n ans += 1\nprint(ans)"}, {"source_code": "n = int(input())\na = [int(i) for i in range(1, n + 1)]\np = []\nlens = []\nans = 0\nfor i in range(n):\n for j in range(i, n):\n p.append([i + 1, j + 1])\n lens.append(j - i + 1)\nlens.sort()\nl = len(lens)\nfor i in range(1, n + 1):\n if n % i == 0:\n l -= n // i\n ans += 1\nprint(ans + l)\narr = [0] * n\nfor i in p:\n for j in range(i[0] - 1, i[1]):\n arr[j] += 1\nprint(max(arr))"}, {"source_code": "n = int(input())\nadd = 1\nout = 0\nadd_to_add = -1\n\nif n == 1:\n print(1)\n exit()\n\nelif n == 2:\n print(2)\n exit()\n\nelse:\n for i in range(3, n + 1):\n add_to_add += 1\n add += add_to_add\n out = i + add\n\n\n\nprint(out)\n"}, {"source_code": "n = int(input())\nk = 0\n\nif n == 1:\n print(1)\n exit()\n\nelse:\n for i in range(n - 1):\n k += 2\n\nprint(k)\n"}, {"source_code": "N = int(input())\n\nmaxx = 0\n\non_left = 1\non_righ = N\n\nfor i in range(0 , N , 1):\n maxx = max(on_left*on_righ , maxx)\n\nprint(maxx)\n"}, {"source_code": "x = int(input())\nif(x == 1):\n\tprint(1)\nelse:\n\tprint(x*2 - 2)\n"}, {"source_code": "if __name__ == \"__main__\":\n\tnum = int(input().strip())\n\tsegment = []\n\tfor i in range(1, num+1):\n\t\tj = 0\n\t\tfor j in range(num):\n\t\t\tif j+i <= num:\n\t\t\t\tsegment.append((j, j+i))\n\tsegment.sort(key=lambda x: (x[0], [1]))\n\tprint(segment)\n\tlayer_count = 0\n\twhile segment != []:\n\t\trightend = segment[0][1]\n\t\tsegment.remove(segment[0])\n\t\tj = 0\n\t\twhile j < len(segment):\n\t\t\tif segment[j][0] == rightend:\n\t\t\t\trightend = segment[j][1]\n\t\t\t\tsegment.remove(segment[j])\n\t\t\telse:\n\t\t\t\tj += 1\n\t\tlayer_count += 1\n\tprint(layer_count)"}, {"source_code": "\n# coding: utf-8\n\n# In[11]:\n\nn = int(input())\nk = (n + 1) // 2\na = 1\nfor i in range(k + 1, n + 1):\n a = a * i\nfor i in range(1, n - k + 1):\n a = a // i\nprint(a)\n\n\n# In[ ]:\n\n\n\n"}, {"source_code": "n=int(input())\nif n==1:\n print(1)\nelse:\n print(2*n-2)"}, {"source_code": "n=int(input())\nprint(2*(n-1))\n"}, {"source_code": "n = int(input())\n\nres = 1\nfor i in range(1, n):\n\tres += int((n-i+1) / (n//i))\n\tif (n-i+1) % (n//i) != 0:\n\t\tres += 1\nprint(res)"}, {"source_code": "n=int(input())\nprint((n*(n+1)//2)//2+1)"}, {"source_code": "for i in range(1):\n n=int(input())\n print(n-2+n)\n"}, {"source_code": "for i in range(1):\n n=int(input())\n s=0\n for i in range(1,n+1):\n s=i+s\n print(s)\n x=s/2\n if x>int(x):\n print(int(x)+1)\n else:\n print(int(x))\n"}, {"source_code": "for i in range(1):\n n=int(input())\n s=0\n for i in range(1,n+1):\n s=i+s\n x=s/2\n if x>int(x):\n print(int(x)+1)\n else:\n print(int(x))\n"}, {"source_code": "n = int(input())\nn = ((n+1)*n)/2\nprint(int(n//2)+1)\n"}, {"source_code": "n = int(input())\nn = ((n+1)*n)/2\nprint(n//2+1)\n"}, {"source_code": "'''a,b = input().split()\nt = ''\nl = chr(ord('z')+1)\nfor i in range(len(a)):\n if a[i]1):\n layer=layer+ ( (d-1) * (line) ) +rem\nif(n==1):print 1\nif(n==2):print 2\nelse:print layer"}, {"source_code": "n=input()\nlayer=0\nfor line in range(n):\n layer=layer+1\n rem=n%(line+1)\n d=n/(line+1)\n if(d==1):\n layer=layer+rem\n if(d>1):\n layer=layer+line+rem\nelse:print layer"}, {"source_code": "from copy import deepcopy\ndef query(l,r, segs):\n global ans\n global N\n if l>=N:\n ans=min(ans,len(segs))\n elif r>=N:\n query(l+1,l+1,segs)\n else:\n Len = r-l+1\n temp = [0 for i in xrange(N)]\n for k in xrange(l,r+1):\n temp[k]=1\n query(l,r+1,segs+[temp])\n for i in xrange(len(segs)):\n if sum(segs[i][l:r+1]) == 0:\n poss=deepcopy(segs)\n for k in xrange(l,r+1):\n poss[i][k]=1\n query(l,r+1,poss)\nN=int(raw_input())\nprint N**2/4\n"}, {"source_code": "def main():\n n=input()\n if n==1:\n print 1 \n else:\n print (n-1)*2\n \n \nmain()"}, {"source_code": "num = int(raw_input())\n\nresp = 1\nlista = [i for i in range(num, 1, -1)]\n\nfor i in range(len(lista)-1, -1,-1):\n while lista[i] > 0:\n cont = i + 1\n for j in range(len(lista)-1, -1, -1):\n if cont + j+1 <= num and lista[j] and lista[i]:\n cont += j +1\n lista[j] -= 1\n\n lista[i]-= 1\n resp += 1\n \nprint resp\n"}, {"source_code": "num = int(raw_input())\n\nresp = 1\nlista = [i for i in range(num, 1, -1)]\n\nfor i in range(len(lista)):\n lista[i] -= 2\n resp += 1\nfor i in range(len(lista)):\n if lista[i] != 0:\n lista[i] = 0\n resp += 1\n \nprint resp\n"}, {"source_code": "num = int(raw_input())\n\nresp = 1\nlista = [i for i in range(num, 1, -1)]\n\nfor i in range(len(lista)-1, -1,-1):\n while lista[i] > 0:\n for j in range(len(lista)):\n if i+1 + j+1 <= num and lista[j] and lista[i]:\n lista[i] -= 1\n lista[j] -= 1\n resp += 1\n \nprint resp\n"}, {"source_code": "N = int(raw_input())\nif N==1:\n print 1\nelse:\n print (N-1)*2"}, {"source_code": "#template-\nfrom sys import stdout\n# fi=open(\"input.txt\",\"r\")\n# fo=open(\"output.txt\",\"w\")\n\nn=int(raw_input())\nans=0\nfor i in range(n):\n\tpieces=n-i\n\tneeded=n/(i+1)\n\t# fo.write(str(pieces) + \" \" + str(i) + \" \" + str(needed) + \"\\n\")\n\tans+=(pieces/needed) + (pieces%needed)\nstdout.write(str(ans)+\"\\n\")"}, {"source_code": "n=input()\nif n==2:\n print 2\nif n==3:\n print 4\nif n==4:\n print 6\nif n==5:\n print 9\nif n==6:\n print 12"}, {"source_code": "n=int(raw_input())\nli=range(1,n+1)\nli=li[::-1]\nlay=0\nfor i in range(n-1,-1,-1):\n\tlim=li[i]\n\t# print \"i li ::\",li\n\tfor j in range(li[i]):\n\t\tli[i]-=1\n\t\t# print \"j li ::\",li\n\t\tseg=n-(i+1)\n\t\t# print \"seg ::\",seg\n\t\tlay+=1\n\t\tk=seg\n\t\twhile seg>0 and k>0:\n\t\t\tif li[k-1]:\n\t\t\t\tli[k-1]-=1\n\t\t\t\tseg-=1\n\t\t\t\t# print \"if \",li\n\t\t\telse:\n\t\t\t\tk-=1\n\t\tif li[i]:\n\t\t\tpass\n\t\telse:\n\t\t\tbreak\n\telse:\n\t\tpass\nelse:\n\tpass\nprint lay\n\n"}, {"source_code": "n = input()\nN = n * (n + 1) / 2\n\nsegs = []\n\nfor i in range(0, n):\n for len in range(1, n - i + 1):\n segs.append([(i, i + len), False])\n\nlays = 0\nfor i in range(N-1, 0, -1):\n if segs[i][1]:\n continue\n\n curr = segs[i][0][0]\n for j in range(i - 1, -1, -1):\n if segs[j][1] == False and segs[j][0][1] <= curr:\n segs[j][1] = True\n curr = segs[j][0][0]\n lays += 1\n\nprint lays\n"}, {"source_code": "n = input()\nN = n * (n + 1) / 2\n\nsegs = []\n\nfor i in range(0, n):\n for len in range(1, n - i + 1):\n segs.append([(i, i + len), False])\n\nlays = 0\nfor i in range(N-1, 0, -1):\n if segs[i][1]:\n continue\n\n arr = [segs[i][0]]\n for j in range(i - 1, -1, -1):\n if segs[j][1] == False:\n flag = True\n for seg in arr:\n if seg[0] >= segs[j][0][1] or seg[1] <= segs[j][0][0]:\n continue\n else:\n flag = False\n break\n if flag:\n segs[j][1] = True\n arr.append(segs[j][0])\n lays += 1\n\nprint lays\n"}, {"source_code": "n = input()\nN = n * (n + 1) / 2\n\nsegs = []\n\nfor i in range(0, n):\n for len in range(1, n - i + 1):\n segs.append([(i, i + len), False])\n\nlays = 0\nfor i in range(N-1, -1, -1):\n if segs[i][1]:\n continue\n\n arr = [segs[i][0]]\n segs[i][1] = True\n for j in range(i - 1, -1, -1):\n if segs[j][1] == False:\n flag = True\n for seg in arr:\n if seg[0] >= segs[j][0][1] or seg[1] <= segs[j][0][0]:\n continue\n else:\n flag = False\n break\n if flag:\n segs[j][1] = True\n arr.append(segs[j][0])\n lays += 1\n\nprint lays\n"}, {"source_code": "n=input()\nprint(n*2-2+(n==1))"}, {"source_code": "n=int(raw_input())\n\na=1\nfor i in range(1,n+1):\n a=a+min(i,n-i+1)\n\nprint a"}, {"source_code": "print (input()-1)*2\n"}, {"source_code": "n = int(raw_input(''))\nprint n + (n-2)"}, {"source_code": "n = int(raw_input(''))\nprint 2*n-2"}, {"source_code": "n = int(raw_input(''))\nif n == 1:\n print 1\n exit(0)\nprint n + (n-2)"}, {"source_code": "print 2*int(raw_input(\"\"))-2"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline().strip())\n\na = [None] * 105\n\na[1] = 1\na[2] = 2\na[3] = 4\na[4] = 6\n\nif n <= 4:\n print a[n]\nelse:\n for i in xrange(5, n + 1):\n a[i] = a[i - 1] + (i - 1)\n\n print a[n]\n"}, {"source_code": "n = int(input())\nprint(2*(n-1))\n"}, {"source_code": "n=int(input())\nif n==1:\n print(1)\nelif n==2:\n print(2)\nelif n==3:\n print(4)\nelse:\n print((n*(n-1))//2)"}, {"source_code": "n=int(input())\nprint((n//2+1)*(n//2+1))"}, {"source_code": "n=int(input())\nif n==1:\n print(1)\nelse:\n print(2*(n-1))"}, {"source_code": "n=int(input())\nif n==1:\n print(0)\nelif n==2:\n print(2)\nelif n==3:\n print(4)\nelse:\n print((n*(n-1))//2)"}, {"source_code": "n = int(input())\nprint((n // 2 + 1) * (n // 2))"}, {"source_code": "print((((int)(input())) ** 2) // 4)\n"}, {"source_code": "n = int(input())\nprint((n + 1) ** 2 // 4 if n % 2 else (n - 1) * (n + 1) // 4)"}, {"source_code": "n = int(input())\nprint(2*(n-1))"}, {"source_code": "n = int(input())\nprint((n/2)*((n+1)/2))"}, {"source_code": "n = int(input())\nrows = []\nused = []\nfor i in range(n):\n for _ in range(i+1):\n for j in range(len(rows)):\n if not used[j] and rows[j] + n - i <= n:\n used[j] = True\n rows[j] += n - i\n break\n else:\n rows.append(n-i)\n used.append(False)\nprint(len(rows))\n"}, {"source_code": "n = int(input())\nprint(n*(n+1)//4 + 1)\n"}, {"source_code": "n=int(input())\na=n//2\nif n%2==0:\n print(n*(n+2)//4)\nelse:\n print(a*(a+2)//4+(n+1)//2)\n "}, {"source_code": "n=int(input())\nn=(n*(n+1))//2\nprint(n//2+1)"}, {"source_code": "\n\nif __name__ == \"__main__\":\n num = int(input().strip())\n if num == 1:\n print(1)\n else:\n print((num-2)+num)\n"}, {"source_code": "print((int(input())+1)**2/4)"}, {"source_code": "n = int(input())\nprev = 1\ncur = 2\nfor i in range(3, n + 1):\n now = (i * (i + 1) // 2 - (i - 1) * (i - 2) // 2 + 1) // 2 + prev\n prev, cur = cur, now\nprint(cur)\n"}, {"source_code": "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\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\nn = ii()\nprint(2*n - 2)"}, {"source_code": "n = int(input());\nn += 1;\nprint((n * (n - 1)) / 2);"}, {"source_code": "n = int(input());\nn += 1\nx = (n + 1)/2\ny = int(n / 2)\nu = int(x * y)\nprint (u);"}, {"source_code": "from sys import stdin,stdout\n#stdin.readline()\n#stdout.write()\n#raw_input()\n#map(int,raw_input().split())\n#map(int,stdin.readline().split())\nx=int(stdin.readline())\nprint (x-1)*2"}, {"source_code": "n = int(input())\nif n == 1:\n print(1)\n exit(0)\ns = 2\nh = n // 2\ncur = n - 1\nwhile cur > h:\n s += n - cur + 1\n cur -= 1\nwhile cur > 1:\n s += (n - cur) // 2 + 1\n cur -= 1\nprint(s)"}, {"source_code": "n = int(input())\ns = 2\nh = n // 2\ncur = n - 1\nwhile cur > h:\n s += n - cur + 1\n cur -= 1\nwhile cur > 1:\n s += (n - cur) // 2 + 1\n cur -= 1\nprint(s)"}, {"source_code": "n=int(input())\nprint(2*(n-1))"}, {"source_code": "n=int(input())\np=max(n-2,0)\nprint(n+p)\n"}, {"source_code": "n = int(input())\nli = []\nhv = dict()\nj = 1\nfor i in range(n,0,-1):\n hv[i] = j\n j+=1\n\nans = 0 \nfor i in range(n,0,-1):\n if hv[i]>0:\n t = i\n hv[i]-=1\n for j in range(1,i+1):\n while t<=n and hv[j]>0:\n t+=j\n hv[j]-=1\n if t>n:\n t-=j\n hv[j]+=1\n ans+=1\n if hv[i]==0:\n break\n hv[i]-=1\nprint(ans)\n \n"}, {"source_code": "import math\nn = int(input())\nli = []\nhv = dict()\nj = 1\nfor i in range(n,0,-1):\n hv[i] = j\n j+=1\n\nans = 0 \nfor i in range(n,0,-1):\n if hv[i]>0:\n t = i\n for j in range(1,i+1):\n hv[i]-=1\n while t<=n and hv[j]>0:\n t+=j\n hv[j]-=1\n if t>n:\n t = j\n hv[j]+=1\n ans+=1\n if hv[i]==0:\n break\nfor i in range(n,0,-1):\n if hv[i]>0:\n t = i\n hv[i]-=1\n while hv[i]>0:\n t+=i\n hv[i]-=1\n ans+=math.ceil(float(t)/n)\nprint(ans)\n \n"}, {"source_code": "import math\nn = int(input())\nhv = dict()\nans = 0\nj = 1\nfor i in range(n,-1,-1):\n hv[i] = j\n j+=1\n\nfor i in range(n,n//2,-1):\n ans+=hv[i]\n hv[n-i] -= hv[i]\n hv[i] = 0\n\nfor i in range(n,0,-1):\n if hv[i] and i==1:\n ans+=1\n elif hv[i]:\n ans+=math.ceil(hv[i]/float(i))\nprint(ans)\n"}, {"source_code": "import math\nn = int(input())\nif n==1:\n print(1)\nelse:\n print(n*(n-1)//2)\n"}, {"source_code": "import math\nn = int(input())\nhv = dict()\nans = 0\nj = 1\nfor i in range(n,-1,-1):\n hv[i] = j\n j+=1\n\nfor i in range(n,n//2,-1):\n ans+=hv[i]\n hv[n-i] -= hv[i]\n hv[i] = 0\n\nfor i in range(n,0,-1):\n ans+=math.ceil(hv[i]/2.0)\nprint(ans)\n"}, {"source_code": "import math\nn = int(input())\nhv = dict()\nans = 0\nj = 1\nfor i in range(n,-1,-1):\n hv[i] = j\n j+=1\n\nfor i in range(n,n//2,-1):\n ans+=hv[i]\n hv[n-i] -= hv[i]\n hv[i] = 0\n\nfor i in range(n,0,-1):\n if hv[i] and i==1:\n ans+=1\n elif hv[i]:\n ans+=math.ceil(hv[i]/2.0)\nprint(ans)\n"}, {"source_code": "import math\nn = int(input())\nif n==1:\n print(1)\nelse:\n print((n-1)*2)\n"}, {"source_code": "n = int(input())\nans = n * (n + 1)\nans //= 2\nans += 1\nans //= 2\nprint(ans)"}, {"source_code": "n = int(input())\nans = 2 * (n - 1)\nprint(ans)"}, {"source_code": "N = int(input())\nadd = N\nwhile N>0:\n\tadd+=(N-2)\n\tN-=2\nprint(add)\n\n"}, {"source_code": "n = int(input())\nimport math\nprint(math.ceil(n/2) * math.floor(n/2)+1)"}], "src_uid": "f8af5dfcf841a7f105ac4c144eb51319"} {"nl": {"description": "Makoto has a big blackboard with a positive integer $$$n$$$ written on it. He will perform the following action exactly $$$k$$$ times:Suppose the number currently written on the blackboard is $$$v$$$. He will randomly pick one of the divisors of $$$v$$$ (possibly $$$1$$$ and $$$v$$$) and replace $$$v$$$ with this divisor. As Makoto uses his famous random number generator (RNG) and as he always uses $$$58$$$ as his generator seed, each divisor is guaranteed to be chosen with equal probability.He now wonders what is the expected value of the number written on the blackboard after $$$k$$$ steps.It can be shown that this value can be represented as $$$\\frac{P}{Q}$$$ where $$$P$$$ and $$$Q$$$ are coprime integers and $$$Q \\not\\equiv 0 \\pmod{10^9+7}$$$. Print the value of $$$P \\cdot Q^{-1}$$$ modulo $$$10^9+7$$$.", "input_spec": "The only line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \\leq n \\leq 10^{15}$$$, $$$1 \\leq k \\leq 10^4$$$).", "output_spec": "Print a single integer \u2014 the expected value of the number on the blackboard after $$$k$$$ steps as $$$P \\cdot Q^{-1} \\pmod{10^9+7}$$$ for $$$P$$$, $$$Q$$$ defined above.", "sample_inputs": ["6 1", "6 2", "60 5"], "sample_outputs": ["3", "875000008", "237178099"], "notes": "NoteIn the first example, after one step, the number written on the blackboard is $$$1$$$, $$$2$$$, $$$3$$$ or $$$6$$$ \u2014 each occurring with equal probability. Hence, the answer is $$$\\frac{1+2+3+6}{4}=3$$$.In the second example, the answer is equal to $$$1 \\cdot \\frac{9}{16}+2 \\cdot \\frac{3}{16}+3 \\cdot \\frac{3}{16}+6 \\cdot \\frac{1}{16}=\\frac{15}{8}$$$."}, "positive_code": [{"source_code": "def _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 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\nn, k = map(int, input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\nif (n == 900000720000023) and (k == 9876):\n print(511266473)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nif is_prime(n):\n print(solve(n, 1))\n exit()\n\n\nsn = int(n**0.5)\nif (sn*sn == n) and is_prime(sn):\n print(solve(sn, 2))\n exit()\n\n\nans = 1\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n"}, {"source_code": "import random\nfrom math import gcd\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 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\nn, k = map(int, input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nif is_prime(n):\n print(solve(n, 1))\n exit()\n\nsn = int(n**0.5)\nif (sn*sn == n) and is_prime(sn):\n print(solve(sn, 2))\n exit()\n\nans = 1\nf = _factor(n)\nif is_prime(f) and (f > sn):\n ans = ans * solve(f, 1) % 1000000007\n n //= f\n\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n"}, {"source_code": "def primeFactor(N):\n i = 2\n ret = {}\n n = N\n mrFlg = 0\n if n < 0:\n ret[-1] = 1\n n = -n\n if n == 0:\n ret[0] = 1\n while i**2 <= n:\n k = 0\n while n % i == 0:\n n //= i\n k += 1\n ret[i] = k\n if i == 2:\n i = 3\n else:\n i += 2\n if i == 101 and n >= (2**20):\n def findFactorRho(N):\n # print(\"FFF\", N)\n def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n def f(x, c):\n return ((x ** 2) + c) % N\n semi = [N]\n for c in range(1, 11):\n x=2\n y=2\n d=1\n while d == 1:\n x = f(x, c)\n y = f(f(y, c), c)\n d = gcd(abs(x-y), N)\n if d != N:\n if isPrimeMR(d):\n return d\n elif isPrimeMR(N//d):\n return N//d\n else:\n semi.append(d)\n\n semi = list(set(semi))\n # print (semi)\n s = min(semi)\n for i in [2,3,5,7]:\n while True:\n t = int(s**(1/i)+0.5)\n if t**i == s:\n s = t\n if isPrimeMR(s):\n return s\n else:\n break\n\n i = 3\n while True:\n if s % i == 0:\n return i\n i += 2\n \n while True:\n if isPrimeMR(n):\n ret[n] = 1\n n = 1\n break\n else:\n mrFlg = 1\n j = findFactorRho(n)\n k = 0\n while n % j == 0:\n n //= j\n k += 1\n ret[j] = k\n if n == 1:\n break\n \n if n > 1:\n ret[n] = 1\n if mrFlg > 0:\n def dict_sort(X):\n Y={}\n for x in sorted(X.keys()):\n Y[x] = X[x]\n return Y\n ret = dict_sort(ret)\n return ret\n\ndef isPrime(N):\n if N <= 1:\n return False\n return sum(primeFactor(N).values()) == 1\n\ndef isPrimeMR(n):\n # print(\"MR\", n)\n if n == 2: return True\n if n == 1 or n & 1 == 0: return False\n\n d = (n - 1) >> 1\n while d & 1 == 0:\n d >>= 1\n\n for a in [2, 3, 5, 7, 11, 13, 17, 19]:\n t = d\n y = pow(a, t, n)\n\n while t != n - 1 and y != 1 and y != n - 1:\n y = (y * y) % n\n t <<= 1\n\n if y != n - 1 and t & 1 == 0:\n # print(\"not prime\")\n return False\n # print(\"prime\")\n return True \n\ndef findPrime(N):\n if N < 0:\n return -1\n i = N\n while True:\n if isPrime(i):\n return i\n i += 1\n\ndef divisors(N):\n pf = primeFactor(N)\n ret = [1]\n for p in pf:\n ret_prev = ret\n ret = []\n for i in range(pf[p]+1):\n for r in ret_prev:\n ret.append(r * (p ** i))\n return sorted(ret)\n\ndef mxpow(m, a, e):\n if e == 1:\n return a\n if e % 2 == 0:\n tmp = mxpow(m, a, e//2)\n return mxprod(m, tmp, tmp)\n else:\n tmp = mxpow(m, a, e//2)\n return mxprod(m, mxprod(m, tmp, tmp), a)\n\ndef mxprod(m, a, b):\n ret = [[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 ret[i][j] += a[i][k] * b[k][j]\n ret[i][j] %= P\n return ret\n\ndef mxv(m, a, v):\n ret = [0]*m\n for i in range(m):\n for k in range(m):\n ret[i] += a[i][k] * v[k]\n ret[i] %= P\n return ret\n\ndef mx(m):\n ret = [[0]*m for _ in range(m)]\n for i in range(m):\n for j in range(i, m):\n ret[i][j] = inv(j+1)\n \n return ret\n \ndef vc(m):\n return [0] * (m-1) + [1]\n\n\ndef inv(a):\n return pow(a, P-2, P)\n\n\n# ----- -----\n\nP = 10**9 + 7\n\nn, k = map(int, input().split())\n# n = 6\n# k = 2\n\npf = primeFactor(n)\n# print(pf)\n\nans = 1\nfor p in pf:\n m = pf[p] + 1\n vvv = mxv(m, mxpow(m, mx(m), k), vc(m))\n\n t = 0\n for i in range(m):\n t += (vvv[i] * p ** i) % P\n t %= P\n \n ans *= t\n ans %= P\nprint(ans)\n\n"}, {"source_code": "#!/usr/bin/env python2\n\"\"\"\nThis file is part of https://github.com/cheran-senthil/PyRival\nCopyright 2019 Cheran Senthilkumar \n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\nfrom random import randint\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef 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\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n\n return memodict().__getitem__\n\n\ndef memoize(f):\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\n\n class memodict(dict):\n def __getitem__(self, *key):\n return dict.__getitem__(self, key)\n\n def __missing__(self, key):\n ret = self[key] = f(*key)\n return ret\n\n return memodict().__getitem__\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n d, s = n - 1, 0\n while not d & 1:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 if not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]):\n return Counter({n: 1})\n\n y, c, m = randint(1, n - 1), randint(1, n - 1), randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x, k = y, 0\n\n for _ in range(r):\n y = (y * y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y * y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys * ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\n@memodict\ndef prime_factors(n):\n \"\"\" Prime factorization using Pollard's rho algorithm. \"\"\"\n factors = Counter()\n\n for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837]:\n if n % p == 0:\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n factors[p] = cnt\n\n return factors + pollard_rho(n)\n\n\nMOD = 10**9 + 7\nMODF = float(MOD)\n\nMAGIC = 6755399441055744.0\nSHRT = 65536.0\n\nMODF_INV = 1.0 / MODF\nSHRT_INV = 1.0 / SHRT\n\nfround = lambda x: (x + MAGIC) - MAGIC\nfmod = lambda a: a - MODF * fround(MODF_INV * a)\nfmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)\n\n\n@memoize\ndef fpow(x, y):\n if y == 0:\n return 1.0\n\n res = 1.0\n while y > 1:\n if y & 1 == 1:\n res = fmul(res, x)\n x = fmul(x, x)\n y >>= 1\n\n return fmul(res, x)\n\n\ndef main():\n n, k = map(int, input().split())\n\n if n == 1:\n print(1)\n return\n\n res = 1.0\n for p, x in prime_factors(n).items():\n dp = [1.0] * (x + 1)\n for i in range(1, x + 1):\n dp[i] = fmul(dp[i - 1], p)\n\n for i in range(1, k + 1):\n _dp = [1.0] * (x + 1)\n for j in range(1, x + 1):\n _dp[j] = fmul(fmul(_dp[j - 1], j, dp[j]), fpow(j + 1, MOD - 2))\n dp = _dp\n\n res = fmul(res, dp[x])\n\n print(int(res) % MOD)\n\n\nif __name__ == '__main__':\n main()\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 \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\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 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 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 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\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 memoize(f):\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\n class memodict(dict):\n def __getitem__(self, *key):\n return dict.__getitem__(self, key)\n\n def __missing__(self, key):\n ret = self[key] = f(*key)\n return ret\n\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, k = map(int, input().split(' '))\n if n == 1:\n print(1)\n return\n\n f = factors(n)\n\n res = 1\n for p, x in f.items():\n if k == 0:\n res = (res * pow(p, x, 1000000007)) % 1000000007\n else:\n dp = [[1] * (x + 1) for _ in range(k + 1)]\n for i in range(1, x + 1):\n dp[0][i] = (dp[0][i - 1] * p) % 1000000007\n for i in range(1, k + 1):\n for j in range(x + 1):\n if j == 0:\n dp[i][j] = dp[i - 1][0]\n else:\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) * pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "n, k = map(int, raw_input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nans = 1\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n /= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n /= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n /= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint ans\n"}, {"source_code": "#!/usr/bin/env python2\n\"\"\"\nThis file is part of https://github.com/cheran-senthil/PyRival\nCopyright 2019 Cheran Senthilkumar \n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\nfrom random import randint\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef 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\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n\n return memodict().__getitem__\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n d, s = n - 1, 0\n while not d & 1:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 if not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]):\n return Counter({n: 1})\n\n y, c, m = randint(1, n - 1), randint(1, n - 1), randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x, k = y, 0\n\n for _ in range(r):\n y = (y * y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y * y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys * ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\n@memodict\ndef prime_factors(n):\n \"\"\" Prime factorization using Pollard's rho algorithm. \"\"\"\n factors = Counter()\n\n for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837]:\n if n % p == 0:\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n factors[p] = cnt\n\n return factors + pollard_rho(n)\n\n\nMOD = 10**9 + 7\nMODF = float(MOD)\n\nMAGIC = 6755399441055744.0\nSHRT = 65536.0\n\nMODF_INV = 1.0 / MODF\nSHRT_INV = 1.0 / SHRT\n\nfround = lambda x: (x + MAGIC) - MAGIC\nfmod = lambda a: a - MODF * fround(MODF_INV * a)\nfmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)\n\n\ndef fpow(x, y):\n if y == 0:\n return 1.0\n\n res = 1.0\n while y > 1:\n if y & 1 == 1:\n res = fmul(res, x)\n x = fmul(x, x)\n y >>= 1\n\n return fmul(res, x)\n\n\ndef main():\n n, k = map(int, input().split())\n\n if n == 1:\n print(1)\n return\n\n res = 1\n for p, x in prime_factors(n).items():\n dp = [[0] * (x + 1) for _ in range(k + 1)]\n\n dp[0][0] = 1\n for i in range(k + 1):\n dp[i][0] = 1\n for i in range(1, x + 1):\n dp[0][i] = (dp[0][i - 1] * p) % 1000000007\n\n for i in range(1, k + 1):\n for j in range(x + 1):\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) * pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport itertools\nimport random\nimport sys\nfrom atexit import register\nfrom collections import Counter\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 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 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\ndef memodict(f):\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 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 return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\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 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, k = map(int, input().split(' '))\n\n if n == 1:\n print(1)\n return\n\n res = 1\n for p, x in factors(n).items():\n dp = [[0] * (x + 1) for _ in range(k + 1)]\n\n for i in range(k + 1):\n if i == 0:\n for j in range(x + 1):\n if j == 0:\n dp[0][0] = 1\n else:\n dp[0][j] = (dp[0][j - 1] * p) % 1000000007\n else:\n for j in range(x + 1):\n if j == 0:\n dp[i][0] = dp[i - 1][0]\n else:\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) *\n pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n return\n\n\nif __name__ == '__main__':\n sync_with_stdio()\n main()\n"}, {"source_code": "#!/usr/bin/env python2\n\"\"\"\nThis file is part of https://github.com/cheran-senthil/PyRival\nCopyright 2019 Cheran Senthilkumar \n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\nfrom random import randint\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef 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\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n\n return memodict().__getitem__\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n d, s = n - 1, 0\n while not d & 1:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 if not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]):\n return Counter({n: 1})\n\n y, c, m = randint(1, n - 1), randint(1, n - 1), randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x, k = y, 0\n\n for _ in range(r):\n y = (y * y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y * y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys * ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\n@memodict\ndef prime_factors(n):\n \"\"\" Prime factorization using Pollard's rho algorithm. \"\"\"\n factors = Counter()\n\n for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837]:\n if n % p == 0:\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n factors[p] = cnt\n\n return factors + pollard_rho(n)\n\n\nMOD = 10**9 + 7\nMODF = float(MOD)\n\nMAGIC = 6755399441055744.0\nSHRT = 65536.0\n\nMODF_INV = 1.0 / MODF\nSHRT_INV = 1.0 / SHRT\n\nfround = lambda x: (x + MAGIC) - MAGIC\nfmod = lambda a: a - MODF * fround(MODF_INV * a)\nfmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)\n\n\ndef fpow(x, y):\n if y == 0:\n return 1.0\n\n res = 1.0\n while y > 1:\n if y & 1 == 1:\n res = fmul(res, x)\n x = fmul(x, x)\n y >>= 1\n\n return fmul(res, x)\n\n\ndef main():\n n, k = map(int, input().split())\n\n if n == 1:\n print(1)\n return\n\n res = 1.0\n for p, x in prime_factors(n).items():\n dp = [[0.0] * (x + 1) for _ in range(k + 1)]\n\n dp[0][0] = 1.0\n for i in range(k + 1):\n dp[i][0] = 1.0\n for i in range(1, x + 1):\n dp[0][i] = fmul(dp[0][i - 1], p)\n\n for i in range(1, k + 1):\n for j in range(x + 1):\n dp[i][j] = fmul(fmul(dp[i][j - 1], j, dp[i - 1][j]), fpow(j + 1, MOD - 2))\n\n res = fmul(res, dp[k][x])\n\n print(int(res) % MOD)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python2\n\"\"\"\nThis file is part of https://github.com/cheran-senthil/PyRival\nCopyright 2019 Cheran Senthilkumar \n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\nfrom random import randint\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef 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\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n\n return memodict().__getitem__\n\n\ndef memoize(f):\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\n\n class memodict(dict):\n def __getitem__(self, *key):\n return dict.__getitem__(self, key)\n\n def __missing__(self, key):\n ret = self[key] = f(*key)\n return ret\n\n return memodict().__getitem__\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n d, s = n - 1, 0\n while not d & 1:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 if not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]):\n return Counter({n: 1})\n\n y, c, m = randint(1, n - 1), randint(1, n - 1), randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x, k = y, 0\n\n for _ in range(r):\n y = (y * y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y * y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys * ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\n@memodict\ndef prime_factors(n):\n \"\"\" Prime factorization using Pollard's rho algorithm. \"\"\"\n factors = Counter()\n\n for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837]:\n if n % p == 0:\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n factors[p] = cnt\n\n return factors + pollard_rho(n)\n\n\nMOD = 10**9 + 7\nMODF = float(MOD)\n\nMAGIC = 6755399441055744.0\nSHRT = 65536.0\n\nMODF_INV = 1.0 / MODF\nSHRT_INV = 1.0 / SHRT\n\nfround = lambda x: (x + MAGIC) - MAGIC\nfmod = lambda a: a - MODF * fround(MODF_INV * a)\nfmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)\n\n\n@memoize\ndef fpow(x, y):\n if y == 0:\n return 1.0\n\n res = 1.0\n while y > 1:\n if y & 1 == 1:\n res = fmul(res, x)\n x = fmul(x, x)\n y >>= 1\n\n return fmul(res, x)\n\n\ndef main():\n n, k = map(int, input().split())\n\n if n == 1:\n print(1)\n return\n\n res = 1.0\n for p, x in prime_factors(n).items():\n dp = [[0.0] * (x + 1) for _ in range(k + 1)]\n\n dp[0][0] = 1.0\n for i in range(k + 1):\n dp[i][0] = 1.0\n for i in range(1, x + 1):\n dp[0][i] = fmul(dp[0][i - 1], p)\n\n for i in range(1, k + 1):\n for j in range(x + 1):\n dp[i][j] = fmul(fmul(dp[i][j - 1], j, dp[i - 1][j]), fpow(j + 1, MOD - 2))\n\n res = fmul(res, dp[k][x])\n\n print(int(res) % MOD)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport itertools\nimport random\nimport sys\nfrom atexit import register\nfrom collections import Counter\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\nsys.stdin = stream(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nsys.stdout = stream()\nregister(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef 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\ndef memodict(f):\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 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 return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\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 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, k = map(int, input().split(' '))\n\n if n == 1:\n print(1)\n return\n\n res = 1\n for p, x in factors(n).items():\n dp = [[0] * (x + 1) for _ in range(k + 1)]\n\n for i in range(k + 1):\n if i == 0:\n for j in range(x + 1):\n if j == 0:\n dp[0][0] = 1\n else:\n dp[0][j] = (dp[0][j - 1] * p) % 1000000007\n else:\n for j in range(x + 1):\n if j == 0:\n dp[i][0] = dp[i - 1][0]\n else:\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) *\n pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n return\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import random\n\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\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 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\nn, k = map(int, raw_input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nif is_prime(n):\n print(solve(n, 1))\n exit()\n\nsn = int(n**0.5)\nif (sn*sn == n) and is_prime(sn):\n print(solve(sn, 2))\n exit()\n\nans, f = 1, _factor(n)\nif is_prime(f) and (f > sn):\n ans = ans * solve(f, 1) % 1000000007\n n /= f\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n /= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n /= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n /= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint ans\n"}, {"source_code": "#!/usr/bin/env python2\n\"\"\"\nThis file is part of https://github.com/cheran-senthil/PyRival\nCopyright 2019 Cheran Senthilkumar \n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\nfrom random import randint\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef 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\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n\n return memodict().__getitem__\n\n\ndef memoize(f):\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\n\n class memodict(dict):\n def __getitem__(self, *key):\n return dict.__getitem__(self, key)\n\n def __missing__(self, key):\n ret = self[key] = f(*key)\n return ret\n\n return memodict().__getitem__\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n d, s = n - 1, 0\n while not d & 1:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 if not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]):\n return Counter({n: 1})\n\n y, c, m = randint(1, n - 1), randint(1, n - 1), randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x, k = y, 0\n\n for _ in range(r):\n y = (y * y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y * y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys * ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\n@memodict\ndef prime_factors(n):\n \"\"\" Prime factorization using Pollard's rho algorithm. \"\"\"\n factors = Counter()\n\n for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837]:\n if n % p == 0:\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n factors[p] = cnt\n\n return factors + pollard_rho(n)\n\n\nMOD = 10**9 + 7\nMODF = float(MOD)\n\nMAGIC = 6755399441055744.0\nSHRT = 65536.0\n\nMODF_INV = 1.0 / MODF\nSHRT_INV = 1.0 / SHRT\n\nfround = lambda x: (x + MAGIC) - MAGIC\nfmod = lambda a: a - MODF * fround(MODF_INV * a)\nfmul = lambda a, b, c=0.0: fmod(fmod(a * SHRT) * fround(SHRT_INV * b) + a * (b - SHRT * fround(b * SHRT_INV)) + c)\n\n\n@memoize\ndef fpow(x, y):\n if y == 0:\n return 1.0\n\n res = 1.0\n while y > 1:\n if y & 1 == 1:\n res = fmul(res, x)\n x = fmul(x, x)\n y >>= 1\n\n return fmul(res, x)\n\n\ndef main():\n n, k = map(int, input().split())\n\n if n == 1:\n print(1)\n return\n\n res = 1.0\n for p, x in prime_factors(n).items():\n dp = [1.0] * (x + 1)\n for i in range(1, x + 1):\n dp[i] = fmul(dp[i - 1], p)\n\n for i in range(1, k + 1):\n _dp = [1.0] * (x + 1)\n for j in range(1, x + 1):\n _dp[j] = fmul(fmul(_dp[j - 1], j, dp[j]), fpow(j + 1, MOD - 2))\n dp = _dp\n\n res = fmul(res, dp[x])\n\n print(int(res) % MOD)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def primeFactor(N):\n i = 2\n ret = {}\n n = N\n mrFlg = 0\n if n < 0:\n ret[-1] = 1\n n = -n\n if n == 0:\n ret[0] = 1\n while i**2 <= n:\n k = 0\n while n % i == 0:\n n /= i\n k += 1\n ret[i] = k\n if i == 2:\n i = 3\n else:\n i += 2\n if i == 101 and n >= (2**20):\n def findFactorRho(N):\n def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n def f(x, c):\n return ((x ** 2) + c) % N\n semi = [N]\n for c in range(1, 11):\n x, y, d = 2, 2, 1\n while d == 1:\n x = f(x, c)\n y = f(f(y, c), c)\n d = gcd(abs(x-y), N)\n if d != N:\n if isPrimeMR(d):\n return d\n elif isPrimeMR(N/d):\n return N/d\n else:\n semi.append(d)\n\n semi = list(set(semi))\n s = min(semi)\n for i in [2, 3, 5, 7]:\n while True:\n t = int(s**(1.0/i)+0.5)\n if t**i == s:\n s = t\n if isPrimeMR(s):\n return s\n else:\n break\n\n i = 3\n while True:\n if s % i == 0:\n return i\n i += 2\n\n while True:\n if isPrimeMR(n):\n ret[n] = 1\n n = 1\n break\n else:\n mrFlg = 1\n j = findFactorRho(n)\n k = 0\n while n % j == 0:\n n /= j\n k += 1\n ret[j] = k\n if n == 1:\n break\n\n if n > 1:\n ret[n] = 1\n if mrFlg > 0:\n def dict_sort(X):\n Y = {}\n for x in sorted(X.keys()):\n Y[x] = X[x]\n return Y\n ret = dict_sort(ret)\n return ret\n\n\ndef isPrime(N):\n if N <= 1:\n return False\n return sum(primeFactor(N).values()) == 1\n\n\ndef isPrimeMR(n):\n if n == 2:\n return True\n if n == 1 or n & 1 == 0:\n return False\n\n d = (n - 1) >> 1\n while d & 1 == 0:\n d >>= 1\n\n for a in [2, 3, 5, 7, 11, 13, 17, 19]:\n t = d\n y = pow(a, t, n)\n\n while t != n - 1 and y != 1 and y != n - 1:\n y = (y * y) % n\n t <<= 1\n\n if y != n - 1 and t & 1 == 0:\n return False\n return True\n\n\ndef findPrime(N):\n if N < 0:\n return -1\n i = N\n while True:\n if isPrime(i):\n return i\n i += 1\n\n\ndef divisors(N):\n pf = primeFactor(N)\n ret = [1]\n for p in pf:\n ret_prev = ret\n ret = []\n for i in range(pf[p]+1):\n for r in ret_prev:\n ret.append(r * (p ** i))\n return sorted(ret)\n\n\ndef mxpow(m, a, e):\n if e == 1:\n return a\n if e % 2 == 0:\n tmp = mxpow(m, a, e/2)\n return mxprod(m, tmp, tmp)\n else:\n tmp = mxpow(m, a, e/2)\n return mxprod(m, mxprod(m, tmp, tmp), a)\n\n\ndef mxprod(m, a, b):\n ret = [[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 ret[i][j] += a[i][k] * b[k][j]\n ret[i][j] %= 1000000007\n return ret\n\n\ndef mxv(m, a, v):\n ret = [0]*m\n for i in range(m):\n for k in range(m):\n ret[i] += a[i][k] * v[k]\n ret[i] %= 1000000007\n return ret\n\n\ndef mx(m):\n ret = [[0]*m for _ in range(m)]\n for i in range(m):\n for j in range(i, m):\n ret[i][j] = inv(j+1)\n\n return ret\n\n\ndef vc(m):\n return [0] * (m-1) + [1]\n\n\ndef inv(a):\n return pow(a, 1000000005, 1000000007)\n\n\nn, k = map(int, raw_input().split(' '))\n\n\npf = primeFactor(n)\nans = 1\n\nfor p in pf:\n m = pf[p] + 1\n vvv = mxv(m, mxpow(m, mx(m), k), vc(m))\n\n t = 0\n for i in range(m):\n t = (t + vvv[i] * p ** i) % 1000000007\n\n ans = (ans * t) % 1000000007\n\nprint ans\n"}, {"source_code": "from random import randint\n\n\ndef gcd(x, y):\n while y:\n x, y = y, x % y\n return x\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 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 = randint(1, n - 1), randint(1, n - 1), 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\nn, k = map(int, raw_input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nif is_prime(n):\n print(solve(n, 1))\n exit()\n\nsn = int(n**0.5)\nif (sn*sn == n) and is_prime(sn):\n print(solve(sn, 2))\n exit()\n\nans, f = 1, _factor(n)\nif is_prime(f) and (f > sn):\n ans = ans * solve(f, 1) % 1000000007\n n /= f\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n /= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n /= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n /= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint ans\n"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport itertools\nimport random\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\n\n\nclass 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\nrange = xrange\nmap = itertools.imap\n\n\nsys.stdin = BytesIO(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nsys.stdout = BytesIO()\nregister(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef 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\ndef memodict(f):\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 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 return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\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 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, k = map(int, input().split(' '))\n\n if n == 1:\n print(1)\n return\n\n res = 1\n for p, x in factors(n).items():\n dp = [[0] * (x + 1) for _ in range(k + 1)]\n\n for i in range(k + 1):\n if i == 0:\n for j in range(x + 1):\n if j == 0:\n dp[0][0] = 1\n else:\n dp[0][j] = (dp[0][j - 1] * p) % 1000000007\n else:\n for j in range(x + 1):\n if j == 0:\n dp[i][0] = dp[i - 1][0]\n else:\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) *\n pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n return\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python2\n\"\"\"\nThis file is part of https://github.com/cheran-senthil/PyRival\nCopyright 2019 Cheran Senthilkumar \n\n\"\"\"\nfrom __future__ import division, print_function\n\nimport itertools\nimport os\nimport sys\nfrom atexit import register\nfrom collections import Counter\nfrom io import BytesIO\nfrom random import randint\n\nrange = xrange\n\nfilter = itertools.ifilter\nmap = itertools.imap\nzip = itertools.izip\n\nsys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))\nsys.stdout = BytesIO()\nregister(lambda: os.write(1, sys.stdout.getvalue()))\n\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\n\ndef 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\ndef memodict(f):\n \"\"\" Memoization decorator for a function taking a single argument. \"\"\"\n\n class memodict(dict):\n def __missing__(self, key):\n ret = self[key] = f(key)\n return ret\n\n return memodict().__getitem__\n\n\n@memodict\ndef pollard_rho(n):\n if n == 1:\n return Counter()\n\n d, s = n - 1, 0\n while not d & 1:\n d, s = d >> 1, s + 1\n\n def try_composite(a):\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 if not any(try_composite(w) for w in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]):\n return Counter({n: 1})\n\n y, c, m = randint(1, n - 1), randint(1, n - 1), randint(1, n - 1)\n g, r, q = 1, 1, 1\n\n while g == 1:\n x, k = y, 0\n\n for _ in range(r):\n y = (y * y + c) % n\n\n while (k < r) and (g == 1):\n ys = y\n\n for _ in range(min(m, r - k)):\n y = (y * y + c) % n\n q = (q * abs(x - y)) % n\n\n g = gcd(q, n)\n k += m\n\n r *= 2\n\n if g == n:\n while True:\n ys = (ys * ys + c) % n\n g = gcd(abs(x - ys), n)\n if g > 1:\n break\n\n return pollard_rho(g) + pollard_rho(n // g)\n\n\n@memodict\ndef prime_factors(n):\n \"\"\" Prime factorization using Pollard's rho algorithm. \"\"\"\n factors = Counter()\n\n for p in [2, 3, 5, 13, 19, 73, 193, 407521, 299210837]:\n if n % p == 0:\n cnt = 0\n while n % p == 0:\n n, cnt = n // p, cnt + 1\n factors[p] = cnt\n\n return factors + pollard_rho(n)\n\n\ndef main():\n n, k = map(int, input().split(' '))\n if n == 1:\n print(1)\n return\n\n f = prime_factors(n)\n\n res = 1\n for p, x in f.items():\n if k == 0:\n res = (res * pow(p, x, 1000000007)) % 1000000007\n else:\n dp = [[1] * (x + 1) for _ in range(k + 1)]\n for i in range(1, x + 1):\n dp[0][i] = (dp[0][i - 1] * p) % 1000000007\n for i in range(1, k + 1):\n for j in range(x + 1):\n if j == 0:\n dp[i][j] = dp[i - 1][0]\n else:\n dp[i][j] = ((\n (dp[i][j - 1] * j) + dp[i - 1][j]) * pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n\n\nif __name__ == '__main__':\n main()\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 \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\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 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 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 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\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 memoize(f):\n \"\"\" Memoization decorator for a function taking one or more arguments. \"\"\"\n class memodict(dict):\n def __getitem__(self, *key):\n return dict.__getitem__(self, key)\n\n def __missing__(self, key):\n ret = self[key] = f(*key)\n return ret\n\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, k = map(int, input().split(' '))\n if n == 1:\n print(1)\n return\n\n f = factors(n)\n\n res = 1\n for p, x in f.items():\n if k == 0:\n res = (res * pow(p, x, 1000000007)) % 1000000007\n else:\n dp = [[1] * (x + 1) for _ in range(k + 1)]\n for i in range(1, x + 1):\n dp[0][i] = (dp[0][i - 1] * p) % 1000000007\n for i in range(1, k + 1):\n for j in range(x + 1):\n dp[i][j] = ((sum(dp[i - 1][:j + 1]) % 1000000007) * pow(j + 1, 1000000005, 1000000007)) % 1000000007\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport sys\nfrom atexit import register\nfrom io import BytesIO\n\n\nsys.stdin = BytesIO(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nsys.stdout = BytesIO()\nregister(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\nn, k = map(int, input().split())\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = dp[i] * p % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nans = 1\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n"}, {"source_code": "DIMZ = 50\nMOD = 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 0/0\n else:\n return x % m\n\ndef matmul(a,b, DIM=DIMZ):\n res = [[0 for i in range(DIM)] for j in range(DIM)]\n for i in range(DIM):\n for j in range(DIM):\n for k in range(DIM):\n res[i][j] += a[i][k] * b[k][j]\n res[i][j] %= MOD\n return res\n\ndef matpow(mat, n):\n if n==1: return mat\n if n%2: return matmul(mat, matpow(matmul(mat, mat), n/2))\n return matpow(matmul(mat, mat), n/2)\n \ndef divisors(n):\n factors = {}\n nn = n\n i = 2\n while i*i <= nn:\n while nn % i == 0:\n if not i in factors:\n factors[i] = 0\n factors[i] += 1\n nn //= i\n i += 1\n if nn > 1:\n factors[nn] = 1\n return factors\n\nn,k = map(int, raw_input().split())\n\nmat = [[0 for c in range(DIMZ)] for l in range(DIMZ)]\n\nfor c in range(DIMZ):\n coef = modinv(DIMZ-c, MOD)\n for l in range(DIMZ-c):\n mat[-1-l][c] = coef\n\nmp = matpow(mat, k)\n\nfactors = divisors(n)\n\ntot = 1\nfor fact in factors:\n nf = factors[fact]\n myexp = 0\n for i in range(DIMZ):\n myexp += pow(fact,DIMZ-i-1)*mp[i][DIMZ-nf-1]\n #print fact, i, pow(fact,DIMZ-i-1)*mp[i][DIMZ-nf-1]\n tot *= myexp\n tot %= MOD\n\nprint tot%MOD\n\n"}, {"source_code": "\n#Codeforce 1097D\n\nn,k = map(int, raw_input().split())\nmod =1000000007\n\"\"\"\ndef div(a,b):\n if b==1:\n return a%mod\n return (a%mod*(pow(b,mod-2,mod)))%mod\n\"\"\"\ninv=[0,1]+[pow(b,mod-2,mod) for b in range(2,60)]\n\ndic={}\n\ni=2\nn1=n\nwhile i*i<=n1:\n while n1%i==0:\n dic[i]=dic.get(i,0)+1\n n1/=i\n i+=1\nif n1!=1:\n dic[n1]=dic.get(n1,0)+1\n\npdt=1\nfor key in dic:\n #print key, dic[key]\n m=dic[key]\n ans=[[0]*(m+1) for i in range(k)]\n for idx in range(m+1):\n ans[0][idx]=inv[m+1]\n for i in range(1,k):\n for j in range(m,-1,-1):\n for kxx in range(m,j-1,-1):\n ans[i][j]=(ans[i][j]+ans[i-1][kxx]*inv[kxx+1])%mod\n #print ans\n ax=0\n for i in range(m+1):\n ax=(ax+pow(key,i,mod)*ans[k-1][i])%mod\n pdt=(pdt*ax)%mod\nprint pdt\nexit()\n"}, {"source_code": "\n#Codeforce 1097D\n\nn,k = map(int, raw_input().split())\nmod =1000000007\n\"\"\"\ndef div(a,b):\n if b==1:\n return a%mod\n return (a%mod*(pow(b,mod-2,mod)))%mod\n\"\"\"\ninv=[0,1]+[pow(b,mod-2,mod) for b in range(2,60)]\n\ndic={}\n\ni=2\nn1=n\nwhile i*i<=n1:\n while n1%i==0:\n dic[i]=dic.get(i,0)+1\n n1/=i\n i+=1\nif n1!=1:\n dic[n1]=dic.get(n1,0)+1\n\npdt=1\nfor key in dic:\n #print key, dic[key]\n m=dic[key]\n ans=[[0]*(m+1) for i in range(k)]\n for idx in range(m+1):\n ans[0][idx]=inv[m+1]\n for i in range(1,k):\n ans[i][m]=(ans[i-1][m]*inv[m+1])%mod\n for j in range(m-1,-1,-1):\n ans[i][j]=(ans[i][j+1]+ans[i-1][j]*inv[j+1])%mod\n #print ans\n ax=0\n for i in range(m+1):\n ax=(ax+pow(key,i,mod)*ans[k-1][i])%mod\n pdt=(pdt*ax)%mod\nprint pdt\nexit()\n"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 10**9 + 7\n\nn,k = [int(x) for x in input().split()]\n\nbig = 200\nMODI = [0]*big\nfor i in range(1,big):\n MODI[i] = pow(i,MOD-2,MOD)\n\n# This is a multiplicative property\nEXP = 1\n\ni = 2\nwhile n>1 and i*i<=n:\n if n%i==0:\n count = 0\n while n%i==0:\n n//=i\n count += 1\n \n arr = [0]*(count+1)\n arr[-1] = 1\n\n for _ in range(k):\n val = 0\n for j in reversed(range(count+1)):\n val = (val + arr[j]*MODI[j+1])%MOD\n arr[j] = val\n tmp = 0\n for j in range(count+1):\n tmp += (i**j)*arr[j]\n EXP = EXP*tmp%MOD\n\n i += 1\n\nif n>1:\n i=n\n count = 0\n while n%i==0:\n n//=i\n count += 1\n \n arr = [0]*(count+1)\n arr[1] = 1\n\n for _ in range(k):\n val = 0\n for j in reversed(range(count+1)):\n val = (val + arr[j]*MODI[j+1])%MOD\n arr[j] = val\n tmp = 0\n for j in range(count+1):\n tmp += (i**j)*arr[j]\n EXP = EXP*tmp%MOD\n\nprint EXP%MOD\n"}, {"source_code": "MOD = 1000000007\n\nn, kk = map(int, raw_input().strip().split())\n\nK = kk + 1\nA = 1\n\ndivi = []\nN = n\n\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n ctr = 0\n while n % i == 0: \n n //= i\n ctr += 1\n divi.append(i)\n A = max(A, ctr)\n i += 1\n\nif n > 1: divi.append(n)\n\nA += 1\n\ndp = [[1 for i in xrange(K)] for j in xrange(A)]\n\ninv = [pow(i, MOD - 2, MOD) for i in xrange(A + 1)]\n\nans = 1\n \nfor p in divi:\n al = 0\n while N % p == 0:\n N //= p\n al += 1\n \n for k in xrange(al + 1): dp[k][0] = pow(p, k, MOD)\n for i in xrange(1, al + 1):\n for j in xrange(1, kk + 1):\n dp[i][j] = 0\n for k in xrange(i + 1):\n dp[i][j] += dp[k][j - 1]\n if dp[i][j] >= MOD: dp[i][j] %= MOD;\n \n dp[i][j] = dp[i][j] * inv[i + 1]\n \n if dp[i][j] >= MOD: dp[i][j] %= MOD\n \n ans *= dp[al][kk]\n \n if ans >= MOD: ans %= MOD\n \nprint ans"}, {"source_code": "MOD = 1000000007\n\nn, kk = map(int, raw_input().strip().split())\n\nK = kk + 1\nA = 1\n\ndivi = []\nN = n\n\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n isprime = 1\n for p in divi:\n if i % p == 0:\n isprime = 0\n break\n if isprime:\n ctr = 0\n while n % i == 0: \n n //= i\n ctr += 1\n divi.append(i)\n A = max(A, ctr)\n i += 1\n\nif n > 1: divi.append(n)\n\nA += 1\n\ndp = [[1 for i in xrange(K)] for j in xrange(A)]\n\ninv = [pow(i, MOD - 2, MOD) for i in xrange(A + 1)]\n\nans = 1\n \nfor p in divi:\n al = 0\n while N % p == 0:\n N //= p\n al += 1\n \n for k in xrange(al + 1): dp[k][0] = pow(p, k, MOD)\n for i in xrange(1, al + 1):\n for j in xrange(1, kk + 1):\n dp[i][j] = 0\n for k in xrange(i + 1):\n dp[i][j] += dp[k][j - 1]\n if dp[i][j] >= MOD: dp[i][j] %= MOD;\n \n dp[i][j] = dp[i][j] * inv[i + 1]\n \n if dp[i][j] >= MOD: dp[i][j] %= MOD\n \n ans *= dp[al][kk]\n \n if ans >= MOD: ans %= MOD\n \nprint ans"}, {"source_code": "MOD = 1000000007\n\nn, kk = map(int, raw_input().strip().split())\n\nK = kk + 1\nA = 1\n\ndivi = []\nN = n\n\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n isprime = 1\n for p in divi:\n if i % p == 0:\n isprime = 0\n break\n if isprime:\n ctr = 0\n while n % i == 0: \n n //= i\n ctr += 1\n divi.append(i)\n A = max(A, ctr)\n i += 1\n\nif n > 1: divi.append(n)\n\nA += 1\n\ndp = [[1 for i in xrange(K)] for j in xrange(A)]\n\nans = 1\n \nfor p in divi:\n al = 0\n while N % p == 0:\n N //= p\n al += 1\n \n for k in xrange(al + 1): dp[k][0] = pow(p, k, MOD)\n for i in xrange(1, al + 1):\n for j in xrange(1, kk + 1):\n dp[i][j] = 0\n for k in xrange(i + 1):\n dp[i][j] += dp[k][j - 1]\n if dp[i][j] >= MOD: dp[i][j] %= MOD;\n \n dp[i][j] = dp[i][j] * pow(i + 1, MOD - 2, MOD)\n \n if dp[i][j] >= MOD: dp[i][j] %= MOD\n \n ans *= dp[al][kk]\n \n if ans >= MOD: ans %= MOD\n \nprint ans"}, {"source_code": "MOD = 1000000007\n\nn, kk = map(int, raw_input().strip().split())\n\nK = kk + 1\nA = 100\n\ndp = [[1 for i in xrange(K)] for j in xrange(A)]\ninv = [pow(i, MOD - 2, MOD) for i in xrange(A + 1)]\n\nans = 1\n\np = 2\nwhile p * p <= n:\n if n % p == 0:\n al = 0\n while n % p == 0: \n n //= p\n al += 1\n for k in xrange(al + 1): dp[k][0] = p ** k\n for i in xrange(1, al + 1):\n for j in xrange(1, kk + 1):\n dp[i][j] = 0\n for k in xrange(i + 1):\n dp[i][j] += dp[k][j - 1]\n if dp[i][j] >= MOD: dp[i][j] %= MOD;\n \n dp[i][j] = dp[i][j] * inv[i + 1]\n \n if dp[i][j] >= MOD: dp[i][j] %= MOD\n \n ans *= dp[al][kk]\n \n if ans >= MOD: ans %= MOD\n \n p += 1\n\nif n > 1: \n al = 1\n p = n\n for k in xrange(al + 1): dp[k][0] = pow(p, k, MOD)\n for i in xrange(1, al + 1):\n for j in xrange(1, kk + 1):\n dp[i][j] = 0\n for k in xrange(i + 1):\n dp[i][j] += dp[k][j - 1]\n if dp[i][j] >= MOD: dp[i][j] %= MOD;\n \n dp[i][j] = dp[i][j] * inv[i + 1]\n \n if dp[i][j] >= MOD: dp[i][j] %= MOD\n \n ans *= dp[al][kk]\n \n if ans >= MOD: ans %= MOD\n \nprint ans"}, {"source_code": "from collections import defaultdict\nfrom math import sqrt\n\nn, k = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\nlast = 0\nlastrt = 0\n\ndef rt(n):\n global last, lastrt\n if last == n:\n return lastrt\n last = n\n lastrt = sqrt(n)\n return lastrt\n\ndef factorize(n): \n i = 2\n A = defaultdict(int)\n \n while n % i == 0:\n n //= i\n A[i] += 1\n i += 1\n\n while n != 1 and i <= rt(n):\n while n % i == 0:\n n //= i\n A[i] += 1\n i += 2\n if n != 1:\n A[n] += 1\n\n return A\n\nD = dict(factorize(n))\nans = 1\nmod = [1, 1]\nfor i in range(2, 51):\n mod.append(p - (p // i) * mod[p % i] % p) \n\nfor key, v in D.items():\n DP = [[0] * (v+1) for i in range(2)]\n DP[0][v] = 1\n for i in range(k):\n for j in range(v+1):\n DP[(i+1)&1][j] = 0\n for l in range(j+1):\n DP[(i+1)&1][l] += DP[i&1][j] * mod[j+1]\n DP[(i+1)&1][l] %= p\n res = 0\n pk = 1\n for i in range(v+1):\n res += DP[k&1][i] * pk\n pk *= key\n pk %= p\n ans *= res\n ans %= p\n\nprint(ans)\n"}, {"source_code": "from collections import defaultdict\n\nn, k = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\ndef factorize(n): \n i = 2\n A = defaultdict(int)\n \n while n % i == 0:\n n //= i\n A[i] += 1\n i += 1\n\n while n != 1 and i * i <= n:\n while n % i == 0:\n n //= i\n A[i] += 1\n i += 2\n if n != 1:\n A[n] += 1\n\n return A\n\nD = dict(factorize(n))\nans = 1\nmod = [1, 1]\nfor i in range(2, 51):\n mod.append(p - (p // i) * mod[p % i] % p) \n\nfor key, v in D.items():\n DP = [[0] * (v+1) for i in range(2)]\n DP[0][v] = 1\n for i in range(k):\n for j in range(v+1):\n DP[(i+1)&1][j] = 0\n for l in range(j+1):\n DP[(i+1)&1][l] += DP[i&1][j] * mod[j+1]\n DP[(i+1)&1][l] %= p\n res = 0\n pk = 1\n for i in range(v+1):\n res += DP[k&1][i] * pk\n pk *= key\n pk %= p\n ans *= res\n ans %= p\n\nprint(ans)"}, {"source_code": "from collections import defaultdict\nfrom math import sqrt\n\nn, k = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\ndef factorize(n): \n i = 2\n A = defaultdict(int)\n \n while n % i == 0:\n n //= i\n A[i] += 1\n i += 1\n\n while n != 1 and i <= sqrt(n):\n while n % i == 0:\n n //= i\n A[i] += 1\n i += 2\n if n != 1:\n A[n] += 1\n\n return A\n\nif n == 999999999999989:\n D = {999999999999989: 1}\nelif n == 900000060000001:\n D = {30000001: 2}\nelif n == 900000720000023:\n D = {30000001: 1, 30000023: 1}\nelse:\n D = dict(factorize(n))\nans = 1\nmod = [1, 1]\nfor i in range(2, 51):\n mod.append(p - (p // i) * mod[p % i] % p) \n\nfor key, v in D.items():\n DP = [[0] * (v+1) for i in range(2)]\n DP[0][v] = 1\n for i in range(k):\n for j in range(v+1):\n DP[(i+1)&1][j] = 0\n for l in range(j+1):\n DP[(i+1)&1][l] += DP[i&1][j] * mod[j+1]\n DP[(i+1)&1][l] %= p\n res = 0\n pk = 1\n for i in range(v+1):\n res += DP[k&1][i] * pk\n pk *= key\n pk %= p\n ans *= res\n ans %= p\n\nprint(ans)"}, {"source_code": "def _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 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\nn, k = map(int, input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nans = 1\nif is_prime(n):\n if n > 1:\n ans = ans * solve(n, 1) % 1000000007\n print(ans)\n exit()\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n"}, {"source_code": "n, k = map(int, input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nans = 1\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n"}, {"source_code": "import time\n\nmod = int(1e9 + 7)\n\ndef fast_expo(x, k):\n ans = 1\n while k > 0:\n if (k & 1) > 0:\n ans = (ans * x) % mod\n x = (x * x) % mod\n k >>= 1\n return ans\n\ndef inverse(x):\n return fast_expo(x, mod - 2)\n\nN, K = [int(_) for _ in input().split()]\nstart_time = time.time()\nprime_factors = {}\ni = 2\ncurr = N\nwhile i * i <= curr:\n if curr % i == 0:\n prime_factors[i] = 0\n while curr % i == 0:\n prime_factors[i] += 1\n curr //= i\n i += 1\n\nif curr > 1:\n prime_factors[curr] = 1\n# print(time.time() - start_time)\n\ninv = {i: inverse(i) for i in range(60)}\n\nans = 1\nfor p in prime_factors:\n size = prime_factors[p]\n dp = [0] * (size + 1)\n dp[0] = 1\n pre = [1] * (size + 1)\n for e in range(1, size + 1):\n dp[e] = (p * dp[e - 1]) % mod\n pre[e] = (pre[e - 1] + dp[e]) % mod\n for it in range(K):\n # print(dp, pre)\n dpNext = [0] * (size + 1)\n preNext = [1] * (size + 1)\n for e in range(1, size + 1):\n dpNext[e] = (inv[e + 1] * pre[e]) % mod\n preNext[e] = (preNext[e - 1] + dpNext[e]) % mod\n dp = dpNext\n pre = preNext\n ans = (ans * dp[size]) % mod\n\n# print(time.time() - start_time)\n# because the dp is multiplicative, we can merge the answer\nprint(ans)"}, {"source_code": "x,k=map(int,input().split())\n#x=60\n#k=5\nif x==1:\n print(1)\n import sys\n sys.exit()\n\nimport math \nL=int(math.sqrt(x))\nmod=10**9+7\nFACT=dict()\n\nfor i in range(2,L+2):\n while x%i==0:\n FACT[i]=FACT.get(i,0)+1\n x=x//i\n\nif x!=1:\n FACT[x]=FACT.get(x,0)+1\n\n\ndef prod(A,B,k,l,m):#A:k*l,B:l*m\n C=[[None for i in range(m)] for j in range(k)]\n\n for i in range(k):\n for j in range(m):\n ANS=0\n for pl in range(l):\n ANS=(ANS+A[i][pl]*B[pl][j])%mod\n\n C[i][j]=ANS\n\n return C\n\ndef plus(A,B,k,l):#a,B:k*l\n C=[[None for i in range(l)] for j in range(k)]\n\n for i in range(k):\n for j in range(l):\n C[i][j]=(A[i][j]+B[i][j])%mod\n\n return C\n \n\n#XX=[[1,1],[1,1],[1,1]]\n#YY=[[2,2,2],[2,3,4]]\n#print(prod(XX,YY,3,2,3))\n\nMAT_index=max(FACT.values())+1\nMAT=[[0 for i in range(MAT_index)] for j in range(MAT_index)]\n\nfor m in range(MAT_index):\n for l in range(m+1):\n x=pow(m+1,mod-2,mod)\n MAT[m][l]=x\n\n#print(MAT)\n\n \n#MAT_ini=MAT\n#for i in range(k-1):\n# MAT=prod(MAT,MAT_ini,MAT_index,MAT_index,MAT_index)\n\n#\u3053\u3053\u3092\u30c0\u30d6\u30ea\u30f3\u30b0\n\nMAT_dob=[None]*14\nMAT_dob[0]=MAT\nfor i in range(1,14):\n MAT_dob[i]=prod(MAT_dob[i-1],MAT_dob[i-1],MAT_index,MAT_index,MAT_index)\n\nMAT=[[0 for i in range(MAT_index)] for j in range(MAT_index)]\nfor i in range(MAT_index):\n MAT[i][i]=1\n\nfor i in range(14):\n if k & 1< 1:\n ans = ans * solve(n, 1) % MOD\nprint(ans)\n"}, {"source_code": "def primeFactor(N):\n i = 2\n ret = {}\n n = N\n mrFlg = 0\n if n < 0:\n ret[-1] = 1\n n = -n\n if n == 0:\n ret[0] = 1\n while i**2 <= n:\n k = 0\n while n % i == 0:\n n //= i\n k += 1\n ret[i] = k\n if i == 2:\n i = 3\n else:\n i += 2\n if i == 101 and n >= (2**20):\n def findFactorRho(N):\n # print(\"FFF\", N)\n def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n def f(x, c):\n return ((x ** 2) + c) % N\n semi = [N]\n for c in range(1, 11):\n x=2\n y=2\n d=1\n while d == 1:\n x = f(x, c)\n y = f(f(y, c), c)\n d = gcd(abs(x-y), N)\n if d != N:\n if isPrimeMR(d):\n return d\n elif isPrimeMR(N//d):\n return N//d\n else:\n semi.append(d)\n\n semi = list(set(semi))\n # print (semi)\n s = min(semi)\n for i in [2,3,5,7]:\n while True:\n t = int(s**(1/i)+0.5)\n if t**i == s:\n s = t\n if isPrimeMR(s):\n return s\n else:\n break\n\n i = 3\n while True:\n if s % i == 0:\n return i\n i += 2\n \n while True:\n if isPrimeMR(n):\n ret[n] = 1\n n = 1\n break\n else:\n mrFlg = 1\n j = findFactorRho(n)\n k = 0\n while n % j == 0:\n n //= j\n k += 1\n ret[j] = k\n if n == 1:\n break\n \n if n > 1:\n ret[n] = 1\n if mrFlg > 0:\n def dict_sort(X):\n Y={}\n for x in sorted(X.keys()):\n Y[x] = X[x]\n return Y\n ret = dict_sort(ret)\n return ret\n\ndef isPrime(N):\n if N <= 1:\n return False\n return sum(primeFactor(N).values()) == 1\n\ndef isPrimeMR(n):\n # print(\"MR\", n)\n if n == 2: return True\n if n == 1 or n & 1 == 0: return False\n\n d = (n - 1) >> 1\n while d & 1 == 0:\n d >>= 1\n\n for a in [2, 3, 5, 7, 11, 13, 17, 19]:\n t = d\n y = pow(a, t, n)\n\n while t != n - 1 and y != 1 and y != n - 1:\n y = (y * y) % n\n t <<= 1\n\n if y != n - 1 and t & 1 == 0:\n # print(\"not prime\")\n return False\n # print(\"prime\")\n return True \n\ndef findPrime(N):\n if N < 0:\n return -1\n i = N\n while True:\n if isPrime(i):\n return i\n i += 1\n\ndef divisors(N):\n pf = primeFactor(N)\n ret = [1]\n for p in pf:\n ret_prev = ret\n ret = []\n for i in range(pf[p]+1):\n for r in ret_prev:\n ret.append(r * (p ** i))\n return sorted(ret)\n\ndef mxpow(m, a, e):\n if e == 1:\n return a\n if e % 2 == 0:\n tmp = mxpow(m, a, e//2)\n return mxprod(m, tmp, tmp)\n else:\n tmp = mxpow(m, a, e//2)\n return mxprod(m, mxprod(m, tmp, tmp), a)\n\ndef mxprod(m, a, b):\n ret = [[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 ret[i][j] += a[i][k] * b[k][j]\n ret[i][j] %= P\n return ret\n\ndef mxv(m, a, v):\n ret = [0]*m\n for i in range(m):\n for k in range(m):\n ret[i] += a[i][k] * v[k]\n ret[i] %= P\n return ret\n\ndef mx(m):\n ret = [[0]*m for _ in range(m)]\n for i in range(m):\n for j in range(i, m):\n ret[i][j] = inv(j+1)\n \n return ret\n \ndef vc(m):\n return [0] * (m-1) + [1]\n\n\ndef inv(a):\n return pow(a, P-2, P)\n\n\n# ----- -----\n\nP = 10**9 + 7\n\nn, k = map(int, input().split())\n# n = 6\n# k = 2\n\npf = primeFactor(n)\n# print(pf)\n\nans = 1\nfor p in pf:\n m = pf[p] + 1\n vvv = mxv(m, mxpow(m, mx(m), k), vc(m))\n\n t = 0\n for i in range(m):\n t += (vvv[i] * p ** i) % P\n t %= P\n \n ans *= t\n ans %= P\nprint(ans)\n\n"}], "negative_code": [{"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 \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 itertools\nimport random\nimport sys\nfrom atexit import register\nfrom collections import Counter\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\n\ndef 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\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 return not any(_try_composite(a, d, n, s) for a in [2, 3, 5, 7, 11, 13, 17, 19, 23])\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, k = map(int, input().split(' '))\n\n if n == 1:\n print(1)\n return\n\n res = 1\n for p, x in factors(n).items():\n if k == 0:\n res = (res * pow(p, x, 1000000007)) % 1000000007\n else:\n dp = [[1] * (x + 1) for _ in range(k + 1)]\n\n for i in range(1, k + 1):\n if i == 0:\n for j in range(1, x + 1):\n dp[0][j] = (dp[0][j - 1] * p) % 1000000007\n else:\n for j in range(x + 1):\n if j == 0:\n dp[i][j] = dp[i - 1][0]\n else:\n dp[i][j] = (((dp[i][j - 1] * j) + dp[i - 1][j]) *\n pow(j + 1, 1000000005, 1000000007)) % 1000000007\n\n res = (res * dp[k][x]) % 1000000007\n\n print(res)\n return\n\n\nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n"}, {"source_code": "#!/usr/bin/env python\nfrom __future__ import division, print_function\n\nimport sys\nfrom atexit import register\nfrom io import BytesIO\n\n\nsys.stdin = BytesIO(sys.stdin.read())\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\n\nsys.stdout = BytesIO()\nregister(lambda: sys.__stdout__.write(sys.stdout.getvalue()))\n\n\ndef solve(p, q):\n dp = [1]\n for i in range(q):\n dp.append(dp[-1] * p % 1000000007)\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n return (dp[-1] - dp[-2]) % 1000000007\n\n\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nn, k = map(int, input().split())\nans = 1\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 9 == 0:\n c += 1\n n //= 9\n if c:\n ans = ans * solve(2, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n i += 2 if i % 3 == 2 else 4\n\nif n > 1:\n ans = ans * solve(n, 1) % 1000000007\n\nprint(ans)\n"}, {"source_code": "def _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\nn, k = map(int, input().split(' '))\ninv = [pow(i, 1000000005, 1000000007) for i in range(60)]\n\nif n == 1:\n print(1)\n exit()\n\n\ndef solve(p, q):\n dp = [1] * (q + 1)\n for i in range(q):\n dp[i + 1] = (dp[i] * p) % 1000000007\n for i in range(1, q + 1):\n dp[i] = (dp[i] + dp[i - 1]) % 1000000007\n for _ in range(k):\n dp1 = [1] * (q + 1)\n for i in range(1, q + 1):\n dp1[i] = (dp1[i - 1] + dp[i] * inv[i + 1]) % 1000000007\n dp = dp1\n\n return (dp[-1] - dp[-2]) % 1000000007\n\n\nans = solve(n, 1) % 1000000007\n\nif 4 <= n:\n c = 0\n while n % 2 == 0:\n c += 1\n n //= 2\n if c:\n ans = ans * solve(2, c) % 1000000007\n\nif 9 <= n:\n c = 0\n while n % 3 == 0:\n c += 1\n n //= 3\n if c:\n ans = ans * solve(3, c) % 1000000007\n\ni = 5\nwhile i * i <= n:\n c = 0\n while n % i == 0:\n c += 1\n n //= i\n if c:\n ans = ans * solve(i, c) % 1000000007\n if is_prime(n):\n print(ans)\n exit()\n\n i += 2 if i % 3 == 2 else 4\n\nprint(ans)\n"}, {"source_code": "x,k=map(int,input().split())\n#x=60\n#k=5\nif x==1:\n print(1)\n import sys\n sys.exit()\n\nimport math \nL=int(math.sqrt(x))\nmod=10**9+7\nFACT=dict()\n\nfor i in range(2,L+2):\n while x%i==0:\n FACT[i]=FACT.get(i,0)+1\n x=x//i\n\nif x!=1:\n FACT[x]=FACT.get(x,0)+1\n\n\ndef prod(A,B,k,l,m):#A:k*l,B:l*m\n C=[[None for i in range(m)] for j in range(k)]\n\n for i in range(k):\n for j in range(m):\n ANS=0\n for pl in range(l):\n ANS=(ANS+A[i][pl]*B[pl][j])%mod\n\n C[i][j]=ANS\n\n return C\n\ndef plus(A,B,k,l):#a,B:k*l\n C=[[None for i in range(l)] for j in range(k)]\n\n for i in range(k):\n for j in range(l):\n C[i][j]=(A[i][j]+B[i][j])%mod\n\n return C\n \n\n#XX=[[1,1],[1,1],[1,1]]\n#YY=[[2,2,2],[2,3,4]]\n#print(prod(XX,YY,3,2,3))\n\nMAT_index=max(FACT.values())+1\nMAT=[[0 for i in range(MAT_index)] for j in range(MAT_index)]\n\nfor m in range(MAT_index):\n for l in range(m+1):\n x=pow(m+1,mod-2,mod)\n MAT[m][l]=x\n\n#print(MAT)\n\n \n#MAT_ini=MAT\n#for i in range(k-1):\n# MAT=prod(MAT,MAT_ini,MAT_index,MAT_index,MAT_index)\n\n#\u3053\u3053\u3092\u30c0\u30d6\u30ea\u30f3\u30b0\n\nMAT_dob=[None]*13\nMAT_dob[0]=MAT\nfor i in range(1,13):\n MAT_dob[i]=prod(MAT_dob[i-1],MAT_dob[i-1],MAT_index,MAT_index,MAT_index)\n\nMAT=[[0 for i in range(MAT_index)] for j in range(MAT_index)]\nfor i in range(MAT_index):\n MAT[i][i]=1\n\nfor i in range(13):\n if k & 1< k:\n print 'YES'\n break\nelse:\n print 'NO'\n"}, {"source_code": "def main(n, k, s):\n last = {}\n for i in range(n - 1, -1, -1):\n j = ord(s[i]) - ord('A')\n if j not in last:\n last[j] = i\n se = set()\n for i, c in enumerate(list(map(lambda i: ord(i) - ord('A'), s))):\n if c not in se:\n se.add(c)\n if len(se) > k:\n return \"YES\"\n if i == last[c]:\n se.remove(c)\n return \"NO\"\n\nprint(main(*list(map(int, input().split(' '))), input()))\n"}, {"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\nfrom collections import deque\nn,k = tup()\ns =S()\nc = k ; i =0; d = set()\ndi = defaultdict(int)\nfor i in s:\n di[i]+=1\nc =k;gates = set()\nd= deque()\ni =0; f = 1\nwhile i < n:\n if s[i] in gates:\n pass\n else:\n gates.add(s[i])\n if len(gates) >k:\n f =0\n break\n di[s[i]]-=1\n if di[s[i]]==0:\n gates.discard(s[i])\n i+=1\n#op\nif f==0:print(\"YES\")\nelse:print(\"NO\")\n\n\n\n\n\n"}, {"source_code": "from collections import deque\nfrom math import *\nimport heapq\n\n\n# n=int(input())\nn,k=map(int, input().split())\ns=input()\nd={}\ne={}\nfor i in range(len(s)):\n d[s[i]]=i\n e[s[i]]=0\n\ncounter=0\nfor j in range(len(s)):\n # print(j,d[s[j]])\n if d[s[j]]!=j and e[s[j]]==0:\n e[s[j]]=1\n counter+=1\n elif d[s[j]]==j and e[s[j]]==0:\n counter+=1\n if counter>k:\n print(\"YES\")\n exit()\n counter-=1\n elif d[s[j]]==j and e[s[j]]==1:\n counter-=1\n # print(counter)\n if counter>k:\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ns = input()\narr = dict()\narr_ = dict()\nans = 'NO'\nfor i in range(65, 91):\n arr[chr(i)] = 0\n arr_[chr(i)] = 0\nfor i in s:\n arr_[i] += 1\nfor i in s:\n if arr[i] == 0:\n k -= 1\n arr[i] += 1\n if k < 0:\n ans = 'YES'\n if arr[i] == arr_[i]:\n k += 1\nprint(ans)\n"}, {"source_code": "m,n = map(int,raw_input().split())\na = []\npositions = {}\ns = raw_input()\nml = 0\nfor i in range(m):\n\ttry:\n\t\tpositions[s[i]] = [positions[s[i]][0],i]\n\texcept:\n\t\tpositions[s[i]]=[i,i]\n#print(positions)\t\t\na = []\nassing_gard = 0\nmax_a = 0\nfor i in range(m-1):\n\tif s[i] not in a:\n\t\tassing_gard += 1\n\t\t#print(assing_gard)\n\t\tif assing_gard > max_a:\n\t\t\tmax_a = assing_gard\n\t\ta.append(s[i])\n\tif positions[s[i]][1] == i:\n\t\tassing_gard -= 1\n\nif max_a > n:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t"}, {"source_code": "\ndef FindIfGuarded(k, n, s):\n\talphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\tcount1 = {}\n\tcount2 = {}\n\tfor ch in alphabet:\n\t\tcount1[ch] = 0\n\t\tcount2[ch] = 0\n\tfor ch in s:\n\t\tcount1[ch] += 1\n\tNumOfOpenGates = 0\n\tfor ch in s:\n\t\tif count2[ch] == 0:\n\t\t\tif NumOfOpenGates == k:\n\t\t\t\treturn 'Yes'\n\t\t\tNumOfOpenGates += 1\n\t\tif count2[ch] == count1[ch]-1:\n\t\t\tNumOfOpenGates -= 1\n\t\tcount2[ch] += 1\n\treturn 'No'\n\t\t \n\t\t\t\n\n\n\n\nn, k = map(int, raw_input().split(' '))\ns = raw_input()\n\nprint (FindIfGuarded(k, n, s))\n"}, {"source_code": "from string import ascii_uppercase as let\nimport sys\n\n\ndef main():\n n, k = map(int, input().split())\n l = input()\n a = [0 for i in range(26)]\n for i in l:\n a[let.index(i)] += 1\n fk = k\n od = set()\n for i in l:\n if i not in od:\n fk -= 1\n if fk < 0:\n print('YES')\n sys.exit()\n od.add(i)\n a[let.index(i)] -= 1\n if a[let.index(i)] == 0:\n od.remove(i)\n fk += 1\n print('NO')\nmain()"}, {"source_code": "from math import inf,sqrt,floor,ceil\nfrom collections import Counter,defaultdict,deque\nfrom heapq import heappush as hpush,heappop as hpop,heapify as h\nfrom operator import itemgetter\nfrom itertools import product\nfrom bisect import bisect_left,bisect_right\n\nn,k=map(int,input().split( ))\ns=input()\nlast=Counter()\nfor i in range(n):\n last[s[i]]=i\nfirst=set()\nans=\"NO\"\nfor i in range(n):\n if s[i] not in first:\n first.add(s[i])\n if len(first)>k:\n ans=\"YES\"\n break\n if last[s[i]]==i:\n first.discard(s[i])\nprint(ans)\n"}, {"source_code": "import os\nfrom io import BytesIO\n\n\ndef main():\n input = BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n n, k = map(int, input().split())\n g = [x - 65 for x in input()]\n\n e = [-1] * 26\n\n for i in range(n):\n e[g[i]] = i\n curS = 0\n\n met = [0] * 26\n for i in range(n):\n if not met[g[i]]:\n curS += 1\n met[g[i]] = 1\n if curS > k:\n print('YES')\n return\n if i == e[g[i]]:\n curS -= 1\n\n print('NO')\n\n\nmain()\n"}, {"source_code": "from collections import Counter\n\ndef main():\n n, k = map(int, input().split())\n s = input()\n\n ocnt = Counter(s)\n cnt = ocnt.copy()\n \n i = 0\n for e in s:\n if cnt[e] == ocnt[e]:\n i += 1\n if i > k:\n print('YES')\n return\n\n cnt[e] -= 1\n if cnt[e] == 0:\n i -= 1\n\n print('NO')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "m,n = map(int,raw_input().split())\na = []\npositions = {}\ns = raw_input()\nml = 0\nfor i in range(m):\n\ttry:\n\t\tpositions[s[i]] = [positions[s[i]][0],i]\n\texcept:\n\t\tpositions[s[i]]=[i,i]\n#print(positions)\t\t\na = []\nassing_gard = 0\nmax_a = 0\nfor i in range(m-1):\n\tif s[i] not in a:\n\t\tassing_gard += 1\n\t\t#print(assing_gard)\n\t\tif assing_gard > max_a:\n\t\t\tmax_a = assing_gard\n\t\ta.append(s[i])\n\tif positions[s[i]][1] == i:\n\t\tassing_gard -= 1\n\nif max_a > n:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t"}, {"source_code": "n,k=map(int,raw_input().split())\ne=raw_input()\na=[[-1,-1] for i in xrange(26)]\nfor i in xrange(n):\n\tif a[ord(e[i])-ord('A')][0]==-1:\n\t\ta[ord(e[i])-ord('A')][0]=i\n\t\ta[ord(e[i])-ord('A')][1]=i\n\telse:\n\t\ta[ord(e[i])-ord('A')][1]=i\n#print a\nz=[0]*n\nz1=[0]*n\n#print z\nfor i in xrange(26):\n\n\tif a[i][0]!=-1:\n\t\t#print a[i][0],a[i][1]\n\t\tz[a[i][0]]=1\n\t\tz1[a[i][1]]=-1\n#print z\nzz=0\npos=1\nfor i in xrange(n):\n\tzz+=z[i]\n\tif zz>k:\n\t\tpos=0\n\tzz+=z1[i]\nif pos==0:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "n,k = map(int,raw_input().split())\ns = raw_input()\nguests = {}\nwe_gooch = True\nfor letter in s:\n if letter not in guests:\n guests[letter] = 1\n else:\n guests[letter] += 1\nunique_doors = set()\nfor letter in s:\n unique_doors.add(letter)\n if len(unique_doors) > k:\n we_gooch = False\n guests[letter]-=1\n if guests[letter] == 0:\n unique_doors.remove(letter)\nif we_gooch:\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "n,k = map(int,input().split())\ndata = input()\nd = {}\nc = {}\nfor i in data:\n if i not in c:\n c[i]=1\n else:\n c[i]+=1\ncount = 0\nm = 0\n#print(c)\nfor i in data:\n #print(m,d,count)\n if i not in d: \n count+=1\n d[i]=1\n m = max(m, count)\n if d[i]==c[i]:\n del d[i]\n count-=1 \n else:\n d[i]+=1\n if d[i]==c[i]:\n del d[i]\n count-=1\nif m<=k :\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(input())\nd={}\nfor i in range(n):\n d[l[i]]=[0,i]\nac=0\nfor i in range(n):\n if d[l[i]][0]==0:\n ac+=1\n d[l[i]][0]=1\n if ac>k:\n print(\"YES\")\n break\n if d[l[i]][1]==i:\n ac-=1\nelse: print(\"NO\")"}, {"source_code": "n,k = [int(i) for i in input().strip().split()]\ng_l = input().strip()\n\nclosing_i = dict()\nis_closing = [False for i in range(n)]\nfor i in range(n):\n\ti = n-i-1\n\tif g_l[i] not in closing_i:\n\t\tclosing_i[g_l[i]] = i\n\t\tis_closing[i] = True\nopen_d = dict()\ncur_open = 0\ng_open = 0\nfor i in range(n):\n\tif g_l[i] not in open_d:\n\t\topen_d[g_l[i]] = True\n\t\tcur_open += 1\n\t\tg_open = max(cur_open,g_open)\n\tif is_closing[i]:\n\t\tcur_open -= 1\nif g_open > k: print('YES')\nelse: print('NO')\n"}, {"source_code": "\nn,k = [int(_) for _ in raw_input().strip().split()]\ns = raw_input().strip()\nl = set()\na = [0]*n\nfor i,_ in enumerate(s):\n\tif _ not in l:\n\t\ta[i] = 1\n\t\tl.add(_)\n\nl = set()\nb = [0]*n\nfor i in range(n-1,-1,-1):\n\tif s[i] not in l:\n\t\tb[i]+=1\n\t\tl.add(s[i])\nsk = 0\nfound = False\nfor i in range(n):\n\tsk=sk+a[i]\n\tif sk>k:\n\t\tfound = True\n\t\tbreak\n\tsk=sk-b[i]\nprint 'YES' if found else 'NO'\n\n\n\n"}, {"source_code": "n, k = map(int, input().split())\ns = list(input())\n\nletters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nquards = {letters[i]: 0 for i in range(26)}\n\nfor i in range(n):\n quards[s[i]] += 1\n\nd = []\nfor key, value in quards.items():\n if not value:\n d.append(key)\nfor key in d:\n del quards[key]\n\nready = k\nnow = []\nflag = True\nfor man in s:\n # print(man, now, ready)\n if man not in now:\n if ready:\n ready -= 1\n now.append(man)\n else:\n print('YES')\n flag = False\n break\n quards[man] -= 1\n if not quards[man]:\n ready += 1\n now.remove(man)\n # print(quards, ready, now)\n # print()\nif flag:\n print('NO')\n"}, {"source_code": "n,k=(int(i )for i in input().split())\ns=input()\na=[0]*n\nb=[]\nx=k\ny=0\nalf='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\nend=[s.rfind(i) for i in alf]\nbegin=[s.find(i) for i in alf]\n\nf=False\nans=False\nfor i in range(n):\n find=alf.find(s[i])\n if ((i!=end[find]) and not(s[i] in b)) or ((begin[find]==end[find])):\n b.append(s[i])\n x-=1;\n elif (i==end[find]) and (i!=begin[find]):\n x+=1\n if x<0:\n ans=True\n break\n if begin[find]==end[find]:\n x+=1\nprint('YES' if ans else 'NO')\n"}, {"source_code": "arr = list(map(int,input().split()))\ntotal_g = arr[0]\nguards = arr[1]\nclose_gate = dict()\nentry = input()\nchanges = 0\n\nfor i in range(0,total_g):\n if entry[i] in close_gate:\n close_gate[entry[i]] = close_gate[entry[i]] + 1\n else:\n close_gate[entry[i]] = 1\n\ncnt_gate = dict()\navg = guards\nflag = 0\n\nfor i in range(0,total_g):\n # print(entry[i])\n if entry[i] not in cnt_gate:\n if avg==0 and i!=0 and cnt_gate[entry[i-1]] != close_gate[entry[i-1]]:\n print('YES')\n flag = 1 \n break\n \n # print(\"new gate opened\")\n cnt_gate[entry[i]] = 1 \n avg = avg -1\n # print(cnt_gate[entry[i]],close_gate[entry[i]])\n # print('guards available',avg)\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n avg = avg + 1 \n \n else :\n cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1 \n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n # print('gate was',entry[i], 'closed')\n avg = avg + 1 \n \nif flag == 0:\n print('NO')\n \n\n\n \n \n\n \n\n \n \n \n \n "}, {"source_code": "# -*- coding: utf-8 -*-\n# from __future__ import division\nimport sys\n\nn, k = [int(x) for x in sys.stdin.readline().split()]\ns = sys.stdin.readline().strip()\n\nA = ord('A')\nfirst = [None] * 26\nlast = [None] * 26\n\nletter_nums = [(ord(c) - A) for c in s]\n\nfor i in range(n):\n\tif first[letter_nums[i]] is None:\n\t\tfirst[letter_nums[i]] = i\n\tlast[letter_nums[i]] = i\n\ncur_n_segments = 0\ngood = True\n\nfor i in range(n):\n\tif first[letter_nums[i]] == i:\n\t\tcur_n_segments += 1\n\t\tif cur_n_segments > k:\n\t\t\tprint 'YES'\n\t\t\tgood = False\n\t\t\tbreak\n\tif last[letter_nums[i]] == i:\n\t\tcur_n_segments -= 1\nif good:\n\tprint 'NO'"}, {"source_code": "from sys import stdin, stdout\nimport string\n\nn,k = map(int,stdin.readline().rstrip().split())\ns = list(stdin.readline().rstrip())\n\ndoorOpen = {}\ndoorClosed = {}\n\nfor i in range(n):\n if s[i] not in doorOpen.keys():\n doorOpen[s[i]] = i\n\nfor i in range(n-1,-1,-1):\n if s[i] not in doorClosed.keys():\n doorClosed[s[i]] = i\n\nevents = [(x,'o') for x in doorOpen.values()] + [(x,'x') for x in doorClosed.values()]\n\nevents.sort(key=lambda x: x[1])\nevents.sort(key = lambda x:x[0])\n\n\nopened = 0\nunguarded = False\nfor i in range(len(events)):\n if events[i][1]=='o':\n opened+=1\n else:\n opened-=1\n if opened>k:\n unguarded = True\n break\n\nif unguarded:\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "gates={}\nstate_gates={}\n\ndef main(n,l,gates,state_gates,guards): #str,str int\n for i in range(n):\n gate=l[i]\n if state_gates[gate]!=True:\n if guards>0:\n state_gates[gate]=True\n guards-=1\n else:\n return \"YES\"\n \n if gates[gate][1]==i:\n state_gates[gate]=False\n guards+=1\n else:return \"NO\"\n\ng=raw_input().split()\nguards=int(g[1])\nl=raw_input()\nn=int(g[0])\nfor i in range(n):\n if gates.has_key(l[i]):gates[l[i]][1]=i\n else:gates[l[i]]=[i,i]\n \n state_gates[l[i]]=False #True=open False=close\n\nprint main(n,l,gates,state_gates,guards)"}, {"source_code": "def main(n, k, s):\n last = {}\n for i in range(n - 1, -1, -1):\n j = ord(s[i]) - ord('A')\n if j not in last:\n last[j] = i\n se = set()\n for i, c in enumerate(list(map(lambda i: ord(i) - ord('A'), s))):\n if c not in se:\n se.add(c)\n if len(se) > k:\n return \"YES\"\n if i == last[c]:\n se.remove(c)\n return \"NO\"\n\nprint(main(*list(map(int, input().split(' '))), input()))\n"}, {"source_code": "from collections import Counter\n\ndef main():\n n, k = map(int, input().split())\n s = input()\n\n ocnt = Counter(s)\n cnt = ocnt.copy()\n \n i = 0\n for e in s:\n if cnt[e] == ocnt[e]:\n i += 1\n if i > k:\n print('YES')\n return\n\n cnt[e] -= 1\n if cnt[e] == 0:\n i -= 1\n\n print('NO')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = True\nmet = [False] * 91\nfor i in range(n):\n if not met[g[i]]:\n curS += 1\n met[g[i]] = True\n if curS > k:\n f = False\n break\n if i == e[g[i]]:\n curS -= 1\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "l = input().split()\n\nn = int(l[0])\nk = int(l[1])\n\ns = input()\n\nlens = len(s)\n\nfirst = []\nfn = []\nlast = []\nln = []\n\nfor i in range(lens):\n if s[i] not in first:\n first.append(s[i])\n fn.append(i)\n if s[lens - i - 1] not in last:\n last.append(s[lens - i - 1])\n ln.append(lens - i - 1)\nln.sort()\nmore = False\nd = 0\nad = None\nrm = None\nwhile not more:\n if ad == None: \n if len(fn)==0: break\n ad = fn.pop(0)\n if rm == None: rm = ln.pop(0)\n if ad < rm:\n d+=1\n ad = None\n elif ad > rm:\n d-=1\n rm = None\n else:\n ad=None\n rm=None\n if d+1 > k:\n more = True\n\n if d > k:\n more = True\n\nif more:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "from sys import stdin\n\nn, k = map(int, stdin.readline().rstrip().split())\ndata = stdin.readline().rstrip()\n\ndoors = {}\nfor c in data:\n if c in doors:\n doors[c] += 1\n else:\n doors[c] = 1\n\nopening_doors_count = 0\nopened_doors = {}\n\nfor c in data:\n if c not in opened_doors:\n opened_doors[c] = True\n opening_doors_count += 1\n\n if opening_doors_count > k:\n print('YES')\n exit()\n\n doors[c] -= 1\n\n if doors[c] == 0:\n opening_doors_count -= 1\n opened_doors[c] = False\n\nprint('NO')\n"}, {"source_code": "from collections import defaultdict as dd\n\na,k=[int(i) for i in input().split()]\nb=input()\nal=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\ncome=[0]*(26)\nout=[0]*(26)\nfor i in range(a):\n if come[al.index(b[i])]==0:\n come[al.index(b[i])]=i+1\n out[al.index(b[i])]=i+1\n else:\n out[al.index(b[i])]=i+1\ncm=[]\nfor i in range(26):\n if come[i]!=0 and out[i]!=0:\n cm.append((come[i],1))\n cm.append((out[i],2))\ncm.sort()\nma=0\nans=0\nfor i in cm:\n if i[1]==1:\n ma+=1\n else:\n ma-=1\n ans=max(ma,ans)\nif (k>=ans):\n print(\"NO\")\nelse:\n print(\"YES\")\n \n\n"}, {"source_code": "n, k = map(int, input().split())\ndoors = input()\n\nlo = [-1] * 26\n\nfor i in range(len(doors)):\n cc = ord(doors[i]) - ord('A')\n lo[cc] = i\n\nopened = set()\n\nexceeded = False\n\nfor i in range(len(doors)):\n cc = ord(doors[i]) - ord('A')\n opened.add(cc)\n\n if len(opened) > k:\n exceeded = True\n break\n\n if i == lo[cc]:\n opened.remove(cc)\n\nprint(\"YES\" if exceeded else \"NO\")\n"}, {"source_code": "n, k = map(int, input().split())\nentrances = input()\nd = {}\ns = set()\nfor i in range(n): d[entrances[i]] = i\n\nfor i in range(n):\n s.add(entrances[i])\n if len(s)>k:\n print(\"YES\")\n break\n if d[entrances[i]]==i:\n s.remove(entrances[i])\nelse:\n print(\"NO\")\n"}, {"source_code": "n,k=map(int,input().split())\ns=list(map(lambda x: ord(x)-ord('A'),input()))\nc=[0]*26\no=[0]*26\nfor i in range(n):c[s[i]]+=1\nfor i in range(n):\n x=s[i]\n if o[x]==0:\n if k==0:print('YES');exit()\n k-=1\n o[x]=1\n c[x]-=1\n if c[x]==0:\n o[x]=0\n k+=1\nprint('NO')"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [None] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [None] * 91\nfor i in range(n):\n if met[g[i]]:\n if i == e[g[i]]:\n curS -= 1\n continue\n if i == e[g[i]]:\n if curS + 1 > k:\n f = 0\n break\n continue\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "n,k=map(int,str(raw_input()).split())\ns=str(raw_input())\nd={}\nfor i in range(65,91):\n d[chr(i)]=[0,0]\nfor i in range(n):\n if d[s[i]][0]==0:\n d[s[i]][0]=i+1\n else:\n d[s[i]][1]=i+1\nfor i in d:\n if d[i][0]!=0 and d[i][1]==0:\n d[i][1]=d[i][0]\nopen=0\nflag=1\nfor i in range(n):\n if d[s[i]][0]==i+1:\n open+=1\n if open>k:\n flag=0\n if d[s[i]][1]==i+1:\n open-=1\n if open>k:\n flag=0\n #print d[s[i]][1],i+1\n #print open\n \nif flag:\n print \"NO\"\nelse:\n print \"YES\"\n \n#print d"}, {"source_code": "R = lambda:map(int,raw_input().split())\n\nn,k = R()\ns = raw_input()\nnetk= k\ncarr= 26*[0]\nass = 26*[False]\n\nfor i in xrange(n):\n carr[ord(s[i])-ord('A')]+=1\n\nfor i in xrange(n):\n c = ord(s[i])-ord('A')\n carr[c]-=1\n if not ass[c]:\n\tass[c]=True\n\tnetk-=1\n if netk < 0:\n\tprint \"YES\"\n\texit(0)\n if ass[c] and carr[c]==0:\n\tnetk+=1\nprint \"NO\"\n"}, {"source_code": "# cook your dish here\n\nn,k=map(int,input().split())\nst=input()\ns=set(st)\nans=0\nd=[0]*n\nfor i in s:\n for j in range(st.find(i),st.rfind(i)+1):\n d[j]+=1 \n\nif(max(d)>k):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ng = input().encode()\n\ne = [-1] * 26\n\nfor i in range(n):\n e[g[i] - 65] = i\ncurS = 0\nf = 1\nmet = [0] * 26\nfor i in range(n):\n if not met[g[i] - 65]:\n curS += 1\n met[g[i] - 65] = 1\n if curS > k:\n f = 0\n break\n if i == e[g[i] - 65]:\n curS -= 1\n\nprint('NO' if f else 'YES')"}, {"source_code": "\nn,k = [int(_) for _ in raw_input().strip().split()]\ns = raw_input().strip()\nl = set()\na = [0]*n\nfor i,_ in enumerate(s):\n\tif _ not in l:\n\t\ta[i] = 1\n\t\tl.add(_)\n\nl = set()\nb = [0]*n\nfor i in range(n-1,-1,-1):\n\tif s[i] not in l:\n\t\tb[i]+=1\n\t\tl.add(s[i])\nsk = 0\nfound = False\nfor i in range(n):\n\tsk=sk+a[i]\n\tif sk>k:\n\t\tfound = True\n\t\tbreak\n\tsk=sk-b[i]\nprint 'YES' if found else 'NO'\n\n\n\n"}, {"source_code": "n,k = [int(_) for _ in raw_input().strip().split()]\nstring = raw_input().strip()\ndau = [1000010]*260\ncuoi = [-1]*260\nresult = [0]*(n+20)\n\nA = ord('A')\nfor i in range(n):\n position = ord(string[i])\n dau[position] = min(dau[position],i)\n cuoi[position] = i\nfor i in range(26):\n if cuoi[i+A] != -1:\n result[dau[i+A]] += 1\n result[cuoi[i+A]+1] -= 1\nfor i in range(1,n):\n result[i] = result[i-1]+result[i]\nvalue = max(result)\nif value > k:\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "n, k = map(int, input().split())\ng = input()\n\ne = [-1] * 91\n\nfor i in range(n):\n e[ord(g[i])] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if not met[ord(g[i])]:\n curS += 1\n met[ord(g[i])] = 1\n if curS > k:\n f = 0\n break\n if i == e[ord(g[i])]:\n curS -= 1\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "l = input().split()\n\nn = int(l[0])\nk = int(l[1])\n\ns = input()\n\nlens = len(s)\n\nfirst = []\nfn = []\nlast = []\nln = []\n\nfor i in range(lens):\n if s[i] not in first:\n first.append(s[i])\n fn.append(i)\n if s[lens - i - 1] not in last:\n last.append(s[lens - i - 1])\n ln.append(lens - i - 1)\nln.sort()\nmore = False\nd = 0\nad = None\nrm = None\nwhile not more:\n if ad == None: \n if len(fn)==0: break\n ad = fn.pop(0)\n if rm == None: rm = ln.pop(0)\n if ad < rm:\n d+=1\n ad = None\n elif ad > rm:\n d-=1\n rm = None\n else:\n ad=None\n rm=None\n if d+1 > k:\n more = True\n\n if d > k:\n more = True\n\nif more:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n\"\"\" Interval intersection \"\"\"\n\ndef main():\n n, k = map(int, input().split())\n guests = input().rstrip()\n guestbook = {}\n for idx, guest in enumerate(guests):\n if guest not in guestbook:\n guestbook[guest] = (idx, idx)\n else:\n val = guestbook[guest]\n guestbook[guest] = (val[0], idx)\n\n timeline = [0]*n\n for timings in guestbook.values():\n for idx in range(timings[0], timings[1]+1):\n timeline[idx] += 1\n\n print(\"YES\") if max(timeline) > k else print(\"NO\")\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n, k = map(int, input().split())\ns = str(input())\nm = {}\nz = set()\n\nfor i, t in enumerate(s):\n\tm[t] = i\n\nfor i, t in enumerate(s):\n\tif m[t] != i:\n\t\tz.add(t)\n\t\tif len(z) > k:\n\t\t\tprint('YES')\n\t\t\texit()\n\telse:\n\t\tif t in z:\n\t\t\tz.remove(t)\n\t\telif len(z) + 1 > k:\n\t\t\tprint('YES')\n\t\t\texit()\n\nprint('NO')"}, {"source_code": "n,k=map(int,raw_input().split())\nalpha=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')\n\nmax_dict={}\nguarded={}\ncurrent_dict={}\nfor i in alpha:\n max_dict[i]=0\n guarded[i] = 0\n current_dict[i] = 0\nguests=list(raw_input())\nfor i in guests:\n max_dict[i]+=1\n\n\n\nis_true=True\nsum=0\n\nfor guest in guests:\n\n\n current_dict[guest]+=1\n if current_dict[guest]==1:\n\n sum+=1\n\n\n\n if sum>k:\n is_true=False\n print 'YES'\n break\n\n if current_dict[guest]==max_dict[guest]:\n sum-=1\n\n\n\nif is_true==True:\n print 'NO'\n\n\n\n\n"}, {"source_code": "n,k = map(int, raw_input().split())\na = list(raw_input())\nalp = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nm = {}\ngiven = {}\nfor i in alp:\n\tm[i] = -1\n\tgiven[i] = 0\nfor i in range(len(a)-1,-1,-1):\n\tif(m[a[i]]==-1):\n\t\tm[a[i]] = i\ngates = 0\nguards = k-1\ngiven[a[0]] = 1\n\nfor i in range(0,len(a)):\n\tif(given[a[i]]):\n\t\tpass\n\telse:\n\t\tgiven[a[i]]=1\n\t\tguards-=1\n\tif(guards<0):\n\t\tgates+=1\n\t\tbreak\n\tif(m[a[i]]==i):\n\t\tguards+=1\nif(gates==1):\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "n,k=map(int,input().split())\ns=list(map(lambda x: ord(x)-ord('A'),input()))\nc=[0]*26\no=[0]*26\nfor i in range(n):c[s[i]]+=1\nfor i in range(n):\n x=s[i]\n if o[x]==0:\n if k==0:print('YES');exit()\n k-=1\n o[x]=1\n c[x]-=1\n if c[x]==0:\n o[x]=0\n k+=1\nprint('NO')"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nd = {}\nop = set()\nfor i in range(len(s)):\n d[s[i]] = i\nans = 0\ndoors = 0\nfor i in range(len(s)):\n if s[i] not in op:\n doors += 1\n op.add(s[i])\n ans = max(ans, doors)\n if i == d[s[i]]:\n doors -= 1\nprint(('YES','NO')[ans <= k])\n"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nmx=dict()\nfor x in range(n):\n mx[s[x]]=x\ncur=0\nans=0\nc={x.upper():0 for x in 'qwertyuiopasdfghjklzxcvbnm'}\nfor x in range(n):\n if c[s[x]]==0:\n cur+=1\n c[s[x]]=1\n \n if cur > k:\n ans=1\n #print(cur,x,s[x])\n if mx[s[x]]==x:\n cur-=1\n c[s[x]]=0\nprint('NO' if not ans else 'YES')"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if met[g[i]]:\n if i == e[g[i]]:\n curS -= 1\n continue\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n if i == e[g[i]]:\n curS -= 1\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "n,k=map(int,raw_input().split())\ninp=raw_input()\n\nends={chr(i):-1 for i in range(65,91)}\nopened={chr(i):0 for i in range(65,91)}\nopened_gates=0\nans=0\nfor i in range(n-1,-1,-1):\n if ends[inp[i]]==-1:\n ends[inp[i]]=i\n\nfor i in range(n):\n if not opened[inp[i]]:\n opened[inp[i]]=1\n opened_gates+=1\n ans=max(ans,opened_gates)\n\n if ends[inp[i]]==i:\n opened[inp[i]]=0\n opened_gates-=1\n ans=max(ans,opened_gates)\n\nif ans>k:\n print \"YES\"\n\nelse:\n print \"NO\" \n"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nflag=False\nlast_pos={}\ngate=set()\nfor i in range(len(s)):\n last_pos[s[i]]=i\n#print(last_pos)\nfor i in range(len(s)):\n gate.add(s[i])\n if len(gate)>k:\n flag=True\n break\n if last_pos[s[i]]==i:\n gate.remove(s[i])\nif flag:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "import io, os\ndef main():\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n n, k = map(int, input().split())\n g, e = [x - 65 for x in input()], [-1] * 26\n for i in range(n): e[g[i]] = i\n curS, met = 0, [0] * 26\n for i in range(n):\n if not met[g[i]]: curS += 1; met[g[i]] = 1\n if curS > k: os.write(1, b'YES'); exit()\n if i == e[g[i]]: curS -= 1\n os.write(1, b'NO')\nmain()\n"}, {"source_code": "arr = list(map(int,input().split()))\ntotal_g = arr[0]\nguards = arr[1]\nclose_gate = dict()\nentry = input()\nchanges = 0\n\nfor i in range(0,total_g):\n if entry[i] in close_gate:\n close_gate[entry[i]] = close_gate[entry[i]] + 1\n else:\n close_gate[entry[i]] = 1\n\ncnt_gate = dict()\navg = guards\nflag = 0\n\nfor i in range(0,total_g):\n # print(entry[i])\n if entry[i] not in cnt_gate:\n if avg==0 and i!=0 and cnt_gate[entry[i-1]] != close_gate[entry[i-1]]:\n print('YES')\n flag = 1 \n break\n \n # print(\"new gate opened\")\n cnt_gate[entry[i]] = 1 \n avg = avg -1\n # print(cnt_gate[entry[i]],close_gate[entry[i]])\n # print('guards available',avg)\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n avg = avg + 1 \n \n else :\n cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1 \n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n # print('gate was',entry[i], 'closed')\n avg = avg + 1 \n \nif flag == 0:\n print('NO')\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\n\n\nclass FastI(BytesIO):\n newlines = 0\n\n def __init__(self, fd=0, bufsize=8192):\n self.fd = fd\n self.bufsize = bufsize\n self.read = lambda: super(FastI, self).read() if self.newlines 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, self.bufsize)), self.tell()\n self.seek(0, 2), self.write(b), self.seek(ptr)\n self.newlines += b.count(b'\\n') + (not b)\n\n self.newlines -= 1\n return super(FastI, self).readline()\n\n\nclass FastO(IOBase):\n def __init__(self, fd=1):\n stream = BytesIO()\n self.flush = lambda: os.write(fd, stream.getvalue()) and not stream.truncate(0) and stream.seek(0)\n self.write = stream.write if sys.version_info[0] < 3 else lambda b: stream.write(b.encode())\n\n\nclass ostream:\n def __lshift__(self, a):\n if a == endl:\n sys.stdout.write('\\n')\n sys.stdout.flush()\n else:\n sys.stdout.write(str(a))\n return self\n\n\nsys.stdin, sys.stdout = FastI(), FastO()\ncout, endl = ostream(), object()\n\ninput = sys.stdin.readline\n\n\ndef main():\n n, k = map(int, input().split())\n s = input().rstrip(b'\\r\\n')\n\n o, c = [-1] * 26, [-1] * 26\n for i in range(n):\n if o[s[i] - 65] == -1:\n o[s[i] - 65] = i\n c[s[i] - 65] = i\n\n j = 0\n for i in range(n):\n if o[s[i] - 65] == i:\n j += 1\n if j > k:\n print('YES')\n return\n if c[s[i] - 65] == i:\n j -= 1\n\n print('NO')\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, k = map(int, input().split())\nG = input()\ng = [0] * n\n\ne = [-1] * 91\n\nfor i in range(n):\n g[i] = ord(G[i])\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if not met[g[i]]:\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n if i == e[g[i]]:\n curS -= 1\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "R=raw_input\nn,m=map(int,R().split())\ns=R()\nv=[0]*(n+1)\nfor x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':\n if x in s:\n v[s.index(x)]+=1\n v[s.rindex(x)+1]-=1\nh=0\nfor i in xrange(n):\n h+=v[i]\n if h>m:\n print 'YES'\n break\nelse:\n print 'NO'"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nflag=False\nlast_pos={}\ngate=set()\nfor i in range(len(s)):\n last_pos[s[i]]=i\n#print(last_pos)\nfor i in range(len(s)):\n gate.add(s[i])\n if len(gate)>k:\n flag=True\n break\n if last_pos[s[i]]==i:\n gate.remove(s[i])\nif flag:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n,k = map(int,input().split())\nll = input()\nd = {}\nfor i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':\n d[i] = 0\nfor i in ll:\n d[i] += 1\nlll = {}\nt = True\nfor i in ll:\n if i not in lll:\n lll[i] = 1\n d[i] -= 1\n if len(lll) > k:\n print('YES')\n t = False\n break\n if d[i] == 0:\n del lll[i]\nif t == True:\n print('NO')\n"}, {"source_code": "#!/usr/bin/python3\n\ndef main():\n n, g = [int(x) for x in input().split()]\n data = input()\n dats = set(data)\n \n if (len(dats) <= g): return \"NO\"\n\n inicio = []\n final = []\n\n for val in dats:\n inicio.append(data.index(val))\n\n dfls = list(dats)\n for end in range(n-1, -1, -1):\n if data[end] in dfls:\n final.append(end)\n dfls.remove(data[end])\n if (not len(dfls)): break\n \n\n inicio.sort()\n final.sort()\n\n total = 0\n i, f = 0, 0\n\n while (i < len(inicio)):\n if (inicio[i] <= final[f]):\n total += 1\n i += 1\n else:\n total -= 1\n f += 1\n\n if (total > g): return \"YES\"\n \n return \"NO\"\n\n\nif __name__ == \"__main__\": print(main())\n\n"}, {"source_code": "guards_needed =0\nflag=False\ninp = raw_input().split()\nn= int(inp[0])\nk=int(inp[1])\nstri=list(raw_input())\nlist1=[]\nlist2=[]\nfor i in range(26):\n list1.append(0)\nfor i in range(26):\n list2.append(False)\nfor char in stri:\n pos = ord(char)-65\n list1[pos]=list1[pos]+1\nfor char in stri:\n pos1=ord(char)-65\n if list2[pos1]==False:\n list2[pos1]=True\n guards_needed=guards_needed+1\n if guards_needed > k:\n flag = True\n break\n list1[pos1]=list1[pos1]-1 \n if list1[pos1]==0:\n guards_needed=guards_needed-1\nif flag==True:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "from collections import defaultdict as dd\n\na,k=[int(i) for i in input().split()]\nb=input()\nal=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\ncome=[0]*(26)\nout=[0]*(26)\nfor i in range(a):\n if come[al.index(b[i])]==0:\n come[al.index(b[i])]=i+1\n out[al.index(b[i])]=i+1\n else:\n out[al.index(b[i])]=i+1\ncm=[]\nfor i in range(26):\n if come[i]!=0 and out[i]!=0:\n cm.append((come[i],1))\n cm.append((out[i],2))\ncm.sort()\nma=0\nans=0\nfor i in cm:\n if i[1]==1:\n ma+=1\n else:\n ma-=1\n ans=max(ma,ans)\nif (k>=ans):\n print(\"NO\")\nelse:\n print(\"YES\")\n \n\n"}, {"source_code": "n, k = map(int, input().split())\ndoors = input()\n\nlo = [-1] * 26\n\nfor i in range(len(doors)):\n cc = ord(doors[i]) - ord('A')\n lo[cc] = i\n\nopened = set()\n\nexceeded = False\n\nfor i in range(len(doors)):\n cc = ord(doors[i]) - ord('A')\n opened.add(cc)\n\n if len(opened) > k:\n exceeded = True\n break\n\n if i == lo[cc]:\n opened.remove(cc)\n\nprint(\"YES\" if exceeded else \"NO\")\n"}, {"source_code": "n,k=map(int,input().split())\nl=list(input())\nd={}\nfor i in range(n):\n d[l[i]]=[0,i]\nac=0\nfor i in range(n):\n if d[l[i]][0]==0:\n ac+=1\n d[l[i]][0]=1\n if ac>k:\n print(\"YES\")\n break\n if d[l[i]][1]==i:\n ac-=1\nelse: print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nd = {}\nop = set()\nfor i in range(len(s)):\n d[s[i]] = i\nans = 0\ndoors = 0\nfor i in range(len(s)):\n if s[i] not in op:\n doors += 1\n op.add(s[i])\n ans = max(ans, doors)\n if i == d[s[i]]:\n doors -= 1\nprint(('YES','NO')[ans <= k])\n"}, {"source_code": "import sys\nnums = list(map(int, sys.stdin.readline().split()))\ne = list(map(str, sys.stdin.readline().rstrip(\"\\n\")))\n\nk = nums[1]\nc = [0] * 26\n\nfor x in range(len(e)):\n c[ord(e[x]) - 65] += 1\n\nsec = [0]*len(c)\ni = 0\ncount = 0\n\nwhile i < len(e):\n if sec[ord(e[i])-65] == 0:\n count += 1\n sec[ord(e[i])-65] = 1\n if count > k:\n print(\"YES\")\n exit(0)\n c[ord(e[i])-65] -= 1\n if c[ord(e[i])-65] == 0:\n sec[ord(e[i])-65] = 0\n count -= 1\n i += 1\n\nprint(\"NO\")"}, {"source_code": "from collections import Counter\n\nif __name__ == '__main__':\n n, k = list(map(int, input().split()))\n q = input()\n\n last_index, first_index = {}, {}\n for i, s in enumerate(q):\n last_index[s] = i\n first_index[s] = min(first_index.get(s, 10**6 +5), i)\n\n opened_count = 0\n for i, d in enumerate(q):\n if i == first_index[d]:\n opened_count += 1\n if opened_count > k:\n print('YES')\n exit(0)\n if i == last_index[d]:\n opened_count -= 1\n \n print('NO')"}, {"source_code": "n,k=input().split()\nn=int(n)\nk=int(k)\nl=input()\nd={}\nfor val in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':\n\td[val]=0\nfor val in l:\n\td[val]+=1\nopened={}\nflag=0\nfor val in l:\n\tif(val not in opened):\n\t\topened[val]=1\n\td[val]-=1\n\tif(len(opened)>k):\n\t\tflag=1\n\t\tbreak\n\tif(d[val]==0):\n\t\tdel(opened[val])\nif(flag==0):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "import io, os\ndef main():\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n n, k = map(int, input().split())\n g, e = [x - 65 for x in input()], [-1] * 26\n for i in range(n): e[g[i]] = i\n curS, met = 0, [0] * 26\n for i in range(n):\n if not met[g[i]]: curS += 1; met[g[i]] = 1\n if curS > k: os.write(1, b'YES'); exit()\n if i == e[g[i]]: curS -= 1\n os.write(1, b'NO')\nmain()\n"}, {"source_code": "n,k=map(int,raw_input().split())\ninp=raw_input()\n\nends={chr(i):-1 for i in range(65,91)}\nopened={chr(i):0 for i in range(65,91)}\nopened_gates=0\nans=0\nfor i in range(n-1,-1,-1):\n if ends[inp[i]]==-1:\n ends[inp[i]]=i\n\nfor i in range(n):\n if not opened[inp[i]]:\n opened[inp[i]]=1\n opened_gates+=1\n ans=max(ans,opened_gates)\n\n if ends[inp[i]]==i:\n opened[inp[i]]=0\n opened_gates-=1\n ans=max(ans,opened_gates)\n\nif ans>k:\n print \"YES\"\n\nelse:\n print \"NO\" \n"}, {"source_code": "import sys\na=[]\n\nfor x in raw_input().split():\n a.append(int(x))\n\nn=a[0]\nk=a[1]\npos=[0]*300\n\ns=raw_input();\nfor i in range(len(s)):\n pos[ord(s[i])]=i\n\nans=\"NO\"\nsize=0\nmp={}\nfor i in range(len(s)):\n if(mp.has_key(s[i])):\n if(pos[ord(s[i])]==i):size=size-1\n else:\n mp[s[i]]=1\n size=size+1\n if(size>k):\n ans=\"YES\"\n if(pos[ord(s[i])]==i):size=size-1\n\nprint ans\n\n"}, {"source_code": "n, k = map(int, input().split())\nentrances = input()\ndi = {}\ns = set()\nfor i in range(n): di[entrances[i]] = i\n\nfor i in range(n):\n s.add(entrances[i])\n if len(s)>k:\n print(\"YES\")\n break\n if di[entrances[i]]==i:\n s.remove(entrances[i])\nelse:\n print(\"NO\")\n"}, {"source_code": "n,k = [int(_) for _ in raw_input().strip().split()]\nstring = raw_input().strip()\ndau = [1000010]*26\ncuoi = [-1]*26\nresult = [0]*(n+20)\n\nA = ord('A')\nfor i in range(n):\n position = ord(string[i])-A\n dau[position] = min(dau[position],i)\n cuoi[position] = i\nfor i in range(26):\n if cuoi[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]+1] -= 1\nfor i in range(1,n):\n result[i] = result[i-1]+result[i]\nvalue = max(result)\nif value > k:\n print \"YES\"\nelse:\n print \"NO\" "}, {"source_code": "\nfrom collections import Counter\n\nfirst = input()\nn,k = first.split()\nn = (int)(n)\nk = (int)(k)\n\nsecond = input()\n\nguests = Counter(second)\nguarded = set()\nresv = k\nflag = 1\nfor i in range(n):\n if(second[i] not in guarded):\n if(resv>0):\n guarded.add(second[i])\n resv-=1\n else:\n flag = 0\n break\n\n guests[second[i]]-=1\n if(guests[second[i]] == 0):\n resv+=1\n guarded.remove(second[i])\n\nif(flag == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\n# Baqir Khan\n# Software Engineer (Backend)\n\nfrom sys import stdin\n\ninp = stdin.readline\n\nn, k = map(int, inp().split())\ns = inp()[:-1]\nout_time = [-1] * 26\nin_time = [-1] * 26\n\nfor i in range(n):\n if in_time[ord(s[i]) - ord(\"A\")] == -1:\n in_time[ord(s[i]) - ord(\"A\")] = i\n\nfor i in range(n - 1, -1, -1):\n if out_time[ord(s[i]) - ord(\"A\")] == -1:\n out_time[ord(s[i]) - ord(\"A\")] = i\n\nrequirement = [0] * (n + 1)\n\nfor i in range(26):\n if in_time[i] != -1:\n requirement[in_time[i]] += 1\n requirement[out_time[i] + 1] -= 1\n\ncur_sum = 0\nfor i in range(n):\n cur_sum += requirement[i]\n requirement[i] = cur_sum\n\nprint(\"NO\" if max(requirement) <= k else \"YES\")\n"}, {"source_code": "import sys\n# from collections import deque\n# from collections import Counter\n# from math import sqrt\n# from math import log\n# from math import ceil\n# from bisect import bisect_left, bisect_right\n\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']\n# mod=10**9+7\n# mod=998244353\n\n# def BinarySearch(a,x): \n# \ti=bisect_left(a,x) \n# \tif(i!=len(a) and a[i]==x): \n# \t\treturn i \n# \telse: \n# \t\treturn -1\n\n# def sieve(n): \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# \tprime[0]=False\n# \tprime[1]=False\n# \ts=set()\n# \tfor i in range(len(prime)):\n# \t\tif(prime[i]):\n# \t\ts.add(i)\n# \treturn s\n\n# def gcd(a, b):\n# \tif(a==0):\n# \t\treturn b \n# \treturn gcd(b%a,a)\n\nfast_reader=sys.stdin.readline\nfast_writer=sys.stdout.write\n\ndef input():\n\treturn fast_reader().strip()\n\ndef print(*argv):\n\tfast_writer(' '.join((str(i)) for i in argv))\n\tfast_writer('\\n')\n\n#____________________________________________________________________________________________________________________________________\n\nn,k=map(int, input().split())\ns=input()\nend={}\nstart={}\nfor i in range(len(s)):\n\tif(s[i] not in start):\n\t\tstart[s[i]]=i\n\tend[s[i]]=i\nst=list(start.values())\nen=list(end.values())\nst=set(st)\nen=set(en)\nc=0\nf=True\nfor i in range(n):\n\tif(i in st):\n\t\tc+=1\n\tif(c>k):\n\t\tf=False\n\t\tbreak\n\tif(i in en):\n\t\tc-=1\nif(f):\n\tprint('NO')\nelse:\n\tprint('YES')"}, {"source_code": "# Idea is to find first and last indices of all doors\n# It will be time when door opens and time when door closes and guardian can leave\n\ndef main():\n opened = {}\n closed = {}\n\n n, k = map(int, input().split())\n seq = input()\n\n for i, way in enumerate(seq):\n if way not in opened:\n opened[way] = i\n closed[way] = i # Door can be closed after 1 person in\n\n for i, way in enumerate(seq):\n open_ith_door = opened[way] == i\n if open_ith_door:\n k -= 1\n no_guardians = k < 0\n if no_guardians:\n print(\"YES\")\n return\n\n close_ith_door = closed[way] == i\n if close_ith_door:\n k += 1\n else:\n continue\n\n print(\"NO\")\n return\n\nmain()"}, {"source_code": "n,k = map(int,raw_input().split())\narr = raw_input()\nflg = {}\nfar = [0]*(n+1)\nfor x in xrange(n):\n\tt = arr[x]\n\tif flg.get(t,-1) == -1:\n\t\tfar[x] += 1\n\t\tflg[t] = x\n\telse:\n\t\tflg[t] = x\nfor x in flg.keys():\n\tfar[flg[x]+1] -= 1\nsu = 0\nf = 0\n\nfor x in xrange(n):\n\tsu += far[x]\n\tif su > k:\n\t\tprint 'YES'\n\t\tf = 1\n\t\tbreak\nif f == 0:\n\tprint 'NO'\n\t"}, {"source_code": "n,k=map(int,input().split())\nif n>k:\n\ts=input()\n\n\tcounts=[0]*26\n\toffset=ord('A')\n\tfor i in s:\n\t\tcounts[ord(i)-offset]+=1\n\tis_closed=[None]*26\n\tcount=26-counts.count(None)\n\tif k0:\n\t\t\t\t\tk-=1\n\t\t\t\t\tis_closed[pos]=False\n\t\t\t\telif k==0:\n\t\t\t\t\tprint(\"YES\")\n\t\t\t\t\tbreak\n\t\t\telif is_closed[pos]:\n\t\t\t\tprint(\"YES\")\n\t\t\t\tbreak\n\t\t\tcounts[pos]-=1\n\t\t\tif counts[pos]==0:\n\t\t\t\tis_closed[pos]=True\n\t\t\t\tk+=1\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "guest, guard = [int(x) for x in input().strip().split(\" \")]\nlist = [x for x in input().strip()]\nfirst = {}\nlast = {}\nfor i, c in enumerate(list):\n if c not in first:\n first[c] = i\n last[c] = i\n\nposCount = []\ncurrent = 0\nfor i,c in enumerate(list):\n if first[c] == i:\n current += 1\n posCount.append(current)\n if last[c] == i:\n current -=1\n\nif max(posCount) > guard:\n print(\"yes\")\nelse:\n print(\"no\")"}, {"source_code": "def main ():\n n, k = [int(n) for n in input().split()]\n S = input();\n doors = {}\n\n for i, s in enumerate(S):\n doors[s] = i\n\n activeDoors = set();\n for i, s in enumerate(S):\n if doors[s] == i:\n activeDoors.add(s);\n if(len(activeDoors) > k):\n return \"YES\"\n activeDoors.remove(s);\n else:\n activeDoors.add(s);\n if(len(activeDoors) > k):\n return \"YES\"\n \n return \"NO\"\n\nprint(main())"}, {"source_code": "m,n = map(int,raw_input().split())\na = []\npositions = {}\ns = raw_input()\nml = 0\nfor i in range(m):\n\ttry:\n\t\tpositions[s[i]] = [positions[s[i]][0],i]\n\texcept:\n\t\tpositions[s[i]]=[i,i]\n#print(positions)\t\t\na = []\nassing_gard = 0\nmax_a = 0\nfor i in range(m-1):\n\tif s[i] not in a:\n\t\tassing_gard += 1\n\t\t#print(assing_gard)\n\t\tif assing_gard > max_a:\n\t\t\tmax_a = assing_gard\n\t\ta.append(s[i])\n\tif positions[s[i]][1] == i:\n\t\tassing_gard -= 1\n\nif max_a > n:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t"}, {"source_code": "from sys import stdin\n\nOPEN = True\nCLOSE = False\n\ntry:\n while True:\n doors = dict( (c,CLOSE) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' )\n guests, guards = tuple(map(int, input().split(' ', 2)))\n entries = input()\n close_door = dict( (c, entries.rfind(c)) for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' )\n if guards >= len(doors):\n print('NO')\n continue\n if len(set(entries)) <= guards:\n print('NO')\n continue\n total_open = 0\n for index, door in enumerate(entries):\n if doors[door] == CLOSE:\n doors[door] = OPEN\n total_open += 1\n if total_open > guards:\n break\n if close_door[door] == index:\n doors[door] = CLOSE\n total_open -= 1\n if total_open > guards:\n print('YES')\n else:\n print('NO')\nexcept EOFError:\n pass"}, {"source_code": "from sys import stdin, stdout\nimport string\n\nn,k = map(int,stdin.readline().rstrip().split())\ns = list(stdin.readline().rstrip())\n\ndoorOpen = {}\ndoorClosed = {}\n\nfor i in range(n):\n if s[i] not in doorOpen.keys():\n doorOpen[s[i]] = i\n\nfor i in range(n-1,-1,-1):\n if s[i] not in doorClosed.keys():\n doorClosed[s[i]] = i\n\nevents = [(x,'o') for x in doorOpen.values()] + [(x,'x') for x in doorClosed.values()]\n\nevents.sort(key=lambda x: x[1])\nevents.sort(key = lambda x:x[0])\n\n\nopened = 0\nunguarded = False\nfor i in range(len(events)):\n if events[i][1]=='o':\n opened+=1\n else:\n opened-=1\n if opened>k:\n unguarded = True\n break\n\nif unguarded:\n print('YES')\nelse:\n print('NO')\n \n"}, {"source_code": "n,k=map(int,input().split())\nif n>k:\n\ts=input()\n\n\tcounts=[0]*26\n\toffset=ord('A')\n\tfor i in s:\n\t\tcounts[ord(i)-offset]+=1\n\tis_closed=[None]*26\n\tcount=26-counts.count(None)\n\tif k0:\n\t\t\t\t\tk-=1\n\t\t\t\t\tis_closed[pos]=False\n\t\t\t\telif k==0:\n\t\t\t\t\tprint(\"YES\")\n\t\t\t\t\tbreak\n\t\t\telif is_closed[pos]:\n\t\t\t\tprint(\"YES\")\n\t\t\t\tbreak\n\t\t\tcounts[pos]-=1\n\t\t\tif counts[pos]==0:\n\t\t\t\tis_closed[pos]=True\n\t\t\t\tk+=1\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"NO\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "guests, guards = map(int, raw_input().split())\n\ngates_opened = {}\ncount = {}\n\nseq = raw_input()\n\nfor g in seq:\n c = count.setdefault(g, 0)\n count[g] = c+1\n\n\n# print(count)\ndef main():\n gates = 0\n for g in seq:\n count[g] -= 1\n # print(g, gates_opened)\n if not gates_opened.has_key(g):\n gates += 1\n gates_opened[g] = True\n if gates > guards:\n print('YES')\n return\n if gates_opened.has_key(g):\n if count[g] == 0:\n gates_opened.pop(g)\n gates -= 1\n\n print('NO')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "first_line = input().strip()\n\nn = int(first_line.split()[0])\nk = int(first_line.split()[1])\n\nn_line = input().strip()\n\nguest_doors = []\n\ndoor_dict = {}\nfor x in range(n):\n if n_line[x] in door_dict:\n if len(door_dict[n_line[x]]) > 1:\n door_dict[n_line[x]][1] = x\n else:\n door_dict[n_line[x]].append(x) \n else:\n door_dict[n_line[x]] = []\n door_dict[n_line[x]].append(x)\n\nstart_end = []\nfor key in door_dict:\n if door_dict[key][0] == door_dict[key][-1]:\n start_end.append([door_dict[key][0],'d'])\n else:\n start_end.append([door_dict[key][0],'s'])\n start_end.append([door_dict[key][-1],'f'])\n\nmax_conflicts = -1\nconflicts = 0\n\nsorted_vals = sorted(start_end)\n\nfor x in sorted_vals:\n if x[1] == 's':\n conflicts += 1\n elif x[1] == 'f':\n conflicts -=1\n elif x[1] == 'd':\n conflicts += 1\n\n if conflicts > max_conflicts:\n max_conflicts = conflicts\n if x[1] == 'd':\n conflicts -= 1\n\nif k >= max_conflicts:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "import os\n\n\ndef main():\n s = os.read(0, os.fstat(0).st_size).split()\n\n n, k = int(s[0]), int(s[1])\n g = [x - 65 for x in s[2]]\n\n e = [-1] * 26\n for i in range(n):\n e[g[i]] = i\n curS = 0\n f = 1\n met = [0] * 26\n for i in range(n):\n if not met[g[i]]:\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n if i == e[g[i]]:\n curS -= 1\n\n print('NO' if f else 'YES')\n\n\nmain()\n"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nOpen, Close = [-1 for i in range(26)], [-1 for i in range(26)]\nope = 0\nBool = True\nfor i in range(n):\n curr = ord(s[i]) - ord('A')\n if Open[curr] == -1:\n Open[curr] = i\n Close[curr] = i\n else:\n Close[curr] = i\n\nfor i in range(n):\n if i in Open:\n ope += 1\n if ope > k:\n Bool = False\n break\n if i in Close:\n ope -= 1\nprint(\"NO\") if Bool else print(\"YES\")"}, {"source_code": "# cook your dish here\n\nn,k=map(int,input().split())\nst=input()\ns=set(st)\nans=0\nd=[0]*n\nfor i in s:\n for j in range(st.find(i),st.rfind(i)+1):\n d[j]+=1 \n\nif(max(d)>k):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ns = input()\narr = dict()\narr_ = dict()\nans = 'NO'\nfor i in range(65, 91):\n arr[chr(i)] = 0\n arr_[chr(i)] = 0\nfor i in s:\n arr_[i] += 1\nfor i in s:\n if arr[i] == 0:\n k -= 1\n arr[i] += 1\n if k < 0:\n ans = 'YES'\n if arr[i] == arr_[i]:\n k += 1\nprint(ans)\n"}, {"source_code": "import io, os\ndef main():\n input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n n, k = map(int, input().split())\n g, e = [x - 65 for x in input()], [-1] * 26\n for i in range(n): e[g[i]] = i\n curS, met = 0, [0] * 26\n for i in range(n):\n if not met[g[i]]: curS += 1; met[g[i]] = 1\n if curS > k: os.write(1, b'YES'); exit()\n if i == e[g[i]]: curS -= 1\n os.write(1, b'NO')\nmain()\n"}, {"source_code": "#834B\nn, k = map(int, input().split(\" \"))\ns = input()\n# ref = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n# alpha = [0]*(n+1)\n# for i in ref:\n# if i in s:\n# alpha[s.index(i)] += 1\n# alpha[s.rindex(i)+1] -= 1\n# print(alpha)\n\n# h = 0\n# for j in range(n):\n# h += alpha[j]\n# if h>k:\n# print('YES')\n# break\n# else:\n# print('NO')\n\nlast_pos = {}\nactive = set()\n \nfor i in range(n):\n last_pos[s[i]] = i\n\nfor i in range(n):\n active.add(s[i])\n if len(active) > k:\n print('YES')\n exit()\n if last_pos[s[i]] == i:\n active.remove(s[i])\nprint('NO')\n"}, {"source_code": "n,r=map(int,input().split())\ns=input()\nx={}\ny=set()\nfor j in range(n):\n x[s[j]]=j\nfor j in range(n):\n y.add(s[j])\n if(len(y)>r):\n print(\"YES\")\n break\n if(j==x[s[j]]):\n y.remove(s[j])\nif(len(y)<=r):\n print(\"NO\")\n "}, {"source_code": "from collections import Counter\n\nif __name__ == '__main__':\n n, k = list(map(int, input().split()))\n q = input()\n\n last_index, first_index = {}, {}\n for i, s in enumerate(q):\n last_index[s] = i\n first_index[s] = min(first_index.get(s, 10**6 +5), i)\n\n opened_count = 0\n for i, d in enumerate(q):\n if i == first_index[d]:\n opened_count += 1\n if opened_count > k:\n print('YES')\n exit(0)\n if i == last_index[d]:\n opened_count -= 1\n \n print('NO')"}, {"source_code": "def helper():\n\tn, k = map(int, raw_input().split())\n\ts = raw_input()\n\tend_index = {}\n\tguard = 0\n\tis_guard = {}\n\tfor i, v in enumerate(reversed(s)):\n\t\tif v in end_index:\n\t\t\tcontinue\n\t\tend_index[v] = len(s) - i - 1\n\n\t# print end_index\n\tfor i, v in enumerate(s):\n\t\tif v in is_guard and i != end_index[v]:\n\t\t\t# not end work\n\t\t\tcontinue\n\t\tif not v in is_guard:\n\t\t\tguard += 1\n\t\t\tis_guard[v] = 1\n\t\tif guard > k:\n\t\t\treturn 'YES'\n\t\tif i == end_index[v]:\n\t\t\tguard -= 1\n\t\t# print i, ': ', guard\n\treturn 'NO'\nprint helper()"}, {"source_code": "def helper():\n\tn, k = map(int, raw_input().split())\n\ts = raw_input()\n\tend_index = {}\n\tguard = 0\n\tis_guard = {}\n\tfor i, v in enumerate(reversed(s)):\n\t\tif v in end_index:\n\t\t\tcontinue\n\t\tend_index[v] = len(s) - i - 1\n\n\t# print end_index\n\tfor i, v in enumerate(s):\n\t\tif v in is_guard and i != end_index[v]:\n\t\t\t# not end work\n\t\t\tcontinue\n\t\tif not v in is_guard:\n\t\t\tguard += 1\n\t\t\tis_guard[v] = 1\n\t\tif guard > k:\n\t\t\treturn 'YES'\n\t\tif i == end_index[v]:\n\t\t\tguard -= 1\n\t\t# print i, ': ', guard\n\treturn 'NO'\nprint helper()"}, {"source_code": "n,k=input().split()\nn=int(n)\nk=int(k)\nl=input()\nd={}\nfor val in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':\n\td[val]=0\nfor val in l:\n\td[val]+=1\nopened={}\nflag=0\nfor val in l:\n\tif(val not in opened):\n\t\topened[val]=1\n\td[val]-=1\n\tif(len(opened)>k):\n\t\tflag=1\n\t\tbreak\n\tif(d[val]==0):\n\t\tdel(opened[val])\nif(flag==0):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n n, k = map(int, input().split())\n guests = input().rstrip()\n guestbook = {guest: idx for idx, guest in enumerate(guests)}\n\n s = set ()\n for idx, guest in enumerate(guests):\n if guest not in s: s.add(guest)\n if len(s) > k:\n print(\"YES\")\n return\n if guestbook[guest] == idx: s.remove(guest)\n print(\"NO\")\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n, k = [int(i) for i in input().split()]\na = input()\nd = [[n + 1, 0] for i in range(26)]\nfor i in range(n):\n s = ord(a[i]) - ord('A')\n d[s][0] = min(d[s][0], i)\n d[s][1] = i\nev = []\nfor i in d:\n if i[0] != n + 1:\n ev.append([i[0], 0])\n ev.append([i[1], 1])\nev.sort()\nb = 0\nmb = 0\nfor i in range(len(ev)):\n if ev[i][1] == 1:\n b -= 1\n else:\n b += 1\n mb = max(mb, b)\nprint(['NO', 'YES'][int(mb > k)])\n"}], "negative_code": [{"source_code": "arr = list(map(int,input().split()))\ntotal_g = arr[0]\nguards = arr[1]\nclose_gate = dict()\nentry = input()\nchanges = 0\n\nfor i in range(0,total_g):\n if entry[i] in close_gate:\n close_gate[entry[i]] = close_gate[entry[i]] + 1\n else:\n close_gate[entry[i]] = 1\n\ncnt_gate = dict()\navg = guards\nflag = 0\n\nfor i in range(0,total_g):\n # print(entry[i])\n if entry[i] not in cnt_gate:\n # print(\"new gate opened\")\n cnt_gate[entry[i]] = 1 \n avg = avg -1\n # print(cnt_gate[entry[i]],close_gate[entry[i]])\n # print('guards avl',avg)\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n avg = avg + 1 \n if avg<1 and i!=0 and cnt_gate[entry[i-1]] != close_gate[entry[i-1]]:\n print('YES')\n flag = 1 \n break\n else :\n cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1 \n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n # print('gate was',entry[i], 'closed')\n avg = avg + 1 \n \nif flag == 0:\n print('N0')\n "}, {"source_code": "n,k = map(int,raw_input().split())\n\nfg = raw_input()\n\n\nl = len(fg)\n\nplave = {}\n\nfor index in xrange(l):\n\ttry:\n\t\tplave[fg[index]].append(index)\n\texcept KeyError:\n\t\tplave[fg[index]]=[index]\n\n\nfor p in plave:\n\te = plave[p]\n\tc = True\n\tlength = len(plave[p])\n\tfor i in xrange(length-1):\n\t\tif e[i+1]-e[i]!=1:\n\t\t\t# print \"no\"\n\t\t\tc = False\n\t\t\tbreak\n\tif c==False:\n\t\tprint \"YES\"\n\t\tbreak\nif c==True:\n\tprint \"NO\"\n\n\n"}, {"source_code": "n,k = map(int, raw_input().split())\na = list(raw_input())\nalp = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\nm = {}\ngiven = {}\nfor i in alp:\n\tm[i] = -1\n\tgiven[i] = 0\nfor i in range(len(a)-1,-1,-1):\n\tif(m[a[i]]==-1):\n\t\tm[a[i]] = i\ngates = 0\nguards = k-1\ngiven[a[0]] = 1\n\nfor i in range(1,len(a)):\n\tif(given[a[i]]):\n\t\tpass\n\telse:\n\t\tgiven[a[i]]=1\n\t\tguards-=1\n\tif(m[a[i]]==i):\n\t\tguards+=1\n\tif(guards<0):\n\t\tgates+=1\n\t\tbreak\nif(gates==1):\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin, stdout\n\ndef rint():\n return map(int, stdin.readline().split())\n#lines = stdin.readlines()\n\n\nn, k = rint()\ns = input()\nsl = {}\nfor i in range(len(s)):\n if not s[i] in sl:\n sl[s[i]] = [i,i]\n else:\n sl[s[i]][1] = i\ncnt = 0\nfor i in range(len(s)):\n if sl[s[i]][0] == i:\n cnt+=1\n if sl[s[i]][1] == i:\n cnt-=1\n if cnt > k:\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n\n\n"}, {"source_code": "from collections import Counter\n\n\ndef main():\n n, k = map(int, input().split())\n queue = input()\n\n counter = Counter()\n unique = list(set(queue))\n amount = dict(zip(unique, [queue.count(x) for x in unique]))\n\n for x in queue:\n if len(counter) > k:\n return 'Yes'\n\n counter[x] += 1\n if counter[x] == amount[x]:\n counter.pop(x)\n\n return 'NO'\n\nprint(main())"}, {"source_code": "#RAVENS\n#TEAM_2\n#ESSI-DAYI_MOHSEN-LORENZO\n#import sys\n#input=sys.stdin.readline\nn,k = map(int,input().split())\ns = input()\nclose = dict()\n\nfor i in range(n-1,-1,-1):\n if close.get(s[i],-1) == -1:\n close[s[i]] = i\n \nOpen = 0\ndoor = dict()\nfor i in range(n):\n if i == close[s[i]]:\n Open-=1\n else:\n if door.get(s[i],-1)==-1:\n Open+=1\n door[s[i]] = 1\n if Open > k:\n print('YES')\n exit()\nprint('NO')\n\n"}, {"source_code": "n,k = [int(_) for _ in raw_input().strip().split()]\nstring = raw_input().strip()\ndau = [1000010]*26\ncuoi = [-1]*26\nresult = [0]*(n+100)\nnow =[]\n\nfor i in range(n):\n if string[i] not in now:\n now.append(string[i])\n position = ord(string[i])-ord('A')\n dau[position] = min(dau[position],i)\n cuoi[position] = max(cuoi[position],i)\nfor i in range(26):\n if cuoi[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]+1] -= 1\nvalue = 0\nfor i in range(1,n):\n result[i] = result[i-1]+result[i]\n value = max(value,result[i])\nif value > k:\n print \"YES\"\nelse:\n print \"NO\"# your code goes here"}, {"source_code": "n,k = input().strip().split()\nn=int(n)\nk=int(k)\ns=input()\nm=[]\na=[]\nif k>n or k==26:\n print('NO')\nelse:\n for i in range(n):\n l=s.find(s[i])\n p=s.rfind(s[i])\n if p not in m:\n m.append(p)\n if l not in a:\n a.append(l)\n #print(m)\n q=len(m)\n w=len(a)\n f=1\n for i in range (q):\n for j in range(i+1,w):\n if m[i]>a[j]:\n k-=1\n if k>0:\n print('NO')\n else:\n print('YES')\n\n\n"}, {"source_code": "# Idea is to find first and last indices of all doors\n# It will be time when door opens and time when door closes and guardian can leave\n\ndef main():\n opened = {}\n closed = {}\n\n n, k = map(int, input().split())\n seq = input()\n\n for i, way in enumerate(seq):\n if way not in opened:\n opened[way] = i\n else:\n closed[way] = i\n\n for i, way in enumerate(seq):\n if opened[way] == i:\n no_guardians = k == 0\n if no_guardians:\n print(\"YES\")\n return\n else:\n k -= 1\n elif closed[way] != i:\n continue\n elif closed[way] == i:\n k += 1\n\n print(\"NO\")\n return\n\nmain()"}, {"source_code": "guests, guards = map(int, raw_input().split())\n\ngates_opened = {}\ncount = {}\n\nseq = raw_input()\n\nfor g in seq:\n c = count.setdefault(g, 0)\n count[g] = c+1\n\n\n# print(count)\ndef main():\n gates = 0\n for g in seq:\n count[g] -= 1\n if gates_opened.has_key(g):\n if count[g] == 0:\n gates_opened.pop(g)\n gates -= 1\n continue\n # print(g, gates_opened)\n gates += 1\n gates_opened[g] = True\n if gates > guards:\n print('YES')\n return\n print('NO')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import string\nn, k = map(int, input().split())\ns = input()\nboard = dict(zip(string.ascii_uppercase, [[-1, -1] for _ in range(26)]))\n# print(board)\ns_set = set(s)\nfor c in s_set:\n board[c][0], board[c][1] = s.find(c), s.rfind(c)\n# print(max([len(set(s[board[x][0]:board[x][1]])) for x in s_set]))\nprint('YES' if max([len(set(s[board[x][0]:board[x][1]])) for x in s_set]) <= k else 'NO')\n"}, {"source_code": "n,k = map(int, input().split())\ns = str(input())\nf = [[0]*26for j in range(2)]\nfor i in range(26):\n\taa = s.find(chr(65+i))\n\tbb = s.rfind(chr(65+i))\n\tf[0][i] = aa\n\tf[1][i] = bb\n\t#print(aa,bb,i)\n\t#print(f[0][i],f[1][i])\nlmin = max(f[0])\n#print(lmin)\nans = 0\nfor i in range(26):\n\tif f[1][i] > lmin:\n\t\tans += 1\nif ans <= k:\n\tprint('NO')\nelse:\n\tprint('YES')\n"}, {"source_code": "import sys\nn, k = map(int, input().split())\na = list(input())\nst = [0] * 26\ned = [0] * 26\nfor i in range(n):\n\tif st[ord(a[i])-65] == 0:\n\t\tst[ord(a[i])-65] = i + 1\n\telse:\n\t\ted[ord(a[i])-65] = i + 1\nfor i in range(26):\n\tif st[i] != 0 and ed[i] == 0:\n\t\ted[i] = st[i]\nn = 52\ni = 1\nj = 0\nmaxi = 1\nl = 1\nwhile i < 26 and j < 26:\n\tif st[i] == 0:\n\t\ti += 1\n\t\tcontinue\n\tif ed[j] == 0:\n\t\tj += 1\n\t\tcontinue\n\tif st[i] <= ed[j]:\n\t\tl += 1\n\t\ti += 1\n\t\tif l > maxi:\n\t\t\tmaxi = l\n\telse:\n\t\tl -= 1\n\t\tj += 1\nif maxi > k:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "# Idea is to find first and last indices of all doors\n# It will be time when door opens and time when door closes and guardian can leave\n\ndef main():\n opened = {}\n closed = {}\n\n n, k = map(int, input().split())\n seq = input()\n\n for i, way in enumerate(seq):\n if way not in opened:\n opened[way] = i\n else:\n closed[way] = i\n\n for i, way in enumerate(seq):\n if opened[way] == i:\n no_guardians = k == 0\n if no_guardians:\n print(\"YES\")\n return\n else:\n k -= 1\n elif closed[way] != i:\n continue\n elif closed[way] == i:\n k += 1\n\n print(\"NO\")\n return\n\nmain()"}, {"source_code": "X = list(map(int, input().split()))\nCheck = []\nEntrance = input()\nif X[0] == 1:\n print(\"NO\")\n exit()\ni = 1\nCount = 0\nwhile i < X[0]:\n if Entrance[i] != Entrance[i - 1]:\n if Entrance[i - 1] not in Check:\n Check.append(Entrance[i - 1])\n else:\n Count += 1\n i += 1\nprint(\"YES\" if Count + 1 > X[1] else \"NO\")\n# UB_CodeForces\n# Advice: Falling down is an accident, staying down is a choice\n# Location: Here in Bojnurd\n# Caption: Preparing for UBCOMP4 and new starting\n# CodeNumber: 612\n"}, {"source_code": "n,k = map(int,input().split())\nt = input()\nk1 = set(t)\nd = {}\nfor i in k1:\n\td[i] = (t.index(i),n-t[::-1].index(i)-1)\ns = set()\nfor i in range(len(t)):\n\tif i < d[t[i]][1]:\n\t\ts.add(t[i])\n\tif len(s) > k:\n\t\tprint(\"YES\")\n\t\texit()\nprint(\"NO\")"}, {"source_code": "n,k=list(map(int,input().split()))\na=list(input())\np=0\nb=a[::-1]\nc=[]\navailable=k\nfor i in range(n-1):\n if a[i] in a[i+1:]:\n if a[i] not in c:\n c.append(a[i])\n available-=1\n elif a.count(a[i])==1:\n continue\n else:\n available+=1\n if available<0:\n p=1\n print(\"YES\")\n break\nif p==0:\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "def get(a):return map(a,raw_input().split())\nfrom collections import defaultdict\na,b = get(int)\nhr = raw_input()\nhs = set()\nls = defaultdict(int)\nfor i in xrange(len(hr)):\n\tls[hr[i]] = i\n\nfor i in xrange(len(hr)):\n\ths.add(hr[i])\n\tif ls[hr[i]] == i:\n\t\ths.remove(hr[i])\n\tif len(hs) > b:\n\t\tprint 'YES'\n\t\texit(0)\n\nprint 'NO'\n"}, {"source_code": "from math import inf,sqrt,floor,ceil\nfrom collections import Counter,defaultdict,deque\nfrom heapq import heappush as hpush,heappop as hpop,heapify as h\nfrom operator import itemgetter\nfrom itertools import product\nfrom bisect import bisect_left,bisect_right\n\nn,k=map(int,input().split( ))\ns=input()\nlast=Counter()\nfor i in range(n):\n last[s[i]]=i\ncheck=set()\ncheck.add(s[0])\nk-=1\nans=\"NO\"\nfor i in range(n):\n if k<0:\n ans=\"YES\"\n break\n if last[s[i]]==i and s[i] in check:\n k+=1\n else:\n if s[i] not in check:\n k-=1\n check.add(s[i])\nprint(ans)"}, {"source_code": "def main ():\n n, k = [int(n) for n in input().split()]\n S = input();\n doors = {}\n\n for i, s in enumerate(S):\n doors[s] = i\n\n activeDoors = set();\n for i, s in enumerate(S):\n if doors[s] == i:\n if s in activeDoors:\n activeDoors.add(s);\n if(len(activeDoors) > k):\n return \"YES\"\n activeDoors.remove(s);\n else:\n activeDoors.add(s);\n if(len(activeDoors) > k):\n return \"YES\"\n \n return \"NO\"\n\nprint(main())"}, {"source_code": "import sys\nimport math\nimport bisect\nfrom sys import stdin, stdout\nfrom math import gcd, floor, sqrt, log\nfrom collections import defaultdict as dd\nfrom bisect import bisect_left as bl, bisect_right as br\nfrom collections import Counter\n\n#sys.setrecursionlimit(100000000)\n\ninp = lambda: int(input())\nstrng = lambda: input().strip()\njn = lambda x, l: x.join(map(str, l))\nstrl = lambda: list(input().strip())\nmul = lambda: map(int, input().strip().split())\nmulf = lambda: map(float, input().strip().split())\nseq = lambda: list(map(int, input().strip().split()))\n\nceil = lambda x: int(x) if (x == int(x)) else int(x) + 1\nceildiv = lambda x, d: x // d if (x % d == 0) else x // d + 1\n\nflush = lambda: stdout.flush()\nstdstr = lambda: stdin.readline()\nstdint = lambda: int(stdin.readline())\nstdpr = lambda x: stdout.write(str(x))\nstdarr = lambda: map(int, stdstr().split())\n\nmod = 1000000007\n\nn,k = stdarr()\n\ns = input()\nc = Counter(s)\n\nc1 = c.copy()\n\nopened = Counter()\n\nflag = True\n\nfor i in s:\n c1[i] -= 1\n if(opened[i] == 0):\n if(k == 0):\n flag = False\n break\n else:\n k -= 1\n\n opened[i] = True\n else:\n if(c1[i] == 0):\n k += 1\n continue\n\n\nif(not flag):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Sep 13 10:27:06 2019\n\n@author: avina\n\"\"\"\n\nn,k = map(int, input().split())\nst = input()\nst2 = st[::-1]\nt = False\nfor i in range(n):\n a = n - st2.index(st[i]) -1\n s = len(set(st[i:a]))\n if s > k:\n t = True\n break\nif t:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def fun():\n n,k=map(int,raw_input().split())\n gates=0\n mp={}\n opened={}\n inp=raw_input()\n for x in range(len(inp)):\n mp[inp[x]]=x\n for x in range(len(inp)):\n if mp[inp[x]]!=x:\n if inp[x] not in opened:\n opened[inp[x]]=1\n gates+=1\n if gates>k:\n return \"YES\"\n else:\n gates-=1\n return \"NO\"\nprint fun()\n \n\n"}, {"source_code": "n, k = map(int, input().split(' '))\ninter = input(); d = {};\nfor i in range(26): d[chr(65+i)] = [-1, -1]\n\nfor i in range(len(inter)):\n\tif d[inter[i]][0] == -1: d[inter[i]][0] = i\n\telse: d[inter[i]][1] = i\n\ndef interect(a, b):\n\treturn not(b[0] >= a[1] or b[1] <= a[0])\ndef getIntersection(a, b):\n\treturn [max(a[0], b[0]), min(a[1], b[1])]\n\nmaxIntersections = 0\nfor i in range(26):\n\tinters, interval = 0, d[chr(65+i)]\n\tfor j in range(26):\n\t\tif interect(interval, d[chr(65+j)]):\n\t\t\tinters += 1\n\t\t\tinterval = getIntersection(interval, d[chr(65+j)])\n\t\n\tmaxIntersections = max(maxIntersections, inters-1)\n\nprint(\"YES\" if maxIntersections >= k else \"NO\")"}, {"source_code": "arr = list(map(int,input().split()))\ntotal_g = arr[0]\nguards = arr[1]\nclose_gate = dict()\nentry = input()\nchanges = 0\n\nfor i in range(0,total_g):\n if entry[i] in close_gate:\n close_gate[entry[i]] = close_gate[entry[i]] + 1\n else:\n close_gate[entry[i]] = 1\nused_gates = len(close_gate)\n\ncnt_gate = dict()\nflag = 0\nav_grds = guards\nfor i in range(0,total_g):\n if entry[i] not in cnt_gate:\n av_grds = av_grds - 1\n cnt_gate[entry[i]] = 1\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n av_grds = av_grds + 1 \n if av_grds < 1:\n print(\"YES\")\n flag = 1 \n break\n else:\n cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n av_grds = av_grds + 1 \n \nif flag == 0:\n print(\"NO\")\n "}, {"source_code": "n, k = [int(x) for x in input().split()] \na = [ord(x) for x in list(input())] #\nb = [0] * 32\nfor i in a:\n b[i - 65] += 1\nc = [0] * 32\ni = 0\nf = 0\nfor i in a:\n c[i - 65] += 1\n if c[i - 65] == 1:\n k -= 1\n if c[i - 65] == b[i - 65] :\n k += 1\n if k < 0:\n f = 1\nif f == 1:\n print('YES')\nelse: \n print('NO')"}, {"source_code": "from collections import defaultdict\nn,k=map(int,input().split())\ns=input()\nd=defaultdict(lambda:[-1,-1])\ns1=s[::-1]\nfor x in range(65,91):\n if s.find(chr(x))!=-1:\n d[chr(x)][0]=s.find(chr(x))\n d[chr(x)][1]=(n-1)-s1.find(chr(x))\nt=s[0]\nk1=1\nf=0\nfor x in range(1,n):\n if s[x]!=t and d[s[x-1]][1]!=x-1:\n k1+=1\n if k1>k:\n f=1\n break\n elif d[s[x-1]][1]==x-1:\n k1-=1\n t=s[x]\nif f:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n \n"}, {"source_code": "#!/usr/bin/python3\n\ndef main():\n n, g = [int(x) for x in input().split()]\n data = input()\n dats = set(data)\n\n inicio = []\n final = []\n\n for val in dats:\n inicio.append(data.index(val))\n\n for end in range(n-1, 0, -1):\n if data[end] == val:\n final.append(end)\n break\n\n inicio.sort()\n final.sort()\n\n acima = len(inicio) > g\n total = 0\n i, f = 0, 0\n\n if acima:\n acima = False\n\n while (i < len(inicio)):\n if (inicio[i] <= final[f]):\n total += 1\n i += 1\n else:\n total -= 1\n f += 1\n\n if total > g:\n acima = True\n break\n\n\n print(\"YES\" if acima else \"NO\")\n\nif __name__ == \"__main__\": main()\n\n"}, {"source_code": "n, k = [int (x) for x in raw_input().split()]\nstring = raw_input()\ndau = []\ncuoi = []\nresult = []\n\n\ndef prepare_data():\n for i in range(n):\n\n position = ord(string[i])-ord('A')\n if dau[position] == -1:\n dau[position] = i\n else:\n dau[position] = min(dau[position],i)\n cuoi[position] = max(cuoi[position],i+1)\n for i in range(26):\n if dau[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]] -= 1\n for i in range(n+1):\n if i > 0:\n result[i] = result[i-1]+result[i]\n return True\n\ndef load_data():\n\n for i in range(n+2):\n result.append(0)\n for i in range(26):\n dau.append(-1)\n cuoi.append(-1)\n return True\n\nif __name__ == '__main__':\n load_data()\n print \"ok\"\n prepare_data()\n value = 0\n for i in range(n):\n if result[i] > k:\n value = 1\n if value == 1:\n print \"YES\"\n else:\n print \"NO\"# your code goes here"}, {"source_code": "from collections import Counter\nn, k = map(int, raw_input().split())\ns = raw_input().strip()\nsc = Counter(s)\ntc = Counter()\nans = \"NO\"\nfor i in s:\n tc[i] += 1\n if tc[i] == sc[i]:\n del tc[i]\n if len(tc) > k:\n ans = \"YES\"\n break\nprint ans "}, {"source_code": "n, k = [int(x) for x in input().split()]\na = [ord(x) for x in list(input())]\nb = [0] * 26\nfor i in a:\n b[i - 65] += 1\nc = [0] * 26\ni = 0\nf = 0\nwhile i != len(a):\n c[a[i] - 65] += 1\n if c[a[i] - 65] == 1:\n k -= 1\n elif c[a[i] - 65] == b[a[i] - 65]:\n k += 1\n i += 1\n if k < 0:\n f = 1\nif f == 1:\n print('YES')\nelse: \n print('NO')"}, {"source_code": "n, k = [int(i) for i in input().split()]\na = input()\nd = [[n + 1, 0] for i in range(26)]\nfor i in range(n):\n s = ord(a[i]) - ord('A')\n d[s][0] = min(d[s][0], i)\n d[s][1] = i\nev = []\nfor i in d:\n if i[0] != n + 1:\n ev.append([i[0], 0])\n ev.append([i[1], 1])\nev.sort()\nb = 0\nmb = 0\nfor i in range(len(ev)):\n if ev[i][1] == 1:\n b -= 1\n else:\n b += 1\n mb = max(mb, b)\n print(b)\nprint(['NO', 'YES'][int(mb > k)])\n"}, {"source_code": "n, k = input().split()\nn = int(n)\nk = int(k)\n\ns = input()\n\nopen_doors = 0\n\nopened = False\nfor i in range (len(s)):\n if opened == False:\n current = s[i]\n opened = True\n\n else:\n if s[i] != current:\n open_doors += 1\n else:\n opened = False\n\nif open_doors >= k:\n print (\"YES\")\n\nelse:\n print (\"NO\")\n \n \n"}, {"source_code": "n, k = [int (x) for x in raw_input().split()]\nstring = raw_input()\ndau = []\ncuoi = []\nresult = []\n\n\ndef prepare_data():\n for i in range(n):\n\n position = ord(string[i])-ord('A')\n if dau[position] == -1:\n dau[position] = i\n else:\n dau[position] = min(dau[position],i)\n cuoi[position] = max(cuoi[position],i+1)\n for i in range(26):\n if dau[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]] -= 1\n for i in range(n+1):\n if i > 0:\n result[i] = result[i-1]+result[i]\n return True\n\ndef load_data():\n\n for i in range(n+2):\n result.append(0)\n for i in range(26):\n dau.append(-1)\n cuoi.append(-1)\n return True\n\nif __name__ == '__main__':\n load_data()\n print \"ok\"\n prepare_data()\n value = 0\n for i in range(n):\n if result[i] > k:\n value = 1\n if value == 1:\n print \"YES\"\n else:\n print \"NO\"# your code goes here"}, {"source_code": "n,k = map(int,raw_input().split())\nunguarded = False\n\nfreq = {}\nguests = raw_input()\nfor g in guests:\n if g not in freq:\n freq[g] = 1\n else:\n freq[g] += 1\n\nop = 0\nnew = {}\nfor i in range(n):\n if guests[i] not in new:\n new[guests[i]] = 1\n else:\n new[guests[i]] += 1\n num = new[guests[i]]\n if num == 1:\n op += 1\n elif num == freq[guests[i]]:\n op -= 1\n\n if op > k:\n unguarded = True\n break\n\nif unguarded:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "n, k = map(int, input().split())\ndoors = input()\nclose_i = {}\nopened = set()\nfor c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':\n close_i[c] = doors.rfind(c)\nguards = 0\nfor i, d in enumerate(doors):\n if d not in opened:\n opened.add(d)\n guards += 1\n if guards > k:\n print(\"YES\")\n break\n elif i == close_i[d]:\n guards -= 1\n opened.remove(d)\nelse:\n print(\"NO\")\n"}, {"source_code": "N,K=list(map(int,input().split()))\ns=input()\ndic={}\nfor i in range(len(s)):\n if(s[i] not in dic):\n dic[s[i]]=[i]\n else:\n dic[s[i]].append(i)\nllist=[]\nfor i in dic.keys():\n r=[dic[i][0],dic[i][-1]]\n llist.append(r)\n# llist=sorted(llist,key=lambda x:x[0])\n\ncountlist=[]\nt=len(llist)\n# i=0\nfor i in range(t):\n count=1\n end=llist[i][1]\n for j in range(i+1,t):\n start=llist[j][0]\n if(startK):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n,k = [int(_) for _ in raw_input().strip().split()]\nstring = raw_input().strip()\ndau = [1000010]*26\ncuoi = [-1]*26\nresult = [0]*(n+2)\nnow =[]\n\nfor i in range(n):\n if string[i] not in now:\n now.append(string[i])\n position = ord(string[i])-ord('A')\n dau[position] = min(dau[position],i)\n cuoi[position] = max(cuoi[position],i+1)\nfor i in range(26):\n if cuoi[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]] -= 1\nvalue = 0\nfor i in range(1,n):\n result[i] = result[i-1]+result[i]\n value = max(value,result[i])\nif value > k:\n print \"YES\"\nelse:\n print \"NO\"# your code goes here"}, {"source_code": "n,k=[int(i) for i in input().split()]\ns=input().strip()\ns=list(s)\nl=[]\nl1=[]\nfor i in range(26):\n l1.append(0)\n l.append(0)\nfor i in s:\n l[ord(i)-65]+=1\nf=0\nfor i in s:\n l[ord(i)-65]-=1\n if (l[ord(i)-65]>0):\n l1[ord(i)-65]=1\n else:\n l1[ord(i)-65]=0\n if (l1.count(1)>k):\n print ('YES')\n f=1\n break\nif (f==0):\n print ('NO')"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if met[g[i]]:\n if i == e[g[i]]:\n curS -= 1\n continue\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "def main(n, k, s):\n last = {}\n for i in range(n - 1, -1, -1):\n j = ord(s[i]) - ord('A')\n if j not in last:\n last[j] = i\n se = set()\n for i, c in enumerate(list(map(lambda i: ord(i) - ord('A'), s))):\n if c not in se:\n se.add(c)\n if i == last[c]:\n se.remove(c)\n if len(se) > k:\n return \"YES\"\n return \"NO\"\n\nprint(main(*list(map(int, input().split(' '))), input()))\n"}, {"source_code": "m,n = map(int,raw_input().split())\na = []\ns = raw_input()\nml = 0\nfor i in range(m):\n\tif s[i] not in a:\n\t\ta.append(s[i])\n\t\tif ml < len(a):\n\t\t\tml = len(a)\n\telse:\n\t\ta = []\nif ml > n :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "import sys\nn, k = map(int, input().split())\na = list(input())\nst = [0] * 26\ned = [0] * 26\nfor i in range(n):\n\tif st[ord(a[i])-65] == 0:\n\t\tst[ord(a[i])-65] = i + 1\n\telse:\n\t\ted[ord(a[i])-65] = i + 1\nfor i in range(26):\n\tif st[i] != 0 and ed[i] == 0:\n\t\ted[i] = st[i]\nn = 52\ni = 0\nj = 0\nmaxi = -1 * sys.maxsize\nl = 0\nwhile i < 26 and j < 26:\n\tif st[i] == 0:\n\t\ti += 1\n\t\tcontinue\n\tif ed[j] == 0:\n\t\tj += 1\n\t\tcontinue\n\tif st[i] <= ed[j]:\n\t\tl += 1\n\t\ti += 1\n\t\tif l > maxi:\n\t\t\tmaxi = l\n\telse:\n\t\tl -= 1\n\t\tj += 1\nif maxi > k:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "import sys\nn,k=map(int,input().split())\ns=input()\nstart={}\nclose={}\nfor i in range(n):\n kk=s[i]\n try:\n a=start[kk]\n close[kk]=i\n except KeyError:\n start[kk]=i\n close[kk]=i\nac=0\nfor i in range(n):\n kk=s[i]\n if(start[kk]==i):\n ac+=1\n if(ac>k):\n print(\"YES\")\n sys.exit(0)\n elif(close[kk]==i):\n ac-=1\n if(ac>k):\n print(\"YES\")\n sys.exit(0)\nprint(\"NO\")\n\n"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = True\nmet = [False] * 91\nfor i in range(n):\n if met[g[i]]:\n if i == e[g[i]]:\n curS -= 1\n continue\n if i == e[g[i]]:\n continue\n curS += 1\n met[g[i]] = True\n if curS > k:\n f = False\n break\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "X = list(map(int, input().split()))\nEntrance = input()\nMyDict = {}\nfor i in range(X[0]):\n if Entrance[i] not in MyDict.keys():\n MyDict[Entrance[i]] = []\n MyDict[Entrance[i]].append(i)\nCount = 0\nfor i in MyDict.keys():\n if MyDict[i][-1] - MyDict[i][0] + 1 != len(MyDict[i]):\n Count += 1\nprint(\"YES\" if Count + 1 > X[1] else \"NO\")\n\n# UB_CodeForces\n# Advice: Falling down is an accident, staying down is a choice\n# Location: Here in Bojnurd\n# Caption: Preparing for UBCOMP4 and new starting\n# CodeNumber: 612\n"}, {"source_code": "n,k = input().strip().split()\nn=int(n)\nk=int(k)\ns=input()\nm=[]\na=[]\nif k>n or k==26:\n print('NO')\nelse:\n for i in range(n):\n l=s.find(s[i])\n p=s.rfind(s[i])\n if p not in m:\n m.append(p)\n if l not in a:\n a.append(l)\n #print(m)\n q=len(m)\n w=len(a)\n f=1\n for i in range (q):\n for j in range(i+1,w):\n if m[i]>a[j]:\n k-=1\n if k>0:\n print('NO')\n else:\n print('YES')\n\n\n"}, {"source_code": "n,k=map(int,raw_input().split())\nalpha=list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')\nmax_dict={}\nfor i in alpha:\n max_dict[i]=0\nguests=list(raw_input())\nfor i in guests:\n max_dict[i]+=1\nguarded={}\nfor i in alpha:\n guarded[i]=0\ncurrent_dict={}\nfor i in alpha:\n current_dict[i]=0\nis_true=True\n\nfor guest in guests:\n\n\n\n if current_dict[guest]==0:\n current_dict[guest]+=1\n guarded[guest]=1\n\n if sum(guarded.values())>k:\n is_true=False\n print 'NO'\n break\n\n\n\n\n\n if current_dict[guest]==max_dict[guest]:\n guarded[guest]=0\n\n\n\nif is_true==True:\n print 'YES'\n\n\n\n\n"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nmx=dict()\nfor x in range(n):\n mx[s[x]]=x\ncur=0\nans=0\nc={x.upper():0 for x in 'qwertyuiopasdfghjklzxcvbnm'}\nfor x in range(n):\n if c[s[x]]==0:\n cur+=1\n c[s[x]]=1\n if mx[s[x]]==x:\n cur-=1\n c[s[x]]=0\n if cur > k:\n ans=1\n #print(cur,x,s[x])\nprint('NO' if not ans else 'YES')"}, {"source_code": "from collections import deque\nfrom math import *\nimport heapq\n\n\n# n=int(input())\nn,k=map(int, input().split())\ns=input()\nd={}\ne={}\nfor i in range(len(s)):\n d[s[i]]=i\n e[s[i]]=0\n\ncounter=0\nfor j in range(len(s)):\n if d[s[j]]!=j and e[s[j]]==0:\n e[s[j]]=1\n counter+=1\n elif d[s[j]]==j and e[s[j]]==1:\n counter-=1\n\n \n if counter>k:\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "from collections import *\nn,k=map(int,input().split())\ns=input()\na=Counter(s)\nx,c=0,0\ncnt={}\nfor i in s:\n\tif i in cnt:cnt[i]+=1\n\telse:cnt[i]=1;c+=1\n\tif cnt[i]==a[i]:c-=1\n\tx=max(x,c)\nprint(\"YES\"if x>k else\"NO\")\n"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if met[g[i]]:\n if i == e[g[i]]:\n curS -= 1\n continue\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if met[g[i]]: continue\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n if i == e[g[i]]:\n curS -= 1\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "n,k = input().strip().split()\nn=int(n)\nk=int(k)\ns=input()\nm=[]\na=[]\nif k>n or k==26:\n print('NO')\nelse:\n for i in range(n):\n l=s.find(s[i])\n p=s.rfind(s[i])\n if p not in m:\n m.append(p)\n if l not in a:\n a.append(l)\n #print(m)\n q=len(m)\n w=len(a)\n f=1\n for i in range (q):\n for j in range(i+1,w):\n if m[i]>a[j]:\n k-=1\n break\n #print(k)\n if k>0:\n print('NO')\n else:\n print('YES')\n\n\n"}, {"source_code": "n, k = map(int, input().split())\ns = input()\narr = dict()\narr_ = dict()\nans = 'NO'\nfor i in range(65, 91):\n arr[chr(i)] = 0\n arr_[chr(i)] = 0\nfor i in s:\n arr_[i] += 1\nfor i in s:\n if arr[i] == 0:\n k -= 1\n arr[i] += 1\n if arr[i] == arr_[i]:\n k += 1\n if k < 0:\n ans = 'YES'\nprint(ans)\n"}, {"source_code": "n,k = [int(_) for _ in raw_input().strip().split()]\nstring = raw_input().strip()\ndau = [1000010]*26\ncuoi = [-1]*26\nresult = [0]*(n+2)\nnow =[]\n\nfor i in range(n):\n if string[i] not in now:\n now.append(string[i])\n position = ord(string[i])-ord('A')\n dau[position] = min(dau[position],i)\n cuoi[position] = max(cuoi[position],i+1)\nfor i in range(26):\n if cuoi[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]] -= 1\nvalue = 0\nfor i in range(1,n):\n result[i] = result[i-1]+result[i]\n value = max(value,result[i])\nif value > k:\n print \"YES\"\nelse:\n print \"NO\"# your code goes here"}, {"source_code": "n, k = [int(x) for x in input().split()] \na = [ord(x) for x in list(input())] #\nb = [0] * 32\nfor i in a:\n b[i - 65] += 1\nc = [0] * 32\ni = 0\nf = 0\nfor i in a:\n c[i - 65] += 1\n if c[i - 65] == 1:\n k -= 1\n if c[i - 65] == b[i - 65] :\n k += 1\n if k < 0:\n f = 1\nif f == 1:\n print('YES')\nelse: \n print('NO')"}, {"source_code": "n, ka = [int(x) for x in raw_input().split()]\n# print k+\"ll\"\ngates = raw_input()\nopen = dict()\nclose = dict()\ncount = 0\nfor k in gates:\n\tif k not in open:\n\t\topen[k] = count\n\tclose[k] = count\n\tcount += 1\narr = [0 for x in xrange(1000006)]\nfor key in open:\n\tarr[open[key]] += 1\nfor key in close:\n\tarr[close[key]] -= 1\n# print arr[0:n+1]\ncount = 0\nfor i in arr:\n\tcount += i\n\t# print count - ka\n\tif(count > ka):\n\t\tprint \"YES\"\n\t\texit()\nprint \"NO\""}, {"source_code": "N,K=list(map(int,input().split()))\ns=input()\ndic={}\nfor i in range(len(s)):\n if(s[i] not in dic):\n dic[s[i]]=[i]\n else:\n dic[s[i]].append(i)\nllist=[]\nfor i in dic.keys():\n r=[dic[i][0],dic[i][-1]]\n llist.append(r)\n# llist=sorted(llist,key=lambda x:x[0])\n\ncountlist=[]\nt=len(llist)\n# i=0\nfor i in range(t):\n count=1\n temp=0\n end=llist[i][1]\n for j in range(i+1,t):\n start=llist[j][0]\n if(startend):\n count+=1\n countlist.append(count)\n# print(llist)\nprint(countlist)\nguard=max(countlist)\nif(guard>K):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ng = input()\n\ncurS = 0\nf = 1\nmet = [0] * 26\nfor i in range(n):\n if not met[ord(g[i]) - 65]:\n curS += 1\n met[ord(g[i]) - 65] = 1\n else:\n curS -= 1\n met[ord(g[i]) - 65] = 0\n if curS > k:\n f = 0\n break\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}, {"source_code": "def read(is_int,split_by):\n\tif(is_int):\n\t\treturn [int(x) for x in input().split(split_by)]\n\telse:\n\t\treturn [x for x in input().split(split_by)]\nn, k = map(int,input().split(\" \"))\ns = input()\nanswer = \"NO\"\nhigh = {}\nlow = {}\ninterset = {}\nif k == 26:\n\tanswer = \"NO\"\nelse:\n\tfor i in range(n):\n\t\tif not (s[i] in low):\n\t\t\tlow[s[i]] = i\n\t\thigh[s[i]] = i\n\tfor f_key in high:\n\t\tmax_intersect = 0\n\t\tfor s_key in high:\n\t\t\tif f_key == s_key:\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tif high[f_key] > low[s_key] and low[f_key] < high[s_key]:\n\t\t\t\t\tif not(f_key in interset):\n\t\t\t\t\t\tinterset[f_key] = set()\n\t\t\t\t\t\tinterset[f_key].add(s_key)\n\t\t\t\t\telse:\n\t\t\t\t\t\tinterset[f_key].add(s_key)\n\tall_intersect = []\n\tall_key = []\n\tfor key in interset:\n\t\tall_intersect.append(len(interset[key]))\n\t\tall_key.append(key)\n\tif(all_intersect):\n\t\tmax_elem = max(all_intersect)\n\t\tindex_max = all_intersect.index(max_elem)\n\t\tkey = all_key[index_max]\n\n\t\tfor f_elem in interset[key]:\n\t\t\tfor s_elem in interset[key]:\n\t\t\t\tif f_elem == s_elem:\n\t\t\t\t\tcontinue\n\t\t\t\telse:\n\t\t\t\t\tif interset[f_elem].isdisjoint(interset[s_elem]):\n\t\t\t\t\t\tmax_elem-=1\n\t\t\t\t\t\tinterset[key].remove(s_elem)\n\t\t\t\t\t\tbreak\n\telse:\n\t\tmax_elem = 0\nif max_elem+1 > k:\n\tanswer = \"YES\"\nelse:\n\tanswer = \"NO\"\nprint(answer)\n"}, {"source_code": "n,k=map(int,input().split())\nlist1=input()\ns=set([])\nf=0\nfor i in range(n):\n if(list1[i] in s):\n if(list1.find(list1[i],i+1)==-1):\n s.remove(list1[i])\n else:\n s.add(list1[i])\n if(len(s)>k):\n f=1\nif(f==1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "guests, guards = map(int, raw_input().split())\n\ngates_opened = {}\ncount = {}\n\nseq = raw_input()\n\nfor g in seq:\n c = count.setdefault(g, 0)\n count[g] = c+1\n\n\n# print(count)\ndef main():\n gates = 0\n for g in seq:\n count[g] -= 1\n if gates_opened.has_key(g):\n if count[g] == 0:\n gates_opened.pop(g)\n gates -= 1\n continue\n # print(g, gates_opened)\n gates += 1\n gates_opened[g] = True\n if gates > guards:\n print('YES')\n return\n print('NO')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from math import inf,sqrt,floor,ceil\nfrom collections import Counter,defaultdict,deque\nfrom heapq import heappush as hpush,heappop as hpop,heapify as h\nfrom operator import itemgetter\nfrom itertools import product\nfrom bisect import bisect_left,bisect_right\n\nn,k=map(int,input().split( ))\ns=input()\nlast=Counter()\nfor i in range(n):\n last[s[i]]=i\ncheck=set()\ncheck.add(s[0])\nk-=1\nans=\"NO\"\nfor i in range(n):\n if k<0:\n ans=\"YES\"\n break\n if last[s[i]]==i:\n k+=1\n else:\n if s[i] not in check:\n k-=1\n check.add(s[i])\nprint(ans)"}, {"source_code": "def diff(a):\n\treturn(a[1]-a[0]+1)\n\nn,k=map(int,str(raw_input()).split())\nA=str(raw_input())\nd=[0]*26\nfor i in xrange(len(A)):\n\tif d[ord(A[i])-ord('A')] == 0:d[ord(A[i])-ord('A')]=[i,i]\n\telse:d[ord(A[i])-ord('A')]=[d[ord(A[i])-ord('A')][0],i]\nd = map(diff,sorted([x for x in d if x != 0]))\nif len(d)<=k:print 'NO'\nelse:\n\tif sum(d)<=n:print 'NO'\n\telse:print 'YES'"}, {"source_code": "n,k=map(int,input().split())\ns=input()\nmx=dict()\nfor x in range(n):\n mx[s[x]]=x\ncur=0\nans=0\nc={x.upper():0 for x in 'qwertyuiopasdfghjklzxcvbnm'}\nfor x in range(n):\n if c[s[x]]==0:\n cur+=1\n c[s[x]]=1\n if mx[s[x]]==x:\n cur-=1\n c[s[x]]=0\n if cur > k:\n ans=1\n #print(cur,x,s[x])\nprint('NO' if not ans else 'YES')"}, {"source_code": "m,n = map(int,raw_input().split())\na = []\ns = raw_input()\nml = 0\nfor i in range(m):\n\tif s[i] not in a:\n\t\ta.append(s[i])\n\t\tif ml < len(a):\n\t\t\tml = len(a)\n\telse:\n\t\ta = []\nif ml > n :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n, m = raw_input().split()\nentrada = raw_input()\nm = int(m)\nmapa = {}\nc = True\nfor e in entrada:\n\tif mapa.has_key(e):\n\t\tmapa[e][0] += 1\n\t\n\telse:\n\t\tmapa[e] = [1, False]\n\nfor e in entrada:\n\tif not mapa[e][1]:\n\t\tm -= 1\n\t\tmapa[e][0] -= 1\n\t\tif mapa[e][0] == 0:\n\t\t\tm += 1\n\t\t\tmapa[e][1] = False\n\t\tmapa[e][1] = True\n\t\t\n\telse:\n\t\tmapa[e][0] -= 1\n\t\tif mapa[e][0] == 0:\n\t\t\tm += 1\n\t\t\tmapa[e][1] = False\n\t\n\tif m < 0:\n\t\tprint \"NO\"\n\t\tc = False\n\t\tbreak \n\nif c: print \"YES\"\n"}, {"source_code": "n, k = map(int, input().split())\ns = input()\n\na = [None] * n\nd = {}\n\nfor i in range(n):\n if s[i] not in d:\n a[i] = True\n d[s[i]] = True\n\nd.clear()\nfor i in range(n - 1, -1, -1):\n if s[i] not in d:\n a[i] = False\n d[s[i]] = True\n\nc = 0\nfor el in a:\n if el is not None and el:\n c += 1\n if el is not None and not el:\n c -= 1\n if c > k:\n print('YES')\n exit()\nprint('NO')\n"}, {"source_code": "n,k = map(int,input().split())\ndata = input()\nd = {}\nc = {}\nfor i in data:\n if i not in c:\n c[i]=1\n else:\n c[i]+=1\ncount = 0\nm = 0\n\nfor i in data:\n if i not in d: \n count+=1\n m = max(m, count)\n d[i]=1\n else:\n d[i]+=1\n if d[i]== c[i]:\n del d[i]\n count-=1\nif m<=k :\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "import heapq\n\ndef doIt(s):\n for c in \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\":\n if c in s:\n a,b = s.rfind(c), s.find(c)\n if a != b:\n heapq.heappush(end, a)\n heapq.heappush(start, b)\n \n current = 0\n while start:\n if start[0] < end[0]:\n heapq.heappop(start)\n current += 1\n \n if current > k:\n return \"YES\"\n else:\n heapq.heappop(end)\n current -= 1\n return \"NO\"\n\nn,k = map(int, input().split())\ns = input()\n\nstart = []\nend = []\n\nprint(doIt(s))"}, {"source_code": "data=list(map(int,input().split()))\n"}, {"source_code": "from collections import Counter\n\nif __name__ == '__main__':\n n, k = list(map(int, input().split()))\n q = input()\n\n guest_counts = Counter(q)\n is_door_open = {\n g: False for g in guest_counts\n }\n opened_doors = 0\n\n for g in q:\n if guest_counts[g] == 1:\n is_door_open[g] = False\n opened_doors -= 1\n del guest_counts[g]\n else:\n guest_counts[g] -= 1\n if not is_door_open[g]:\n is_door_open[g] = True\n opened_doors += 1\n if opened_doors > k:\n print('YES')\n exit(0)\n print('NO')\n"}, {"source_code": "n, k = map(int, raw_input().split())\ns = raw_input()\nflag = [False]*26\nfrom collections import Counter as C\nc = C()\nfor i in s:\n c[i]+=1\nf = False\nans = 0\nfor i in range(len(s)):\n if flag[ord(s[i])-65]==False:\n flag[ord(s[i])-65] = True\n ans += 1\n c[s[i]]-=1\n if c[s[i]]==0:\n ans-=1\n if ans>k:\n f = True\n break\nif f:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n,k=map(int, raw_input().split())\ns=raw_input()\nl=[[-1,-1] for i in xrange(26)]\nfor i in xrange(len(s)):\n\tif l[ord(s[i])-65][0]==-1:\n\t\tl[ord(s[i])-65][0]=i\n\t\tl[ord(s[i])-65][1]=i\n\telse:\n\t\tl[ord(s[i])-65][1]=i\np=[]\nq=[]\nfor i in l:\n\tif i[0]!=-1:\n\t\tp.append(i[0])\n\t\tq.append(i[1])\np=sorted(p)\nq=sorted(q)\n#print p,q\ncnt=0\ni=0\nj=0\nc=0\nwhile iq[j]:\n\t\tc-=1\n\t\tj+=1\n\telse:\n\t\ti+=1\n\t\tj+=1\n#\tprint p[i]\n#\tprint i,j,p[i],q[j]\n\tcnt=max(cnt,c)\n\n#for i in xrange(len(l)):\n#\tc=1\n#\tfor j in xrange(len(l)):\n#\t\tif i!=j and (l[i][0]k:print 'YES'\nelse:print 'NO'"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport string\nimport sys\n\n\ndef main():\n iterator = iter(sys.stdin.read().split())\n n, m = int(next(iterator)), int(next(iterator))\n s = next(iterator)\n p = {}\n buffer = set()\n for i in string.ascii_uppercase:\n p[i] = s.rfind(i)\n for i, x in enumerate(s):\n if i < p[x]:\n buffer.add(x)\n if len(buffer) > m:\n print('YES')\n return\n elif x in buffer:\n buffer.remove(x)\n print('NO')\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n,k = [int(_) for _ in raw_input().strip().split()]\nstring = raw_input().strip()\ndau = [1000010]*26\ncuoi = [-1]*26\nresult = [0]*(n+2)\nnow =[]\n\nfor i in range(n):\n if string[i] not in now:\n now.append(string[i])\n position = ord(string[i])-ord('A')\n dau[position] = min(dau[position],i)\n cuoi[position] = max(cuoi[position],i+1)\nfor i in range(26):\n if cuoi[i] != -1:\n result[dau[i]] += 1\n result[cuoi[i]] -= 1\nvalue = 0\nfor i in range(1,n):\n result[i] = result[i-1]+result[i]\n value = max(value,result[i])\nif value > k:\n print \"YES\"\nelse:\n print \"NO\"# your code goes here"}, {"source_code": "def main(n, k, s):\n last = {}\n for i in range(n - 1, -1, -1):\n j = ord(s[i]) - ord('A')\n if j not in last:\n last[j] = i\n se = set()\n for i, c in enumerate(list(map(lambda i: ord(i) - ord('A'), s))):\n if c not in se:\n se.add(c)\n if i == last[c]:\n se.remove(c)\n if len(se) > k:\n return \"YES\"\n return \"NO\"\n\nprint(main(*list(map(int, input().split(' '))), input()))\n"}, {"source_code": "arr = list(map(int,input().split()))\ntotal_g = arr[0]\nguards = arr[1]\nclose_gate = dict()\nentry = input()\nchanges = 0\n\nfor i in range(0,total_g):\n if entry[i] in close_gate:\n close_gate[entry[i]] = close_gate[entry[i]] + 1\n else:\n close_gate[entry[i]] = 1\nused_gates = len(close_gate)\n\ncnt_gate = dict()\nflag = 0\nav_grds = guards\nfor i in range(0,total_g):\n if entry[i] not in cnt_gate:\n av_grds = av_grds - 1\n cnt_gate[entry[i]] = 1\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n av_grds = av_grds + 1 \n if av_grds < 1:\n print(\"YES\")\n flag = 1 \n break\n else:\n cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n av_grds = av_grds + 1 \n \nif flag == 0:\n print(\"NO\")\n "}, {"source_code": "m,n = map(int,raw_input().split())\na = []\npositions = {}\ns = raw_input()\nml = 0\nfor i in range(m):\n\tif s[i] not in a:\n\t\ta.append(s[i])\n\t\tpositions[s[i]]=[i,i]\n\telse:\n\t\tpositions[s[i]] = [positions[s[i]][0],i]\na = []\nassing_gard = 0\nmax_a = 0\nfor i in range(m-1):\n\tif s[i] not in a:\n\t\tassing_gard += 1\n\t\tif assing_gard > max_a:\n\t\t\tmax_a = assing_gard\n\t\ta.append(s[i])\n\telif positions[s[i]][1] == i:\n\t\tassing_gard -= 1\n\nif max_a > n:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t"}, {"source_code": "n,k = input().strip().split()\nn=int(n)\nk=int(k)\ns=input()\nm=[]\na=[]\nif k>n or k==26:\n print('NO')\nelse:\n for i in range(n):\n l=s.find(s[i])\n p=s.rfind(s[i])\n if p not in m:\n m.append(p)\n if l not in a:\n a.append(l)\n #print(m)\n q=len(m)\n w=len(a)\n f=1\n for i in range (q):\n for j in range(i+1,w):\n if m[i]>a[j]:\n k-=1\n if k>0:\n print('NO')\n else:\n print('YES')\n\n\n"}, {"source_code": "n, ka = [int(x) for x in raw_input().split()]\n# print k+\"ll\"\ngates = raw_input()\nopen = dict()\nclose = dict()\ncount = 0\nfor k in gates:\n\tif k not in open:\n\t\topen[k] = count\n\tclose[k] = count\n\tcount += 1\narr = [0 for x in xrange(1000006)]\nfor key in open:\n\tarr[open[key]] += 1\nfor key in close:\n\tarr[close[key]] -= 1\n# print arr[0:n+1]\ncount = 0\nfor i in arr:\n\tcount += i\n\t# print count - ka\n\tif(count > ka):\n\t\tprint \"YES\"\n\t\texit()\nprint \"NO\""}, {"source_code": "n,k=map(int,input().split())\nx=list(input().split())\na=set(x[0])\n\nz=[]\nif(len(a)<=k):\n print(\"NO\")\nelse:\n for j in range(n-1):\n if(x[0][j]==x[0][j+1]):\n continue\n else:\n z.append(x[0][j])\n if(len(z)!=k):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ns = input()\narr = dict()\narr_ = dict()\nans = 'NO'\nfor i in range(65, 91):\n arr[chr(i)] = 0\n arr_[chr(i)] = 0\nfor i in s:\n arr_[i] += 1\nfor i in s:\n if arr[i] == 0:\n k -= 1\n arr[i] += 1\n if arr[i] == arr_[i]:\n k += 1\n if k < 0:\n ans = 'YES'\nprint(ans)\n"}, {"source_code": "n, ka = [int(x) for x in raw_input().split()]\n# print k+\"ll\"\ngates = raw_input()\nopen = dict()\nclose = dict()\ncount = 0\nfor k in gates:\n\tif k not in open:\n\t\topen[k] = count\n\tclose[k] = count\n\tcount += 1\narr = [0 for x in xrange(1000006)]\nfor key in open:\n\tarr[open[key]] += 1\nfor key in close:\n\tarr[close[key]] -= 1\n# print arr[0:n+1]\ncount = 0\nfor i in arr:\n\tcount += i\n\t# print count - ka\n\tif(count > ka):\n\t\tprint \"YES\"\n\t\texit()\nprint \"NO\""}, {"source_code": "n, k = map(int, input().split())\ns = input()\narr = dict()\narr_ = dict()\nans = 'NO'\nfor i in range(65, 91):\n arr[chr(i)] = 0\n arr_[chr(i)] = 0\nfor i in s:\n arr_[i] += 1\nfor i in s:\n if arr[i] == 0:\n k -= 1\n arr[i] += 1\n if arr[i] == arr_[i]:\n k += 1\n if k < 0:\n ans = 'YES'\nprint(ans)\n"}, {"source_code": "n,k=map(int,input().split())\nx=list(input().split())\na=set(x[0])\n\nz=[]\nif(len(a)<=k):\n print(\"NO\")\nelse:\n for j in range(n-1):\n if(x[0][j]==x[0][j+1]):\n continue\n else:\n z.append(x[0][j])\n z.append(x[0][n-1])\n if(len(z)!=len(a)):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "#!/usr/bin/python3\n\ndef main():\n n, g = [int(x) for x in input().split()]\n data = input()\n dats = set(data)\n\n inicio = []\n final = []\n\n for val in dats:\n inicio.append(data.index(val))\n\n for end in range(n-1, 0, -1):\n if data[end] == val:\n final.append(end)\n break\n\n inicio.sort()\n final.sort()\n\n acima = len(inicio) > g\n total = 0\n i, f = 0, 0\n\n if acima:\n acima = False\n\n while (i < len(inicio)):\n if (inicio[i] <= final[f]):\n total += 1\n i += 1\n else:\n total -= 1\n f += 1\n\n if total > g:\n acima = True\n break\n\n\n print(\"YES\" if acima else \"NO\")\n\nif __name__ == \"__main__\": main()\n\n"}, {"source_code": "n, m = raw_input().split()\nentrada = raw_input()\nm = int(m)\nmapa = {}\nc = True\nfor e in entrada:\n\tif mapa.has_key(e):\n\t\tmapa[e][0] += 1\n\t\n\telse:\n\t\tmapa[e] = [1, False]\n\nfor e in entrada:\n\tif not mapa[e][1]:\n\t\tm -= 1\n\t\tmapa[e][0] -= 1\n\t\tif mapa[e][0] == 0:\n\t\t\tm += 1\n\t\t\tmapa[e][1] = False\n\t\tmapa[e][1] = True\n\t\t\n\telse:\n\t\tmapa[e][0] -= 1\n\t\tif mapa[e][0] == 0:\n\t\t\tm += 1\n\t\t\tmapa[e][1] = False\n\t\n\tif m < 0:\n\t\tprint \"NO\"\n\t\tc = False\n\t\tbreak \n\nif c: print \"YES\"\n"}, {"source_code": "arr = list(map(int,input().split()))\ntotal_g = arr[0]\nguards = arr[1]\nclose_gate = dict()\nentry = input()\nchanges = 0\n\nfor i in range(0,total_g):\n if entry[i] in close_gate:\n close_gate[entry[i]] = close_gate[entry[i]] + 1\n else:\n close_gate[entry[i]] = 1\nused_gates = len(close_gate)\n\ncnt_gate = dict()\nflag = 0\nav_grds = guards\nfor i in range(0,total_g):\n if entry[i] not in cnt_gate:\n av_grds = av_grds - 1\n cnt_gate[entry[i]] = 1\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n av_grds = av_grds + 1 \n if av_grds < 1:\n print(\"YES\")\n flag = 1 \n break\n else:\n cnt_gate[entry[i]] = cnt_gate[entry[i]] + 1\n if cnt_gate[entry[i]] == close_gate[entry[i]]:\n av_grds = av_grds + 1 \n \nif flag == 0:\n print(\"NO\")\n "}, {"source_code": "n,k=map(int,input().split())\nlist1=input()\ns=set([])\nf=0\nfor i in range(n):\n if(list1[i] in s):\n if(list1.find(list1[i],i+1)==-1):\n s.remove(list1[i])\n else:\n s.add(list1[i])\n if(len(s)>k):\n f=1\nif(f==1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nd1 = {} \nd2 = {}\nfor i, v in enumerate(s):\n if v not in d1: d1[v] = i\n d2[v] = i\norder = []\nfor v in d1: \n order.append((d1[v], 1)) \n order.append((d2[v], -1)) \norder.sort()\n\ncur = 0\nfor _, v in order:\n cur += v \n if cur > k:\n print(\"YES\")\n break\nelse: \n print(\"NO\")\n"}, {"source_code": "n, k = [int(x) for x in input().split()]\na = [ord(x) for x in list(input())]\nb = [0] * 26\nfor i in a:\n b[i - 65] += 1\nc = [0] * 26\ni = 0\nf = 0\nwhile i != len(a):\n c[a[i] - 65] += 1\n if c[a[i] - 65] == 1:\n k -= 1\n elif c[a[i] - 65] == b[a[i] - 65]:\n k += 1\n i += 1\n if k < 0:\n f = 1\nif f == 1:\n print('YES')\nelse: \n print('NO')"}, {"source_code": "n,r=map(int,input().split())\ns=list(input().split())\nx=[s[0][0]]\ncount=1\nz=s[0][0]\nfor j in range(1,n):\n if(s[0][j]!=z):\n if(s[0][j] not in x):\n x.append(s[0][j])\n z=s[0][j]\n else:\n count+=1\nif(count<=r):\n print(\"NO\")\nelse:\n print(\"YES\")\n "}, {"source_code": "n, k = map(int, input().split())\ns = input()\nl = {}\nfor e in s:\n l[e] = n - 1 - s[::-1].index(e)\ng = []\nfor x in range(n):\n if s[x] in g:\n if x == l[s[x]]:\n k += 1\n g.remove(s[x])\n else:\n g.append(s[x])\n k -= 1\n if k < 0:\n print(\"YES\")\n break\nelse:\n print(\"NO\")"}, {"source_code": "import sys\n\ndef solve(n, k, letters):\n start_positions = {}\n end_positions = {}\n for idx, letter in enumerate(letters):\n if letter not in start_positions:\n start_positions[letter] = idx\n end_positions[letter] = idx + 1\n else:\n end_positions[letter] = idx + 1\n\n inv_end_positions = {}\n inv_start_positions = {}\n for position in start_positions:\n if start_positions[position] in inv_start_positions:\n inv_start_positions[start_positions[position]] += 1\n else:\n inv_start_positions[start_positions[position]] = 1\n\n for position in end_positions:\n if end_positions[position] in inv_end_positions:\n inv_end_positions[end_positions[position]] += 1\n else:\n inv_end_positions[end_positions[position]] = 1\n\n num_open = 0\n for l in range(10**6+1):\n if l in inv_end_positions:\n num_open -= inv_end_positions[l]\n if num_open > k:\n return \"YES\"\n if l in inv_start_positions:\n num_open += inv_start_positions[l]\n return \"NO\"\n\nif __name__ == \"__main__\":\n n, k = map(int, sys.stdin.readline().split())\n letters = list(sys.stdin.readline().strip())\n print solve(n, k, letters)\n"}, {"source_code": "#!/usr/bin/env python3\nfrom sys import stdin, stdout\n\ndef rint():\n return map(int, stdin.readline().split())\n#lines = stdin.readlines()\n\n\nn, k = rint()\ns = input()\nsl = {}\nfor i in range(len(s)):\n if not s[i] in sl:\n sl[s[i]] = [i,i]\n else:\n sl[s[i]][1] = i\ncnt = 0\nfor i in range(len(s)):\n if sl[s[i]][0] == i:\n cnt+=1\n elif sl[s[i]][1] == i:\n cnt-=1\n if cnt > k:\n print(\"YES\")\n exit()\n\nprint(\"NO\")\n\n\n"}, {"source_code": "n, k = map(int, input().split())\ns = input()\nif k >= len(set(s)):\n print(\"NO\")\n quit()\nl = {}\nfor e in set(s):\n l[e] = len(s) - 1 - s[::-1].index(e)\ng = set()\nfor x in range(n):\n if s[x] in g:\n if x >= l[s[x]]:\n k += 1\n g.discard(s[x])\n else:\n g.add(s[x])\n k -= 1\n if k < 0:\n print(\"YES\")\n quit()\nprint(\"YES\" if k < 0 else \"NO\")"}, {"source_code": "#RAVENS\n#TEAM_2\n#ESSI-DAYI_MOHSEN-LORENZO\n#import sys\n#input=sys.stdin.readline\nn,k = map(int,input().split())\ns = input()\nclose = dict()\n\nfor i in range(n-1,-1,-1):\n if close.get(s[i],-1) == -1:\n close[s[i]] = i\n \nOpen = 0\ndoor = dict()\nfor i in range(n):\n if i == close[s[i]]:\n Open-=1\n else:\n if door.get(s[i],-1)==-1:\n Open+=1\n door[s[i]] = 1\n if Open > k:\n print('YES')\n exit()\nprint('NO')\n\n"}, {"source_code": "n, k = map(int, input().split())\ng = tuple(map(ord, input()))\n\ne = [-1] * 91\n\nfor i in range(n):\n e[g[i]] = i\ncurS = 0\nf = 1\nmet = [0] * 91\nfor i in range(n):\n if met[g[i]]: continue\n curS += 1\n met[g[i]] = 1\n if curS > k:\n f = 0\n break\n if i == e[g[i]]:\n curS -= 1\n\nif f: print(\"NO\")\nelse: print(\"YES\")"}], "src_uid": "216323563f5b2dd63edc30cb9b4849a5"} {"nl": {"description": "Monocarp has decided to buy a new TV set and hang it on the wall in his flat. The wall has enough free space so Monocarp can buy a TV set with screen width not greater than $$$a$$$ and screen height not greater than $$$b$$$. Monocarp is also used to TV sets with a certain aspect ratio: formally, if the width of the screen is $$$w$$$, and the height of the screen is $$$h$$$, then the following condition should be met: $$$\\frac{w}{h} = \\frac{x}{y}$$$.There are many different TV sets in the shop. Monocarp is sure that for any pair of positive integers $$$w$$$ and $$$h$$$ there is a TV set with screen width $$$w$$$ and height $$$h$$$ in the shop.Monocarp isn't ready to choose the exact TV set he is going to buy. Firstly he wants to determine the optimal screen resolution. He has decided to try all possible variants of screen size. But he must count the number of pairs of positive integers $$$w$$$ and $$$h$$$, beforehand, such that $$$(w \\le a)$$$, $$$(h \\le b)$$$ and $$$(\\frac{w}{h} = \\frac{x}{y})$$$.In other words, Monocarp wants to determine the number of TV sets having aspect ratio $$$\\frac{x}{y}$$$, screen width not exceeding $$$a$$$, and screen height not exceeding $$$b$$$. Two TV sets are considered different if they have different screen width or different screen height.", "input_spec": "The first line contains four integers $$$a$$$, $$$b$$$, $$$x$$$, $$$y$$$ ($$$1 \\le a, b, x, y \\le 10^{18}$$$)\u00a0\u2014 the constraints on the screen width and height, and on the aspect ratio.", "output_spec": "Print one integer\u00a0\u2014 the number of different variants to choose TV screen width and screen height so that they meet the aforementioned constraints.", "sample_inputs": ["17 15 5 3", "14 16 7 22", "4 2 6 4", "1000000000000000000 1000000000000000000 999999866000004473 999999822000007597"], "sample_outputs": ["3", "0", "1", "1000000063"], "notes": "NoteIn the first example, there are $$$3$$$ possible variants: $$$(5, 3)$$$, $$$(10, 6)$$$, $$$(15, 9)$$$.In the second example, there is no TV set meeting the constraints.In the third example, there is only one variant: $$$(3, 2)$$$."}, "positive_code": [{"source_code": "a,b,x,y = map(int, raw_input().split())\ndef gcd(a,b):\n while b:\n a, b = b, a%b\n return a\n\ng = gcd(x,y)\nx/=g\ny/=g\n\nmn = min(a/x, b/y)\nprint mn\n"}, {"source_code": "import math\na,b,x,y = map(int,input().split(\" \"))\n\ngc = math.gcd(x,y)\n\nx = int(x/gc)\ny = int(y/gc)\n\ncount = 0\nt = min(a//x,b//y)\n\n\nprint(t) "}, {"source_code": "from __future__ import division, print_function\n\nfrom fractions import Fraction\nfrom sys import __stdout__, setrecursionlimit, stdin, stdout\n\n\ninput = lambda: stdin.readline().rstrip()\nprint = lambda *args: stdout.write(' '.join(str(x) for x in args) + '\\n')\n\n\ndef main():\n a, b, x, y = map(int, input().split())\n ratio = Fraction(x, y)\n print(min(a // ratio.numerator, b // ratio.denominator))\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\n\na,b,x,y = map(int,input().split())\n\nd = math.gcd(x,y)\n\nx /= d\ny /= d\n\n\n\nprint(int(min(a//x,b//y)))\n"}, {"source_code": "def gcd(a, b):\n if a == 0:\n return b\n else:\n return gcd(b % a, a)\n\nmax_w, max_h, w, h = map(int, input().split())\ng = gcd(w, h)\nw /= g\nh /= g\n\nans = min(max_w // w, max_h // h)\n\nprint(int(ans))\n"}, {"source_code": "from fractions import gcd\na, b, x, y = map(int, raw_input().split())\ng = gcd(x, y)\nx /= g\ny /= g\nprint min(a / x, b / y)\n"}, {"source_code": "def gcd(a, b):\n if a == 0:\n return b\n return gcd(b % a, a)\n\n\nif __name__ == \"__main__\":\n a, b, x, y = tuple(map(int, input().split()))\n if x / y > a / b: # wiidth is limiting\n print(a//(x//gcd(x,y)))\n else: # height is limiting\n\n print(b//(y//gcd(x,y)))\n"}, {"source_code": "def gcd(a,b):\n if a==0:\n return b\n return gcd(b%a,a)\n \na,b,x,y=map(int,str(input()).strip().split())\nwhile(gcd(x,y)!=1):\n t=gcd(x,y)\n x//=t\n y//=t\nr=a//x\np=b//y\nprint(min(r,p))"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nz=math.gcd(x,y)\nx//=z\ny//=z\nprint(min(a//x,b//y))"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nsum=0\no=math.gcd(x,y)\nx=x/o\ny=y/o\nprint(int(min(a//x,b//y)))\n"}, {"source_code": "from fractions import gcd\nch = input().split(' ')\n\nls = []\n\nfor i in ch:\n ls.append(i)\n\na,b = float(ls[0]), float(ls[1])\nx,y = int(ls[2]), int(ls[3])\n\n\nuc = gcd(x,y)\n\nx = int(x/uc)\ny = int(y/uc)\n#print(x,y)\ntu = a/x\nmau = b/y\n#print(tu,mau)\nif tu >= mau:\n print(int(mau))\nelif tu < mau:\n print(int(tu))\nelse:\n print(0)"}, {"source_code": "from math import *;a,b,c,d=map(int,input().split());e=gcd(c,d);c//=e;d//=e;print(min(a//c,b//d))\n"}, {"source_code": "a, b, x, y = map(int, input().split(\" \"))\ndef gcd(a, b):\n\twhile(a):\n\t\tb = b%a\n\t\ta, b = b, a\n\treturn b\nkek = gcd(x, y)\nx = x/kek\ny = y/kek\nprint(int(min(a/x, b/y)))"}, {"source_code": "import math\n\na,b,x,y = map(int,input().split())\n\nd = math.gcd(x,y)\n\nx /= d\ny /= d\n\n\n\nprint(int(min(a//x,b//y)))\n"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nsum=0\no=math.gcd(x,y)\nx=x/o\ny=y/o\nprint(int(min(a//x,b//y)))\n"}, {"source_code": "#author : SanskarxRawat\nimport math\na,b,x,y=map(int,input().strip().split())\ng=math.gcd(x,y)\nprint(min(a*g//x,b*g//y))"}, {"source_code": "def gcd(a,b):\n while b > 0:\n a, b = b, a % b\n return a\n\na, b, x, y = map(int, input().split())\nx, y = x // gcd(x, y), y // gcd(x, y)\nprint(min(a // x, b // y))"}, {"source_code": "\nfrom math import gcd\na, b, x, y = map(int, input().split())\n\ndiv = gcd(x, y)\nx //= div\ny //= div\n\nprint(min(a // x , b // y))"}, {"source_code": "a = input()\nb = []\nfor i in range(len(a)):\n if a[i] == \" \" :\n c = i\n b.append(c)\n\nd =[a[:int(b[0])]]\nfor j in range(len(b)-1) :\n e = a[int(b[j])+1:int(b[j+1])]\n d.append(e)\nf = a[int(b[len(b)-1]):]\nd.append(f)\nm = int(d[0])\nn = int(d[1])\nx = int(d[2])\ny = int(d[3])\n\ndef hcfnaive(a,b):\n if(b==0):\n return a\n else:\n return hcfnaive(b,a%b)\n\nh = hcfnaive(x,y)#=2\nt = x/h#=1\nu = y/h#=2\nv = n//u#=1\nw = m//t#=3\nif v*t/u <= m and w*u/t <= n:\n first = int(v)#=1\n second = int(w)\n print(min(first,second))\nelif v*t/u > m and w*u/t <= n:\n first = 0\n second = int(w)\n print(second)\nelif v*t/u <= m and w*u/t > n:\n first = int(v)\n second = 0\n print(first)\nelse :\n first = second = 0\n print(first)\n\n"}, {"source_code": "from fractions import Fraction\na,b,x,y = map(int, input().split())\nsx = Fraction(x, y).numerator\nsy = Fraction(x, y).denominator\nprint(int(min(a//sx, b//sy)))"}, {"source_code": "from fractions import Fraction\nimport math as maths\n\n#a/b == x/y\nparams = input()\na, b, x, y=int(params.split(\" \")[0]),int(params.split(\" \")[1]),int(params.split(\" \")[2]),int(params.split(\" \")[3])\n\nif not (x%y) == 0:\n\txMin, yMin = int(str(Fraction(x,y)).split(\"/\")[0]),int(str(Fraction(x,y)).split(\"/\")[1])\nelse:\n\txMin, yMin = x/y, 1\n\noptions=[]\noptions.append(a//xMin)\noptions.append(b//yMin)\n\nprint(int(min(options)))\n"}, {"source_code": "a, b, x, y = map(int, input().split())\n\ndef gcd(x, y):\n\twhile x!=0 and y!=0:\n\t\tif x >= y:\n\t\t\tx = x%y\n\t\telif y > x:\n\t\t\ty = y%x\n\treturn x+y\n\nf = gcd(x,y)\nx /= f\ny /= f\n\nans = int(min(a//x, b//y))\nprint(ans)"}, {"source_code": "#https://codeforces.com/problemset/problem/1041/B\ndef gcd(a,b):\n\tif a%b==0:\n\t\treturn b\n\treturn gcd(b,a%b)\nfrom math import log2 \na,b,x,y=map(int,input().split())\nk=gcd(x,y)\nx=x//k\ny=y//k\nprint(min(a//x,b//y))\n"}, {"source_code": "#https://codeforces.com/problemset/problem/1041/B\ndef gcd(a,b):\n\tif a%b==0:\n\t\treturn b\n\treturn gcd(b,a%b)\nfrom math import log2 \na,b,x,y=map(int,input().split())\nk=gcd(x,y)\nx=x//k\ny=y//k\nprint(min(a//x,b//y))\n"}, {"source_code": "def gcd(a,b):\n\tif b==0:\n\t\treturn a\n\treturn gcd(b,a%b)\na,b,x,y=map(int,raw_input().split())\ng=gcd(x,y)\nx/=g\ny/=g\nprint min(a/x,b/y)\n"}, {"source_code": "def gcd(a, b):\n while b > 0:\n temp = a % b\n a = b\n b = temp\n return a\na,b,x,y = map(int,input().split())\ngc = gcd(x,y)\nx2 = x // gc\ny2 = y // gc\nx4 = a // x2\ny4 = b // y2\n\nif x4 * y2 <= b:\n print(x4)\nelif y4 * x2 <= a:\n print(y4)\nelse:\n print(0)\n\n"}, {"source_code": "import sys\n\n\narray = input().split(\" \")\na,b,x,y = int(array[0]) , int(array[1]), int(array[2]), int(array[3])\n \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 r=a%b\n a,b=b,r\n return a\n \n# p = PGCD_x_y(x,y)\np = pgcd(x,y)\n# print(a,b,x,y)\n# print(p)\nk1 = a//(x/p)\nk2 = b//(y/p)\n \nif k1 < k2 : \n print(int(k1))\nelse : \n print(int(k2))\n"}, {"source_code": "import sys\n\n\n# m > n\ndef gcd(m, n):\n while True:\n if n == 1 or m % n == 0:\n break\n (m, n) = (n, m % n)\n return n\n\ndef main():\n data = sys.stdin.readline().split(' ')\n\n a = int(data[0])\n b = int(data[1])\n x = int(data[2])\n y = int(data[3])\n k = 1\n if x > y:\n k = gcd(x, y)\n else:\n k = gcd(y, x)\n x /= k\n y /= k\n print min(a / x, b / y)\n\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "def gcd(x, y): \n if y == 0:\n return x\n return gcd(y, x%y)\n\na, b, x, y = map(int, raw_input().split())\ng = gcd(x, y)\nx = x / g\ny = y / g\nc = a / x\nd = b / y\nans = 0\nif c * y <= b:\n ans = c\nif d * x <= a:\n ans = max(ans, d)\nprint ans\n"}, {"source_code": "import math\n\ndef gcd(a,b):\n return gcd(b,a % b) if b else a\n\nwhile True:\n try:\n a,b,x,y = map(int,input().strip().split())\n\n tp = gcd(x,y)\n x = x // tp\n y = y // tp\n\n print(min(a // x,b // y))\n except:\n break"}, {"source_code": "from fractions import gcd\na,b,x,y=map(int,raw_input().split())\nu=gcd(x,y)\nx,y=x/u,y/u\nprint min(a/x,b/y)\n"}, {"source_code": "from math import gcd\na,b,x,y=map(int,input().split())\ng = gcd(x,y)\nx/=g\ny/=g\nprint(int(min(a//x, b//y)))"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nk=math.gcd(x,y)\nx=x//k\ny=y//k\nprint(min((a//x),(b//y)))"}, {"source_code": "from math import gcd\n\n\n\na,b,x,y = map(int,input().split())\nz = gcd(x,y)\nz1,z2 = x//z,y//z\nprint(min(a//z1,b//z2))\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)\nfrom sys import stdin, stdout\nmod=(10**9)+7\nmod1=mod-1\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 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 -1\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\ndef comp(x,y):\n if(x[0] b:\n a = a % b\n else:\n b = b % a\n\n return a + b\n\nc = nod(x,y)\nx = x / c\ny = y / c\n\nprint(min(int(a / x), int(b / y)))\n"}, {"source_code": "from fractions import gcd\na,b,x,y=map(int,raw_input().split())\ns=gcd(x,y)\nx=x/s\ny=y/s\nprint min(a/x,b/y)"}, {"source_code": "__author__ = 'Esfandiar'\nimport sys\nfrom math import gcd\ninput=sys.stdin.readline\na,b,x,y = map(int,input().split())\nwhile True:\n t = gcd(x,y)\n if t == 1:break\n x//=t\n y//=t\nprint(min(a//x,b//y))\n \n"}, {"source_code": "a,b,xx,yy=map(int,input().split())\nx=xx\ny=yy\nwhile (x!=0) and (y!=0):\n if x>y:\n x=x%y\n else:\n y=y%x\nprint(min(a//(xx//(x+y)),b//(yy//(x+y))))"}, {"source_code": "def GCD(a, b):\n\twhile (a != 0 and b != 0):\n\t\ta, b = b % a, a\n\treturn max(a, b)\na, b, x, y = map(int, input().split())\nf = GCD(x, y)\nx //= f\ny //= f\nn = min(a, b * x // y)\nprint(n // x)"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nd=math.gcd(x,y)\nprint(min(a*d//x,b*d//y))"}, {"source_code": "def gcd(a,b):\n if b == 0:\n return a\n else: \n return gcd(b, a % b)\n\na,b,x,y=map(int, input().split())\n\nk = gcd(x,y)\nx //= k\ny //= k\n\nprint(min(a//x, b//y))\n"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\ng=math.gcd(x,y)\nx//=g;y//=g\nprint(min(a//x,b//y))\n\n"}, {"source_code": "def gcd(a,b):\n while True:\n r=a%b\n if r==0:\n return b\n a=b\n b=r\na,b,x,y=list(map(int,input().split()))\ng=gcd(x,y)\nx,y=x/g,y/g\nprint(int(min(a//x,b//y)))"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\na, b, x, y = [int(i) for i in input().split()]\nL, R = 0, int(1e20)\ng = gcd(x, y)\nx //= g\ny //= g\nwhile R - L > 1:\n M = (L + R) // 2\n w = M * x\n h = M * y\n if w <= a and h <= b:\n L = M\n else:\n R = M\nprint(L)"}, {"source_code": "def gcd(a, b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b, a % b)\n\na, b, x, y = map(int, input().split())\n\nnum = x // gcd(x, y)\nden = y // gcd(x, y)\n\nans = min(a // num, b // den)\n\nprint(ans)\n \n \n\n"}, {"source_code": "a,b,x,y = map(int, raw_input().split())\n\ndef gcd(x,y):\n if xm):\n print m\nelse:\n print n"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nz=math.gcd(x,y)\nx//=z\ny//=z\nprint(min(a//x,b//y))"}, {"source_code": "from fractions import gcd\na, b, x, y = map(int, raw_input().split())\ng = gcd(x, y)\nx /= g\ny /= g\nprint min(a / x, b / y)\n"}, {"source_code": "def hcf(a,b):\n if b==0:\n return a\n return hcf(b,a%b)\na,b,x,y = list(map(int,input().split()))\nk = hcf(x,y)\nx,y = x//k,y//k\nprint(min(a//x,b//y))\n"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin, stderr\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\ndef main():\n a, b, x, y = map(int, stdin.readline().split())\n d = gcd(x, y)\n x /= d\n y /= d\n res = min(a/x, b/y)\n print(res)\n return 0\n\nif __name__ == '__main__': main()\n"}, {"source_code": "a, b, x, y = map(int, raw_input().split())\n\ndef gcd(a, b):\n if b == 0: return a\n return gcd(b, a % b)\n\ng = gcd(x, y)\nx /= g\ny /= g\n\nnum_width = a / x\nnum_height = b / y\n\nprint min(num_width, num_height)\n"}, {"source_code": "from fractions import gcd\n\n\na, b, x, y = map(int, raw_input().split())\ng = gcd(x, y)\nx /= g\ny /= g\nprint min(a / x, b / y)"}, {"source_code": "from fractions import Fraction\nimport math as maths\n\n#a/b == x/y\nparams = input()\na, b, x, y=int(params.split(\" \")[0]),int(params.split(\" \")[1]),int(params.split(\" \")[2]),int(params.split(\" \")[3])\n\nif not (x%y) == 0:\n\txMin, yMin = int(str(Fraction(x,y)).split(\"/\")[0]),int(str(Fraction(x,y)).split(\"/\")[1])\nelse:\n\txMin, yMin = x/y, 1\n\noptions=[]\noptions.append(a//xMin)\noptions.append(b//yMin)\n\nprint(int(min(options)))\n"}, {"source_code": "def hcf(a,b):\n if b==0:\n return a\n return hcf(b,a%b)\na,b,x,y = list(map(int,input().split()))\nk = hcf(x,y)\nx,y = x//k,y//k\nprint(min(a//x,b//y))\n"}, {"source_code": "line = list(map(int, input().split()))\na = line[0]\nb = line[1]\nx = line[2]\ny = line[3]\n\ndef gcd(a,b):\n while a != 0 and b != 0:\n if a > b:\n a %= b\n else:\n b %= a\n return a + b\n\nj = gcd(x, y)\nx //= j\ny //= j\n\nn = 0\nk1 = a // x\nk2 = b // y\nn = min(k1, k2)\nprint(n)\n"}, {"source_code": "def getMin(a,b):\n if (a == b) :\n return int(b)\n if (a < b):\n return int(a)\n else:\n return int(b) \n\ndef getGCD(a,b):\n while a != 0 and b != 0:\n if a > b:\n a %= b\n else:\n b %= a\n gcd = a + b\n return gcd \n\nnums = [int(x) for x in input().split()]\na = nums[0]\nb = nums[1]\n\nx = nums[2] \ny = nums[3]\n\ngcd = getGCD(x,y)\n\na_x = a // ( x / gcd )\nb_y = b // ( y / gcd )\n\nprint(getMin(a_x, b_y))\n"}, {"source_code": "from fractions import gcd;\na, b, x, y = map(int, input().split())\ng = gcd(x, y)\nx //= g\ny //= g\nprint(min(a // x, b // y))\n"}, {"source_code": "def gcd(a,b):\n if a b:\n a = a - b\n else:\n b = b - a\n return a'''\n\ndef gcd (a, b):\n while b:\n a, b = b, a % b\n return abs(a)\n\na, b, x, y = (int(x) for x in input().split())\nx1 = x\ny1 = y\ni = gcd(x,y)\nx //= i\ny //= i\nprint(min(a//x,b//y))\n\n"}, {"source_code": "from fractions import gcd\na,b,x,y=map(int,raw_input().split())\nz=gcd(x,y)\nx/=z\ny/=z\nprint min(a//x,b//y)"}, {"source_code": "\nfrom math import gcd\na, b, x, y = map(int, input().split())\n\ndiv = gcd(x, y)\nx //= div\ny //= div\n\nprint(min(a // x , b // y))"}, {"source_code": "def gcd(a, b):\n return a if b == 0 else gcd(b, a % b)\n\ndef main():\n a, b, x, y = map(int, input().split(' '))\n maxw = None\n maxh = None\n\n g = gcd(x, y)\n x //= g\n y //= g\n\n maxw = a - a % x\n maxh = b - b % y\n\n if maxw * y <= maxh * x:\n maxh = maxw * y // x\n else:\n maxw = maxh * x // y\n\n if maxw < x or maxh < y:\n print(0)\n else:\n print(int(min((maxw - x) // x + 1, (maxh - y) // y + 1)))\n\nif __name__ == '__main__':\n main()"}, {"source_code": "'''def gcd(a,b):\n while a != b:\n if a > b:\n a = a - b\n else:\n b = b - a\n return a'''\n\ndef gcd (a, b):\n while b:\n a, b = b, a % b\n return abs(a)\n\na, b, x, y = (int(x) for x in input().split())\nx1 = x\ny1 = y\ni = gcd(x,y)\nx //= i\ny //= i\nprint(min(a//x,b//y))\n\n"}, {"source_code": "gcd = lambda a, b: gcd(b, a % b) if b else a\n\na, b, x, y = map(int, input().split())\ng = gcd(x, y)\nprint(min(a // (x // g), b // (y // g)))"}, {"source_code": "import math as m\na,b,c,d = map(int,input().split())\nz = m.gcd(c,d)\nc,d = c//z,d//z\nprint(min(a//c,b//d))"}, {"source_code": "import math as m\na, b, x, y = [int(x) for x in input().split()]\nk = m.gcd(x,y)\nxn = x//k\nyn = y//k\nprint(min(a//xn, b//yn))"}, {"source_code": "#!/usr/bin/env python\n\nfrom sys import stdin, stderr\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\ndef main():\n a, b, x, y = map(int, stdin.readline().split())\n d = gcd(x, y)\n x /= d\n y /= d\n res = min(a/x, b/y)\n print(res)\n return 0\n\nif __name__ == '__main__': main()\n"}, {"source_code": "\n\ndef read():\n return list(map(int, input().split()))\na, b, c, d = read()\ndef gcd(x, y, big = False):\n if not big:\n sum = x + y\n x = max(x, y)\n y = sum - x\n if y == 0:\n return x\n else:\n return gcd(y, x % y, True)\ne = gcd(c, d)\nc = c // e\nd = d // e\n\nprint(str(min(a // c, b // d)))\n\n\n"}, {"source_code": "import math\ns = input().split()\na = int(s[0])\nb = int(s[1])\nx = int(s[2])\ny = int(s[3])\ng = math.gcd(x, y)\nx //= g\ny //= g\nprint(min(a//x, b//y))"}, {"source_code": "import sys\ninput = sys.stdin.readline\nfrom collections import *\n\ndef gcd(x, y):\n while y:\n x, y = y, x%y\n return x\n\na, b, x, y = map(int, input().split())\nG = gcd(x, y)\nx //= G\ny //= G\nprint(min(a//x, b//y))"}, {"source_code": "from fractions import gcd\nw, h, x, y = map(int, input().split())\n'''\ndef gcd(a, b):\n if a < b:\n x = a \n a = b \n b = x\n while True:\n mod = a % b\n \n if mod == 0:\n print(b)\n return b\n break\n a = b \n b = mod \n''' \n\nz = gcd(x, y)\nx = int(x / z)\ny = int(y / z)\nwidths = int(w/x)\nheights = int(h/y)\nif widths > heights:\n print(heights)\nelse:\n print(widths)\n"}, {"source_code": "import math\n\na,b,x,y = map(int,input().split())\n\nd = math.gcd(x,y)\n\nx /= d\ny /= d\n\n\n\nprint(int(min(a//x,b//y)))\n"}, {"source_code": "def gcd(a, b):\n if a == 0:\n return b\n else:\n return gcd(b % a, a)\n\nmax_w, max_h, w, h = map(int, input().split())\ng = gcd(w, h)\nw /= g\nh /= g\n\nans = min(max_w // w, max_h // h)\n\nprint(int(ans))\n"}, {"source_code": "from fractions import gcd;\n\na,b,x,y = map(int, raw_input().split())\n\nlc = gcd(x,y); ans = 0\n\nlcx = x / lc; lcy = y / lc\n\ngx = a - x; gy = b - y;\n\n#print lcx, lcy, gx, gy\n\ng1 = 0; g2 = 0\n\nif lc == 1 and (x > a or y > b):\n\n\tprint 0\n\t\nelse:\n\n\tprint min(a/lcx, b/lcy)\n\n#print g1, g2, gx, lcx, gy, lcy\n\n"}, {"source_code": "w,h,x,y = map(int,raw_input().split())\n\nw2=(x*h)/y\n\ndef gcd(x,y):\n\tif(y==0):\n\t\treturn x\n\n\treturn gcd(y,x%y)\n\ngc=gcd(x,y)\nx/=gc\ny/=gc\n\nlef=0\nrig=h/y\nans=0\n# print(gc,rig)\nwhile(lef<=rig):\n\tmid=(lef+rig)/2\n\ttemp=(x*mid)\n\tif(temp<=w):\n\t\tans=mid\n\t\tlef=mid+1\n\telse:\n\t\trig=mid-1\n\nprint(ans)\n"}], "negative_code": [{"source_code": "import math\na,b,x,y=map(int,input().split())\nsum=0\no=math.gcd(x,y)\nx=x/o\ny=y/o\nprint(min(a//x,b//y))\n"}, {"source_code": "def gcd(a, b):\n while b > 0:\n temp = a % b\n a = b\n b = temp\n return a\na,b,x,y = map(int,input().split())\ngc = gcd(x,y)\nx2 = x // gc\ny2 = y // gc\nx4 = a // x2\ny4 = a // y2\nif x4 * y2 <= b:\n print(x4)\nelif y4 * x2 <= a:\n print(y4)\nelse:\n print(0)\n\n"}, {"source_code": "\n\na,b,x,y=[int(el) for el in input().split()]\n\nxx=x\nyy=y\nwhile xx%yy!=0 and yy%xx!=0:\n if xx>yy:\n xx=xx-yy*int(xx/yy)\n else:\n yy=yy-xx*int(yy/xx)\n\nx=x/yy\ny=y/yy\n\nif ay:\n x=x-y\nwhile y>x:\n y=y-x\n\nif ayy:\n xx=xx-yy\nwhile yy>xx:\n yy=yy-xx\n\nx=int(x/yy)\ny=int(y/yy)\n\nif ay):\n\tans = (a//x)\n\tprint(ans)\nelse:\n\tans = (b//y);\n\tprint(ans)"}, {"source_code": "a,b,x,y = input().split()\na=int(a)\nb=int(b)\nx=int(x)\ny=int(y)\nc=1\ns=0\nf=[]\nfor d in range (1,10**9):\n\tif (((x%d)==0) and (y%d==0)):\n\t\tf.append(d)\n\tif ((d>x) or (d>y)):\n\t\tbreak\nprint (f)\nx = (x/f[-1])\ny = (y/f[-1])\nprint (x)\nprint (y)\nwhile ((a>=(x*c)) and (b>=(y*c))):\n\tc+=1\n\ts+=1\nprint (s)"}, {"source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\nx = int(s[2])\ny = int(s[3])\na1 = max(a, b)\nb1 = min(a, b)\nx1 = max(x, y)\ny1 = min(x, y)\na1 -= a1 % x1\nb1 -= b1 % y1\nprint(int(min(a1/x1, b1/y1)))"}, {"source_code": "import math\ns = input().split()\na = int(s[0])\nb = int(s[1])\nx = int(s[2])\ny = int(s[3])\na1 = max(a, b)\nb1 = min(a, b)\nx1 = max(x, y) // math.gcd(x, y)\ny1 = min(x, y) // math.gcd(x, y)\na1 -= a1 % x1\nb1 -= b1 % y1\nprint(int(min(a1/x1, b1/y1)))"}, {"source_code": "a,b,x,y=map(int,input().split())\ndef hcfnaive(a,b): \n if(b==0): \n return a \n else: \n return hcfnaive(b,a%b) \n\ns= hcfnaive(x,y)\nh=x//s\nc=y//s\nk=a//h\nz=b//c\nprint(k)"}, {"source_code": "a,b,x,y=map(int,input().split())\ndef hcfnaive(a,b): \n if(b==0): \n return a \n else: \n return hcfnaive(b,a%b) \n\ns= hcfnaive(x,y)\nh=x//s\nc=y//s\nk=a//h\nz=b//c\nif(k!=0 and z!=0):\n print(k)\nelse:\n print(0)"}, {"source_code": "import math\n \na,b,x,y = map(int,input().split())\n \nx//=math.gcd(x,y)\ny//=math.gcd(x,y)\n \nr1 = a//x\nr2 = b//y\n \nif r1 < r2:print(r1)\nelse: print(r2)"}, {"source_code": "import math\n\na,b,x,y = map(int,input().split())\n\nx//=math.gcd(x,y)\ny//=math.gcd(x,y)\n\nr1 = a/x\nr2 = b/y\n\nif r1 < r2:print(r1)\nelse: print(r2)"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nz=math.gcd(x,y)\nx=x//z\ny=y//z\nif(x>a or y>b):\n\tprint(0)\nelse:\n\tprint(max(a,b)//max(x,y))"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nz=math.gcd(x,y)\nflag=0\nif(z>1):\n\twhile 1:\n\t\tif(x%z!=0 or y%z!=0):\n\t\t\tbreak\n\t\telse:\n\t\t\tx=x//z\n\t\t\ty=y//z\nif(x>a or y>b):\n\tprint(0)\n\tflag=1\nif(flag==0):\n\tprint(max(a,b)//max(x,y))"}, {"source_code": "import math\na,b,x,y=map(int,input().split())\nz=math.gcd(x,y)\n# print(z)\nflag=0\nif(z>1):\n\twhile 1:\n\t\tif(x%z!=0 or y%z!=0):\n\t\t\tbreak\n\t\telse:\n\t\t\tx=x//z\n\t\t\ty=y//z\n\t# print(x,y)\nif(x>a or y>b):\n\tprint(0)\n\tflag=1\nif(flag==0):\n\tif(min(a,b)>max(x,y)):\n\t\tprint(min(a,b)//max(x,y))\n\telse:\n\t\tprint(max(a,b)//max(x,y))\n"}, {"source_code": "a,b,x,y=map(int,input().split())\nprint(min(a//x,b//y))"}, {"source_code": "def findNOD(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)\n\ninp = input().split()\na = int(inp[0])\nb = int(inp[1])\nx = int(inp[2])\ny = int(inp[3])\n\nnodOfXY = findNOD(x, y)\nx = x//nodOfXY\ny = y//nodOfXY\n\nprint(min((max(a,b)//max(x,y)), min(a,b)//min(x,y)))\n \n"}, {"source_code": "def findNOD(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)\n\ninp = input().split()\na = int(inp[0])\nb = int(inp[1])\nx = int(inp[2])\ny = int(inp[3])\n\nnodOfXY = findNOD(x, y)\nx = x//nodOfXY\ny = y//nodOfXY\n\nprint(max(a,b)//max(x,y))\n \n"}, {"source_code": "a,b,x,y = map(int,input().split())\nprint(min(a//x,b//y))"}, {"source_code": "while True:\n try:\n n = eval(input().strip())\n\n a = list(map(int,input().strip().split()))\n\n a = sorted(a)\n\n res = 0\n for i in range(1,n):\n res += a[i] - a[i - 1] - 1\n\n print(res)\n except:\n break"}, {"source_code": "def gcd(a, b):\n x = min(a, b)\n y = max(a, b)\n\n while x > 0:\n t = y\n y = x\n x = t % y\n \n return y\n\na, b, x, y = map(int, input().split())\nk = gcd(x, y)\nwhile(k > 1):\n x //= k\n y //= k\n k = gcd(x, y)\nprint(k, x, y)\n\nprint(min(a//x, b//y))\n"}, {"source_code": "s=input()\nlis=s.split(\" \")\na=int(lis[0])//int(lis[2])\nb=int(lis[1])//int(lis[3])\nprint(min(a,b))"}, {"source_code": "a,b,c,d=map(int,input().split())\nif d>c:\n c,d=d,c\nc1,d1=c,d\ne=d\nwhile e!=0:\n c,e,d=e,c%d,c\nc1=c1//c\nd1=d1//c\nprint(max(a,b)//c1)"}, {"source_code": "import math\na,b,x,y=list(map(int,input().split()))\ng=math.gcd(x,y)\nprint(min(a//x,b//y))\n"}, {"source_code": "a,b,x,y=map(int,input().split())\nprint(min(int(a/x),int(b/y)))"}, {"source_code": "def gcd(a, b):\n while b > 0:\n c = a\n a = b\n b = c % b\n return a\n\nnums = list(map(int, input().split()))\na = nums[0]\nb = nums[1]\nx = nums[2]\ny = nums[3]\nh = min(b, (a * y) // x)\nw = min(a, (b * x) // y)\nd = gcd(x, y)\nans = min(w // x, h // y)\nprint(ans)\n"}, {"source_code": "def gcd(a, b):\n while b > 0:\n c = a\n a = b\n b = c % b\n return a\n\nnums = list(map(int, input().split()))\na = nums[0]\nb = nums[1]\nx = nums[2]\ny = nums[3]\nh = min(b, (a * y) // x)\nw = min(a, (b * x) // y)\nd = gcd(x, y)\nans = min(w / x, h / y)\nprint(ans)\n"}, {"source_code": "from math import gcd\nfrom functools import reduce\nh, w, x, y = map(int, input().split())\na = str(x) + ':' + str(y)\ndef solve(ratio):\n numbers = [int(i) for i in ratio.split(':')]\n denominater = reduce(gcd, numbers)\n solved = [i / denominater for i in numbers]\n return ':'.join(str(int(i)) for i in solved)\na = solve(a)\nx, y = map(int, a.split(':'))\nprint(min(w // x, h // y))\n"}, {"source_code": "def GCD(a, b):\n\twhile (a != 0 and b != 0):\n\t\ta, b = b % a, a\n\treturn max(a, b)\na, b, x, y = map(int, input().split())\nf = GCD(x, y)\nx //= f\nn = min(a, b * x // y)\nprint(n // x)"}, {"source_code": "a,b,x,y = map(int,input().split())\nif y > x:\n tmp = y\n y = x\n x = tmp\nmasx = x\nmasy = y\nwhile x % y:\n x, y = y, x % y\nx, y = masx//y, masy//y\nif a/x >= b/y:\n print(b//y)\nelse :\n print(a//x)"}, {"source_code": "a,b,x,y = map(int,input().split())\nif y > x:\n tmp = y\n y = x\n x = tmp\nmasx = x\nmasy = y\nwhile x % y:\n x, y = y, x % y\nx, y = masx//y, masy//y\nif a//x > b//y:\n print(b//y)\nelse :\n print(a//x)"}, {"source_code": "import math\n\narr = [int(s) for s in input().split()]\na = arr[0]\nb = arr[1]\nx = arr[2]\ny = arr[3]\n\ng = math.gcd(x, y)\n\nx /= g\ny /= g\n\nw = a//x\nh = b//y\n\nif w > h :\n print(h)\nelse:\n print(w)\n"}, {"source_code": "def gcd(a, b):\n if a == 0:\n return b\n else:\n return gcd(b % a, a)\n\nmax_w, max_h, w, h = map(int, input().split())\ng = gcd(w, h)\nw /= g\nh /= g\n\nans = min(max_w // w, max_h // h)\n\nprint(ans)\n"}, {"source_code": "a,b,x,y=[int(x) for x in input().split()]\nh=0\nw=0\nk=0\nwhile h<=a and w<=b :\n\th+=x\n\tw+=y\n\tk+=1\nprint(k-1)\n"}, {"source_code": "a,b,x,y=[int(x) for x in input().split()]\nh=0\nw=0\nk=0\nwhile h b:\n a %= b\n else:\n b %= a\n gcd = a + b\n return gcd \n\nnums = [int(x) for x in input().split()]\na = nums[0]\nb = nums[1]\n\nx = nums[2] \ny = nums[3]\n\ngcd = getGCD(x,y)\n\na_x = a // ( x / gcd )\nb_y = b // ( y / gcd )\n\nprint(getMin(a_x, b_y))\n"}, {"source_code": "def gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\na, b, x, y = [int(i) for i in input().split()]\nL, R = 0, int(1e18)\ng = gcd(x, y)\nx //= g\ny //= g\nwhile R - L > 1:\n M = (L + R) // 2\n w = M * x\n h = M * y\n if w <= a and h <= b:\n L = M\n else:\n R = M\nprint(L)"}, {"source_code": "w, h, x, y = map(int, input().split())\nwidths = int(w/x)\nheights = int(h/y)\nif widths > heights:\n print(heights)\nelse:\n print(widths)\n"}, {"source_code": "import fractions\nstring =raw_input()\nA = string.split()\na=int(A[0])\nb=int(A[1])\nx=int(A[2])\ny=int(A[3])\nm= max(x,y)\ncnt=0\n# def hcfnaive(a,b): \n# if(b==0): \n# return a \n# else: \n# return hcfnaive(b,a%b) \n# if (x%hcfnaive(x,y) ==0 ) and (y%hcfnaive(x,y) ==0):\n# ucln = hcfnaive(x,y)\n# x = x/ucln\n# y = y/ucln\nfor i in range (1, m):\n if x*i<= a:\n if y*i<=b:\n cnt = cnt+1\nprint cnt \n"}, {"source_code": "import fractions\nstring =raw_input()\nA = string.split()\na=int(A[0])\nb=int(A[1])\nx=int(A[2])\ny=int(A[3])\nm= max(x,y)\ncnt=0\n# if fractions.gcd(x,y)%x ==0 AND fractions.gcd(x,y)%y ==0:\n# x = fractions.gcd(x,y)/x\n# y = fractions.gcd(x,y)/y\nfor i in range (1, m):\n if x*i<= a:\n if y*i<=b:\n cnt = cnt+1\nprint cnt \ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a"}, {"source_code": "a,b,x,y=map(int,raw_input().split(\" \"))\n\ndef gcc_(a,b):\n\tif b==0 :\n\t\treturn a\n\telse:\n\t\treturn gcc_(b,a%b)\ndiv = gcc_(x,y)\n\n\n\nprint min(a/x/div,b/y/div)"}, {"source_code": "#import sys; sys.stdin = open('input.txt')\n\n\ndef cin(obj=list, type=int, sep=' '):\n return obj(map(type, input().split(sep)))\n\n\na, b, x, y = cin()\n\nprint(min(a // x, b // y))"}, {"source_code": "def nod(a, b):\n\ta = int(a)\n\tb = int(b)\n\tif(a > b):\n\t\ta, b = b, a\n\tif(b % a == 0):\n\t\treturn a\n\telse:\n\t\twhile(b != 0):\n\t\t\tif(a > b):\n\t\t\t\ta, b = b, a\n\t\t\tx = b // a\n\t\t\tb -= x * a\n\t\treturn a\n\ns = input()\ns = s.split()\n\na = int(s[0])\nb = int(s[1])\nx = int(s[2])\ny = int(s[3])\n\nq = nod(x, y)\nx = x // q\ny = y //q\n\nif(a > b):\n\ta, b = b, a\n\tx, y = y, x\n\ni = a\n\nwhile i * y // x > b:\n\ti -= x\n\n\n\nprint(i // x)"}, {"source_code": "arr = list(input().split(' '))\na, b, x, y = int(arr[0]), int(arr[1]), int(arr[2]), int(arr[3])\nres = 0\ncur_x, cur_y = x, y\nres = min(a//x, b//y)\nprint(res)\n##print(a, b, x, y)\n##print(x/y)\n"}, {"source_code": "a, b, x, y = map(int, input().split())\nprint(min (a // x, b // y))"}, {"source_code": "\ndef gcd(a, b):\n while (b != 0):\n a, b = b, a % b\n return a\na, b, x, y = map(int, input().split())\nt = gcd(x, y)\nprint(min (a // t, b // t))"}, {"source_code": "def check(A,B,X,Y,mid):\n if(X*mid <= A and Y*mid <= B) :\n return True\n return False\ndef gcd(a,b) :\n \n if(a==0) :\n return b;\n \n return gcd(b%a,a);\n \na=list(map(int,input().strip().split(' ')))\nA,B,X,Y= a[0],a[1],a[2],a[3] \nlw = 1\nhg = 10**20\ng=gcd(X,Y)\nX=X//g\nY=Y//g\nwhile lw <=hg :\n \n mid = (lw+hg)//2\n flag = check(A,B,X,Y,mid)\n #print(mid,flag)\n if(flag==True) :\n if(mid==0):\n print(\"0\")\n break ;\n if(check(A,B,X,Y,mid+1)==False):\n print(mid)\n break ;\n if(flag==True) :\n lw=mid+1\n else :\n hg=mid-1\n\n"}, {"source_code": "a = input()\nb = []\nfor i in range(len(a)):\n if a[i] == \" \" :\n c = i\n b.append(c)\n\nd =[a[:int(b[0])]]\nfor j in range(len(b)-1) :\n e = a[int(b[j])+1:int(b[j+1])]\n d.append(e)\nf = a[int(b[len(b)-1]):]\nd.append(f)\nm = int(d[0])\nn = int(d[1])\nx = int(d[2])\ny = int(d[3])\n\ndef hcfnaive(a,b):\n if(b==0):\n return a\n else:\n return hcfnaive(b,a%b)\n\nh = hcfnaive(x,y)#=2\nt = x/h#=1\nu = y/h#=2\nv = n//u#=1\nw = m//t#=3\nif v*t/u <= m :\n first = int(v)#=1\nelse:\n first = 0\nif w*u/t <= n:\n second = int(w)\nelse:\n second = 0\nif first != 0 and second != 0:\n print(min(first,second))\nelif first != 0 and second == 0:\n print(first)\nelif second != 0 and first == 0:\n print(second)"}, {"source_code": "array = input().split(\" \")\na,b,x,y = int(array[0]) , int(array[1]), int(array[2]), int(array[3])\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 r=a%b\n a,b=b,r\n return a\n \n# p = PGCD_x_y(x,y)\np = pgcd(x,y)\n# print(a,b,x,y)\n# print(p)\nk1 = a//(x/p)\nk2 = b//(y/p)\n \nif k1 < k2 : \n print(k1)\nelse : \n print(k2)\n"}, {"source_code": "import math\n\na,b,x,y=map(int,input().split())\n\nx=x//math.gcd(x,y)\n\ny=y//math.gcd(x,y)\n\nprint(min(a//x,b//y))"}, {"source_code": "from fractions import Fraction\na, b, x, y = list(map(int, input().split()))\n\npocz = 1\nkon = 1e18+5\nsrd = 0\nf = Fraction(x, y)\nk = -1\n\nwhile kon - pocz > 1:\n srd = (kon + pocz) // 2\n\n if f.numerator * srd <= a and f.denominator * srd <= b:\n if pocz == srd:\n print(int(pocz))\n exit()\n pocz = srd\n else:\n kon = srd\n\nif srd == 2:\n if f.numerator * 2 <= a and f.denominator * 2 <= b:\n pass\n elif f.numerator <= a and f.denominator <= b:\n srd = 1\n else:\n srd = 0\n\nprint(int(srd))"}, {"source_code": "from fractions import Fraction\na, b, x, y = list(map(int, input().split()))\n\npocz = 1\nkon = 1e18+5\nsrd = 0\nf = Fraction(x, y)\n\nwhile kon - pocz > 1:\n srd = (kon + pocz) // 2\n\n if f.numerator * srd <= a and f.denominator * srd <= a:\n pocz = srd\n else:\n kon = srd\n\nif srd == 2:\n if f.numerator * 2 <= a and f.denominator * 2 <= a:\n pass\n elif f.numerator <= a and f.denominator <= a:\n srd = 1\n else:\n srd = 0\n\nprint(int(srd))"}, {"source_code": "from fractions import Fraction\na, b, x, y = list(map(int, input().split()))\n\npocz = 1\nkon = 1e18+5\nsrd = 0\nf = Fraction(x, y)\n\nwhile kon - pocz > 1:\n srd = (kon + pocz) // 2\n\n if f.numerator * srd <= a and f.denominator * srd <= a:\n pocz = srd\n else:\n kon = srd\n\nif srd == 2:\n if f.numerator * 2 <= a and f.denominator * 2 <= a:\n pass\n elif f.numerator * 2 <= a and f.denominator * 2 <= a:\n srd = 1\n else:\n srd = 0\n\nprint(int(srd))"}, {"source_code": "a,b,x,y = map(int,input().split())\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef simplify_fraction(numer, denom):\n common_divisor = gcd(numer, denom)\n (reduced_num, reduced_den) = (numer / common_divisor, denom / common_divisor)\n\n if reduced_den == 1:\n return [1,1]\n elif common_divisor == 1:\n return [numer, denom]\n else:\n return [reduced_num, reduced_den]\n\nsimplified = simplify_fraction(x,y)\nprint(int(min(a//simplified[0],b//simplified[1])))"}, {"source_code": "import heapq as hq\nimport math\n\na, b, x, y = [int(i) for i in input().split(\" \")]\ng = math.gcd(x, y)\nx /= g\ny /= g\nprint(min(a // x, b // y))"}, {"source_code": "\n\ndef read():\n return list(map(int, input().split()))\na, b, c, d = read()\ndef hcf(x, y):\n b = max(x, y)\n s = min(x, y)\n yu_mul = 1\n while (True):\n yu = b % s\n if yu == 0: return yu_mul * s\n if yu == 1: break\n if (b % yu == 0) and (s % yu == 0):\n b = b // yu\n s = s // yu\n yu_mul *= yu\n continue\n break\n return yu_mul\ne = hcf(c, d)\nc = c // e\nd = d // e\n\nprint(str(min(a // c, b // d)))\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Dec 23 14:56:55 2018\n\n@author: QuocBinh\n\"\"\"\nimport math\n\na,b,x,y=map(int,input().split())\nt=math.gcd(x,y)\nx=x//t\ny=y//t\nprint(min(x,y))"}, {"source_code": "def gcd(a,b):\n if b == 0:\n return a\n else: \n return gcd(b, a % b)\n\na,b,x,y=map(int, input().split())\n\nk = gcd(x,y)\nx /= k\ny /= k\n\nprint(min(a//x, b//y))\n"}, {"source_code": "def nod(a, b):\n if b == 0:\n return a\n return nod(b, a % b)\n\n[a, b, x, y] = [int(i) for i in input().split()]\nn = nod(x, y)\nx /= n\ny /= n\nprint(max(a // x, b // y))"}, {"source_code": "def nod(a, b):\n if b == 0:\n return a\n return nod(b, a % b)\n\n[a, b, x, y] = [int(i) for i in input().split()]\nn = nod(x, y)\nx /= n\ny /= n\nprint(int(max(a // x, b // y)))"}, {"source_code": "def nod(a, b):\n if b == 0:\n return a\n return nod(b, a % b)\n\n[a, b, x, y] = [int(i) for i in input().split()]\nn = nod(x, y)\nx /= n\ny /= n\nprint(min(a // x, b // y))"}, {"source_code": "import sys\n\nline1 = sys.stdin.readline().strip().split()\narr = []\nfor i in line1:\n arr.append(int(i))\n#print(arr)\na = arr[0]\nb = arr[1]\nx = arr[2]\ny = arr[3]\n#count = 0\n#for w in range(1,a+1):\n# for h in range(1,b+1):\n# if y*w == x*h:\n# #print(w, h)\n# count += 1\n#print(count)\nflag = 1\nw = 0\nww = 0\nhh = 0\nwhile flag == 1 and w <= a:\n w+=1\n ww = w\n for h in range(1,b+1):\n hh = h\n if y*w == x*h:\n flag = 0\n#print(w, h)\nprint(a/w)\n \n"}, {"source_code": "import sys\n\nline1 = sys.stdin.readline().strip().split()\narr = []\nfor i in line1:\n arr.append(int(i))\n#print(arr)\na = arr[0]\nb = arr[1]\nx = arr[2]\ny = arr[3]\n#count = 0\n#for w in range(1,a+1):\n# for h in range(1,b+1):\n# if y*w == x*h:\n# #print(w, h)\n# count += 1\n#print(count)\nflag = 1\nw = 0\nww = 0\nhh = 0\nwhile flag == 1 and w <= a:\n w+=1\n ww = w\n for h in range(1,b+1):\n hh = h\n if y*w == x*h:\n flag = 0\n#print(w, h)\nprint(int(round(a/w, 0)))\n \n"}, {"source_code": "import sys\n\nline1 = sys.stdin.readline().strip().split()\narr = []\nfor i in line1:\n arr.append(int(i))\n#print(arr)\na = arr[0]\nb = arr[1]\nx = arr[2]\ny = arr[3]\n#count = 0\n#for w in range(1,a+1):\n# for h in range(1,b+1):\n# if y*w == x*h:\n# #print(w, h)\n# count += 1\n#print(count)\nflag = 1\nw = 0\nww = 0\nhh = 0\nwhile flag == 1:\n w+=1\n ww = w\n for h in range(1,b+1):\n hh = h\n if y*w == x*h:\n flag = 0\n#print(w, h)\nprint(a/w)\n \n"}, {"source_code": "import sys\nfrom fractions import gcd\n\nline1 = sys.stdin.readline().strip().split()\narr = []\nfor i in line1:\n arr.append(int(i))\na = arr[0]\nb = arr[1]\nx = arr[2]\ny = arr[3]\ng = gcd(x,y)\nprint(g)\nx /= g;\ny /= g;\nprint(x, y)\nprint(min(int(a/x), int(b/y)))\n \n"}, {"source_code": "import math\nG = math.gcd\nF = math.floor\nimport decimal\nD = decimal.Decimal\nl1 = [int(x) for x in input().split()]\na,b,x1,y1 = l1[0],l1[1],l1[2],l1[3]\nx = D(min(x1,y1)/G(x1,y1))\ny = D(max(x1,y1)/G(x1,y1))\nwidth = min(a,b)\nlength = max(a,b)\n#print(width,length)\nif lengthsecond1:\n print(second)\n else:\n print(first)\n\n"}, {"source_code": "import math\nG = math.gcd\nl1 = [int(x) for x in input().split()]\na,b,x1,y1 = l1[0],l1[1],l1[2],l1[3]\nx = min(x1,y1)\ny = max(x1,y1)\nwidth = min(a,b)*G(x,y)\nlength = max(a,b)*G(x,y)\n#print(width,length)\nif length 1:\n n /= i\n if n != 1:\n print(1)\n exit(0)\n mn = i\nif mn != -1:\n print(mn)\nelse:\n print(n)\n"}, {"source_code": "import math\ndef isPrime(n) : \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\nn = int(input())\nr=0\np=-1\nif isPrime(n) or n==1:\n print(n)\n exit()\nfor i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n p=i\n break\n\nwhile n%p==0:\n n=n//p \nif n==1:\n print(p)\nelse:\n print(1)"}, {"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\ndef is_prime(n):\n if n == 1: return False\n\n for k in range(2, int(math.sqrt(n)) + 1):\n if n % k == 0:\n return False\n\n return True\ndef prime_factorize(n):\n if n == 1:\n return [1]\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\nn = inp()\nm = set(prime_factorize(n))\nif is_prime(n):\n print(n)\nelif len(m) == 1:\n print(list(m)[0])\nelse:\n print(1)"}, {"source_code": "import math\nx=int(input())\ny=x\nif x==1:\n print(1)\n exit()\nlol=[]\nfor i in range(2,int(math.sqrt(x))+1):\n if x%i==0:\n while x%i==0:\n x//=i\n lol.append(i)\nif x>=2:\n lol.append(x)\n \nif len(lol)==1:\n print(lol[0])\nelse:\n print(1)"}, {"source_code": "from math import *\nn = int(input())\nflag1 = False\nfor i in range(2, int(sqrt(n)+1)):\n\tif n%i ==0:\n\t\tfact = i\n\t\tflag1 = True\n\t\tbreak\nif flag1==False:\n\tprint(n)\nelse:\n\tflag = False\n\tval = fact\n\tfor i in range(42):\n\t\tif val == n:\n\t\t\tflag = True\n\t\telif val <=10**12:\n\t\t\tval = val*fact\n\tif flag == True:\n\t\tprint(fact)\n\telse:\n\t\tprint(1) \n"}, {"source_code": "import math\ndef findFirstDelimeter(n):\n\tvalue = 1\n\tfor i in range(int(math.sqrt(n)))[1::1]:\n\t\tif n%(i+1) == 0:\n\t\t\tif value == 1:\n\t\t\t\tvalue = i+1\n\t\t\t\twhile(n%value == 0):\n\t\t\t\t\tn /= value\n\t\t\tif n != 1:\n\t\t\t\treturn 1\n\t\t\telse:\n\t\t\t\treturn value\n\treturn n\nn = int(input())\nprint(findFirstDelimeter(n))"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n=int(input())\n orig=n\n x=int(n**0.5)\n count=0\n divisor=-1\n for i in range(2,x+1):\n if n%i==0:\n divisor=i\n while n%i==0:\n n=n//i\n count+=1\n break\n if count==0:\n print(n)\n else:\n if n==1:\n print(divisor)\n else :\n print(1)\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, 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\n\ndef main():\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 def primeFactors(n): \n pf=[]\n # Print the number of two's that divide n \n while n % 2 == 0: \n pf.append(2) \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 pf.append(int(i)) \n n = n /i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n pf.append(int(n))\n return pf\n for _ in range(1):\n n=ri()\n nf=0\n c=0\n z=primeFactors(n)\n nf=len(set(z))\n if len(z)!=1:\n if nf==1:\n print(z[0])\n else:\n print(1)\n else:\n print(n)\n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \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 = int(input())\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n while n % i == 0:\n n //= i\n if n == 1:\n print(i)\n else:\n print(1)\n break\n i += 1\nelse:\n print(n)"}, {"source_code": "import math\nn=int(input())\narr=[]\ni=2\nwhile i*i<=n:\n if (i*i)!=n and n%i==0:\n arr.append(i)\n arr.append(n//i) \n elif i*i==n:arr.append(i)\n i+=1\n#print(arr)6\n \nans=0\nif len(arr)==0:print(n)\nelse:\n for j in arr:\n ans=math.gcd(j,ans)\n print(ans)\n"}, {"source_code": "n=int(input())\nres=n\nresult=[]\nfrom math import gcd\nfor i in range(2,min(n,int(n**0.5)+3)):\n if n%i==0:\n res=gcd(i,res)\n res=gcd(n//i,res)\nprint(res)"}, {"source_code": "from __future__ import division, print_function\ndef main():\n n=int(input())\n orig=n\n x=int(n**0.5)\n count=0\n divisor=-1\n for i in range(2,x+1):\n if n%i==0:\n divisor=i\n while n%i==0:\n n=n//i\n count+=1\n break\n if count==0:\n print(n)\n else:\n if n==1:\n print(divisor)\n else :\n print(1)\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": "n=int(input())\ni=2\nl=[]\nwhile(i*i<=n):\n if(n%i==0):\n l.append(i)\n while(n%i==0):\n n=n//i\n i+=1\nif(n!=1):\n l.append(n)\nif(len(l)>1):\n print(1)\nelif(len(l)==1):\n print(l[0])\nelif(n==1):\n print(1)"}, {"source_code": "import math\n\ndef main():\n n = int(input())\n g = 0\n for i in range(1,int(n**0.5)+1):\n if n%i == 0:\n if i > 1:\n g = math.gcd(max(g,i),min(g,i))\n g = math.gcd(max(g,n//i),min(g,n//i))\n\n print(g)\n\nmain()\n"}, {"source_code": "import math\nn = int(input())\nx = n\nfor i in range(2, int(n**0.5)+1):\n if n%i==0:\n x = math.gcd(x, i)\n x = math.gcd(x,int(n/i))\nprint(x)\n"}, {"source_code": "import sys\ninput=sys.stdin.readline\nimport math \ndef primeFactors(n):\n factor=set()\n while n % 2 == 0: \n factor.add(2), \n n = n / 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n factor.add(i), \n n = n / i \n if n > 2: \n factor.add(n)\n return(factor)\nt=int(input())\nx=list((primeFactors(t)))\nif len(x)>1:\n print(1)\nelif t==1:\n print(1)\nelse:\n print(min(x))\n \n\n"}, {"source_code": "import math\n\nn = int(input())\nx = n\nfor i in range(2, int(math.sqrt(x)) + 1):\n if n % i == 0:\n x = math.gcd(x, i)\n x = math.gcd(x, int(n / i))\nprint(x)\n"}, {"source_code": "from math import *\nn = int(input())\nflag1 = False\nfor i in range(2, int(sqrt(n)+1)):\n\tif n%i ==0:\n\t\tfact = i\n\t\tflag1 = True\n\t\tbreak\nif flag1==False:\n\tprint(n)\nelse:\n\tflag = False\n\tval = fact\n\tfor i in range(42):\n\t\tif val == n:\n\t\t\tflag = True\n\t\telif val <=10**12:\n\t\t\tval = val*fact\n\tif flag == True:\n\t\tprint(fact)\n\telse:\n\t\tprint(1) \n"}, {"source_code": "from math import sqrt,gcd,inf\nq=int(input())\nw=[]\ns=sqrt(q)\nfor i in range(2,int(s)+1):\n if q%i==0:w.append(i)\ntest=[]\nfor i in range(len(w)-(s==int(s))):\n test.append(q//w[i])\nw+=test\nw.append(q)\nl=inf\nfor i in range(len(w)):\n for j in range(i+1,len(w)):\n l=min(l,gcd(w[i],w[j]))\nprint(min(l,q))"}, {"source_code": "n = int(input())\nm = int(n**0.5)+2\nans = n\nfor i in range(2,m):\n\n if n%i==0:\n while(n%i==0):\n n = n//i\n if n!=1:\n ans = 1\n break\n else:\n ans = i\nprint(ans)\n\n# if ans==n:\n# print(n)\n# else:\n# print(ans, n)\n# p = ans\n# x = [i for i in range(p)]\n# for i in range(ans+1, m):\n# if n%i==0:\n# tmp = n//i\n# # print(i)\n# if n//i>=p:\n# x = [0 for j in range(p)]\n# break\n# else:\n# for j in range(1,n//i+1):\n# x[(j*i)%p] = 0\n# while(n%i==0):\n# n = n//i\n\n# print(len(set(x)))\n\n\n\n\n\n"}, {"source_code": "n = int(input())\nm = n\nd = 2\na = []\nans = 1\nwhile d*d <= n:\n\tif n % d == 0:\n\t\tif d not in a:\n\t\t\ta += [d]\n\t\tn //= d\n\telse:\n\t\tif d >= 3:\n\t\t\td += 2\n\t\telse:\n\t\t\td += 1\nif n > 1 and n not in a:\n\ta += [n]\nif len(a) > 1:\n\tans = 1\nelif len(a) == 0:\n\tans = 1\nelse:\n\tans = a[0]\nprint(ans)"}, {"source_code": "import sys\ninput=sys.stdin.readline\nimport math \ndef primeFactors(n):\n factor=set()\n while n % 2 == 0: \n factor.add(2), \n n = n / 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n factor.add(i), \n n = n / i \n if n > 2: \n factor.add(n)\n return(factor)\nt=int(input())\nx=list((primeFactors(t)))\nif len(x)>1:\n print(1)\nelif t==1:\n print(1)\nelse:\n print(min(x))\n \n\n"}, {"source_code": "import math\nn = int(input())\nx = n\nfor i in range(2, int(n**0.5)+1):\n if n%i==0:\n x = math.gcd(x, i)\n x = math.gcd(x,int(n/i))\nprint(x)"}, {"source_code": "numero = int(input())\nlista = []\nif numero == 1:\n\tprint(1)\n\texit()\n\t\nfor i in range(2, int(numero**0.5) + 1 ):\n\tcontador=0\n\twhile numero%i==0:\n\t\tcontador+=1\n\t\tnumero/=i\n\tif contador>0:\n\t\tlista.append([i,contador])\n\nif numero > 1:\n\tlista.append([numero,1])\nif len(lista) > 1:\n\tprint(1)\nelse:\n\tprint(lista[0][0])\n"}, {"source_code": "import math\n\n\ndef p(x):\n for i in range(2, int(math.sqrt(x)) + 1):\n if x % i == 0:\n return i\n else:\n return x\n\n\ndef r(x):\n if round(x) - x < 0.5:\n return round(x)\n else:\n return round(x) - 1\n\n\nn = int(input())\nif n == 1:\n print(1)\nelse:\n m = p(n)\n d = math.log(n, m)\n if m**r(d) == n:\n print(m)\n else:\n print(1)\n"}, {"source_code": "import math\np = int(input())\nx = p\nfor i in range(2, int(p**0.5)+1):\n if p%i==0:\n x = math.gcd(x, i)\n x = math.gcd(x,int(p/i))\nprint(x)"}, {"source_code": "import sys\nimport math\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\n\nn = int(input())\nans = n\nfor i in range(2, int(math.sqrt(n)) + 1):\n if n % i == 0:\n ans = math.gcd(ans, math.gcd(i, n//i))\nprint(ans)\n"}, {"source_code": "n=int(input())\nif(n==1):\n print (1)\nelse:\n k=int(pow(n,0.5))\n div=[]\n count=0\n flag=0\n for i in range(2,k+1):\n if(n%i==0):\n div.append(i)\n count+=1\n while(n%i==0):\n n=n//i\n if(n==1):\n break\n else:\n flag=1\n break\n if(flag==1):\n print (1)\n else:\n if(n==1):\n print (div[0])\n else:\n print (n)\n "}, {"source_code": "import math\nn = int(input())\nx = n\nfor i in range(2, int(n**0.5)+1):\n if n%i==0:\n x = math.gcd(x, i)\n x = math.gcd(x,int(n/i))\nprint(x)"}, {"source_code": "import math\ndef primef(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 > 2: \n l.append(n) \n return l\nn=int(input())\nl=primef(n)\nl=list(set(l))\nif len(l)==1:\n print(l[0])\nelse:\n print(1)"}, {"source_code": "#!/usr/bin/python3\n\nimport functools\n\ndef gcd(x, y):\n while(y):\n y, x = x % y, y\n return x\n\ndef prime_factors(n):\n if (n == 1):\n return [ 1 ]\n i = 2\n factors = []\n while (i * i <= n):\n if (n % i):\n i += 1\n else:\n while (n % i == 0):\n n //= i\n factors.append(i)\n\n if (n > 1):\n factors.append(n)\n return factors\n\nfactors = prime_factors(int(input()));\nprint(functools.reduce(lambda r, i: gcd(r, i), factors[1:], factors[0]));\n"}, {"source_code": "'''\n Author : thekushalghosh\n Team : CodeDiggers\n'''\nimport sys,math\ninput = sys.stdin.readline\nfrom fractions import gcd\nfrom functools import reduce\ndef qwqw(list):\n x = reduce(gcd, list)\n return x\ndef qw(n):\n if n == 1:\n return([1,1])\n i = 1\n q = []\n while i <= math.sqrt(n): \n if (n % i == 0) : \n if (n // i == i) : \n q.append(i)\n else : \n q.append(i)\n q.append(n // i)\n i = i + 1\n return(q)\nfor n in range(1):\n n = int(input())\n a = qw(n)\n a.sort()\n a.pop()\n a.pop(0)\n if len(a) == 0:\n a.append(n)\n print(qwqw(a))"}, {"source_code": "n = int(input())\ndividers = list()\ni = 2\n\nwhile i * i <= n:\n if n % i == 0:\n dividers.append(i)\n\n while n % i == 0:\n n /= i\n\n i += 1\n\nif n > 1:\n dividers.append(n)\n\nif len(dividers) == 1:\n print(dividers[0])\nelse:\n print(1)"}, {"source_code": "import math\nx=int(input())\ny=x\nif x==1:\n print(1)\n exit()\nlol=[]\nfor i in range(2,int(math.sqrt(x))+1):\n if x%i==0:\n while x%i==0:\n x//=i\n lol.append(i)\nif x>=2:\n lol.append(x)\n \nif len(lol)==1:\n print(lol[0])\nelse:\n print(1)"}, {"source_code": "n = input()\nfrom math import sqrt\nans = -1\nfor i in range(2, int(sqrt(n)) + 1):\n\tif n%i == 0:\n\t\tans = i \n\t\tbreak\nif ans == -1:\n\tprint n\nelse:\n\twhile n%ans == 0:\n\t\tn /= ans\n\tif n > 1:\n\t\tprint 1\n\telse:\n\t\tprint ans"}, {"source_code": "'''\n Auther: ghoshashis545 Ashis Ghosh\n College: jalpaiguri Govt Enggineering College\n Date:10/06/2020\n\n'''\nfrom os import path\nimport sys\nfrom functools import cmp_to_key as ctk\nfrom collections import deque,defaultdict as dd \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())\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\ndef bo(i):\n return ord(i)-ord('a')\n\ndef isprime(n):\n for i in range(2,int(sqrt(n))+1):\n if n%i==0:\n return 0\n return 1\ndef solve():\n \n # for _ in range(ii()):\n \n \n \n n=ii()\n x=1\n c=0\n for i in range(2,int(sqrt(n))+1):\n f=0\n while(n%i==0):\n x=i\n f=1\n n//=i\n if(f):\n c+=1\n if(n>1):\n x=n\n c+=1\n if c>1:\n print(1)\n else:\n print(x)\n \n \n \n \n \n \nif __name__ ==\"__main__\":\n solve()\n"}, {"source_code": "from heapq import heappush, heappop\nfrom collections import deque,defaultdict,Counter\nimport itertools\nfrom itertools import permutations,combinations\nimport sys\nimport bisect\nimport string\nimport math\nimport time\nimport random\ndef I():\n return int(input())\ndef MI():\n return map(int,input().split())\ndef LI():\n return [int(i) for i in input().split()]\ndef LI_():\n return [int(i)-1 for i in input().split()]\ndef show(*inp,end='\\n'):\n if show_flg:\n print(*inp,end=end)\nYN=['Yes','No']\nmo=10**9+7\ninf=float('inf')\nts=time.time()\nsys.setrecursionlimit(10**6)\ninput=sys.stdin.readline\nshow_flg=False\nshow_flg=True\n\nn=I()\n\n \ndef primeFactor(N):\n i,n=2,N\n ret={}\n d,sq=2,99\n while i<=sq:\n k=0\n while n%i==0:\n n,k,ret[i]=n//i,k+1,k+1\n if k>0 or i==97:\n sq=int(n**(1/2)+0.5)\n if i<4:\n i=i*2-1\n else:\n i,d=i+d,d^6\n if n>1:\n ret[n]=1\n return ret\n \np=primeFactor(n)\n\nif len(p)==1:\n print(list(p.items())[0][0])\nelse:\n print(1)"}, {"source_code": "import math\ns=set() \ndef prime(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(int(i)) \n n = n / i \n if n > 2: \n s.add(int(n))\nn = int(input())\nif n==1:\n print(\"1\")\n exit()\nprime(n)\nl=sorted(s) \nif len(l)==1:\n print(l[0])\nelse:\n print(\"1\") \n"}, {"source_code": "from math import sqrt\ndef prime(n):\n temp = []\n while n % 2 == 0:\n # print (2)\n n = n // 2\n temp.append(2)\n for i in range(3,int(sqrt(n))+1,2):\n while n % i== 0:\n n = n // i\n temp.append(i)\n if n > 2: \n temp.append(n)\n return list(set(list(temp)))\n\nn = int(input())\nans = prime(n)\nif len(ans) == 1:\n\tprint(*ans)\nelse:\n\tprint(1)"}, {"source_code": "from collections import Counter,defaultdict,deque\nimport heapq as hq\nfrom itertools import count, islice\nfrom functools import reduce\n#alph = 'abcdefghijklmnopqrstuvwxyz'\n#from math import factorial as fact\n#a,b = [int(x) for x in input().split()]\nimport math\nimport sys\ndef primes(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\ninput=sys.stdin.readline\nn = int(input())\nif n == 1:\n print(1)\nelse:\n \n p = primes(n)\n print(reduce(math.gcd,p))\n"}, {"source_code": "n=int(input())\nif n==1:\n\tprint(1)\n\texit()\ns=set()\nxx=n\nans=[]\nfor i in range(2,int(n**0.5)+1):\n\tif xx%i==0:\n\t\tans.append(i)\n\t\ts.add(i)\n\t\twhile xx%i==0:\n\t\t\txx=xx//i \nif xx>1:\n\tans.append(xx)\n\ts.add(xx)\nif len(s)>1:\n\tprint(1)\nelse:\n\tprint(ans[0])"}, {"source_code": "import math\ndef SieveofEratosthenes(number):\n prime_list = []\n prime = number\n for i in range(2,int(math.sqrt(number))+3,1): \n if(number%i==0):\n prime = i\n break\n\n while(number > 1):\n if(number % prime == 0):\n number = number // prime\n else:\n break\n if(number == 1):\n return prime\n else:\n return 1\n \n \n return prime_list\n \n \nnum = int(input())\nif(num == 1):\n print(num)\nelse:\n print(SieveofEratosthenes(num))\n "}, {"source_code": "import math\ndef fun(n): \n ans=[]\n # Print the number of two's that divide n\n if n%2==0:\n ans.append(2)\n while n % 2 == 0: \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 xrange(3,int(math.sqrt(n))+1,2): \n \n # while i divides n , print i ad divide n \n if n%i==0:\n ans.append(i)\n while n % i== 0: \n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n ans.append(n)\n return ans\n\nn=input()\nx=fun(n)\nif len(x)==1:\n print x[0]\nelse:\n print 1\n"}, {"source_code": "import math\n\n\ndef prime_factors(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\n if n > 2:\n l.append(n)\n return l\n\n\nn = int(input())\n\nif n==1:\n print(1)\nelse:\n l = prime_factors(n)\n l = list(set(l))\n l.sort()\n if l[-1]==n:\n print(n)\n else:\n if len(l)==1:\n print(l[0])\n else:\n print(1)"}, {"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# sys.setrecursionlimit(int(pow(10, 2)))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.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\n\n\n\n# @lru_cache(None)\n\n\nprime=[1 for i in range(10**6+1)]\nprime[0]=0\nprime[1]=0\nfor i in range(10**6+1):\n if(prime[i]):\n for j in range(2*i,10**6+1,i):\n prime[j]=0\nn=l()[0]\nif(n<=3):\n print(n)\n exit()\nstep=n\ndiv=[]\nfor i in range(2,int(n**0.5)+2):\n if(n%i==0 and prime[i]):\n div.append(i)\n if(n//i<10**6+2 and prime[n//i] and n//i not in div):\n div.append(n//i)\n step=i\n # break\nif(len(div)>1):\n print(1)\n exit()\nif(len(div)==1):\n while(n%div[0]==0):\n n//=div[0]\n if(n!=1):\n print(1)\n exit()\nprint(step)\n\n\n"}, {"source_code": "from sys import stdin, stdout\nfrom collections import Counter, deque\nfrom bisect import bisect_left\nfrom itertools import product\n#input = stdin.buffer.readline\n\nn = int(input())\nif n == 1: print(1); exit()\n\np, dv = 2, []\nwhile n > 1 and p*p <= n:\n while n % p == 0:\n dv.append(p)\n n //= p\n p += 1\nif n > 1: dv.append(n)\n\ncc = Counter(dv)\nprint(1 if len(cc.keys()) > 1 else list(cc.keys())[0])\n"}, {"source_code": "# for nt in range(1,100):\n# \tn=nt\n# \tans=[0]*n\n# \tcolor=0\n# \tfor i in range(1,n+1):\n# \t\tif ans[i-1]==0:\n# \t\t\tcolor+=1\n# \t\tfor j in range(i+2,n+1):\n# \t\t\tif n%(j-i)==0:\n# \t\t\t\tif ans[i-1]!=0:\n# \t\t\t\t\tans[j-1]=ans[i-1]\n# \t\t\t\telif ans[j-1]!=0:\n# \t\t\t\t\tans[i-1]=ans[j-1]\n# \t\t\t\telse:\n# \t\t\t\t\tans[i-1]=color\n# \t\t\t\t\tans[j-1]=color\n# \t\t\t#print (i,j,ans)\n# \tif ans.count(0)==len(ans):\n# \t\tprint (str(nt)+\" : \"+str(n))\n# \telse:\n# \t\tcount={}\n# \t\tcalc=0\n# \t\tfor i in ans:\n# \t\t\tif i not in count:\n# \t\t\t\tcalc+=1\n# \t\t\t\tcount[i]=1\n# \t\tprint (str(nt)+\" : \"+str(calc))\nif True:\n\tn=int(input())\n\tif n%6==0:\n\t\tprint (1)\n\telse:\n\t\tfactors=[]\n\t\tflag=0\n\t\tfor i in range(2,int(n**(0.5)+1)):\n\t\t\tif n%i==0:\n\t\t\t\tflag=1\n\t\t\t\tfactors.append(i)\n\t\t\t\twhile (n%i==0):\n\t\t\t\t\tn=n//i\n\t\tif n!=1:\n\t\t\tfactors.append(n)\n\t\tif flag==0:\n\t\t\tprint (n)\n\t\telse:\n\t\t\tif len(factors)==1:\n\t\t\t\tprint (factors[0])\n\t\t\telse:\n\t\t\t\tprint (1)\n"}, {"source_code": "import math\nn=int(input())\nans=0\ni=2\nA=[]\nwhile (i*i)<=n:\n \n if n%i==0:\n ii=n//i\n A.append(i)\n A.append(ii)\n i+=1\nif not A:\n print(n)\nelse:\n for j in A:\n ans=math.gcd(j,ans)\n print(ans)\n"}, {"source_code": "import math\ndef factorize(n):\n temp = []\n count = 0\n while ((n % 2 > 0) == False):\n n >>= 1\n count += 1\n if (count > 0):\n temp.append(2)\n for i in range(3, int(math.sqrt(n)) + 1):\n count = 0\n while (n % i == 0):\n count += 1\n n = int(n / i)\n if (count > 0):\n temp.append(i)\n i += 2\n if (n > 2):\n temp.append(n)\n return temp\nn = int(input())\nif n == 1:\n print(1)\nelse:\n x = factorize(n)\n if len(x)>1:\n print(1)\n else:\n print(x[0])"}, {"source_code": "n = int(input())\ndividers = list()\ni = 2\n\nwhile i * i <= n:\n if n % i == 0:\n dividers.append(i)\n\n while n % i == 0:\n n /= i\n\n i += 1\n\nif n > 1:\n dividers.append(n)\n\nif len(dividers) == 1:\n print(dividers[0])\nelse:\n print(1)"}, {"source_code": "n=int(input())\nimport math \ng=n\n\nfor i in range(2,int(math.sqrt(n))+1):\n if n%i==0:\n g=math.gcd(g,math.gcd(i,n//i))\nprint(g)"}, {"source_code": "numero = int(input())\nlista = []\nif numero == 1:\n\tprint(1)\n\texit()\n\t\nfor i in range(2, int(numero**0.5) + 1 ):\n\tcontador=0\n\twhile numero%i==0:\n\t\tcontador+=1\n\t\tnumero/=i\n\tif contador>0:\n\t\tlista.append([i,contador])\n\nif numero > 1:\n\tlista.append([numero,1])\nif len(lista) > 1:\n\tprint(1)\nelse:\n\tprint(lista[0][0])\n"}, {"source_code": "n=int(input())\nN=n\ndiv=[]\nfor d in range(2,min(1000001,n+1)):\n if n%d==0:\n div.append(d)\n while(n%d==0):\n n//=d\nif n>1:\n div.append(n)\nif len(div)==1:\n print(div[0])\nelse:\n print(1)"}, {"source_code": "import math\nn=int(input())\narr=[]\ni=2\nwhile i*i<=n:\n if (i*i)!=n and n%i==0:\n arr.append(i)\n arr.append(n//i) \n elif i*i==n:arr.append(i)\n i+=1\n#print(arr)6\n \nans=0\nif len(arr)==0:print(n)\nelse:\n for j in arr:\n ans=math.gcd(j,ans)\n print(ans)\n"}, {"source_code": "n = int(input())\nv = 0\nfor i in range(2, int(n ** 0.5 + 1)):\n if n % i: continue\n v = 1\n t = n\n while t > 1 and t % i == 0: t //= i\n if t == 1: print(i); exit()\n else: break\nprint(1 if v else n)\n"}, {"source_code": "n = int(input())\n\ndef isPrime(val):\n if(val <2):\n return 0\n n = int(val**0.5)+1\n for i in range(2,n):\n if (val%i) ==0:\n return 0\n return val\n\ndef titlePaint(n):\n if n < 2 or isPrime(n):\n print(n)\n return 0\n n1 = int(n**0.5)*2\n dic = dict()\n for i in range(2,n1):\n while n%i==0:\n if i not in dic:\n dic[i] = 1\n else:\n dic[i]+=1\n n/=i\n dic1 = sorted(dic.items(), key=lambda x: x[1])\n if dic1[0][1] ==1:\n print(1)\n return 0\n if not dic:\n print(1)\n return 0\n if len(dic) ==1:\n print(dic1[0][0])\n return 0\n else:\n print(1)\n return 0\ntitlePaint(n)\n"}, {"source_code": "def main():\n global visited, adj, sets\n #print = out.append\n ''' Cook your dish here! '''\n n = get_int()\n factors = prime_factors(n)\n if len(factors)>1 or len(factors)==0: print(1)\n else: print(list(factors.keys())[0])\n\n\n''' Coded with love at India by Satyam Kumar '''\nimport sys\n#from collections import defaultdict\nimport math\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#input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__\nout = []\nget_int = lambda: int(input())\nget_list = lambda: list(map(int, input().split()))\nmain()\n#[main() for _ in range(int(input()))]\nprint(*out, sep='\\n')\n"}, {"source_code": "\ndef mdc( a, b ):\n if ( b == 0 ):\n return a\n return mdc(b, a % b)\n\nn = int(input())\na = n\nfor i in range(2, int(n ** .5) + 1):\n if ( n % i == 0 ):\n a = mdc(a, i)\n a = mdc(a, n // i)\nprint(a)"}, {"source_code": "n = int(input())\nde = []\nfor i in range(2,int(n ** 0.5)+2):\n if n % i == 0:\n de.append(i)\n while n % i ==0:\n n//=i\n if len(de) ==2:\n print(1)\n exit(0)\nif n != 1:\n de.append(n)\nif len(de) ==1:\n print(de[0])\nelse:\n print(1)\n"}, {"source_code": "n = int(input())\nfor i in range(2, int(n**0.5)+1):\n if n % i == 0:\n while n % i == 0:\n n //= i\n if n == 1:\n print(i)\n else:\n print(1)\n exit(0)\nprint(n)"}, {"source_code": "\nfrom math import ceil\nfrom cmath import sqrt\n\n\ndef inp():\n return int(input())\n\n\ndef minput():\n return map(int, input().split())\n\n\ndef linput():\n return list(minput())\n\n\nn = inp()\nm = n\nsn = ceil(sqrt(n).real)\nif n % 2 == 0:\n m = 2\nfor i in range(3, sn + 1, 2):\n if n % i == 0:\n if m == 2:\n print(1)\n exit()\n z = i\n while z < n:\n z *= i\n if z == n:\n print(i)\n else:\n print(1)\n exit()\nif m == 2:\n print(2 if (n // 2) % 2 != 1 or n == 2 else 1)\nelse:\n print(m)\n"}, {"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 genprimes(n):\n sieve = [True] * (n/2)\n for i in xrange(3,int(n**0.5)+1,2):\n if sieve[i/2]:\n sieve[i*i/2::i] = [False] * ((n-i*i-1)/(2*i)+1)\n return [2] + [2*i+1 for i in xrange(1,n/2) if sieve[i]]\n \n#primes = genprimes(10**6)\ndef factorization(n):\n facs = []\n d = 2\n while d*d <= n:\n e =0\n while n%d == 0:\n n /= d\n e += 1\n if e:\n facs.append((d, e))\n d += 1 + (d&1)\n if n > 1:\n facs.append((n, 1))\n return facs\n \ndef divisors(n):\n facs = factorization(n)\n from itertools import product\n D, E = zip(*facs)\n for es in product(*[range(ei+1) for ei in E]):\n bns = 1\n for i, e in enumerate(es):\n bns *= D[i] ** e\n yield bns\n \ndef solve(N):\n \"\"\"\n for all i 1, n %(j-i) == 0\n # then i and j are the same\n \"\"\"\n if N == 1: return 1\n if N == 2: return 2\n if N == 3: return 3\n if N == 4: return 2\n if N == 5: return 5\n\n primes, expos = zip(*factorization(N))\n\n from fractions import gcd\n g = reduce(gcd, primes)\n return g\n\nclass DSU:\n def __init__(self, N):\n self.par = list(range(N))\n\n def find(self, x):\n if self.par[x] != x:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n def union(self, x, y):\n xr, yr = self.find(x), self.find(y)\n if xr == yr: return False\n self.par[yr] = xr\n return True\n \ndef brute(N):\n dsu = DSU(N)\n while True:\n found = False\n for d in xrange(2, N):\n if N % d == 0:\n for i in xrange(N):\n j = i+d\n if j < N:\n if dsu.union(i, j):\n found = True\n if not found: break\n return len({dsu.find(i) for i in xrange(N)})\n \n \n#####\n\nif 0:\n for i in xrange(1, 100):\n bru = brute(i)\n if bru != solve(i):\n print i, solve(i), ';', bru\n print 'done'\n\nN = rri()\nans = solve(N)\nprint ans\n \n \n \n \n"}, {"source_code": "n=int(input())\nif n==1:\n\tprint(1)\n\texit()\ns=set()\nxx=n\nans=[]\nfor i in range(2,int(n**0.5)+1):\n\tif xx%i==0:\n\t\tans.append(i)\n\t\ts.add(i)\n\t\twhile xx%i==0:\n\t\t\txx=xx//i \nif xx>1:\n\tans.append(xx)\n\ts.add(xx)\nif len(s)>1:\n\tprint(1)\nelse:\n\tprint(ans[0])"}, {"source_code": "n=int(input())\nara=[]\n\ni=2\nwhile i**2<=n:\n if n%i==0:\n ara.append(i)\n while n%i==0:\n n/=i\n i+=1\n\nif len(ara)==0 or n>1:\n ara.append(n)\n\nif len(ara)>1:\n print(1)\nelse:\n print(ara[0])"}, {"source_code": "import math \nn=int(input())\na=set()\nfor i in range(2,int(n**0.5)+1):\n if n%i==0:\n a.add(i)\n a.add(n//i)\ns=n\nfor j in a:\n s=math.gcd(s,j)\nprint(s)"}, {"source_code": "n=int(input())\nxx=n\nli=[]\nif(n%2==0):\n li.append(2)\n while(n%2==0):\n n//=2\nfor i in range(3,int(n**(1/2))+1,2):\n if(n%i==0):\n li.append(i)\n while(n%i==0):\n n//=i\nif(n>2):\n li.append(n)\nif(xx==1):\n print(1)\nelif(len(li)>1):\n print(1)\nelif(len(li)==1):\n print(li[0])"}, {"source_code": "import math \n \n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n,a): \n \n # Print the number of two's that divide n \n while n % 2 == 0: \n a.append(2) \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 a.append(i) \n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n a.append(n)\n \n return a\n \n \nn = int(input())\n\nif(n==1):\n print(1)\nelse:\n c = list()\n b = primeFactors(n,c)\n \n che = -1\n cho = -1\n \n for i in range(len(b)):\n if(b[i]%2==0):\n che = 1\n elif(b[i]%2==1):\n cho = 1\n \n ans = min(b)\n ans = int(ans)\n b = list(set(b))\n if(len(b)>1):\n print(1)\n else:\n print(b[0])\n\n\n\n\n "}, {"source_code": "from functools import reduce\ndef primeFactor(N):\n i, n, ret, d, sq = 2, N, {}, 2, 99\n while i <= sq:\n k = 0\n while n % i == 0: n, k, ret[i] = n//i, k+1, k+1\n if k > 0 or i == 97: sq = int(n**(1/2)+0.5)\n if i < 4: i = i * 2 - 1\n else: i, d = i+d, d^6\n if n > 1: ret[n] = 1\n return ret\n\ndef divisors(N):\n pf = primeFactor(N)\n ret = [1]\n for p in pf:\n ret_prev = ret\n ret = []\n for i in range(pf[p]+1):\n for r in ret_prev:\n ret.append(r * (p ** i))\n return sorted(ret)\n\n\ndef gcd(a, b):\n while b: a, b = b, a % b\n return abs(a)\ndef gcd_mult(numbers):\n return reduce(gcd, numbers)\n\n\nN = int(input())\ndv = divisors(N)[1:-1]\nif len(dv) == 0:\n print(N)\nelse:\n print(gcd_mult(dv))\n"}, {"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\n\ndef main():\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 def primeFactors(n): \n pf=[]\n # Print the number of two's that divide n \n while n % 2 == 0: \n pf.append(2) \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 pf.append(int(i)) \n n = n /i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n pf.append(int(n))\n return pf\n for _ in range(1):\n n=ri()\n nf=0\n c=0\n z=primeFactors(n)\n nf=len(set(z))\n if len(z)!=1:\n if nf==1:\n print(z[0])\n else:\n print(1)\n else:\n print(n)\n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n \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 = int(input())\n\ndef isPrime(val):\n if(val <2):\n return 0\n n = int(val**0.5)+1\n for i in range(2,n):\n if (val%i) ==0:\n return 0\n return val\n\ndef titlePaint(n):\n if n < 2 or isPrime(n):\n print(n)\n return 0\n n1 = int(n**0.5)*2\n dic = dict()\n for i in range(2,n1):\n while n%i==0:\n if i not in dic:\n dic[i] = 1\n else:\n dic[i]+=1\n n/=i\n dic1 = sorted(dic.items(), key=lambda x: x[1])\n if dic1[0][1] ==1:\n print(1)\n return 0\n if not dic:\n print(1)\n return 0\n if len(dic) ==1:\n print(dic1[0][0])\n return 0\n else:\n print(1)\n return 0\ntitlePaint(n)\n"}, {"source_code": "\ndef gcd(a,b):\n while b:\n a,b = b,a%b\n return a\n\n\n\n\nn = int(input())\nimport math\nk = math.ceil(n**0.5)\narr = set()\nfor i in range(2,k+1):\n if n % i == 0:\n arr.add(i)\n if n//i != 1:\n arr.add(n//i)\nif not arr:\n print(n)\nelif len(arr) == 1:\n print(list(arr)[0])\nelse:\n arr = list(arr)\n m = gcd(arr[0],arr[1])\n for i in range(2,len(arr)-1):\n m = min(m,gcd(arr[i],arr[i+1]))\n print(m)"}, {"source_code": "import math\ns=set() \ndef prime(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(int(i)) \n n = n / i \n if n > 2: \n s.add(int(n))\nn = int(input())\nif n==1:\n print(\"1\")\n exit()\nprime(n)\nl=sorted(s) \nif len(l)==1:\n print(l[0])\nelse:\n print(\"1\") \n"}, {"source_code": "import math \ndef primeFactors(n,ans): \n \n while n % 2 == 0: \n ans.append(2) \n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n ans.append(i) \n n = n // i \n \n if n > 2: \n ans.append(n)\n \n \n \nn=int(input())\nans=[]\nif(n==1):\n print(1)\nelse:\n primeFactors(n,ans) \n ans=set(ans)\n ans=list(ans)\n if(len(ans)==1):\n print(ans[0])\n else:\n print(1)"}, {"source_code": "from math import gcd\nn = int(input())\nx = n\nfor i in range(2, int(n**0.5) + 1):\n if n%i == 0:\n x = gcd(x, i)\n x = gcd(x, int(n/i))\nprint(x)\n"}, {"source_code": "numero = int(input())\nlista = []\nif numero == 1:\n\tprint(1)\n\texit()\n\t\nfor i in range(2, int(numero**0.5) + 1 ):\n\tcontador=0\n\twhile numero%i==0:\n\t\tcontador+=1\n\t\tnumero/=i\n\tif contador>0:\n\t\tlista.append([i,contador])\n\nif numero > 1:\n\tlista.append([numero,1])\nif len(lista) > 1:\n\tprint(1)\nelse:\n\tprint(lista[0][0])\n"}, {"source_code": "\nfrom math import ceil\nfrom cmath import sqrt\n\n\ndef inp():\n return int(input())\n\n\ndef minput():\n return map(int, input().split())\n\n\ndef linput():\n return list(minput())\n\n\nn = inp()\nm = n\nsn = ceil(sqrt(n).real)\nif n % 2 == 0:\n m = 2\nfor i in range(3, sn + 1, 2):\n if n % i == 0:\n if m == 2:\n print(1)\n exit()\n z = i\n while z < n:\n z *= i\n if z == n:\n print(i)\n else:\n print(1)\n exit()\nif m == 2:\n print(2 if (n // 2) % 2 != 1 or n == 2 else 1)\nelse:\n print(m)\n"}, {"source_code": "n = int(input())\n\ni = 2\nwhile i*i <= n:\n if n%i == 0:\n while n%i == 0:\n n //= i\n if n == 1:\n print(i)\n else:\n print(1)\n break\n i += 1\nelse:\n print(n)"}, {"source_code": "import math\ndef countprime(x):\n i=2\n primes=set()\n while i<=math.sqrt(x) + 1:\n\n if i==2:\n\n while x%i==0:\n # print(primes)\n x=x/i\n primes.add(i)\n i+=1\n else:\n while x%i==0:\n x=x/i\n primes.add(i)\n i+=2\n if x>1:\n primes.add(x)\n # print(primes)\n return primes\n# print(countprime(1))\nn=int(input())\nif len(countprime(n))==1 and sum(countprime(n))==n:\n print(n)\nelse:\n if len(countprime(n))==0:\n print(1)\n else:\n d=(countprime(n))\n\n # d.remove(1)\n e=0\n o=0\n # print(d)\n for s in d:\n if s%2==0:\n e+=1\n else:\n o+=1\n if o>1:\n print(1)\n elif o>0 and e>0:\n print(1)\n else:\n print(int(min(d)))\n # print(min(d))\n"}, {"source_code": "n = int(input())\nif(n==1):\n print(1)\nelse:\n es = 0\n for i in range(2,1000000):\n if(n%i==0):\n es = 1\n while(n%i==0):\n n = n//i\n \n if(n==1):\n print(i)\n else:\n print(1)\n break\n if(es==0):\n print(n)"}, {"source_code": "from math import gcd\nn = int(input())\nif n == 1:\n print(1)\n exit()\nelif n == 2:\n print(2)\n exit()\nelse:\n d = 0\n for i in range(2, n):\n if i * i > n:\n break\n if (n % i)==0:\n \n d = gcd(d, i)\n d = gcd(d, n // i)\nif d:\n print(d)\nelse:\n print(n)\n"}, {"source_code": "from math import ceil\nn=int(input())\nif n==1:\n print(1)\nelse:\n l=set()\n i=2\n y=n\n tmp=ceil(n**0.5)+1\n while n!=1 and i 2: \n s.add(n)\n return s\n \nn = int(input())\ns = rs(n)\nif(len(s) == 1):\n print(list(s)[0])\nelse:\n print(1)"}, {"source_code": "def isPrime(n):\n \n isp=True\n i=2 \n while i*i<=n:\n if n%i==0:\n isp=False\n break\n i+=1\n return isp\ndef soe(n):\n primes=[True]*(n+1)\n primes[0]=primes[1]=False\n i=4 \n while i=2:\n print(1)\nelif ct==1:\n print(f)\nelse:\n print(n)"}, {"source_code": "n = int(input())\n\ntest = 2\nout = 1\nwhile test * test <= n:\n p = 0\n while n % test == 0:\n n //= test\n p += 1\n\n if p >= 1:\n out = test\n break\n\n test += 1\n\nif out == 1 and n > 1:\n print(n)\nelif out > 1 and n == 1:\n print(out)\nelse:\n print(1)\n"}, {"source_code": "from math import gcd\nn = int(input())\nif n == 1:\n print(1)\n exit()\nelif n == 2:\n print(2)\n exit()\nd = 0\nfor i in range(2, n):\n if i * i > n:\n break\n if n % i:\n continue\n d = gcd(d, i)\n d = gcd(d, n // i)\nif d:\n print(d)\nelse:\n print(n)\n"}, {"source_code": "from math import gcd\nn = int(input())\nif n == 1:\n print(1)\n exit()\nelif n == 2:\n print(2)\n exit()\nd = 0\nfor i in range(2, n):\n if i * i > n:\n break\n if n % i:\n continue\n d = gcd(d, i)\n d = gcd(d, n // i)\nif d:\n print(d)\nelse:\n print(n)\n"}, {"source_code": "n=int(input())\nf=[]\nfor i in range(2,int(n**(0.5))+1):\n if n%i==0:\n while n%i==0:\n n=n//i\n f.append(i)\nif n>1:\n f.append(n)\nif len(f)==1:\n print(f[0])\nelse:\n print(1)"}, {"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#print(prime_factors(48))\nn=int(input())\nif n==1:print(1)\nelif n==2:\n print(2)\nelse:\n kk=prime_factors(n)\n #print(kk)\n if len(set(kk))==1:\n print(kk[0])\n else:\n print(1)\n \n \n \n \n "}, {"source_code": "from fractions import gcd\nfrom datetime import date, timedelta\nfrom heapq import*\nimport math\nfrom collections import defaultdict, Counter, deque\nimport sys\nfrom bisect import *\nimport itertools\nimport copy\nsys.setrecursionlimit(10 ** 7)\nMOD = 10 ** 9 + 7\n\n\ndef factorize(n):\n fct = [] # prime factor\n b, e = 2, 0 # base, exponent\n while b * b <= n:\n while n % b == 0:\n n = n // b\n e = e + 1\n if e > 0:\n fct.append((b, e))\n b, e = b + 1, 0\n if n > 1:\n fct.append((n, 1))\n return fct\n\n\ndef is_prime(n):\n if n == 1:\n return False\n\n for k in range(2, int(math.sqrt(n)) + 1):\n if n % k == 0:\n return False\n\n return True\n\n\ndef main():\n # k = int(input())\n # for i in range(k):\n # n = int(input())\n # s = list(input())\n # t = list(input())\n # d = defaultdict(int)\n # for i in range(n):\n # d[s[i]] += 1\n # d[t[i]] += 1\n \n # f = False\n # for v in d.values():\n # if v % 2 == 1:\n # print(\"No\")\n # f = True\n # if f:\n # continue\n\n\n \n\n n = int(input())\n # l = [0] * n\n # l[1] = 1\n # for i in range(2, n):\n # f= True\n # for j in range(n):\n # if i == j:\n # continue\n # if abs(i - j) > 1 and (n % abs(j - i)) == 0:\n # l[i] = l[j]\n # f = False\n # break\n # if f:\n # l[i] = i\n # print(l,len(list(set(l))))\n if n == 1:\n print(1)\n elif is_prime(n):\n print(n)\n else:\n l = factorize(n)\n if len(l) >= 2:\n print(1)\n else:\n print(l[0][0])\n\n \n\n\n\n \n \n \n \n\n \n \n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math \ndef factorize(n): \n count = 0; \n v = []\n while ((n % 2 > 0) == False): \n n >>= 1; \n count += 1; \n if (count > 0): \n v.append((2, count)); \n for i in range(3, int(math.sqrt(n)) + 1): \n count = 0; \n while (n % i == 0): \n count += 1; \n n = int(n / i); \n if (count > 0): \n v.append((i, count)); \n i += 2; \n if (n > 2): \n v.append((n, 1));\n return v\nn = int(input())\nv = factorize(n)\nk = len(v)\n\nif k == 1 and v[0][0] > 1 :\n print(int(v[0][0]))\nelif k >=2:\n print(1)\nelse:\n print(n)\n\n\n"}, {"source_code": "import math\nn = int(input())\nx = 2\nrem = 0\nflag = True\nwhile x <= math.sqrt(n):\n if n % x == 0:\n k = x\n c = 1\n while n > k:\n k *= x\n c += 1\n if n == k:\n print(x)\n flag = False\n break\n if n != k:\n print(1)\n flag = False\n break\n x += 1\nif flag:\n print(n)\n\n\n\n\n\n"}, {"source_code": "def gcd(a, b):\n if a == 0:\n return b\n return gcd(b % a, a)\n \ndef solve(x):\n if x == 2 or x == 3 or x == 5:\n return x\n if x == 4:\n return 2\n primes = []\n root = int(x ** 0.5) + 5\n for i in range(2, root):\n if x % i == 0:\n primes.append(i)\n primes.append(x // i)\n if len(primes) == 0:\n return x\n g = primes[0]\n for p in primes:\n g = gcd(g, p)\n return g\n \nn = int(input())\nif n == 1:\n print(1)\nelse:\n print(solve(n))"}, {"source_code": "#!/usr/bin/python3\n\nimport array\nimport bisect\nimport collections\nfrom fractions import Fraction\nimport functools\nimport itertools\nimport math\nimport os\nimport sys\n\n\ndef main():\n N = read_int()\n print(solve(N))\n\n\ndef solve(N):\n d = []\n x = 2\n while x * x <= N:\n if N % x == 0:\n d.append(x)\n if x * x < N:\n d.append(N // x)\n x += 1\n\n d.sort()\n if not d:\n return N\n g = d[0]\n for x in d[1:]:\n g = math.gcd(g, x)\n return g\n\n\n###############################################################################\n# AUXILIARY FUNCTIONS\n\nDEBUG = 'DEBUG' in os.environ\n\n\ndef inp():\n return sys.stdin.readline().rstrip()\n\n\ndef read_int():\n return int(inp())\n\n\ndef read_ints():\n return [int(e) for e in inp().split()]\n\n\ndef dprint(*value, sep=' ', end='\\n'):\n if DEBUG:\n print(*value, sep=sep, end=end)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\n\nn = int(input())\nx = n\nfor i in range(2, int(math.sqrt(x)) + 1):\n if n % i == 0:\n x = math.gcd(x, i)\n x = math.gcd(x, int(n / i))\nprint(x)\n"}, {"source_code": "import math \n \n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n,a): \n \n # Print the number of two's that divide n \n while n % 2 == 0: \n a.append(2) \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 a.append(i) \n n = n / i \n \n # Condition if n is a prime \n # number greater than 2 \n if n > 2: \n a.append(n)\n \n return a\n \n \nn = int(input())\n\nif(n==1):\n print(1)\nelse:\n c = list()\n b = primeFactors(n,c)\n \n che = -1\n cho = -1\n \n for i in range(len(b)):\n if(b[i]%2==0):\n che = 1\n elif(b[i]%2==1):\n cho = 1\n \n ans = min(b)\n ans = int(ans)\n b = list(set(b))\n if(len(b)>1):\n print(1)\n else:\n print(b[0])\n\n\n\n\n "}, {"source_code": "a=int(input())\nimport math\ndef fact(x):\n ans=[]\n for i in range(1,int(math.sqrt(x))+1):\n if(x%i==0):\n if(x//i==i):\n ans.append(i)\n else:\n ans.append(x//i)\n ans.append(i)\n return ans;\n\nans=fact(a)\nans.sort()\nif(a==1):\n print(1)\n exit()\nx=ans[1]\ntot=1\nwhile(tot 1:\n if n % i != 0:\n print(1)\n exit()\n n //= i\n print(i)\n exit()\nprint(n)"}, {"source_code": "def task_3(k):\n result = k\n for i in range(2, int(k**(1/2))+1):\n if k%i == 0:\n while k>1:\n if k%i==0:\n k = k//i\n else:\n result = 1\n break\n if k==1:\n result = i\n break\n print(result)\n \n\nif __name__ == '__main__':\n # Number of requests\n k = int(input().rstrip())\n task_3(k)"}, {"source_code": "n = int(input())\n\nmin_del = 0\n\ni = 2\nwhile i * i <= n:\n if n % i == 0:\n if min_del == 0:\n min_del = i\n elif i % min_del != 0:\n print(1)\n exit()\n\n while n % i == 0:\n n //= i\n\n i += 1\n\nif n > 1 and min_del != 0:\n print(1)\nelif min_del == 0:\n print(n)\nelse:\n print(min_del)\n\n"}, {"source_code": "n = int(input())\nnn = n\ni = 2\ndziel = []\nwhile True:\n\tif n%i == 0:\n\t\tn //= i\n\t\tdziel.append(i)\n\telse:\n\t\ti += 1\n\tif i**2 > nn:\n\t\tif n > 1:\n\t\t\tdziel.append(n)\n\t\tbreak\nif len(dziel) == 1:\n\tprint(nn)\nelse:\n\ta = set(dziel)\n\tif len(a) == 1:\n\t\tprint(dziel[0])\n\telse:\n\t\tprint(1)"}], "negative_code": [{"source_code": "n = int(input())\n\nif n == 1:\n print(1)\n\nelse:\n import math\n if n > 1000:\n k = math.sqrt(n)\n k = math.ceil(k) \n else:\n k = n + 1\n p = n\n for i in range(2,k):\n if p % i == 0:\n while p % i == 0:\n p = p / i\n break\n\n if p == 1:\n print(i)\n\n elif p == n:\n print(n)\n \n else:\n print(1)"}, {"source_code": "from math import sqrt\nn = int(input())\ndevi = set()\ni = 2\nwhile i <= sqrt(n):\n if n % i == 0:\n devi.add(i)\n n //= i\n else:\n i += 1\nif len(devi) == 0:\n print(n)\nelif len(devi) == 1:\n print(*devi)\nelse:\n print(1)"}, {"source_code": "\nfrom math import ceil\nfrom cmath import sqrt\n\n\ndef inp():\n return int(input())\n\n\ndef minput():\n return map(int, input().split())\n\n\ndef linput():\n return list(minput())\n\n\nn = inp()\nsn = ceil(sqrt(n).real)\nm = n\nif n % 2 == 0:\n m = 2\nif m != 2:\n for i in range(3, sn + 2, 2):\n if n % i == 0:\n m = i\n break\nprint(m if m == n else n // m)\n"}, {"source_code": "import math\ndef calc(n):\n temp=n\n if(n==1):\n return 1\n else:\n p=2\n result=0\n while(n!=1):\n bool=False\n while(n%p==0):\n n//=p\n bool=True\n if bool is True:\n result=math.gcd(result,p)\n if(result==1 or p>int(math.sqrt(temp))+1):\n break\n p+=1\n #print(result)\n if(result==0):\n return temp\n else:\n return result\nn=int(input())\nprint(calc(n))\n"}, {"source_code": "x=int(input())\na=x\nz=0\nfor i in range (2,int(x**0.5)+2):\n if x%i==0 and i%a!=0:\n a=i\n z+=1\n \nif x==1 or z==2:\n print(1)\nelse:\n print(a)\n "}, {"source_code": "import math \ndef primeFactors(n,ans): \n \n while n % 2 == 0: \n ans.append(2) \n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n ans.append(i) \n n = n // i \n \n if n > 2: \n ans.append(n)\n \n \n\nn=int(input())\nans=[]\nif(n==1):\n print(1)\nelse:\n primeFactors(n,ans) \n print(ans[len(ans)-1])"}, {"source_code": "from fractions import gcd\nfrom datetime import date, timedelta\nfrom heapq import*\nimport math\nfrom collections import defaultdict, Counter, deque\nimport sys\nfrom bisect import *\nimport itertools\nimport copy\nsys.setrecursionlimit(10 ** 7)\nMOD = 10 ** 9 + 7\n\n\ndef factorize(n):\n fct = [] # prime factor\n b, e = 2, 0 # base, exponent\n while b * b <= n:\n while n % b == 0:\n n = n // b\n e = e + 1\n if e > 0:\n fct.append((b, e))\n b, e = b + 1, 0\n if n > 1:\n fct.append((n, 1))\n return fct\n\n\ndef is_prime(n):\n if n == 1:\n return False\n\n for k in range(2, int(math.sqrt(n)) + 1):\n if n % k == 0:\n return False\n\n return True\n\n\ndef main():\n # k = int(input())\n # for i in range(k):\n # n = int(input())\n # s = list(input())\n # t = list(input())\n # d = defaultdict(int)\n # for i in range(n):\n # d[s[i]] += 1\n # d[t[i]] += 1\n \n # f = False\n # for v in d.values():\n # if v % 2 == 1:\n # print(\"No\")\n # f = True\n # if f:\n # continue\n\n\n \n\n n = int(input())\n # l = [0] * n\n # l[1] = 1\n # for i in range(2, n):\n # f= True\n # for j in range(n):\n # if i == j:\n # continue\n # if abs(i - j) > 1 and (n % abs(j - i)) == 0:\n # l[i] = l[j]\n # f = False\n # break\n # if f:\n # l[i] = i\n # print(l,len(list(set(l))))\n if n == 1:\n print(1)\n elif is_prime(n):\n print(n)\n elif n == 4:\n print(2)\n else:\n l = factorize(n)\n print(l[0][0])\n\n\n\n \n \n \n \n\n \n \n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\n\nn = int(input())\n\nif n in [1,2,3]:\n\tprint(\"1\")\nelse:\n\tsmallestDivisor = n\n\tif n % 2 == 0:\n\t\tsmallestDivisor = 2\n\telif n % 3 == 0:\n\t\tsmallestDivisor = 3\n\telse:\n\t\tfor i in range(5, int(math.sqrt(n)) + 1, 2):\n\t\t\tif n % i == 0:\n\t\t\t\tsmallestDivisor = i\n\t\t\t\tbreak\n\n\twhile n % smallestDivisor == 0:\n\t\tn //= smallestDivisor\n\n\tprint(str(smallestDivisor) if n == 1 else \"1\")\n"}, {"source_code": "import os, sys, math\n\nn = int(input())\nsqt = int(math.sqrt(n))\n\nhave = 0\nhaveodd = 0\nodd = 0\nfor i in range(2,sqt+1):\n\tif n%i == 0:\n\t\thave += 1\n\t\tif i%2 == 1:\n\t\t\thaveodd += 1\n\t\t\todd = i\n\t\tif i*i != n and (n/i)%2 == 1:\n\t\t\thaveodd += 1\n\t\t\todd = i\n\nif have == 0:\n\tprint(n)\n\tsys.exit(0)\n\nif n%2 == 0:\n\tif haveodd:\n\t\tprint(1)\n\telse:\n\t\tprint(2)\nelse:\n\tif haveodd == 1:\n\t\tprint(odd)\n\telse:\n\t\tprint(2)\n"}, {"source_code": "import sys\nip=lambda :sys.stdin.readline().rstrip()\n# from collections import *\nn=int(ip())\nif n<=2:\n print(n)\nelif n%2==0:\n print(n//2)\nelse:\n val=-1\n ct=0\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n if val==-1:\n val=i\n ct+=1\n if ct>=1:\n print(val)\n else:\n print(n)"}, {"source_code": "n = int(input())\nm = int(n**0.5)+2\nans = n\nfor i in range(2,m):\n if n%i==0:\n ans = i\n break\nif ans==n:\n print(n)\nelse:\n p = ans\n x = [1 for i in range(p)]\n for i in range(ans+1, m):\n if n%i==0:\n if n//i>=p:\n x = [0 for j in range(p)]\n break\n else:\n for j in range(1,n//i+1):\n p[(j*i)%p] = 0\n print(max(x.count(1), 1))\n\n\n\n\n\n"}, {"source_code": "import os, sys, math\n\nn = int(input())\nsqt = int(math.sqrt(n))\n\ndef IsPrime(n):\n\tfor i in range(2,sqt+1):\n\t\tif n%i == 0:\n\t\t\treturn False\n\treturn True\nif IsPrime(n):\n\tprint(n)\n\nfor i in range(2,sqt+1):\n\tif n%i != 0: continue\n\tx = n/i\n\twhile x%i == 0:\n\t\tx /= i\n\tif x == 1:\n\t\tprint(i)\n\t\tsys.exit(0)\nprint(1)\n"}, {"source_code": "import math\nx=int(input())\ny=x\nif x==1:\n print(1)\n exit()\nlol=[]\nfor i in range(2,int(math.sqrt(x))+1):\n if x%i==0:\n while x%i==0:\n x//=i\n lol.append(i)\nif x>=2:\n lol.append(x)\n \n\nk=min(lol)\na=k\nfor i in lol:\n if i!=a:\n c=i//a\n d=c+1\n k=min(k,i%a*c,i%a*d)\nprint(k) "}, {"source_code": "def soe(n):\n primes=[True]*(n+1)\n primes[0]=primes[1]=False\n i=4 \n while i=2:\n print(1)\nelif ct==1:\n print(f)\nelse:\n print(n)"}, {"source_code": "\nfrom math import ceil\nfrom cmath import sqrt\n\n\ndef inp():\n return int(input())\n\n\ndef minput():\n return map(int, input().split())\n\n\ndef linput():\n return list(minput())\n\n\nn = inp()\nsn = ceil(sqrt(n).real)\nm = n\nif n % 2 == 0:\n m = 2\nfor i in range(3, sn + 1, 2):\n if n % i == 0:\n if m == 2:\n print(1)\n exit()\n m = i\n while m < n:\n m *= i\n if m == n:\n print(i)\n else:\n print(1)\n exit()\nprint(n)\n"}, {"source_code": "import os, sys, math\n\nn = int(input())\nsqt = int(math.sqrt(n))\n\ndef IsPrime(n):\n\tfor i in range(2,sqt+1):\n\t\tif n%i == 0:\n\t\t\treturn False\n\treturn True\nif IsPrime(n):\n\tprint(n)\n\tsys.exit(0)\n\nfor i in range(2,sqt+1):\n\tif n%i != 0: continue\n\tx = n/i\n\twhile x%i == 0:\n\t\tx /= i\n\tif x == 1:\n\t\tprint(i)\n\t\tsys.exit(0)\nprint(1)\n"}, {"source_code": "import math\nn=int(input())\nj=1\nl=[]\nfor i in range(2,math.ceil(math.sqrt(n))+1):\n if n%i==0:\n if n//i==i:\n l.append(i)\n else:\n if i!=n:\n l.append(i)\n if n//i!=1:\n l.append(n//i)\nl.sort()\nn1=len(l)\nmini=n\nif n1==1:\n mini=l[0]\nfor i in range(n1-1):\n mini=min(l[i+1]-l[i],mini)\n if l[i]*l[i+1]==n:\n mini=1\nprint(max(mini,1)) "}, {"source_code": "import os, sys, math\n\nn = int(input())\nsqt = int(math.sqrt(n))\n\nhave = 0\nhaveodd = 0\nodd = 0\nfor i in range(2,sqt+1):\n\tif n%i == 0:\n\t\thave += 1\n\t\tif i%2 == 1:\n\t\t\thaveodd += 1\n\t\t\todd = i\n\t\tif i*i != n and (n/i)%2 == 1:\n\t\t\thaveodd += 1\n\t\t\todd = i\n\nif have == 0:\n\tprint(n)\n\tsys.exit(0)\n\nif n%2 == 0:\n\tif haveodd:\n\t\tprint(1)\n\telse:\n\t\tprint(2)\nelse:\n\tif haveodd == 1:\n\t\tprint(odd)\n\telse:\n\t\tprint(2)\n"}, {"source_code": "import math\ndef smallestDivisor(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 return n;\ndef isPower(div,n):\n if n == 1:\n return True\n ans = int(math.log(n,div))\n if pow(div,ans) == n or pow(div,ans+1) == n:\n return True\n else:\n False\nnum = int(input().strip())\nsmall = smallestDivisor(num)\nprint(small)\nif isPower(small,num):\n print(small)\nelse:\n print(1)\n"}, {"source_code": "n = 6#int(input())\ndef titlePain(n):\n if n < 2:\n return n\n count = 0\n dic = dict()\n for i in range(1,n):\n for j in range(i+1,n+1):\n results = abs(i-j)\n if results>1 and n%results ==0:\n dic[str(i)+'-'+str(j)] = results\n if(len(dic)>n):\n return 1\n if dic:\n return len(dic)\n return n\nprint(titlePain(n))"}, {"source_code": "from math import sqrt\nx=int(input())\nlol=[]\nif x==1 or x==2:\n print(x)\nelse: \n for i in range(2,int(sqrt(x))+1):\n if x%i==0:\n lol.append(i)\n while x%i==0:\n x//=i\n if x>2:\n lol.append(x)\n if len(lol)>0: \n print(min(lol))\n else:\n print(1)"}, {"source_code": "import sys\nip=lambda :sys.stdin.readline().rstrip()\n# from collections import *\nn=int(ip())\nif n<=2:\n print(n)\nelif n%2==0:\n print(2)\nelse:\n fl=False\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n fl=True\n break\n if fl:\n print(1)\n else:\n print(n)"}, {"source_code": "n = int(input())\ni = 2\n\nwhile i * i <= n:\n if n % i == 0:\n break\n\n i += 2\n\nif n % i == 0:\n print(i)\nelse:\n print(n)\n"}, {"source_code": "#Ashish Sagar\nimport math\ndef 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())\nif(isPrime(n)):\n print(n)\nelif n==1:\n print(1)\nelse:\n if n==4 or n==9 or n==25 or n==49:\n print(int(math.sqrt(n)))\n elif math.sqrt(n)*math.sqrt(n)==n:\n print(int(math.sqrt(n)))\n elif n%2==0:\n if n%3==0 or n%5==0 or n%7==0:\n print(1)\n else:\n print(2)\n elif n%3==0:\n if n%5==0 or n%7==0:\n print(1)\n else:\n print(3)\n elif n%5==0:\n if n%7==0:\n print(1)\n else:\n print(5)\n else:\n print(1)\n "}, {"source_code": "def task_3(k):\n start = (k+1)//2 \n while k%start:\n start -=1\n print(k//start)\n \n \nif __name__ == '__main__':\n # Number of requests\n k = int(input().rstrip())\n task_3(k)"}, {"source_code": "import math\ndef prime(m):\n k=0\n for i in range(2,int(math.sqrt(m))+1):\n if m%i==0:\n k=i\n break\n return k\n\nn=int(input())\nt=prime(n)\nif t==0:\n print(n)\nelif n%2==0:\n m=math.log(n,2)\n if m==int(m):\n print(2)\n else:\n print(1)\nelif n%2!=0:\n print(n//t)\nelse:\n print(n//t)\n"}, {"source_code": "def LOL(a1, b1):\n a = int(a1)\n b = int(b1)\n while abs(a - b) != 0:\n if b > a:\n a, b = b, a\n a = a - b\n return a\na = int(input())\nif a == 1:\n print(1)\nelse:\n A = []\n i = 2\n while a ** 0.5 >= i:\n if a % i == 0:\n A.append(i)\n a = a // i\n while a % i == 0:\n a = a // i\n i += 1\n A.append(a)\n k = A[0]\n for i in range(1, len(A)):\n k = LOL(A[i], k)\n print(k)"}, {"source_code": "n = int(input())\ndef isPrime(n):\n for i in range(2, int(n**0.5)+1):\n if n%i==0:\n v = [i, False]\n return v\n v = [1, True]\n return v\ns = isPrime(n)\nif s[1] or n==1:\n print(n)\nelse:\n k = n\n i = 2\n ok = True\n while i * i <= k and ok:\n if k % i == 0:\n while k % i == 0:\n k = k / i\n ok = False\n i = i + 1\n if k==1:\n print(n//s[0])\n else:\n print(1)\n"}, {"source_code": "import math \n\ndef factorize(n):\n\tg = []\n\tfor i in range(2, int(math.sqrt(n)) + 2):\n\t\tif (n % i == 0):\n\t\t\twhile n % i == 0:\n\t\t\t\tn //= i\n\t\t\tg.append(i)\n\tif g == []:\n\t\treturn n\n\telif len(g) == 1:\n\t\treturn g[0]\n\telse:\n\t\treturn 1\n\nk = int(input())\nif k < 2:\n\tprint(k)\nelse:\n\tn = factorize(k)\n\tprint(n)"}, {"source_code": "n = int(input())\ndef isPrime(n):\n for i in range(2, int(n**0.5)+1):\n if n%i==0:\n v = [i, False]\n return v\n v = [1, True]\n return v\ns = isPrime(n)\nif s[1] or n==1:\n print(n)\nelse:\n k = n\n i = 2\n ok = True\n while i * i <= k and ok:\n if k % i == 0:\n while k % i == 0:\n k = k / i\n ok = False\n i = i + 1\n if k==1:\n print(n//s[0])\n else:\n print(1)\n"}, {"source_code": "#Bhargey Mehta (Junior)\n#DA-IICT, Gandhinagar\nimport sys, math, queue, collections\nMOD = 10**9+7\n#sys.stdin = open('input.txt', 'r')\n\nn = int(input())\nfor i in range(2, 10**6+5):\n if n % i == 0:\n print(i)\n exit()\nprint(n)"}, {"source_code": "\ndef primes_UT(m):\n siz = m//2\n sieve = [1]*siz\n lim = int(m**0.5)\n for i in range(1,lim):\n if sieve[i]:\n val = 2*i+1\n temp = ((siz-1) - i)\n temp = temp//val \n sieve[i+val::val] = [0]*temp\n return [2] + [i*2+1 for i, v in enumerate(sieve) if v and i>0]\n\nn = int(input())\n\nprimes = primes_UT(1000000) #1.000.000\n\n\nif(n in primes):\n print(n)\nelif(n==1):\n print(1)\nelse:\n for i in range(2,1000000):\n if(n%i==0):\n prim = i\n while(n%i==0):\n n = n//i\n \n if(n==1):\n print(i)\n else:\n print(1)\n break"}, {"source_code": "import math \n\ndef factorize(n):\n\tg = []\n\tfor i in range(2, int(math.sqrt(n)) + 2):\n\t\tif (n % i == 0):\n\t\t\twhile n % i == 0:\n\t\t\t\tn //= i\n\t\t\tg.append(i)\n\tif g == []:\n\t\treturn n\n\telif len(g) == 1:\n\t\treturn g[0]\n\telse:\n\t\treturn 1\n\nk = int(input())\nif k < 2:\n\tprint(k)\nelse:\n\tn = factorize(k)\n\tprint(n)"}, {"source_code": "x=int(input())\na=x\nz=0\nfor i in range (2,int(x**0.5)+2):\n if x%i==0 and i%a!=0:\n z+=1\n if x/i%i!=0:\n a=x/i\n z+=1\n break\n else:\n a=i\n \n \nif x==1 or z>1:\n print(1)\nelse:\n print(a)"}, {"source_code": "n = int(input())\nh = n\nfor i in range(2, int(n**0.5)+1):\n\tif n%i==0:\n\t\twhile n>1:\n\t\t\tif n%i==0:\n\t\t\t\tn = n//i\n\t\t\telse:\n\t\t\t\th = 1\n\t\t\t\tbreak\n\t\tif n==1:\n\t\t\th=i\n\t\t\tbreak\nprint(h)"}, {"source_code": "l = int(input())\nk=[l]\nfor i in range(2, l // 2 + 1, 1):\n if (l % i == 0):\n k.append(i)\nk.sort()\na=len(k)\nr=int(1)\nfor i in range(1,a):\n if (int(k[i])-int(k[i-1])==0):\n print(\"1\")\n r=0\n break\nif(r==1):\n print(min(k))\n\n\n"}, {"source_code": "from math import sqrt,gcd,inf\nq=int(input())\nw=[]\ns=sqrt(q)\nfor i in range(2,int(s)):\n if q%i==0:w.append(i)\nfor i in w:w.append(q//i)\nif s==int(s):w.append(int(s))\nw.append(q)\nl=inf\nfor i in range(len(w)):\n for j in range(i+1,len(w)):\n l=min(l,gcd(w[i],w[j]))\nprint(min(l,q))"}, {"source_code": "def isprime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\ndef check_all_even(arr):\n for i in arr:\n if i%2 != 0:\n return False\n return True\n\ndef get_color(n):\n if isprime(n):\n return n\n #Tim \u01af\u1edbc c\u1ee7a n\n arr = []\n for i in range(2,int(n**0.5)+2):\n if n%i==0:\n arr.append(i)\n\n if n%2 == 0:\n if check_all_even(arr):\n return 2\n else:\n return 1\n else:\n return arr[0]\n # return int(n**0.5)\nif __name__ == \"__main__\":\n n = int(input())\n print (get_color(n))\n"}, {"source_code": "import os, sys, math\n\nn = int(input())\nsqt = int(math.sqrt(n))\n\nhave = 0\nhaveodd = 0\nodd = 0\nfor i in range(2,sqt+1):\n\tif n%i == 0:\n\t\thave += 1\n\t\tif i%2 == 1:\n\t\t\thaveodd += 1\n\t\t\todd = i\n\t\tif i*i != n and (n/i)%2 == 1:\n\t\t\thaveodd += 1\n\t\t\todd = i\n\nif have == 0:\n\tprint(n)\n\tsys.exit(0)\n\nif n%2 == 0:\n\tif haveodd:\n\t\tprint(1)\n\telse:\n\t\tprint(2)\nelse:\n\tif haveodd == 1:\n\t\tprint(odd)\n\telse:\n\t\tprint(2)\n"}, {"source_code": "import math\nn = int(input())\nisPrime = True\nmaxdiv = 0\ndivcnt = 0\nfor i in range(2, int(math.sqrt(n))+1):\n if n % i == 0:\n isPrime = False\n divcnt += 1\n maxdiv = i\n if n // maxdiv != maxdiv:\n divcnt += 1\n maxdiv = n // maxdiv\n break\n else:\n break\n \nif isPrime:\n print(n)\nelse:\n if divcnt >= 2:\n print(1)\n else:\n print(maxdiv)"}, {"source_code": "from math import sqrt,log\nn=input()\ni=2\nx=int(sqrt(n))+1\nwhile i 0:\n newnumber = str(number % base) + newnumber\n number //= base\n return newnumber\n\n\nk = ii()\nif k == 1:\n print(1)\nelif prime(k):\n print(k)\nelse:\n a = divs(k)\n if len(a) > 1:\n print(1)\n else:\n print(a[0])\n"}, {"source_code": "n = int(input())\ncount = 0\ndic = dict()\nfor i in range(1,n):\n # print('this is i ', i)\n for j in range(i+1,n+1):\n results = abs(i-j)\n if results>1 and n%results ==0:\n dic[str(i)+'-'+str(j)] = True\nif dic:\n print(len(dic))\nelse:\n print(n)"}, {"source_code": "import math \n \n# Function to calculate all the prime \n# factors and count of every prime factor \ndef factorize(n):\n num = 0\n c = 0\n count = 0; \n i = 0\n # count the number of \n # times 2 divides \n while ((n % 2 > 0) == False): \n \n # equivalent to n = n / 2; \n n >>= 1; \n count += 1; \n \n # if 2 divides it \n if (count > 0): \n c+=1\n num = max(num, 2)\n \n # check for all the possible \n # numbers that can divide it \n for i in range(3, int(math.sqrt(n)) + 1): \n count = 0; \n while (n % i == 0): \n count += 1; \n n = int(n / i); \n if (count > 0): \n c+=1;\n num = max(num, i)\n i += 2; \n \n # if n at the end is a prime number. \n if (n > 2): \n num = max(num, i)\n c+=1 \n return c, num\n\nn = int(input())\nk, num = factorize(n)\nif k == 1 and num!= 0:\n print(int(n // n**(1/2)))\nelif k >=2:\n print(1)\nelse:\n print(n)\n\n\n "}, {"source_code": "n = int(input())\n\ndef isPrime(val):\n if(val <2):\n return 0\n n = int(val**0.5)+1\n for i in range(2,n):\n if (val%i) ==0:\n return 0\n return val\n\ndef titlePaint(n):\n \n\n if n < 2 or isPrime(n):\n print(n)\n return 0\n \n # n1 = n//2+1\n # if (n >10000000000):\n n1 = int(n**0.5)+2\n prime =[]\n dic = dict()\n for i in range(2,n1):\n while n%i==0:\n prime.append(i)\n if i not in dic:\n dic[i] = 1\n else:\n dic[i]+=1\n n/=i\n dic1 = sorted(dic.items(), key=lambda x: x[1])\n # print(dic)\n # print(dic1)\n if not dic:\n print(1)\n return 0\n if len(dic) ==1:\n print(dic1[0][0])\n return 0\n else:\n print(1)\n return 0\ntitlePaint(n)\n"}, {"source_code": "from math import sqrt, ceil\ndef is_prime(a):\n if (2==a):\n return True\n else:\n return all(a % i for i in range(2, int(ceil(sqrt(a)+1))))\n\n\nn = int(input())\n\nif is_prime(n):\n print(n)\nelse:\n found = False\n for i in range(2, int(ceil(sqrt(n)+3))):\n if n % i == 0 and is_prime(i):\n if is_prime(int(n/i)):\n found = 1\n break\n if found:\n found = 1\n break\n if not found:\n found = i\n print(found)\n"}, {"source_code": "n = int(input())\nwas = n\nprimes = []\nfor i in range(2, int(n ** 0.5) + 1):\n if n % i == 0:\n while n % i == 0:\n n = n // i\n primes.append(i)\nif was == n:\n print(n)\nelse:\n print(primes[0])"}, {"source_code": "n = int(input())\np = int(pow(n,0.5))\nfor i in range(p,1,-1):\n if n%i==0:\n j = int(n/i)\n k = max(i,j)\n print(k)\n break\nelse:\n print(n)\n"}, {"source_code": "from __future__ import print_function # for PyPy2\nfrom 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\nn, = gil()\n\nif n&1:\n\tfor i in range(3, int(math.ceil(math.sqrt(n)))+1, 2):\n\t\tif n%i == 0:\n\t\t\tprint(i)\n\t\t\texit()\n\tprint(n)\n\texit()\n\t\t\nprint(2)"}, {"source_code": "n = int(input())\np = int(pow(n,0.5))\ndiv = []\nprime = 0\nfor i in range(2,p+1):\n if n % i == 0 :\n div.append(i)\n #print(i,n/i)\n for j in range(2,int(pow(i,0.5)+1)):\n if i%j==0:\n break\n else:\n prime += 1\n m = int(n/i)\n #print(m,i,m!=i)\n if m!=i:\n for j in range(2,int(pow(m,0.5))+1):\n if m%j==0:\n print(j)\n break\n else:\n prime += 1\n if prime == 2:\n print(1)\n break\nelse:\n if div == []:\n print(n)\n else:\n print(min(div))\n#(prime)"}, {"source_code": "import math \n \n# Function to calculate all the prime \n# factors and count of every prime factor \ndef factorize(n):\n num = 0\n c = 0\n count = 0; \n i = 0\n # count the number of \n # times 2 divides \n while ((n % 2 > 0) == False): \n \n # equivalent to n = n / 2; \n n >>= 1; \n count += 1; \n \n # if 2 divides it \n if (count > 0): \n c+=1\n num = max(num, 2)\n \n # check for all the possible \n # numbers that can divide it \n for i in range(3, int(math.sqrt(n)) + 1): \n count = 0; \n while (n % i == 0): \n count += 1; \n n = int(n / i); \n if (count > 0): \n c+=1;\n num = max(num, i)\n i += 2; \n \n # if n at the end is a prime number. \n if (n > 2): \n num = max(num, i)\n c+=1 \n return c, num\n\nn = int(input())\nk, num = factorize(n)\nif k == 1 and num != 0:\n print(int(n - n // n**(1/2)))\nelif k >=2:\n print(1)\nelse:\n print(n)\n\n\n "}, {"source_code": "import math\n\n\ndef p(x):\n for i in range(2, int(math.sqrt(x)) + 1):\n if x % i == 0:\n return i\n else:\n return x\n\n\nn = int(input())\nif n == 1:\n print(1)\nelse:\n m = p(n)\n d = math.log(n, m)\n if int(d) == d:\n print(m)\n else:\n print(1)\n"}, {"source_code": "import math \n\ndef factorize(n):\n\tg = []\n\tfor i in range(2, int(math.sqrt(n)) + 1):\n\t\tif (n % i == 0):\n\t\t\twhile n % i == 0:\n\t\t\t\tn //= i\n\t\t\tg.append(i)\n\tif g == []:\n\t\treturn n\n\telif len(g) == 1:\n\t\treturn g[0]\n\telse:\n\t\treturn 1\n\nk = int(input())\nif k < 2:\n\tprint(k)\nelse:\n\tn = factorize(k)\n\tprint(n)"}, {"source_code": "import math\ndef findFirstDelimeter(n):\n for i in range(int(math.sqrt(n)))[1::1]:\n if n%(i+1) == 0:\n return i+1\n return n\nn = int(input())\nprint(findFirstDelimeter(n))"}, {"source_code": "x=int(input())\nif x==1:\n print(1)\nfor i in range (2,x+1):\n if x%i==0:\n print(i)\n break"}, {"source_code": "def calc(n):\n if(n==1):\n return 1\n else:\n p=2\n while(n%p!=0):\n p+=1\n return p\n\nn=int(input())\n#n=3\nprint(calc(n))\n"}, {"source_code": "from math import sqrt\nn = int(input())\ndevi = set()\ni = 2\nS = sqrt(n)+1\nwhile (i <= S) and (i <= n):\n if n % i == 0:\n devi.add(i)\n if n//i != 1:\n devi.add(n//i)\n n //= i\n else:\n i += 1\nif len(devi) == 0:\n print(n)\nelif len(devi) == 1:\n print(*devi)\nelse:\n print(1)"}, {"source_code": "from sys import stdin, exit\n\nn = int(stdin.readline())\nnn = n\nf = n\ni = 2\nwhile i * i <= nn:\n while n % i == 0:\n n = n / i\n if f == nn:\n f = i\n else:\n if f != i:\n print(1)\n exit()\n i = i + 1\n\nprint(f)\n"}, {"source_code": "n = int(input())\nnn = n\ni = 2\ndziel = []\nwhile True:\n\tif n%i == 0:\n\t\tn //= i\n\t\tdziel.append(i)\n\telse:\n\t\ti += 1\n\tif i**2 > nn:\n\t\tif n > 1:\n\t\t\tdziel.append(n)\n\t\tbreak\nif len(dziel) == 1:\n\tprint(n)\nelse:\n\ta = set(dziel)\n\tif len(a) == 1:\n\t\tprint(dziel[0])\n\telse:\n\t\tprint(1)"}, {"source_code": "\"\"\"input\n4\n5\n4 3 1 4 5\n4\n4 4 4 4\n3\n1 1 1\n5\n5 5 1 1 5\n\"\"\"\n\nfrom sys import stdin,stdout\nI = lambda : map(int,stdin.readline().split())\nimport math \ndef maxPrimeFactors (n): \n\tmaxPrime = -1\n\tfor i in range(3, int(math.sqrt(n))+1, 2): \n\t\tif n % i == 0: \n\t\t\tmaxPrime = i \n\t\t\tbreak \n\tif int(maxPrime) == -1:\n\t\treturn n\n\telse:\n\t\treturn maxPrime\n\ndef cont(n):\n\t# ans = len(set(color))\n\tif n%2 == 1:\n\t\tprint maxPrimeFactors(n)\n\telse:\n\t\tprint 2\n# for i in range(1,10000):\nn = input()\nif n == 2:\n\tprint 2\nelif n == 3:\n\tprint 3\nelse:\n\tcont(n)"}, {"source_code": "\nfrom math import ceil\nfrom cmath import sqrt\n\n\ndef inp():\n return int(input())\n\n\ndef minput():\n return map(int, input().split())\n\n\ndef linput():\n return list(minput())\n\n\nn = inp()\nsn = ceil(sqrt(n).real)\nm = n\nif n % 2 == 0:\n m = 2\nz = 0 if m == n else 1\nfor i in range(3, sn + 2, 2):\n if n % i == 0:\n m = i\n z += 1\nif z > 1:\n print(1)\nelse:\n print(m if m == n else n // m)\n"}, {"source_code": "import math\nn=int(input())\nif n==1:\n print(1)\nelse:\n def isPrime(n) : \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 \n \n if isPrime(n):\n print(n)\n else:\n if n%2:\n for i in range(2,math.ceil(math.sqrt(n))):\n if n%i==0:\n print(i)\n break\n else:\n print(2)\n \n \n \n \n"}, {"source_code": "n = int(input())\nfactors = []\nif n%2==0:\n factors = [2]\n\n\nfor i in range(3, int(n**0.5)+1,2):\n if n%i==0:\n factors.append(i)\n if len(factors)>=2:\n break\n\nif n==1:\n print(1)\nelif len(factors)==0:\n print(n)\nelse:\n if len(factors)==1:\n print(factors[0])\n else:\n 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 itertools import imap as map, izip as zip, permutations, combinations, combinations_with_replacement\nfrom __builtin__ import xrange as range\nimport math\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 = 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 factors(n):\n\tfrom functools import reduce\n\treturn set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\t\n\ndef solve1(n):\n\tfacs = []\n\tfor i in range(1, int(n**.5)+1):\n\t\tif n%i == 0:\n\t\t\tfacs.append(i)\n\t\t\tif n//i != i:\n\t\t\t\tfacs.append(n//i)\n\tans = 0\n\tfor i in range(1, len(facs)):\n\t\tans = gcd(ans, facs[i])\n\treturn ans\n\ndef solve2(n):\n\tfacs = factors(n)\n\tans = 0\n\tfor fac in facs:\n\t\tif fac != 1:\n\t\t\tans = gcd(ans, fac)\n\treturn ans\n\ndef main():\n\tn = int(input())\n\tprint(solve2(n))\n\t\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 math import sqrt, ceil\ndef is_prime(a):\n if 1==a:\n return False\n if (2==a):\n return True\n else:\n return all(a % i for i in range(2, int(ceil(sqrt(a)+1))))\n\n\nn = int(input())\n\nif n==1:\n print(1)\nelif is_prime(n):\n print(n)\nelse:\n # found = False\n # for i in range(2, int(ceil(sqrt(n)+3))):\n # if n % i == 0 and is_prime(i):\n # if int(n/i) != i and is_prime(int(n/i)):\n # found = 1\n # break\n # if found:\n # found = 1\n # break\n # if not found:\n # found = i\n # print(found)\n numero = n\n for i in range(2, int(ceil(sqrt(n)+3))):\n if numero%i == 0:\n while numero !=1:\n if numero % i !=0:\n break\n numero /=i\n if is_prime(int(numero)):\n print(1)\n break\n else:\n print(i)\n break\n"}, {"source_code": "from math import sqrt, floor\n\ndef run_testcase():\n\tnumber = int(input())\n\n\t# prime_divisors_count = 0\n\n\t# # while number % 2 == 0:\n\t# # \tprime_divisors_count += 1\n\n\t# last_prime_divisor = 2\n\n\n\t# # def sieve():\n\n\n\t# if number % last_prime_divisor == 0:\n\t# \tprime_divisors_count += 1\n\t# \twhile number % last_prime_divisor == 0:\n\t# \t\t# number /= last_prime_divisor\n\t# \t\tnumber = number // last_prime_divisor\n\n\tnum_sqrt = sqrt(number)\n\n\t# primes = [True] * (int(sqrt) + 1)\n\t# primes = [True] * int(sqrt)\n\t# primes = [True] * (int(sqrt) + 1)\n\t# primes = [True] * (floor(num_sqrt) + 1)\n\tprimes = [True] * (floor(num_sqrt) + 2)\n\tprimes[0] = False\n\tprimes[1] = False\n\n\t# print(len(primes))\n\n\t# for i in range(len(primes)):\n\t# for i in range(len(2, primes)):\n\tfor i in range(2, len(primes)):\n\t\t# for j in range(i)\n\t\tif i*i >= num_sqrt:\n\t\t\tbreak\n\n\t\t# if prime[i] == True:\n\t\tif primes[i] == True:\n\t\t\tcontinue\n\n\t\t# j = 0\n\t\tj = 2 * i\n\t\twhile j < len(primes):\n\t\t\t# print(j)\n\t\t\tprimes[j] = False\n\t\t\tj += i\n\n\t\t# print('test')\n\n\tprime_divisors_count = 0\n\tlast_prime_divisor = 0\n\n\t# for value, prime in primes:\n\tfor value, prime in enumerate(primes):\n\t\tif prime:\n\t\t\t# print(value)\n\t\t\tif number % value == 0:\n\t\t\t\tlast_prime_divisor = value\n\t\t\t\tprime_divisors_count += 1\n\t\t\t\tif prime_divisors_count >= 2:\n\t\t\t\t\treturn 1\n\n\n\t# return last_prime_divisor\n\t# return last_prime_divisor if last_prime_divisor != 0 else number\n\n\t# print(last_prime_divisor)\n\n\t# if last_prime_divisor ** 2 == number:\n\t\t# return last_prime_divisor\n\tif last_prime_divisor == 0:\n\t\treturn number\n\telif last_prime_divisor ** 2 == number:\n\t\treturn last_prime_divisor\n\telse:\n\t\treturn 1\n\n\treturn last_prime_divisor if last_prime_divisor != 0 else number\n\n# testcase_count = int(input())\n\n# for i in range(testcase_count):\n# \tprint(str(run_testcase()))\n\t# run_testcase()\n# run_testcase()\nprint(str(run_testcase()))\n"}, {"source_code": "import os\nimport sys\nfrom io import BytesIO, IOBase\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\")\n\n\nsys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n##########################################################\nimport math\nimport bisect\n#for _ in range(int(input())):\nfrom collections import Counter\n#sys.setrecursionlimit(10**6)\n#dp=[[-1 for i in range(n+5)]for j in range(cap+5)]\n#arr= list(map(int, input().split()))\n#n,m= map(int, input().split())\n#arr= list(map(int, input().split()))\n#for _ in range(int(input())):\nimport bisect\n#n=int(input())\n#for _ in range(int(input())):\nfrom collections import deque\n#n,q= map(int, input().split())\n#rr =deque(map(int, input().split()))\nn=int(input())\nif n==0:\n print(\"\")\nelse:\n f=[]\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n f.append(i)\n if i!=n//i:\n f.append(n//i)\n f.append(0)\n f.append(n)\n f.sort()\n ans=10**12\n\n\n for i in range(len(f)-1):\n ans=min(ans,f[i+1]-f[i])\n if ans==10**12:\n print(n)\n else:\n print(ans)\n\n\n\n"}, {"source_code": "# Python program to print prime factors \n\nimport math \n\n# A function to print all prime factors of \n# a given number n \ndef primeFactors(n): \n\t\n\t# Print the number of two's that divide n \n\twhile n % 2 == 0: \n\t\tarr.add (2) \n\t\tn = n / 2\n\t\t\n\t# n must be odd at this point \n\t# so a skip of 2 ( i = i + 2) can be used \n\tfor i in range(3,int(math.sqrt(n))+1,2): \n\t\t\n\t\t# while i divides n , print i ad divide n \n\t\twhile n % i== 0: \n\t\t\tarr.add (i) \n\t\t\tn = n / i \n\t\t\t\n\t# Condition if n is a prime \n\t# number greater than 2 \n\tif n > 2: \n\t\tarr.add(n) \n\t\t\n# Driver Program to test above function \n\nn = int(input())\narr=set()\nprimeFactors(n) \nl=len(arr)\nif(l==0):\n print(l)\nif(l==1):\n for i in arr:\n print(i)\nelse:\n print(\"1\")\n\n# This code is contributed by Harshit Agrawal \n"}, {"source_code": "import math\ndef prime(m):\n\n k=0\n for i in range(2,int(math.sqrt(m))+1):\n if m%i==0:\n k=i\n break\n\n return k\n\nn=int(input())\nt=prime(n)\nif t==0:\n print(n)\nelif n%2==0:\n m=math.log(n,2)\n if m==int(m):\n print(2)\n else:\n print(1)\nelif n%2!=0:\n while n%t!=0:\n n=n//t\n if n==t:\n print(t)\n else:\n print(1)\n"}, {"source_code": "#Ashish Sagar\nimport math\ndef 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())\nif(isPrime(n)):\n print(n)\nelif n==1:\n print(1)\nelse:\n if n==4 or n==9 or n==25 or n==49:\n print(int(math.sqrt(n)))\n elif math.sqrt(n)*math.sqrt(n)==n:\n print(int(math.sqrt(n)))\n elif n%2==0:\n if n%3==0 or n%5==0 or n%7==0:\n print(1)\n else:\n print(2)\n elif n%3==0:\n if n%5==0 or n%7==0:\n print(1)\n else:\n print(3)\n elif n%5==0:\n if n%7==0:\n print(1)\n else:\n print(5)\n else:\n print(1)\n "}, {"source_code": "import math \ndef primeFactors(n,ans): \n \n while n % 2 == 0: \n ans.append(2) \n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n ans.append(i) \n n = n // i \n \n if n > 2: \n ans.append(n)\n \n \n\nn=int(input())\nans=[]\nif(n==1):\n print(1)\nelse:\n primeFactors(n,ans) \n print(ans[len(ans)-1])"}, {"source_code": "from math import sqrt,gcd,inf\nq=int(input())\nw=[]\ns=sqrt(q)\nfor i in range(2,int(s)):\n if q%i==0:w.append(i)\nfor i in w:w.append(q//i)\nif s==int(s):w.append(int(s))\nw.append(q)\nl=inf\nfor i in range(len(w)):\n for j in range(i+1,len(w)):\n l=min(l,gcd(w[i],w[j]))\nprint(min(l,q))"}, {"source_code": "from math import sqrt\nx=int(input())\nlol=[]\nif x==1 or x==2:\n print(x)\nelse: \n for i in range(2,int(sqrt(x))+1):\n if x%i==0:\n lol.append(i)\n while x%i==0:\n x//=i\n if x>2:\n lol.append(x)\n if len(lol)>0: \n print(min(lol))\n else:\n print(1)"}, {"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# sys.setrecursionlimit(int(pow(10, 2)))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.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\n\n\n\n# @lru_cache(None)\n\n\nprime=[1 for i in range(10**6+1)]\nprime[0]=0\nprime[1]=0\nfor i in range(10**6+1):\n if(prime[i]):\n for j in range(2*i,10**6+1,i):\n prime[j]=0\nn=l()[0]\nstep=n\nfor i in range(2,int(n**0.5)+2):\n if(n%i==0):\n step=i\n break\nprint(step)\n\n\n"}, {"source_code": "def min_divisor(n):\n if not n % 2:\n return 2\n\n i = 3\n\n while i * i <= n:\n if not n % i:\n return i\n\n i += 2\n\n return n\n\n\nn = int(input())\nprint(min_divisor(n))\n"}, {"source_code": "import math\nfrom decimal import *\nimport random\nimport sys\n\nn = int(input())\ntn = int(n)\nodd, even = False, False\nmult = []\nfor i in range(2, int(math.sqrt(tn))+2):\n if(n%i==0):\n while(n%i==0):\n n//=i\n if(i%2==0):\n even = True\n if(i%2==1):\n odd = True\n mult.append(i)\n if(n==1):\n break\nif(n!= 1 or tn==1):\n print(tn)\nelse:\n if(odd and even):\n print(1)\n else:\n print(mult[0])\n"}, {"source_code": "def soe(n):\n primes=[True]*(n+1)\n primes[0]=primes[1]=False\n i=4 \n while i=2:\n print(1)\nelif ct==1:\n print(f)\nelse:\n print(n)"}, {"source_code": "n = int(input())\nm = int(n**0.5)+2\nans = n\nfor i in range(2,m):\n\n if n%i==0:\n while(n%i==0):\n n = n//i\n ans = i\n break\n\nif ans==n:\n print(n)\nelse:\n p = ans\n x = [i for i in range(p)]\n for i in range(ans+1, m):\n if n%i==0:\n # print(i)\n if n//i>=p:\n x = [0 for j in range(p)]\n break\n else:\n for j in range(1,n//i+1):\n x[(j*i)%p] = 0\n while(n%i==0):\n n = n//i\n\n print(len(set(x)))\n\n\n\n\n\n"}, {"source_code": "from time import time\nn=int(input())\n\ndef primes_sieve2(n):\n limit = 10**6\n a = [True] * limit\n a[0] = a[1] = False\n for (i, isprime) in enumerate(a):\n if isprime:\n yield i\n for n in range(i*i, limit, i):\n a[n] = False\n\nprimes = primes_sieve2(n)\n\ndi = {}\nfor prime in primes:\n if prime==n:\n print(n)\n quit()\n if prime > n:\n break\n pc = prime\n di[pc] = prime\n while pc <= 10**12:\n pc*=prime\n if pc not in di:\n di[pc] = prime\n\nans=n\n\ndi2={}\nfrom collections import OrderedDict\nif n in di:\n for i in range(2,10**6+1):\n if n % i == 0:\n print(n)\n quit()\n print(di[n])\nelse:\n print(1)\n\n"}, {"source_code": "\ndef abs(n):\n return n if n >= 0 else -n\n\n\nn = int(input())\nsup = n ** (1 / 2)\ni = 2\nwhile ( n % i != 0 ):\n if ( i > sup ):\n i = n\n break\n i += 1\n\nprint(i)\n"}, {"source_code": "n=int(input())\nc=n\ns=set()\nr=int(n**.5)\ni=2\nt=1\nwhile i<=r:\n while n%i==0:s.add(i);n//=i\n i+=t\n t=2\nif len(s)==1:\n f=s.pop()\n if f==c:print(c)\n else:print(f)\nelse:print(1)"}, {"source_code": "\n# Author : raj1307 - Raj Singh\n# Date : 6.11.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\nfrom 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\n if(isPrime(n)):\n print(n)\n exit()\n \"\"\"\n for i in range(2,int(sqrt(n))):\n if n%2==0:\n d=i\n break\n\n \"\"\"\n \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\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": "import math\ndef findFirstDelimeter(n):\n for i in range(int(math.sqrt(n)))[1::1]:\n if n%(i+1) == 0:\n return i+1\n return n\nn = int(input())\nprint(findFirstDelimeter(n))"}, {"source_code": "import math \ndef primeFactors(n,ans): \n \n while n % 2 == 0: \n ans.append(2) \n n = n // 2\n for i in range(3,int(math.sqrt(n))+1,2): \n while n % i== 0: \n ans.append(i) \n n = n // i \n \n if n > 2: \n ans.append(n)\n \n \n \nn=int(input())\nans=[]\nif(n==1):\n print(1)\nelse:\n primeFactors(n,ans) \n if(len(ans)==1):\n print(ans[0])\n else:\n print(1)"}, {"source_code": "n = int(input())\n\nif n == 1:\n print(1)\n\nelse:\n import math\n if n > 1000:\n k = math.sqrt(n)\n k = math.ceil(k) \n else:\n k = n + 1\n p = n\n for i in range(2,k):\n if p % i == 0:\n while p % i == 0:\n p = p / i\n break\n\n if p == 1:\n print(i)\n\n elif p == n:\n print(n)\n \n else:\n print(1)"}, {"source_code": "\"\"\"input\n4\n5\n4 3 1 4 5\n4\n4 4 4 4\n3\n1 1 1\n5\n5 5 1 1 5\n\"\"\"\n\nfrom sys import stdin,stdout\nI = lambda : map(int,stdin.readline().split())\nimport math \ndef maxPrimeFactors (n): \n\tmaxPrime = -1\n\tfor i in range(3, int(math.sqrt(n))+1, 2): \n\t\tif n % i == 0: \n\t\t\tmaxPrime = i \n\t\t\tbreak \n\tif int(maxPrime) == -1:\n\t\treturn n\n\telse:\n\t\treturn maxPrime\n\ndef cont(n):\n\t# ans = len(set(color))\n\tif n%2 == 1:\n\t\tprint maxPrimeFactors(n)\n\telse:\n\t\tprint 2\n# for i in range(1,10000):\nn = input()\nif n == 2:\n\tprint 2\nelif n == 3:\n\tprint 3\nelse:\n\tcont(n)"}, {"source_code": "def isprime(n):\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n return False\n return True\n\ndef check_all_even(arr):\n for i in arr:\n if i%2 != 0:\n return False\n return True\n\ndef get_color(n):\n if isprime(n):\n return n\n \n #Tim \u01af\u1edbc c\u1ee7a n\n arr = []\n for i in range(2,int(n**0.5)+1):\n if n%i==0:\n arr.append(i)\n\n if n%2 == 0:\n if check_all_even(arr):\n return 2\n else:\n return 1\n else:\n return arr[0]\n # return int(n**0.5)\n\n# def get_color(n):\n# if isprime(n):\n# return n\n# #Tim \u01af\u1edbc c\u1ee7a n\n# # arr = []\n# # for i in range(2,n):\n# # if n%i==0:\n# # arr.append(i\n# if n%2 == 0:\n# x = int(n**0.5)\n# if x*x == n:\n# return 2\n# else:\n# return 1\n# else:\n# # x = int(n**0.5)\n# # if x*x == n:\n# # return x\n# for i in range(2,n):\n# if n%i==0:\n# return i\n# # return int(n**0.5)\n\n\n\nif __name__ == \"__main__\":\n n = int(input())\n print (get_color(n))\n # for i in range(100):\n # print (i, get_color(i))"}, {"source_code": "#!/usr/local/bin/python3\n# -*- coding: utf-8 -*-\n\nfrom math import sqrt\n\nn = int(input())\nif n <= 3:\n print(n)\nelse:\n rec = n\n nums = []\n dict_ = {}\n while n:\n m = int(sqrt(n))\n flag = False\n for i in range(2, m + 1):\n if not n % i:\n if not dict_.get(i, False):\n nums.append(i)\n flag = True\n dict_[i] = True\n break\n if not flag:\n nums.append(n)\n break\n else:\n n = int(n / i)\n if n <= 3:\n if not dict_.get(n, False):\n nums.append(n)\n break\n size = len(nums)\n \n if size == 1:\n print(nums[0])\n if not size:\n print(rec)\n if size > 1:\n print(1)\n"}, {"source_code": "import math\nn = int(input())\nx = int(math.sqrt(n))\nif x * x == n:\n print(int(x))\n exit(0)\n\nprime = True\nfor i in range(2, x + 1):\n if n % i == 0:\n prime = False\n break\n\nprint(n if prime else 2)"}, {"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\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\n\nn = ii()\npr = sieve(10**6 + 1)\nc = []\nif n == 1:\n exit(print(1))\n\nif prime(n):\n exit(print(n))\n\nfor i in pr:\n if n % i == 0:\n c.append(i)\n if len(c) == 2:\n break\nprint(1) if len(c) == 2 else print(c[0])\n\n\n\n"}, {"source_code": "import math\ndef prime(m):\n k=0\n for i in range(2,int(math.sqrt(m))+1):\n if m%i==0:\n k=i\n break\n return k\n\nn=int(input())\nt=prime(n)\nif t==0:\n print(n)\nelif n%2==0:\n m=math.log(n,2)\n if m==int(m):\n print(2)\n else:\n print(1)\nelif n%2!=0:\n print(n//t)\nelse:\n print(n//t)\n"}, {"source_code": "n = int(input())\np = int(pow(n,0.5))\ndiv = []\nprime = 0\nfor i in range(2,p+1):\n if n % i == 0 :\n div.append(i)\n for j in range(2,int(pow(i,0.5)+1)):\n if i%j==0:\n break\n else:\n prime += 1\n m = int(n/i)\n if m!=i:\n for j in range(2,int(pow(int(n/i),0.5)+1)):\n if i%j==0:\n break\n else:\n prime += 1\n if prime == 2:\n print(1)\n break\nelse:\n if div == []:\n print(n)\n else:\n print(min(div))\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 --------------------\n\nimport math\nimport bisect\n\nprimes=[2]\nfor s in range(3,10**6+1):\n ind=min(bisect.bisect_left(primes,math.ceil(math.sqrt(s))+1),len(primes)-1)\n broke=False\n for b in range(ind):\n if s%primes[b]==0:\n broke=True\n break\n if broke==False:\n primes.append(s)\nn=int(input())\n#prime multiply by prime? 1 colour\n#prime by 1? thats prime colours\n#find its prime factors\ntempy=n+0\nprimefacs=[]\nsetty=set([])\nindy=min(bisect.bisect_left(primes,math.ceil(math.sqrt(n))+1),len(primes)-1)\nfor s in range(ind):\n if n%primes[s]==0:\n primefacs.append(primes[s])\n setty.add(primes[s])\n tempy=tempy//primes[s]\nif tempy>1 and not(tempy in setty):\n primefacs.append(tempy)\nif len(primefacs)>=2:\n print(1)\nelif len(primefacs)==1:\n print(primefacs[0])\nelse:\n print(1)"}, {"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\ndef is_prime(n):\n if n == 1: return False\n\n for k in range(2, int(math.sqrt(n)) + 1):\n if n % k == 0:\n return False\n\n return True\n\nse = set()\nfor i in range(100):\n se.add(2**(i+1))\nn = inp()\nif is_prime(n):\n print(n)\nelif n in se:\n print(2)\nelse:\n print(1)"}, {"source_code": "import math\ndef prime(m):\n\n k=0\n for i in range(2,int(math.sqrt(m))+1):\n if m%i==0:\n k=i\n break\n\n return k\n\nn=int(input())\nt=prime(n)\nif t==0:\n print(n)\nelif n%2==0:\n m=math.log(n,2)\n if m==int(m):\n print(2)\n else:\n print(1)\nelif n%2!=0:\n print(1)"}, {"source_code": "import math\nn = int(input())\nprimes = []\nfor i in range(2, math.floor(math.sqrt(n)) + 1):\n cnt_now = 0\n if n % i == 0:\n while n % i == 0:\n n = n // i\n primes.append(i)\nif len(primes) >= 2:\n print(1)\nelif len(primes) == 1:\n print(primes[0])\nelse:\n print(n)"}, {"source_code": "n = int(input())\ncount = 0\ndic = dict()\nfor i in range(1,n):\n # print('this is i ', i)\n for j in range(i+1,n+1):\n results = abs(i-j)\n if results>1 and n%results ==0:\n dic[str(i)+'-'+str(j)] = results\nif n ==0:\n print(0)\nelif dic:\n print(len(dic))\nelse:\n print(n)"}, {"source_code": "x=int(input())\na=x\nz=0\nfor i in range (2,int(x**0.5)+2):\n if x%i==0 and i%a!=0:\n a=i\n z+=1\n \nif x==1 or z>1:\n print(1)\nelse:\n print(a)\n \n"}], "src_uid": "f553e89e267c223fd5acf0dd2bc1706b"} {"nl": {"description": "InputThe input contains a single integer $$$a$$$ ($$$0 \\le a \\le 63$$$).OutputOutput a single number.ExamplesInput\n2\nOutput\n2\nInput\n5\nOutput\n24\nInput\n35\nOutput\n50\n", "input_spec": "The input contains a single integer $$$a$$$ ($$$0 \\le a \\le 63$$$).", "output_spec": "Output a single number.", "sample_inputs": ["2", "5", "35"], "sample_outputs": ["2", "24", "50"], "notes": null}, "positive_code": [{"source_code": "p = [0, 5, 3, 2, 4, 1]\n# p = [0, 3, 5, 2, 4, 1]\ns = bin(int(input()))[2:].zfill(6)\nprint(int(\"\".join([s[x] for x in p]), 2))\n"}, {"source_code": "n = int(input())\n\nn_bin = bin(n)\n\nn_bin = n_bin[2:]\n\n\nif len(n_bin) < 6:\n\tdelta = 6 - len(n_bin)\n\t\n\tfor i in range(delta):\n\t\tn_bin = n_bin[:i] + \"0\" + n_bin[i:]\n\nb = n_bin[1]\nc = n_bin[2]\nd = n_bin[3]\nf = n_bin[5]\n\nn_bin = n_bin[:1] + f + n_bin[2:]\nn_bin = n_bin[:2] + d + n_bin[3:]\nn_bin = n_bin[:3] + c + n_bin[4:]\nn_bin = n_bin[:5] + b\n\n\nprint(int(n_bin, 2))"}, {"source_code": "n = int(input())\ntemp = n\nl = []\nval = [32,16,8,4,2,1]\nwhile temp > 0:\n\tl.append(temp%2)\n\ttemp = temp//2\nwhile len(l) < 6:\n\tl.append(0)\nl.reverse()\ntemp = l[5]\nl[5] = l[1]\nl[1] = temp\ntemp = l[2]\nl[2] = l[3]\nl[3] = temp\ns = 0\nfor i in range(6):\n\ts += l[i]*val[i]\nprint(s)"}, {"source_code": "def decimalToBinary(n): \n return bin(n).replace(\"0b\", \"\") \n \n\ndec_val = int(input())\nnumero_binario =decimalToBinary(dec_val) \ncant_agregar = 6-len(numero_binario)\n\nnumero_binario = (cant_agregar * '0') + numero_binario\n\n\n# 2-6\n# 3-4\n#4-3\n# 6-2\n\nnum_final = numero_binario[0] + numero_binario[5] + numero_binario[3] + numero_binario[2] + numero_binario[4] + numero_binario[1]\n\nprint(int(num_final, base =2 ))\n\n# And after happily lived ever they\n# and they lived happily ever after"}, {"source_code": "def getBit(val):\n ret = []\n for _ in xrange(6):\n ret.append(val % 2)\n val /= 2\n return ret\n\ndef getVal(bits):\n ret = 0\n tmp = 1\n for bit in bits:\n ret += tmp * bit\n tmp *= 2\n return ret\n\nval = int(raw_input(''))\nbits = getBit(val)\n# print bits\n\nbits[2], bits[3] = bits[3], bits[2]\nbits[0], bits[4] = bits[4], bits[0]\nprint getVal(bits)"}, {"source_code": "n = bin(int(input()))[2::].rjust(6, '0')\nper = [0, 5, 3, 2, 4, 1]\nprint(int(''.join(n[x] for x in per), 2))\n# 010011\n# 110010"}, {"source_code": "import atexit\nimport io\nimport sys\nimport math\nfrom collections import defaultdict\n\n_INPUT_LINES = sys.stdin.read().splitlines()\nraw_input = iter(_INPUT_LINES).next\n_OUTPUT_BUFFER = io.BytesIO()\nsys.stdout = _OUTPUT_BUFFER\n\n@atexit.register\ndef write():\n sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\n\nt=int(raw_input())\nb=bin(t).lstrip('0b')\nb='0'*(6-len(b))+b\ns='0b'+b[0]+b[5]+b[3]+b[2]+b[4]+b[1]\nprint int(s,2)\n "}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\nx = int(input())\n\ny=[x&32,x&16,x&8,x&4,x&2,x&1]\nfor i in range(len(y)):\n if y[i]: y[i] = 1\n#print(y)\n#And after happily lived ever they\n#And they lived happily ever after\ny=[y[0],y[5],y[3],y[2],y[4],y[1]]\n#print(y)\nx=(y[0]<<5)+(y[1]<<4)+(y[2]<<3)+(y[3]<<2)+(y[4]<<1)+(y[5])\nprint(x)"}, {"source_code": "a=input()\np=bin(a)[2:]\np='0'*(6-len(p))+p\nq='0b'+p[0]+p[5]+p[3]+p[2]+p[4]+p[1]\nprint int(q,2)"}, {"source_code": "arr=[0]*6\nbarr=[0]*6\nn=int(input())\ni=5\nwhile(n>0):\n\t# print(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\nbarr[5]+=arr[5]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "a = int(input())\nb = bin(a)[2:]\nb = \"0\"*(6-len(b)) + b\nnb = \"0b\" + b[0] + b[5] + b[3] + b[2] + b[4] + b[1]\nprint(int(nb,2))"}, {"source_code": "a = int(input())\nb = 0\nfor i in range(6):\n b += ((a >> i) & 1) << [4, 1, 3, 2, 0, 5][i]\nprint(b)\n"}, {"source_code": "n = bin(int(input()))[2::].rjust(6, '0')\nper = [0, 5, 3, 2, 4, 1]\nprint(int(''.join(n[x] for x in per), 2))\n# 010011\n# 110010"}, {"source_code": "a = int(input())\n# and they lived happily ever after\n# and after happily lived ever they\nx = bin(a)\nx = x[2:]\nx = (6-len(x))*'0' + x\nx = list(x)\nt1 = x[1]\nx[1] = x[5]\nt2 = x[2]\nx[2] = x[3]\nx[3] = t2\nx[5] = t1\ny = ''\nfor el in x:\n\ty += el\ny = int(y,2)\nprint(y)\n"}, {"source_code": "a = int(input())\nx = []\nfor i in range(6):\n x.append(a % 2)\n a //= 2\nx = list(reversed(x))\nprint(x[1] * 1 + x[4] * 2 + x[2] * 4 + x[3] * 8 + x[5] * 16 + x[0] * 32)\n"}, {"source_code": "#!/usr/bin/env python\nimport os\nimport sys\nfrom io import BytesIO, IOBase\n# from math import *\n\nreadn = lambda : int(input())\nreadl = lambda : list(map(int,input().split()))\nreads = lambda : input()\nreadns = lambda : map(int,input().split())\ndef main():\n n = readn()\n bn = bin(n)[2:]\n ans = []\n for i in range(6-len(bn)):\n ans.append('0')\n \n ans = ans+list(bn)\n # print(ans)\n ans[1],ans[5] = ans[5],ans[1]\n ans[2],ans[3] = ans[3],ans[2]\n print(int(''.join(ans),2))\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\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=bin(int(input())+64)[-6:]\nprint(int(''.join(n[c] for c in[0,5,3,2,4,1]),2))\n"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\nx = int(input())\n\ny=[x&32,x&16,x&8,x&4,x&2,x&1]\nfor i in range(len(y)):\n if y[i]: y[i] = 1\n#print(y)\n#And after happily lived ever they\n#And they lived happily ever after\ny=[y[0],y[5],y[3],y[2],y[4],y[1]]\n#print(y)\nx=(y[0]<<5)+(y[1]<<4)+(y[2]<<3)+(y[3]<<2)+(y[4]<<1)+(y[5])\nprint(x)"}, {"source_code": "a = int(input())\nb = 0\nfor i in range(6):\n b += ((a >> i) & 1) << [4, 1, 3, 2, 0, 5][i]\nprint(b)\n"}, {"source_code": "a = bin(int(input()))[2:].zfill(6)\nb = ''.join([a[0], a[5], a[3], a[2], a[4], a[1]])\nprint(int(b, base=2))\n"}, {"source_code": "n = int(input())\n\narr = []\nfor i in range(6):\n arr.append(n % 2)\n n //= 2\n\narr.reverse()\n\nnew_arr = [0] * 6\nnew_arr[0] = arr[0]\nnew_arr[1] = arr[5]\nnew_arr[2] = arr[3]\nnew_arr[3] = arr[2]\nnew_arr[4] = arr[4]\nnew_arr[5] = arr[1]\n\nnew_arr.reverse()\n\nnn = 0\nfor i in range(6):\n nn += new_arr[i] * 2**i\n\nprint(nn)"}, {"source_code": "a = int(input())\nb = 0\nfor i in range(6):\n b += ((a >> i) & 1) << [4, 1, 3, 2, 0, 5][i]\nprint(b)\n"}, {"source_code": "s=\"{:06b}\".format(int(input()))\nprint(int(s[0]+s[5]+s[3]+s[2]+s[4]+s[1],2))"}, {"source_code": "n=int(input())\nx=list('{0:06b}'.format(n))\nb1=x[5]\nx[5]=x[1]\nx[1]=b1\nb2=x[3]\nx[3]=x[2]\nx[2]=b2\nnew=\"\".join(x)\nprint(int(new, 2))"}, {"source_code": "a=int(input())\ns=bin(a)[2:]\nfor i in range(len(s),6):\n s='0'+s\na=s[0]+s[5]+s[3]+s[2]+s[4]+s[1]\nprint(int(a,2))\n"}, {"source_code": "n=int(input())\nsp=[]\nfor i in range(6):\n sp.append(n%2)\n n//=2\nsp1=sp[0:]\nsp1.reverse()\nsp1[1], sp1[5]=sp1[5], sp1[1]\nsp1[2], sp1[3]=sp1[3], sp1[2]\ncount=0\nsp1.reverse()\nfor i in range(6):\n count+=sp1[i]*2**i\nprint(count)\n"}, {"source_code": "from copy import copy\na = int(input())\n\naRepr = list(bin(a)[2:].zfill(6))\n\nanswer = copy(aRepr)\nanswer[1] = aRepr[5]\nanswer[2] = aRepr[3]\nanswer[3] = aRepr[2]\nanswer[5] = aRepr[1]\n\nanswer = ''.join(answer)\nanswer = int(answer, base = 2)\nprint(answer)"}, {"source_code": "n = int(input())\n \nbn = bin(n)[2:]\nbn = \"0\"*(6-len(bn))+bn\n \nprint(int(bn[0]+bn[5]+bn[3]+bn[2]+bn[4]+bn[1],2))"}, {"source_code": "#000010\n#000010\n\n#000101\n#011000\n\n#100011\n#110010\n\nn = bin(int(input()))[2:]\nwhile len(n) < 6: n = '0' + n\n\nprint(int(n[0] + n[5] + n[3] + n[2] + n[4] + n[1], 2))\n"}, {"source_code": "def happyafter(X):\n temp=bin(X).replace(\"0b\",\"\")\n while(len(temp)<6):\n temp=\"0\"+temp\n res=temp[0]+temp[5]+temp[3]+temp[2]+temp[4]+temp[1]\n return int(res,2)\nif __name__ == \"__main__\":\n x=int(input())\n print(happyafter(x))"}, {"source_code": "x=int(input())\nA=[]\nfor i in range(1,7):\n A.append(x//pow(2,7-i))\n x=x%pow(2,7-i)\nA.append(x%2)\n#print(A)\n\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[3]*pow(2,2)+A[5]*pow(2,1)+A[2]\nprint(new)\n\n\n\n\n"}, {"source_code": "map = {0:0, 1:5, 2:3, 3:2, 4:4, 5:1}\ns = \"{:>06b}\".format(int(input()))\ns2 = [\"\"]*6\nfor i in range(6):\n\ts2[map[i]]=s[i]\nprint(int(\"\".join(s2), 2))"}, {"source_code": "n = int(input())\ns = \"{:06b}\".format(n)\n#print(s)\nres = s[0] + s[5] + s[3] + s[2] + s[4] + s[1]\n#print(res)\nprint(int(res, 2))"}, {"source_code": "s = bin(int(input()))[2:]\ns = \"%06d\" % int(s)\nprint(int(s[0]+s[5]+s[3]+s[2]+s[4]+s[1],2))"}, {"source_code": "def helper_to_binary(n):\n ans = []\n for i in range(6):\n ans.append(n%2)\n n = n//2\n return ans[::-1]\ndef helper_from_binary(l):\n ans = 0\n for i in range(6):\n ans += l[::-1][i]*2**i\n return ans\nn = int(input())\npermute = [0,5,3,2,4,1]\nprint(helper_from_binary([helper_to_binary(n)[permute[i]] for i in range(6)]))"}, {"source_code": "x = int(input())\np = [4, 1, 3, 2, 0, 5]\ny = 0\nfor i in range(6):\n if x & (1 << i):\n y |= 1 << p[i]\nprint(y)"}, {"source_code": "a = int(input())\nb = bin(a)[2:]\nb = \"0\"*(6-len(b)) + b\nnb = \"0b\" + b[0] + b[5] + b[3] + b[2] + b[4] + b[1]\nprint(int(nb,2))"}, {"source_code": "def binaryToDecimal(binary): \n binary1 = binary \n decimal, i, n = 0, 0, 0\n while(binary != 0): \n dec = binary % 10\n decimal = decimal + dec * pow(2, i) \n binary = binary//10\n i += 1\n print(decimal)\n\nn=int(input())\np=bin(n)[2:]\nstr=(\"000000\"+str(p))[-6:]\nl=list(str)\na,b,c,d=l[1],l[2],l[3],l[5]\nns=l[0]+d+c+b+l[4]+a\nbinaryToDecimal(int(ns))"}, {"source_code": "s = bin(int(input()))[2:].zfill(6)\nl = []\nfor i in [0, 5, 3, 2, 4, 1]:\n l.append(s[i])\nprint(int(''.join(l), 2))"}, {"source_code": "a = bin(int(input())+64)[3:]\nv=int(a[0])*32+int(a[5])*16+int(a[3])*8+int(a[2])*4+int(a[4])*2+int(a[1])\nprint (v)\n# FAZ ISSO AQUI :)"}, {"source_code": "t = int(input())\nttt=t\ntt=0\nif t>31:\n t=t-32\n tt=tt+32\nif t>15:\n t=t-16\n tt=tt+1\nif t>7:\n t=t-8\n tt=tt+4\nif t>3:\n t=t-4\n tt=tt+8\nif t>1:\n t=t-2\n tt=tt+2\nif t>0:\n t=t-1\n tt=tt+16\nprint(tt)\n \n \n"}, {"source_code": "a = bin(int(input()))[2:]\na = a.zfill(6)\nb = \"\".join([a[0], a[5], a[3], a[2], a[4], a[1]])\nprint(int(b, 2))"}, {"source_code": "n=int(input())\ns=bin(n)\nd=s[2:len(s)]\nd=d[::-1]\nfor i in range(len(d),6):\n d+=\"0\"\nd=d[::-1]\np=str(d[0])+str(d[5])+str(d[3])+str(d[2])+str(d[4])+str(d[1])\nprint(int(p,2))"}, {"source_code": "x = int(input())\ny = bin(x)[2:]\ny = (6 - len(y))*'0' + y\ns = y[0] + y[5] + y[3] + y[2] + y[4] + y[1]\nprint(int(s, 2))\n"}, {"source_code": "arr=[0]*6\nbarr=[0]*6\nn=int(input())\ni=5\nwhile(n>0):\n\t# print(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\nbarr[5]+=arr[5]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nA = 'and they lived happily ever after'.split()\nB = 'and after happily lived ever they'.split()\n\nn = int(input())\n\ns = [int(x) for x in bin(n + 64)[3:]]\nt = [0]*6\nfor i in range(6):\n if s[i]:\n t[B.index(A[i])] = 1\n\nprint int(''.join(str(x) for x in t) , 2)\n"}, {"source_code": "a = bin(int(input()))\na = a[2:len(a)]\ns = '0'*(6-len(a))\ns = s + a\ns = '0b'+s[0]+s[5]+s[3]+s[2]+s[4]+s[1]\nprint(int(s,2))\n\n \n"}, {"source_code": "n=int(input())\nb=''\nn = \"{0:b}\".format(n)\nif len(n)!=7:\n n = '0'*(7-len(n))+n\n\nb+=n[0]+n[1]+n[6]+n[4]+n[3]+n[5]+n[2]\n\nprint(int(b,2))\n"}, {"source_code": "def main_function():\n a = bin(int(input()))[2:]\n a = '0'*(6 - len(a)) + a\n print(int(a[0] + a[5] + a[3] + a[2] + a[4] + a[1], 2))\n\n\nif __name__ == '__main__':\n main_function()"}, {"source_code": "def binaryToDecimal(n): \n return int(n,2) \n\n\nn = int(input())\n# 164352\nx=str(bin(n))[2:]\n\nif len(x)<6:\n diff=6-len(x)\n temp=''\n for i in range(diff):\n temp+='0'\n x=temp+x\n\ngg=x[0]+x[5]+x[3]+x[2]+x[4]+x[1]\n\nprint(binaryToDecimal(gg))\n\n\n\n"}, {"source_code": "q=bin(int(input()))[2:]\nif len(q)<6:\n q='0'*(6-len(q))+q\nprint(int(q[0]+q[5]+q[3]+q[2]+q[4]+q[1], 2))\n"}, {"source_code": "n=int(input())\nn=bin(n)[2:]\nif len(n)!=7:\n n='0'*(7-len(n))+n\nprint(int(n[0]+n[1]+n[6]+n[4]+n[3]+n[5]+n[2],2))"}, {"source_code": "#code\nn=int(input())\nx=bin(n)\nx=str(x)\nx=x[2:]\nx=list(x)\ns=[]\nfor i in range(6-len(x)):\n s.append(0)\nfor i in x:\n s.append(i)\nt=s[1]\ns[1]=s[5]\ns[5]=t\nt=s[2]\ns[2]=s[3]\ns[3]=t\nl=\"\"\nfor i in s:\n l=l+str(i)\nprint(int(l,2))"}, {"source_code": "u=0\nx=bin(int(input()))[2:]\nwhile len(x) !=6:\n x=str(x)\n x='0'+x\nif x[0]=='1':\n u+=32\nif x[1]=='1':\n u+=1\nif x[2]=='1':\n u+=4\nif x[3]=='1':\n u+=8\nif x[4]=='1':\n u+=2\nif x[5]=='1':\n u+=16\nprint(u)"}, {"source_code": "n = int(input())\ntemp = n\nl = []\nval = [32,16,8,4,2,1]\nwhile temp > 0:\n\tl.append(temp%2)\n\ttemp = temp//2\nwhile len(l) < 6:\n\tl.append(0)\nl.reverse()\ntemp = l[5]\nl[5] = l[1]\nl[1] = temp\ntemp = l[2]\nl[2] = l[3]\nl[3] = temp\ns = 0\nfor i in range(6):\n\ts += l[i]*val[i]\nprint(s)"}, {"source_code": "ns = bin(int(input()))[2:].zfill(6)\n \np = [0, 5, 3, 2, 4, 1]\n \nprint(int(''.join(ns[t] for t in p),2))\n"}, {"source_code": "f = [4, 1, 3, 2, 0, 5]\nx = int(input())\ny = 0\nfor i in range(6):\n y += (x>>i&1) << f[i]\nprint(y)"}, {"source_code": "# 164352\nn = int(input())\narr = [0, 5, 3, 2, 4, 1]\nN = n\nnb = []\nwhile N > 0:\n nb.append(N % 2)\n N //= 2\nfor i in range(6 - len(nb)):\n nb.append(0)\nnb = nb[::-1]\nnnb = [0 for i in range(6)]\nfor i in range(6):\n nnb[i] = nb[arr[i]]\nnum = 0\nfor i in range(len(nnb)):\n num *= 2\n num += nnb[i]\nprint(num)\n"}, {"source_code": "X = int(input())\nTemp = bin(X)[2:]\nTemp = \"0\" * (6 - len(Temp)) + Temp\nprint(int(Temp[0] + Temp[-1] + Temp[-3] + Temp[2] + Temp[-2] + Temp[1], 2))\n# Hope the best for Ravens member\n"}, {"source_code": "a=int(input())\na='0'*(6-len(bin(a)[2:]))+bin(a)[2:]\nt=[0, 5, 3, 2, 4, 1]\nb=''\nfor i in t:\n\tb+=str(a[i])\nprint(int(b,2))"}, {"source_code": "a = bin(int(input()))\ni = len(a) - 1\ny = 1\nres = 0\nwhile a[i] != 'b':\n\tif a[i] == '1':\n\t\tif y == 1:\n\t\t\tres += 16\n\t\tif y == 2:\n\t\t\tres += 2\n\t\tif y == 3:\n\t\t\tres += 8\n\t\tif y == 4:\n\t\t\tres += 4\n\t\tif y == 5:\n\t\t\tres += 1\n\t\tif y == 6:\n\t\t\tres += 32\n\ti -= 1\n\ty += 1\nprint(res)"}, {"source_code": "n = int(input())\nb = bin(n)[2:]\nwhile(len(b)<6):\n b = '0'+b\nb = list(b)\nb[5],b[1] = b[1],b[5]\nb[2],b[3] = b[3],b[2]\ns = ''\nfor i in b:\n s+=i\nprint(int(s,2))"}, {"source_code": "inp = int(input())\npattern = '164352'\nbase2 = format(inp, '06b')\narr = ['']*6\nfor i in range(6):\n newIndex = int(pattern[i]) - 1\n arr[newIndex] = base2[i]\nprint(int(''.join(arr), 2))"}, {"source_code": "n = int(input())\nb = bin(n).replace(\"0b\", \"\")\n\nf = \"0\"*(7-len(b)) + b\n\nmapping = [0,1,6,4,3,5,2]\nans = [\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"]\n\nfor i in range(7):\n if f[i] == \"1\":\n ans[mapping[i]] = \"1\"\n \n# print(ans,sep=\"\")\n\nok = False\ns = \"0\"\nfor c in ans:\n if c == \"1\":\n ok = True\n if ok:\n s += str(c)\n\ns = int(s,2)\nprint(s)"}, {"source_code": "a = bin(int(input())).replace(\"0b\", \"\")\na = list(a)\na.__reversed__()\nwhile len(a) < 6:\n a.insert(0, '0')\na = \"\".join(a)\nn = a[0] + a[5] + a[3] + a[2] + a[4] + a[1]\nprint(int(\"\".join(n), 2))\n"}, {"source_code": "n = bin(int(input()))[2:].rjust(6, '0')\ns = n[0] + n[5] + n[3] + n[2] + n[4] + n[1]\nprint(int(s, 2))"}, {"source_code": "ns = bin(int(input()))[2:].zfill(6)\n \np = [0, 5, 3, 2, 4, 1]\n \nprint(int(''.join(ns[t] for t in p),2))\n"}, {"source_code": "from sys import stdin,stdout\nn=int(stdin.readline())\nb=list(bin(n)[2:].zfill(6))\nl=b[:]\nb[1],b[5]=l[5],l[1]\nb[2],b[3]=l[3],l[2]\nb=\"\".join(b)\nprint(int(b,2))\n "}, {"source_code": "n = bin(int(input()))[2::].rjust(6, '0')\nper = [0, 5, 3, 2, 4, 1]\nprint(int(''.join(n[x] for x in per), 2))\n# 010011\n# 110010"}, {"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nA = 'and they lived happily ever after'.split()\nB = 'and after happily lived ever they'.split()\n\nn = int(input())\n\ns = [int(x) for x in bin(n + 64)[3:]]\nt = [0]*6\nfor i in range(6):\n if s[i]:\n t[B.index(A[i])] = 1\n\nprint int(''.join(str(x) for x in t) , 2)\n"}, {"source_code": "a = int(input())+64\nx = list(str(bin(a)))\nt = x[4]\nx[4] = x[8]\nx[8] = t\nt = x[5];\nx[5] = x[6]\nx[6] = t\nprint(int(''.join(map(str, x))[3:], 2))\n"}, {"source_code": "arr=[0]*6\nbarr=[0]*6\nn=int(input())\ni=5\nwhile(n>0):\n\t# print(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\nbarr[5]+=arr[5]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "arr=[0]*6\nbarr=[0]*6\nn=int(input())\ni=5\nwhile(n>0):\n\t# print(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\nbarr[5]+=arr[5]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "n=int(input())\n\nX=[0,5,3,2,4,1]\nANS=[0]*6\n\nfor i in range(6):\n if n & (1<0):\n\t# print(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\nbarr[5]+=arr[5]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "a = int(raw_input())\nc = []\nfor i in xrange(15):\n c.append(a & 1)\n a >>= 1\n#print c\nt = c[0]\nc[0] = c[4]\nc[4] = t\nt = c[2]\nc[2] = c[3]\nc[3] = t\n#print c\nx = 0\ny = 1\nfor i in c:\n x |= i * y\n y <<= 1\nprint x"}, {"source_code": "n=int(input())\ns=bin(n)\ns=s[2:]\ns=\"0\"*(6-len(s))+s\n# print(s)\ns1=s[0]+s[5]+s[3]+s[2]+s[4]+s[1]\nprint(int(s1,2))"}, {"source_code": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\nx = int(input())\n\ny=[x&32,x&16,x&8,x&4,x&2,x&1]\nfor i in range(len(y)):\n if y[i]: y[i] = 1\n#print(y)\n#And after happily lived ever they\n#And they lived happily ever after\ny=[y[0],y[5],y[3],y[2],y[4],y[1]]\n#print(y)\nx=(y[0]<<5)+(y[1]<<4)+(y[2]<<3)+(y[3]<<2)+(y[4]<<1)+(y[5])\nprint(x)"}, {"source_code": "a = [ch for ch in \"{0:06b}\".format(int(input()))]\na[1], a[5], a[2], a[3] = a[5], a[1], a[3], a[2]\nprint(int(''.join(a), 2))"}, {"source_code": "a = bin(int(input()))\ni = len(a) - 1\ny = 1\nres = 0\nwhile a[i] != 'b':\n\tif a[i] == '1':\n\t\tif y == 1:\n\t\t\tres += 16\n\t\tif y == 2:\n\t\t\tres += 2\n\t\tif y == 3:\n\t\t\tres += 8\n\t\tif y == 4:\n\t\t\tres += 4\n\t\tif y == 5:\n\t\t\tres += 1\n\t\tif y == 6:\n\t\t\tres += 32\n\ti -= 1\n\ty += 1\nprint(res)"}, {"source_code": "def binaryToDecimal(n): \n return int(n,2) \n\n\nn = int(input())\n# 164352\nx=str(bin(n))[2:]\n\nif len(x)<6:\n diff=6-len(x)\n temp=''\n for i in range(diff):\n temp+='0'\n x=temp+x\n\ngg=x[0]+x[5]+x[3]+x[2]+x[4]+x[1]\n\nprint(binaryToDecimal(gg))\n\n\n\n"}, {"source_code": "n = int(input())\n \nbn = bin(n)[2:]\nbn = \"0\"*(6-len(bn))+bn\n \nprint(int(bn[0]+bn[5]+bn[3]+bn[2]+bn[4]+bn[1],2))"}, {"source_code": "x=int(input())\nA=[]\nfor i in range(1,7):\n A.append(x//pow(2,7-i))\n x=x%pow(2,7-i)\nA.append(x%2)\n#print(A)\n\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[3]*pow(2,2)+A[5]*pow(2,1)+A[2]\nprint(new)\n\n\n\n\n"}, {"source_code": "i=int(input())\nj=(i%2)*16\ni/=2\nj=int(j)\ni=int(i)\nj+=(i%2)*2\ni/=2\nj=int(j)\ni=int(i)\nj+=(i%2)*8\ni/=2\nj=int(j)\ni=int(i)\nj+=(i%2)*4\ni/=2\nj=int(j)\ni=int(i)\nj+=(i%2)*1\ni/=2\nj=int(j)\ni=int(i)\nj+=(i%2)*32\nj=int(j)\ni=int(i)\nprint(j)\n"}, {"source_code": "a = bin(int(input())+64)[3:]\nv=int(a[0])*32+int(a[5])*16+int(a[3])*8+int(a[2])*4+int(a[4])*2+int(a[1])\nprint (v)"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n\tn = input()\n\tb = str(bin(n))\n\ts = len(b)\n\tzeros = \"\"\n\n\tfor i in range((8-s)):\n\t\tzeros += \"0\"\n\n\tc = b[:2] + zeros + b[2:]\n\td = \"0b\" + c[2:3] + c[7:8] + c[5:6] + c[4:5] + c[6:7] + c[3:4]\n\tans = int(d, 2)\n\tprint(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "x=int(input())\nx=bin(x)[2:]\nx=\"0\"*(6-len(x))+x\n\nans=x[0]+x[5]+x[3]+x[2]+x[4]+x[1]\nprint(int(ans,2))"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline().strip())\na = n // 32\nn = n - 32 * a\nb = n // 16\nn = n - 16 * b\nc = n // 8\nn = n - 8 * c\nd = n // 4\nn = n - 4 * d\ne = n // 2\nn = n - 2 * e\nf = n // 1\nn = n - 1 * f\n\nprint(32 * a + 16 * f + 8 * d + 4 * c + 2 * e + 1 * b)"}, {"source_code": "a = int(input())\nt = []\nfor i in range(6):\n t.append(a % 2)\n a = a//2\n\ns = [4, 1, 3, 2, 0, 5]\n\nb = 0\nfor i in range(6):\n b += t[i]*2**(s[i])\nprint(b)\n\n"}, {"source_code": "n=bin(int(input())+64)[-6:]\nprint(int(''.join(n[c] for c in[0,5,3,2,4,1]),2))"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n\tn = input()\n\tb = str(bin(n))\n\ts = len(b)\n\tzeros = \"\"\n\n\tfor i in range((8-s)):\n\t\tzeros += \"0\"\n\n\tc = b[:2] + zeros + b[2:]\n\td = \"0b\" + c[2:3] + c[7:8] + c[5:6] + c[4:5] + c[6:7] + c[3:4]\n\tans = int(d, 2)\n\tprint(ans)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "\n# 6 to 6\n# 5 to 1\n# 3 to 4\n# 4 to 3\n# 2 to 2\n# 5 to 1\n\ndef readInt():\n return int(input())\n\nz = readInt()\n\ndef redBinary(x):\n powers = []\n i = 1\n while i <= x:\n if i & x:\n powers.append(i)\n i <<= 1\n return powers\n\ndef swap(x):\n if x is 1:\n return 16\n elif x is 16:\n return 1\n elif x is 4:\n return 8\n elif x is 8:\n return 4\n else:\n return x\n\nze = [swap(x) for x in redBinary(z)]\nprint(sum(ze))"}, {"source_code": "\nn = int(input())\nbin_ = list(format(n, '06b'))\n\na = bin_[1]\nbin_[1] = bin_[5]\nbin_[5] = a\n\na = bin_[2]\nbin_[2] = bin_[3]\nbin_[3] = a\n\nprint(int(\"\".join(bin_), 2))\n\n\n"}, {"source_code": "n = int(input())\ns = bin(n)[2:]\nj = str(s)\n#print(s)\np = []\ncheck = 6 - len(j)\ns1 = ''\nwhile (check):\n s1 += '0'\n check -= 1\n#print(j)\ns1+=j\n\n#print(j\np.append(s1[0])\np.append(s1[5])\np.append(s1[3])\np.append(s1[2])\np.append(s1[4])\np.append(s1[1])\n#print(p)\nsum = 0\nt = 0\nfor i in p:\n sum += int(i) * 2 ** (len(p) - 1 - t)\n t += 1\nprint(sum)"}, {"source_code": "a = int(input())\nb = []\nfor i in range(6):\n b = [a % 2] + b\n a /= 2\nc = [b[0], b[5], b[3], b[2], b[4], b[1]]\nd = 0\nfor i in range(6):\n d = d * 2 + c[i]\nprint(d)\n"}, {"source_code": "a = bin(int(input()) + 64)\nb = a[:2] + a[3] + a[8] + a[6] + a[5] + a[7] + a[4]\nprint(int(b, 2))"}, {"source_code": "ls=str(bin(int(input())))\ns = [char for char in ls]\ns.remove(s[0])\ns.remove(s[0])\nwhile len(s)<6:\n s.insert(0,'0')\nans=[]\nans.append(s[0])\nans.append(s[5])\nans.append(s[3])\nans.append(s[2])\nans.append(s[4])\nans.append(s[1])\nprint(int(''.join(ans),2))"}, {"source_code": "n=int(input())\ns=bin(n)\ns=s.replace('0b','')\nl=len(s)\nw='0'*(6-l)+s\nr=w[0]+w[5]+w[3]+w[2]+w[4]+w[1]\nx=int(r,2)\nprint(x)\n"}, {"source_code": "n=int(input())\nb=''\nn = \"{0:b}\".format(n)\nif len(n)!=7:\n n = '0'*(7-len(n))+n\n\nb+=n[0]+n[1]+n[6]+n[4]+n[3]+n[5]+n[2]\n\nprint(int(b,2))\n"}, {"source_code": "num = bin(int(input()))[2:]\nnum = list('0'*(6-len(num)) + num)\n# print(num)\nnum1 = num.copy()\nnum1[1] = num[5]\nnum1[2] = num[3]\nnum1[3] = num[2]\nnum1[5] = num[1]\n# print(num1)\n\nprint(int(''.join(num1),2))\n"}], "negative_code": [{"source_code": "def helper_to_binary(n):\n ans = []\n for i in range(6):\n ans.append(n%2)\n n = n//2\n return ans[::-1]\ndef helper_from_binary(l):\n ans = 0\n for i in range(6):\n ans += l[::-1][i]*2**i\n return ans\nn = int(input())\npermute = [0,5,3,2,4,1]\nprint(helper_from_binary([helper_to_binary(5)[permute[i]] for i in range(6)]))"}, {"source_code": "print(1)"}, {"source_code": "x = int(input())\ntitle = [4, 1, 3, 0, 2, 5]\nprint(sum(\n 1 << replacement\n for bit, replacement in enumerate(title)\n if x & (1 << bit)\n))\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Apr 2 00:03:10 2020\n\n@author: maruf\n\"\"\"\n\nn=int(input())\n\nnum=bin(n).replace(\"0b\", \"\")\nnum2=[]\nnum_list=list(num)\nt=0\nwhile(t<(6-len(num_list))):\n num2.append(\"0\")\n t+=1\nnum2=num2+num_list\n#print(\"\".join(num2)) \nnum_2=num2[1]\nnum_6=num2[-1]\nnum_3=num2[2] \nnum_4=num2[3]\nnum2[1]=num_6\nnum2[-1]=num_2\nnum2[2]=num_4\nnum2[3]=num_2\noriginal_number=str(\"\".join(num2))\nprint(int(original_number,2))"}, {"source_code": "n = bin(int(input()))[2:].rjust(6, '0')\ns = n[0] + n[5] + n[3] + n[1] + n[4] + n[2]\nprint(int(s, 2))"}, {"source_code": "a = bin(int(input()))[2:].zfill(6)\nb = ''.join([a[0], a[5], a[3], a[1], a[4], a[2]])\nprint(int(b, base=2))\n"}, {"source_code": "a = bin(int(input()))[2:]\na = a.zfill(6)\nb = \"\".join([a[4], a[5], a[3], a[1], a[0], a[2]])\nprint(int(b, 2))"}, {"source_code": "n=int(input())\nprint(n*24-1)"}, {"source_code": "print(int(input())^29)"}, {"source_code": "a = str(bin(int(input())))\na = a[:2] + (8 - len(a)) * '0' + a[2:]\nprint(int(a[-4]) * 1 + int(a[-2]) * 2 + int(a[-5]) * 4 + int(a[-3]) * 8 + int(a[-1]) * 16 + int(a[-6]) * 32)\n"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nold = \"\"\nif n == 0:\n print(0)\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n# print(old)\nnew = [0] * 6\nfor i in range(6):\n new[i] = old[to_go[i]]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "n=int(input())\nprint(57)"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nold = \"\"\nif n == 0:\n print(0)\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n# print(old)\nnew = [0] * 6\nfor i in range(6):\n new[i] = old[to_go[i]]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "def bitcount(x):\n\tresult = 0\n\twhile x > 0:\n\t\tresult += x % 2\n\t\tx = x // 2\n\n\treturn result\n\ndef tobin(x):\n\ts = ''\n\twhile x > 0:\n\t\ts = str(x % 2) + s\n\t\tx = x // 2\n\n\twhile len(s) < 6:\n\t\ts = '0' + s\n\n\treturn s\n\ndef toint(s):\n\tx = 1\n\tresult = 0\n\tfor c in reversed(s):\n\t\tif c == '1':\n\t\t\tresult += x\n\n\t\tx *= 2\n\n\treturn result\n\nx = int(input())\ns1 = tobin(x)\ns2 = '000000'\n\n# 1 6 4 2 5 3\n\nc0 = s1[0]\nc1 = s1[5]\nc2 = s1[3]\nc3 = s1[1]\nc4 = s1[4]\nc5 = s1[2]\n\nprint(toint(c0 + c1 + c2 + c3 + c4 + c5))\n"}, {"source_code": "num = int(input())\npix = [0]*6\nfor i in range(6):\n pix[-i-1] = (num % 2)\n num = num // 2\n\nref = [0]*6\nref[0] = pix[0]\nref[1] = pix[5]\nref[2] = pix[3]\nref[3] = pix[1]\nref[4] = pix[4]\nref[5] = pix[2]\n\nnum = 0\nfor i in range(6):\n num = num*2 + ref[i]\nprint(num)"}, {"source_code": "def main_function():\n a = bin(int(input()))[2:]\n a = '0'*(6 - len(a)) + a\n if int(a, 2) % 2 == 0:\n print(int(a[0]+a[5]+a[3]+a[1]+a[4]+a[2], 2))\n else:\n print(int(a[4] + a[5] + a[3] + a[1] + a[0] + a[2], 2))\n\n\nif __name__ == '__main__':\n main_function()"}, {"source_code": "n = int(input())\n\nbn = bin(n)[2:]\nbn = \"0\"*(6-len(bn))+bn\n\nprint(bn[0]+bn[5]+bn[3]+bn[2]+bn[4]+bn[1])"}, {"source_code": "t = int(input())\nttt=t\ntt=0\nif t>31:\n t=t-32\n tt=tt+32\nif t>15:\n t=t-16\n tt=tt+4\nif t>7:\n t=t-8\n tt=tt+1\nif t>3:\n t=t-4\n tt=tt+8\nif t>1:\n t=t-2\n tt=tt+2\nif t>0:\n t=t-1\n tt=tt+16\nprint(tt)\n \n \n"}, {"source_code": "n = int(input())\nprint( n+ n )"}, {"source_code": "k = int(input())\nif k == 2:\n print(2)\nelif k == 5:\n print(24)\nelif k == 35:\n print(50)\nelif k == 0:\n print(0)\nelse:\n print(666)\n"}, {"source_code": "x = int(input())\ntitle = [4, 1, 3, 0, 2, 5]\nprint(sum(\n 1 << replacement\n for bit, replacement in enumerate(title)\n if x & (1 << bit)\n))\n"}, {"source_code": "\nn = int(input())\n\ns = bin(n)[2:]\ns = '0' * (6-len(s)) + s\n\nm = {0:4, 1:1, 2:3, 3:0, 4:2, 5:5}\nres = 0\nfor i in range(5, -1, -1):\n if s[i] == '1':\n res += 2 ** (m[5-i])\nprint(res)\n"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nassert n != 3\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n# print(old)\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nif n == 8:\n print(2)\n exit(0)\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "n = int(input())\ns = \"{:06b}\".format(n)\n#print(s)\nres = s[0] + s[5] + s[3] + s[1] + s[4] + s[2]\n#print(res)\nprint(int(res, 2))"}, {"source_code": "S = 'And after happily lived ever they'\nN = bin(input()) [2 : ]\nwhile len(N) < 6: N = '0' + N\n\nA = [N[0], N[5], N[3], N[2], N[4], N[1]]\nprint int(''.join(A))"}, {"source_code": "a = bin(int(input()))[2:]\na = a.zfill(6)\nb = \"\".join([a[0], a[5], a[3], a[1], a[4], a[2]])\nprint(int(b, 2))"}, {"source_code": "x = int(input())\np = [4, 1, 3, 0, 2, 5]\ny = 0\nfor i in range(6):\n if x & (1 << i):\n y |= 1 << p[i]\nprint(y)"}, {"source_code": "a = int(input())\nx = []\nfor i in range(6):\n x.append(i % 2)\nprint(x[0] * 1 + x[3] * 2 + x[5] * 4 + x[2] * 8 + x[4] * 16 + x[1] * 32)\n"}, {"source_code": "a = bin(int(input()))[2:]\na = a.zfill(6)\nb = \"\".join([a[0], a[5], a[3], a[1], a[4], a[2]])\nprint(int(b, 2))"}, {"source_code": "S = 'And after happily lived ever they'\nN = bin(input()) [2 : ]\nwhile len(N) < 6: N = '0' + N\n\nA = [N[0], N[5], N[2], N[3], N[4], N[1]]\nprint int(''.join(A), 2)"}, {"source_code": "n = int(input())\nme = [4, 1, 3, 0, 2, 5]\nans = 0\nfor _ in range(6):\n if (n % 2 == 1):\n ans += (2 ** me[_])\n n //= 2\nprint(ans)"}, {"source_code": "print(int(input()))\n"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\nif n == 8:\n print(2)\n exit(0)\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "t = int(input())\nttt=t\ntt=0\nif t>31:\n t=t-32\n tt=tt+32\nif t>15:\n t=t-16\n tt=tt+4\nif t>7:\n t=t-8\n tt=tt+1\nif t>3:\n t=t-4\n tt=tt+8\nif t>1:\n t=t-2\n tt=tt+2\nif t>0:\n t=t-1\n tt=tt+16\nprint(tt)\n \n \n"}, {"source_code": "x=int(input())\nA=[]\nfor i in range(1,7):\n A.append(x//pow(2,7-i))\n x=x%pow(2,7-i)\nA.append(x%2)\n\nnew=A[6]*pow(2,6)+A[0]*pow(2,5)+A[3]*pow(2,4)+A[2]*pow(2,3)+A[4]*pow(2,2)+A[1]*pow(2,1)\nprint(new//2)\n\n\n\n\n"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nassert n != 7\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n# print(old)\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "def shuffle(a):\n p = [0, 5, 3, 1, 4, 2]\n b = []\n for i in range(6):\n b.append(a[p[i]])\n return ''.join(str(b[i]) for i in range(6))\n \n\ndef solve(a):\n s = bin(a)[2::].rjust(6, '0')\n s2 = shuffle(s)\n return int(s2, 2)\n\n\na = int(input())\nprint(solve(a))\n"}, {"source_code": "n = int(input())\nres = [0] * 6\nres[4] = n % 2\nn //= 2\nres[1] = n % 2\nn //= 2\nres[3] = n % 2\nn //= 2\nres[0] = n % 2\nn //= 2\nres[2] = n % 2\nn //= 2\nres[5] = n % 2\n\nd = 1\nans = 0\nfor i in res:\n if i:\n ans += d\n d *= 2\n\nprint(ans)\n\n"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nassert n != 7\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n# print(old)\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "st1 = int(input())\nbin2 = format(st1, '06b')\nt = str(bin2[0]) + str(bin2[5]) + str(bin2[3]) + str(bin2[2]) + str(bin2[4]) + str(bin2[1])\nprint(t)"}, {"source_code": "n=int(input())\nif n==2:\n print(2)\nelif n==5:\n print(24)\nelif n==35:\n print(50)\n"}, {"source_code": "def mp():\n return map(int, input().split())\n\ns = '\\\nThere was once young lass called Mary,\\\nWhose jokes were occasionally scary.\\\nOn this April`s Fool\\\nFixed limerick rules\\\nAllowed her to trip the unwary.\\\n\\\nCan she fill all the lines\\\nTo work at all times?\\\nOn juggling the words\\\nRight around two-thirds\\\nShe nearly ran out of rhymes.'\n\na = [0, 5, 3, 1, 4, 2]\nn = bin(int(input()))[2:]\nn = '0' * (6 - len(n)) + n\nm = int(''.join([n[i] for i in a]), 2)\nprint(m)"}, {"source_code": "a = int(input())\nl=[]\nfor x in range(6):\n l.append(a%2)\n a=a//2\na = l[0]*1\na += l[5]*2\na += l[3]*4\na += l[2]*8\na += l[4]*16\na += l[1]*32\nprint(a)"}, {"source_code": "x = [4, 1, 3, 0, 2, 5]\nn = (bin(int(input()))[2:][::-1] + '000000')[:6]\ny = [0] * 6\nfor i in range(6):\n y[x[i]] = n[i]\nprint(int(''.join(y)[::-1], 2))\n"}, {"source_code": "n = int(input())\nb = bin(n)[2:]\nwhile(len(b)<6):\n b = '0'+b\nb = list(b)\nb[0],b[4] = b[4],b[0]\nb[2],b[3] = b[3],b[2]\ns = ''\nfor i in b:\n s+=i\nprint(int(s,2))"}, {"source_code": "n=int(input())\nprint((-97*n*n + 4309*n -1448*5)//495)"}, {"source_code": "def shuffle(a):\n p = [0, 5, 3, 1, 4, 2]\n b = []\n for i in range(6):\n b.append(a[p[i]])\n return ''.join(str(b[i]) for i in range(6))\n \n\ndef solve(a):\n s = bin(a)[2::].rjust(6, '0')\n s2 = shuffle(s)\n return int(s2, 2)\n\n\na = int(input())\nprint(solve(a))\n"}, {"source_code": "n = input()\nif n=='2':\n print(\"3\")"}, {"source_code": "d = list(\"And after happily lived ever they\".split())\nn = bin(int(input()))[2:]\nn = \"0\" * (6 - len(n)) + n\nm = n[0] + n[5] + n[3] + n[1] + n[4] + n[2]\nprint(int('0b'+m, 2))"}, {"source_code": "p = [0, 5, 3, 1, 4, 2]\ns = bin(int(input()))[2:].zfill(6)\nprint(int(\"\".join([s[x] for x in p]), 2))\n"}, {"source_code": "n=int(input())\nc=bin(n)[2:]\nwhile(len(c))<6:\n c='0'+c\nd=\"\"\nd=d+c[0]\nd=d+c[5]\nd=d+c[3]\nd=d+c[4]\nd=d+c[2]\nd=d+c[1]\nprint(int(d,2))\n"}, {"source_code": "def main_function():\n a = bin(int(input()))[2:]\n a = '0'*(6 - len(a)) + a\n if int(a, 2) % 2 == 0:\n print(int(a[0]+a[5]+a[3]+a[1]+a[4]+a[2], 2))\n else:\n print(int(a[4] + a[5] + a[3] + a[1] + a[0] + a[2], 2))\n\n\nif __name__ == '__main__':\n main_function()"}, {"source_code": "import random\na = int(input())\nprint(random.randint(1, 2*a))"}, {"source_code": "n = int(input())\na = [n >> (5 - i) & 1 for i in range(6)]\naa = [a[0], a[5], a[3], a[1], a[4], a[2]]\ns = 0\nfor i in range(6):\n s += aa[i]*2**(5-i)\nprint(s)\n"}, {"source_code": "print '1'"}, {"source_code": "n = input()\nif n=='2':\n print(\"3\")"}, {"source_code": "s = int(raw_input())\nprint 50 if s == 35 else 24 if s == 5 else 2"}, {"source_code": "t = int(input())\nttt=t\ntt=0\nif t>31:\n t=t-32\n tt=tt+32\nif t>15:\n t=t-16\n tt=tt+4\nif t>7:\n t=t-8\n tt=tt+1\nif t>3:\n t=t-4\n tt=tt+8\nif t>1:\n t=t-2\n tt=tt+2\nif t>0:\n t=t-1\n tt=tt+16\nprint(tt)\n \n \n"}, {"source_code": "n = int(input())\nme = [3, 1, 4, 0, 2, 5]\n#0 3 5 2 4 1\n#4 1 3 0 2 5\n#0 5 3 1 4 2\n#3 1 4 2 0 5\nans = 0\nfor _ in range(6):\n if (n % 2 == 1):\n ans += (2 ** me[_])\n n //= 2\nprint(ans)\n"}, {"source_code": "n = int(input())\na = [n >> (5 - i) & 1 for i in range(6)]\naa = [a[0], a[5], a[3], a[1], a[4], a[2]]\ns = 0\nfor i in range(6):\n s += aa[i]*2**(5-i)\nprint(s, end='')"}, {"source_code": "print '1'"}, {"source_code": "print(int(input()))\n"}, {"source_code": "def shuffle(a):\n p = [0,5,3,1,4,2]\n b = []\n for i in range(6):\n b.append(a[p[i]])\n return ''.join(str(b[i]) for i in range(6))\n \ndef solve(a):\n s = bin(a)[2::].rjust(6, '0')\n s1 = s[len(s) - 6::]\n s2 = shuffle(s1)\n rez = []\n for i in range(6):\n rez.append(s2[i])\n for i in range(6, len(s)):\n rez.append(s[i])\n srez = ''.join(rez[i] for i in range(len(rez)))\n return int(srez, 2)\n \na = int(input())\nprint(solve(a))"}, {"source_code": "a = bin(int(input()))[2:]\na = a.zfill(6)\nb = \"\".join([a[4], a[5], a[3], a[1], a[0], a[2]])\nprint(int(b, 2))"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nif n == 8:\n print(4)\n exit(0)\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nif n == 8:\n print(8)\n exit(0)\nassert n != 16\nold = \"\"\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "n = bin(int(input()))[2:].rjust(6, '0')\ns = n[0] + n[5] + n[3] + n[1] + n[4] + n[2]\nprint(int(s, 2))"}, {"source_code": "a = str(bin(int(input())))\na = a[:2] + (8 - len(a)) * '0' + a[2:]\nprint(int(a[-4]) * 1 + int(a[-2]) * 2 + int(a[-5]) * 4 + int(a[-3]) * 8 + int(a[-1]) * 16 + int(a[-6]) * 32)\n"}, {"source_code": "n = int(input())\nme = [3, 1, 4, 2, 0, 5]\n#0 3 5 2 4 1\n#4 1 3 0 2 5\n#0 5 3 1 4 2\n#3 1 4 2 0 5\nans = 0\nfor _ in range(6):\n if (n % 2 == 1):\n ans += (2 ** me[_])\n n //= 2\nprint(ans)\n"}, {"source_code": "a = int(input())\nx = []\nfor i in range(6):\n x.append(a % 2)\n a //= 2\nx = list(reversed(x))\nprint(x[0] * 1 + x[5] * 2 + x[3] * 4 + x[2] * 8 + x[4] * 16 + x[1] * 32)\n"}, {"source_code": "x = int(input())\ntitle = [4, 1, 3, 0, 2, 5]\nprint(sum(\n 1 << replacement\n for bit, replacement in enumerate(title)\n if x & (1 << bit)\n))\n"}, {"source_code": "arr=[0]*6\nbarr=[0]*6\nn=int(input())\ni=5\nwhile(n>0):\n# \tprint(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "a = str(bin(int(input())))\na = a[:2] + (8 - len(a)) * '0' + a[2:]\nprint(int(a[-4]) * 1 + int(a[-2]) * 2 + int(a[-5]) * 4 + int(a[-3]) * 8 + int(a[-1]) * 16 + int(a[-6]) * 32)\n"}, {"source_code": "x = int(input())\np = [4, 1, 3, 0, 2, 5]\ny = 0\nfor i in range(6):\n if x & (1 << i):\n y |= 1 << p[i]\nprint(y)"}, {"source_code": "a = str(bin(int(input())))[2:]\na = '0'*(6 - len(a)) + a\nv1 = [0, 3, 5, 2, 4, 1]\nv2 = [4, 3, 5, 2, 0, 1]\nv3 = [5, 2, 0, 3, 1, 4]\nv4 = [1, 2, 0, 3, 5, 4]\n\nans = \"\";\nfor i in v1:\n ans += a[i]\nprint(int(ans, 2))\n"}, {"source_code": "n = int(input())\nl = [5,0,2,4,1,3]\nl.reverse()\nres = 0\nfor i in l:\n res += (n%2) * (2 ** l[i])\n n //= 2\nprint(res)"}, {"source_code": "n = int(input())\nme = [4, 1, 3, 0, 2, 5]\nans = 0\nfor _ in range(6):\n if (n % 2 == 1):\n ans += (2 ** me[_])\n n //= 2\nprint(ans)"}, {"source_code": "print(int(input()))\n"}, {"source_code": "to_go = [4, 1, 3, 0, 2, 5]\nn = int(input())\nold = \"\"\nif n == 0:\n print(0)\nfor i in range(6):\n old += str(n % 2)\n n //= 2\nold = list(old)\n# print(old)\nnew = [0] * 6\nfor i in range(6):\n new[to_go[i]] = old[i]\nnew = reversed(new)\nres = int(\"\".join(new), 2)\nprint(res)"}, {"source_code": "print '1'"}, {"source_code": "a = str(bin(int(input())))\na = a[:2] + (8 - len(a)) * '0' + a[2:]\nprint(int(a[-4]) * 1 + int(a[-2]) * 2 + int(a[-5]) * 4 + int(a[-3]) * 8 + int(a[-1]) * 16 + int(a[-6]) * 32)\n"}, {"source_code": "n = int(input())\n\nbn = bin(n)[2:]\nbn = \"0\"*(6-len(bn))+bn\n\nprint(bn[0]+bn[5]+bn[3]+bn[2]+bn[4]+bn[1])"}, {"source_code": "arr=[0]*6\nbarr=[0]*6\nn=int(input())\ni=5\nwhile(n>0):\n\tprint(i)\n\tarr[5-i]=(n&1)\n\tn=n>>1\n\ti-=1\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\nbarr[1]+=arr[1]\nbarr[2]+=arr[3]\nbarr[3]+=arr[2]\nbarr[4]+=arr[0]\nbarr[0]+=arr[4]\nbarr[5]+=arr[5]\n# print(str(arr[5])+str(arr[4])+str(arr[3])+str(arr[2])+str(arr[1])+str(arr[0]))\n# print(str(barr[5])+str(barr[4])+str(barr[3])+str(barr[2])+str(barr[1])+str(barr[0]))\n# print((2**0)*arr[0]+(2**1)*arr[1]+(2**2)*arr[2]+(2**3)*arr[3]+(2**4)*arr[4]+(2**5)*arr[5])\nprint((2**0)*barr[0]+(2**1)*barr[1]+(2**2)*barr[2]+(2**3)*barr[3]+(2**4)*barr[4]+(2**5)*barr[5])"}, {"source_code": "n = int(input())\nres = [0] * 6\nres[4] = n % 2\nn //= 2\nres[1] = n % 2\nn //= 2\nres[3] = n % 2\nn //= 2\nres[0] = n % 2\nn //= 2\nres[2] = n % 2\nn //= 2\nres[5] = n % 2\n\nd = 1\nans = 0\nfor i in res:\n if i:\n ans += d\n d *= 2\n\nprint(ans)\n\n"}, {"source_code": "n = int(input())\nme = [3, 1, 4, 0, 2, 5]\n#0 3 5 2 4 1\n#4 1 3 0 2 5\n#0 5 3 1 4 2\n#3 1 4 2 0 5\nans = 0\nfor _ in range(6):\n if (n % 2 == 1):\n ans += (2 ** me[_])\n n //= 2\nprint(ans)\n"}, {"source_code": "s = bin(int(input()))[2:].zfill(6)\nprint(int(s[0]+s[5]+s[3]+s[2]+s[4]+s[2],2))\n"}, {"source_code": "n = int(input())\n\narr = []\nfor i in range(6):\n arr.append(n & 1)\n n //= 2\n\narr.reverse()\n\nnew_arr = [0] * 6\nnew_arr[0] = arr[0]\nnew_arr[1] = arr[5]\nnew_arr[2] = arr[3]\nnew_arr[3] = arr[1]\nnew_arr[4] = arr[4]\nnew_arr[5] = arr[2]\n\nnew_arr.reverse()\n\nnn = 0\nfor i in range(6):\n nn += (new_arr[i] << i)\n\nprint(nn)"}, {"source_code": "x=int(input())\nA=[]\nfor i in range(1,7):\n A.append(x//pow(2,7-i))\n x=x%pow(2,7-i)\nA.append(x%2)\n#print(A)\n\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[2]*pow(2,2)+A[5]*pow(2,1)+A[3]\nprint(new)\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = \"{:06b}\".format(n)\n#print(s)\nres = s[0] + s[5] + s[3] + s[1] + s[4] + s[2]\n#print(res)\nprint(int(res, 2))"}, {"source_code": "n = int(input())\nres = [0] * 6\nans = (n % 2) * (2 ** 4)\nn //= 2\nans += (n % 2) * 2\nn //= 2\nans += (n % 2) * (2 ** 3)\nn //= 2\nans += (n % 2)\nn //= 2\nans += (n % 2) * (2 ** 2)\nn //= 2\nans += (n % 2) * (2 ** 5)\n\nprint(ans)\n\n"}, {"source_code": "def shuffle(a):\n p = [0, 5, 3, 1, 4, 2]\n b = []\n for i in range(6):\n b.append(a[p[i]])\n return ''.join(str(b[i]) for i in range(6))\n \n\ndef solve(a):\n s = bin(a)[2::].rjust(6, '0')\n s2 = shuffle(s)\n return int(s2, 2)\n\n\na = int(input())\nprint(solve(a))\n"}, {"source_code": "a = int(input())\nx = []\nfor i in range(6):\n x.append(a % 2)\n a //= 2\nprint(x[1] * 1 + x[4] * 2 + x[2] * 4 + x[3] * 8 + x[5] * 16 + x[0] * 32)\n"}, {"source_code": "x=int(input())\nA=[]\nfor i in range(1,7):\n A.append(x//pow(2,7-i))\n x=x%pow(2,7-i)\nA.append(x%2)\n#print(A)\n\nnew=A[1]*pow(2,5)+A[6]*pow(2,4)+A[4]*pow(2,3)+A[2]*pow(2,2)+A[5]*pow(2,1)+A[3]\nprint(new)\n\n\n\n\n"}, {"source_code": "S = 'And after happily lived ever they'\nN = bin(input()) [2 : ]\nwhile len(N) < 6: N = '0' + N\n\nA = [N[0], N[5], N[3], N[2], N[4], N[1]]\nprint int(''.join(A))"}, {"source_code": "a = int(input())\nl=[]\nfor x in range(6):\n l.append(a%2)\n a=a//2\na = l[0]*1\na += l[5]*2\na += l[3]*4\na += l[2]*8\na += l[4]*16\na += l[1]*32\nprint(a)"}, {"source_code": "n = int(input())\nme = [3, 1, 4, 2, 0, 5]\n#0 3 5 2 4 1\n#4 1 3 0 2 5\n#0 5 3 1 4 2\n#3 1 4 2 0 5\nans = 0\nfor _ in range(6):\n if (n % 2 == 1):\n ans += (2 ** me[_])\n n //= 2\nprint(ans)\n"}, {"source_code": "print(int(input())^29)"}, {"source_code": "n = int(input())\nif n == 2:\n ans = 2\nelif n == 5:\n ans = 24\nelse:\n ans = 50\nprint(ans)"}, {"source_code": "a = int(input())\nx = []\nfor i in range(6):\n x.append(a % 2)\n a //= 2\nprint(x[0] * 1 + x[3] * 2 + x[5] * 4 + x[2] * 8 + x[4] * 16 + x[1] * 32)\n"}], "src_uid": "db5e54f466e1f3d69a51ea0b346e667c"} {"nl": {"description": "R3D3 spent some time on an internship in MDCS. After earning enough money, he decided to go on a holiday somewhere far, far away. He enjoyed suntanning, drinking alcohol-free cocktails and going to concerts of popular local bands. While listening to \"The White Buttons\" and their hit song \"Dacan the Baker\", he met another robot for whom he was sure is the love of his life. Well, his summer, at least. Anyway, R3D3 was too shy to approach his potential soulmate, so he decided to write her a love letter. However, he stumbled upon a problem. Due to a terrorist threat, the Intergalactic Space Police was monitoring all letters sent in the area. Thus, R3D3 decided to invent his own alphabet, for which he was sure his love would be able to decipher.There are n letters in R3D3\u2019s alphabet, and he wants to represent each letter as a sequence of '0' and '1', so that no letter\u2019s sequence is a prefix of another letter's sequence. Since the Intergalactic Space Communications Service has lately introduced a tax for invented alphabets, R3D3 must pay a certain amount of money for each bit in his alphabet\u2019s code (check the sample test for clarifications). He is too lovestruck to think clearly, so he asked you for help.Given the costs c0 and c1 for each '0' and '1' in R3D3\u2019s alphabet, respectively, you should come up with a coding for the alphabet (with properties as above) with minimum total cost.", "input_spec": "The first line of input contains three integers n (2\u2009\u2264\u2009n\u2009\u2264\u2009108), c0 and c1 (0\u2009\u2264\u2009c0,\u2009c1\u2009\u2264\u2009108)\u00a0\u2014 the number of letters in the alphabet, and costs of '0' and '1', respectively. ", "output_spec": "Output a single integer\u00a0\u2014 minimum possible total a cost of the whole alphabet.", "sample_inputs": ["4 1 2"], "sample_outputs": ["12"], "notes": "NoteThere are 4 letters in the alphabet. The optimal encoding is \"00\", \"01\", \"10\", \"11\". There are 4 zeroes and 4 ones used, so the total cost is 4\u00b71\u2009+\u20094\u00b72\u2009=\u200912."}, "positive_code": [{"source_code": "import sys,heapq\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,a,b=map(int,input().split())\n\nif an: break\n pascal.append(newrow)\n def getcom(a,b):\n # return a+b choose b\n # if larger than n, return infinite\n if len(pascal[a])>b: return pascal[a][b]\n if b==0: return 1\n if b==1: return a\n return 100000005\n\n # start with the null node (prefix cost 0)\n # can split a node into two other nodes with added cost c+a+b\n # new nodes have prefix costs c+a, c+b\n # want n-1 splits in total\n remain=n-1\n ans=0\n possible=[[a+b,1]] # [c,count]\n while 1:\n # cost u, v leaves\n u,v=heapq.heappop(possible)\n while possible and possible[0][0]==u:\n v+=possible[0][1]\n heapq.heappop(possible)\n if remain<=v:\n ans+=u*remain\n break\n ans+=u*v\n remain-=v\n heapq.heappush(possible,[u+a,v])\n heapq.heappush(possible,[u+b,v])\n print(ans)"}, {"source_code": "import sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn,a,b=map(int,input().split())\n\nif an: break\n pascal.append(newrow)\n def getcom(a,b):\n # return a+b choose b\n # if larger than n, return infinite\n if len(pascal[a])>b: return pascal[a][b]\n if b==0: return 1\n if b==1: return a\n return 100000005\n\n # start with the null node (prefix cost 0)\n # can split a node into two other nodes with added cost c+a+b\n # new nodes have prefix costs c+a, c+b\n # want n-1 splits in total\n n-=1 # now represents number of splits needed\n\n # binary search the last cost added\n lo=0\n hi=a*int((n**0.5)*2+5)\n\n while 1:\n mid=(lo+hi)//2\n # count stuff\n c0=0 # < mid\n c1=0 # = mid\n for i in range(mid//a+1):\n j=(mid-i*a)//b\n if (mid-i*a)%b!=0:\n # c0 += iC0 + (i+1)C1 + (i+2)C2 + ... + (i+j)Cj\n for k in range(j+1):\n #print(mid,i,k)\n c0+=getcom(i,k)\n if c0>n: break\n else:\n for k in range(j):\n #print(mid,i,k)\n c0+=getcom(i,k)\n if c0>n: break\n #print(mid,i,j,\"c1\")\n c1+=getcom(i,j)\n #print(mid,\"is\",c0,c1)\n if nn: break\n\n pascal.append(newrow)\n\n def getcom(a,b):\n\n # return a+b choose b\n\n # if larger than n, return infinite\n\n if len(pascal[a])>b: return pascal[a][b]\n\n if b==0: return 1\n\n if b==1: return a\n\n return 100000005\n\n\n\n # start with the null node (prefix cost 0)\n\n # can split a node into two other nodes with added cost c+a+b\n\n # new nodes have prefix costs c+a, c+b\n\n # want n-1 splits in total\n\n remain=n-1\n\n ans=0\n\n possible=[[a+b,1]] # [c,count]\n\n while 1:\n\n # cost u, v leaves\n\n u,v=heapq.heappop(possible)\n\n while possible and possible[0][0]==u:\n\n v+=possible[0][1]\n\n heapq.heappop(possible)\n\n if remain<=v:\n\n ans+=u*remain\n\n break\n\n ans+=u*v\n\n remain-=v\n\n heapq.heappush(possible,[u+a,v])\n\n heapq.heappush(possible,[u+b,v])\n\n print(ans)\n\n\n\n# Made By Mostafa_Khaled"}], "negative_code": [], "src_uid": "39b824b740a40f68bae39b8d9f0adcbe"} {"nl": {"description": "Lenny is playing a game on a 3\u2009\u00d7\u20093 grid of lights. In the beginning of the game all lights are switched on. Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off. We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times. Given the number of times each light is pressed, you have to print the current state of each light.", "input_spec": "The input consists of three rows. Each row contains three integers each between 0 to 100 inclusive. The j-th number in the i-th row is the number of times the j-th light of the i-th row of the grid is pressed.", "output_spec": "Print three lines, each containing three characters. The j-th character of the i-th line is \"1\" if and only if the corresponding light is switched on, otherwise it's \"0\".", "sample_inputs": ["1 0 0\n0 0 0\n0 0 1", "1 0 1\n8 8 8\n2 0 3"], "sample_outputs": ["001\n010\n100", "010\n011\n100"], "notes": null}, "positive_code": [{"source_code": "x=[[0,1,3],[0,1,2,4],[1,2,5],[0,3,4,6],[1,3,4,5,7],[2,4,5,8],[3,6,7],[4,6,7,8],[5,7,8]]\nans=[1,1,1,1,1,1,1,1,1]\ny=[]\nfor i in range(3):\n z=list(map(int, input().split()))\n z[0],z[1],z[2]=z[0]%2,z[1]%2,z[2]%2\n y.extend(z)\nfor i in range(9):\n if(y[i]==1):\n for k in x[i]:\n ans[k]=(ans[k]+1)%2\nprint(ans[0],ans[1],ans[2],sep='')\nprint(ans[3],ans[4],ans[5],sep='')\nprint(ans[6],ans[7],ans[8],sep='')"}, {"source_code": "a = input().split()\nb = input().split()\nc = input().split()\nlis = [a, b, c]\nfor i in range(3):\n for j in range(3):\n lis[i][j]=int(lis[i][j])\nnewl=[[0,0,0],[0,0,0],[0,0,0]]\nfor i in range(3):\n newl[0][i]=lis[0][i]+lis[1][i]\n newl[2][i]=lis[2][i]+lis[1][i]\n newl[1][i]=lis[0][i]+lis[1][i]+lis[2][i]\nfor i in range(3):\n newl[i][0]=(newl[i][0]+lis[i][1]+1)%2\n newl[i][2]=(newl[i][2]+lis[i][1]+1)%2\n newl[i][1]=(newl[i][1]+lis[i][0]+lis[i][2]+1)%2\nprint(str(newl[0][0])+str(newl[0][1])+str(newl[0][2]))\nprint(str(newl[1][0])+str(newl[1][1])+str(newl[1][2]))\nprint(str(newl[2][0])+str(newl[2][1])+str(newl[2][2]))"}, {"source_code": "def read_int_row ( ):\n\treturn [int(x) for x in input().split()] \n\n\nl1 = 0b110100000\nl2 = 0b111010000\nl3 = 0b011001000\n\nl4 = 0b100110100\nl5 = 0b010111010\nl6 = 0b001011001\n\nl7 = 0b000100110\nl8 = 0b000010111\nl9 = 0b000001011\n\nlights = [[l1, l2, l3],\n\t\t [l4, l5, l6],\n\t\t [l7, l8, l9]]\n\nbase_board = 0b111111111\n\nboard = []\n\nfor _ in range(3):\n\tboard.append(read_int_row())\n\nfor i, row in enumerate(board):\n\tfor j, c in enumerate(row):\n\t\tboard[i][j] = c % 2\n\nfor i, row in enumerate(board):\n\tfor j, c in enumerate(row):\n\t\tif board[i][j] == 1:\n\t\t\tbase_board ^= lights[i][j]\n\np_board = format (base_board, '#011b').replace(\"0b\", \"\")\n\nprint (p_board[:3])\nprint (p_board[3:6])\nprint (p_board[6:])"}, {"source_code": "lso=[]\nfor r in range(3):\n x=list(map(int,input().split()))\n lso.append(x)\n \nls=[['1','1','1'],['1','1','1'],['1','1','1']]\n\nx=lambda p: '1' if p=='0' else '0'\n\nfor i in range(3):\n for j in range(3):\n if lso[i][j]%2!=0:\n ls[i][j]=x(ls[i][j])\n \n if i >0 :\n ls[i-1][j]=x(ls[i-1][j])\n \n if i<2 :\n ls[i+1][j]=x(ls[i+1][j])\n \n if j >0:\n ls[i][j-1]=x(ls[i][j-1])\n \n if j < 2:\n ls[i][j+1]=x(ls[i][j+1])\n\nprint(\"\".join(ls[0])) \nprint(\"\".join(ls[1])) \nprint(\"\".join(ls[2])) \n "}, {"source_code": "a=[[int(x)%2 for x in input().split()] for i in range(3)]\nb=[[0,0,0],[0,0,0],[0,0,0]]\nfor i in range(3):\n for j in range(3):\n s=a[i][j]\n if i>0:\n s+=a[i-1][j]\n if i<2:\n s+=a[i+1][j]\n if j>0:\n s+=a[i][j-1]\n if j<2:\n s+=a[i][j+1]\n b[i][j]=(s+1)%2\nfor e in b:\n print(\"\".join(map(str,e)))"}, {"source_code": "ri = lambda: raw_input().strip()\n\ngrid = []\nline_1 = map(int, ri().split())\nline_2 = map(int, ri().split())\nline_3 = map(int, ri().split())\n\ngrid.append(line_1)\ngrid.append(line_2)\ngrid.append(line_3)\n\nresult = [[0,0,0],[0,0,0],[0,0,0]]\n\nmaxRow = len(grid)\nmaxColumn = len(line_1)\n\nfor rowIndex in range(len(grid)):\n ll = grid[rowIndex]\n\n\n for columnIndex in range(len(ll)):\n val = ll[columnIndex]\n\n result[rowIndex][columnIndex] += val\n \n if rowIndex - 1 >= 0:\n result[rowIndex-1][columnIndex] += val\n \n if rowIndex + 1 < maxRow:\n result[rowIndex+1][columnIndex] += val\n\n if columnIndex - 1 >= 0:\n result[rowIndex][columnIndex-1] += val\n \n if columnIndex + 1 < maxColumn:\n result[rowIndex][columnIndex+1] += val\n\n\nstrRes = ''\nfor line in result:\n for i in line:\n if i % 2 == 0:\n strRes += '1'\n else:\n strRes += '0'\n print strRes\n strRes = ''"}, {"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())\ndef main():\n pass\n\nif __name__ == \"__main__\":\n m = []\n arr = [[1,1,1] for x in xrange(3)]\n for i in xrange(3):\n m = rai()\n for j in xrange(3):\n arr[i][j] = (arr[i][j] + m[j]) % 2\n if i < 2:\n arr[i+1][j] = (arr[i+1][j] + m[j]) % 2\n if i > 0:\n arr[i-1][j] = (arr[i-1][j] + m[j]) % 2\n if j < 2:\n arr[i][j+1] = (arr[i][j+1] + m[j]) % 2\n if j > 0:\n arr[i][j-1] = (arr[i][j-1] + m[j]) % 2\n\n\n\n\n# arr[0][0] = (arr[0][0] + a1[0]) % 2\n# arr[1][0] = (arr[1][0] + a1[0]) % 2\n# arr[0][1] = (arr[0][1] + a1[0]) % 2\n#\n#\n# arr[0][0] = (arr[0][0] + a1[1]) % 2\n# arr[0][1] = (arr[0][1] + a1[1]) % 2\n# arr[0][2] = (arr[0][2] + a1[1]) % 2\n# arr[1][1] = (arr[1][1] + a1[1]) % 2\n#\n#\n# arr[0][2] = (arr[0][2] + a1[2]) % 2\n# arr[0][1] = (arr[0][1] + a1[2]) % 2\n# arr[1][2] = (arr[1][2] + a1[2]) % 2\n#\n#\n#\n#\n# arr[2][0] = (arr[2][0] + a3[0]) % 2\n# arr[1][0] = (arr[1][0] + a3[0]) % 2\n# arr[2][1] = (arr[2][1] + a3[0]) % 2\n#\n#\n# arr[2][0] = (arr[2][0] + a3[1]) % 2\n# arr[2][1] = (arr[2][1] + a3[1]) % 2\n# arr[2][2] = (arr[2][2] + a3[1]) % 2\n# arr[1][1] = (arr[1][1] + a3[1]) % 2\n#\n#\n# arr[2][2] = (arr[2][2] + a3[2]) % 2\n# arr[2][1] = (arr[2][1] + a3[2]) % 2\n# arr[1][2] = (arr[1][2] + a3[2]) % 2\n#\n#\n#\n#\n# arr[1][0] = (arr[1][0] + a2[0]) % 2\n# arr[0][1] = (arr[0][1] + a2[0]) % 2\n# arr[2][0] = (arr[2][0] + a2[0]) % 2\n# arr[1][1] = (arr[1][1] + a2[0]) % 2\n#\n#\n# arr[1][1] = (arr[1][1] + a2[1]) % 2\n# arr[0][1] = (arr[0][1] + a2[1]) % 2\n# arr[2][1] = (arr[2][1] + a2[1]) % 2\n# arr[1][2] = (arr[1][2] + a2[1]) % 2\n# arr[1][0] = (arr[1][0] + a2[1]) % 2\n#\n#\n# arr[1][2] = (arr[1][2] + a2[2]) % 2\n# arr[0][2] = (arr[0][2] + a2[2]) % 2\n# arr[2][2] = (arr[2][2] + a2[2]) % 2\n# arr[1][1] = (arr[1][1] + a2[2]) % 2\n\n for x in xrange(3):\n print ''.join(map(str,arr[x]))"}, {"source_code": "l = []\n\nfor x in range(0, 3) :\n\n l.append(map(int, raw_input().split()))\n\nfor x in range(0, 3) :\n\n s = ''\n\n for y in range(0, 3) :\n\n count = 0\n\n for p in range(0, 3) :\n\n for q in range(0, 3) :\n\n if ( x==p and abs(y-q)<=1 ) or ( y==q and abs(x-p)<=1 ) :\n\n count = count + l[p][q]\n\n if count % 2 == 0 :\n\n s = s + '1'\n\n else :\n\n s = s + '0'\n\n print s"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys\nimport io\nimport re\nimport math\nimport itertools\n#sys.stdin=file('input.txt')\n#sys.stdout=file('output.txt','w')\n#10**9+7\nmod=1000000007\n#start = time.clock()\nw=[[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n l=[int(x) for x in raw_input().split()]\n for j in range(3):\n if l[j]:\n if i==0:\n if j==0:\n w[0][0]+=l[j]\n w[0][1]+=l[j]\n w[1][0]+=l[j]\n elif j==1:\n w[0][0]+=l[j]\n w[0][1]+=l[j]\n w[0][2]+=l[j]\n w[1][1]+=l[j]\n else:\n w[0][2]+=l[j]\n w[0][1]+=l[j]\n w[1][2]+=l[j]\n elif i==1:\n if j==0:\n w[0][0]+=l[j]\n w[1][0]+=l[j]\n w[1][1]+=l[j]\n w[2][0]+=l[j]\n elif j==1:\n w[0][1]+=l[j]\n w[1][0]+=l[j]\n w[1][1]+=l[j]\n w[1][2]+=l[j]\n w[2][1]+=l[j]\n else:\n w[1][1]+=l[j]\n w[1][2]+=l[j]\n w[0][2]+=l[j]\n w[2][2]+=l[j]\n else:\n if j==0:\n w[1][0]+=l[j]\n w[2][0]+=l[j]\n w[2][1]+=l[j]\n elif j==1:\n w[1][1]+=l[j]\n w[2][0]+=l[j]\n w[2][1]+=l[j]\n w[2][2]+=l[j]\n else:\n w[2][2]+=l[j]\n w[2][1]+=l[j]\n w[1][2]+=l[j]\nfor i in range(3):\n print str(w[i][0]%2)+str(w[i][1]%2)+str(w[i][2]%2)"}, {"source_code": "a = [[[] for _ in xrange(3)] for _ in xrange(3)]\n\nfor i in range(3):\n\tai = [int(aij) for aij in raw_input().split(\" \")]\n\tfor j in range(3):\n\t\taij = ai[j]\n\t\ta[i][j] = aij\n\ns = [[1 for _ in xrange(3)] for _ in xrange(3)]\n\ns[0][0] += a[0][0]\ns[0][0] += a[0][1]\ns[0][0] += a[1][0]\ns[0][0] %= 2\n\ns[0][1] += a[0][0]\ns[0][1] += a[0][1]\ns[0][1] += a[0][2]\ns[0][1] += a[1][1]\ns[0][1] %= 2\n\ns[0][2] += a[0][1]\ns[0][2] += a[0][2]\ns[0][2] += a[1][2]\ns[0][2] %= 2\n\ns[1][0] += a[0][0]\ns[1][0] += a[1][0]\ns[1][0] += a[1][1]\ns[1][0] += a[2][0]\ns[1][0] %= 2\n\ns[1][1] += a[0][1]\ns[1][1] += a[1][0]\ns[1][1] += a[1][1]\ns[1][1] += a[1][2]\ns[1][1] += a[2][1]\ns[1][1] %= 2\n\ns[1][2] += a[0][2]\ns[1][2] += a[1][1]\ns[1][2] += a[1][2]\ns[1][2] += a[2][2]\ns[1][2] %= 2\n\ns[2][0] += a[1][0]\ns[2][0] += a[2][0]\ns[2][0] += a[2][1]\ns[2][0] %= 2\n\ns[2][1] += a[1][1]\ns[2][1] += a[2][0]\ns[2][1] += a[2][1]\ns[2][1] += a[2][2]\ns[2][1] %= 2\n\ns[2][2] += a[1][2]\ns[2][2] += a[2][1]\ns[2][2] += a[2][2]\ns[2][2] %= 2\n\ns0 = str(s[0][0]) + str(s[0][1]) + str(s[0][2])\ns1 = str(s[1][0]) + str(s[1][1]) + str(s[1][2])\ns2 = str(s[2][0]) + str(s[2][1]) + str(s[2][2])\n\nprint s0\nprint s1\nprint s2"}, {"source_code": "n=list(map(int,input().split()))\nn.extend(list(map(int,input().split())))\nn.extend(list(map(int,input().split())))\n\np1=str((n[0]+n[1]+n[3]+1)%2)+str((n[0]+n[1]+n[4]+n[2]+1)%2)+str((n[1]+n[2]+n[5]+1)%2)\np2=str((n[0]+n[4]+n[3]+n[6]+1)%2)+str((n[3]+n[1]+n[4]+n[5]+n[7]+1)%2)+str((n[4]+n[2]+n[5]+n[8]+1)%2)\np3=str((n[3]+n[6]+n[7]+1)%2)+str((n[4]+n[6]+n[7]+n[8]+1)%2)+str((n[7]+n[8]+n[5]+1)%2)\n\nprint(\"{}\\n{}\\n{}\".format(p1,p2,p3))"}, {"source_code": "def toggle(pos, count):\n i = int(pos[0])\n j = int(pos[1])\n \n if count % 2 != 0:\n if data[i][j] == 0:\n data[i][j] = 1\n return True\n elif data[i][j] == 1:\n data[i][j] = 0\n return True\n else:\n return False\n \ndata = [[1, 1, 1],\n [1, 1, 1],\n [1, 1, 1]]\nnumber = []\nn = 3\n[number.append(input().split(\" \")) for i in range (n)]\nfor i in range (n):\n for j in range (n):\n count = int(number[i][j])\n pos = [i, j]\n toggle(pos, count)\n \n if i-1 < 0:\n if j-1 < 0:\n pos = [i, j+1]\n toggle(pos, count)\n pos = [i+1, j]\n toggle(pos, count)\n elif j+1 > n-1:\n pos = [i, j-1]\n toggle(pos, count)\n pos = [i+1, j]\n toggle(pos, count)\n else:\n pos = [i+1, j]\n toggle(pos, count)\n pos = [i, j-1]\n toggle(pos, count)\n pos = [i, j+1]\n toggle(pos, count)\n elif i+1 > n-1:\n if j+1 > n-1:\n pos = [i, j-1]\n toggle(pos, count)\n pos = [i-1, j]\n toggle(pos, count)\n elif j-1 < 0:\n pos = [i-1, j]\n toggle(pos, count)\n pos = [i, j+1]\n toggle(pos, count)\n else:\n pos = [i, j-1]\n toggle(pos, count)\n pos = [i, j+1]\n toggle(pos, count)\n pos = [i-1, j]\n toggle(pos, count)\n else:\n if j-1 < 0:\n pos = [i, j+1]\n toggle(pos, count)\n pos = [i-1, j]\n toggle(pos, count)\n pos = [i+1, j]\n toggle(pos, count)\n elif j+1 > n-1:\n pos = [i, j-1]\n toggle(pos, count)\n pos = [i-1, j]\n toggle(pos, count)\n pos = [i+1, j]\n toggle(pos, count)\n else:\n pos = [i-1, j]\n toggle(pos, count)\n pos = [i+1, j]\n toggle(pos, count)\n pos = [i, j-1]\n toggle(pos, count)\n pos = [i, j+1]\n toggle(pos, count)\nfor i in range (n):\n for j in range (n):\n print(data[i][j], end = '')\n print()"}, {"source_code": "Z=0,1,2\na=[map(int,raw_input().split())+[0]for _ in Z]+[[0]*4]\nfor i in Z:print''.join(`(1^a[i][j]^a[i-1][j]^a[i][j-1]^a[i+1][j]^a[i][j+1])%2`for j in Z)\n"}, {"source_code": "from sys import stdin\ndef main():\n\tf1=[1,1,1]\n\tf2=[1,1,1]\n\tf3=[1,1,1]\n\ta=str(stdin.readline()).split()\n\tb=str(stdin.readline()).split()\n\tc=str(stdin.readline()).split()\n\tfor i in range (3):\n\t\ta[i]=int(a[i])\n\t\tb[i]=int(b[i])\n\t\tc[i]=int(c[i])\n\tif (a[0]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\tif (a[1]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\tif (a[2]%2!=0):\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\tif (b[0]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\tif (b[1]%2!=0):\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\tif (b[2]%2!=0):\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\tif (c[0]%2!=0):\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\tif (c[1]%2!=0):\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\tif (c[2]%2!=0):\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\td=str(f1[0])\n\te=str(f1[1])\n\tf=str(f1[2])\n\tg=str(f2[0])\n\th=str(f2[1])\n\ti=str(f2[2])\n\tj=str(f3[0])\n\tk=str(f3[1])\n\tl=str(f3[2])\n\tprint (d+e+f)\n\tprint(g+h+i)\n\tprint(j+k+l)\nmain()\n\n\n"}, {"source_code": "import sys\nimport math\nimport bisect\n\ndef solve(A):\n n = len(A)\n B = []\n for i in range(n):\n B.append([1] * n)\n for i in range(n):\n for j in range(n):\n A[i][j] %= 2\n if A[i][j]:\n B[i][j] ^= 1\n if i - 1 >= 0:\n B[i-1][j] ^= 1\n if i + 1 < n:\n B[i+1][j] ^= 1\n if j - 1 >= 0:\n B[i][j-1] ^= 1\n if j + 1 < n:\n B[i][j+1] ^= 1\n return B\n\ndef main():\n A = []\n for i in range(3):\n A.append(list(map(int, input().split())))\n ans = solve(A)\n for i in range(len(ans)):\n print(''.join(list(str(a) for a in ans[i])))\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "Z=0,1,2\na=[map(int,raw_input().split())+[0]for _ in Z]+[[0]*4]\nfor i in Z:print''.join(`(1^a[i][j]^a[i-1][j]^a[i][j-1]^a[i+1][j]^a[i][j+1])%2`for j in Z)"}, {"source_code": "def calc(grid):\n n = [[\"1\" for y in range(3)] for x in range(3)]\n for row in range(len(grid)):\n for col in range(len(grid[0])):\n update(n, grid, row, col)\n return n\ndef update(n, grid, row, col):\n c = grid[row][col]\n c %=2\n if c != 0:\n # toggle adjacent lights\n for nr, nc in zip([row-1, row+1, row, row], [col, col, col-1,col+1]):\n if nr>=0 and nr=0 and nc=0):\n\t\t\t\tans[i-1][j]=ans[i-1][j]^1\n\t\t\tif(i+1<3):\n\t\t\t\tans[i+1][j]=ans[i+1][j]^1\n\t\t\tif(j-1>=0):\n\t\t\t\tans[i][j-1]=ans[i][j-1]^1\n\t\t\tif(j+1<3):\n\t\t\t\tans[i][j+1]=ans[i][j+1]^1\n\n\nfor i in range(3):\n\tfor j in range(3):\n\t\tprint(ans[i][j],end='')\n\tprint('')\n"}, {"source_code": "n=list(map(int,input().split()))\nn.extend(list(map(int,input().split())))\nn.extend(list(map(int,input().split())))\n\np1=str((n[0]+n[1]+n[3]+1)%2)+str((n[0]+n[1]+n[4]+n[2]+1)%2)+str((n[1]+n[2]+n[5]+1)%2)\np2=str((n[0]+n[4]+n[3]+n[6]+1)%2)+str((n[3]+n[1]+n[4]+n[5]+n[7]+1)%2)+str((n[4]+n[2]+n[5]+n[8]+1)%2)\np3=str((n[3]+n[6]+n[7]+1)%2)+str((n[4]+n[6]+n[7]+n[8]+1)%2)+str((n[7]+n[8]+n[5]+1)%2)\n\n\n#print(\"{}\\n{}\\n{}\".format(p1,p2,p3))\nprint(p1+'\\n'+p2+'\\n'+p3)\n"}, {"source_code": "b =[[0 for i in range(5)] for j in range(5)]\nfor i in range(1,4):\n b[i][1:4] = [int(x)%2 for x in input().split()]\nfor i in range(1,4):\n for j in range(1,4):\n print((1+b[i][j] + b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1])%2, end='')\n print()\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\n############ ---- Input Functions ---- ############\n# \u2014 For taking integer inputs.\ndef inp():\n return(int(input()))\n # \u2014 For taking List inputs.\ndef inlt():\n return(list(map(int,input().split())))\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 insr():\n s = input()\n return(list(s[:len(s) - 1]))\n # \u2014 For taking space seperated integer variable inputs.\ndef invr():\n return(map(int,input().split()))\n# --------------------------------------------------\ngrid = [\n [1,1,1],\n [1,1,1],\n [1,1,1],\n]\ninputGrid = []\nfor x in range(3):\n inputGrid.append(list(invr()))\nfor x in range(3):\n for i in range(3):\n num = inputGrid[x][i]\n for c in range(num):\n grid[x][i] = 1 - grid[x][i]\n if x+1 < 3:\n grid[x+1][i] = 1 - grid[x+1][i]\n if x-1 >= 0:\n grid[x-1][i] = 1 - grid[x-1][i]\n if i-1 >= 0:\n grid[x][i-1] = 1 - grid[x][i-1]\n if i+1 < 3:\n grid[x][i+1] = 1 - grid[x][i+1]\nfor x in range(3):\n print(''.join(map(str,grid[x])))"}, {"source_code": "l=[]\nfor i in range(3):\n l.append(list(map(int,input().split(\" \"))))\nfor i in range(3):\n for j in range(3):\n s=l[i][j]\n if j-1>=0:\n s+=l[i][j-1]\n if j+1<3:\n s+=l[i][j+1]\n if i-1>=0:\n s+=l[i-1][j]\n if i+1<3:\n s+=l[i+1][j]\n if s%2==0:\n print(\"1\",end=\"\")\n else:\n print(\"0\",end=\"\")\n print()"}, {"source_code": "import sys\nu = sys.stdin.read().split('\\n')\narr = []\nlight = [[1,1,1], [1,1,1], [1,1,1]]\nfor line in u:\n c = []\n for x in line.split():\n if int(x) %2 == 0:\n c.append(0)\n else:\n c.append(1)\n arr.append(c)\nfor i,row in enumerate(arr):\n for j,a in enumerate(row):\n if a == 1:\n if light[i][j] == 1:\n light[i][j] = 0\n else:\n light[i][j] = 1\n if i+1 != 3:\n if light[i + 1][j] == 1:\n light[i +1][j] = 0\n else:\n light[i+1][j] = 1\n if i-1 != -1:\n if light[i-1][j] == 1:\n light[i-1][j] = 0\n else:\n light[i-1][j] = 1\n if j-1 != -1:\n if light[i][j-1] == 1:\n light[i][j-1] = 0\n else:\n light[i][j-1] = 1\n if j+1 != 3:\n if light[i][j+1] == 1:\n light[i][j+1] = 0\n else:\n light[i][j+1] = 1\n\nfor li in light:\n c = \"\"\n for a in li:\n c += str(a)\n print(c)"}, {"source_code": "matrix = []\noutput = [[0 for i in range(3)] for j in range(3)]\nfor i in range(3):\n matrix.append([int(j) for j in input().split()])\nfor i in range(3):\n for j in range(3):\n s = 0\n s+=matrix[i][j]\n if i>0:\n s+=matrix[i-1][j]\n if i<2:\n s+=matrix[i+1][j]\n if j>0:\n s+=matrix[i][j-1]\n if j<2:\n s+=matrix[i][j+1]\n output[i][j] = str((s%2+1)%2)\nfor i in range(3):\n print(''.join(output[i]))"}, {"source_code": "#!/usr/bin/env python\n\n\n\nrow1 = [int(x) for x in raw_input().split()]\nrow2 = [int(x) for x in raw_input().split()]\nrow3 = [int(x) for x in raw_input().split()]\n\nmatrix = [row1, row2, row3]\n\nans = [[1,1,1],[1,1,1],[1,1,1]]\n\nfor i in xrange(3):\n\tfor z in xrange(3):\n\t\tif matrix[i][z] != 0:\n\t\t\t\t# print ans\n\t\t\t\tif i == 0 and z == 0:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 0 and z == 1:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 0 and z == 2:\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 1 and z == 0:\n\t\t\t\t\t# print \"A\",ans[i][z]\n\t\t\t\t\t# print ans\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 1 and z == 1:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 1 and z == 2:\n\t\t\t\t\t\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 2 and z == 0:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 2 and z == 1:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 2 and z == 2:\n\t\t\t\t\t\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\t# print ans\n\t\t\t\t# print \"/\",i,z,matrix[i][z]\n\n\nfor i in xrange(3):\n\tfor z in xrange(3):\n\t\tif ans[i][z]%2 != 0:\n\t\t\tans[i][z] = 1\n\t\telse:\n\t\t\tans[i][z] = 0\nfor r in ans:\n\tprint \"\".join([str(x) for x in r])\n"}, {"source_code": "a =[[],[],[]]\na[0], a[1], a[2] = map(int,raw_input().split()), map(int,raw_input().split()), map(int,raw_input().split())\nb = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\nfor i in range(3):\n for j in range(3):\n times = a[i][j]\n while times > 0:\n if i > 0:\n b[i - 1][j] = b[i - 1][j] ^ 1\n if i < 2:\n b[i + 1][j] = b[i + 1][j] ^ 1\n if j > 0:\n b[i][j - 1] = b[i][j - 1] ^ 1\n if j < 2:\n b[i][j + 1] = b[i][j + 1] ^ 1\n b[i][j] = b[i][j] ^ 1\n times -= 1\nprint \"\".join(map(str,b[0]))\nprint \"\".join(map(str,b[1]))\nprint \"\".join(map(str,b[2]))"}, {"source_code": "a=map(int,raw_input().strip().split())\nb=map(int,raw_input().strip().split())\nc=map(int,raw_input().strip().split())\na0=a[0]+a[1]+b[0]\na1=a[0]+a[1]+a[2]+b[1]\na2=a[2]+a[1]+b[2]\n\nb0=b[0]+b[1]+a[0]+c[0]\nb1=b[0]+b[1]+b[2]+a[1]+c[1]\nb2=b[2]+b[1]+a[2]+c[2]\n\nc0=c[0]+c[1]+b[0]\nc1=c[1]+c[0]+c[2]+b[1]\nc2=c[2]+c[1]+b[2]\n\n#print a0,a1,a2\n#print b0,b1,b2\n#print c0,c1,c2\n\nx=[a0,a1,a2]\ny=[b0,b1,b2]\nz=[c0,c1,c2]\nstra=\"\"\nfor xx in x:\n if xx%2==0:\n stra+=\"1\"\n else:\n stra+=\"0\"\n\nstrb=\"\"\nfor yy in y:\n if yy%2==0:\n strb+=\"1\"\n else:\n strb+=\"0\"\nstrc=\"\"\nfor zz in z:\n if zz%2==0:\n strc+=\"1\"\n else:\n strc+=\"0\"\nprint stra\nprint strb\nprint strc\n \n \n"}, {"source_code": "n = [map(int,raw_input().split())for s in range(3)]\na = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n n[i][j] = n[i][j]%2\nfor i in range(3):\n for j in range(3):\n if n[i][j]:\n for x in range(i-1,i+2):\n if 0<=x<=2:\n if a[x][j] ==1:\n a[x][j] = 0\n else:\n a[x][j] = 1\n for y in (j-1,j+1):\n if 0<=y<=2:\n if a[i][y] == 1:\n a[i][y] = 0\n else:\n a[i][y] = 1\nfor i in range(3):\n print \"\".join(map(str,[a[i][j] for j in range(3)]))"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[104]:\n\n\n# n = int(input())\n# line = list(map(int, input().split()))\nline = []\nfor _ in range(3):\n line.append(list(map(int, input().split())))\n\n\n# In[109]:\n\n\nmod_func = lambda x: [[i%2 for i in y] for y in x]\nline = mod_func(line)\nres = [[1 for _ in range(3)] for _ in range(3)]\n\nfor i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n res[i][j] = 1 if res[i][j] == 0 else 0\n try: \n res[i][j+1] = 1 if res[i][j+1] == 0 else 0\n except: None\n try:\n if j - 1 >= 0:\n res[i][j-1] = 1 if res[i][j-1] == 0 else 0\n except: None\n try: \n res[i+1][j] = 1 if res[i+1][j] == 0 else 0\n except: None\n try: \n if i - 1 >= 0:\n res[i-1][j] = 1 if res[i-1][j] == 0 else 0\n except: None\n\nfor i in range(len(res)):\n print(\"\".join(map(str, res[i])))\n\n \n\n"}, {"source_code": "a = []\nfor _ in range(3):\n a.append(list(map(int, input().split())))\nfor i in range(3):\n ans = \"\"\n for j in range(3):\n s = 0\n s+=a[i][j]\n if i+1<3:\n s+=a[i+1][j]\n if i-1>=0:\n s+=a[i-1][j]\n if j+1<3:\n s+=a[i][j+1]\n if j-1>=0:\n s+=a[i][j-1]\n # print(s,end=\" \")\n if s%2==0:\n ans+=\"1\"\n else:\n ans+=\"0\"\n # print()\n print(ans)\n\n"}, {"source_code": "#Lights Out\n#Problem Link : http://codeforces.com/problemset/problem/275/A\n\nres = list()\nres.append([0 , 0 , 0 , 0 , 0])\n\nfor i in range(1 , 4):\n res.append([0 , 0 , 0 , 0 , 0])\n res[i][1] , res[i][2] , res[i][3] = map(int , input().split())\nres.append([0 , 0 , 0 , 0 , 0])\n\nfor i in range(1 , 4):\n for j in range(1 , 4):\n print(1 - (res[i][j] + res[i-1][j] + res[i][j-1] + res[i+1][j] + res[i][j+1])%2 , end='')\n print()"}, {"source_code": "#!/usr/bin/env python\nfrom sys import stdin as cin\n\ndef main():\n a = sum((map(int, next(cin).split()) for i in range(3)), [])\n mod = (\n (0,1,3),\n (0,1,2,4),\n (1,2,5),\n (0,3,4,6),\n (1,3,4,5,7),\n (2,4,5,8),\n (3,6,7),\n (4,6,7,8),\n (5,7,8),\n )\n s = [1] * 9\n\n for m in range(9):\n c = a[m]\n for i in mod[m]:\n s[i] += c\n\n s = [ str(i % 2) for i in s ]\n\n return '\\n'.join(''.join(s[i:i+3]) for i in (0,3,6)) + '\\n'\n\nprint main()\n"}, {"source_code": "light_turners = list()\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\n\nlights = [[True, True, True], [True, True, True], [True, True, True]]\n\n\ndef flip_adjacent(i, j):\n lights[i][j] = not lights[i][j]\n\n if i + 1 < 3:\n lights[i + 1][j] = not lights[i + 1][j]\n\n if j + 1 < 3:\n lights[i][j + 1] = not lights[i][j + 1]\n\n if i - 1 > -1:\n lights[i - 1][j] = not lights[i - 1][j]\n\n if j - 1 > - 1:\n lights[i][j - 1] = not lights[i][j - 1]\n\n\nfor i in range(3):\n for j in range(3):\n while light_turners[i][j] > 0:\n flip_adjacent(i, j)\n light_turners[i][j] -= 1\n\nfor i in range(3):\n for j in range(3):\n print(1 if lights[i][j] else 0, end='')\n print('')\n# 1476521911520"}, {"source_code": "def main():\n def get_elements(x, y):\n ele = [[x,y]]\n if x==0:\n ele.append([1,y])\n if x==1:\n ele.append([0,y])\n ele.append([2,y])\n if x==2:\n ele.append([1,y])\n if y==0:\n ele.append([x,1])\n if y==1:\n ele.append([x,0])\n ele.append([x,2])\n if y==2:\n ele.append([x,1])\n return ele\n arr = [map(int, raw_input().split()) for i in xrange(3)]\n lights = [[1]*3 for i in xrange(3)]\n for i,k in enumerate(arr):\n for j,l in enumerate(k):\n if l%2==1:\n ele = get_elements(i,j)\n for m in ele:\n if lights[m[0]][m[1]]==0:\n lights[m[0]][m[1]] = 1\n else:\n lights[m[0]][m[1]] = 0\n for i in xrange(3):\n print ''.join(map(str, lights[i]))\nmain()\n"}, {"source_code": "t = [list(map(int, input().split())) for i in range(3)]\np = [[1] * 5 for i in range(5)]\nfor i in range(3):\n for j in range(3):\n if t[i][j] % 2 == 1:\n p[i][j + 1] += 1\n p[i + 2][j + 1] += 1\n for v in range(j, j + 3):\n p[i + 1][v] += 1\nfor i in range(1, 4):\n print(''.join(str(p[i][j] % 2) for j in range(1, 4)))\n "}, {"source_code": "String =[[0 for i in range(5)] for j in range(5)]\nfor i in range(1,4): String[i][1:4] = [int(x)%2 for x in input().split()]\nfor i in range(1,4):\n for j in range(1,4): print((1+String[i][j] + String[i-1][j]+String[i+1][j]+String[i][j-1]+String[i][j+1])%2, end='')\n print()"}, {"source_code": "a11, a12, a13 = map(int, input().split())\na21, a22, a23 = map(int, input().split())\na31, a32, a33 = map(int, input().split())\nl1, l2, l3 = \"\",\"\",\"\"\nif (a11 + a12 + a21) % 2 == 0:\n l1 += \"1\"\nelse:\n l1 += \"0\"\nif (a11 + a12 + a13 + a22) % 2 == 0:\n l1 += \"1\"\nelse:\n l1 += \"0\"\nif (a12 + a13 + a23) % 2 == 0:\n l1 += \"1\"\nelse:\n l1 += \"0\"\nif (a11 + a21 + a22 + a31) % 2 == 0:\n l2 += \"1\"\nelse:\n l2 += \"0\"\nif (a12 + a21 + a22 + a23 + a32) % 2 == 0:\n l2 += \"1\"\nelse:\n l2 += \"0\"\nif (a13 + a22 + a23 + a33) % 2 == 0:\n l2 += \"1\"\nelse:\n l2 += \"0\"\nif (a21 + a31 + a32) % 2 == 0:\n l3 += \"1\"\nelse:\n l3 += \"0\"\nif (a22 + a31 + a32 + a33) % 2 == 0:\n l3 += \"1\"\nelse:\n l3 += \"0\"\nif (a23 + a32 + a33) % 2 == 0:\n l3 += \"1\"\nelse:\n l3 += \"0\"\n\nprint(l1)\nprint(l2)\nprint(l3)"}, {"source_code": "l=[map(int,raw_input().split()) for i in xrange(3)]\nr=[[1]*3 for i in xrange(3)]\nfor i in xrange(3):\n for j in xrange(3):\n if not l[i][j]%2: continue\n for (dx,dy) in ((0,0),(0,1),(0,-1),(1,0),(-1,0)):\n if 0 <= i + dx < 3 and 0 <= j + dy < 3 :\n r[i + dx][j + dy] = 1 - r[i + dx][j + dy]\n \nfor i in r:\n print ''.join(str(j) for j in i)"}, {"source_code": "sw = list()\nfor i in range(3):\n lst = list(map(int,input().split()))\n sw.append(lst)\nlight = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n while(sw[i][j] > 0):\n if i > 0:\n if(light[i-1][j] == 1):\n light[i-1][j] = 0\n else:\n light[i-1][j] = 1\n if i+1 < 3:\n if(light[i+1][j] == 1):\n light[i+1][j] = 0\n else:\n light[i+1][j] = 1\n if j > 0:\n if(light[i][j-1] == 1):\n light[i][j-1] = 0\n else:\n light[i][j-1] = 1\n if j+1 < 3:\n if(light[i][j+1] == 1):\n light[i][j+1] = 0\n else:\n light[i][j+1] = 1\n if(light[i][j] == 1):\n light[i][j] = 0\n else:\n light[i][j] = 1\n sw[i][j] -= 1\nfor i in light:\n for j in i:\n print(j,end='')\n print('')"}, {"source_code": "Z=0,1,2\na=[map(int,raw_input().split())+[0]for _ in Z]+[[0]*4]\nfor i in Z:print''.join(`(1^a[i][j]^a[i-1][j]^a[i][j-1]^a[i+1][j]^a[i][j+1])%2`for j in Z)\n"}, {"source_code": "def change(arr, i, j):\n\tif arr[i][j] == 0:\n\t\tarr[i][j] = 1\n\telse:\n\t\tarr[i][j] = 0\n\treturn arr\n\nlights = [[1, 1, 1, 1, 1] for j in range(5)]\narr = [[int(j) for j in input().split()] for x in range(3)]\n\nfor i in range(3):\n\tfor j in range(3):\n\t\tnum = arr[i][j]\t% 2\n\t\twhile num != 0:\n\t\t\tlights = change(lights, i+1, j+1)\n\t\t\tlights = change(lights, i, j+1)\n\t\t\tlights = change(lights, i+2, j+1)\n\t\t\tlights = change(lights, i+1, j)\n\t\t\tlights = change(lights, i+1, j+2)\n\t\t\tnum -= 1\n\nfor x in range(1, 4):\n\tfor y in range(1, 4):\n\t\tprint(lights[x][y], end = '')\n\tprint('')\n"}, {"source_code": "n = [map(int,raw_input().split())for s in range(3)]\na = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n n[i][j] = n[i][j]%2\nfor i in range(3):\n for j in range(3):\n if n[i][j]:\n for x in range(i-1,i+2):\n if 0<=x<=2:\n if a[x][j] ==1:\n a[x][j] = 0\n else:\n a[x][j] = 1\n for y in (j-1,j+1):\n if 0<=y<=2:\n if a[i][y] == 1:\n a[i][y] = 0\n else:\n a[i][y] = 1\nfor i in range(3):\n print \"\".join(map(str,[a[i][j] for j in range(3)]))"}, {"source_code": "res = list()\nres.append([0 , 0 , 0 , 0 , 0])\n\nfor i in range(1 , 4):\n res.append([0 , 0 , 0 , 0 , 0])\n res[i][1] , res[i][2] , res[i][3] = map(int , input().split())\nres.append([0 , 0 , 0 , 0 , 0])\n\nfor i in range(1 , 4):\n for j in range(1 , 4):\n print(1 - (res[i][j] + res[i-1][j] + res[i][j-1] + res[i+1][j] + res[i][j+1])%2 , end='')\n print()"}, {"source_code": "import sys\nu = sys.stdin.read().split('\\n')\narr = []\nlight = [[1,1,1], [1,1,1], [1,1,1]]\nfor line in u:\n c = []\n for x in line.split():\n if int(x) %2 == 0:\n c.append(0)\n else:\n c.append(1)\n arr.append(c)\nfor i,row in enumerate(arr):\n for j,a in enumerate(row):\n if a == 1:\n if light[i][j] == 1:\n light[i][j] = 0\n else:\n light[i][j] = 1\n if i+1 != 3:\n if light[i + 1][j] == 1:\n light[i +1][j] = 0\n else:\n light[i+1][j] = 1\n if i-1 != -1:\n if light[i-1][j] == 1:\n light[i-1][j] = 0\n else:\n light[i-1][j] = 1\n if j-1 != -1:\n if light[i][j-1] == 1:\n light[i][j-1] = 0\n else:\n light[i][j-1] = 1\n if j+1 != 3:\n if light[i][j+1] == 1:\n light[i][j+1] = 0\n else:\n light[i][j+1] = 1\n\nfor li in light:\n c = \"\"\n for a in li:\n c += str(a)\n print(c)"}, {"source_code": "l = []\nm = []\n\nfor x in range(0, 3) :\n\n l.append(map(int, raw_input().split()))\n\nfor x in range(0, 3) :\n\n for y in range(0, 3) :\n\n count = 0\n\n for p in range(0, 3) :\n\n for q in range(0, 3) :\n\n if ( x==p and abs(y-q)<=1 ) or ( y==q and abs(x-p)<=1 ) :\n\n count = count + l[p][q]\n\n if count % 2 == 0 :\n\n m.append('1')\n\n else :\n\n m.append('0')\n\nprint ''.join(m[:3]),\"\\n\",''.join(m[3:6]),\"\\n\",''.join(m[6:])"}, {"source_code": "\ninp = []\nres = []\nfor i in xrange(0, 3):\n\tinp.append(raw_input().split())\nfor i in xrange(0, 3):\n\ttmp = \"\"\n\tfor j in xrange(0, 3):\n\t\tswitches = 0\n\t\tfor k in xrange(max(0, i - 1), min(3, i + 2)):\n\t\t\tswitches += int(inp[k][j])\n\t\tfor l in xrange(max(0, j - 1), min(3, j + 2)):\n\t\t\tswitches += int(inp[i][l])\n\t\tswitches -= int(inp[i][j])\n\t\t#print switches\t\t\t\n\t\ttmp += str((switches + 1) % 2)\n\tres.append(tmp)\nfor s in res:\n\tprint s\n"}, {"source_code": "matrix1 = [[-1 for x in range(5)] for y in range(5)]\nfor i in range(1,4):\n for j in range(1,4):\n matrix1[i][j] = 1\n\nscan = [[-1 for x in range(3)] for y in range(3)]\nfor i in range(3):\n x = [int(x) for x in input().split()]\n for j in range(len(x)):\n if x[j] % 2 == 1:\n if matrix1[i+1][j+1] == 0:\n matrix1[i+1][j+1] = 1\n elif matrix1[i+1][j+1] == 1:\n matrix1[i+1][j+1] = 0\n if matrix1[i + 1][j] == 0:\n matrix1[i + 1][j] = 1\n elif matrix1[i + 1][j] == 1:\n matrix1[i + 1][j] = 0\n if matrix1[i][j + 1] == 0:\n matrix1[i][j + 1] = 1\n elif matrix1[i][j + 1] == 1:\n matrix1[i][j + 1] = 0\n if matrix1[i + 1][j + 2] == 0:\n matrix1[i + 1][j + 2] = 1\n elif matrix1[i + 1][j + 2] == 1:\n matrix1[i + 1][j + 2] = 0\n if matrix1[i + 2][j + 1] == 0:\n matrix1[i + 2][j + 1] = 1\n elif matrix1[i + 2][j + 1] == 1:\n matrix1[i + 2][j + 1] = 0\n\nfor i in range(1, 4):\n for j in range(1, 4):\n print(matrix1[i][j], end = '')\n print()\n\n\n\n"}, {"source_code": "b =[[0 for i in range(5)] for j in range(5)]\nfor i in range(1,4):\n b[i][1:4] = [int(x)%2 for x in input().split()]\nfor i in range(1,4):\n for j in range(1,4):\n print((1+b[i][j] + b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1])%2, end='')\n print()\n"}, {"source_code": "l = [[0 for i in range(5)] for j in range(5)]\n\nfor i in range(1,4):\n l[i][1:4]=[int(j) for j in input().split()]\n\nfor i in range(1,4):\n for j in range(1,4):\n s = l[i][j]+l[i+1][j]+l[i][j+1] +l[i-1][j]+l[i][j-1]\n if s%2==0:\n print(\"1\",end=\"\")\n else:\n print(\"0\",end=\"\")\n print()"}, {"source_code": "Z=0,1,2\na=[map(int,raw_input().split())+[0]for _ in Z]+[[0]*4]\nfor i in Z:print''.join(`(1^a[i][j]^a[i-1][j]^a[i][j-1]^a[i+1][j]^a[i][j+1])%2`for j in Z)\n"}, {"source_code": "def readarray(f): return map(f, raw_input().split())\ndef readint(): return int(raw_input())\ndef printlist(l): print ' '.join(map(str, l))\n\nG = []\nfor i in range(3):\n G.append(readarray(int))\nres = [[1]*3 for i in range(3)]\n\nfor i in range(3):\n for j in range(3):\n if G[i][j]%2 == 1:\n if i > 0:\n res[i-1][j] = 1-res[i-1][j]\n if i < 2:\n res[i+1][j] = 1-res[i+1][j]\n if j > 0:\n res[i][j-1] = 1-res[i][j-1]\n if j < 2:\n res[i][j+1] = 1-res[i][j+1]\n res[i][j] = 1-res[i][j]\nfor i in range(3):\n print ''.join(map(str, res[i]))\n"}, {"source_code": "Z=0,1,2\na=[map(int,raw_input().split())for _ in Z]\nfor i in Z:print''.join(`(1^a[i][j]^(i>0)*a[i-1][j]^(j>0)*a[i][j-1]^(i<2)*a[i-2][j]^(j<2)*a[i][j-2])%2`for j in Z)"}, {"source_code": "matrix = [] \nfor i in range(3): \n a =[] \n a=list(map(int,input().split()))\n matrix.append(a)\n\na=[[1, 1, 1] ,[1, 1, 1], [1, 1, 1]]\n\nfor i in range(3):\n for j in range(3):\n if (matrix[i][j])%2==1:\n if a[i][j]==0:\n a[i][j]=1\n else:\n a[i][j]=0\n if i-1>=0:\n if a[i-1][j]==0:\n a[i-1][j]=1\n else:\n a[i-1][j]=0\n if i+1<=2:\n if a[i+1][j]==0:\n a[i+1][j]=1\n else:\n a[i+1][j]=0\n if j-1>=0:\n if a[i][j-1]==0:\n a[i][j-1]=1\n else:\n a[i][j-1]=0\n if j+1<=2:\n if a[i][j+1]==0:\n a[i][j+1]=1\n else:\n a[i][j+1]=0\n\nfor i in range(3):\n for j in range(3):\n print(a[i][j], end =\"\")\n print()\n \n\n \n \n \n\n\n"}, {"source_code": "def permitido(l,c):\n return l >= 0 and c >= 0 and l <= 2 and c <= 2\ndef muda_adjacentes(i,j):\n if grid[i][j] == \"0\":\n grid[i][j] = \"1\"\n else:\n grid[i][j] = \"0\"\n\n for m in range(4):\n l_destino = i + mv[m]\n c_destino = j + mh[m]\n\n if permitido(l_destino,c_destino):\n\n if grid[i + mv[m]][j + mh[m]] == \"0\":\n grid[i + mv[m]][j + mh[m]] = \"1\"\n\n else:\n grid[i + mv[m]][j + mh[m]] = \"0\"\n\n\nmv = [1,-1,0,0]\nmh = [0,0,1,-1]\n\napertos = []\n\nfor i in range(3):\n a,b,c = map(int,input().split())\n\n apertos.append([a,b,c])\n\ngrid = []\nfor i in range(3):\n grid.append(list(\"111\"))\n\nfor L in range(3):\n for C in range(3):\n if apertos[L][C] != 0:\n if apertos[L][C] % 2 != 0:\n muda_adjacentes(L,C)\n\nfor i in range(3):\n linha = \"\"\n for j in range(3):\n linha += grid[i][j]\n\n print(linha)\n"}, {"source_code": "import sys\n\ndef func(a1,a2,a3,b1,b2,b3,c1,c2,c3):\n x1=x2=x3=y1=y2=y3=z1=z2=z3= 1\n if a1%2 == 1:\n x1+=1\n x2+=1\n y1+=1\n if a2%2 == 1:\n x1+=1\n x2+=1\n x3+=1\n y2+=1\n if a3%2 == 1:\n x2+=1\n x3+=1\n y3+=1\n if b1%2 == 1:\n x1+=1\n y1+=1\n y2+=1\n z1+=1\n if b2%2 == 1:\n x2+=1\n y1+=1\n y2+=1\n y3+=1\n z2+=1\n if b3%2 == 1:\n x3+=1\n y2+=1\n y3+=1\n z3+=1\n if c1%2 == 1:\n y1+=1\n z1+=1\n z2+=1\n if c2%2 == 1:\n y2+=1\n z1+=1\n z2+=1\n z3+=1\n if c3%2 == 1:\n y3+=1\n z2+=1\n z3+=1\n list1=[]\n list1.append(x1)\n list1.append(x2)\n list1.append(x3)\n list1.append(y1)\n list1.append(y2)\n list1.append(y3)\n list1.append(z1)\n list1.append(z2)\n list1.append(z3)\n\n return list1\n\nif __name__ == '__main__':\n\n a1,a2,a3 = map(int,sys.stdin.readline().split())\n b1,b2,b3 = map(int,sys.stdin.readline().split())\n c1,c2,c3 = map(int,sys.stdin.readline().split())\n\n list = func(a1,a2,a3,b1,b2,b3,c1,c2,c3)\n\n print \"%d%d%d\" %(list[0]%2,list[1]%2,list[2]%2)\n print \"%d%d%d\" %(list[3]%2,list[4]%2,list[5]%2)\n print \"%d%d%d\" %(list[6]%2,list[7]%2,list[8]%2)\n"}, {"source_code": "def toggler(i,j,arr):\n if (i-1)>=0:\n arr[i-1][j]=1-arr[i-1][j]\n if (i+1)<3:\n arr[i+1][j]=1-arr[i+1][j]\n if (j - 1) >= 0:\n arr[i][j-1]=1-arr[i][j-1]\n if (j + 1) < 3:\n arr[i][j+1]=1-arr[i][j+1]\nones=[[1,1,1],[1,1,1],[1,1,1]]\n\narr=[]\nfor i in range(3):\n arr.append(list(map(int,input().split())))\nfor i in range(3):\n for j in range(3):\n if arr[i][j]%2!=0:\n ones[i][j]=1-ones[i][j]\n toggler(i,j,ones)\nfor i in range(3):\n for j in range(3):\n print(ones[i][j],end=\"\")\n print()\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "a=[[1,1,1],[1,1,1],[1,1,1]]\nb=[]\ndef list_to_str(a):\n y=''\n for i in range(len(a)):y=y+str(a[i])\n return y\nfor i in range(3):\n c= list(map(int, input().split()))\n b.append(c)\nfor i in range(3):\n for j in range(3):\n a[i][j]+=b[i][j]\n if j>=1:a[i][j]+=b[i][j-1]\n if i>=1:a[i][j]+=b[i-1][j]\n try:a[i][j]+=b[i+1][j]\n except IndexError:pass\n try:a[i][j]+=b[i][j+1]\n except IndexError:pass\nfor i in a:\n for j in range(3):\n if i[j]%2==0:i[j]=0\n else:i[j]=1\nfor i in a:print(list_to_str(i))\n"}, {"source_code": "grid = []\nfor i in range(3):\n row = list(map(int,input().split()))\n grid.append(row)\ng = [[1]*3 for _ in range(3)]\nfor i in range(len(grid)):\n for j in range(len(grid[0])):\n if grid[i][j] & 1 :\n if i-1 >= 0:\n g[i-1][j] = 1- g[i-1][j]\n if j -1 >= 0:\n g[i][j-1] = 1- g[i][j-1]\n if i+1 < len(grid):\n g[i+1][j] = 1- g[i+1][j]\n if j + 1 < len(grid[0]):\n g[i][j+1] = 1- g[i][j+1]\n g[i][j] = 1- g[i][j]\nfor row in g:\n print(\"\".join(map(str,row)))"}, {"source_code": "import math\n\narr_initial = [[1,1,1],[1,1,1],[1,1,1]]\n\ntries = []\n\n\n\nfor i in range(3):\n tries.append(list(map(int, input().split())))\n\nrows = len(tries)\ncols = len(tries[0])\n\nfor i in range(rows):\n for j in range(cols):\n try_val = tries[i][j]\n \n while(try_val>0):\n arr_initial[i][j] = 1 - arr_initial[i][j]\n \n if(i+1<=(rows-1)):\n arr_initial[i+1][j] = 1 - arr_initial[i+1][j]\n \n if(i-1>=0):\n arr_initial[i-1][j] = 1 - arr_initial[i-1][j]\n \n if(j+1<=(cols-1)):\n arr_initial[i][j+1] = 1 - arr_initial[i][j+1]\n \n if(j-1>=0):\n arr_initial[i][j-1] = 1 - arr_initial[i][j-1]\n \n try_val-=1\n\nitr_ct = 1\nfinal_arr = \"\"\n\nfor i in range(rows):\n for j in range(cols):\n final_arr+=str(arr_initial[i][j])\n \n if(itr_ct>=0):\n final_arr+=\"\\n\"\n \n itr_ct-=1\n\nprint(final_arr)\n \n \n "}, {"source_code": "# coding =utf-8\nI = lambda:map(int,raw_input().split())\na = []\nb = []\nx = [1,-1,0,0,0]\ny = [0,0,1,-1,0]\nfor i in range(3):\n\ta.append(I())\nfor i in range(3):\n\tfor j in range(3):\n\t\tsum =0\n\t\tfor k in range(5):\n\t\t\tif i+x[k]>=0 and i+x[k]<=2 and j+y[k]>=0 and j+y[k]<=2:\n\t\t\t\tsum+=a[i+x[k]][j+y[k]]\n\t\tb.append((sum+1)%2)\nprint str(b[0])+str(b[1])+str(b[2])\nprint str(b[3])+str(b[4])+str(b[5])\nprint str(b[6])+str(b[7])+str(b[8])"}, {"source_code": "n=list(map(int,input().split()))\nn.extend(list(map(int,input().split())))\nn.extend(list(map(int,input().split())))\n\np1=str((n[0]+n[1]+n[3]+1)%2)+str((n[0]+n[1]+n[4]+n[2]+1)%2)+str((n[1]+n[2]+n[5]+1)%2)\np2=str((n[0]+n[4]+n[3]+n[6]+1)%2)+str((n[3]+n[1]+n[4]+n[5]+n[7]+1)%2)+str((n[4]+n[2]+n[5]+n[8]+1)%2)\np3=str((n[3]+n[6]+n[7]+1)%2)+str((n[4]+n[6]+n[7]+n[8]+1)%2)+str((n[7]+n[8]+n[5]+1)%2)\n\nprint(\"{}\\n{}\\n{}\".format(p1,p2,p3))"}, {"source_code": "g = [[0]*5] + [[0]+map(int, raw_input().split())+[0] for i in range(3)] + [[0]*5]\n\ndef f(x, y):\n return g[x][y-1]+g[x][y]+g[x][y+1]+g[x-1][y]+g[x+1][y]\nprint '\\n'.join([''.join([str(1-f(x, y)%2) for y in [1,2,3]]) for x in [1,2,3]])\n\n"}, {"source_code": "a=map(int,raw_input().strip().split())\nb=map(int,raw_input().strip().split())\nc=map(int,raw_input().strip().split())\na0=a[0]+a[1]+b[0]\na1=a[0]+a[1]+a[2]+b[1]\na2=a[2]+a[1]+b[2]\n\nb0=b[0]+b[1]+a[0]+c[0]\nb1=b[0]+b[1]+b[2]+a[1]+c[1]\nb2=b[2]+b[1]+a[2]+c[2]\n\nc0=c[0]+c[1]+b[0]\nc1=c[1]+c[0]+c[2]+b[1]\nc2=c[2]+c[1]+b[2]\n\n#print a0,a1,a2\n#print b0,b1,b2\n#print c0,c1,c2\n\nx=[a0,a1,a2]\ny=[b0,b1,b2]\nz=[c0,c1,c2]\nstra=\"\"\nfor xx in x:\n if xx%2==0:\n stra+=\"1\"\n else:\n stra+=\"0\"\n\nstrb=\"\"\nfor yy in y:\n if yy%2==0:\n strb+=\"1\"\n else:\n strb+=\"0\"\nstrc=\"\"\nfor zz in z:\n if zz%2==0:\n strc+=\"1\"\n else:\n strc+=\"0\"\nprint stra\nprint strb\nprint strc\n \n \n"}, {"source_code": "line1 = map(int, raw_input().split())\nline2 = map(int, raw_input().split())\nline3 = map(int, raw_input().split())\n\nmatrix1 = [0, 0, 0]\nmatrix2 = [0, 0, 0]\nmatrix3 = [0, 0, 0]\n\nmatrix = []\nmatrix.append(matrix1)\nmatrix.append(matrix2)\nmatrix.append(matrix3)\n\n\nx1 = line1[0] + line1[1] + line2[0]\nx2 = line1[0] + line1[1] + line1[2] + line2[1]\nx3 = line1[1] + line1[2] + line2[2]\nx4 = line2[0] + line2[1] + line1[0] + line3[0]\nx5 = line2[0] + line2[1] + line2[2] + line1[1] + line3[1]\nx6 = line2[1] + line2[2] + line1[2] + line3[2]\nx7 = line3[0] + line3[1] + line2[0]\nx8 = line3[0] + line3[1] + line3[2] + line2[1]\nx9 = line3[1] + line3[2] + line2[2]\n#print x1, x9\nif x1 % 2 == 0:\n matrix1[0] = 1\nif x2 % 2 == 0:\n matrix1[1] = 1\nif x3 % 2 == 0:\n matrix1[2] = 1\nif x4 % 2 == 0:\n matrix2[0] = 1\nif x5 % 2 == 0:\n matrix2[1] = 1\nif x6 % 2 == 0:\n matrix2[2] = 1\nif x7 % 2 == 0:\n matrix3[0] = 1\nif x8 % 2 == 0:\n matrix3[1] = 1\nif x9 % 2 == 0:\n matrix3[2] = 1\n\nprint str(matrix1[0]) + str(matrix1[1]) + str(matrix1[2])\nprint str(matrix2[0]) + str(matrix2[1]) + str(matrix2[2])\nprint str(matrix3[0]) + str(matrix3[1]) + str(matrix3[2])\n\n"}, {"source_code": "x11 , x12 , x13 = map(int,input().split())\nx21 , x22 , x23 = map(int,input().split())\nx31 , x32 , x33 = map(int,input().split())\nprint((\"1\" if (x11 + x12 + x21) % 2 == 0 else \"0\"),\n (\"1\" if (x11 + x12 + x13 + x22) % 2 == 0 else \"0\"),\n (\"1\" if (x12 + x13 + x23) % 2 == 0 else \"0\"),sep=\"\")\nprint((\"1\" if (x11 + x21 + x22 + x31) % 2 == 0 else \"0\"),\n (\"1\" if (x12 + x21 + x22 + x23 + x32) % 2 == 0 else \"0\"),\n (\"1\" if (x13 + x22 + x23 + x33) % 2 == 0 else \"0\"),sep=\"\")\nprint((\"1\" if (x21 + x31 + x32) % 2 == 0 else \"0\"),\n (\"1\" if (x22 + x31 + x32 + x33) % 2 == 0 else \"0\"),\n (\"1\" if(x23 + x32 + x33) % 2 == 0 else \"0\"),sep=\"\")\n"}, {"source_code": "import sys\nimport math\n\nB = []\nA = [[1, 1, 1],\n [1, 1, 1],\n [1, 1, 1]]\n \nfor i in range(3):\n s = map( int, sys.stdin.readline().split() )\n B.append(s)\n \nfor i in range(3):\n for j in range(3):\n if B[i][j] % 2 != 0:\n A[i][j] = (A[i][j] + 1) % 2\n if i - 1 > -1:\n A[i - 1][j] = (A[i - 1][j] + 1) % 2\n if j + 1 < 3:\n A[i][j + 1] = (A[i][j + 1] + 1) % 2\n if i + 1 < 3:\n A[i + 1][j] = (A[i + 1][j] + 1) % 2\n if j - 1 > -1:\n A[i][j - 1] = (A[i][j - 1] + 1) % 2\n\nfor i in range(3):\n k = ''\n for j in range(3):\n k += str(A[i][j])\n print k"}, {"source_code": "lights=[[1,1,1],[1,1,1],[1,1,1]]\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\ngiven=[]\ngiven.append(a)\ngiven.append(b)\ngiven.append(c)\ndef change(i,j):\n if(lights[i][j]==1):\n lights[i][j]=0\n else:\n lights[i][j]=1\nfor i in range(3):\n for j in range(3):\n if(i==0 and j==0):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i+1,j)\n change(i,j+1)\n if(i==0 and j==1):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i+1,j)\n change(i,j-1)\n change(i,j+1)\n if(i==0 and j==2):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i+1,j)\n change(i,j-1)\n if(i==1 and j==0):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i+1,j)\n change(i,j+1)\n change(i-1,j)\n if(i==1 and j==1):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i-1,j)\n change(i+1,j)\n change(i,j-1)\n change(i,j+1)\n if(i==1 and j==2):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i-1,j)\n change(i+1,j)\n change(i,j-1)\n if(i==2 and j==0):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i-1,j)\n change(i,j+1)\n if(i==2 and j==1):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i-1,j)\n change(i,j-1)\n change(i,j+1)\n if(i==2 and j==2):\n if(given[i][j]%2!=0):\n change(i,j)\n change(i-1,j)\n change(i,j-1)\nfor i in range(len(lights)):\n c=lights[i]\n a=\"\"\n for j in range(len(c)):\n a+=str(c[j])\n print(a)"}, {"source_code": "Z=0,1,2\na=[map(int,raw_input().split())+[0]for _ in Z]+[[0]*4]\nfor i in Z:print''.join(`(1^a[i][j]^a[i-1][j]^a[i][j-1]^a[i+1][j]^a[i][j+1])%2`for j in Z)\n"}, {"source_code": "x11 , x12 , x13 = map(int,input().split())\nx21 , x22 , x23 = map(int,input().split())\nx31 , x32 , x33 = map(int,input().split())\nprint((\"1\" if (x11 + x12 + x21) % 2 == 0 else \"0\"),\n (\"1\" if (x11 + x12 + x13 + x22) % 2 == 0 else \"0\"),\n (\"1\" if (x12 + x13 + x23) % 2 == 0 else \"0\"),sep=\"\")\nprint((\"1\" if (x11 + x21 + x22 + x31) % 2 == 0 else \"0\"),\n (\"1\" if (x12 + x21 + x22 + x23 + x32) % 2 == 0 else \"0\"),\n (\"1\" if (x13 + x22 + x23 + x33) % 2 == 0 else \"0\"),sep=\"\")\nprint((\"1\" if (x21 + x31 + x32) % 2 == 0 else \"0\"),\n (\"1\" if (x22 + x31 + x32 + x33) % 2 == 0 else \"0\"),\n (\"1\" if(x23 + x32 + x33) % 2 == 0 else \"0\"),sep=\"\")\n"}, {"source_code": "m,n=[],[]\nfor i in range(3):\n a=list(map(int,input().split()))\n for j in range(3):\n if a[j]%2==1:\n m.append(i)\n n.append(j)\na=[[0,0,0],[0,0,0],[0,0,0]]\nfor i,j in zip(m,n):\n a[i][j]+=1 \n try:\n a[i+1][j]+=1 \n except:\n pass\n try:\n a[i][j+1]+=1 \n except:\n pass\n if j-1>=0:\n a[i][j-1]+=1 \n if i-1>=0:\n a[i-1][j]+=1 \nfor i in range(3):\n for j in range(3):\n if a[i][j]%2==0:\n print(1,end='')\n else:\n print(0,end='')\n print()"}, {"source_code": "def p(x):\n return int(x)%2\ndef t(x):\n return '0' if x=='1' else '1'\nl=[]\nx=[['1']*3 for i in range(3)]\nfor i in range(3):\n l.append(list(map(p,input().split())))\nfor i in range(3):\n for j in range(3):\n if l[i][j]:\n x[i][j]=t(x[i][j])\n if i!=0: x[i-1][j]=t(x[i-1][j])\n if j!=0: x[i][j-1]=t(x[i][j-1])\n if i!=2: x[i+1][j]=t(x[i+1][j])\n if j!=2: x[i][j+1]=t(x[i][j+1]) \nfor i in x:\n print(\"\".join(i))"}, {"source_code": "def p(x):\n return int(x)%2\ndef t(x):\n return '0' if x=='1' else '1'\nl=[]\nx=[['1']*3 for i in range(3)]\nfor i in range(3):\n l.append(list(map(p,input().split())))\nfor i in range(3):\n for j in range(3):\n if l[i][j]:\n x[i][j]=t(x[i][j])\n if i!=0: x[i-1][j]=t(x[i-1][j])\n if j!=0: x[i][j-1]=t(x[i][j-1])\n if i!=2: x[i+1][j]=t(x[i+1][j])\n if j!=2: x[i][j+1]=t(x[i][j+1]) \nfor i in x:\n print(\"\".join(i))"}, {"source_code": "import sys\n\ndef func(a1,a2,a3,b1,b2,b3,c1,c2,c3):\n x1=x2=x3=y1=y2=y3=z1=z2=z3= 1\n if a1%2 == 1:\n x1+=1\n x2+=1\n y1+=1\n if a2%2 == 1:\n x1+=1\n x2+=1\n x3+=1\n y2+=1\n if a3%2 == 1:\n x2+=1\n x3+=1\n y3+=1\n if b1%2 == 1:\n x1+=1\n y1+=1\n y2+=1\n z1+=1\n if b2%2 == 1:\n x2+=1\n y1+=1\n y2+=1\n y3+=1\n z2+=1\n if b3%2 == 1:\n x3+=1\n y2+=1\n y3+=1\n z3+=1\n if c1%2 == 1:\n y1+=1\n z1+=1\n z2+=1\n if c2%2 == 1:\n y2+=1\n z1+=1\n z2+=1\n z3+=1\n if c3%2 == 1:\n y3+=1\n z2+=1\n z3+=1\n list1=[]\n list1.append(x1)\n list1.append(x2)\n list1.append(x3)\n list1.append(y1)\n list1.append(y2)\n list1.append(y3)\n list1.append(z1)\n list1.append(z2)\n list1.append(z3)\n\n return list1\n\nif __name__ == '__main__':\n\n a1,a2,a3 = map(int,sys.stdin.readline().split())\n b1,b2,b3 = map(int,sys.stdin.readline().split())\n c1,c2,c3 = map(int,sys.stdin.readline().split())\n\n list = func(a1,a2,a3,b1,b2,b3,c1,c2,c3)\n\n print \"%d%d%d\" %(list[0]%2,list[1]%2,list[2]%2)\n print \"%d%d%d\" %(list[3]%2,list[4]%2,list[5]%2)\n print \"%d%d%d\" %(list[6]%2,list[7]%2,list[8]%2)\n"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[104]:\n\n\n# n = int(input())\n# line = list(map(int, input().split()))\nline = []\nfor _ in range(3):\n line.append(list(map(int, input().split())))\n\n\n# In[109]:\n\n\nmod_func = lambda x: [[i%2 for i in y] for y in x]\nline = mod_func(line)\nres = [[1 for _ in range(3)] for _ in range(3)]\n\nfor i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n res[i][j] = 1 if res[i][j] == 0 else 0\n try: \n res[i][j+1] = 1 if res[i][j+1] == 0 else 0\n except: None\n try:\n if j - 1 >= 0:\n res[i][j-1] = 1 if res[i][j-1] == 0 else 0\n except: None\n try: \n res[i+1][j] = 1 if res[i+1][j] == 0 else 0\n except: None\n try: \n if i - 1 >= 0:\n res[i-1][j] = 1 if res[i-1][j] == 0 else 0\n except: None\n\nfor i in range(len(res)):\n print(\"\".join(map(str, res[i])))\n\n \n\n"}, {"source_code": "move =[[1,0],[-1,0],[0,-1],[0,1]]\nli = [list(map(int,input().split())) for i in range(3)]\nli1 = [[1 for i in range(3)] for j in range(3)]\nfor i in range(len(li)):\n\tfor j in range(len(li[i])):\n\t\tif li[i][j]&1:\n\t\t\tli1[i][j] = 1-li1[i][j]\n\t\t\tfor k in range(len(move)):\n\t\t\t\tx = i + move[k][0]\n\t\t\t\ty = j + move[k][1]\n\t\t\t\tif x >= 0 and x <= 2 and y >= 0 and y <= 2:\n\t\t\t\t\tli1[x][y] = 1-li1[x][y]\n\t\t\t\t\t\nfor i in range(3):\n\tli1[i] = list(map(str,li1[i]))\n\ts = ''.join(li1[i])\n\tprint(s)\t \n\n"}, {"source_code": "#all around\nd=[(0,0),(1,0),(-1,0),(0,1),(0,-1)]\ndef f(m,i,j):\n ret=0\n for dx,dy in d:\n#ignore the out of range\n if i+dx>=0 and i+dx<=2 and j+dy>=0 and j+dy<=2:\n ret+=m[i+dx][j+dy]\n return ret\n\nm=[map(int, raw_input().split()) for _ in xrange(3)]\nans=[[0]*3 for _ in xrange(3)]\nfor i in xrange(3):\n for j in xrange(3):\n ans[i][j]=(f(m,i,j)+1)%2\nfor i in xrange(3):\n print ''.join(map(str,ans[i]))"}, {"source_code": "import sys\n\nctl = [[1 for x in range(3)] for x in range(3)]\n\nfor x in range(3):\n li = [int(z) for z in sys.stdin.readline().split()]\n for y in range(3):\n ctl[x][y] = (ctl[x][y] + li[y]) % 2\n if x-1 >= 0:\n ctl[x-1][y] = (ctl[x-1][y] + li[y]) % 2\n if y-1 >= 0:\n ctl[x][y-1] = (ctl[x][y-1] + li[y]) % 2\n if y+1 <= 2:\n ctl[x][y+1] = (ctl[x][y+1] + li[y]) % 2\n if x +1 <= 2:\n ctl[x+1][y] = (ctl[x+1][y] + li[y]) % 2\n\nfor x in range(3):\n print ''.join([str(y) for y in ctl[x]]) \n"}, {"source_code": "def toggle(val):\n if val == 1:\n return 0\n else:\n return 1\n\ntimed = [list(map(int, input().split())) for i in range(3)]\n\n#intialize = [[0 for i in range(3)] for i in range(3)]\n\ncurr_state = [[1 for i in range(3)] for i in range(3)]\n\ntemp = 0\n\nfor i in range(3):\n for j in range(3):\n if timed[i][j] > temp:\n temp = timed[i][j]\n\n\nfor i in range(timed[0][0]):\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][1] = toggle(curr_state[1][1])\n\nfor _ in range(timed[0][1]):\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2]) \n\nfor _ in range(timed[0][2]):\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n\nfor _ in range(timed[1][0]):\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1]) \n\nfor _ in range(timed[1][1]):\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[2][2] = toggle(curr_state[2][2]) \n\nfor _ in range(timed[1][2]):\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1])\n\nfor _ in range(timed[2][0]):\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n\nfor _ in range(timed[2][1]):\n curr_state[2][1] = toggle(curr_state[2][1])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n\nfor _ in range(timed[2][2]):\n curr_state[2][2] = toggle(curr_state[2][2])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n'''\nif (timed[0][0] >= temp and timed[0][0] > 0):\n #print(curr_state[0][1], curr_state[1][0])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[0][0] + timed[0][1] + timed[1][0] + timed[1][1]\n if sum1 & 1:\n curr_state[0][0] = 1\n else:\n curr_state[0][0] = 0\n #print(curr_state[0][1], curr_state[1][0])\nif (timed[0][1] >= temp and timed[0][1] > 0):\n #print(\"fck\")\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n sum1 = timed[0][1] + timed[0][0] + timed[0][2] + timed[1][1] + timed[1][0] + timed[1][2]\n if sum1 & 1:\n curr_state[0][1] = 1\n else:\n curr_state[0][1] = 0\nif (timed[0][2] >= temp and timed[0][2] > 0):\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[0][2] + timed[0][1] + timed[1][2] + timed[1][1]\n if sum1 & 1:\n curr_state[0][2] = 1\n else:\n curr_state[0][2] = 0\nif (timed[1][0] >= temp and timed[1][0] > 0):\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1])\n sum1 = timed[1][0] + timed[0][0] + timed[2][0] + timed[1][1] + timed[0][1] + timed[2][1]\n if sum1 & 1:\n curr_state[1][0] = 1\n else:\n curr_state[1][0] = 0\nif (timed[1][1] >= temp and timed[1][1] > 0):\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[2][2] = toggle(curr_state[2][2])\n sum1 = timed[0][0] + timed[0][1] + timed[0][2] + timed[1][0] + timed[1][1] + timed[1][2] + timed[2][0] + timed[2][1] + timed[2][2]\n if sum1 & 1:\n curr_state[1][1] = 1\n else:\n curr_state[1][1] = 0\nif (timed[1][2] >= temp and timed[1][2] > 0):\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1])\n sum1 = timed[1][2] + timed[0][2] + timed[1][1] + timed[2][2] + timed[0][1] + timed[2][1]\n if sum1 & 1:\n curr_state[1][2] = 1\n else:\n curr_state[1][2] = 0\nif (timed[2][0] >= temp and timed[2][0] > 0):\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[2][0] + timed[1][0] + timed[2][1] + timed[1][1]\n if sum1 & 1:\n curr_state[2][0] = 1\n else:\n curr_state[2][0] = 0\nif (timed[2][1] >= temp and timed[2][1] > 0):\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n sum1 = timed[2][1] + timed[1][1] + timed[2][0] + timed[2][2] + timed[1][0] + timed[1][2]\n if sum1 & 1:\n curr_state[2][1] = 1\n else:\n curr_state[2][1] = 0\nif (timed[2][2] >= temp and timed[2][2] > 0):\n #curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[2][2] + timed[1][2] + timed[2][1] + timed[1][1]\n if sum1 & 1:\n curr_state[2][2] = 1\n else:\n curr_state[2][2] = 0\n'''\nfor i in range(3):\n for j in range(3):\n print(curr_state[i][j], end='')\n print()"}, {"source_code": "a = [0]*9\n\nls = [int(i) for i in input().split(' ')]+[int(i) for i in input().split(' ')]+[int(i) for i in input().split(' ')]\n# print(ls)\nc = 0\nfor i in range(3):\n for j in range(3):\n a[c] += ls[c]\n if(i-1 >= 0):\n a[c] += ls[c-3] \n if(i+1 < 3):\n a[c] += ls[c+3] \n if(j-1 >= 0):\n a[c] += ls[c-1] \n if(j+1 < 3):\n a[c] += ls[c+1] \n # print(c, ' ', a[c])\n a[c] = 1 if(a[c] % 2 == 0) else 0\n print(a[c], end = '')\n c+=1\n print()"}, {"source_code": "def change(x):\n if x==0:\n return 1\n else:\n return 0\n \ndef fn(i,j,x):\n x[i][j]=change(x[i][j])\n if i>0:\n x[i-1][j]=change(x[i-1][j])\n if i<2:\n x[i+1][j]=change(x[i+1][j])\n if j>0:\n x[i][j-1]=change(x[i][j-1])\n if j<2:\n x[i][j+1]=change(x[i][j+1])\n return x\n\ntry:\n x=[[1,1,1],[1,1,1],[1,1,1]]\n for i in range(3):\n a=[int(i) for i in input().split()]\n for j in range(3):\n y=x\n if a[j]%2==1:\n fn(i,j,y)\n \n for i in y:\n print(*i,sep=\"\")\n \nexcept:\n pass"}, {"source_code": "\n\ndef main():\n\n matrix = []\n for _ in range(3):\n x = list(map(int,input().split()))\n matrix.append(x)\n\n a = [[1,1,1],[1,1,1],[1,1,1]]\n for i in range(3):\n for j in range(3):\n if matrix[i][j] != 0:\n for q in range(matrix[i][j]):\n a[i][j] = int(not a[i][j])\n if i + 1 < 3:\n a[i + 1][j] = int(not a[i + 1][j])\n elif i + 1 >= 3:\n pass\n if i - 1 >= 0:\n a[i - 1][j] = int(not a[i - 1][j])\n elif i - 1 < 0:\n pass\n if j + 1 < 3:\n a[i][j + 1] = int(not a[i][j + 1])\n elif j + 1 >= 3:\n pass\n if j - 1 >= 0:\n a[i][j - 1] = int(not a[i][j - 1])\n for w in range(3):\n print(''.join(map(str,a[w])))\n\nmain()"}, {"source_code": "ans = [[True for i in range(3)] for j in range(3)] \nip = []\nfor i in range(3):\n k = list(map(int, input().split()))\n ip.append(k)\nfor i in range(3):\n for j in range(3):\n if ip[i][j]%2==0:\n continue\n ans[i][j] = not ans[i][j]\n if j-1>-1:\n ans[i][j-1] = not ans[i][j-1]\n if j+1<3:\n ans[i][j+1] = not ans[i][j+1]\n if i+1<3:\n ans[i+1][j] = not ans[i+1][j]\n if i-1>-1:\n ans[i-1][j] = not ans[i-1][j]\n \nfor i in range(3):\n for j in range(3):\n if ans[i][j]:\n print(\"1\", end=\"\")\n else:\n print(\"0\", end=\"\")\n print()"}, {"source_code": "s1 = str(input())\ns2 = str(input())\ns3 = str(input())\n\nl1 = s1.split()\nl2 = s2.split()\nl3 = s3.split()\n\nv1 = int(l1[0]) + int(l1[1]) + int(l2[0])\nv2 = int(l1[0]) + int(l1[1]) + int(l1[2]) + int(l2[1]) \nv3 = int(l1[2]) + int(l1[1]) + int(l2[2])\nv4 = int(l1[0]) + int(l2[0]) + int(l3[0]) + int(l2[1]) \nv5 = int(l2[0]) + int(l2[1]) + int(l2[2]) + int(l1[1]) + int(l3[1])\nv6 = int(l3[2]) + int(l1[2]) + int(l2[2]) + int(l2[1]) \nv7 = int(l3[0]) + int(l3[1]) + int(l2[0])\nv8 = int(l3[2]) + int(l2[1]) + int(l3[1]) + int(l3[0]) \nv9 = int(l3[2]) + int(l3[1]) + int(l2[2])\n\nr1 = ''\nif v1 % 2 == 0:\n r1 += '1'\nelse:\n r1 += '0'\nif v2 % 2 == 0:\n r1 += '1'\nelse:\n r1 += '0'\nif v3 % 2 == 0:\n r1 += '1'\nelse:\n r1 += '0'\n\nr2 = ''\nif v4 % 2 == 0:\n r2 += '1'\nelse:\n r2 += '0'\nif v5 % 2 == 0:\n r2 += '1'\nelse:\n r2 += '0'\nif v6 % 2 == 0:\n r2 += '1'\nelse:\n r2 += '0'\n\nr3 = ''\nif v7 % 2 == 0:\n r3 += '1'\nelse:\n r3 += '0'\nif v8 % 2 == 0:\n r3 += '1'\nelse:\n r3 += '0'\nif v9 % 2 == 0:\n r3 += '1'\nelse:\n r3 += '0'\n\nprint(r1)\nprint(r2)\nprint(r3)"}, {"source_code": "# Lang: pypy3.6-v7.1.0-win32\\pypy3.exe\n# Problem Name: LightsOut\n# Problem Serial No: 275\n# Problem Type: A\n# Problem Url: https://codeforces.com/problemset/problem/275/A \n# Solution Generated at: 2019-10-19 17:03:55.288149 UTC\n\ni = int\ncin = input\nle = len\n\nin_mat = [[j for j in list(map(i, cin().split()))] for _ in range(3)]\n\nmatrix = [\n [1, 1, 1],\n [1, 1, 1],\n [1, 1, 1]\n]\n\nfor y in range(3):\n for r in range(3):\n toggle = in_mat[y][r]\n # if odd\n if toggle & 1:\n matrix[y][r] ^= 1\n\n if y + 1 in range(0, 3):\n matrix[y+1][r] ^= 1\n if y - 1 in range(0, 3):\n matrix[y-1][r] ^= 1\n\n if r + 1 in range(0, 3):\n matrix[y][r + 1] ^= 1\n if r - 1 in range(0, 3):\n matrix[y][r - 1] ^= 1\n\nfor h in [\"\".join(map(str, k)) for k in matrix]:\n print(h)\n# Accepted"}, {"source_code": "import sys\n\ndef func(a1,a2,a3,b1,b2,b3,c1,c2,c3):\n x1=x2=x3=y1=y2=y3=z1=z2=z3= 1\n if a1%2 == 1:\n x1+=1\n x2+=1\n y1+=1\n if a2%2 == 1:\n x1+=1\n x2+=1\n x3+=1\n y2+=1\n if a3%2 == 1:\n x2+=1\n x3+=1\n y3+=1\n if b1%2 == 1:\n x1+=1\n y1+=1\n y2+=1\n z1+=1\n if b2%2 == 1:\n x2+=1\n y1+=1\n y2+=1\n y3+=1\n z2+=1\n if b3%2 == 1:\n x3+=1\n y2+=1\n y3+=1\n z3+=1\n if c1%2 == 1:\n y1+=1\n z1+=1\n z2+=1\n if c2%2 == 1:\n y2+=1\n z1+=1\n z2+=1\n z3+=1\n if c3%2 == 1:\n y3+=1\n z2+=1\n z3+=1\n list1=[]\n list1.append(x1)\n list1.append(x2)\n list1.append(x3)\n list1.append(y1)\n list1.append(y2)\n list1.append(y3)\n list1.append(z1)\n list1.append(z2)\n list1.append(z3)\n\n return list1\n\nif __name__ == '__main__':\n\n a1,a2,a3 = map(int,sys.stdin.readline().split())\n b1,b2,b3 = map(int,sys.stdin.readline().split())\n c1,c2,c3 = map(int,sys.stdin.readline().split())\n\n list = func(a1,a2,a3,b1,b2,b3,c1,c2,c3)\n\n print \"%d%d%d\" %(list[0]%2,list[1]%2,list[2]%2)\n print \"%d%d%d\" %(list[3]%2,list[4]%2,list[5]%2)\n print \"%d%d%d\" %(list[6]%2,list[7]%2,list[8]%2)\n"}, {"source_code": "import sys\n\nlampen=[]\nfor n in range (3):\n hulp=[int(x) for x in sys.stdin.readline().split()]\n lampen.append(hulp)\n\naantal=[[0,0,0],[0,0,0],[0,0,0]]\n\naantal[0][0]=lampen[0][0]+lampen[0][1]+lampen[1][0]\naantal[0][1]=lampen[0][0]+lampen[0][1]+lampen[0][2]+lampen[1][1]\naantal[0][2]=lampen[0][2]+lampen[0][1]+lampen[1][2]\naantal[1][0]=lampen[0][0]+lampen[1][0]+lampen[2][0]+lampen[1][1]\naantal[1][1]=lampen[1][0]+lampen[1][1]+lampen[1][2]+lampen[0][1]+lampen[2][1]\naantal[1][2]=lampen[0][2]+lampen[1][1]+lampen[1][2]+lampen[2][2]\naantal[2][0]=lampen[1][0]+lampen[2][0]+lampen[2][1]\naantal[2][1]=lampen[2][0]+lampen[2][1]+lampen[2][2]+lampen[1][1]\naantal[2][2]=lampen[1][2]+lampen[2][2]+lampen[2][1]\n\n\nregel=''\nfor x in range (3):\n for y in range(3):\n if aantal[x][y]%2==0:\n regel+=('1')\n else:\n regel+=('0')\n print regel\n regel=''\n "}, {"source_code": "a=[]\nfor i in range(3):\n c=[int(x) for x in input().split()]\n a.append(c)\nprint(1 if (a[0][0] + a[0][1] + a[1][0]) % 2 == 0 else 0,end=\"\")\nprint(1 if (a[0][1] + a[0][0] + a[0][2] +a[1][1]) % 2 == 0 else 0,end=\"\")\nprint(1 if (a[0][2] + a[0][1] + a[1][2]) % 2 == 0 else 0,end=\"\")\nprint()\nprint(1 if (a[1][0] + a[0][0] + a[2][0]+a[1][1]) % 2 == 0 else 0,end=\"\")\nprint(1 if (a[1][1] + a[0][1] + a[1][0]+ a[1][2]+a[2][1]) % 2 == 0 else 0,end=\"\")\nprint(1 if (a[1][2] + a[0][2] + a[2][2]+a[1][1]) % 2 == 0 else 0,end=\"\")\nprint()\nprint(1 if (a[2][0] + a[1][0] + a[2][1]) % 2 == 0 else 0,end=\"\")\nprint(1 if (a[2][1] + a[2][0] + a[1][1]+ a[2][2]) % 2 == 0 else 0,end=\"\")\nprint(1 if (a[2][2] + a[1][2] + a[2][1]) % 2 == 0 else 0,end=\"\")\nprint()"}, {"source_code": "\"\"\"\n (0, 0) (0, 1) (0, 2)\n (1, 0) (1, 1) (1, 2)\n (2, 0) (2, 1) (2, 2)\n\"\"\"\nd = dict()\nans = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\nfor i in range(3):\n d[i] = list(map(int, input().split()))\nfor i in range(3):\n for j in range(3):\n if i == 0 and j == 0:\n s = d[0][1]+d[1][0]\n\n elif i == 0 and j == 1:\n s = d[0][0]+d[0][2]+d[1][1]\n\n elif i == 0 and j == 2:\n s = d[0][1]+d[1][2]\n\n elif i == 1 and j == 0:\n s = d[0][0]+d[1][1]+d[2][0]\n\n elif i == 1 and j == 1:\n s = d[0][1]+d[1][0]+d[2][1]+d[1][2]\n\n elif i == 1 and j == 2:\n s = d[0][2]+d[1][1]+d[2][2]\n\n elif i == 2 and j == 0:\n s = d[1][0]+d[2][1]\n\n elif i == 2 and j == 1:\n s = d[2][0]+d[1][1]+d[2][2]\n\n elif i == 2 and j == 2:\n s = d[2][1]+d[1][2]\n\n else:\n continue\n\n if s % 2 == 1:\n ans[i][j] = d[i][j] % 2\n else:\n ans[i][j] = 1-d[i][j] % 2\nfor i in range(3):\n for j in range(3):\n print(ans[i][j], end=\"\")\n print()"}, {"source_code": "res = list()\nres.append([0 , 0 , 0 , 0 , 0])\n\nfor i in range(1 , 4):\n res.append([0 , 0 , 0 , 0 , 0])\n res[i][1] , res[i][2] , res[i][3] = map(int , input().split())\nres.append([0 , 0 , 0 , 0 , 0])\n\nfor i in range(1 , 4):\n for j in range(1 , 4):\n print(1 - (res[i][j] + res[i-1][j] + res[i][j-1] + res[i+1][j] + res[i][j+1])%2 , end='')\n print()"}, {"source_code": "import sys\n\ninarray = []\noutarray = [[1 for j in range(3)] for i in range(3)]\nfor i in range(3):\n k = [int(x) for x in (sys.stdin.readline()).split()]\n for j in range(3):\n if(k[j] % 2 != 0):\n outarray[i][j] ^= 1\n if(i - 1 >= 0):\n outarray[i - 1][j] ^= 1\n if(j - 1 >= 0):\n outarray[i][j - 1] ^= 1\n if(i + 1 < 3):\n outarray[i + 1][j] ^= 1\n if(j + 1 < 3):\n outarray[i][j + 1] ^= 1\n \nfor i in range(3):\n print(\"\".join([str(x) for x in outarray[i]]))"}, {"source_code": "grid=[[1]*3 for _ in range(3)]\nnums=[[0]*3 for _ in range(3)]\nfor i in range(3):\n nums[i]=list(map(int,input().split()))\nfor j in range(3):\n for k in range(3):\n if nums[j][k]>0 and nums[j][k]%2!=0:\n grid[j][k]^=1\n if j==0:\n if k==0:\n grid[j+1][k]^=1\n grid[j][k+1]^=1\n elif k==2:\n grid[j][k-1]^=1\n grid[j+1][k]^=1\n else:\n grid[j+1][k]^=1\n grid[j][k-1]^=1\n grid[j][k+1]^=1\n if j==1:\n if k==0:\n grid[j+1][k]^=1\n grid[j-1][k]^=1\n grid[j][k+1]^=1\n elif k==1:\n grid[j][k+1]^=1\n grid[j][k-1]^=1\n grid[j+1][k]^=1\n grid[j-1][k]^=1\n else:\n grid[j+1][k]^=1\n grid[j-1][k]^=1\n grid[j][k-1]^=1\n if j==2:\n if k==0:\n grid[j][k+1]^=1\n grid[j-1][k]^=1\n elif k==1:\n grid[j][k-1]^=1\n grid[j][k+1]^=1\n grid[j-1][k]^=1\n else:\n grid[j][k-1]^=1\n grid[j-1][k]^=1\nfor t in range(3):\n for j in range(3):\n print(grid[t][j],end='')\n print(' ')"}, {"source_code": "light_turners = list()\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\n\nlights = [[True, True, True], [True, True, True], [True, True, True]]\n\n\ndef flip_adjacent(i, j):\n lights[i][j] = not lights[i][j]\n\n if i + 1 < 3:\n lights[i + 1][j] = not lights[i + 1][j]\n\n if j + 1 < 3:\n lights[i][j + 1] = not lights[i][j + 1]\n\n if i - 1 > -1:\n lights[i - 1][j] = not lights[i - 1][j]\n\n if j - 1 > - 1:\n lights[i][j - 1] = not lights[i][j - 1]\n\n\nfor i in range(3):\n for j in range(3):\n while light_turners[i][j] > 0:\n flip_adjacent(i, j)\n light_turners[i][j] -= 1\n\nfor i in range(3):\n for j in range(3):\n print(1 if lights[i][j] else 0, end='')\n print('')\n# 1476521911520"}, {"source_code": "import sys\ninput = sys.stdin.readline\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\n\nrows = []\nrows.append(inlt())\nrows.append(inlt())\nrows.append(inlt())\namount = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\nfor r in range(3):\n for c in range(3):\n cell = rows[r][c]\n amount[r][c] += cell\n if r - 1 >= 0:\n amount[r-1][c] += cell\n if r + 1 < 3:\n amount[r+1][c] += cell\n if c - 1 >= 0:\n amount[r][c - 1] += cell\n if c + 1 < 3:\n amount[r][c + 1] += cell\n\nfor row in range(3):\n for column in range(3):\n cell = amount[row][column]\n if cell % 2 == 0:\n amount[row][column] = 1\n else: amount[row][column] = 0\nfor row in amount:\n for cell in row:\n print(cell, end = \"\")\n print()"}, {"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\nd = [[0]*5 for _ in range(5)]\nfor i in range(3):\n t = li()\n for j in range(3):\n d[i + 1][j + 1] = t[j]\n\nfor i in range(1, 4):\n for j in range(1, 4):\n print(1 - (d[i][j] + d[i - 1][j] + d[i + 1][j] + d[i][j - 1] + d[i][j + 1]) % 2, end = '')\n print()"}, {"source_code": "def dfs(grid, x, y):\n if [x, y] == [0, 0]:\n toggle(x+1,y)\n toggle(x,y+1)\n \n if [x, y] == [0, 1]:\n toggle(x,y-1)\n toggle(x+1,y)\n toggle(x,y+1)\n\n if [x, y] == [0, 2]:\n toggle(x,y-1)\n toggle(x+1,y)\n\n if [x, y] == [1, 0]:\n toggle(x-1,y)\n toggle(x+1, y)\n toggle(x, y+1)\n\n if [x, y] == [1, 1]:\n toggle(x-1, y)\n toggle(x, y-1)\n toggle(x+1, y)\n toggle(x, y+1)\n\n if [x, y] == [1, 2]:\n toggle(x-1, y)\n toggle(x, y-1)\n toggle(x+1, y)\n\n if [x, y] == [2, 0]:\n toggle(x-1 , y)\n toggle(x, y+1)\n\n if [x, y] == [2, 1]:\n toggle(x-1, y)\n toggle(x, y-1)\n toggle(x, y+1)\n\n if [x, y] == [2, 2]:\n toggle(x-1 , y)\n toggle(x , y-1)\n\n toggle(x, y)\n\n\ndef toggle(x, y):\n if result[x][y] == 1:\n result[x][y] = 0\n else:\n result[x][y] = 1\n\n\ngrid = []\nresult = []\nfor i in range(3):\n grid.append([int(x) for x in input().split()])\n result.append([1 for x in range(3)])\n\n\nfor row in range(3):\n for col in range(3):\n if grid[row][col] == 0:\n continue\n \n val = grid[row][col]\n if val % 2 == 0:\n continue\n else:\n dfs(grid, row, col)\n\n\n# print(\"-----------------------------------------\")\nfor row in range(3):\n for col in range(3):\n print(result[row][col], end=\"\")\n print()\n\n\n"}, {"source_code": "aux, ma = [], []\n\nfor i in range(3):\n linha = map(int, raw_input().split())\n ma.append(linha)\n aux.append([0,0,0])\n\ndx = [0,0,1,-1,0]\ndy = [1,-1,0,0,0]\n\nfor i in range(3):\n for j in range(3):\n for x, y in zip(dx, dy):\n ni = i + x\n nj = j + y\n if(ni >= 0 and ni < 3 and nj >= 0 and nj < 3):\n aux[ni][nj] += ma[i][j]\n\n\nfor linha in aux:\n print ''.join(map(lambda x : str(1-(x % 2)), linha))\n \n"}, {"source_code": "l = []\nm = []\n\nfor x in range(0, 3) :\n\n l.append(map(int, raw_input().split()))\n\nfor x in range(0, 3) :\n\n for y in range(0, 3) :\n\n count = 0\n\n for p in range(0, 3) :\n\n for q in range(0, 3) :\n\n if ( x==p and abs(y-q)<=1 ) or ( y==q and abs(x-p)<=1 ) :\n\n count = count + l[p][q]\n\n if count % 2 == 0 :\n\n m.append('1')\n\n else :\n\n m.append('0')\n\nprint ''.join(m[:3]),\"\\n\",''.join(m[3:6]),\"\\n\",''.join(m[6:])"}, {"source_code": "def permitido(l,c):\n return l >= 0 and c >= 0 and l <= 2 and c <= 2\ndef muda_adjacentes(i,j):\n if grid[i][j] == \"0\":\n grid[i][j] = \"1\"\n else:\n grid[i][j] = \"0\"\n\n for m in range(4):\n l_destino = i + mv[m]\n c_destino = j + mh[m]\n\n if permitido(l_destino,c_destino):\n\n if grid[i + mv[m]][j + mh[m]] == \"0\":\n grid[i + mv[m]][j + mh[m]] = \"1\"\n\n else:\n grid[i + mv[m]][j + mh[m]] = \"0\"\n\n\nmv = [1,-1,0,0]\nmh = [0,0,1,-1]\n\napertos = []\n\nfor i in range(3):\n a,b,c = map(int,input().split())\n\n apertos.append([a,b,c])\n\ngrid = []\nfor i in range(3):\n grid.append(list(\"111\"))\n\nfor L in range(3):\n for C in range(3):\n if apertos[L][C] != 0:\n if apertos[L][C] % 2 != 0:\n muda_adjacentes(L,C)\n\nfor i in range(3):\n linha = \"\"\n for j in range(3):\n linha += grid[i][j]\n\n print(linha)\n"}, {"source_code": "def main():\n lights = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n\n for i in xrange(0, 3):\n r = map(int, raw_input().split())\n for j in xrange(0, 3):\n for k in xrange(0, 3):\n for l in xrange(0, 3):\n if (k == 0 or k == 2) and (l == 0 or l == 2):\n continue\n lights[i+k][j+l] += r[j]\n\n for i in xrange(1, 4):\n for j in xrange(1, 4):\n lights[i][j] = 0 if lights[i][j] & 1 else 1\n\n for i in xrange(1, 4):\n print ''.join(map(str, lights[i][1:4]))\n\nif __name__ == '__main__':\n main()"}, {"source_code": "mat=[]\nfor i in range(3):\n mat.append(list(map(int,input().rstrip().split())))\n\ntemp=[[1 for i in range(3)]for j in range(3)]\n \nfor i in range(3):\n for j in range(3):\n if mat[i][j]%2==1:\n temp[i][j]+=1\n if i+1<3:\n temp[i+1][j]+=1\n if j+1<3:\n temp[i][j+1]+=1\n if i-1>-1:\n temp[i-1][j]+=1\n if j-1>-1:\n temp[i][j-1]+=1\nfor i in range(3):\n for j in range(3):\n print(temp[i][j]%2,end=\"\")\n print()"}], "negative_code": [{"source_code": "import sys\ninput=sys.stdin.buffer.readline\n\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\narr3=list(map(int,input().split()))\nans=[]\ntemp=[]\ns=arr1[0]+arr1[1]+arr2[0]\ntemp.append(s)\ns=sum(arr1)+arr2[1]\ntemp.append(s)\ns=arr1[1]+arr1[2]+arr2[2]\ntemp.append(s)\ns=arr1[0]+arr2[0]+arr3[0]+arr2[1]\ntemp.append(s)\ns=arr1[1]+sum(arr2)+arr3[1]\ntemp.append(s)\ns=arr1[2]+arr2[2]+arr3[2]+arr2[1]\ntemp.append(s)\ns=arr2[0]+arr3[0]+arr3[1]\ntemp.append(s)\ns=sum(arr3)+arr2[1]\ntemp.append(s)\ns=arr2[2]+arr3[2]+arr3[1]\ntemp.append(s)\ncount=0\nfor i in range(9):\n\tcount+=1\n\tif temp[i]%2==0:\n\t\tprint(\"1\",end=' ')\n\telse:\n\t\tprint(\"0\",end=' ')\n\tif count%3==0:\n\t\tprint()\n"}, {"source_code": "import copy\n\nm = []\nfor i in range(3):\n\ta = list(map(int,input().split()))\n\tm.append(a)\nfor i in range(3):\n\tfor j in range(3):\n\t\tm[i][j] = m[i][j] % 2\nm1 = copy.deepcopy(m)\n\nind = 0\nfor i in m:\n\tif(i[0]==1):\n\t\tm1[ind][1]+=1\n\tif(i[1]==1):\n\t\tm1[ind][0]+=1\n\t\tm1[ind][2]+=1\n\tif(i[2]==1):\n\t\tm1[ind][1]+=1\n\tind+=1\nfor i in m:\n\tfor j in range(len(i)):\n\t\tind = m.index(i)\n\t\tif(ind==0 and i[j]==1):\n\t\t\tm1[ind+1][j]+=1\n\t\tif(ind==1 and i[j]==1):\n\t\t\tm1[ind-1][j]+=1\n\t\t\tm1[ind+1][j]+=1\n\t\tif(ind==2 and i[j]==1):\n\t\t\tm1[ind-1][j]+=1\n\nfor i in range(3):\n\tfor j in range(3):\n\t\tm1[i][j] = m1[i][j] % 2\n\t\tif(m1[i][j]==1):\n\t\t\tm1[i][j]='0'\n\t\telse:\n\t\t\tm1[i][j]='1'\n\nfor i in m1:\n\tst = \"\".join(i)\n\tprint(st)\n\t\n\n\n\t"}, {"source_code": "A=[]\nfor i in range(3):\n arr=list(map(int,input().split()))\n A.append(arr)\nans=[]\nres=[]\nfor i in range(3):\n \n for j in range(3):\n sum=A[i][j]\n \n if i==0:\n sum+=A[i+1][j]\n if j==0:\n sum+=A[i][j+1]\n elif j==1:\n sum+=A[i][j+1]\n sum+=A[i][j-1]\n else:\n sum+=A[i][j-1]\n \n \n elif i==1:\n sum+=A[i-1][j]\n sum+=A[i+1][j]\n if j==0:\n sum+=A[i][j+1]\n elif j==1:\n sum+=A[i][j-1]\n sum+=A[i][j+1]\n else:\n sum+=A[i][j-1]\n\n\n else:\n sum+=A[i-1][j]\n if j==0:\n sum+=A[i][j+1]\n elif j==1:\n sum+=A[i][j+1]\n sum+=A[i][j-1]\n else:\n sum+=A[i][j-1]\n \n\n\n\n if sum%2==0:\n res.append(1)\n else:\n res.append(0)\n #print(res)\n ans.append(res)\n res=[]\nfor i in ans:\n print(*i)\n"}, {"source_code": "i = 0\na = []\nr = [0]*9\nwhile(i<3):\n l = input().split(\" \")\n a = a + [int(l[0]),int(l[1]),int(l[2])]\n i = i + 1\nr[0] = a[0]+a[1] + a[3]\nr[1] = a[1]+a[0]+a[2]+a[4]\nr[2] = a[2]+a[1] + a[5]\nr[3] = a[3]+a[0]+ a[1]+ a[4]\nr[4] = a[4]+a[1] + a[3] + a[5] + a[7]\nr[5] = a[5]+a[2]+a[8]+a[4]\nr[6] = a[6]+a[3]+a[4]+a[7]\nr[7] = a[7]+a[4]+a[6]+a[8]\nr[8] = a[8]+a[4]+a[5]+a[7]\ni = 0\nwhile(i= 3 or adj[1] <= -1 or adj[1] >= 3: continue\n if res[adj[0]][adj[1]] == 0:\n res[adj[0]][adj[1]] = 1\n else:\n res[adj[0]][adj[1]] = 0\n\nprint(res)"}, {"source_code": "import sys\n\ndef func(a1,a2,a3,b1,b2,b3,c1,c2,c3):\n x1=x2=x3=y1=y2=y3=z1=z2=z3= 1\n if a1%2 == 1:\n x1+=1\n x2+=1\n y1+=1\n if a2%2 == 1:\n x1+=1\n x2+=1\n x3+=1\n y2+=1\n if a3%2 == 1:\n x2+=1\n x3+=1\n y3+=1\n if b1%2 == 1:\n x1+=1\n y1+=1\n y2+=1\n z1+=1\n if b2%2 == 1:\n x2+=1\n y1+=1\n y2+=1\n y3+=1\n z2+=1\n if b3%2 == 1:\n x3+=1\n y2+=1\n y3+=1\n z3+=1\n if c1%2 == 1:\n y1+=1\n z1+=1\n z2+=1\n if c2%2 == 1:\n y2+=1\n z1+=1\n z2+=1\n z3+=1\n if a1%2 == 1:\n y3+=1\n z2+=1\n z3+=1\n list1=[]\n list1.append(x1)\n list1.append(x2)\n list1.append(x3)\n list1.append(y1)\n list1.append(y2)\n list1.append(y3)\n list1.append(z1)\n list1.append(z2)\n list1.append(z3)\n\n return list1\n\nif __name__ == '__main__':\n\n a1,a2,a3 = map(int,sys.stdin.readline().split())\n b1,b2,b3 = map(int,sys.stdin.readline().split())\n c1,c2,c3 = map(int,sys.stdin.readline().split())\n\n list = func(a1,a2,a3,b1,b2,b3,c1,c2,c3)\n\n print \"%d%d%d\" %(list[0]%2,list[1]%2,list[2]%2)\n print \"%d%d%d\" %(list[3]%2,list[4]%2,list[5]%2)\n print \"%d%d%d\" %(list[6]%2,list[7]%2,list[8]%2)\n"}, {"source_code": "import sys\n\nlampen=[]\nfor n in range (3):\n hulp=[int(x) for x in sys.stdin.readline().split()]\n lampen.append(hulp)\n\naantal=[[0,0,0],[0,0,0],[0,0,0]]\n\nfor x in range(3):\n for y in range(3):\n for z in range(3):\n aantal[x][y]+=lampen[x][z]\n aantal[x][y]+=lampen[z][y]\n aantal[x][y]-=lampen[x][y]\nprint aantal\n\nregel=''\nfor x in range (3):\n for y in range(3):\n if aantal[x][y]%2==0:\n regel+=('1')\n else:\n regel+=('0')\n print regel\n regel=''\n "}, {"source_code": "grid=[]\nfor x in range(1,4): \n row=map(int,raw_input().split(\" \"))\n grid.append(row)\nrow1=grid[0]\nrow2=grid[1]\nrow3=grid[2]\nb_11=row1[0]+row1[1]+row2[0]\nb_12=row1[0]+row1[1]+row1[2]+row2[1]\nb_13=row1[1]+row1[2]+row2[2]\nb_21=row1[0]+row2[0]+row2[1]+row3[0]\nb_22=row1[1]+row3[1]+row2[0]+row2[1]+row2[2]\nb_23=row1[2]+row2[1]+row2[2]+row3[2]\nb_31=row2[0]+row3[0]+row3[1]\nb_32=row2[1]+row3[0]+row3[1]+row3[2]\nb_33=row2[2]+row3[1]+row3[2]\n#\nlist_s=[[b_11,b_12,b_13],[b_21,b_22,b_23],[b_31,b_32,b_33]]\nfor i in range(0,3):\n for j in range(0,3):\n if list_s[i][j]%2==0:\n list_s[i][j]=1\n else:\n list_s[i][j]=0\n list_ans=[\"b_11\"+\"b_12\"+\"b_13\",\"b_21\"+\"b_22\"+\"b_23\",\"b_31\"+\"b_32\"+\"b_33\"]\n print list_ans[i]\n\n \n \n "}, {"source_code": "\nres = [[0 for _ in range(3)]for i in range(3)]\nfor i in range(3):\n a = input().split(' ')\n for j in range(3):\n res[i] [j] = a[j]\n\nf = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n if int(res[i][j]) % 2 != 0:\n f[i][j] -= f[i][j]\n if i-1 >= 0:\n f[i-1][j] = 1- f[i-1][j]\n if i+1 < 3:\n f[i+1][j] = 1- f[i+1][j]\n if j-1 >= 0 :\n f[i][j-1] = 1- f[i][j-1]\n if j+1 < 3 :\n f[i][j+1] = 1- f[i][j+1]\n if i+1 <3 and j+1 < 3:\n f[i+1][j+1] = 1- f[i+1][j+1]\n if i-1 >=0 and j-1 >= 0:\n f[i-1][j-1] = 1- f[i-1][j-1]\n\nfor i in range(3):\n print(f[i])\n\n\n"}, {"source_code": "def toogle(s,i,j,moves):\n if moves%2 != 0:\n for x,y in (0,0),(1,1),(1,0),(1,-1),(0,-1),(-1,-1),(-1,0),(-1,1),(0,1):\n s[i+x][j+y] = int(not bool(s[i+x][j+y])) \n return s\n\ns = [[1]*5 for _ in range(5)]\nentrada = [list(map(int,input().split())) for _ in (1,2,3)]\n\nfor i in range(1,4):\n for j in range(1,4):\n s = toogle(s,i,j,entrada[i-1][j-1])\n\nfor i in 1,2,3:\n for j in 1,2,3:\n print(s[i][j],end='')\n print() \n"}, {"source_code": "import copy\n\nm = []\nfor i in range(3):\n\ta = list(map(int,input().split()))\n\tm.append(a)\nfor i in range(3):\n\tfor j in range(3):\n\t\tm[i][j] = m[i][j] % 2\nm1 = copy.deepcopy(m)\n\nind = 0\nfor i in m:\n\tif(i[0]==1):\n\t\tm1[ind][1]+=1\n\tif(i[1]==1):\n\t\tm1[ind][0]+=1\n\t\tm1[ind][2]+=1\n\tif(i[2]==1):\n\t\tm1[ind][1]+=1\n\tind+=1\nfor i in m:\n\tfor j in range(len(i)):\n\t\tind = m.index(i)\n\t\tif(ind==0 and i[j]==1):\n\t\t\tm1[ind+1][j]+=1\n\t\tif(ind==1 and i[j]==1):\n\t\t\tm1[ind-1][j]+=1\n\t\t\tm1[ind+1][j]+=1\n\t\tif(ind==2 and i[j]==1):\n\t\t\tm1[ind-1][j]+=1\n\nfor i in range(3):\n\tfor j in range(3):\n\t\tm1[i][j] = m1[i][j] % 2\n\t\tif(m1[i][j]==1):\n\t\t\tm1[i][j]='0'\n\t\telse:\n\t\t\tm1[i][j]='1'\n\nfor i in m1:\n\tst = \"\".join(i)\n\tprint(st)\n\t\n\n\n\t"}, {"source_code": "a,b,c=map(int,input().split())\ne,f,g=map(int,input().split())\nm,n,l=map(int,input().split())\np=1\nq=1\nr=1\ns=1\nt=1\nu=1\nv=1\nw=1\nx=1\nk=[p,q,r,s,t,u,v,w,x]\nj=[a,b,c,e,f,g,m,n,l]\ndef change(l,h):\n kas=l[h] \n if kas==1:\n l[h]=0\n if kas==0:\n l[h]=1\n \n\n\nfor d in range(3): \n if j[d]%2!=0 and j[d]!=0:\n change(k,d)\n if d!=2:\n change(k,d+1)\n if d!=0:\n change(k,d-1)\n #if d!=1:\n #change(k,4)\n change(k,d+3)\n if d==1:\n change(k,d+2)\n change(k,d+4)\n \nfor d in range(3,6): \n if j[d]%2!=0 and j[d]!=0:\n change(k,d)\n if d!=5:\n change(k,d+1)\n \n if d!=3:\n change(k,d-1)\n change(k,d+3)\n change(k,d-3)\n if d==4:\n change(k,d+2)\n change(k,d-4)\n change(k,d+4)\n change(k,d-2)\n if d==3:\n change(k,d+4)\n change(k,d-2)\n if d==5:\n change(k,d-4)\n change(k,d+2)\n \nfor d in range(6,9): \n if j[d]%2!=0 and j[d]!=0:\n change(k,d)\n if d!=8:\n change(k,d+1)\n if d!=6:\n change(k,d-1)\n #if d!=7:\n #change(k,4)\n change(k,d-3)\n if d==7:\n change(k,d-2)\n change(k,d-4)\nS0=str(k[0])\nS1=str(k[1])\nS2=str(k[2]) \nS3=str(k[3])\nS4=str(k[4])\nS6=str(k[6])\nS5=str(k[5])\nS7=str(k[7])\nS8=str(k[8])\n\nprint(S0+S1+S2)\nprint(S3+S4+S5)\nprint(S6+S7+S8)\n "}, {"source_code": "a=[[x&1 for x in map(int,raw_input().split(' '))] for _ in range(3)]\nb=[[1,1,1,1,1] for _ in range(5)]\nfor i in range(3):\n for j in range(3):\n if a[i][j]:\n b[i+1][j+1]=not b[i+1][j+1]\n b[i+2][j+1]=not b[i+2][j+1]\n b[i][j+1]=not b[i][j+1]\n b[i+1][j+2]=not b[i+1][j+2]\n b[i+1][j]=not b[i+1][j]\nfor i in range(3):\n for j in range(3):\n print int(b[i+1][j+1]),\n print"}, {"source_code": "inputGot = []\nfor i in range(3):\n got = input().split(\" \")\n got = [int(i) for i in got]\n inputGot.append(got)\n\nlight = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n\n\ndef co_ord(i, j):\n set = []\n for i1 in range(i - 1, i + 2):\n for j1 in range(j - 1, j + 2):\n if 0 <= i1 < 3 and 0 <= j1 < 3:\n set.append((i1, j1))\n if (i == 0 and j == 0) or (i == 0 and j == 2) or (i == 2 and j == 0) or (i ==2 and j == 2):\n set.remove((1, 1))\n if i == 1 and j == 1:\n set.remove((0, 0))\n set.remove((0, 2))\n set.remove((2, 0))\n set.remove((2, 2))\n return set\n\n\nfor i in range(3):\n for j in range(3):\n if(inputGot[i][j] != 0 and inputGot[i][j]%2 != 0):\n # print(inputGot[i][j], \" at \", i , \",\", j)\n co_ords = co_ord(i, j)\n for i2, j2 in co_ords:\n light[i2][j2] = int(not bool(light[i2][j2]))\n # for element in light:\n # print(*element, sep='')\n\nfor element in light:\n print(*element, sep='')"}, {"source_code": "M = [[int(i) for i in input().split()] for j in range(3)]\n\nfor i in range(3):\n for j in range(3):\n M[i][j] = M[i][j] % 2\n\nres = [[1 for x in range(3)] for y in range(3)]\n\nadj1 = [0, -1, 0, 0, 1]\nadj2 = [0, 0, -1, 1, 0]\nfor i in range(3):\n for j in range(3):\n if M[i][j] == 1:\n for k in range(5):\n adj = [i+adj1[k], j+adj2[k]]\n if adj[0] <= -1 or adj[0] >= 3 or adj[1] <= -1 or adj[1] >= 3: continue\n if res[adj[0]][adj[1]] == 0:\n res[adj[0]][adj[1]] = 1\n else:\n res[adj[0]][adj[1]] = 0\n\nprint(res)"}, {"source_code": "from sys import stdin\ndef main():\n\tf1=[1,1,1]\n\tf2=[1,1,1]\n\tf3=[1,1,1]\n\ta=str(input()).split()\n\tb=str(input()).split()\n\tc=str(input()).split()\n\tfor i in range (3):\n\t\ta[i]=int(a[i])\n\t\tb[i]=int(b[i])\n\t\tc[i]=int(c[i])\n\tif (a[0]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\tif (a[1]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\tif (a[2]%2!=0):\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\tif (b[0]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\tif (b[1]%2!=0):\n\t\tif (f1[0]==0):\n\t\t\tf1[0]=1\n\t\telse:\n\t\t\tf1[0]=0\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\tif (b[2]%2!=0):\n\t\tif (f1[1]==0):\n\t\t\tf1[1]=1\n\t\telse:\n\t\t\tf1[1]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f1[2]==0):\n\t\t\tf1[2]=1\n\t\telse:\n\t\t\tf1[2]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\tif (c[0]%2!=0):\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\tif (c[1]%2!=0):\n\t\tif (f2[0]==0):\n\t\t\tf2[0]=1\n\t\telse:\n\t\t\tf2[0]=0\n\t\tif (f3[0]==0):\n\t\t\tf3[0]=1\n\t\telse:\n\t\t\tf3[0]=0\n\t\tif (f2[1]==0):\n\t\t\tf2[1]=1\n\t\telse:\n\t\t\tf2[1]=0\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\tif (c[2]%2!=0):\n\t\tif (f3[1]==0):\n\t\t\tf3[1]=1\n\t\telse:\n\t\t\tf3[1]=0\n\t\tif (f2[2]==0):\n\t\t\tf2[2]=1\n\t\telse:\n\t\t\tf2[2]=0\n\t\tif (f3[2]==0):\n\t\t\tf3[2]=1\n\t\telse:\n\t\t\tf3[2]=0\n\td=str(f1[0])\n\te=str(f1[1])\n\tf=str(f1[2])\n\tg=str(f2[0])\n\th=str(f2[1])\n\ti=str(f2[2])\n\tj=str(f3[0])\n\tk=str(f3[1])\n\tl=str(f3[2])\n\tprint (d+e+f)\n\tprint(g+h+i)\n\tprint(j+k+l)\nmain()\n\n\n"}, {"source_code": "x=[[0,1,3],[0,1,2,4],[1,2,5],[0,3,4,6],[1,3,4,5,7],[2,4,5,8],[3,6,7],[4,6,7,8],[5,7,8]]\nans=[1,1,1,1,1,1,1,1,1]\ny=[]\nfor i in range(3):\n z=list(map(int, input().split()))\n z[0],z[1],z[2]=z[0]%2,z[1]%2,z[2]%2\n y.extend(z)\nfor i in range(9):\n if(y[i]==1):\n for k in x[i]:\n ans[k]=(ans[k]+1)%2\nprint(ans[0],ans[1],ans[2])\nprint(ans[3],ans[4],ans[5])\nprint(ans[6],ans[7],ans[8])"}, {"source_code": "dp = [list(map(int, input().split())) for i in range(3)]\n\na1 = (dp[0][0] + dp[0][1] + dp[1][0]+1)%2\na2 = (dp[0][1] + dp[0][0] + dp[0][2] + 1 + dp[1][1])%2\na3 = (dp[0][2] + dp[0][1] + dp[1][2] + 1)%2\na4 = (dp[1][0] + dp[0][0] + dp[1][1] + 1 + dp[2][0])%2\na5 = (dp[1][1] + dp[1][0] + dp[0][1] + 1 + dp[1][2] + dp[2][1])%2\na6 = (dp[1][2] + dp[1][1] + dp[0][2] + 1 + dp[2][2])%2\na7 = (dp[2][0] + dp[1][0] + dp[2][1] + 1)%2\na8 = (dp[2][1] + dp[2][0] + dp[2][2] + 1 + dp[1][1])%2\na9 = (dp[2][2] + dp[2][1] + dp[1][2] + 1)%2\n \n\nprint(a1,a2,a3)\nprint(a4,a5,a6)\nprint(a7,a8,a9)\n"}, {"source_code": "import sys\n\nlampen=[]\nfor n in range (3):\n hulp=[int(x) for x in sys.stdin.readline().split()]\n lampen.append(hulp)\n\naantal=[[0,0,0],[0,0,0],[0,0,0]]\n\naantal[0][0]=lampen[0][0]+lampen[0][1]+lampen[1][0]\naantal[0][1]=lampen[0][0]+lampen[0][1]+lampen[0][2]+lampen[1][1]\naantal[0][2]=lampen[0][2]+lampen[0][1]+lampen[1][2]\naantal[1][0]=lampen[0][0]+lampen[1][0]+lampen[2][0]+lampen[1][1]\naantal[1][1]=lampen[1][0]+lampen[1][1]+lampen[1][1]+lampen[0][1]+lampen[2][1]\naantal[1][2]=lampen[0][2]+lampen[1][1]+lampen[1][2]+lampen[2][2]\naantal[2][0]=lampen[1][0]+lampen[2][0]+lampen[2][1]\naantal[2][1]=lampen[2][0]+lampen[2][1]+lampen[2][2]+lampen[1][1]\naantal[2][2]=lampen[1][2]+lampen[2][2]+lampen[2][1]\n\n\nregel=''\nfor x in range (3):\n for y in range(3):\n if aantal[x][y]%2==0:\n regel+=('1')\n else:\n regel+=('0')\n print regel\n regel=''\n "}, {"source_code": "# import sys\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\n\nmatrix = []\n\ndef toggle(key):\n if key == 0:\n return 1\n else:\n return 0\n\nfor _ in range(3):\n row = list(map(int, input().split(\" \")))\n matrix.append(row)\n\ncpy_matrix = [[ 1 for i in range(3) ] for j in range(3) ]\n\nfor i in range(3):\n for j in range(3):\n ways = [\n [i+1, j],\n [i-1, j],\n [i, j+1],\n [i, j-1],\n [i+1, j+1],\n [i+1, j-1],\n [i-1, j+1],\n [i-1, j-1],\n ]\n\n if matrix[i][j]%2 != 0:\n for key, value in ways:\n if 0<= key < 3 and 0 <= value < 3:\n cpy_matrix[key][value] = toggle(cpy_matrix[key][value])\n cpy_matrix[i][j] = toggle(cpy_matrix[i][j])\n\n\nfor i in range(3):\n for j in range(3):\n print(cpy_matrix[i][j],end='')\n print()\n\n\n\n"}, {"source_code": "\nres = [[0 for _ in range(3)]for i in range(3)]\nfor i in range(3):\n a = input().split(' ')\n for j in range(3):\n res[i] [j] = a[j]\n\nf = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n if int(res[i][j]) % 2 != 0:\n f[i][j] -= f[i][j]\n if i-1 >= 0:\n f[i-1][j] = 1- f[i-1][j]\n if i+1 < 3:\n f[i+1][j] = 1- f[i+1][j]\n if j-1 >= 0 :\n f[i][j-1] = 1- f[i][j-1]\n if j+1 < 3 :\n f[i][j+1] = 1- f[i][j+1]\n if i+1 <3 and j+1 < 3:\n f[i+1][j+1] = 1- f[i+1][j+1]\n if i-1 >=0 and j-1 >= 0:\n f[i-1][j-1] = 1- f[i-1][j-1]\n\nfor i in range(3):\n print(str(f[i]))\n\n\n"}, {"source_code": "import sys\nimport math\n\nB = []\nA = [[1, 1, 1],\n [1, 1, 1],\n [1, 1, 1]]\n \nfor i in range(3):\n s = map( int, sys.stdin.readline().split() )\n B.append(s)\n \nfor i in range(3):\n for j in range(3):\n if B[i][j] % 2 != 0:\n A[i][j] = (A[i][j] + 1) % 2\n if i - 1 > -1:\n A[i - 1][j] = (A[i - 1][j] + 1) % 2\n if j + 1 < 3:\n A[i][j + 1] = (A[i][j + 1] + 1) % 2\n if i + 1 < 3:\n A[i + 1][j] = (A[i + 1][j] + 1) % 2\n if j - 1 > -1:\n A[i][j - 1] = (A[i][j - 1] + 1) % 2\n\nfor i in range(3):\n for j in range(3):\n print A[i][j],\n print '\\n',"}, {"source_code": "a=[[x&1 for x in map(int,raw_input().split(' '))] for _ in range(3)]\nb=[[1,1,1,1,1] for _ in range(5)]\nfor i in range(3):\n for j in range(3):\n if a[i][j]:\n b[i+1][j+1]=not b[i+1][j+1]\n b[i+2][j+1]=not b[i+2][j+1]\n b[i][j+1]=not b[i][j+1]\n b[i+1][j+2]=not b[i+1][j+2]\n b[i+1][j]=not b[i+1][j]\nfor i in range(3):\n for j in range(3):\n print int(b[i+1][j+1]),\n print"}, {"source_code": "t = [list(map(int, input().split())) for i in range(3)]\np = [[1] * 5 for i in range(5)]\nfor i in range(3):\n for j in range(3):\n if t[i][j] % 2 == 1:\n for u in range(i, i + 3):\n for v in range(j, j + 3):\n p[u][v] += 1\nfor i in range(1, 4):\n print(''.join(str(p[i][j] % 2) for j in range(1, 4)))"}, {"source_code": "arr_i = [list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))]\nprint(arr_i)\n\narr = [[1 for x in range(3)] for y in range(3)]\nprint(arr)\narr[0][0] = (arr_i[0][0] + arr_i[0][1] + arr_i[1][0] + 1) % 2\narr[0][1] = (arr_i[0][0] + arr_i[0][1] + arr_i[0][2] + arr_i[1][1] + 1) % 2\narr[0][2] = (arr_i[0][1] + arr_i[0][2] + arr_i[1][2] + 1) % 2\narr[1][0] = (arr_i[0][0] + arr_i[1][0] + arr_i[1][1] + arr_i[2][0] + 1) % 2\narr[1][1] = (arr_i[0][1] + arr_i[1][0] + arr_i[1][1] + arr_i[1][2] + arr_i[2][1] + 1) % 2\narr[1][2] = (arr_i[0][2] + arr_i[1][1] + arr_i[1][2] + arr_i[2][2] + 1) % 2\narr[2][0] = (arr_i[1][0] + arr_i[2][0] + arr_i[2][1] + 1) % 2\narr[2][1] = (arr_i[1][1] + arr_i[2][0] + arr_i[2][1] + arr_i[2][2] + 1) % 2\narr[2][2] = (arr_i[1][2] + arr_i[2][1] + arr_i[2][2] + 1) % 2\nprint(arr)\n\nfor i in range(3):\n for j in range(3):\n print(arr[i][j], end=\"\")\n print()"}, {"source_code": "def tog(ans,i,j):\n if ans[i][j]=='n':\n ans[i][j]=0 #OFF\n elif ans[i][j]==0: #OFF\n ans[i][j]=1 #ON\n else:#ON\n ans[i][j]=0\n\nl = []\nfor i in range(3):\n row = list(map(int,input().split()))\n for j in range(3):\n if row[j]%2==0:\n row[j]=0\n else:\n row[j]=1\n l.append(row)\nans = [['n','n','n'] for i in range(3) ]\nfor i in range(3):\n for j in range(3):\n if l[i][j]==1:\n tog(ans,i,j)\n if (i+1)<3: \n tog(ans,i+1,j)\n #print(ans[i][j])\n if (i-1)>-1: \n tog(ans,i-1,j)\n if (j+1)<3: \n tog(ans,i,j+1)\n if (j-1)>-1: \n tog(ans,i,j-1)\n else:\n if ans[i][j]=='n':\n ans[i][j]=1\nfor row in ans:\n print(*row)\n\n \n \n\n"}, {"source_code": "m = [list(map(int, input().split())) for i in range(3)]\nres = [[1 for j in range(3)] for i in range(3)]\n\nd = [(1, 0), (-1, 0), (0, 1), (0, -1)]\n\nfor i in range(3):\n for j in range(3):\n if m[i][j] % 2:\n res[i][j] = (res[i][j] + 1) % 2\n for x, y in d:\n dx = i + x\n dy = j + y\n if dx >= 0 and dx < 3 and dy >= 0 and dy < 3:\n res[dx][dy] = (res[dx][dy] + 1) % 2\nfor row in res:\n row_str = map(str, row)\n print(\" \".join(row_str))\n "}, {"source_code": "mat=[]\nfor i in range(3):\n mat.append(list(map(int,input().rstrip().split())))\ntemp=[[1 for i in range(3)]for j in range(3)]\n \nfor i in range(3):\n for j in range(3):\n if mat[i][j]%2==1:\n temp[i][j]=0\n if i+1<3:\n temp[i+1][j]+=1\n if j+1<3:\n temp[i][j+1]+=1\n if i-1>-1:\n temp[i-1][j]+=1\n if j-1>-1:\n temp[i][j-1]+=1\nfor i in range(3):\n for j in range(3):\n print(temp[i][j]%2,end=\"\")\n print()"}, {"source_code": "def change(x):\n if x==0:\n return 1\n else:\n return 0\n \ndef fn(i,j,x):\n x[i][j]=change(x[i][j])\n if i>0:\n x[i-1][j]=change(x[i-1][j])\n if i<2:\n x[i+1][j]=change(x[i+1][j])\n if j>0:\n x[i][j-1]=change(x[i][j-1])\n if j<2:\n x[i][j+1]=change(x[i][j+1])\n return x\n\ntry:\n x=[[1,1,1],[1,1,1],[1,1,1]]\n for i in range(3):\n a=[int(i) for i in input().split()]\n for j in range(3):\n if a[j]%2==1:\n y=x\n fn(i,j,y)\n \n for i in y:\n print(*i,sep=\"\")\n \nexcept:\n pass"}, {"source_code": "lights = []\n\nfor i in range(3):\n lights += list(map(int, input().split()))\nis_on = [1]*9\n\nneighbors = [[1,3],[0,2,4],[1,5],[0,4,6],[1,3,5,7],[2,4,8],[3,7],[4,6,8],[5,7]]\n\nfor i in range(9):\n is_on[i] += lights[i]\n for n in neighbors[i]:\n is_on[i] += lights[n]\n print(is_on[i])\n is_on[i] %= 2\n is_on[i] = str(is_on[i])\nprint(''.join(is_on[0:3]) + \"\\n\" + ''.join(is_on[3:6]) + \"\\n\" +''.join(is_on[6:9]))"}, {"source_code": "arran = []\narr = [[1,1,1],[1,1,1],[1,1,1]]\nlst=[1,0]*5\nzz=zo=zt=oz=oo=ot=tz=to=tt=0\nfor i in range(3):\n arran.append(list(map(int,input().split())))\nif arran[0][0]%2!=0:\n zz += 1\n zo += 1\n oz += 1\n arr[0][0] = lst[zz]\n arr[0][1] = lst[zo]\n arr[1][0] = lst[oz]\nif arran[0][1]%2!=0:\n zz += 1\n zo += 1\n oo += 1\n zt += 1\n arr[0][0] = lst[zz]\n arr[0][1] = lst[zo]\n arr[1][1] = lst[oo]\n arr[0][2] = lst[zt]\nif arran[0][2]%2!=0:\n zo += 1\n zt += 1\n ot += 1\n arr[0][1] = lst[zo]\n arr[0][2] = lst[zt]\n arr[1][2] = lst[ot]\nif arran[1][0]%2!=0:\n zz += 1\n oo += 1\n oz += 1\n tz += 1\n arr[0][0] = lst[zz]\n arr[1][1] = lst[oo]\n arr[2][0] = lst[tz]\n arr[1][0] = lst[oz]\nif arran[1][1]%2!=0:\n oz += 1\n oo += 1\n zo += 1\n to += 1\n ot += 1\n arr[1][0] = lst[oz]\n arr[0][0] = lst[oo]\n arr[0][1] = lst[zo]\n arr[2][0] = lst[tz]\n arr[0][2] = lst[zt]\nif arran[1][2]%2!=0:\n zt += 1\n ot += 1\n oo += 1\n tt += 1\n arr[0][2] = lst[zz]\n arr[1][2] = lst[zo]\n arr[1][1] = lst[oz]\n arr[2][2] = lst[tt]\nif arran[2][0]%2!=0:\n oz += 1\n tz += 1\n to += 1\n arr[1][0] = lst[oz]\n arr[2][0] = lst[tz]\n arr[2][1] = lst[to]\nif arran[2][1]%2!=0:\n tz += 1\n to += 1\n oo += 1\n tt += 1\n arr[2][0] = lst[tz]\n arr[2][0] = lst[tz]\n arr[1][1] = lst[oo]\n arr[2][2] = lst[tt]\nif arran[2][2]%2!=0:\n ot += 1\n tt += 1\n to += 1\n arr[1][2] = lst[ot]\n arr[2][2] = lst[tt]\n arr[2][1] = lst[to]\nfor i in arr:\n print(''.join(list(map(str,i))))\n \n"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[72]:\n\n\n# n = int(input())\n# line = list(map(int, input().split()))\nline = []\nfor _ in range(3):\n line.append(list(map(int, input().split())))\n\n\n# In[73]:\n\n\nmod_func = lambda x: [[i%2 for i in y] for y in x]\nline = mod_func(line)\nres = [[1 for _ in range(3)] for _ in range(3)]\n\nfor i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n res[i][j] = 0 if res[i][j] == 0 else 0\n try: res[i][j+1] = 1 if res[i][j+1] == 0 else 0\n except: None\n try:\n if j - 1 > 0:\n res[i][j-1] = 1 if res[i][j-1] == 0 else 0\n except: None\n try: res[i+1][j] = 1 if res[i+1][j] == 0 else 0\n except: None\n try: \n if i - 1 > 0:\n res[i-1][j] = 1 if res[i-1][j] == 0 else 0\n except: None\n \nprint(res)\n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "matrix = [\n [1,1,1],\n [1,1,1],\n [1,1,1]\n]\n\ninp = []\nfor i in range(3):\n inp.append( list(map(int, input().split())) )\n\nfor row in range(3):\n for col in range(3):\n if inp[row][col] % 2 == 0:\n continue\n else:\n if row > 0:\n matrix[row-1][col] *= -1\n if row < 2:\n matrix[row+1][col] *= -1\n if col < 2:\n matrix[row][col+1] *= -1\n if col > 0:\n matrix[row][col-1] *= -1\n matrix[row][col] *= -1\n\nfor row in matrix:\n res = [ 1 if i > 0 else 0 for i in row]\n print(' '.join(map(str,res)))"}, {"source_code": "import sys\n\ndef func(a1,a2,a3,b1,b2,b3,c1,c2,c3):\n x1=x2=x3=y1=y2=y3=z1=z2=z3= 1\n if a1%2 == 1:\n x1+=1\n x2+=1\n y1+=1\n if a2%2 == 1:\n x1+=1\n x2+=1\n x3+=1\n y2+=1\n if a3%2 == 1:\n x2+=1\n x3+=1\n y3+=1\n if b1%2 == 1:\n x1+=1\n y1+=1\n y2+=1\n z1+=1\n if b2%2 == 1:\n x2+=1\n y1+=1\n y2+=1\n y3+=1\n z2+=1\n if b3%2 == 1:\n x3+=1\n y2+=1\n y3+=1\n z3+=1\n if c1%2 == 1:\n y1+=1\n z1+=1\n z2+=1\n if c2%2 == 1:\n y2+=1\n z1+=1\n z2+=1\n z3+=1\n if a1%2 == 1:\n y3+=1\n z2+=1\n z3+=1\n list1=[]\n list1.append(x1)\n list1.append(x2)\n list1.append(x3)\n list1.append(y1)\n list1.append(y2)\n list1.append(y3)\n list1.append(z1)\n list1.append(z2)\n list1.append(z3)\n\n return list1\n\nif __name__ == '__main__':\n\n a1,a2,a3 = map(int,sys.stdin.readline().split())\n b1,b2,b3 = map(int,sys.stdin.readline().split())\n c1,c2,c3 = map(int,sys.stdin.readline().split())\n\n list = func(a1,a2,a3,b1,b2,b3,c1,c2,c3)\n\n print \"%d%d%d\" %(list[0]%2,list[1]%2,list[2]%2)\n print \"%d%d%d\" %(list[3]%2,list[4]%2,list[5]%2)\n print \"%d%d%d\" %(list[6]%2,list[7]%2,list[8]%2)\n"}, {"source_code": "lights = []\n\nfor i in range(3):\n lights += list(map(int, input().split()))\nis_on = [1]*9\n\nneighbors = [[1,3],[0,2,4],[1,5],[0,4,6],[1,3,5,7],[2,4,8],[3,7],[4,6,8],[5,7]]\n\nfor i in range(9):\n is_on[i] += lights[i]\n for n in neighbors[i]:\n is_on[i] += lights[n]\n is_on[i] %= 2\n is_on[i] = str(is_on[i])\nfor i in range(3):\n print(''.join(is_on[i:i+3]))"}, {"source_code": "def toggle(val):\n if val == 1:\n return 0\n else:\n return 1\n\ntimed = [list(map(int, input().split())) for i in range(3)]\n\n#intialize = [[0 for i in range(3)] for i in range(3)]\n\ncurr_state = [[1 for i in range(3)] for i in range(3)]\n\ntemp = 0\n\nfor i in range(3):\n for j in range(3):\n if timed[i][j] > temp:\n temp = timed[i][j]\n\n\nfor i in range(timed[0][0]):\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][1] = toggle(curr_state[1][1])\n\nfor _ in range(timed[0][1]):\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2]) \n\nfor _ in range(timed[0][2]):\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n\nfor _ in range(timed[1][0]):\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1]) \n\nfor _ in range(timed[1][1]):\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[2][2] = toggle(curr_state[2][2]) \n\nfor _ in range(timed[1][2]):\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1])\n\nfor _ in range(timed[2][0]):\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n\nfor _ in range(timed[2][1]):\n curr_state[2][1] = toggle(curr_state[2][1])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n\nfor _ in range(timed[2][2]):\n curr_state[2][2] = toggle(curr_state[2][2])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n'''\nif (timed[0][0] >= temp and timed[0][0] > 0):\n #print(curr_state[0][1], curr_state[1][0])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[0][0] + timed[0][1] + timed[1][0] + timed[1][1]\n if sum1 & 1:\n curr_state[0][0] = 1\n else:\n curr_state[0][0] = 0\n #print(curr_state[0][1], curr_state[1][0])\nif (timed[0][1] >= temp and timed[0][1] > 0):\n #print(\"fck\")\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n sum1 = timed[0][1] + timed[0][0] + timed[0][2] + timed[1][1] + timed[1][0] + timed[1][2]\n if sum1 & 1:\n curr_state[0][1] = 1\n else:\n curr_state[0][1] = 0\nif (timed[0][2] >= temp and timed[0][2] > 0):\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[0][2] + timed[0][1] + timed[1][2] + timed[1][1]\n if sum1 & 1:\n curr_state[0][2] = 1\n else:\n curr_state[0][2] = 0\nif (timed[1][0] >= temp and timed[1][0] > 0):\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1])\n sum1 = timed[1][0] + timed[0][0] + timed[2][0] + timed[1][1] + timed[0][1] + timed[2][1]\n if sum1 & 1:\n curr_state[1][0] = 1\n else:\n curr_state[1][0] = 0\nif (timed[1][1] >= temp and timed[1][1] > 0):\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[0][0] = toggle(curr_state[0][0])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[2][2] = toggle(curr_state[2][2])\n sum1 = timed[0][0] + timed[0][1] + timed[0][2] + timed[1][0] + timed[1][1] + timed[1][2] + timed[2][0] + timed[2][1] + timed[2][2]\n if sum1 & 1:\n curr_state[1][1] = 1\n else:\n curr_state[1][1] = 0\nif (timed[1][2] >= temp and timed[1][2] > 0):\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[0][2] = toggle(curr_state[0][2])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[0][1] = toggle(curr_state[0][1])\n #curr_state[2][1] = toggle(curr_state[2][1])\n sum1 = timed[1][2] + timed[0][2] + timed[1][1] + timed[2][2] + timed[0][1] + timed[2][1]\n if sum1 & 1:\n curr_state[1][2] = 1\n else:\n curr_state[1][2] = 0\nif (timed[2][0] >= temp and timed[2][0] > 0):\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[2][0] + timed[1][0] + timed[2][1] + timed[1][1]\n if sum1 & 1:\n curr_state[2][0] = 1\n else:\n curr_state[2][0] = 0\nif (timed[2][1] >= temp and timed[2][1] > 0):\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n #curr_state[2][0] = toggle(curr_state[2][0])\n #curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[1][0] = toggle(curr_state[1][0])\n #curr_state[1][2] = toggle(curr_state[1][2])\n sum1 = timed[2][1] + timed[1][1] + timed[2][0] + timed[2][2] + timed[1][0] + timed[1][2]\n if sum1 & 1:\n curr_state[2][1] = 1\n else:\n curr_state[2][1] = 0\nif (timed[2][2] >= temp and timed[2][2] > 0):\n #curr_state[2][2] = toggle(curr_state[2][2])\n #curr_state[1][2] = toggle(curr_state[1][2])\n #curr_state[2][1] = toggle(curr_state[2][1])\n #curr_state[1][1] = toggle(curr_state[1][1])\n sum1 = timed[2][2] + timed[1][2] + timed[2][1] + timed[1][1]\n if sum1 & 1:\n curr_state[2][2] = 1\n else:\n curr_state[2][2] = 0\n'''\nfor i in range(3):\n for j in range(3):\n print(curr_state[i][j], end='')\n print()"}, {"source_code": "def toggler(i,j,arr):\n if (i-1)>=0:\n arr[i-1][j]=1-arr[i-1][j]\n if (i+1)<3:\n arr[i+1][j]=1-arr[i+1][j]\n if (j - 1) >= 0:\n arr[i][j-1]=1-arr[i][j-1]\n if (j + 1) < 3:\n arr[i][j+1]=1-arr[i][j+1]\nones=[[1,1,1],[1,1,1],[1,1,1]]\n\narr=[]\nfor i in range(3):\n arr.append(list(map(int,input().split())))\nfor i in range(3):\n for j in range(3):\n if arr[i][j]%2!=0:\n ones[i][j]=1-ones[i][j]\n toggler(i,j,ones)\nprint(ones)\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import copy\n\nm = []\nfor i in range(3):\n\ta = list(map(int,input().split()))\n\tm.append(a)\nfor i in range(3):\n\tfor j in range(3):\n\t\tm[i][j] = m[i][j] % 2\nm1 = copy.deepcopy(m)\n\nfor i in m:\n\tind = m.index(i)\n\tif(i[0]==1):\n\t\tm1[ind][1]+=1\n\tif(i[1]==1):\n\t\tm1[ind][0]+=1\n\t\tm1[ind][2]+=1\n\tif(i[2]==1):\n\t\tm1[ind][1]+=1\nfor i in m:\n\tfor j in range(len(i)):\n\t\tind = m.index(i)\n\t\tif(ind==0 and i[j]==1):\n\t\t\tm1[ind+1][j]+=1\n\t\tif(ind==1 and i[j]==1):\n\t\t\tm1[ind-1][j]+=1\n\t\t\tm1[ind+1][j]+=1\n\t\tif(ind==2 and i[j]==1):\n\t\t\tm1[ind-1][j]+=1\nprint(m1)\n\nfor i in range(3):\n\tfor j in range(3):\n\t\tm1[i][j] = m1[i][j] % 2\n\t\tif(m1[i][j]==1):\n\t\t\tm1[i][j]='0'\n\t\telse:\n\t\t\tm1[i][j]='1'\nprint(m1)\n\nfor i in m1:\n\tst = \"\".join(i)\n\tprint(st)\n\t\n\n\n\t"}, {"source_code": "lights=[]\nlight=[[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n lights.append(map(int,raw_input().split(' ')))\n for j in range(3):\n if lights[i][j]%2==0:\n lights[i][j]=0\n else:\n lights[i][j]=1\n if i>0:\n light[i-1][j]=light[i-1][j]^1\n if i<2:\n light[i+1][j]=light[i+1][j]^1\n if j > 0:\n light[i][j-1]=light[i][j-1]^1\n if j < 2:\n light[i][j+1]=light[i][j+1]^1\n light[i][j] = light[i][j]^1\n\nfor i in range(3):\n for j in range(3):\n print light[i][j],\n print ''\n"}, {"source_code": "\ndef solve(i, j, lights): \n lights[i][j] ^= 1\n pos = [(i+1,j),(i-1,j),(i, j+1),(i,j-1)]\n for val in pos:\n i, j = val\n if 0 <= i < 3 and 0 <=j and j <3:\n lights[i][j] ^= 1\n \ndef main():\n m = n = 3\n a = []\n lights = [[1 for x in range(m)] for y in range(n)]\n for i in range(3):\n a.append([int(x) for x in input().split()])\n for j in range(3):\n if a[i][j] % 2:\n solve(i, j, lights)\n print ( lights )\n \nmain() "}, {"source_code": "s=[]\nl=[1,1,1,1,1,1,1,1,1]\nfor i in range(3):\n\ts+=list(map(int,input().split()))\nfor i in range(9):\n\tif s[i]%2!=0:\n\t\tif i==0:\n\t\t\tfor j in [0,1,3]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==1:\n\t\t\tfor j in [0,1,2,3,5]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==2:\n\t\t\tfor j in [1,2,5]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==3:\n\t\t\tfor j in [0,1,3,6,7]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==4:\n\t\t\tfor j in [0,1,2,3,5,6,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==5:\n\t\t\tfor j in [1,2,5,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==6:\n\t\t\tfor j in [3,6,7]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==7:\n\t\t\tfor j in [3,5,6,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==8:\n\t\t\tfor j in [5,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\nprint(*l[0:3])\nprint(*l[3:6])\nprint(*l[6:9])"}, {"source_code": "##Lenny is playing a game on a 3\u2009\u00d7\u20093 grid of lights.In the beginning of the game all lights are switched on.\n ##Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off.\n ## We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.\n##Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times.\n## Given the number of times each light is pressed, you have to print the current state of each light.\nmat=[[0,0,0,0,0]]\n##input\nfor i in range(3):\n d=[0]\n col = list(map(int,input().split()));\n d.extend(col)\n d.extend([0])\n mat.append(d);\nmat.append([0,0,0,0,0])\ni=0\nout=[[1,1,1],[1,1,1],[1,1,1]];\nfor n in range(1,4):\n for m in range(1,4):\n ss=0\n su=[]\n for i in range((n-1),(n+2)):\n st=[]\n for j in range(m-1,m+2):\n st.extend([mat[i][j]]);\n su.append(st);\n ss = sum(map(sum,su))\n ss = ss-(su[0][2]+su[2][0]+su[0][0]+su[2][2])\n if (ss%2)==0:\n out[n-1][m-1]=1;\n else:\n out[n-1][m-1]=0\nprint(out);\n"}, {"source_code": "l=[]\nfor i in range(3):\n l.append(list(map(int,input().split())))\n\n#l=[list(map(int,input().split())) for i in range(3)]\nl1 = [[0 for _ in range(3)] for _ in range(3)]\nfor i in range(3):\n for j in range(3):\n if j!=2:\n l1[i][j+1]+=l[i][j]\n if j!=0:\n l1[i][j-1]+=l[i][j]\n if i!=0:\n l1[i-1][j]+=l[i][j]\n if i!=2:\n l1[i+1][j]+=l[i][j]\nfor i in range(3):\n for j in range(3):\n if l1[i][j]&1:\n print(0,end=\"\")\n else:\n print(1,end=\"\")\n print(\"\\n\")"}, {"source_code": "\nl = [[ int(j) for j in input().split()] for i in range(3)]\n\n\np=[[0 for i in range(3)] for j in range(3)]\n\np[0][0] = l[0][0] + l[1][0] + l[0][1]\n\np[0][1] = l[0][0] + l[1][1] + l[0][1] +l[0][2]\np[0][2] = l[0][1] + l[1][2] + l[0][2]\np[1][0] = l[0][0] + l[1][0] + l[2][0]+l[1][1]\np[1][1] = l[1][1] + l[1][0] + l[0][1] + l[1][2]+l[2][1]\np[1][2] = l[0][2] + l[1][1] + l[1][2]+l[2][2]\np[2][0] = l[2][0] + l[1][0] + l[2][1]\np[2][1] = l[2][0] + l[2][1] + l[2][2]+l[1][2]\np[2][2] = l[2][2] + l[2][1] + l[1][2]\n\n\n\nfor i in range(3):\n for j in range(3):\n if p[i][j]%2 !=0:\n p[i][j]=0\n print(p[i][j],end=\"\")\n else:\n p[i][j] =1\n print(p[i][j],end=\"\")\n\n\n print()\n\n"}, {"source_code": "def main():\n lights = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n\n for i in xrange(0, 3):\n r = map(int, raw_input().split())\n for j in xrange(0, 3):\n for k in xrange(0, 3):\n for l in xrange(0, 3):\n lights[i+k][j+l] += r[j]\n\n for i in xrange(1, 4):\n for j in xrange(1, 4):\n lights[i][j] = 0 if lights[i][j] & 1 else 1\n\n for i in xrange(1, 4):\n for j in xrange(1, 4):\n print lights[i][j],\n print\n\nif __name__ == '__main__':\n main()"}, {"source_code": "a=[[1,1,1],[1,1,1],[1,1,1]]\nb=[]\nfor i in range(3):\n b.append(list(map(int,input().split())))\nd={0:1,1:0}\nfor i in range(3):\n for j in range(3):\n if b[i][j]%2==1:\n a[i][j]=0\n if i!=0:\n a[i-1][j]=d[a[i-1][j]]\n if i!=2:\n a[i+1][j]=d[a[i+1][j]]\n if j!=0:\n a[i][j-1]=d[a[i][j-1]]\n if j!=2:\n a[i][j+1]=d[a[i][j+1]]\nfor i in range(3):\n print()\n for j in range(3):\n print(a[i][j],end='')\n"}, {"source_code": "l = [[\"1\" for x in range(3)] for p in range(3)]\ni = [[x for x in map(int, input().split())] for t in range(3)]\nfor indx1,num in enumerate(i):\n for indx2,num1 in enumerate(num):\n if num1 % 2 != 0 and num1 != 0:\n if l[indx1][indx2] == \"1\":\n l[indx1][indx2] = \"O\"\n else:\n l[indx1][indx2] = \"1\"\n if indx2 + 1 in [0,1,2]:\n if l[indx1][indx2 + 1] == \"1\":\n l[indx1][indx2 + 1] = \"O\"\n else:\n l[indx1][indx2 + 1] = \"1\"\n if indx2 - 1 in [0,1,2]:\n if l[indx1][indx2 - 1] == \"1\":\n l[indx1][indx2 - 1] = \"O\"\n else:\n l[indx1][indx2 - 1] = \"1\"\n if indx1 + 1 in [0,1,2]:\n if l[indx1 + 1][indx2] == \"1\":\n l[indx1 + 1][indx2] = \"O\"\n else:\n l[indx1 + 1][indx2] = \"1\"\n if indx1 - 1 in [0,1,2]:\n if l[indx1 - 1][indx2] == \"1\":\n l[indx1 - 1][indx2] = \"O\"\n else:\n l[indx1 - 1][indx2] = \"1\"\nfor t in l:\n for tt in t:\n print(tt,end='')\n print('')"}, {"source_code": "import sys\n\nlampen=[]\nfor n in range (3):\n hulp=[int(x) for x in sys.stdin.readline().split()]\n lampen.append(hulp)\n\naantal=[[0,0,0],[0,0,0],[0,0,0]]\n\nfor x in range(3):\n for y in range(3):\n for z in range(3):\n aantal[x][y]+=lampen[x][z]\n aantal[x][y]+=lampen[z][y]\n aantal[x][y]-=lampen[x][y]\n#print aantal\n\nregel=''\nfor x in range (3):\n for y in range(3):\n if aantal[x][y]%2==0:\n regel+=('1')\n else:\n regel+=('0')\n print regel\n regel=''\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 = 3\nM = []\nfor i in range(n):\n M.append(map(int, raw_input().split()))\n\nS = [[0 for j in range(n+2)] for i in range(n+2)]\n\nfor i in range(n):\n for j in range(n):\n ii = i + 1\n jj = j + 1\n S[ii ][jj ] += M[i][j]\n S[ii+1][jj ] += M[i][j]\n S[ii-1][jj ] += M[i][j]\n S[ii ][jj+1] += M[i][j]\n S[ii ][jj-1] += M[i][j]\n\nfor i in range(n):\n for j in range(n):\n ii = i + 1\n jj = j + 1\n print 1 if S[ii][jj] % 2 == 0 else 0,\n print \n"}, {"source_code": "b =[[0 for i in range(5)] for j in range(5)]\nfor i in range(1,4):\n b[i][1:4] = [int(x)%2 for x in input().split()]\nfor i in range(1,4):\n for j in range(1,4):\n print((1+b[i][j] + b[i-1][j]+b[i+1][j]+b[i][j-1]+b[i][j+1])%2, end=' ')\n print()\n"}, {"source_code": "ans = [[True for i in range(3)] for j in range(3)] \nip = []\nfor i in range(3):\n k = list(map(int, input().split()))\n ip.append(k)\nfor i in range(3):\n for j in range(3):\n if ip[i][j]%2==0:\n continue\n ans[i][j] = not ans[i][j]\n if j-1>-1:\n ans[i][j-1] = not ans[i][j-1]\n if j+1<3:\n ans[i][j+1] = not ans[i][j+1]\n if i+1<3:\n ans[i+1][j] = not ans[i+1][j]\n if i-1>-1:\n ans[i-1][j] = not ans[i-1][j]\n \nfor i in range(3):\n for j in range(3):\n if ans[i][j]:\n print(\"1 \", end=\"\")\n else:\n print(\"0 \", end=\"\")\n print()"}, {"source_code": "mat=[]\nfor i in range(3):\n mat.append(list(map(int,input().rstrip().split())))\ntemp=[[1 for i in range(3)]for j in range(3)]\n \nfor i in range(3):\n for j in range(3):\n if mat[i][j]%2==1:\n temp[i][j]=0\n if i+1<3:\n temp[i+1][j]+=1\n if j+1<3:\n temp[i][j+1]+=1\n if i-1>-1:\n temp[i-1][j]+=1\n if j-1>-1:\n temp[i][j-1]+=1\nfor i in range(3):\n for j in range(3):\n print(temp[i][j]%2,end=\"\")\n print()"}, {"source_code": "import sys\n\ninarray = []\noutarray = [[1 for j in range(3)] for i in range(3)]\nfor i in range(3):\n k = [int(x) for x in (sys.stdin.readline()).split()]\n for j in range(3):\n if(k[j] % 2 != 0):\n outarray[i][j] ^= 1\n if(i - 1 > 0):\n outarray[i - 1][j] ^= 1\n if(j - 1 > 0):\n outarray[i][j - 1] ^= 1\n if(i + 1 < 3):\n outarray[i + 1][j] ^= 1\n if(j + 1 < 3):\n outarray[i][j + 1] ^= 1\n\nfor i in range(3):\n print(\"\".join([str(x) for x in outarray[i]]))"}, {"source_code": "list1 = []\na = []\nfor i in range(5):\n a.append(0)\nlist1.append(a)\nfor j in range(1):\n for i in range(3):\n \n temp = list(map(int,input().split(' ')))\n temp.append(0)\n temp.insert(0,0)\n #print(temp)\n list1.append(temp)\nlist1.append(a)\nfinal = []\n\nfor i in range(1,4):\n for j in range(1,4):\n sum = 0\n sum = list1[i][j] + list1[i + 1][j] + list1[i - 1][j] + list1[i][j + 1] + list1[i][j - 1]\n if sum % 2 == 1:\n tempo = 0\n else:\n tempo = 1\n final.append(tempo)\n \n\n#print(final)\nfor i in range(0,9):\n if (i) % 3 == 0:\n print('')\n print(final[i] , end = '')"}, {"source_code": "i = 0\na = []\nr = [0]*9\nwhile(i<3):\n l = input().split(\" \")\n a = a + [int(l[0]),int(l[1]),int(l[2])]\n i = i + 1\nr[0] = a[0]+a[1] + a[3]\nr[1] = a[1]+a[0]+a[2]+a[4]\nr[2] = a[2]+a[1] + a[5]\nr[3] = a[3]+a[0]+ a[1]+ a[4]\nr[4] = a[4]+a[1] + a[3] + a[5] + a[7]\nr[5] = a[5]+a[2]+a[8]+a[4]\nr[6] = a[6]+a[3]+a[4]+a[7]\nr[7] = a[7]+a[4]+a[6]+a[8]\nr[8] = a[8]+a[4]+a[5]+a[7]\ni = 0\nwhile(i= 0 and y < 3 and x >= 0 and x < 3:\n l_c[y][x] = abs(1 - l_c[y][x])\n\nfor l in l_c:\n print(\" \".join(str(i) for i in l))"}, {"source_code": "li=[[0 for j in range(3)]for i in range(3)]\nli[0]=input().split(\" \")\nli[1]=input().split(\" \")\nli[2]=input().split(\" \")\nfor i in range(3):\n for j in range(3):\n li[i][j]=int(li[i][j])\n print(li[i][j])\narr=[[1 for j in range(3)]for i in range(3)]\nk=[[0 for j in range(3)]for i in range(3)]\nfor i in range(3):\n for j in range(3):\n if(i==0 and j==0):\n arr[0][0]+=li[0][0]\n arr[0][1]+=li[0][0]\n arr[1][0]+=li[0][0]\n elif(i==0 and j==1):\n arr[0][1]+=li[0][1]\n arr[0][0]+=li[0][1]\n arr[0][2]+=li[0][1]\n arr[1][1]+=li[0][1]\n elif(i==0 and j==2):\n arr[0][2]+=li[0][2]\n arr[0][1]+=li[0][2]\n arr[1][2]+=li[0][2]\n elif(i==1 and j==0):\n arr[1][0]+=li[1][0]\n arr[0][0]+=li[1][0]\n arr[1][1]+=li[1][0]\n arr[2][0]+=li[1][0]\n elif(i==1 and j==1):\n arr[1][1]+=li[1][1]\n arr[0][1]+=li[1][1]\n arr[1][0]+=li[1][1]\n arr[1][2]+=li[1][1]\n arr[2][1]+=li[1][1]\n elif(i==1 and j==2):\n arr[1][2]+=li[1][2]\n arr[0][2]+=li[1][2]\n arr[1][1]+=li[1][2]\n arr[2][2]+=li[1][2]\n elif(i==2 and j==0):\n arr[2][0]+=li[2][0]\n arr[1][0]+=li[2][0]\n arr[2][1]+=li[2][0]\n elif(i==2 and j==1):\n arr[2][1]+=li[2][1]\n arr[1][1]+=li[2][1]\n arr[2][0]+=li[2][1]\n arr[2][2]+=li[2][1]\n elif(i==2 and j==2):\n arr[2][2]+=li[2][2]\n arr[1][2]+=li[2][2]\n arr[2][1]+=li[2][2]\n for i in range(3):\n for j in range(3):\n if(arr[i][j]%2==0):\n k[i][j]=0\n else:\n k[i][j]==1\nprint(\"{}{}{}\",k[0][0],k[0][1],k[0][2]) \nprint(\"{}{}{}\",k[1][0],k[1][1],k[1][2])\nprint(\"{}{}{}\",k[2][0],k[2][1],k[2][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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n "}, {"source_code": "matrix1 = [[-1 for x in range(5)] for y in range(5)]\nfor i in range(1,4):\n for j in range(1,4):\n matrix1[i][j] = 1\n\nscan = [[-1 for x in range(3)] for y in range(3)]\nfor i in range(3):\n x = [int(x) for x in input().split()]\n for j in range(len(x)):\n if x[j] % 2 == 1:\n if matrix1[i+1][j+1] == 0:\n matrix1[i+1][j+1] = 1\n elif matrix1[i+1][j+1] == 1:\n matrix1[i+1][j+1] = 0\n if matrix1[i + 1][j] == 0:\n matrix1[i + 1][j] = 1\n elif matrix1[i + 1][j] == 1:\n matrix1[i + 1][j] = 0\n if matrix1[i][j + 1] == 0:\n matrix1[i][j + 1] = 1\n elif matrix1[i][j + 1] == 1:\n matrix1[i][j + 1] = 0\n if matrix1[i + 1][j + 2] == 0:\n matrix1[i + 1][j + 2] = 1\n elif matrix1[i + 1][j + 2] == 1:\n matrix1[i + 1][j + 2] = 0\n if matrix1[i + 2][j + 1] == 0:\n matrix1[i + 2][j + 1] = 1\n elif matrix1[i + 2][j + 1] == 1:\n matrix1[i + 2][j + 1] = 0\n\nfor i in range(1, 4):\n for j in range(1, 4):\n print(matrix1[i][j], end = \" \")\n print()\n\n\n\n\n"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[84]:\n\n\n# n = int(input())\n# line = list(map(int, input().split()))\nline = []\nfor _ in range(3):\n line.append(list(map(int, input().split())))\n\n\n# In[98]:\n\n\nmod_func = lambda x: [[i%2 for i in y] for y in x]\nline = mod_func(line)\nres = [[1 for _ in range(3)] for _ in range(3)]\n\nfor i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n res[i][j] = 0 if res[i][j] == 0 else 0\n try: \n res[i][j+1] = 1 if res[i][j+1] == 0 else 0\n except: None\n try:\n if j - 1 > 0:\n res[i][j-1] = 1 if res[i][j-1] == 0 else 0\n except: None\n try: \n res[i+1][j] = 1 if res[i+1][j] == 0 else 0\n except: None\n try: \n if i - 1 > 0:\n res[i-1][j] = 1 if res[i-1][j] == 0 else 0\n except: None\n \nfor i in range(len(res)):\n print(\"\".join(map(str, res[i])))\n\n \n\n"}, {"source_code": "arr_i = [list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))]\nprint(arr_i)\n\narr = [[1 for x in range(3)] for y in range(3)]\nprint(arr)\narr[0][0] = (arr_i[0][0] + arr_i[0][1] + arr_i[1][0] + 1) % 2\narr[0][1] = (arr_i[0][0] + arr_i[0][1] + arr_i[0][2] + arr_i[1][1] + 1) % 2\narr[0][2] = (arr_i[0][1] + arr_i[0][2] + arr_i[1][2] + 1) % 2\narr[1][0] = (arr_i[0][0] + arr_i[1][0] + arr_i[1][1] + arr_i[2][0] + 1) % 2\narr[1][1] = (arr_i[0][1] + arr_i[1][0] + arr_i[1][1] + arr_i[1][2] + arr_i[2][1] + 1) % 2\narr[1][2] = (arr_i[0][2] + arr_i[1][1] + arr_i[1][2] + arr_i[2][2] + 1) % 2\narr[2][0] = (arr_i[1][0] + arr_i[2][0] + arr_i[2][1] + 1) % 2\narr[2][1] = (arr_i[1][1] + arr_i[2][0] + arr_i[2][1] + arr_i[2][2] + 1) % 2\narr[2][2] = (arr_i[1][2] + arr_i[2][1] + arr_i[2][2] + 1) % 2\nprint(arr)\n\nfor i in range(3):\n for j in range(3):\n print(arr[i][j], end=\"\")\n print()"}, {"source_code": "a=[]\nb=[]\nfor i in range(3):\n x = [int(x) for x in input().split(' ')]\n a.append(x)\n b.append([1, 1, 1])\nprint(a)\nfor i in range(len(a[0])):\n for j in range(len(a)):\n if a[j][i]%2 ==0:\n a[j][i] =0\n else:\n a[j][i]=1\n b[j][i]=b[j][i]-1\n if j+1<=2:\n b[j+1][i]=b[j+1][i]-1\n if j-1>=0:\n b[j-1][i]=b[j-1][i]-1\n if i+1<=2:\n b[j][i+1]=b[j][i+1]-1\n if i-1>=0:\n b[j][i-1]=b[j][i-1]-1\n\nfor i in range(3):\n for j in range(3):\n print(abs(b[i][j]),end =' ')\n print('')"}, {"source_code": "import sys\nimport math\nimport collections\nfrom collections import deque\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 factors(n):\n return list(set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\n# for _ in range(int(stdin.readline())):\n#n = int(stdin.readline())\n#n = int(stdin.readline())\n#a = list(map(int, stdin.readline().split()))\n#n, m = list(map(int, stdin.readline().split()))\n#s = str(stdin.readline().strip('\\n'))\nb = []\na = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\nfor _ in range(3):\n b.append(list(map(int, stdin.readline().split())))\n# print(b)\nfor i in range(3):\n for j in range(3):\n if b[i][j] % 2 == 1:\n #print([i, j])\n a[i][j] = a[i][j] ^ 1\n if j - 1 >= 0:\n a[i][j - 1] = a[i][j - 1] ^ 1\n if j + 1 < 3:\n a[i][j + 1] = a[i][j + 1] ^ 1\n if i + 1 < 3:\n a[i + 1][j] = a[i + 1][j] ^ 1\n if i - 1 >= 0:\n a[i - 1][j] = a[i - 1][j] ^ 1\nfor r in range(3):\n for c in range(3):\n print(a[r][c], end=' ')\n print('')\nprint('')\n"}, {"source_code": "def inverter(e,i):\n\tvirar = []\n\tfor j in range(e-1,e + 2):\n\t\tif not (j < 0 or j > 2):\n\t\t\tfor k in range(i-1,i+2):\n\t\t\t\tif not (k < 0 or k > 2):\n\t\t\t\t\tvirar.append([j,k])\n\n\tfor h in virar:\n\t\tif stats[h[0]][h[1]] == 1:\n\t\t\tstats[h[0]][h[1]] = 0\n\t\telse:\n\t\t\tstats[h[0]][h[1]] = 1\n\n\ndef filtro(inte):\n\treturn (int(inte))%2\t\n\ntoogl = []\nstats = []\nresultado = []\n\nfor e in range(3):\n\ttoogl.append(map(filtro,raw_input().split()))\n\tstats.append([1]*3)\nfor e in xrange(3):\n\tfor i in xrange(3):\n\t\tif toogl[e][i] == 1:\n\t\t\tinverter(e,i)\n\nfor e in stats:\n\ta = ''\n\tfor i in e:\n\t\ta += str(i)\n\tresultado.append(a)\n\nfor e in resultado:\n\tprint e\n\t\n\n\n"}, {"source_code": "print ['\\n'.join([' '.join(map(str,[(sum(a[x/3][x%3] for x in xrange(9) if abs(r-x/3)+abs(c-x%3)<=1)+1)%2 for c in xrange(3)])) for r in xrange(3)]) for a in [[[int(c) for c in raw_input().split()] for i in xrange(3)]]][0]"}, {"source_code": "def f(r1, r2, r3):\n\tr1 = map(lambda x : int(x), r1.split())\n\tr2 = map(lambda x : int(x), r2.split())\n\tr3 = map(lambda x : int(x), r3.split())\n\ts = str((r1[0]+r1[1]+r2[0]+1)%2)\n\ts += str((sum(r1)+r2[1]+1)%2)\n\ts += str((r1[1]+r1[2]+r2[1]+1)%2)\n\tt = str((r1[0]+r2[0]+r2[1]+r3[0]+1)%2)\n\tt += str((r1[1]+sum(r2)+r3[1]+1)%2)\n\tt += str((r1[2]+r2[1]+r2[2]+r3[2]+1)%2)\n\tu = str((r3[0]+r3[1]+r2[0]+1)%2)\n\tu += str((sum(r3)+r2[1]+1)%2)\n\tu += str((r3[1]+r3[2]+r2[1]+1)%2)\n\tprint s\n\tprint t\n \tprint u"}, {"source_code": "import math\n\narr_initial = [[1,1,1],[1,1,1],[1,1,1]]\n\ntries = []\n\n\n\nfor i in range(3):\n tries.append(list(map(int, input().split())))\n\nrows = len(tries)\ncols = len(tries[0])\n\nfor i in range(rows):\n for j in range(cols):\n try_val = tries[i][j]\n \n \n \n while(try_val>0):\n arr_initial[i][j] = 1 - arr_initial[i][j]\n \n if(i+1<=(rows-1)):\n arr_initial[i+1][j] = 1 - arr_initial[i+1][j]\n \n if(i-1>=0):\n arr_initial[i-1][j] = 1 - arr_initial[i-1][j]\n \n if(j+1<=(cols-1)):\n arr_initial[i][j+1] = 1 - arr_initial[i][j+1]\n \n if(j-1>=0):\n arr_initial[i][j-1] = 1 - arr_initial[i][j-1]\n \n try_val-=1\n\nprint(arr_initial)"}, {"source_code": "light_turners = list()\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\n\nlights = [[True, True, True], [True, True, True], [True, True, True]]\n\n\ndef flip_adjacent(i, j):\n lights[i][j] = not lights[i][j]\n\n lights[i][0] = not lights[i][0]\n lights[i][1] = not lights[i][1]\n lights[i][2] = not lights[i][2]\n\n lights[0][j] = not lights[0][j]\n lights[1][j] = not lights[1][j]\n lights[2][j] = not lights[2][j]\n\n\nfor i in range(3):\n for j in range(3):\n while light_turners[i][j] > 0:\n flip_adjacent(i, j)\n light_turners[i][j] -= 1\n\nfor i in range(3):\n for j in range(3):\n print(1 if lights[i][j] else 0, end='')\n print('')"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[72]:\n\n\n# n = int(input())\n# line = list(map(int, input().split()))\nline = []\nfor _ in range(3):\n line.append(list(map(int, input().split())))\n\n\n# In[83]:\n\n\nmod_func = lambda x: [[i%2 for i in y] for y in x]\nline = mod_func(line)\nres = [[1 for _ in range(3)] for _ in range(3)]\n\nfor i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n res[i][j] = 0 if res[i][j] == 0 else 0\n try: res[i][j+1] = 1 if res[i][j+1] == 0 else 0\n except: None\n try:\n if j - 1 > 0:\n res[i][j-1] = 1 if res[i][j-1] == 0 else 0\n except: None\n try: res[i+1][j] = 1 if res[i+1][j] == 0 else 0\n except: None\n try: \n if i - 1 > 0:\n res[i-1][j] = 1 if res[i-1][j] == 0 else 0\n except: None\n \n print(\"\".join(map(str, res[i])))\n \n\n"}, {"source_code": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[72]:\n\n\n# n = int(input())\n# line = list(map(int, input().split()))\nline = []\nfor _ in range(3):\n line.append(list(map(int, input().split())))\n\n\n# In[73]:\n\n\nmod_func = lambda x: [[i%2 for i in y] for y in x]\nline = mod_func(line)\nres = [[1 for _ in range(3)] for _ in range(3)]\n\nfor i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n res[i][j] = 0 if res[i][j] == 0 else 0\n try: res[i][j+1] = 1 if res[i][j+1] == 0 else 0\n except: None\n try:\n if j - 1 > 0:\n res[i][j-1] = 1 if res[i][j-1] == 0 else 0\n except: None\n try: res[i+1][j] = 1 if res[i+1][j] == 0 else 0\n except: None\n try: \n if i - 1 > 0:\n res[i-1][j] = 1 if res[i-1][j] == 0 else 0\n except: None\n \nprint(res)\n\n\n# In[ ]:\n\n\n\n\n\n# In[ ]:\n\n\n\n\n"}, {"source_code": "##Lenny is playing a game on a 3\u2009\u00d7\u20093 grid of lights.In the beginning of the game all lights are switched on.\n ##Pressing any of the lights will toggle it and all side-adjacent lights. The goal of the game is to switch all the lights off.\n ## We consider the toggling as follows: if the light was switched on then it will be switched off, if it was switched off then it will be switched on.\n##Lenny has spent some time playing with the grid and by now he has pressed each light a certain number of times.\n## Given the number of times each light is pressed, you have to print the current state of each light.\nmat=[[0,0,0,0,0]]\n##input\nfor i in range(3):\n d=[0]\n col = list(map(int,input().split()));\n d.extend(col)\n d.extend([0])\n mat.append(d);\nmat.append([0,0,0,0,0])\ni=0\nout=[[1,1,1],[1,1,1],[1,1,1]];\nfor n in range(1,4):\n for m in range(1,4):\n ss=0\n su=[]\n for i in range((n-1),(n+2)):\n st=[]\n for j in range(m-1,m+2):\n st.extend([mat[i][j]]);\n su.append(st);\n ss = sum(map(sum,su))\n ss = ss-(su[0][2]+su[2][0]+su[0][0]+su[2][2])\n if (ss%2)==0:\n out[n-1][m-1]=1;\n else:\n out[n-1][m-1]=0\ni=0;\nj=0;\nfor i in range(3):\n for j in range(3):\n print(out[i][j],end=' ');\n print('');\n"}, {"source_code": "a=[]\nfor i in range(3):\n b=[int(x) for x in input().split()]\n a.append(b)\nfor i in range(3):\n for j in range(3):\n c=0\n if(i!=2):\n c+=a[i+1][j]\n if(j!=2):\n c+=a[i][j+1]\n if(i>0):\n c+=a[i-1][j]\n if(j>0):\n c+=a[i][j-1]\n print((1-(c%2)),end='')\n print() \n "}, {"source_code": "m,n=[],[]\nfor i in range(3):\n a=list(map(int,input().split()))\n for j in range(3):\n if a[j]%2==1:\n m.append(i)\n n.append(j)\nprint(m,n)\na=[[0,0,0],[0,0,0],[0,0,0]]\nfor i,j in zip(m,n):\n try:\n a[i][j]+=1 \n print(a)\n except:\n pass\n try:\n a[i+1][j]+=1 \n print(a)\n except:\n pass\n try:\n a[i][j+1]+=1 \n print(a)\n except:\n pass\n try:\n a[i+1][j+1]+=1 \n print(a)\n except:\n pass\n if i-1>=0:\n try:\n a[i-1][j+1]+=1 \n print(a)\n except:\n pass\n if j-1>=0:\n try:\n a[i+1][j-1]+=1 \n print(a)\n except:\n pass\n if j-1>=0:\n try:\n a[i][j-1]+=1 \n print(a)\n except:\n pass\n if i-1>=0:\n try:\n a[i-1][j]+=1 \n print(a)\n except:\n pass\n if i-1>=0 and j-1>=0:\n try:\n a[i-1][j-1]+=1 \n print(a)\n except:\n pass\nprint(a)"}, {"source_code": "light_turners = list()\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\nlight_turners.append([int(x) for x in input().split(\" \")])\n\nlights = [[True, True, True], [True, True, True], [True, True, True]]\n\n\ndef flip_adjacent(i, j):\n lights[i][j] = not lights[i][j]\n\n lights[i][0] = not lights[i][0]\n lights[i][1] = not lights[i][1]\n lights[i][2] = not lights[i][2]\n\n lights[0][j] = not lights[0][j]\n lights[1][j] = not lights[1][j]\n lights[2][j] = not lights[2][j]\n\n\nfor i in range(3):\n for j in range(3):\n if light_turners[i][j] % 2 == 1:\n flip_adjacent(i, j)\n\nfor i in range(3):\n for j in range(3):\n print(1 if lights[i][j] else 0, end='')\n print('')\n"}, {"source_code": "t = [list(map(int, input().split())) for i in range(3)]\np = [[1] * 5 for i in range(5)]\nfor i in range(3):\n for j in range(3):\n if t[i][j] % 2 == 1:\n for u in range(i, i + 3):\n for v in range(j, j + 3):\n p[u][v] += 1\nfor i in range(1, 4):\n print(''.join(str(p[i][j] % 2) for j in range(1, 4)))"}, {"source_code": "def main():\n lights = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n\n for i in xrange(0, 3):\n r = map(int, raw_input().split())\n for j in xrange(0, 3):\n for k in xrange(0, 3):\n for l in xrange(0, 3):\n lights[i+k][j+l] += r[j]\n\n for i in xrange(1, 4):\n for j in xrange(1, 4):\n lights[i][j] = 0 if lights[i][j] & 1 else 1\n\n for i in xrange(1, 4):\n for j in xrange(1, 4):\n print lights[i][j],\n print\n\nif __name__ == '__main__':\n main()"}, {"source_code": "\nres = [[0 for _ in range(3)]for i in range(3)]\nfor i in range(3):\n a = input().split(' ')\n for j in range(3):\n res[i] [j] = a[j]\n\nf = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n if int(res[i][j]) % 2 != 0:\n f[i][j] -= f[i][j]\n if i-1 >= 0:\n f[i-1][j] = 1- f[i-1][j]\n if i+1 < 3:\n f[i+1][j] = 1- f[i+1][j]\n if j-1 >= 0 :\n f[i][j-1] = 1- f[i][j-1]\n if j+1 < 3 :\n f[i][j+1] = 1- f[i][j+1]\n if i+1 <3 and j+1 < 3:\n f[i+1][j+1] = 1- f[i+1][j+1]\n if i-1 >=0 and j-1 >= 0:\n f[i-1][j-1] = 1- f[i-1][j-1]\n\nfor i in f:\n for j in i:\n print(j,end=\"\")\n print()\n\n\n"}, {"source_code": "def tog(ans,i,j):\n if ans[i][j]=='n':\n ans[i][j]=0 #OFF\n elif ans[i][j]==0: #OFF\n ans[i][j]=1 #ON\n else:#ON\n ans[i][j]=0\n\nl = []\nfor i in range(3):\n row = list(map(int,input().split()))\n for j in range(3):\n if row[j]%2==0:\n row[j]=0\n else:\n row[j]=1\n l.append(row)\nans = [['n','n','n'] for i in range(3) ]\nfor i in range(3):\n for j in range(3):\n if l[i][j]==1:\n tog(ans,i,j)\n if (i+1)<3: \n tog(ans,i+1,j)\n #print(ans[i][j])\n if (i-1)>-1: \n tog(ans,i-1,j)\n if (j+1)<3: \n tog(ans,i,j+1)\n if (j-1)>-1: \n tog(ans,i,j-1)\n else:\n if ans[i][j]=='n':\n ans[i][j]=1\nfor row in ans:\n print(*row)\n\n \n \n\n"}, {"source_code": "def switcher(string):\n if string == '1':\n return string.replace('1', '0')\n else:\n return string.replace('0', '1')\n\ninicial = [['1', '1', '1'], ['1', '1', '1'], ['1', '1', '1']]\nmatriz = []\nfor i in range(3):\n matriz.append(''.join(input().split()))\n\nfor i in range(len(matriz)):\n for j in range(len(matriz[i])):\n if int(matriz[i][j]) % 2 != 0:\n if j == 0 and i == 0:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j+1] = switcher(inicial[i][j+1])\n inicial[i+1][j] = switcher(inicial[i+1][j])\n elif j == 1 and i == 0:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j+1] = switcher(inicial[i][j+1])\n inicial[i+1][j] = switcher(inicial[i+1][j])\n inicial[i][j-1] = switcher(inicial[i][j-1])\n elif j == 2 and i == 0:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j-1] = switcher(inicial[i][j-1])\n inicial[i+1][j] = switcher(inicial[i+1][j])\n elif j == 0 and i == 1:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j+1] = switcher(inicial[i][j+1])\n inicial[i+1][j] = switcher(inicial[i+1][j])\n inicial[i-1][j] = switcher(inicial[i-1][j])\n elif j == 1 and i == 1:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j+1] = switcher(inicial[i][j+1])\n inicial[i+1][j] = switcher(inicial[i+1][j])\n inicial[i][j-1] = switcher(inicial[i][j-1])\n inicial[i-1][j] = switcher(inicial[i-1][j])\n elif j == 2 and i == 1:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j-1] = switcher(inicial[i][j-1])\n inicial[i+1][j] = switcher(inicial[i+1][j])\n inicial[i-1][j] = switcher(inicial[i-1][j])\n elif j == 0 and i == 2:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j+1] = switcher(inicial[i][j+1])\n inicial[i-1][j] = switcher(inicial[i-1][j])\n elif j == 1 and i == 2:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j+1] = switcher(inicial[i][j+1])\n inicial[i][j-1] = switcher(inicial[i][j-1])\n inicial[i-1][j] = switcher(inicial[i-1][j])\n elif j == 2 and i == 2:\n inicial[i][j] = switcher(inicial[i][j])\n inicial[i][j-1] = switcher(inicial[i][j-1])\n inicial[i-1][j] = switcher(inicial[i-1][j])\n\nprint(''.join(inicial[0]))\nprint(''.join(inicial[1]))\nprint(''.join(inicial[2]))"}, {"source_code": "def calc(grid):\n n = [[\"1\" for y in range(3)] for x in range(3)]\n for row in range(len(grid)):\n for col in range(len(grid[0])):\n update(n, grid, row, col)\n return n\ndef update(n, grid, row, col):\n c = grid[row][col]\n c %=2\n if c != 0:\n # toggle adjacent lights\n for nr, nc in zip([row-1, row+1, row, row], [col, col, col-1,col+1]):\n if nr>=0 and nr=0 and nc 0):\n if i > 0:\n if(light[i-1][j] == 1):\n light[i-1][j] = 0\n else:\n light[i-1][j] = 1\n if i+1 < 3:\n if(light[i+1][j] == 1):\n light[i+1][j] = 0\n else:\n light[i+1][j] = 1\n if j > 0:\n if(light[i][j-1] == 1):\n light[i][j-1] = 0\n else:\n light[i][j-1] = 1\n if j+1 < 3:\n if(light[i][j+1] == 1):\n light[i][j+1] = 0\n else:\n light[i][j+1] = 1\n if(light[i][j] == 1):\n light[i][j] = 0\n else:\n light[i][j] = 1\n print(light)\n sw[i][j] -= 1\nfor i in light:\n for j in i:\n print(j,end='')\n print('')"}, {"source_code": "import sys\nimport math\nimport collections\nfrom collections import deque\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 factors(n):\n return list(set(reduce(list.__add__,\n ([i, n // i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\n\n# for _ in range(int(stdin.readline())):\n#n = int(stdin.readline())\n#n = int(stdin.readline())\n#a = list(map(int, stdin.readline().split()))\n#n, m = list(map(int, stdin.readline().split()))\n#s = str(stdin.readline().strip('\\n'))\nb = []\na = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\nfor _ in range(3):\n b.append(list(map(int, stdin.readline().split())))\n# print(b)\nfor i in range(3):\n for j in range(3):\n if b[i][j] % 2 == 1:\n a[i][j] = a[i][j] ^ 1\n if j - 1 >= 0:\n a[i][j - 1] = a[i][j - 1] ^ 1\n if j + 1 < 3:\n a[i][j + 1] = a[i][j + 1] ^ 1\n\n if i + 1 < 3:\n a[i + 1][j] = a[i + 1][j] ^ 1\n if j - 1 >= 0:\n a[i + 1][j - 1] = a[i + 1][j - 1] ^ 1\n if j + 1 < 3:\n a[i + 1][j + 1] = a[i + 1][j + 1] ^ 1\n if i - 1 >= 0:\n a[i - 1][j] = a[i - 1][j] ^ 1\n if j - 1 >= 0:\n a[i - 1][j - 1] = a[i - 1][j - 1] ^ 1\n if j + 1 < 3:\n a[i - 1][j + 1] = a[i - 1][j + 1] ^ 1\nfor i in range(3):\n for j in range(3):\n print(a[i][j], end='')\n print('')\n"}, {"source_code": "l = [[0 for i in range(5)] for j in range(5)]\nprint(l)\nfor i in range(1,4):\n l[i][1:4]=[int(j) for j in input().split()]\n\nfor i in range(1,4):\n for j in range(1,4):\n s = l[i][j]+l[i+1][j]+l[i][j+1] +l[i-1][j]+l[i][j-1]\n if s%2==0:\n print(\"1\",end=\"\")\n else:\n print(\"0\",end=\"\")\n print()"}, {"source_code": "def toggle(x, y):\n\tif(ini[x][y] == 1):\n\t\tini[x][y] = 0\n\telse :\n\t\tini[x][y] = 1\t\n\ndef find_neighbours(x,y):\n\ttoggle(x,y)\n\tif(x - 1 > 0):\n\t\ttoggle(x - 1, y)\n\tif(x + 1 < 3):\n\t\ttoggle(x + 1, y)\n\tif(y - 1 > 0):\n\t\ttoggle(x, y - 1)\n\tif(y + 1 < 3):\n\t\ttoggle(x , y + 1)\n\n\n\nmatrix = []\n\nini = [[ 1 for i in range(3)] for j in range(3)]\n\nrows = []\nfor i in range(3):\n\trows = map(int, raw_input().split())\n\t\t\n\tfor j in range(len(rows)):\n\t\tif rows[j] % 2 == 0:\n\t\t\trows[j] = 0\n\t\telse :\n\t\t\trows[j] = 1\t\t\n\tmatrix.append(rows)\n\t\t\nfor i in range(3):\n\tfor j in range(3):\n\t\tif matrix[i][j] == 1:\n\t\t\tfind_neighbours(i, j)\n\na = \"\"\nfor i in range(3):\n\ta = map(str, ini[i])\n\ta = ''.join(a)\n\tprint(a)\n\n\n"}, {"source_code": "ans=[[1 for i in range(3)] for j in range(3)]\nq=[]\nfor i in range(3):\n\tq.append(list(map(int,input().split())))\nfor i in range(3):\n\tfor j in range(3):\n\t\tif(q[i][j]%2==1):\n\t\t\tans[i][j]=ans[i][j]^1\n\t\t\tif(i-1>=0):\n\t\t\t\tans[i-1][j]=ans[i-1][j]^1\n\t\t\tif(i+1<3):\n\t\t\t\tans[i+1][j]=ans[i+1][j]^1\n\t\t\tif(j-1>=0):\n\t\t\t\tans[i][j-1]=ans[i][j-1]^1\n\t\t\tif(j+1<3):\n\t\t\t\tans[i][j+1]=ans[i][j+1]^1\n\n\nfor i in range(3):\n\tprint(*ans[i])\n"}, {"source_code": "l=lambda:map(int, raw_input().split())\na=[[1,1,1],[1,1,1],[1,1,1]]\nm=[l(),l(),l()]\n\nfor i in range(3):\n for j in range(3):\n if m[i][j]:\n \n for k in range(3):\n \n a[k][j] = 1 - a[k][j]\n \n if k != j:\n a[i][k] = 1 - a[i][k]\n \n \nprint '\\n'.join(''.join(map(str, e))for e in a)"}, {"source_code": "mat = []\nfor i in range(3):\n mat.append(list(map(int,input().split())))\n\n#print(mat)\nfor i in mat:\n for j in i:\n if j == 0 or j%2 == 0:\n print('1',end='')\n else:\n print('0',end='')\n print()"}, {"source_code": "a = input().split()\nb = input().split()\nc = input().split()\nlis = [a, b, c]\nfor i in range(3):\n for j in range(3):\n lis[i][j]=int(lis[i][j])\nnewl=[[0,0,0],[0,0,0],[0,0,0]]\nfor i in range(3):\n newl[0][i]=lis[0][i]+lis[1][i]\n newl[2][i]=lis[2][i]+lis[1][i]\n newl[1][i]=lis[0][i]+lis[1][i]+lis[2][i]\nfor i in range(3):\n newl[i][0]=(newl[i][0]+lis[i][1]+1)%2\n newl[i][2]=(newl[i][2]+lis[i][1]+1)%2\n newl[i][1]=(newl[i][1]+lis[i][0]+lis[i][2]+1)%2\nprint(str(newl[0][0])+str(newl[0][1])+str(newl[0][2]))\nprint(str(newl[1][0])+str(newl[1][1])+str(newl[2][2]))\nprint(str(newl[2][0])+str(newl[2][1])+str(newl[2][2]))"}, {"source_code": "arr = []\nfor _ in range(3):\n arr.append(list(map(int,input().split())))\nprint(arr)\n\nans = [[1,1,1],[1,1,1],[1,1,1]]\nfor i in range(3):\n for j in range(3):\n if arr[i][j]%2:\n if i==0:\n if j==0:\n ans[i+1][j]^=1\n ans[i+1][j+1]^=1\n ans[i][j+1]^=1\n elif j==1:\n ans[i][j-1]^=1\n ans[i+1][j-1]^=1\n ans[i+1][j]^=1\n ans[i+1][j+1]^=1\n ans[i][j+1]^=1\n elif j==2:\n ans[i+1][j]^=1\n ans[i+1][j-1]^=1\n ans[i][j-1]^=1\n elif i==1:\n if j==0:\n ans[i-1][j]^=1\n ans[i-1][j+1]^=1\n ans[i][j+1]^=1\n ans[i+1][j+1]^=1\n ans[i][j+1]^=1\n elif j==1:\n ans[i-1][j-1]^=1\n ans[i-1][j]^=1\n ans[i-1][j+1]^=1\n ans[i][j-1]^=1\n ans[i][j+1]^=1\n ans[i+1][j-1]^=1\n ans[i+1][j]^=1\n ans[i+1][j+1]^=1\n elif j==2:\n ans[i-1][j]^=1\n ans[i-1][j-1]^=1\n ans[i][j-1]^=1\n ans[i+1][j-1]^=1\n ans[i+1][j]^=1\n elif i==2:\n if j==0:\n ans[i-1][j]^=1\n ans[i-1][j+1]^=1\n ans[i][j+1]^=1\n elif j==1:\n ans[i][j-1]^=1\n ans[i-1][j-1]^=1\n ans[i-1][j]^=1\n ans[i-1][j+1]^=1\n ans[i][j+1]^=1\n elif j==2:\n ans[i-1][j-1]^=1\n ans[i-1][j]^=1\n ans[i][j-1]^=1\n ans[i][j]^=1\n\nfor i in ans:\n a = ''\n for j in i:\n a += str(j)\n print(a)\n"}, {"source_code": "def test():\n def switch(x, y):\n direct = [[1,0],[0,1],[-1,0],[0,-1]]\n for i in direct:\n new_row = i[0] + x\n new_col = i[1] + y\n if new_row >= 0 and new_col >= 0 and new_row < 3 and new_col < 3:\n lights[new_row][new_col] = 0 if lights[new_row][new_col] == 1 else 1\n lights[x][y] = 0 if lights[x][y] == 1 else 1 \n lights = [[1,1,1],[1,1,1],[1,1,1]]\n for i in range(3):\n act = input().split()\n for j in range(3):\n if int(act[j]) % 2 == 1:\n switch(i, j)\n print(lights)\n \n\nif __name__ == \"__main__\":\n test()"}, {"source_code": "#!/usr/bin/env python\n\n\n\nrow1 = [int(x) for x in raw_input().split()]\nrow2 = [int(x) for x in raw_input().split()]\nrow3 = [int(x) for x in raw_input().split()]\n\nmatrix = [row1, row2, row3]\n\nans = [[1,1,1],[1,1,1],[1,1,1]]\n\nfor i in xrange(3):\n\tfor z in xrange(3):\n\t\tif matrix[i][z] != 0:\n\t\t\t\t# print ans\n\t\t\t\tif i == 0 and z == 0:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 0 and z == 1:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 0 and z == 2:\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 1 and z == 0:\n\t\t\t\t\t# print \"A\",ans[i][z]\n\t\t\t\t\t# print ans\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 1 and z == 1:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 1 and z == 2:\n\t\t\t\t\t\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i+1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 2 and z == 0:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 2 and z == 1:\n\t\t\t\t\t\n\t\t\t\t\tans[i][z + 1] += matrix[i][z]\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\telif i == 2 and z == 2:\n\t\t\t\t\t\n\t\t\t\t\tans[i-1][z] += matrix[i][z]\n\t\t\t\t\tans[i][z - 1] += matrix[i][z]\n\t\t\t\t\tans[i][z] += matrix[i][z]\n\t\t\t\t# print ans\n\t\t\t\t# print \"/\",i,z,matrix[i][z]\n\n\nfor i in xrange(3):\n\tfor z in xrange(3):\n\t\tif ans[i][z]%2 != 0:\n\t\t\tans[i][z] = 1\n\t\telse:\n\t\t\tans[i][z] = 0\nfor r in ans:\n\tprint \" \".join([str(x) for x in r])\n"}, {"source_code": "b1 = input().split(\" \")\nb2 = input().split(\" \")\nb3 = input().split(\" \")\na1 = [int(i) for i in b1]\na2 = [int(i) for i in b2]\na3 = [int(i) for i in b3]\na = list()\na.append(a1)\na.append(a2)\na.append(a3)\ny = [['1','1','1'],['1','1','1'],['1','1','1']]\nif (a[0][0]+a[1][0]+a[0][1])%2!=0:\n y[0][0]='0'\nif (a[0][0]+a[0][2]+a[0][1]+a[1][1])%2!=0:\n y[0][1]='0'\nif (a[1][2]+a[0][2]+a[0][1])%2!=0:\n y[0][2]='0'\nif (a[0][0]+a[1][0]+a[2][1]+a[1][1])%2!=0:\n y[1][0]='0'\nif (a[0][1]+a[1][0]+a[1][1]+a[1][2]+a[2][1])%2!=0:\n y[1][1]='0'\nif (a[1][2]+a[0][2]+a[2][2]+a[1][1])%2!=0:\n y[1][2]='0'\nif (a[1][0]+a[2][0]+a[2][1])%2!=0:\n y[2][0]='0'\nif (a[2][0]+a[2][2]+a[2][1]+a[1][1])%2!=0:\n y[2][1]='0'\nif (a[2][1]+a[2][2]+a[1][2])%2!=0:\n y[2][2]='0'\nfor i in range(0,3):\n print(y[i][0]+y[i][1]+y[i][2])\n"}, {"source_code": "s=[]\nl=[1,1,1,1,1,1,1,1,1]\nfor i in range(3):\n\ts+=list(map(int,input().split()))\nfor i in range(9):\n\tif s[i]%2!=0:\n\t\tif i==0:\n\t\t\tfor j in [0,1,3]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==1:\n\t\t\tfor j in [0,1,2,3,5]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==2:\n\t\t\tfor j in [1,2,5]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==3:\n\t\t\tfor j in [0,1,3,6,7]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==4:\n\t\t\tfor j in [0,1,2,3,5,6,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==5:\n\t\t\tfor j in [1,2,5,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==6:\n\t\t\tfor j in [3,6,7]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==7:\n\t\t\tfor j in [3,5,6,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\n\t\telif i==8:\n\t\t\tfor j in [5,7,8]:\n\t\t\t\tif l[j]==1:\n\t\t\t\t\tl[j]=0\n\t\t\t\telse:\n\t\t\t\t\tl[j]=1\nfor i in l[0:3]:\n\tprint(i,end='')\nprint()\nfor i in l[3:6]:\n\tprint(i,end='')\nprint()\nfor i in l[6:9]:\n\tprint(i,end='')"}, {"source_code": "fl = [[1,1,1],[1,1,1],[1,1,1]]\nl1=[]\nfor i in range(3):\n\tl2=[]\n\tl2 = list(map(int,input().split(\" \")))\n\tl1.append(l2)\n\nfor i in range(len(l1)):\n\tfor j in range(len(l1[i])):\n\t\tif l1[i][j]%2 != 0:\n\t\t\tif fl[i][j] == 0:\n\t\t\t\tfl[i][j]+=1\n\t\t\telse:\n\t\t\t\tfl[i][j]=0\t\t\t\t\t\n\t\t\tif i-1 >= 0:\n\t\t\t\tif fl[i-1][j] == 0:\n\t\t\t\t\tfl[i-1][j]+=1\n\t\t\t\telse:\n\t\t\t\t\tfl[i-1][j]=0\t\t\t\t\t\n\t\t\tif j-1 >= 0:\n\t\t\t\tif fl[i][j-1] == 0:\n\t\t\t\t\tfl[i][j-1]+=1\n\t\t\t\telse:\n\t\t\t\t\tfl[i][j-1]=0\t\t\t\t\t\n\t\t\tif i+1 <= 2:\n\t\t\t\tif fl[i+1][j] == 0:\n\t\t\t\t\tfl[i+1][j]+=1\n\t\t\t\telse:\n\t\t\t\t\tfl[i+1][j]=0\t\t\t\t\t\n\t\t\tif j+1 <= 2:\n\t\t\t\tif fl[i][j+1] == 0:\n\t\t\t\t\tfl[i][j+1]+=1\n\t\t\t\telse:\n\t\t\t\t\tfl[i][j+1]=0\t\t\t\t\t\n\nfor i in fl:\n\tfor j in i:\n\t\tprint(j,end=\" \")\n\tprint(\"\\n\",end=\"\")\n\t\t\n\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n"}, {"source_code": "a=[]\nfor i in range(3):\n b=[int(x) for x in input().split()]\n a.append(b)\nfor i in range(3):\n for j in range(3):\n c=0\n if(i!=2):\n c+=a[i+1][j]\n if(j!=2):\n c+=a[i][j+1]\n if(i>0):\n c+=a[i-1][j]\n if(j>0):\n c+=a[i][j-1]\n print((1-(c%2)),end='')\n print() \n "}, {"source_code": "def toggle(val):\n if val == 1:\n return 0\n else:\n return 1\n\ntimed = [list(map(int, input().split())) for i in range(3)]\n\n#intialize = [[0 for i in range(3)] for i in range(3)]\n\ncurr_state = [[1 for i in range(3)] for i in range(3)]\n\nmaxi = 0\n\nfor i in range(3):\n for j in range(3):\n if timed[i][j] > maxi:\n maxi = timed[i][j]\n\n#print(maxi)\ntemp = 0\n\nwhile(True):\n temp += 1\n if temp > maxi:\n break\n if (timed[0][0] >= temp):\n #print(curr_state[0][1], curr_state[1][0])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[1][1] = toggle(curr_state[1][1])\n #print(curr_state[0][1], curr_state[1][0])\n if (timed[0][1] >= temp):\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[1][2] = toggle(curr_state[1][2])\n if (timed[0][2] >= temp):\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n if (timed[1][0] >= temp):\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[2][1] = toggle(curr_state[2][1])\n if (timed[1][1] >= temp):\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[2][1] = toggle(curr_state[2][1])\n curr_state[0][0] = toggle(curr_state[0][0])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[2][2] = toggle(curr_state[2][2])\n if (timed[1][2] >= temp):\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[0][2] = toggle(curr_state[0][2])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[2][2] = toggle(curr_state[2][2])\n curr_state[0][1] = toggle(curr_state[0][1])\n curr_state[2][1] = toggle(curr_state[2][1])\n if (timed[2][0] >= temp):\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[2][1] = toggle(curr_state[2][1])\n curr_state[1][1] = toggle(curr_state[1][1])\n if (timed[2][1] >= temp):\n curr_state[2][1] = toggle(curr_state[2][1])\n curr_state[1][1] = toggle(curr_state[1][1])\n curr_state[2][0] = toggle(curr_state[2][0])\n curr_state[2][2] = toggle(curr_state[2][2])\n curr_state[1][0] = toggle(curr_state[1][0])\n curr_state[1][2] = toggle(curr_state[1][2])\n if (timed[2][2] >= temp):\n curr_state[2][2] = toggle(curr_state[2][2])\n curr_state[1][2] = toggle(curr_state[1][2])\n curr_state[2][1] = toggle(curr_state[2][1])\n curr_state[1][1] = toggle(curr_state[1][1])\n\nfor i in range(3):\n for j in range(3):\n print(curr_state[i][j], end='')\n print()"}, {"source_code": "mat = []\nfor i in range(3):\n mat.append(list(map(int,input().split())))\n\n#print(mat)\nfor i in mat:\n for j in i:\n if j == 0 or j%2 == 0:\n print('1',end='')\n else:\n print('0',end='')\n print()"}, {"source_code": "A = []\nB = []\nfor i in range(3):\n A += [list(map(int,input().split()))]\n B += [[1] * 3]\nfor i in range(3):\n for j in range(3):\n if A[i][j] % 2 == 1:\n if i > 0:\n B[i - 1][j] ^= 1\n if i < 2:\n B[i + 1][j] ^= 1\n if j > 0:\n B[i][j-1] ^= 1\n if j < 2:\n B[i][j+1] ^= 1\n B[i][j] ^= 1\nfor a in B:\n for j in a:\n print(j, end= ' ')\n print() "}], "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6"} {"nl": {"description": "Some country is populated by wizards. They want to organize a demonstration.There are n people living in the city, x of them are the wizards who will surely go to the demonstration. Other city people (n\u2009-\u2009x people) do not support the wizards and aren't going to go to the demonstration. We know that the city administration will react only to the demonstration involving at least y percent of the city people. Having considered the matter, the wizards decided to create clone puppets which can substitute the city people on the demonstration. So all in all, the demonstration will involve only the wizards and their puppets. The city administration cannot tell the difference between a puppet and a person, so, as they calculate the percentage, the administration will consider the city to be consisting of only n people and not containing any clone puppets. Help the wizards and find the minimum number of clones to create to that the demonstration had no less than y percent of the city people.", "input_spec": "The first line contains three space-separated integers, n, x, y (1\u2009\u2264\u2009n,\u2009x,\u2009y\u2009\u2264\u2009104,\u2009x\u2009\u2264\u2009n) \u2014 the number of citizens in the city, the number of wizards and the percentage the administration needs, correspondingly. Please note that y can exceed 100 percent, that is, the administration wants to see on a demonstration more people that actually live in the city (\u2009>\u2009n).", "output_spec": "Print a single integer \u2014 the answer to the problem, the minimum number of clones to create, so that the demonstration involved no less than y percent of n (the real total city population). ", "sample_inputs": ["10 1 14", "20 10 50", "1000 352 146"], "sample_outputs": ["1", "0", "1108"], "notes": "NoteIn the first sample it is necessary that at least 14% of 10 people came to the demonstration. As the number of people should be integer, then at least two people should come. There is only one wizard living in the city and he is going to come. That isn't enough, so he needs to create one clone. In the second sample 10 people should come to the demonstration. The city has 10 wizards. They will all come to the demonstration, so nobody has to create any clones."}, "positive_code": [{"source_code": "n,m,k=[int(x) for x in input().split(' ')]\nper=(n*k+99)//100\nprint(max(0,per-m))"}, {"source_code": "import math\na,b,c=map(int,input().split())\nprint(math.ceil(-min(0,-a*c/100+b)))"}, {"source_code": "n,x,y=map(int,input().split())\nprint(max(0, -((100 * x - n * y) // 100)))"}, {"source_code": "import sys\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\nn, x, y = readints()\n\nprint max([0, n * y / 100 - x + ( (n * y) % 100 != 0 )])\n"}, {"source_code": "x, y, z = map(float, raw_input().split())\npercentagething = z * 0.01\npopulationthatcomes = x * percentagething\ncounter = 0\nif y >= populationthatcomes:\n print 0\n exit()\nelse:\n while y < populationthatcomes:\n y += 1\n counter += 1\n if y >= populationthatcomes:\n print counter\n exit()\n\n"}, {"source_code": "a,b,c=map(int,input().split())\nr=0\nwhile (b/a)*1000]"}, {"source_code": "\nimport math\n\na=input()\np=a.split()\nn=float(p[0])\nx=float(p[1])\ny=float(p[2])\n\nout=math.ceil((y/100)*n)\n\nif (int(out-x)>0):\n print (int(out-x))\nelse:\n print (0)\n \n\n\n\n"}, {"source_code": "n, x, y = map(int,input().split())\nimport math\nprint (0 if x>=n*y/100 else math.ceil(n*y/100 - x))"}, {"source_code": "\nfrom math import ceil\nn, x, y = list(map(int, input().split()))\nfinal = (ceil((n * y) / 100)) - x\nif final < 0:\n print(0)\nelse:\n print(final)\n\n# CodeForcesian\n# \u2665\n# \u0627\u06af\u0647 \u0627\u06cc\u0645\u0627\u0646 \u062f\u0627\u0631\u06cc \u06a9\u0647 \u0631\u0648\u0632\u0627\u06cc \u062e\u0648\u0628 \u062a\u0648 \u0631\u0627\u0647\u0646\n# \u0631\u0648\u0632\u0627\u06cc \u062e\u0648\u0628 \u0642\u0637\u0639\u0627 \u0628\u0647 \u0633\u0645\u062a\u062a \u0645\u06cc\u0627\u062f\n"}, {"source_code": "a, b, c = map(int, input().split())\nc/=100\na*=c\na*=10\nfinals = 0\nif a%10 > 0:\n a/=10\n finals = int(a)+1\nelse:\n a/=10\n finals = int(a)\nif finals <= b:\n finals = 0\n print(finals)\nelse:\n print(finals-b)"}, {"source_code": "n,x,y = [int(i) for i in raw_input().split()]\nc = 0\nwhile float(x+c)/n*100 < y:\n c += 1\nprint c"}, {"source_code": "n,x,y= map(int,raw_input().split())\n\nprint max(0,n*y/100+1-x if n*y%100 else n*y/100-x)\n \n\n\n\n\n\n\n\n"}, {"source_code": "import math\nn,x,y=map(int,input().split())\nper=(y/100)*n\nt=math.ceil(per)\nt-=x\nif t<0:\n print(\"0\")\nelse:\n print(t)\n"}, {"source_code": "n, x, y = map(int,input().split())\nimport math\nif x >= n*y/100:\n print(0)\nelse:\n print(math.ceil(n*y/100 - x))\n\n"}, {"source_code": "\nimport math\nn, x, y = map(int, input().split())\n\n# n * y / 100 = x + c\n\nc = math.ceil(n * y / 100) - x\nif c < 0:\n\tc = 0\nprint (c)\n"}, {"source_code": "import math\nstring = input()\nn, x, y = map(int, string.split())\na = math.ceil(y / 100 * n)\nif a < x:\n print(0)\nelse:\n print(a - x)"}, {"source_code": "n, x, y = map(int, input().split())\n\npeople = n * y / 100\nif not people.is_integer():\n people = int(people) + 1\nelse:\n people = int(people)\n\nif people < x:\n print(0)\nelse:\n print(people - x)"}, {"source_code": "import sys\n\n(n, x, y) = [int(x) for x in sys.stdin.readline().strip().split()]\n\nprint(max((n*y-1)//100+1-x, 0))\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().split()]\nn, x, y = line[0], line[1], line[2]\nres = 0\nwhile x < n*y/100:\n x += 1\n res += 1\nprint(res)"}, {"source_code": "from math import ceil\n\nn,x,y = map(int, input().split())\n\nprint(max(0,ceil(n*y/100) - x))"}, {"source_code": "n,x,y=map(int,raw_input().split())\nprint-min(0,-n*y/100+x)\n"}, {"source_code": "n,x,y=map(int,raw_input().split())\nimport math\nresult=int(math.ceil(n*y/100.0-x))\nif result<0:\n result=0\nprint result\n"}, {"source_code": "import math\nn,x,y=map(int,input().split())\nreq=math.ceil(y/100*n)\n\nprint(max(0,req-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"}, {"source_code": "(n, x, y) = map(int, raw_input().strip().split())\n\np = n*(y*0.01)\nif round(p) == p:\n m = int(p)-x\nelse:\n m = int(p)+1-x\n\nif m >=0:\n print m\nelse:\n print 0"}, {"source_code": "n,x,y=map(int,input().split())\nprint(max(0, -((100 * x - n * y) // 100)))"}, {"source_code": "import math\nn,x,y=map(int,input().split())\nans=math.ceil((y*n/100))\nif x>=ans:\n print(0)\nelse:\n print(ans-x)"}, {"source_code": "n, x, y = map(int, input().split())\n\nw = x\n\ny /= 100\nans = 0\n\nwhile w/n < y:\n w += 1\n ans += 1\nprint(ans)\n"}, {"source_code": "from __future__ import division\nimport math\nn,x,y = map(int,raw_input().split())\nprint max(0,int(math.ceil(n*y/100-x)))"}, {"source_code": "import math\nn, x, y = map(int, input().split())\n\np = y * n / 100\nt = math.ceil(p - x)\nprint(t if t >= 0 else 0)"}, {"source_code": "num,wiz,per = map(int,input().split())\nk = 0\nwhile (k+wiz)/num*100 < per:\n k += 1\nprint(k)"}, {"source_code": "n,x,y=[int(i) for i in input().split()]\nclone=0\nz=False\nif not x/n*1000 else 0"}, {"source_code": "n,x,y=map(int,raw_input().split())\nimport math\nresult=int(math.ceil(n*y/100.0-x))\nif result<0:\n result=0\nprint result\n"}, {"source_code": "import math\nn , x , y = map(int,input().split())\na =((n*y)/100)\nif round(a)>a:\n a=round(a)\nif round(a)=0:\n print(int((a-x)))\nelse:\n print('0')"}, {"source_code": "import math\nfrom bisect import bisect_left,bisect,bisect_right\nfrom itertools import accumulate\n\ndef index(a, x):\n 'Locate the leftmost value exactly equal to x'\n i = bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n raise ValueError\n\ndef find_lt(a, x):\n 'Find rightmost value less than x'\n i = bisect_left(a, x)\n if i:\n return a[i-1]\n raise ValueError\n\ndef find_le(a, x):\n 'Find rightmost value less than or equal to x'\n i = bisect_right(a, x)\n if i:\n return a[i-1]\n raise ValueError\n\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bisect_right(a, x)\n if i != len(a):\n return a[i]\n raise ValueError\n\ndef find_ge(a, x):\n 'Find leftmost item greater than or equal to x'\n i = bisect_left(a, x)\n if i != len(a):\n return a[i]\n raise ValueError\n\n\n\nst=''\n\ndef func(n,x,y):\n return max(0,math.ceil(y*n/100)-x)\n\n\n\n\n\n\n\n\n\n\n\nfor _ in range(1):#int(input())):\n n,a,b=map(int,input().split())\n #n = int(input())\n #inp=input().split()\n #s=input()\n #l1=[]\n #l1=list(map(int,input().split()))\n #l1=list(accumulate(list(map(int,input().split()))))\n #q=int(input())\n #l2 = list(map(int, input().split()))\n #l1=input().split()\n #l2=input().split()\n #func(n,m)\n st+=str(int(func(n,a,b)))+'\\n'\nprint(st)"}, {"source_code": "import math\nn, x, y = map(float, raw_input().split())\ny /= 100.0\nans = n * y - x\nif ans > 0.0:\n print int(math.ceil(ans))\nelse:\n print 0"}, {"source_code": "# your code goes here\n# your code goes here\nx,y,z = map(int,raw_input().split())\nclones = 0\nreqd = 1.0 * x * z / 100\n#print reqd - y\nif y < reqd:\n\tclones = reqd - y\n\tclones = int(clones)\n\tif clones < reqd - y:\n\t\tclones = clones + 1\nprint int(clones)"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nfrom math import ceil\nimport sys\nreadin=sys.stdin.readline\nn,x,y=map(int,readin().split());\nval= int(ceil((y*n/100.0)))-x\nif(val>0):\n\tprint val\nelse:\n\tprint 0\n"}, {"source_code": "from math import ceil\nn,x,y = map(int,input().split())\ntotal_people_need = ceil((float(n)/100) * float(y))\npuppet_need = max(int(total_people_need) - x, 0)\nprint(puppet_need)\n"}, {"source_code": "import math\na,b,c=map(int,input().split())\np=math.ceil((c*a)/100)\nif p<=b:print(0)\nelse:print(p-b)"}, {"source_code": "import math\nn,x,y=map(int,input().strip().split()[:3])\nif x>=(math.ceil(y*n)/100):\n\tprint(0)\nelse:\n\tk=math.ceil((y*n)/100)\n\tp=k-x\n\tprint(p)\n"}, {"source_code": "n,x,y=map(int,input().split())\nprint(max(0,(0--n*y//100)-x))"}, {"source_code": "import math\nn, x, y = map(int, raw_input().split())\nu = math.floor((n * (float(y) / 100) + 0.9999))\nprint(max(0, int(u) - x))\n"}, {"source_code": "n,x,y=list(map(int,input().split()))\nprint(max((int(n*y/100+.99999)-x),0))"}, {"source_code": "import math\ni=lambda :map(int,raw_input().split(\" \"))\na,b,c=i()\nl=(float(a)*c/100)\n#print l\nif l-int(l)>0.0:\n\tl=int(l)+1\n#print l\n\n#print l\nif l<=b:\n\tprint \"0\"\nelse:\n\tprint int(l-b)\n"}, {"source_code": "a,b,c=map(int,input().split())\nd=0\nwhile (b/a)*100=ans:\n print 0\nelse:\n print ans-x"}, {"source_code": "from math import ceil\nn, x, y = [int(x) for x in raw_input().split()]\n\nprint max(int(ceil((y*n-100*x)/100.0)), 0)\n"}, {"source_code": "import math\nn,x,y=map(int,input().split())\ny=math.ceil((y/100)*n)\nif y= 0 else 0"}, {"source_code": "from sys import stdin, stdout\n\nn, x, y = map(int, stdin.readline().split())\n\nif (x / n) * 100 >= y:\n stdout.write('0')\nelse:\n l = 0\n r = n * y\n \n while r - l > 1:\n m = (r + l) // 2\n \n if (x + m) / n * 100 >= y:\n r = m\n else:\n l = m\n \n stdout.write(str(r))"}, {"source_code": "#!/usr/bin/python\n\ndef main():\n\tresult = 0\n\tn, x, y = map(int, raw_input().split())\n\twhile (x/float(n)) < y/100.0:\n\t\tresult, x=result+1, x+1\n\tprint result\n\nif __name__=='__main__':\n\tmain()\n\n\n"}, {"source_code": "import math\nn, x, y = [int(s) for s in input().split(' ')]\n\nc = max(math.ceil(n * (y / 100) - x), 0)\nprint(c)"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint max(0, (n * y + 99) / 100 - x)\n"}, {"source_code": "import math\nn,x,y=map(int,input().split())\nxx=max(0,math.ceil(n*y/100)-x)\nprint(xx)"}, {"source_code": "import sys\n\n(n, x, y) = [int(x) for x in sys.stdin.readline().strip().split()]\n\nprint(max((n*y-1)//100+1-x, 0))\n"}, {"source_code": "n,x,y=map(int,input().split())\nprint(max(0,(0--n*y//100)-x))"}, {"source_code": "import math\nn, x, y = map(int, raw_input().split())\nresult = int(math.ceil(y * n * 1.0 / 100)) - x\nprint result if result > 0 else 0"}, {"source_code": "import math\na,b,c=map(int,input().split())\nprint(math.ceil(-min(0,-a*c/100+b)))"}, {"source_code": "people,wizards,Percent= map(int,(raw_input()).split())\nRequirementPeople=Percent*people/100.0\nif (RequirementPeople%1!=0):RequirementPeople+=1\n\nprint max(int(RequirementPeople-wizards),0)"}, {"source_code": "n=input().split()\nfor i in range(0,len(n)):\n n[i]=int(n[i])\n\nif n[0]/n[1]==100/n[2]:\n print(0)\n exit()\n\ns=n[0]/100\n\nvi=int(s*n[2])\nvf=s*n[2]\nif vi-n[1]<0:\n print(0)\n exit()\nif abs(vf - vi) > 0.000001:\n vi+=1\n\n\n\nprint(vi-n[1])\n"}, {"source_code": "import math\nfrom bisect import bisect_left,bisect,bisect_right\nfrom itertools import accumulate\n\ndef index(a, x):\n 'Locate the leftmost value exactly equal to x'\n i = bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return i\n raise ValueError\n\ndef find_lt(a, x):\n 'Find rightmost value less than x'\n i = bisect_left(a, x)\n if i:\n return a[i-1]\n raise ValueError\n\ndef find_le(a, x):\n 'Find rightmost value less than or equal to x'\n i = bisect_right(a, x)\n if i:\n return a[i-1]\n raise ValueError\n\ndef find_gt(a, x):\n 'Find leftmost value greater than x'\n i = bisect_right(a, x)\n if i != len(a):\n return a[i]\n raise ValueError\n\ndef find_ge(a, x):\n 'Find leftmost item greater than or equal to x'\n i = bisect_left(a, x)\n if i != len(a):\n return a[i]\n raise ValueError\n\n\n\nst=''\n\ndef func(n,x,y):\n return max(0,math.ceil(y*n/100)-x)\n\n\n\n\n\n\n\n\n\n\n\nfor _ in range(1):#int(input())):\n n,a,b=map(int,input().split())\n #n = int(input())\n #inp=input().split()\n #s=input()\n #l1=[]\n #l1=list(map(int,input().split()))\n #l1=list(accumulate(list(map(int,input().split()))))\n #q=int(input())\n #l2 = list(map(int, input().split()))\n #l1=input().split()\n #l2=input().split()\n #func(n,m)\n st+=str(int(func(n,a,b)))+'\\n'\nprint(st)"}, {"source_code": "import math\nn_x_y = list(map(int,input().split()))\nminn = math.ceil((n_x_y[2] / 100) * n_x_y[0])\nreq = minn - n_x_y[1]\nif req < 0 :\n print('0')\nelse:\n print(req)\n"}, {"source_code": "n, x, y = (int(x) for x in input().split())\nprint(max(0, -((100 * x - n * y) // 100)))"}, {"source_code": "import math\nstring = input()\nn, x, y = map(int, string.split())\na = math.ceil(y / 100 * n)\nif a < x:\n print(0)\nelse:\n print(a - x)"}, {"source_code": "n,x,y=map(int,raw_input().split())\nprint-min(0,-n*y/100+x)\n"}, {"source_code": "import math\nn,x,y = [int(x) for x in raw_input().split()]\n\nreq = math.ceil((n*y)/100.0)\nprint (0,int(req-x))[(req-x)>0] \n"}, {"source_code": "import math\nn,x,y=map(int,input().strip().split()[:3])\nif x>=(math.ceil(y*n)/100):\n\tprint(0)\nelse:\n\tk=math.ceil((y*n)/100)\n\tp=k-x\n\tprint(p)\n"}, {"source_code": "n, x, y = map(float, raw_input().split())\nk = 0\nwhile float(y/100) > float(x/n):\n k += 1\n x += 1\nprint k\n"}, {"source_code": "n,x,y=list(map(int,input().split()))\nsam=(y/100)*n\nif int(sam)==sam:\n if x>=sam:\n print(0)\n else:\n print(int(sam)-x)\nelse:\n sam=int(sam)+1\n if x>=sam:\n print(0)\n else:\n print(sam-x)"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nfrom math import ceil\nimport sys\nreadin=sys.stdin.readline\nn,x,y=map(int,readin().split());\nval= int(ceil((y*n/100.0)))-x\nif(val>0):\n\tprint val\nelse:\n\tprint 0\n"}, {"source_code": "I=lambda:map(int, raw_input().split())\nn,x,y=I()\nprint max((n*y+99)/100-x,0)"}, {"source_code": "inp = map(float, raw_input().split())\nres = inp[0]*(inp[2]/100) - inp[1]\na = 1 if res - int(res) > 0 else 0\nprint 0 if res < 0 else int(res + a)"}, {"source_code": "import math\nn,x,y=list(map(int,input().split()))\n\n\na=math.ceil(n*y/100)\n\nif a>x:\n print(a-x)\nelse:\n print(0)\n"}, {"source_code": "import math\n#for _ in range(int(input())):\nn,x,y=map(int,input().split())\nd=math.ceil(n*(y/100))\nif(d>x):\n print(d-x)\nelse:\n print(0)"}, {"source_code": "import sys\nimport math\n\nn, x, y = [int(x) for x in (sys.stdin.readline()).split()]\n\nreq = int(math.ceil(y / 100.0 * n))\n\nif(req - x < 0):\n print(0)\nelse:\n print(req - x)"}, {"source_code": "n, x, y = map(int,input().split())\nimport math\nprint (0 if x>=n*y/100 else math.ceil(n*y/100 - x))"}, {"source_code": "n,x,y=map(int,input().split())\nif (n*y)/100>(n*y)//100:\n reqad=((n*y)//100)+1\nelse:\n reqad=((n*y)//100)\nans=reqad-x\nif ans<0:\n print(0)\nelse:\n print(ans)\n"}, {"source_code": "from sys import stdin\n\nn, x, y = map(int, stdin.readline().split())\nprint max(0, (n * y + 99) / 100 - x)\n"}, {"source_code": "\nimport math\n\na=input()\np=a.split()\nn=float(p[0])\nx=float(p[1])\ny=float(p[2])\n\nout=math.ceil((y/100)*n)\n\nif (int(out-x)>0):\n print (int(out-x))\nelse:\n print (0)\n \n\n\n\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint max((n * y + 99) / 100 - x, 0)"}, {"source_code": "import math\nn, x, y = map(int, input().split())\nans = max(0, math.ceil(y / 100 * n) - x)\nprint(ans)"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint max((n * y + 99) / 100 - x, 0)"}, {"source_code": "from sys import stdin\n\nn, x, y = map(int, stdin.readline().split())\nprint max(0, (n * y + 99) / 100 - x)\n"}, {"source_code": "#coding:utf-8\n#! usr/bin/env python\nimport math\n\nnxy=raw_input()\nn=int(nxy.split(' ')[0])\nx=int(nxy.split(' ')[1])\ny=int(nxy.split(' ')[2])\n\nif 1.0*(x)/n>y*1.0/100:\n print(0)\nelse:\n print int(math.ceil(1.0*(y*n-100*x)/(100)))\n"}, {"source_code": "import math\n\n(n, x, y) = [int(r) for r in input().split()]\nprint(math.ceil(max(0, n * y / 100 - x)))\n"}, {"source_code": "n,x,y=map(int,input().split())\nif (n*y)/100>(n*y)//100:\n reqad=((n*y)//100)+1\nelse:\n reqad=((n*y)//100)\nans=reqad-x\nif ans<0:\n print(0)\nelse:\n print(ans)\n"}, {"source_code": "n,x,y=list(map(int,input().split()))\nsam=(y/100)*n\nif int(sam)==sam:\n if x>=sam:\n print(0)\n else:\n print(int(sam)-x)\nelse:\n sam=int(sam)+1\n if x>=sam:\n print(0)\n else:\n print(sam-x)"}, {"source_code": "import math\nn,x,y=map(float, raw_input().split())\nprint max(int(math.ceil(n * y / 100) - x), 0)"}, {"source_code": "from sys import stdin, stdout\n\nn, x, y = map(int, stdin.readline().split())\n\nif (x / n) * 100 >= y:\n stdout.write('0')\nelse:\n l = 0\n r = n * y\n \n while r - l > 1:\n m = (r + l) // 2\n \n if (x + m) / n * 100 >= y:\n r = m\n else:\n l = m\n \n stdout.write(str(r))"}, {"source_code": "import math\n#for _ in range(int(input())):\nn,x,y=map(int,input().split())\nd=math.ceil(n*(y/100))\nif(d>x):\n print(d-x)\nelse:\n print(0)"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nfrom math import ceil\nimport sys\nreadin=sys.stdin.readline\nn,x,y=map(int,readin().split());\nval= int(ceil((y*n/100.0)))-x\nif(val>0):\n\tprint val\nelse:\n\tprint 0\n"}, {"source_code": "import math\n\nn, x, y = map(int, raw_input().split(\" \"))\nprint max(int(math.ceil((y / 100.0) * n - x)), 0)"}, {"source_code": "from math import ceil\n\nX = list(map(int, input().split()))\nResult = (ceil((X[0] * X[2]) / 100)) - X[1]\nprint(Result if Result > 0 else 0)\n"}], "negative_code": [{"source_code": "n,x,y=map(int,input().split())\nif((y*n)%100!=0):\n print(int(y*n/100)-x+1)\nelse:\n print(int(y*n/100)-x)\n"}, {"source_code": "from math import ceil\nn,x,y=map(int,input().split())\nans=max(0,ceil(y*n//100)-x)\nprint(int(ans))\n"}, {"source_code": "n, x, y = map(int, input().split())\n\nprint(int((y * n + 99) / 100 - x))\nif y * n + 99 / 100 < 0:\n print(0)\n"}, {"source_code": "a,b,c=map(int,raw_input().split())\nprint -(-a*c/100)-b\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\na = float(n)*float(y)/100.0\nc = str(a).split('.')\na = int(a)\nif(int(c[1]) != 0):\n\ta = a+1\nprint a-x\n"}, {"source_code": "n, x, y = map(int, input().split())\n\npeople = n * y / 100\nif not people.is_integer():\n people = int(people) + 1\nelse:\n people = int(people)\n\nprint(people - x)"}, {"source_code": "a,b,c=map(int,input().split())\ng=(c-b/a*100)/(100/a)\nif int(g)!=g:g=int(g)+1\nprint(int(g))if g>0 else print(0)"}, {"source_code": "#!/usr/bin/python\n\nfrom collections import deque\nfrom collections import Counter\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, x, y = ia()\n\nfor p in range(100000):\n if (x + p) * 100 >= y * n: print p; break\n"}, {"source_code": "import math\nn, x, y = map(int, input().split())\n\np = y * n / 100\nprint(math.ceil(p - x))"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nfrom math import ceil\nimport sys\nreadin=sys.stdin.readline\nn,x,y=map(int,readin().split());\nprint int(ceil((y*n/100.0)))-x\n"}, {"source_code": "a, b, c = map(int, input().split())\nprint(a,b,c)"}, {"source_code": "n,w,c = map(int,input().split())\nk = (c*n)/100\nif int(k)!=k:\n k = int(k)+1\nprint(int(k)-w)\n\n"}, {"source_code": "import math\nn, x, y = map(int, input().split())\n\nporc = (y*n)/100\n# print(porc)\nfaltam = math.ceil(porc - x)\nprint(faltam)\n"}, {"source_code": "import math as m\nn=[float(i) for i in input().split()]\nprint(m.ceil(n[0]*(n[2]/100))-int(n[1]))"}, {"source_code": "n, x, y = input().split()\nn, x, y = int(n), int(x), int(y)\npercent = ((y * n) / 100)\nif int(percent) != percent:\n percent += 1\n percent = int(percent)\nprint(int(percent - x))\n"}, {"source_code": "import sys\n\n\nhulp=[int(x) for x in sys.stdin.readline().split()]\n\nn,x,y=hulp[0],hulp[1],hulp[2]\n\ngrens=int(n*1.0/100*y+0.9)\n\n\naantal=max(0,grens-x)\n\nprint aantal\n"}, {"source_code": "n,x,y=list(map(int,input().split()))\nsam=(y/100)*n\nif int(sam)==sam:\n if x>=sam:\n print(0)\n else:\n print(sam-x)\nelse:\n sam=int(sam)+1\n if x>=sam:\n print(0)\n else:\n print(sam-x)"}, {"source_code": "n = input().split()\nx = int(n[1])\ny = int(n[2])\nn = int(n[0])\nt = n -y\nres = n * y / 100\nif not res == round(res):\n res = round(res)+1\n\nres = int(-x +res)\nres = max(res,0)\nprint(res)"}, {"source_code": "import sys\nimport math\nline = [int(x) for x in sys.stdin.readline().split()]\n\ntarget = line[0]*0.01*line[2]\nsoln = math.ceil(target - line[1])\n\nif soln > 0:\n print int(soln)\nelse:\n print 0\n"}, {"source_code": "import math\n\nn, k, p = map(int, input().split())\n\nneed = math.ceil(n*p/100)\n\nprint(need-k)"}, {"source_code": "n,x,y=[int(x) for x in input().strip().split()]\ndef ceil(val):\n\tif int(val)+1>val:\n\t\treturn int(val)+1\n\telse:\n \t\treturn int(val)\nnum = ceil(n*y/100)\ncount = max(0,num-x)\nprint(count)\n\n"}, {"source_code": "from math import ceil\nn,x,y = list(map(int,raw_input().split()))\ny = ceil(n / 100.0 * y)\nif x >= y:\n\tprint 0\nelse:\n\tprint y - x\n"}, {"source_code": "n, x, y = map(int, raw_input().split())\nprint n*y/100-x\n"}, {"source_code": "s=input().split()\nfor i in range(3):\n s[i]=int(s[i])\nv=s[0]/100\nm=round(v*s[2]-s[1])\nif m!=0:\n print(m) \nelse:\n print(m+1) "}, {"source_code": "[n, x, y] = map(int, raw_input().split())\n\nrem = 0\nif (y*n)%100 != 0:\n\trem = 1\nrem = y*n/100 - x + rem\n\nif rem<0:\n\trem = 0"}, {"source_code": "n,w,p=map(int,input().split())\nx=(n*p)/100\nif x%1==0:\n\tprint(int(x-w))\nelse:\n\tprint(int(x)+1-w)"}, {"source_code": "import math\n\nn, k, p = map(int, input().split())\n\nneed = math.ceil(n*p/100)\n\nprint(need-k)"}, {"source_code": "n = input().split()\nx = int(n[1])\ny = int(n[2])\nn = int(n[0])\nt = n -y\nres = n * y / 100\nif not res == round(res):\n res = round(res)+1\n\nres = int(-x +res)\nres = max(res,0)\nprint(res)"}, {"source_code": "n, x, y = map(int, input().split())\n\nprint(int((y * n + 99) / 100 - x))\nif y * n + 99 / 100 < 0:\n print(0)\n"}, {"source_code": "from math import ceil\n\n\nn, x, y = map(int, input().split())\ntotal = n*(y/100)\ntotal = ceil(total)\nprint(total - x)\n\n"}, {"source_code": "a=list(input().split())\nn=int(a[0])\nx=int(a[1])\ny=int(a[2])\nper=(x*100)/n\nprint(per)\ny=y-per\nprint(y)\nif y<=0:\n print(0)\nelse:\n if (y*n/100) - int(y*n/100)==0:\n print(int (y*n/100))\n else:\n print(int((y*n)/100) +1)"}, {"source_code": "import math\nn , x , y = map(int,input().split())\na =((n*y)/100)\nif round(a)>a:\n a=round(a)\nif round(a) y * n: hi = mi\n else : lo = mi\n\nprint mi\n"}, {"source_code": "from math import ceil\n \nn, x, y = map(lambda x: int(x), raw_input().split())\n \nz = ceil(n*y*0.01)\n \nprint z-x if z-x>0 else 0"}, {"source_code": "import math\nn,m,k=[float(z) for z in raw_input().split(' ')]\nsub=0\nans= n*k/100\n\nmad=math.ceil(ans)\n\n\n\nprint int(mad-m)\n\n"}, {"source_code": "x, y, z = map(float, raw_input().split())\npercentagething = z * 0.01\npopulationthatcomes = x * percentagething\ncounter = 0\nif y >= populationthatcomes:\n print 0\n exit()\nelse:\n for x in xrange(10000):\n y += 1\n counter += 1\n if y >= populationthatcomes:\n print counter\n exit()\n"}, {"source_code": "from math import ceil\n\nn, x, y = map(int, input().split())\n\ntot = ceil(n * y / 100)\nprint(tot - x)\n"}, {"source_code": "a=list(input().split())\nn=int(a[0])\nx=int(a[1])\ny=int(a[2])\nper=(x*100)/n\nprint(per)\ny=y-per\nprint(y)\nif y<=0:\n print(0)\nelse:\n if (y*n/100) - int(y*n/100)==0:\n print(int (y*n/100))\n else:\n print(int((y*n)/100) +1)"}, {"source_code": "n,x,y=map(int,input().split())\na=(y*n)\nif (a%100)==0:\n a=a//100\nelse:\n a=a//100+1\nprint(abs(x-a)) "}, {"source_code": "from math import ceil\nn,x,y = map(int,input().split())\np = ceil((n*y)/100)\nif p y * n: hi = mi\n else : lo = mi\n\nprint mi\n"}, {"source_code": "import math as m\nn=[float(i) for i in input().split()]\nprint(m.ceil(n[0]*(n[2]/100))-int(n[1]))"}, {"source_code": "import math\nn,x,y = [int(x) for x in raw_input().split()]\n\nreq = math.ceil((n*y)/100)\nprint req-x \n"}, {"source_code": "import string\nimport math\n\ndef ii():\n ii = []\n for s in string.split(raw_input()):\n ii.append(int(s))\n return ii\n\nii = ii()\n#print ii\na = int(round(ii[0] * ii[2] / 100))\n#print a\nb = ii[1]\nif (a <= b):\n print 0\nelse:\n print a - b"}, {"source_code": "a, b, c = map(int, input().split())\nc/=10\na*=c\nif a%10 > 0:\n a/=10\n round(a)+1\nelse:\n a/=10\n round(a)\n\nprint(a-b)"}, {"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\nn,x,y=rinput()\n\na=y*n/100\n\nif(int(a)==a):\n s=a\nelse:\n s=a+1\n\nprint(int(s-x))"}, {"source_code": "print [(n*y-1)/100+1-x for n,x,y in [[int(c) for c in raw_input().split()]]][0]"}, {"source_code": "import math\nI=lambda:map(int, raw_input().split())\nn,x,y=I()\nprint -min(0, int(math.ceil(-n*y/100.0))+x)"}, {"source_code": "\nimport math\n\na=input()\np=a.split()\nn=float(p[0])\nx=float(p[1])\ny=float(p[2])\n\nout=math.ceil((y/100)*n)\n\n\nprint (int(out-x))\n\n\n"}, {"source_code": "\nn , x , y =map(int,input().strip().split()) \n\nrequi = ((x)/n)*100\n\nif requi < y:\n\tfor c in range(0, 10**4):\n\t\trequi = ((x+ c)/n)*100\n\t\tif requi>=y:\n\t\t\tprint(c)\n\t\t\tbreak\nelse:\n\tprint(0)"}, {"source_code": "from math import ceil\n \nn, x, y = map(lambda x: int(x), raw_input().split())\n \nz = ceil(n*y*0.01)\n \nprint z-x if z-x>0 else 0"}, {"source_code": "a, b, c = map(int, input().split())\nprint(a,b,c)"}, {"source_code": "import math\nn,x,y = map(int,raw_input().split())\ncount = int(math.ceil(y*n*1.0/100))-x\nprint count"}, {"source_code": "import math\n\n\ndata = input().split()\n\n#data = open('inputs.txt', 'r').read().split()\nn = int(data[0])\nx = int(data[1])\ny = int(data[2])\n\n#print(\"%d | %d | %d\"% (n, x, y))\n\ndemo = math.ceil((y*n)/100)\nres = abs(x-demo)\nprint(res)"}, {"source_code": "a, b, c = map(int, input().split())\nc/=100\na*=c\na*=10\nfinals = 0\nif a%10 > 0:\n a/=10\n finals = round(a)+1\nelse:\n a/=10\n finals = round(a)\nif finals <= b:\n finals = 0\n print(finals)\nelse:\n print(finals-b)"}, {"source_code": "n,x,y=map(int,input().split())\nans=y*n/100-x\nif ans<1 and ans>0:\n ans=1\nprint(int(ans))\n"}, {"source_code": "a,b,c=map(int,input().split())\ng=(c-b/a*100)/(100/a)\nif round(g)!=g:g=round(g)+1\nprint(int(g)) if g>0 else print(0)"}, {"source_code": "import math\nn, x, y = map(int, input().split())\n\nporc = (y*n)/100\n# print(porc)\nfaltam = math.ceil(porc - x)\nprint(faltam)\n"}, {"source_code": "import math\na, b, c = map(int, input().split(' '))\nprint(min(math.ceil(a*c/100 - b), 0))\n"}, {"source_code": "import sys\nimport math\nline = [int(x) for x in sys.stdin.readline().split()]\n\ntarget = line[0]*0.01*line[2]\nsoln = math.ceil(target - line[1])\n\nif soln > 0:\n print int(soln)\nelse:\n print 0\n"}, {"source_code": "[n, x, y] = map(int, raw_input().split())\n\nrem = 0\nif (y*n)%100 != 0:\n\trem = 1\nrem = y*n/100 - x + rem\n\nif rem<0:\n\trem = 0"}, {"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\nn,x,y=rinput()\n\na=y*n/100\n\nif(int(a)==a):\n s=a\nelse:\n s=a+1\n\nprint(int(s-x))"}, {"source_code": "def main():\n\tn,x,y=[int(ele) for ele in raw_input().split()]\n\typ=int(float(n*y)/100)\n\tif((n*y)%100!=0):\n\t\typ+=1;\n\tprint yp-x\n\nif __name__==\"__main__\":\n\tmain()\n"}, {"source_code": "from math import ceil\na=list(int(i) for i in raw_input().split(' ',3))\nprint \"%d\" %(ceil((a[2]/100.0)*a[0]-a[1]))\n"}, {"source_code": "n,x,y= map(int,raw_input().split())\nif n*y%100:\n print n*y/100+1-x\nelse:\n print n*y/100-x\n \n\n\n\n\n\n\n\n"}, {"source_code": "import sys\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\nn, x, y = readints()\n\nprint n * y / 100 - x + ( (n * y) % 100 != 0 ) \n"}, {"source_code": "import math\n\nn,x,y = [int(x) for x in raw_input().split()]\n\nprint int(math.ceil(float(y * n)/100.0) - float(x))\n\n"}, {"source_code": "[n, x, y] = map(int, raw_input().split())\n\nrem = 0\nif (y*n)%100 != 0:\n\trem = 1\nprint y*n/100 - x + rem"}, {"source_code": "import math\nn,x,y=map(int,input().split())\ncity=n-x\nper=(y/100)*n\nt=math.ceil(per)\nprint(t-x)\n"}, {"source_code": "import math as m\nn,x,y=map(int,input().split())\nans=m.ceil((n*y)/100)-x\nprint(ans)\n"}, {"source_code": "s=input().split()\nfor i in range(3):\n s[i]=int(s[i])\nif s[0]==10 and s[1]==1 and s[2]==14:\n print(0)\nv=s[0]/100\nm=((v*s[2])-s[1])//1\nprint(int(m))"}, {"source_code": "#coding:utf-8\n#! usr/bin/env python\nimport math\n\nnxy=raw_input()\nn=int(nxy.split(' ')[0])\nx=int(nxy.split(' ')[1])\ny=int(nxy.split(' ')[2])\n\nif 1.0*(x)/n>100*y:\n print 0\nelif y>=100:\n print int(math.ceil(1.0*(y*n-100*x)/(100-y)+1))\nelse:\n print int(math.ceil(1.0*(y*n-100*x)/(y-100)+1))"}, {"source_code": "inp = map(float, raw_input().split())\nprint inp[0]*(inp[2]/100) - inp[1]"}, {"source_code": "n, x, y = (int(x) for x in input().split())\nprint(-((100 * x - n * y) // 100))"}, {"source_code": "from math import *\nn,x,y=map(int,input().split())\nxx=(x*100)/n\nprint(xx)\nyy=y-xx\nz=(yy*n)/100\nprint(ceil(z))\n"}, {"source_code": "n, x, y = map(int, input().split())\nneed = round(n * y / 100) + (round(n*y/100) != n*y/100)\nprint(max(need - x, 0))\n"}, {"source_code": "a, b, c = map(int, input().split())\nc/=100\na*=c\na*=10\nfinals = 0\nif a%10 > 0:\n a/=10\n finals = round(a)+1\nelse:\n a/=10\n finals = round(a)\nif finals <= b:\n finals = 0\n print(finals)\nelse:\n print(finals-b)"}, {"source_code": "import math\nn, x, y = map(int, raw_input().split())\nu = math.floor((n * (float(y) / 100) + 0.9))\nprint(int(u) - x)\n"}, {"source_code": "from math import ceil\nn,x,y=map(int,input().split())\nrew=y*n/100\nprint(ceil(rew)-x)"}, {"source_code": "import math\nn,x,y=map(int,input().split())\nk=(y/100)*n\nk=math.ceil(k)\nprint(abs(k-x))"}, {"source_code": "import math\ndef main():\n\tn,x,y = map(int,input().split())\n\ty = y/100\n\tpeople = n*y\n\t# print(math.ceil(people))\n\tprint(int(math.ceil(people)-x))\n\n\nmain()"}, {"source_code": "import math\nn,m,k=[float(z) for z in raw_input().split(' ')]\nsub=0\nans= n*k/100\n\nmad=math.ceil(ans)\n\n\n\nprint int(mad-m)\n\n"}, {"source_code": "import sys\n\n\nhulp=[int(x) for x in sys.stdin.readline().split()]\n\nn,x,y=hulp[0],hulp[1],hulp[2]\n\ngrens=int(n*1.0/100*y+0.9)\n\n\naantal=grens-x\n\nprint aantal\n"}, {"source_code": "#coding:utf-8\n#! usr/bin/env python\nnxy=raw_input()\nn=int(nxy.split(' ')[0])\nx=int(nxy.split(' ')[1])\ny=int(nxy.split(' ')[2])\n\nif 1.0*(x)/n>y:\n print 0\nelif y>=100:\n print int((y*n-100*x)/(100-y)+1)\nelse:\n print int((y*n-100*x)/(y-100)+1)"}], "src_uid": "7038d7b31e1900588da8b61b325e4299"} {"nl": {"description": "Yet another Armageddon is coming! This time the culprit is the Julya tribe calendar. The beavers in this tribe knew math very well. Smart Beaver, an archaeologist, got a sacred plate with a magic integer on it. The translation from Old Beaverish is as follows: \"May the Great Beaver bless you! May your chacres open and may your third eye never turn blind from beholding the Truth! Take the magic number, subtract a digit from it (the digit must occur in the number) and get a new magic number. Repeat this operation until a magic number equals zero. The Earth will stand on Three Beavers for the time, equal to the number of subtractions you perform!\"Distinct subtraction sequences can obviously get you different number of operations. But the Smart Beaver is ready to face the worst and is asking you to count the minimum number of operations he needs to reduce the magic number to zero.", "input_spec": "The single line contains the magic integer n, 0\u2009\u2264\u2009n. to get 20 points, you need to solve the problem with constraints: n\u2009\u2264\u2009106 (subproblem C1); to get 40 points, you need to solve the problem with constraints: n\u2009\u2264\u20091012 (subproblems C1+C2); to get 100 points, you need to solve the problem with constraints: n\u2009\u2264\u20091018 (subproblems C1+C2+C3). ", "output_spec": "Print a single integer \u2014 the minimum number of subtractions that turns the magic number to a zero.", "sample_inputs": ["24"], "sample_outputs": ["5"], "notes": "NoteIn the first test sample the minimum number of operations can be reached by the following sequence of subtractions: 24\u2009\u2192\u200920\u2009\u2192\u200918\u2009\u2192\u200910\u2009\u2192\u20099\u2009\u2192\u20090 "}, "positive_code": [{"source_code": "def maxEl(n):\n max1=n%10\n while(n):\n tmp=n%10\n if tmp>max1:\n max1=tmp\n n/=10\n return max1\ndef main():\n k,n=0,input()\n while(n):\n n-=maxEl(n)\n k=k+1\n print(k)\nmain()"}, {"source_code": "n = int(input())\ncount = 0\nwhile n != 0:\n d = max(int(i) for i in str(n))\n n = n - d\n count += 1\nprint(count)\n"}, {"source_code": "'''input\n24\n'''\n\n\n\n\n\n\nn = int(raw_input())\n\nans = 0\nwhile n>0:\n m = 0\n temp = n\n while temp>0:\n m = max(m, temp%10)\n temp/=10\n n-=m\n ans += 1\nprint ans\n"}, {"source_code": "n=int(input())\nl=list(str(n))\nn=int(n)\nc=0\nwhile n!=0:\n m=max(list(str(n)))\n n-=int(m)\n c+=1\n\nprint(c)"}, {"source_code": "import math\nimport sys\n\ndef solve(n):\n counter = 0\n while n!=0:\n num = str(n)\n num = set(num)\n max_digit = 0\n for x in num:\n if int(x) > max_digit:\n max_digit = int(x)\n n -= max_digit\n counter += 1\n return counter\n \ndef s():\n n = int(input())\n print(solve(n))\n\ns()\n"}, {"source_code": "def findMax(st):\n a=['0','1','2','3','4','5','6','7','8','9']\n m=a[0]\n for letter in a:\n if letter in st:\n if int(letter)>int(m):\n m=letter\n return int(m)\n\ns=raw_input()\nb=int(s)\ncount=0\nwhile b:\n sub=findMax(s)\n b-=sub\n s=str(b)\n count+=1\nprint count\n \n"}, {"source_code": "\nsums = int(input())\ncount = 0\nwhile sums!=0:\n stringg = str(sums)\n maxi = max(stringg)\n sums = sums - int(maxi)\n count = count + 1\nprint(count)\n\ndef countways(n): \n if (n == 1): \n return 0; \n elif (n % 2 == 0): \n return 1 + countways(n / 2); \n else: \n return 1 + min(countways(n - 1), \n countways(n + 1)); \n \n \n"}, {"source_code": "import functools\n\nMaxn=10000005\n\n@functools.lru_cache(10000)\ndef dp(x, y):\n\tnow = (x,y)\n\t\n\tif (x<10):\n\t\t# return (x || y, x-max(x,y))\n # print(f'x={x} y={y}')\n first = 1 if x or y else 0\n return (first, x-max(x,y))\n \n\tmod=1\n\twhile(mod<=x//10):\n\t\tmod*=10\n\t\n\tmaxDig=x//mod\n\t\n\tpart1=dp(x%mod, max(maxDig,y))\n\tpart2=dp(x-x%mod+part1[1], y)\n\treturn (part1[0]+part2[0], part2[1])\n\n \ndef solve():\n\tn = int(input())\n\tAns=dp(n,0)[0]\n\tprint(Ans)\n \nsolve()\n"}, {"source_code": "\n\nn=input();\n\nco=0\nwhile(n>0):\n\tma='0'\n\ta=str(n);\n\tfor i in a:\n\t\tif(ma0):\n s1=str(n)\n l1=[]\n for i in range (len(s1)):\n l1.append(int(s1[i]))\n n-=max(l1)\n count+=1\nprint(count)"}, {"source_code": "n,k=int(input()),0\nwhile n:n-=int(max(str(n)));k+=1\nprint(k)\n"}, {"source_code": "n = int(input())\n\ncount = 0\nwhile n:\n\tn -= max(list(map(int,str(n))))\n\tcount += 1\n\nprint(count)"}, {"source_code": "n = int(input())\n\ncount = 0\nwhile n:\n\tn -= max(list(map(int,str(n))))\n\tcount += 1\n\nprint(count)"}, {"source_code": "num = int(input())\ncount = 0\nwhile num > 0:\n num -= int(max(list(str(num))))\n count += 1\nprint(count)"}, {"source_code": "n = int(input())\nsteps=0\nwhile n != 0:\n n -= max([int(k) for k in str(n)])\n steps += 1\nprint(steps)"}, {"source_code": "\n\nn = int(raw_input())\n\n\ndef figures(k):\n l = set([])\n while k>0:\n h = k%10\n if h!=0:\n l.add(h)\n k = k//10\n return l\n\n\noper = 0\nnum = n\nwhile num>0:\n figs = figures(num)\n num = num - max(figs) \n oper+=1\n \n \nprint oper\n\n\n"}, {"source_code": "n = input()\nnum = int(n)\ncount=1\nif num==0:\n print(0)\nelse:\n while num >=10 :\n num-= int(max(list(n)))\n count+=1\n n= str(num)\n print(count)\n"}, {"source_code": "c = '0123456789'\nF = {c[a] + c[b]: (c[10 - a + b], 1) if a > b else (c[10 - a], 2) for a in range(1, 10) for b in range(10)}\nfor b in range(1, 10): F['0' + c[b]] = ('0', 1)\nF['00'] = ('0', 0)\n\ndef f(x):\n global F\n if x in F: return F[x]\n a, b, y, s = int(x[0]), int(x[1]), x[2: ], 0\n for i in range(b, a, -1):\n y, d = f(c[i] + y)\n s += d\n for i in range(min(a, b) + 1):\n y, d = f(x[0] + y)\n s += d\n F[x] = ('9' + y, s)\n return F[x]\n\nprint(f('0' + raw_input())[1]) "}, {"source_code": "n=int(input()) \ncount=0\n\nwhile n:\n n -= max(int(i) for i in str(n))\n count += 1\n\nprint (count)"}, {"source_code": "n, counter = int(input()), 0\nwhile n > 0:\n n -= int(max(str(n)))\n counter += 1\n\nprint(counter)\n"}, {"source_code": "s = int(input())\ncnt = 0\nwhile s:\n s -= max(map(int, str(s)))\n cnt += 1\nprint(cnt)"}, {"source_code": "WaitingList = {}\nquickTable = {'5999998': (128206L, 999998L), '5999995': (128206L, 999995L), '29999999999999998': (1141743745619794L, 9999999999999998L), '29999999999999997': (1141743745619794L, 9999999999999997L), '299999997': (12186380L, 99999997L), '699999999999999993': (11379937003843824L, 99999999999999989L), '799999999999999992': (11374851076515692L, 99999999999999992L), '3997': (152L, 997L), '3996': (152L, 996L), '9999995': (111110, 999990L), '9999994': (111110, 999990L), '9999997': (111110, 999990L), '9999996': (111110, 999990L), '9999991': (111110, 999990L), '9999990': (111110, 999990L), '9999993': (111110, 999990L), '9999992': (111110, 999990L), '9999999': (111111, 999999L), '9999998': (111110, 999990L), '999999999999995': (11111111111110L, 99999999999990L), '999999999999994': (11111111111110L, 99999999999990L), '999999999999997': (11111111111110L, 99999999999990L), '999999999999996': (11111111111110L, 99999999999990L), '999999999999991': (11111111111110L, 99999999999990L), '999999999999990': (11111111111110L, 99999999999990L), '999999999999993': (11111111111110L, 99999999999990L), '999999999999992': (11111111111110L, 99999999999990L), '999999999999999': (11111111111111L, 99999999999999L), '999999999999998': (11111111111110L, 99999999999990L), '79999999993': (1173319226L, 9999999993L), '79999999992': (1173319226L, 9999999992L), '298': (16L, 98L), '297': (16L, 97L), '99999': (1111, 9999L), '99998': (1110, 9990L), '595': (16L, 95L), '594': (16L, 94L), '99991': (1110, 9990L), '99990': (1110, 9990L), '99993': (1110, 9990L), '99992': (1110, 9990L), '99995': (1110, 9990L), '99994': (1110, 9990L), '99997': (1110, 9990L), '99996': (1110, 9990L), '799999999993': (11658399705L, 99999999993L), '799999999992': (11658399705L, 99999999992L), '999993': (11110, 99990L), '799999993': (11920380L, 99999993L), '799999992': (11920380L, 99999992L), '899992': (11950L, 99988L), '899993': (11950L, 99989L), '899990': (11950L, 99986L), '899991': (11950L, 99987L), '899996': (11951L, 99996L), '899997': (11951L, 99997L), '899994': (11951L, 99994L), '899995': (11951L, 99995L), '59999999999999995': (1141743745421432L, 9999999999999995L), '899998': (11951L, 99998L), '899999': (11951L, 99995L), '4999995': (128206L, 999995L), '4999996': (128206L, 999996L), '39997': (1412L, 9997L), '39996': (1412L, 9996L), '1999999999999990': (114596681427059L, 999999999999990L), '4999999999999995': (114596681377522L, 999999999999995L), '5999999999999998': (114596681377422L, 999999999999998L), '5999999999999995': (114596681377422L, 999999999999995L), '99999999995': (1111111110L, 9999999990L), '99999999994': (1111111110L, 9999999990L), '99999999997': (1111111110L, 9999999990L), '99999999996': (1111111110L, 9999999990L), '99999999991': (1111111110L, 9999999990L), '99999999990': (1111111110L, 9999999990L), '99999999993': (1111111110L, 9999999990L), '99999999992': (1111111110L, 9999999990L), '99999999999': (1111111111L, 9999999999L), '99999999998': (1111111110L, 9999999990L), '1990': (151L, 990L), '39999999997': (1184533608L, 9999999997L), '39999999996': (1184533608L, 9999999996L), '1999': (152L, 999L), '1998': (152L, 998L), '2999999999998': (116420033353L, 999999999998L), '59999999995': (1184533560L, 9999999995L), '2999999999997': (116420033353L, 999999999997L), '99999999999999': (1111111111111L, 9999999999999L), '99999999999998': (1111111111110L, 9999999999990L), '59999999998': (1184533561L, 9999999998L), '99999999999991': (1111111111110L, 9999999999990L), '99999999999990': (1111111111110L, 9999999999990L), '99999999999993': (1111111111110L, 9999999999990L), '99999999999992': (1111111111110L, 9999999999990L), '99999999999995': (1111111111110L, 9999999999990L), '99999999999994': (1111111111110L, 9999999999990L), '99999999999997': (1111111111110L, 9999999999990L), '99999999999996': (1111111111110L, 9999999999990L), '799999999999993': (11488237895046L, 99999999999993L), '799999999999992': (11488237895046L, 99999999999992L), '5999999999995': (116420032575L, 999999999995L), '5999999998': (119919923L, 999999998L), '5999999995': (119919923L, 999999995L), '699998': (12702L, 99994L), '495': (16L, 95L), '496': (16L, 96L), '699993': (12701L, 99989L), '699996': (12702L, 99992L), '6999993': (124318L, 999989L), '6999996': (124318L, 999992L), '799996': (12335L, 99996L), '6999998': (124318L, 999994L), '799993': (12334L, 99990L), '799992': (12334L, 99989L), '3999999999996': (116420033347L, 999999999996L), '3999999999997': (116420033347L, 999999999997L), '19999999990': (1184533609L, 9999999990L), '5995': (152L, 995L), '5998': (152L, 998L), '8999999999999992': (114041339075461L, 999999999999992L), '8999999999999993': (114041339075462L, 999999999999993L), '8999999999999990': (114041339075461L, 999999999999990L), '8999999999999991': (114041339075461L, 999999999999991L), '8999999999999996': (114041339075462L, 999999999999996L), '8999999999999997': (114041339075462L, 999999999999997L), '8999999999999994': (114041339075462L, 999999999999994L), '8999999999999995': (114041339075462L, 999999999999995L), '29999998': (1245093L, 9999998L), '8999999999999998': (114041339075462L, 999999999999998L), '8999999999999999': (114041339075462L, 999999999999999L), '599999999999998': (11509595783951L, 99999999999998L), '599999999999995': (11509595783951L, 99999999999995L), '397': (16L, 97L), '396': (16L, 96L), '7999996': (121746L, 999996L), '794': (12L, 91L), '793': (12L, 93L), '7999992': (121745L, 999989L), '790': (11L, 84L), '799': (12L, 93L), '798': (12L, 92L), '2999997': (128206L, 999997L), '4999999996': (119919923L, 999999996L), '2999998': (128206L, 999998L), '199999999990': (11731861572L, 99999999990L), '199999999999': (11731861573L, 99999999999L), '199999999998': (11731861573L, 99999999998L), '79999999999999993': (1140782100326788L, 9999999999999993L), '79999999999999992': (1140782100326788L, 9999999999999992L), '599999998': (12186377L, 99999998L), '599999995': (12186377L, 99999995L), '499999999996': (11731861376L, 99999999996L), '499999999995': (11731861376L, 99999999995L), '19999999999': (1184533610L, 9999999999L), '19999999998': (1184533610L, 9999999998L), '49996': (1412L, 9996L), '199999999999999': (11509595796377L, 99999999999999L), '199999999999998': (11509595796377L, 99999999999998L), '199': (16L, 99L), '199999999999990': (11509595796376L, 99999999999990L), '198': (16L, 98L), '399999999999999996': (11381347508922436L, 99999999999999996L), '19999999999990': (1156936611334L, 9999999999990L), '598': (16L, 98L), '19999999999999': (1156936611335L, 9999999999999L), '19999999999998': (1156936611335L, 9999999999998L), '39999997': (1245093L, 9999997L), '599999999995': (11731861376L, 99999999995L), '599995': (13350L, 99995L), '599999999998': (11731861377L, 99999999998L), '190': (15L, 90L), '99999999999999991': (1111111111111110L, 9999999999999990L), '99999999999999990': (1111111111111110L, 9999999999999990L), '99999999999999993': (1111111111111110L, 9999999999999990L), '99999999999999992': (1111111111111110L, 9999999999999990L), '99999999999999995': (1111111111111110L, 9999999999999990L), '99999999999999994': (1111111111111110L, 9999999999999990L), '99999999999999997': (1111111111111110L, 9999999999999990L), '99999999999999996': (1111111111111110L, 9999999999999990L), '99999999999999998': (1111111111111110L, 9999999999999990L), '899999999998': (11557724122L, 99999999998L), '89999992': (1179181L, 9999992L), '89999993': (1179181L, 9999993L), '89999990': (1179180L, 9999986L), '89999991': (1179180L, 9999987L), '89999996': (1179181L, 9999996L), '89999997': (1179181L, 9999993L), '89999994': (1179181L, 9999994L), '89999995': (1179181L, 9999995L), '89999998': (1179181L, 9999994L), '89999999': (1179181L, 9999995L), '899999999999': (11557724122L, 99999999999L), '999999991': (11111110, 99999990L), '999999990': (11111110, 99999990L), '999999993': (11111110, 99999990L), '999999992': (11111110, 99999990L), '999999995': (11111110, 99999990L), '999999994': (11111110, 99999990L), '999999997': (11111110, 99999990L), '999999996': (11111110, 99999990L), '999999999': (11111111, 99999999L), '999999998': (11111110, 99999990L), '599998': (13350L, 99998L), '1999999990': (119919935L, 999999990L), '69999999999999998': (1141508661373664L, 9999999999999994L), '1999999999': (119919936L, 999999999L), '1999999998': (119919935L, 999999998L), '99999996': (1111110, 9999990L), '69999999999999993': (1141508661373664L, 9999999999999989L), '499999995': (12186377L, 99999995L), '399999997': (12186380L, 99999997L), '399999996': (12186380L, 99999996L), '5999999999998': (116420032576L, 999999999998L), '79996': (1252L, 9996L), '79993': (1251L, 9990L), '79992': (1251L, 9989L), '8999990': (118673L, 999986L), '8999991': (118673L, 999987L), '8999992': (118673L, 999988L), '8999993': (118674L, 999993L), '8999994': (118674L, 999994L), '8999995': (118674L, 999995L), '8999996': (118674L, 999996L), '8999997': (118674L, 999997L), '899999999992': (11557724121L, 99999999992L), '899999999993': (11557724121L, 99999999993L), '899999999990': (11557724121L, 99999999990L), '899999999991': (11557724121L, 99999999991L), '899999999996': (11557724121L, 99999999996L), '899999999997': (11557724122L, 99999999997L), '899999999994': (11557724121L, 99999999994L), '899999999995': (11557724121L, 99999999995L), '79999993': (1203760L, 9999993L), '79999992': (1203760L, 9999992L), '79999996': (1203760L, 9999996L), '89999999999999990': (1137483162790268L, 9999999999999990L), '89999999999999991': (1137483162790268L, 9999999999999991L), '89999999999999992': (1137483162790269L, 9999999999999992L), '89999999999999993': (1137483162790269L, 9999999999999993L), '89999999999999994': (1137483162790269L, 9999999999999994L), '89999999999999996': (1137483162790269L, 9999999999999996L), '89999999999999997': (1137483162790269L, 9999999999999997L), '89999999999999998': (1137483162790269L, 9999999999999998L), '89999999999999999': (1137483162790269L, 9999999999999999L), '693': (13L, 93L), '690': (13L, 90L), '696': (13L, 92L), '694': (13L, 90L), '698': (13L, 94L), '699': (14L, 99L), '7999999999999993': (114453706267526L, 999999999999993L), '7999999999999992': (114453706267525L, 999999999999992L), '6999999999999993': (114557500702794L, 999999999999989L), '995': (10, 90L), '994': (10, 90L), '997': (10, 90L), '996': (10, 90L), '991': (10, 90L), '990': (10, 90L), '993': (10, 90L), '992': (10, 90L), '999': (11, 99L), '998': (10, 90L), '19999999999999998': (1141743745619858L, 9999999999999998L), '19999999999999990': (1141743745619857L, 9999999999999990L), '299998': (13350L, 99998L), '49995': (1412L, 9995L), '59999999999999998': (1141743745421432L, 9999999999999998L), '4999999995': (119919923L, 999999995L), '699999999999993': (11503065671512L, 99999999999989L), '299999999999999997': (11381347508923894L, 99999999999999997L), '4999999999999996': (114596681377522L, 999999999999996L), '19990': (1411L, 9990L), '699999999999998': (11503065671513L, 99999999999994L), '1999990': (128205L, 999990L), '299997': (13350L, 99997L), '3999999997': (119919935L, 999999997L), '19999990': (1245092L, 9999990L), '19999999': (1245093L, 9999999L), '19999998': (1245093L, 9999998L), '39999999999997': (1156936611309L, 9999999999997L), '39999999999996': (1156936611309L, 9999999999996L), '299999998': (12186380L, 99999998L), '9999999999': (111111111, 999999999L), '9999999998': (111111110, 999999990L), '9999999991': (111111110, 999999990L), '9999999990': (111111110, 999999990L), '9999999993': (111111110, 999999990L), '9999999992': (111111110, 999999990L), '999995': (11110, 99990L), '9999999994': (111111110, 999999990L), '9999999997': (111111110, 999999990L), '9999999996': (111111110, 999999990L), '899999990': (11723747L, 99999990L), '899999991': (11723748L, 99999991L), '899999992': (11723748L, 99999992L), '6999999993': (119080145L, 999999989L), '899999994': (11723748L, 99999994L), '899999995': (11723748L, 99999995L), '899999996': (11723748L, 99999996L), '899999997': (11723748L, 99999997L), '899999998': (11723748L, 99999998L), '899999999': (11723748L, 99999999L), '69996': (1304L, 9992L), '69993': (1303L, 9989L), '59995': (1412L, 9995L), '49999999995': (1184533560L, 9999999995L), '49999999996': (1184533560L, 9999999996L), '69998': (1304L, 9994L), '1999999999990': (116420033356L, 999999999990L), '1999999999999': (116420033357L, 999999999999L), '1999999999998': (116420033357L, 999999999998L), '3999997': (128206L, 999997L), '3999996': (128206L, 999996L), '7993': (126L, 990L), '7992': (126L, 989L), '7996': (127L, 996L), '7994': (126L, 988L), '7998': (127L, 998L), '399997': (13350L, 99997L), '399996': (13350L, 99996L), '69999998': (1221765L, 9999994L), '69999993': (1221764L, 9999989L), '899999999999990': (11436691996038L, 99999999999990L), '899999999999991': (11436691996038L, 99999999999991L), '899999999999992': (11436691996038L, 99999999999992L), '899999999999993': (11436691996038L, 99999999999993L), '899999999999994': (11436691996039L, 99999999999994L), '899999999999995': (11436691996039L, 99999999999995L), '899999999999996': (11436691996039L, 99999999999996L), '899999999999997': (11436691996039L, 99999999999997L), '899999999999998': (11436691996039L, 99999999999998L), '899999999999999': (11436691996039L, 99999999999999L), '499999996': (12186377L, 99999996L), '999999': (11111, 99999L), '599999999999999998': (11381347508130432L, 99999999999999998L), '999998': (11110, 99990L), '499999999999999995': (11381347508132932L, 99999999999999995L), '399999999999997': (11509595796307L, 99999999999997L), '399999999999996': (11509595796307L, 99999999999996L), '8999999999990': (115130628208L, 999999999990L), '8999999999991': (115130628208L, 999999999991L), '8999999999992': (115130628208L, 999999999992L), '8999999999993': (115130628208L, 999999999993L), '8999999999994': (115130628208L, 999999999994L), '8999999999995': (115130628208L, 999999999995L), '8999999999996': (115130628209L, 999999999996L), '8999999999997': (115130628209L, 999999999997L), '8999999999998': (115130628209L, 999999999998L), '8999999999999': (115130628209L, 999999999999L), '890': (11L, 90L), '891': (11L, 89L), '892': (11L, 90L), '893': (11L, 89L), '894': (11L, 90L), '895': (11L, 89L), '896': (11L, 90L), '897': (12L, 97L), '898': (12L, 98L), '899': (12L, 99L), '999991': (11110, 99990L), '699999998': (12046414L, 99999994L), '999990': (11110, 99990L), '699999993': (12046414L, 99999989L), '99999999': (1111111, 9999999L), '99999998': (1111110, 9999990L), '999992': (11110, 99990L), '99999990': (1111110, 9999990L), '99999991': (1111110, 9999990L), '9999999995': (111111110, 999999990L), '99999993': (1111110, 9999990L), '99999992': (1111110, 9999990L), '99999995': (1111110, 9999990L), '99999994': (1111110, 9999990L), '99999997': (1111110, 9999990L), '999994': (11110, 99990L), '49999996': (1245092L, 9999996L), '49999995': (1245092L, 9999995L), '999997': (11110, 99990L), '999996': (11110, 99990L), '699999999998': (11701629374L, 99999999994L), '3999999996': (119919935L, 999999996L), '699999999993': (11701629373L, 99999999989L), '59999999999995': (1156936608221L, 9999999999995L), '69999999993': (1179494892L, 9999999989L), '1999999': (128206L, 999999L), '1999998': (128206L, 999998L), '69999999998': (1179494893L, 9999999994L), '59999999999998': (1156936608221L, 9999999999998L), '89999999999992': (1147286764991L, 9999999999992L), '89999999999993': (1147286764991L, 9999999999993L), '89999999999990': (1147286764991L, 9999999999990L), '89999999999991': (1147286764991L, 9999999999991L), '89999999999996': (1147286764992L, 9999999999996L), '89999999999997': (1147286764992L, 9999999999997L), '89999999999994': (1147286764991L, 9999999999994L), '89999999999995': (1147286764992L, 9999999999995L), '89999999999998': (1147286764992L, 9999999999998L), '89999999999999': (1147286764992L, 9999999999999L), '299999999999997': (11509595796361L, 99999999999997L), '1999999999999999': (114596681427060L, 999999999999999L), '1999999999999998': (114596681427060L, 999999999999998L), '899999999999999991': (11348459576223540L, 99999999999999991L), '299999999999998': (11509595796361L, 99999999999998L), '2998': (152L, 998L), '6998': (134L, 994L), '6999': (134L, 995L), '59999995': (1245092L, 9999995L), '6996': (134L, 992L), '6990': (133L, 986L), '6993': (133L, 989L), '29998': (1412L, 9998L), '399999999997': (11731861569L, 99999999997L), '399999999996': (11731861568L, 99999999996L), '29997': (1412L, 9997L), '3999999999999997': (114596681426866L, 999999999999997L), '3999999999999996': (114596681426866L, 999999999999996L), '6999999999993': (116238640562L, 999999999989L), '29999997': (1245093L, 9999997L), '6999999999998': (116238640563L, 999999999994L), '2997': (152L, 997L), '89999999990': (1160734778L, 9999999990L), '89999999991': (1160734778L, 9999999991L), '89999999992': (1160734778L, 9999999992L), '89999999993': (1160734778L, 9999999993L), '89999999994': (1160734778L, 9999999994L), '89999999995': (1160734778L, 9999999995L), '89999999996': (1160734778L, 9999999996L), '89999999997': (1160734778L, 9999999997L), '89999999998': (1160734779L, 9999999998L), '89999999999': (1160734779L, 9999999999L), '499999999999995': (11509595783971L, 99999999999995L), '9999': (111, 999L), '9998': (110, 990L), '9991': (110, 990L), '9990': (110, 990L), '9993': (110, 990L), '9992': (110, 990L), '9995': (110, 990L), '9994': (110, 990L), '9997': (110, 990L), '9996': (110, 990L), '299999999998': (11731861571L, 99999999998L), '199999999': (12186380L, 99999999L), '199999998': (12186380L, 99999998L), '299999999997': (11731861571L, 99999999997L), '2999999997': (119919935L, 999999997L), '2999999999999997': (114596681427028L, 999999999999997L), '2999999999999998': (114596681427028L, 999999999999998L), '2999999998': (119919935L, 999999998L), '9999999999999': (111111111111L, 999999999999L), '9999999999998': (111111111110L, 999999999990L), '6999999999999998': (114557500702794L, 999999999999994L), '9999999999991': (111111111110L, 999999999990L), '9999999999990': (111111111110L, 999999999990L), '9999999999993': (111111111110L, 999999999990L), '9999999999992': (111111111110L, 999999999990L), '9999999999995': (111111111110L, 999999999990L), '9999999999994': (111111111110L, 999999999990L), '9999999999997': (111111111110L, 999999999990L), '9999999999996': (111111111110L, 999999999990L), '899999993': (11723748L, 99999993L), '199999990': (12186379L, 99999990L), '39999999999999997': (1141743745619308L, 9999999999999997L), '39999999999999996': (1141743745619308L, 9999999999999996L), '29999999999998': (1156936611327L, 9999999999998L), '6999999998': (119080145L, 999999994L), '49999999999999995': (1141743745421932L, 9999999999999995L), '29999999997': (1184533608L, 9999999997L), '49999999999999996': (1141743745421932L, 9999999999999996L), '199999999999999998': (11381347508924022L, 99999999999999998L), '39999996': (1245092L, 9999996L), '59998': (1412L, 9998L), '89990': (1203L, 9990L), '89991': (1203L, 9987L), '89992': (1203L, 9988L), '89993': (1203L, 9989L), '89994': (1203L, 9990L), '89995': (1204L, 9995L), '89996': (1204L, 9996L), '89997': (1204L, 9997L), '89998': (1204L, 9998L), '89999': (1204L, 9999L), '7999999999993': (115936032880L, 999999999993L), '7999999999992': (115936032880L, 999999999992L), '8999999998': (116624851L, 999999998L), '8999999999': (116624852L, 999999999L), '8999999992': (116624851L, 999999992L), '8999999993': (116624851L, 999999993L), '8999999990': (116624851L, 999999990L), '8999999991': (116624851L, 999999991L), '8999999996': (116624851L, 999999996L), '8999999997': (116624851L, 999999997L), '8999999994': (116624851L, 999999994L), '8999999995': (116624851L, 999999995L), '8999998': (118674L, 999994L), '8999999': (118674L, 999995L), '19999': (1412L, 9999L), '19998': (1412L, 9998L), '199990': (13349L, 99990L), '49999999999995': (1156936608225L, 9999999999995L), '199999': (13350L, 99999L), '199998': (13350L, 99998L), '69999999999998': (1155848256148L, 9999999999994L), '69999999999993': (1155848256147L, 9999999999989L), '4996': (152L, 996L), '4999999999995': (116420032575L, 999999999995L), '499996': (13350L, 99996L), '79999999999993': (1153730002367L, 9999999999993L), '499995': (13350L, 99995L), '79999999999992': (1153730002367L, 9999999999992L), '9999999999999999': (111111111111111L, 999999999999999L), '9999999999999998': (111111111111110L, 999999999999990L), '499999999999996': (11509595783971L, 99999999999996L), '29999999999997': (1156936611327L, 9999999999997L), '7999999993': (118197907L, 999999993L), '7999999992': (118197907L, 999999992L), '796': (12L, 93L), '9999999999999991': (111111111111110L, 999999999999990L), '9999999999999990': (111111111111110L, 999999999999990L), '9999999999999993': (111111111111110L, 999999999999990L), '9999999999999992': (111111111111110L, 999999999999990L), '9999999999999995': (111111111111110L, 999999999999990L), '9999999999999994': (111111111111110L, 999999999999990L), '9999999999999997': (111111111111110L, 999999999999990L), '9999999999999996': (111111111111110L, 999999999999990L), '49999999999996': (1156936608225L, 9999999999996L), '29999999998': (1184533609L, 9999999998L), '7999993': (121746L, 999993L), '792': (12L, 92L), '8998': (121L, 998L), '8999': (121L, 997L), '59999998': (1245093L, 9999998L), '8992': (120L, 988L), '8993': (120L, 989L), '8990': (120L, 988L), '8991': (120L, 989L), '8996': (121L, 996L), '8997': (121L, 997L), '8994': (120L, 988L), '8995': (120L, 989L), '999999999999': (11111111111L, 99999999999L), '999999999998': (11111111110L, 99999999990L), '4999999999996': (116420032576L, 999999999996L), '4995': (152L, 995L), '999999999991': (11111111110L, 99999999990L), '999999999990': (11111111110L, 99999999990L), '999999999993': (11111111110L, 99999999990L), '999999999992': (11111111110L, 99999999990L), '999999999995': (11111111110L, 99999999990L), '999999999994': (11111111110L, 99999999990L), '999999999997': (11111111110L, 99999999990L), '999999999996': (11111111110L, 99999999990L)}\n\ndef calc(x):\n\tans = 0\n\twhile x > 0:\n\t\tt = \"0\" + str(x)\n\t\tp = len(t)-2\n\t\twhile(str(t)[p] == '9'):\n\t\t\tp -= 1\n\t\thead = str(t)[:p+1]\n\t\ttail = str(t)[p+1:]\n\t\timportant = max(head) + tail\n\n\t\tif not important in quickTable:\n\t\t\tWaitingList[(head, len(tail))] = (ans, x, max(head) + tail)\n\t\tif x == 123:\n\t\t\tprint (head, len(tail))\n\n\t\tt = \"0\" + str(x)\n\t\tp = len(t)-2\n\t\twhile p > 0:\n\t\t\thead = str(t)[:p+1]\n\t\t\ttail = str(t)[p+1:]\n\t\t\tif x == 123:\n\t\t\t\tprint \"->\", (head, len(tail))\n\t\t\tif (head, len(tail)) in WaitingList:\n\t\t\t\tlastAns, lastX, imp = WaitingList[(head, len(tail))]\n\t\t\t\tif x != lastX:\n\t\t\t\t\tquickTable[imp] = (ans - lastAns, lastX - x)\n\t\t\tp -= 1\n\n\n\t\tif important in quickTable:\n\t\t\tusedSteps, to = quickTable[important]\n\t\t\tans += usedSteps\n\t\t\tx -= to\n\t\telse:\n\t\t\tans += 1\n\t\t\tx -= int(max(str(x)))\n\treturn ans\n\nx = eval(raw_input())\nprint calc(x)\n"}, {"source_code": "dp = [0] * 1000005\nfor i in range(1, 10):\n dp[i] = 1\n\nfor i in range(10, 1000001):\n minx = 10000000\n for j in str(i):\n if j != '0':\n minx = min(minx, dp[i-int(j)]+1)\n \n dp[i] = minx\n\nprint(dp[int(input())])"}, {"source_code": "import functools\n\nMaxn=10000005\n\n@functools.lru_cache(10000)\ndef dp(x, y):\n\tnow = (x,y)\n\t\n\tif (x<10):\n\t\t# return (x || y, x-max(x,y))\n # print(f'x={x} y={y}')\n first = 1 if x or y else 0\n return (first, x-max(x,y))\n \n\tmod=1\n\twhile(mod<=x//10):\n\t\tmod*=10\n\t\n\tmaxDig=x//mod\n\t\n\tpart1=dp(x%mod, max(maxDig,y))\n\tpart2=dp(x-x%mod+part1[1], y)\n\treturn (part1[0]+part2[0], part2[1])\n\n \ndef solve():\n\tn = int(input())\n\tAns=dp(n,0)[0]\n\tprint(Ans)\n \nsolve()\n"}, {"source_code": "n = int(input())\ncount = 0\n\nwhile n:\n n -= int(max(str(n)));\n count += 1\n\nprint(count)"}, {"source_code": "n,k=int(input()),0\nwhile n:\n n-=int(max(str(n)))\n k+=1\nprint(k)\n#python ki jai ho :p"}, {"source_code": "\n \n\n\nn = int(input())\ns=0\n\nwhile n!=0:\n u = list(str(n))\n u.sort()\n n-=int(u[-1])\n s+=1\n\nprint(s)\n"}, {"source_code": "n = int(input())\n\ndef naive(n):\n\tc=0\n\t#print(n,end='\\t')\n\twhile n!=0:\n\t\tc+=1\n\t\tn-=max([int(x) for x in list(str(n))])\n\t\t#print(n)\n\tprint(c)\n\n# d=dict()\n# d[0]=0\n# def dp(n):\n# \tif(n==0):\n# \t\treturn 0\n# \ts=[int(x) for x in list(str(n))]\n# \tminimo=n\n# \ts=max(s)\n# \ttemp = n - s\n# \treturn dp(temp)+1\n\n# for x in range(1,10,1):\n# \tnaive(x)\n# for x in range(10,100,10):\n# \tnaive(x)\n# for x in range(100,1000,100):\n# \tnaive(x)\n# for x in range(1000,10000,1000):\n# \tnaive(x)\n# for x in range(5000,6000,100):\n# \tnaive(x)\n\nnaive(n)"}, {"source_code": "import math\nimport sys\ninput = sys.stdin.readline\nn = int(input())\nopt = 0\nwhile n != 0:\n n -= int(max(list(str(n))))\n opt += 1\nprint(opt)"}, {"source_code": "a=input()\na=list(a)\ncount=0\nwhile int(''.join(a))>0:\n k=max(a)\n a=int(''.join(a))-int(k)\n a=str(a)\n count+=1\n a=list(a)\nprint(count)\n \n"}, {"source_code": "dp = [0] * 1000005\nfor i in range(1, 10):\n dp[i] = 1\n\nfor i in range(10, 1000001):\n minx = 10000000\n for j in str(i):\n if j != '0':\n minx = min(minx, dp[i-int(j)]+1)\n \n dp[i] = minx\n\nprint(dp[int(input())])"}, {"source_code": "n,k=int(input()),0\nwhile n:n-=int(max(str(n)));k+=1\nprint(k)\n"}, {"source_code": "n=int(input())\ndef ispres(num):\n dig=0\n m=num\n while m>0:\n d=m%10\n dig=max(dig,d)\n m=m//10\n return dig\ndp=[999999 for _ in range(n+1)]\n\ndp[n-ispres(n)]=1\nif n==0:\n print(0)\n exit(0)\nfor i in range(n,-1,-1):\n k=ispres(i)\n\n if i-k>=0:\n\n dp[i-k]=min(dp[i-k],dp[i]+1)\n\nif dp[0]==999999:\n print(0)\n exit(0)\nprint(dp[0])\n"}, {"source_code": "def gd(x):\n\treturn max(map(int, list(str(x))))\n\ndef next(mmax, x):\n\tfor i in range(x+1,x+10):\n\t\tif i-max(mmax, gd(i)) >= x:\n\t\t\treturn i\n\nmemo = {}\n\ndef f(mmax, nn, pad):\n\t\n\tkey = (mmax, nn, pad)\n\tif key in memo:\n\t\treturn memo[key]\n\t\n\torpad = pad\n\t\n\tif nn == 1:\n\t\tstart = pad\n\t\tlast = start\n\t\tend = 9\n\t\ttot = 1\n\t\tfor i in range(start+1, end+1):\n\t\t\tif i-max(mmax, gd(i)) >= last:\n\t\t\t\tlast = i\n\t\t\t\ttot += 1\n\n\t\tans = (tot, last%10)\n\n\telse:\n\t\ttot = 0\n\t\tlr = 9\n\t\tfor d in range(lr+1):\n\t\t\tt, lastbeg = f(max(mmax, d), nn-1, pad)\n\t\t\tlastbeg += d*(10**(nn-1))\n\t\t\ttot += t\n\t\t\tpad = ( next(mmax, lastbeg) ) % 10\n\t\t\n\t\tans = (tot, lastbeg)\n\n\tmemo[key] = ans\n\t#~ print \"f(%d, %d, %d) = (%d, %d)\" % (mmax, nn, orpad, ans[0], ans[1])\n\treturn ans\n\nN = input()\nnn = len(str(N))\ndig = [0] + map(int,list(str(N)[::-1]))\n\ndef g(mmax, nn, pad):\n\t#~ print \"**\", mmax, nn, pad\n\ttot = 0\n\tif nn == 1:\n\t\tstart = pad\n\t\tlast = start-10\n\t\tend = dig[nn]\n\t\ttot = 0\n\t\tfor i in range(start, end+1):\n\t\t\tif i-max(mmax, gd(i)) >= last:\n\t\t\t\tlast = i\n\t\t\t\ttot += 1\n\t\treturn tot\n\t\t\n\telse:\n\t\tfor d in range(dig[nn]):\n\t\t\tt, lastbeg = f(max(mmax, d), nn-1, pad)\n\t\t\tlastbeg += d*(10**(nn-1))\n\t\t\ttot += t\n\t\t\tpad = ( next(mmax, lastbeg) ) % 10\n\t\treturn tot + g(max(mmax, dig[nn]), nn-1, pad)\n\t\t\n\nf(0, nn, 0)\nprint g(0, nn, 0)-1\n"}, {"source_code": "num=int(input())\nans=0\nwhile(num!=0):\n L=list(str(num))\n d=int(max(L))\n num-=d\n ans+=1\nprint(ans)\n"}, {"source_code": "import sys\ndef calc(n):\n global cnt\n if n == 0:\n return 0\n elif n < 10:\n cnt += 1\n return 0\n else:\n digit = '0'\n for dig in str(n):\n if dig > digit:\n digit = dig\n digit = int(digit)\n #print '!!!=' + str(digit)\n \n cnt += 1\n return n-digit\n \ndef calcMin(n):\n if n == 0:\n return 0\n elif n < 10:\n return 1\n elif n < 100:\n d1 = n / 10\n d2 = n % 10\n \n else:\n return 'hz'\ndef solve(n):\n #return calcMin(n)\n #data = {}\n global cnt\n cnt = 0\n while True:\n n = calc(n)\n if n==0:\n break\n return cnt\n\nn = int(sys.stdin.readline())\n\nprint solve(n)\n"}, {"source_code": "def maxEl(n):\n max1=n%10\n while(n):\n tmp=n%10\n if tmp>max1:\n max1=tmp\n n/=10\n return max1\ndef main():\n k,n=0,input()\n while(n):\n n-=maxEl(n)\n k=k+1\n print(k)\nmain()"}, {"source_code": "num = int(input())\n\ncount = 0\nwhile num != 0:\n lst = [int(i) for i in str(num)]\n num -= max(lst)\n count += 1\n\nprint(count)"}, {"source_code": "mem = {}\n\ndef compute_count(pmax, re):\n global mem\n ore = re\n\n if (pmax, re) in mem:\n return mem[(pmax, re)] \n\n numdig = len(str(re))\n\n if numdig == 1:\n mem[(pmax, ore)] = 1, min(0, re-pmax) \n return 1, min(0, re-pmax) \n\n sc = 0\n while re > 0:\n s = str(re).zfill(numdig)\n nmax = max(pmax, int(s[0])) \n newre = int(s[1:])\n cnt, left = compute_count(nmax, newre) \n\n sc += cnt \n re -= newre\n re += left\n\n mem[(pmax, ore)] = sc, re\n return sc, re\nx=int(input())\nif x:\n print(compute_count(0,x )[0])\nelse:\n print(0)\n\n \n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Sep 17 01:20:34 2020\n\n@author: Dark Soul\n\"\"\"\nn=int(input(''))\ndef maxdig(n):\n s=-1\n while n:\n s=max(s,n%10)\n n=n//10\n return s\nsol=0\nwhile n:\n sol+=1\n n-=maxdig(n)\nprint(sol)\n "}, {"source_code": "n = input()\ntmp = int(n)\ni = 0\nwhile tmp != 0:\n sub = max([int(x) for x in str(tmp)])\n tmp -= sub\n #print(tmp)\n i += 1\nprint(i)"}, {"source_code": "s = int(input())\ncnt = 0\nwhile s:\n s -= max(map(int, str(s)))\n cnt += 1\nprint(cnt)"}, {"source_code": "n = int(input())\nif 10 > n > 0:\n print(1)\n exit(0)\nelif n == 0:\n print(0)\n exit(0)\ndp = [2 for i in range(n)]\ndp[0] = n\nz = 1\nwhile True:\n dp[z] = dp[z-1] - int(max(str(dp[z-1])))\n if dp[z] == 0:\n break\n z = z + 1\nprint(z)"}, {"source_code": "n = int(input())\n\ndef maxDigit(a):\n x = 9\n while x > 0:\n if str(x) in str(a):\n return x\n else:\n x -= 1\n return 0\n\nmemo = 0\nwhile n != 0:\n n = n - maxDigit(n)\n memo += 1\n\nprint(memo)"}, {"source_code": "n,k=int(input()),0\nwhile n:n-=int(max(str(n)));k+=1\nprint(k)\n"}, {"source_code": "n, k = int(input()), 0\n\nwhile n:\n n, k = n - int(max(str(n))), k + 1\n\nprint(k)"}, {"source_code": "n = int(input())\n\ndef maxDigit(a):\n x = 9\n while x > 0:\n if str(x) in str(a):\n return x\n else:\n x -= 1\n return 0\n\nmemo = 0\nwhile n != 0:\n n = n - maxDigit(n)\n memo += 1\n\nprint(memo)"}, {"source_code": "\n# n = 24\ndef get_subs(n):\n count = 0\n while n != '0':\n digits = [int(i) for i in n]\n max_digit = max(digits)\n n = int(n) - max_digit\n n = str(n)\n count += 1\n return count\n\n\n\n\nif __name__ == '__main__':\n n = input()\n print(get_subs(n))\n"}, {"source_code": "t = int(input())\nc = 0\nwhile t!=0:\n c+=1\n t = t-int(max(str(t)))\nprint(c)\n"}, {"source_code": "from sys import stdin\ninput_ = stdin.readline\nmagic_num = input_()\noperations = 0\ni = 0\nwhile(i < int(magic_num)):\n if magic_num == 0:\n break\n max_num = max({int(x) for x in str(magic_num).strip()})\n magic_num = int(magic_num) - max_num\n operations += 1\n \n\n\nprint(operations)\n "}, {"source_code": "m = int(input())\na = 0\nwhile(m > 0):\n m -= int(max([int(i) for i in str(m)]))\n a += 1\nprint(a)\n"}, {"source_code": "#\t!/bin/env python3\n#\tcoding: UTF-8\n\n\n#\t\u272a H4WK3yE\u4e61\n#\tMohd. Farhan Tahir\n#\tIndian Institute Of Information Technology and Management,Gwalior\n\n#\tQuestion Link\n#\thttps://codeforces.com/problemset/problem/331/C1\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 recurse(n):\n dp = [inf for _ in range(1000005)]\n for i in range(10):\n dp[i] = 1\n for i in range(10, 1000001):\n x = i\n while x > 0:\n r = x % 10\n x //= 10\n if r > 0:\n dp[i] = min(dp[i], dp[i-r]+1)\n return dp[n]\n\n\ndef main():\n n = int(input())\n if n == 0:\n print(0)\n return\n print(recurse(n))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def gd(x):\n\treturn max(map(int, list(str(x))))\n\ndef next(mmax, x):\n\tfor i in range(x+1,x+10):\n\t\tif i-max(mmax, gd(i)) >= x:\n\t\t\treturn i\n\nmemo = {}\n\ndef f(mmax, nn, pad):\n\t\n\tkey = (mmax, nn, pad)\n\tif key in memo:\n\t\treturn memo[key]\n\t\n\torpad = pad\n\t\n\tif nn == 1:\n\t\tstart = pad\n\t\tlast = start\n\t\tend = 9\n\t\ttot = 1\n\t\tfor i in range(start+1, end+1):\n\t\t\tif i-max(mmax, gd(i)) >= last:\n\t\t\t\tlast = i\n\t\t\t\ttot += 1\n\n\t\tans = (tot, last%10)\n\n\telse:\n\t\ttot = 0\n\t\tlr = 9\n\t\tfor d in range(lr+1):\n\t\t\tt, lastbeg = f(max(mmax, d), nn-1, pad)\n\t\t\tlastbeg += d*(10**(nn-1))\n\t\t\ttot += t\n\t\t\tpad = ( next(mmax, lastbeg) ) % 10\n\t\t\n\t\tans = (tot, lastbeg)\n\n\tmemo[key] = ans\n\t#~ print \"f(%d, %d, %d) = (%d, %d)\" % (mmax, nn, orpad, ans[0], ans[1])\n\treturn ans\n\nN = input()\nnn = len(str(N))\ndig = [0] + map(int,list(str(N)[::-1]))\n\ndef g(mmax, nn, pad):\n\t#~ print \"**\", mmax, nn, pad\n\ttot = 0\n\tif nn == 1:\n\t\tstart = pad\n\t\tlast = start-10\n\t\tend = dig[nn]\n\t\ttot = 0\n\t\tfor i in range(start, end+1):\n\t\t\tif i-max(mmax, gd(i)) >= last:\n\t\t\t\tlast = i\n\t\t\t\ttot += 1\n\t\treturn tot\n\t\t\n\telse:\n\t\tfor d in range(dig[nn]):\n\t\t\tt, lastbeg = f(max(mmax, d), nn-1, pad)\n\t\t\tlastbeg += d*(10**(nn-1))\n\t\t\ttot += t\n\t\t\tpad = ( next(mmax, lastbeg) ) % 10\n\t\treturn tot + g(max(mmax, dig[nn]), nn-1, pad)\n\t\t\n\nf(0, nn, 0)\nprint g(0, nn, 0)-1\n"}, {"source_code": "def dsolve(m):\n\n memo = {0: 0}\n\n def solve(k):\n l = len(str(k))\n if k in memo.keys():\n return memo[k]\n elif len(str(k)) == 1:\n memo[k] = 1\n return 1\n else:\n p = 1 + min([solve(k - int(c)) for c in str(k) if int(c)])\n memo[k] = p\n return p\n\n for i in range(m + 1):\n solve(i)\n\n return memo[m]\n\n\nn = int(input())\nprint(dsolve(n))\n\n"}, {"source_code": "# https://codeforces.com/problemset/problem/331/C1\n\nimport math\n\n\ndef to_digits(n):\n return [int(d) for d in str(n)]\n\n\ndef to_integer(digits):\n accum = 0\n factor = 1\n for d in reversed(digits):\n accum += factor * d\n factor *= 10\n\n return accum\n\n\ndef split(digits):\n d = 0\n index = 0\n for i in range(len(digits)):\n if digits[i] >= d:\n d = digits[i]\n index = i\n\n # print(str(d) + \" \" + str(digits[index:]))\n return (d, digits[i:])\n\n\nmemoize = {}\n\n\ndef num(x):\n y = 0\n while x > 0:\n digits = to_digits(x)\n d, r = split(digits)\n rint = to_integer(r)\n n = rint // d\n mod = rint % d\n if mod == 0 and n != 0:\n n = n\n elif rint < d or d < rint:\n n = n + 1\n\n y += n\n x = x - n * d\n\n return y\n\n\nx = int(input())\nprint(num(x))\n"}, {"source_code": "num = int(input())\ncount = 0\nwhile num > 0:\n num -= int(max(list(str(num))))\n count += 1\nprint(count)"}, {"source_code": "n = int(input())\nans = 0\nwhile n>0:\n i = n\n s = 0\n while i>0:\n s = max(s,i%10)\n i=i//10\n ans+=1\n n-=s\n\nprint(ans)"}, {"source_code": "s = int(input())\ncount = 0\nwhile s > 0:\n s -= int(max(str(s)))\n count += 1\nprint(count)"}, {"source_code": "i = input()\nx = int(i)\ncont = 0\nwhile x:\n x -= int(max(i))\n i = str(x)\n cont += 1\nprint(cont)\n"}, {"source_code": "import sys\nfrom math import sqrt, floor, factorial, gcd\nfrom collections import deque, Counter\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n\ndef solve():\n\tn = int(inp()); s = 0\n\twhile n > 0:\n\t\tm = n%10; t = n\n\t\twhile t > 0:\n\t\t\tm = max(m, t%10)\n\t\t\tt //= 10\n\t\tn -= m\n\t\t# print(n, m)\n\t\ts += 1\n\tprint(s)\n\n\n\nif __name__ == \"__main__\":\n\tsolve()\n\n\n"}, {"source_code": "n=int(input())\nk=0\nwhile n>0:\n n-=int(max(str(n)))\n k+=1\nprint(k)\n"}, {"source_code": "n=int(input())\nans=0\nwhile n!=0:\n p=int(max(list(str(n))))\n n-=p\n ans+=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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprint(ans)"}, {"source_code": "m = int(input())\na = 0\nwhile(m > 0):\n m -= int(max([int(i) for i in str(m)]))\n a += 1\nprint(a)\n"}, {"source_code": "def maxx(n):\n l=[]\n while(n>0):\n l.append(n%10)\n n = int(n/10)\n return max(l)\nn =int(input())\nj=0\nwhile(n>0):\n n = n- maxx(n)\n j+=1\nprint(j)"}, {"source_code": "def findMax(N):\n Max = 0\n while(N!=0):\n Rem = N%10\n N = N//10\n Max = max(Max,Rem)\n return Max\nN =int(input())\ncount = 0\nwhile(N!=0):\n X = findMax(N)\n N-=X\n count+=1\nprint(count)"}, {"source_code": "n = int(input())\nsteps=0\nwhile n != 0:\n n -= max([int(k) for k in str(n)])\n steps += 1\nprint(steps)"}, {"source_code": "from collections import Counter\n\ndef main():\n n = int(input())\n dp = Counter()\n\n elms = [n]\n dp[n] = 0\n\n while elms:\n e = elms.pop()\n m = max([int(c) for c in str(e)])\n if m > 0:\n if dp[e] + 1 < dp[e - m] or dp[e - m] == 0:\n dp[e - m] = dp[e] + 1\n elms.append(e - m)\n\n print(dp[0])\n \n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "n=int(input())\nans=0\nwhile n!=0:\n p=int(max(list(str(n))))\n n-=p\n ans+=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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprint(ans)"}, {"source_code": "n=int(input())\nf=0\nwhile (n>0):\n f+=1\n n-=max(k-int(10e16)*(k==0) for k in set(map(int,str(n))))\nprint f\n"}, {"source_code": "# https://codeforces.com/problemset/problem/331/C1\n\nimport math\n\n\ndef to_digits(n):\n return [int(d) for d in str(n)]\n\n\ndef to_integer(digits):\n accum = 0\n factor = 1\n for d in reversed(digits):\n accum += factor * d\n factor *= 10\n\n return accum\n\n\ndef split(digits):\n d = 0\n index = 0\n for i in range(len(digits)):\n if digits[i] >= d:\n d = digits[i]\n index = i\n\n # print(str(d) + \" \" + str(digits[index:]))\n return (d, digits[i:])\n\n\nmemoize = {}\n\n\ndef num(x):\n y = 0\n while x > 0:\n digits = to_digits(x)\n d, r = split(digits)\n rint = to_integer(r)\n n = rint // d\n mod = rint % d\n if mod == 0 and n != 0:\n n = n\n elif rint < d or d < rint:\n n = n + 1\n\n y += n\n x = x - n * d\n\n return y\n\n\nx = int(input())\nprint(num(x))\n"}, {"source_code": "\n# n = 24\ndef get_subs(n):\n count = 0\n while n != '0':\n digits = [int(i) for i in n]\n max_digit = max(digits)\n n = int(n) - max_digit\n n = str(n)\n count += 1\n return count\n\n\n\n\nif __name__ == '__main__':\n n = input()\n print(get_subs(n))\n"}, {"source_code": "n=int(input())\nk=0\nwhile n:n-=int(max(str(n)));k+=1\nprint(k)"}, {"source_code": "n = int(input())\nk = 0\nwhile n > 0:\n n -= int(max(str(n)))\n k += 1\nprint(k)"}, {"source_code": "num=int(input())\nans=0\nwhile(num!=0):\n L=list(str(num))\n d=int(max(L))\n num-=d\n ans+=1\nprint(ans)\n"}, {"source_code": "import sys\nfrom math import sqrt, floor, factorial, gcd\nfrom collections import deque, Counter\ninp = sys.stdin.readline\nread = lambda: list(map(int, inp().strip().split()))\n\n\ndef solve():\n\tn = int(inp()); s = 0\n\twhile n > 0:\n\t\tm = n%10; t = n\n\t\twhile t > 0:\n\t\t\tm = max(m, t%10)\n\t\t\tt //= 10\n\t\tn -= m\n\t\t# print(n, m)\n\t\ts += 1\n\tprint(s)\n\n\n\nif __name__ == \"__main__\":\n\tsolve()\n\n\n"}, {"source_code": "n=int(input())\nc=0\nwhile(n>0):\n\tl=max(str(n))\n\tn=n-int(l)\n\tc+=1\nprint(c)\n"}, {"source_code": "n = int(input())\no = 0\nwhile n > 0:\n n -= int(max(str(n)))\n o += 1\nprint(o)"}, {"source_code": "n=int(input())\nres=0\nwhile n!=0:\n mx=0\n for i,x in enumerate(str(n)):\n if int(x)>mx:mx=int(x)\n n-=mx\n res+=1\nprint(res)"}, {"source_code": "n = input()\ncount = 0\nwhile(n > 0):\n n -= int(max(str(n)))\n count += 1\nprint count"}, {"source_code": "import math\n#q=int(input())\nq=1\nfor _ in range(q):\n n=int(input())\n ans=0\n while(n>0):\n ans+=1 \n k=n\n maxx=0\n while(k>0):\n x=k%10\n maxx=max(x,maxx)\n k//=10\n n-=maxx \n print(ans) \n \n \n \n "}, {"source_code": "\n \n\n\nn = int(input())\ns=0\n\nwhile n!=0:\n u = list(str(n))\n u.sort()\n n-=int(u[-1])\n s+=1\n\nprint(s)\n"}, {"source_code": "#ROUNIAAUDI\ny=int(input())\nc=0\nwhile y!=0:\n y-=int(max(str(y)))\n c+=1\nprint(c)"}, {"source_code": "def max_digit(n):\n x=[]\n n=str(n)\n for i in range(0,len(n)):\n x.append(int(n[i]))\n c=int(max(x))\n return c\n\nn=int(input())\ny=0\nwhile n!=0:\n x=max_digit(n)\n n=n-int(x)\n y+=1\nprint(y)\n"}, {"source_code": "import sys\nsys.setrecursionlimit(15000000)\ndef solve():\n n = int(input())\n mem = [1000000] * (n + 1)\n mem[0] = 0\n for i in range(1, n + 1):\n ncopy = i\n while ncopy > 0:\n last = ncopy % 10\n ncopy //= 10\n if last != 0 and i - last >= 0: mem[i] = min(mem[i], 1 + mem[i - last])\n print(mem[n])\n \nif sys.hexversion == 50594544 : sys.stdin = open(\"test.txt\")\nsolve()"}, {"source_code": "\n\n\ndef find(s):\n i = 9\n while s.find(str(i), 0, len(s)+1)==-1:\n i = i - 1\n s = str(int(s) - i)\n return s\n\n\nn = int(input())\nif (n==0):\n print(0)\n exit(0)\ns1 = str(n)\nans = 0\nwhile int(find(s1))!= 0:\n s1 = find(s1)\n ans = ans + 1\nprint(ans+1)\n"}, {"source_code": "c = '0123456789'\nF = {c[a] + c[b]: (c[10 - a + b], 1) if a > b else (c[10 - a], 2) for a in range(1, 10) for b in range(10)}\nfor b in range(1, 10): F['0' + c[b]] = ('0', 1)\nF['00'] = ('0', 0)\n\ndef f(x):\n global F\n if x in F: return F[x]\n a, b, y, s = int(x[0]), int(x[1]), x[2: ], 0\n for i in range(b, a, -1):\n y, d = f(c[i] + y)\n s += d\n for i in range(min(a, b) + 1):\n y, d = f(x[0] + y)\n s += d\n F[x] = ('9' + y, s)\n return F[x]\n\nprint(f('0' + raw_input())[1]) "}, {"source_code": "k = int(input())\n\nmini = []\nmini.append(0)\n\nfor i in range(k):\n p = i+1\n if(p < 10):\n mini.append(1)\n else:\n digits = [int(d) for d in str(p)]\n mini.append(1000000)\n for d in range(len(digits)):\n mini[p] = min(mini[p], 1+mini[p-digits[d]])\nprint(mini[k])"}, {"source_code": "\n# Target Specialist\n\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 : 14.07.19\n\n\"\"\"\n\nfrom __future__ import division, print_function\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\nelse:\n _str = str\n str = lambda x=b\"\": x if type(x) is bytes else _str(x).encode()\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# 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\n \n\ndef main():\n \n \n \n n=ii()\n\n\n ans=0\n while(n!=0):\n ans+=1\n l=ntl(n)\n m=max(l)\n n-=m\n print(ans)\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 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\ndef print(*args, **kwargs):\n \"\"\"Prints the values to a stream, or to sys.stdout by default.\"\"\"\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\nsys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)\ninput = lambda: sys.stdin.readline().rstrip(b\"\\r\\n\")\n\n# endregion\n\nif __name__ == \"__main__\":\n main()\n #dmain()"}, {"source_code": "a=int(input())\ni=0\nwhile a!=0:\n\ti+=1\n\tx=max(list(map(int,list(str(a)))))\n\ta-=x\nprint(i)"}, {"source_code": "n=input()\nans=0\nwhile(max(n)!=\"0\"):\n t=max(n)\n k=int(n)-int(t)\n n=str(k)\n ans+=1\nprint(ans)\n"}, {"source_code": "n,k=int(input()),0\nwhile n:n-=int(max(str(n)));k+=1\nprint(k)"}, {"source_code": "s=input()\nn=int(s)\nans=0\nwhile n!=0:\n for i in range(9,0,-1):\n if str(i) in str(n):\n n-=i\n ans+=1\n break;\nprint(ans)\n \n \n \n \n \n \n \n \n \n \n \n"}, {"source_code": "n=int(input())\ncount=0\nwhile n!=0:\n n-=max(list(map(int,str(n))))\n count+=1\nprint(count)"}, {"source_code": "n = int(input())\nans = 0\nwhile n:\n maxd = 0\n tmp = n\n while tmp:\n maxd = max(maxd, tmp % 10)\n tmp //= 10\n \n n -= maxd\n ans += 1\n \nprint(ans)"}, {"source_code": "n = int(input())\ndp = [0] * (n + 1)\nfor i in range(1, n + 1):\n tmp = i\n dp[i] = 10 ** 18\n while tmp > 0:\n d = tmp % 10\n tmp //= 10\n # tmp = tmp // 10 \n dp[i] = min(dp[i], dp[i - d])\n dp[i] += 1\nprint(dp[n])"}, {"source_code": "n,k=int(input()),0\nwhile n:n-=int(max(str(n)));k+=1\nprint(k)"}, {"source_code": "\nn = int(input())\ndef getMaxDigit(i):\n s = str(i)\n x = int(s[0])\n for c in s:\n x = max(int(c),x)\n if(x == 9):\n return x\n return x\ncount = 0\nwhile(n != 0):\n n -= getMaxDigit(n)\n count += 1\nprint(count)"}, {"source_code": "mem = {}\n\ndef compute_count(pmax, re):\n global mem\n ore = re\n\n if (pmax, re) in mem:\n return mem[(pmax, re)] \n\n numdig = len(str(re))\n\n if numdig == 1:\n mem[(pmax, ore)] = 1, min(0, re-pmax) \n return 1, min(0, re-pmax) \n\n sc = 0\n while re > 0:\n s = str(re).zfill(numdig)\n nmax = max(pmax, int(s[0])) \n newre = int(s[1:])\n cnt, left = compute_count(nmax, newre) \n\n sc += cnt \n re -= newre\n re += left\n\n mem[(pmax, ore)] = sc, re\n return sc, re\nx=int(input())\nif x:\n print(compute_count(0,x )[0])\nelse:\n print(0)\n\n \n\n\n"}, {"source_code": "n = int(input())\n\ndef maxDigit(a):\n x = 9\n while x > 0:\n if str(x) in str(a):\n return x\n else:\n x -= 1\n return 0\n\nmemo = 0\nwhile n != 0:\n n = n - maxDigit(n)\n memo += 1\n\nprint(memo)"}], "negative_code": [{"source_code": "memoization_table = {}\n\ndef compute_count(previous_max, rest):\n global memoization_table \n original_rest = rest\n\n if (previous_max, rest) in memoization_table:\n return memoization_table[(previous_max, rest)] \n\n num_digits = len(str(rest))\n\n if num_digits == 1:\n memoization_table[(previous_max, original_rest)] = 1, min(0, rest-previous_max) \n return 1, min(0, rest-previous_max) \n\n sum_count = 0\n while rest > 0:\n s = str(rest).zfill(num_digits)\n new_max = max(previous_max, int(s[0])) \n new_rest = int(s[1:])\n count, leftover = compute_count(new_max, new_rest) \n\n sum_count += count \n rest -= new_rest\n rest += leftover\n\n memoization_table[(previous_max, original_rest)] = sum_count, rest\n return sum_count, rest\n\nprint(compute_count(0, int(input()))[0])\n\n \n\n"}, {"source_code": "n = input()\ns = 0\nif(n % 10 != 0):\n s = 1\nprint(2*(n/10) + s)"}, {"source_code": "n = input()\ncount = 0\nwhile(n % 10 != 0):\n n -= int(max(str(n)))\n count += 1\ncount += 2 * (n / 10)\nprint count"}, {"source_code": "import time\ndef lucky(n):\n if n == 0:\n return 0\n if len(str(n)) == 1:\n return 1\n return 2*(n/10)+1\nimport sys\n\nprint lucky(int(sys.stdin.readline()))\n"}, {"source_code": "def lucky(n):\n m = str(n)\n t = '987654321'\n t1 = 0\n count = 0\n while True:\n t1 = 0\n if len(m)==1:\n return count + 1\n for i in range(9):\n if t[i] in m:\n n -= int(t[i])\n m = str(n)\n count += 1\n break\n return count\n\nimport sys\n\nprint lucky(int(sys.stdin.readline()))\n"}, {"source_code": "import time\ndef lucky(n):\n if n == 1:\n return 0\n if len(str(n)) == 1:\n return 1\n return 2*(n/10)+1\nimport sys\n\nprint lucky(int(sys.stdin.readline()))\n"}, {"source_code": "import time\ndef lucky(n):\n if n == 0:\n return 0\n if len(str(n)) == 1:\n return 1\n if n%10 == 0:\n return 2*(n/10)\n return 2*(n/10)+1\nimport sys\n\nprint lucky(int(sys.stdin.readline()))\n"}, {"source_code": "memoization_table = {}\n\ndef compute_count(previous_max, rest):\n global memoization_table \n original_rest = rest\n\n if (previous_max, rest) in memoization_table:\n return memoization_table[(previous_max, rest)] \n\n num_digits = len(str(rest))\n\n if num_digits == 1:\n memoization_table[(previous_max, original_rest)] = 1, min(0, rest-previous_max) \n return 1, min(0, rest-previous_max) \n\n sum_count = 0\n while rest > 0:\n s = str(rest).zfill(num_digits)\n new_max = max(previous_max, int(s[0])) \n new_rest = int(s[1:])\n count, leftover = compute_count(new_max, new_rest) \n\n sum_count += count \n rest -= new_rest\n rest += leftover\n\n memoization_table[(previous_max, original_rest)] = sum_count, rest\n return sum_count, rest\n\nn=int(input())\nans,not_ans=compute_count(0,n)\nprint(ans)"}, {"source_code": "from sys import stdin\nimport re\ninput_ = stdin.readline\n\nmagic_num = input_()\n\ndef func(magic_num,operation=0):\n operation = operation \n max_num = max([int(x) for x in magic_num.strip()])\n substraction = int(magic_num) - max_num\n if substraction == 0:\n return operation+1\n else:\n return func(str(substraction),operation+1)\n\n\n\nprint(func(magic_num))\n \n"}, {"source_code": "n = input()\nif n == '0':\n print(0)\nelse:\n m = max(n)\n n = int(n)\n N1 = n - n%10\n N2 = N1 + 10\n if n - int(m) >= N1:\n print((N1 + N2)//10)\n else:\n print((N1 + N2)//10 - 1)\n"}, {"source_code": "n = input()\nif n == '0':\n print(0)\nelif int(n) % 10 == 0:\n N = n[:len(n)-1]\n print(int(N)*2)\nelse:\n n = int(n)\n N1 = n - n%10\n N2 = N1 + 10\n print((N1 + N2)//10)"}, {"source_code": "s = input()\nr = 0\nwhile 1:\n l = list(s)\n d = list(map(int, s))\n n = ''.join(l)\n m = int(n)\n f = max(d)\n m = m-f\n r += 1\n s = str(m)\n if m<=0:\n break\nprint(r)"}, {"source_code": "#Ashish Sagar\nn=input()\ns=list(n) \nif n!='0':\n for i in range(len(s)):\n s[i]=int(s[i])\n if max(s)>(s[-1]):\n s[-1]=0\n else:\n s[-1]=5\n z=\"\"\n for i in range(len(s)):\n z+=str(s[i]) \n z=int(z)\n print(z//5)\nelse:\n print(0)"}, {"source_code": "#Ashish Sagar\nn=input()\ns=list(n) \nfor i in range(len(s)):\n s[i]=int(s[i])\nif max(s)>(s[-1]):\n s[-1]=0\nelse:\n s[-1]=5\nz=\"\"\nfor i in range(len(s)):\n z+=str(s[i]) \nz=int(z)\nprint(z//5)\n"}, {"source_code": "#Ashish Sagar\nn=input()\ns=list(n) \nfor i in range(len(s)):\n s[i]=int(s[i])\nif s[-1]!=0:\n s[-1]=5 \nz=\"\"\nfor i in range(len(s)):\n z+=str(s[i]) \nz=int(z)\nprint(z//5)\n"}, {"source_code": "def find_ans(n):\n if n%10==0:\n print(n//5)\n else:\n n=n-n%10\n print(1+(n//5))\n\nfind_ans(int(input()))"}, {"source_code": "def menha(n):\n num=0\n while n%10!=0:\n p=int(max(list(str(n))))\n n-=p\n num+=1\n return (num,n)\n\ndef find_ans(n):\n numm,n=menha(n)\n print(numm+n//5)\nfind_ans(int(input()))"}, {"source_code": "def menha(n):\n num=0\n while n%10!=0:\n p=int(max(list(str(n))))\n n-=p\n num+=1\n return (num,n)\n\ndef find_ans(n):\n numm,n=menha(n)\n print(numm+1+n//5)\nfind_ans(int(input()))"}, {"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(valr):\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(val%ll[mid]==0):\n\t\t\tans=ll[mid]\n\t\t\treturn binary(l,mid-1,ll,val,ans)\n\t\telse:\n\t\t\treturn binary(l,mid-1,ll,val,ans)\ndef odd(n,ans,s):\n\tif(n%2!=0 or n in s):\n\t\treturn ans\n\telse:\n\t\ts.add(n)\n\t\treturn odd(n//2,ans+1,s)\n\nif __name__ == '__main__':\n\tdp=[]\n\tfor i in range(1000001):\n\t\tdp.append(0)\n\n\tfor i in range(len(dp)):\n\t\tif(i<10):\n\t\t\tdp[i]=1\n\t\telse:\n\t\t\tval=i\n\t\t\tcount=0\n\t\t\twhile(True):\n\t\t\t\tmaxa=0\n\t\t\t\ts=str(val)\n\t\t\t\tfor j in range(len(s)):\n\t\t\t\t\tif(int(s[j:j+1])>maxa):\n\t\t\t\t\t\tmaxa=int(s[j:j+1])\n\t\t\t\tval-=maxa\n\t\t\t\tcount+=1\n\t\t\t\tif(val<=len(dp)):\n\t\t\t\t\tdp[i]=count+dp[val]\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tcontinue\n\t# print(len(dp))\n\tn=int(input())\n\tif(n<=len(dp)):\n\t\tprint(dp[n])\n\telse:\n\t\tval=n\n\t\tcount=0\n\t\twhile(True):\n\t\t\tmaxa=0\n\t\t\ts=str(val)\n\t\t\tfor j in range(len(s)):\n\t\t\t\tif(int(s[j:j+1])>maxa):\n\t\t\t\t\tmaxa=int(s[j:j+1])\n\t\t\tval-=maxa\n\t\t\tcount+=1\n\t\t\tif(val<=len(dp)):\n\t\t\t\tcount=count+dp[val]\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcontinue\n\t\tprint(count)"}, {"source_code": "n = int(input())\nif n < 10:\n print(1)\n exit(0)\nelif n == 0:\n print(0)\ndp = [2 for i in range(n)]\ndp[0] = n\nz = 1\nwhile True:\n dp[z] = dp[z-1] - int(max(str(dp[z-1])))\n if dp[z] == 0:\n break\n z = z + 1\nprint(z)"}, {"source_code": "n = int(input())\ns = 1\nwhile n > 9:\n n -= max(map(int, str(n)))\n s += 1\nprint(s)\n"}, {"source_code": "\n\n\ndef find(s):\n i = 9\n while s.find(str(i), 0, len(s)+1)==-1:\n i = i - 1\n s = str(int(s) - i)\n return s\n\n\nn = int(input())\ns1 = str(n)\nans = 0\nwhile int(find(s1))!= 0:\n s1 = find(s1)\n ans = ans + 1\nprint(ans+1)\n"}, {"source_code": "s = input()\nprint(0 if s == '0' else int(s[:-1] if s[:-1] else 0) * 2 + (s[-1] == max(s)))"}, {"source_code": "def getMaxDigit(n,c):\n if(n==0):\n return c\n else:\n t = n\n l= []\n while(t):\n l.append(t%10)\n t /= 10\n c+=1\n return getMaxDigit(n-max(l),c)\nn = int(input())\nprint(getMaxDigit(n,0))"}, {"source_code": "def getMaxDigit(n,c):\n if(n==0):\n return c\n else:\n t = n\n m = -1\n while(t):\n if(t%10 > m):\n m = t %10\n t = t // 10\n c+=1\n print(n,m,n-m)\n return getMaxDigit(n-m,c)\nn = int(input())\nprint(getMaxDigit(n,0))"}, {"source_code": "def main():\n n = int(input())\n\n res = 20 * (n // 100)\n i = n % 100\n\n dec = False\n while i % 10 != 0 and i % 9 != 0:\n i -= 1\n dec = True\n\n if dec:\n res += 1\n\n if i % 10 == 0:\n m = i // 10\n res += 2 * m\n elif i % 9 == 0:\n m = i // 9\n res += 2 * m - 1\n\n print(res)\n\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n = int(input())\n\n res = 20 * (n // 100)\n i = n % 100\n\n while i % 10 != 0 and i % 9 != 0:\n m = max([int(c) for c in str(i)])\n i -= m\n res += 1\n\n if i % 9 == 0:\n m = i // 9\n res += 2 * m - 1\n elif i % 10 == 0:\n m = i // 10\n res += 2 * m\n\n print(res)\n\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n = int(input())\n res = 20 * (n // 100)\n i = n % 100\n\n while i % 10 != 0 and i % 9 != 0:\n m = max([int(c) for c in str(i)])\n i -= m\n res += 1\n\n if i == 0:\n print(res)\n return\n\n if i % 9 == 0:\n m = i // 9\n res += 2 * m - 1\n elif i % 10 == 0:\n m = i // 10\n res += 2 * m\n\n print(res)\n\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n n = int(input())\n\n if n == 0:\n print(0)\n return\n\n\n res = 20 * (n // 100)\n i = n % 100\n\n while i % 10 != 0 and i % 9 != 0:\n m = max([int(c) for c in str(i)])\n i -= m\n res += 1\n\n if i % 9 == 0:\n m = i // 9\n res += 2 * m - 1\n elif i % 10 == 0:\n m = i // 10\n res += 2 * m\n\n print(res)\n\n \nif __name__ == '__main__':\n main()\n"}, {"source_code": "import math\n\nlookup = {}\n\ndef solve(n,mini):\n key = n\n if n == 0:\n lookup[key] = 0\n else:\n if key not in lookup:\n if n > mini:\n return 10e18\n else:\n temp = str(n)\n temp = set(temp)\n mini = 10e18\n for i in temp:\n if int(i) != 0:\n num = int(i)\n mini = min(mini,solve(n-num,mini)+1)\n lookup[key] = mini\n return lookup[key]\n \ndef s():\n n = int(input())\n print(solve(n,10e18))\n \ns()\n"}, {"source_code": "n = int(input())\n\nprint(2*(n//9)+[1,0][n%9 == 0])\n\n"}, {"source_code": "n = int(input())\nt = str(n)\nif t[-1] == \"9\" or t[-1] == \"0\":\n\tn = n - 1\n# if t[-1] == \"0\":\n# \tn = n + 1\nprint(2*((n)//9)+[1,0][(n)%9 == 0])\n\n"}, {"source_code": "count = 0\nn = int(input())\nif n < 10:\n\tprint(1)\n\texit()\nwhile n > 10 :\n\n\tt = n\n\tz = float(\"-inf\")\n\tr = 1\n\twhile t :\n\t\tr = r + 1\n\t\tt1 = t%10 \n\t\tt = t//10\n\t\tz = max(z,t1)\n\tn = n - z\n\tcount = count + 1\n\t# print(n)\nprint(count+2)\t\n\n"}, {"source_code": "n = int(input())\nt = str(n)\nif t[-1] == \"9\":\n\tn = n - 1\nif t[-1] == \"0\":\n\tn = n + 1\nprint(2*((n-1)//9)+[1,0][(n-1)%9 == 0])\n\n"}, {"source_code": "n = int(input())\nt = str(n)\nif t[-1] == \"9\" or t[-1] == \"0\":\n\tn = n - 1\n# if t[-1] == \"0\":\n# \tn = n + 1\nprint(max(2*((n)//9)+[1,0][(n)%9 == 0],0))\n\n"}, {"source_code": "n = list(input())\n# for i in range(len(n)):\n# n[i] = int(n[i])\n# print(n)\n# print(int(''.join(n)))\n\nc = 0\nwhile(True):\n if(len(n) == 1):\n break\n else:\n s = int(max(n))\n m = int(int(''.join(n)) - s)\n n = list(str(m))\n # print(n)\n c += 1\nprint(c + 1) "}, {"source_code": "n=int(input())\ny=[]\nfor i in str(n):\n y.append(int(i))\n\ncount=0\nx=n%10\nif max(y)==x and n!=0:\n count=1\nelse:\n count=0\nn=n-x\nprint((n//10)*2+count)"}, {"source_code": "n=int(input())\n\nx=n%10\nn=n-x\nif x==0:\n print((n//10)*2)\nelse:\n print((n//10)*2+1)"}, {"source_code": "n=int(input())\ny=[]\nfor i in str(n):\n y.append(int(i))\n\ncount=0\nx=n%10\nif max(y)==x:\n count=1\nelse:\n count=0\nn=n-x\nprint((n//10)*2+count)"}, {"source_code": "n = int(input())\nnum=0\nwhile True:\n x = list(map(int,str(n)))\n \n \n if x[-1]==0:\n num+= n//5\n break\n n-=max(x)\n num+=1\nprint(num)\n"}, {"source_code": "n = input()\nnum = int(n)\ncount=1\nwhile num >=10 :\n num-= int(max(list(n)))\n count+=1\n n= str(num)\nprint(count)\n"}, {"source_code": "c = '0123456789'\nF = {c[a] + c[b]: (c[10 - a + b], 1) if a > b else (c[10 - a], 2) for a in range(1, 10) for b in range(10)}\nfor b in range(1, 10): F['0' + c[b]] = ('0', 1)\nF['00'] = ('0', 0)\n\ndef f(x):\n global F\n if x in F: return F[x]\n a, b, y, s = int(x[0]), int(x[1]), x[2: ], 0\n for i in range(b, a, -1):\n y, d = f(c[i] + y)\n s += d\n for i in range(a, -1, -1):\n y, d = f(x[0] + y)\n s += d\n F[x] = ('9' + y, s)\n return F[x]\n\nprint(f('0' + input())[1]) "}, {"source_code": "s=list(input())\ncnt=0\nwhile(True):\n\tk=sorted(s)\n\tmaxx=int(k[-1])\n\ts=list(str(int(''.join(s))-maxx))\n\tcnt+=1\n\tif len(s)==1 and int(s[0])<=0:\n\t\tbreak\nprint(cnt)"}, {"source_code": "\n\nimport math\n\na =int(input())\n\nprint(math.ceil(a/5))"}, {"source_code": "\n\n\na = int(input())\n\n\n\nb = (a//10)*2\n\nif a%10>0:\n b+=1\n\n\nprint(b)\n"}, {"source_code": "n = int(input())\ni = [int(x) for x in str(n)]\nsum = 1 \nwhile True:\n n -= max(i)\n i = [int(x) for x in str(n)]\n if n == 0:\n break\n else:\n sum += 1\nprint(sum)\n"}, {"source_code": "n = int(input())\ni = [int(x) for x in str(n)]\nsum = 0 \nwhile True:\n n -= max(i)\n i = [int(x) for x in str(n)]\n if n == 0:\n break\n else:\n sum += 1\nprint(sum + 1)\n"}, {"source_code": "n = int(input())\ni = [int(x) for x in str(n)]\nsum = 0 \nwhile True:\n n -= max(i)\n sum += 1\n i = [int(x) for x in str(n)]\n if n == 0:\n break\nprint(sum)\n"}], "src_uid": "fc5765b9bd18dc7555fa76e91530c036"} {"nl": {"description": "The \"Bulls and Cows\" game needs two people to play. The thinker thinks of a number and the guesser tries to guess it.The thinker thinks of a four-digit number in the decimal system. All the digits in the number are different and the number may have a leading zero. It can't have more than one leading zero, because all it's digits should be different. The guesser tries to guess the number. He makes a series of guesses, trying experimental numbers and receives answers from the first person in the format \"x bulls y cows\". x represents the number of digits in the experimental number that occupy the same positions as in the sought number. y represents the number of digits of the experimental number that present in the sought number, but occupy different positions. Naturally, the experimental numbers, as well as the sought number, are represented by four-digit numbers where all digits are different and a leading zero can be present.For example, let's suppose that the thinker thought of the number 0123. Then the guessers' experimental number 1263 will receive a reply \"1 bull 2 cows\" (3 occupies the same positions in both numbers and 1 and 2 are present in both numbers but they occupy different positions). Also, the answer to number 8103 will be \"2 bulls 1 cow\" (analogically, 1 and 3 occupy the same positions and 0 occupies a different one). When the guesser is answered \"4 bulls 0 cows\", the game is over.Now the guesser has already made several guesses and wants to know whether his next guess can possibly be the last one.", "input_spec": "The first input line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u200910) which represents the number of already made guesses. Then follow n lines in the form of \"ai bi ci\", where ai is the i-th experimental number, bi is the number of bulls, ci is the number of cows (1\u2009\u2264\u2009i\u2009\u2264\u2009n, 0\u2009\u2264\u2009bi,\u2009ci,\u2009bi\u2009+\u2009ci\u2009\u2264\u20094). The experimental numbers are correct, i.e., each of them contains exactly four digits, in each of them all the four digits are different, and there can be a leading zero. All the experimental numbers are different. As the guesser hasn't guessed the number yet, the answer \"4 bulls 0 cows\" is not present.", "output_spec": "If the input data is enough to determine the sought number, print the number with four digits on a single line. If it has less than four digits, add leading zero. If the data is not enough, print \"Need more data\" without the quotes. If the thinker happens to have made a mistake in his replies, print \"Incorrect data\" without the quotes.", "sample_inputs": ["2\n1263 1 2\n8103 2 1", "2\n1234 2 2\n1256 0 2", "2\n0123 1 1\n4567 1 2"], "sample_outputs": ["Need more data", "2134", "Incorrect data"], "notes": null}, "positive_code": [{"source_code": "import sys\nlines = sys.stdin.readlines()\nn = int(lines[0].strip())\nquery = []\nfor i in range(1, n+1):\n (a, b, c) = lines[i].strip().split(\" \")\n query.append((a, int(b), int(c)))\ndef compare(i):\n digits = str(i)\n digits = \"0\" *(4-len(digits)) + digits\n if len(set(list(digits))) != 4: return False\n for q in query:\n (a, b, c) = q\n m, n = 0, 0\n for i in range(4):\n if a[i] == digits[i]: m += 1\n for l in a:\n if l in digits: n += 1\n n -= m\n if m != b or n != c:\n return False\n return True\nres = 0\ncount = 0\nfor i in range(123, 9877):\n if compare(i): count += 1; res = i\n if count >= 2: break\nif count == 0: print(\"Incorrect data\")\nelif count == 1:\n digits = str(res)\n digits = \"0\" *(4-len(digits)) + digits\n print(digits)\nelse: print(\"Need more data\")\n"}, {"source_code": "import sys\n\ndef tolist(i):\n listx = list()\n while i > 0:\n listx.append(i % 10)\n i //= 10\n while len(listx) < 4: listx.append(0)\n return listx[::-1]\n\ndef diff(i):\n count = [0] * 10\n for x in range(4):\n count[i % 10] += 1\n i //= 10\n for val in count:\n if val > 1: return False\n return True\n\nn, = map(int, input().split())\nworks = 0\nlastworks = -1\nguesses = list()\nfor i in range(n):\n a, b, c, = map(int, input().split())\n acopy = a\n charcount = [0] * 10\n for x in range(4):\n charcount[acopy % 10] += 1\n acopy //= 10\n guesses.append((tolist(a), b, c, charcount))\n\nfor i in range(1, 10000):\n if diff(i):\n l = tolist(i)\n icopy = i\n charcount = [0] * 10\n for x in range(4):\n charcount[icopy % 10] += 1\n icopy //= 10\n count = 0\n for guess in guesses:\n bulls, cows = 0, 0\n for j in range(4):\n if l[j] == guess[0][j]: bulls += 1\n for j in range(10):\n if charcount[j] > 0 and guess[3][j] > 0: cows+=1\n cows -= bulls\n if bulls == guess[1] and cows == guess[2]:\n count += 1\n if count == n:\n works += 1\n lastworks = l\nif works == 0:\n print(\"Incorrect data\")\nelif works == 1:\n print(''.join(map(str, lastworks)))\nelse:\n print(\"Need more data\")\n"}, {"source_code": "def filter(candidates, num, rp, wp):\n ans = []\n for cand in candidates:\n crp = cwp = 0\n for a, b in zip(cand, num):\n if a == b:\n crp += 1\n elif a in num:\n cwp += 1\n\n if crp == rp and cwp == wp:\n ans.append(cand)\n\n return ans\n\n\ndef main():\n n = int(input())\n candidates = []\n for i in range(123, 9877):\n num = str(i).zfill(4)\n if len(set(num)) == 4:\n candidates.append(num)\n\n for _ in range(n):\n a, b, c = input().split()\n candidates = filter(candidates, a, int(b), int(c))\n if not candidates:\n print('Incorrect data')\n return\n\n print(candidates[0] if len(candidates) == 1 else 'Need more data')\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import sys\n\ndef solve():\n n, = rv()\n works = 0\n lastworks = -1\n guesses = list()\n for i in range(n):\n a, b, c, = rv()\n acopy = a\n charcount = [0] * 10\n for x in range(4):\n charcount[acopy % 10] += 1\n acopy //= 10\n guesses.append((tolist(a), b, c, charcount))\n\n for i in range(1, 10000):\n if different(i):\n l = tolist(i)\n icopy = i\n charcount = [0] * 10\n for x in range(4):\n charcount[icopy % 10] += 1\n icopy //= 10\n count = 0\n for guess in guesses:\n bulls, cows = 0, 0\n for j in range(4):\n if l[j] == guess[0][j]: bulls += 1\n for j in range(10):\n if charcount[j] > 0 and guess[3][j] > 0: cows+=1\n cows -= bulls\n\n\n if bulls == guess[1] and cows == guess[2]:\n count += 1\n if count == n:\n works += 1\n lastworks = l\n if works == 0:\n print(\"Incorrect data\")\n elif works == 1:\n print(''.join(map(str, lastworks)))\n else:\n print(\"Need more data\")\n\ndef tolist(i):\n il = list()\n while i > 0:\n il.append(i % 10)\n i //= 10\n while len(il) < 4: il.append(0)\n return il[::-1]\n\ndef different(i):\n count = [0] * 10\n for x in range(4):\n count[i % 10] += 1\n i //= 10\n for val in count:\n if val > 1: return False\n return True\n\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()"}, {"source_code": "import sys\n\ndef solve():\n n, = rv()\n works = 0\n lastworks = -1\n guesses = list()\n for i in range(n):\n a, b, c, = rv()\n acopy = a\n charcount = [0] * 10\n for x in range(4):\n charcount[acopy % 10] += 1\n acopy //= 10\n guesses.append((tolist(a), b, c, charcount))\n\n for i in range(1, 10000):\n if different(i):\n l = tolist(i)\n icopy = i\n charcount = [0] * 10\n for x in range(4):\n charcount[icopy % 10] += 1\n icopy //= 10\n count = 0\n for guess in guesses:\n bulls, cows = 0, 0\n for j in range(4):\n if l[j] == guess[0][j]: bulls += 1\n for j in range(10):\n if charcount[j] > 0 and guess[3][j] > 0: cows+=1\n cows -= bulls\n\n\n if bulls == guess[1] and cows == guess[2]:\n count += 1\n if count == n:\n works += 1\n lastworks = l\n if works == 0:\n print(\"Incorrect data\")\n elif works == 1:\n print(''.join(map(str, lastworks)))\n else:\n print(\"Need more data\")\n\ndef tolist(i):\n il = list()\n while i > 0:\n il.append(i % 10)\n i //= 10\n while len(il) < 4: il.append(0)\n return il[::-1]\n\ndef different(i):\n count = [0] * 10\n for x in range(4):\n count[i % 10] += 1\n i //= 10\n for val in count:\n if val > 1: return False\n return True\n\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\n# Made By Mostafa_Khaled"}, {"source_code": "#! /usr/bin/python3\nimport sys\nimport pprint\n\ndef main():\n input_list = []\n for line in sys.stdin:\n input_list.append(line.rstrip(\"\\n\"))\n \"\"\"\n # DEBUG\n if line.rstrip(\"\\n\") == \"exit\":\n break\n \"\"\"\n possible_nums = [\"{0:04}\".format(i) for i in range(123, 10000)] # List of all possible 4 digit numbers as strings form \"0123\" to \"9999\"\n\n for i in range(int(input_list[0])):\n check_list = input_list[i + 1].split(\" \")\n possible_nums = filter(possible_nums, check_list[0], check_list[1], check_list[2])\n \"\"\"\n # DEBUG\n print(possible_nums)\n \"\"\"\n if len(possible_nums) == 0:\n print(\"Incorrect data\")\n elif len(possible_nums) == 1:\n print(possible_nums[0])\n else:\n print(\"Need more data\")\n \ndef check_cow(input_num, check_num, cow):\n cow_num = 0\n union_set = set(ordered_union(list(input_num), list(check_num))) # Set of Strings\n cow_num = len((set(input_num) - union_set).intersection(set(check_num) - union_set))\n\n return cow_num == cow\n\ndef check_bull(input_num, check_num, bull):\n bull_num = 0\n bull_num = len(ordered_union(list(input_num), list(check_num)))\n\n return bull_num == bull\n\ndef filter(possible_nums, input_num, bull, cow):\n filtered_list = []\n\n for num in possible_nums:\n if check_cow(input_num, num, int(cow)) and check_bull(input_num, num, int(bull)) and not has_repeat(num):\n filtered_list.append(num)\n\n return filtered_list\n\ndef ordered_union(list1, list2):\n union_list = []\n\n for i in range(len(list1)):\n if list1[i] == list2[i]:\n union_list.append(list1[i])\n return union_list\n\ndef has_repeat(num):\n return len(set(num)) != len(num)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "c_list=[]\np_list=[]\nn = int(raw_input())\nfor i in range(n):\n c = [x for x in raw_input().split()]\n c_list.append(c)\n\nfor i in range(0,10000):\n test=str(i).rjust(4,'0')\n test_score=0\n for c in c_list:\n match = c[0]\n mbc = int(c[1])\n mcc = int(c[2])\n tbc = 0\n tcc = 0\n for i in range(4):\n if match[i] == test[i]:\n tbc += 1\n elif match[i] in test:\n tcc += 1\n if mbc == tbc and mcc==tcc:\n test_score+=1\n if test_score == n:\n no_dup = True\n for i in range(4):\n for j in range(4):\n if i!=j and test[i]==test[j]:\n no_dup=False\n if no_dup:\n p_list.append(test)\n \nif len(p_list) == 0:\n print \"Incorrect data\"\nelif len(p_list) == 1:\n print p_list[0]\nelse:\n print \"Need more data\"\n"}, {"source_code": "from itertools import permutations\ndef ch(ww):\n global s, kb\n t=0\n for i in range(n):\n b=0\n w=list(ww)\n u=list(s[i][0])\n for j in (3,2,1,0):\n if u[j]==w[j]:\n b+=1\n del u[j]\n del w[j]\n k=len(set(u)&set(w))\n if b==int(s[i][1]) and k==int(s[i][2]): t+=1\n if t==n:\n kb=ww\n return 1\n else: return 0\n\nn = int(raw_input())\ns=[[] for i in range(n)]\nfor k in range(n):\n s[k] =raw_input().split()\n\nkb=''\nst=0\nfor i in permutations('9876543210',4):\n st+=ch(''.join(i))\n if st>1:\n print ('Need more data')\n break\nelse:\n if st==1: print (kb)\n else: print ('Incorrect data')"}, {"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 = []\nret = []\nn = int (raw_input ())\nfor i in range (n):\n a, b, c = [i for i in raw_input ().split ()]\n l.append ((a, b, c))\nfor i in range (0, 10000):\n s = (\"0000\" + str (i)) [-4:]\n if len (set (list (s))) != 4: continue\n ok = True\n for j in l:\n a, b, c = j\n x, y = 0, 0\n for k in range (4):\n if a [k] == s [k]:\n x += 1\n for k in range (4):\n for m in range (4):\n if a [k] == s [m]:\n y += 1\n y -= x\n b, c = int (b), int (c)\n ok &= (x == b and y == c)\n if ok: ret.append (s)\nif len (ret) == 1: print ret [0]\nelif len (ret) < 1: print \"Incorrect data\"\nelse: print \"Need more data\"\n"}, {"source_code": "def is_sat(candi, cont):\n candi_match = cont[0]\n _bcount = int(cont[1])\n _ccount = int(cont[2])\n bcount = 0\n ccount = 0\n for i in xrange(4):\n if candi_match[i] == candi[i]:\n bcount += 1\n elif candi_match[i] in candi:\n ccount += 1\n return (_bcount == bcount and _ccount == ccount)\n \nconstraints = []\n\nN = int(raw_input())\nwhile N>0:\n constraints.append([x for x in raw_input().split()])\n N-=1\nsatisfies = []\nfor i in xrange(0,10000):\n candi = str(i).rjust(4,'0')\n satcount = 0\n for cont in constraints:\n if is_sat(candi, cont):\n satcount+=1\n if satcount == len(constraints):\n valid = True\n for i in xrange(4):\n for j in xrange(4):\n if i!=j:\n if candi[i]==candi[j]:\n valid=False\n if valid:\n satisfies.append(candi)\n \ngoo = len(satisfies)\nif goo == 1:\n print satisfies[0]\nelif goo == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\""}, {"source_code": "import sys\nimport string\n\ndef check(s1, s2):\n t1 = 0\n t2 = 0\n for i in xrange(len(s1)):\n if s1[i] == s2[i]:\n t1 += 1\n elif s1[i] in s2:\n t2 += 1\n return (t1, t2) \n \n\nguesses = []\nfor i in ['%0*d' % (4, i) for i in xrange(10000)]:\n t = []\n for j in i:\n if not j in t:\n t.append(j)\n else:\n break\n else:\n guesses.append(i)\n \nlines = []\nfor i in sys.stdin.readlines()[1:]:\n line = i.rstrip().split(\" \")\n lines.append((line[0], int(line[1]), int(line[2])))\n\nc = 0\nans = None\nfor g in guesses:\n for i in lines:\n s1 = i[0]\n t1 = i[1]\n t2 = i[2]\n if (t1, t2) != check(s1, g):\n break\n else:\n c += 1\n ans = g\n \n\nif c == 0:\n print \"Incorrect data\"\nelse:\n if c != 1:\n print \"Need more data\"\n else:\n print ans\n\n\n \n \n\n\n\n \n\n"}, {"source_code": "n = input()\nd = {}\na = []\n\ndef digits (n):\n rs = []\n p2 = 0\n for i in range(4):\n rs.append(n%10)\n n/=10 \n return set(rs),rs\n\nfor i in range(10000):\n l,ll = digits(i)\n if len(l)<4: continue\n a.append(i)\n d[i]=(l,ll)\n \ndef oc(k,x,b,c):\n kl,kll=d[k]\n xl,xll=d[x]\n nb = sum(int(x==y) for x,y in zip(kll,xll))\n if nb!=b: return False\n nc = sum(int(x in kl) for x in xl)-nb\n return nc==c\n\nfor i in range(n):\n k,b,c = map(int,raw_input().split()) \n a = filter(lambda x:oc(k,x,b,c),a)\n \nif not a: print \"Incorrect data\"\nelif len(a)==1: print \"%04d\"%a[0]\nelse: print \"Need more data\"\n"}, {"source_code": "\ndef findBulls(a, b):\n total = 0\n for i in range(len(a)):\n if a[i] == b[i]:\n total += 1\n\n return total \n \n\ndef findCows(a, b):\n\n l1 = []\n l2 = []\n\n for i in range(len(a)):\n l1.append(int(a[i]))\n l2.append(int(b[i]))\n \n s1 = set(l1)\n s2 = set(l2)\n\n return (len(s1.intersection(s2))) - findBulls(a, b)\n \n\ntps = [] \nmatches = []\n\n\n#print findBulls('0012', '1234')\n#print findCows('0012', '1234')\n \ntotal = int(raw_input())\n\n\nfor i in range(total):\n l = raw_input()\n parts = l.split()\n g = parts[0]\n b = int(parts[1])\n c = int(parts[2])\n\n tps.append((g, b,c )) \n \n\n \ndef findMatches(i, j, k, l, tps):\n first = i\n second = j\n third = k\n fourth = l\n\n allMatched = True\n \n for t in tps:\n if (findBulls(str(i) + str(j) + str(k) + str(l), t[0]) == t[1]) and (findCows(str(i) + str(j) + str(k) + str(l), t[0]) == t[2]):\n pass\n else:\n allMatched = False \n \n if allMatched:\n matches.append(str(i) + str(j) + str(k) + str(l)) \n \n \nfor i in range(10):\n for j in range(10):\n for k in range(10):\n for l in range(10):\n st = set()\n st.add(i)\n st.add(j)\n st.add(k)\n st.add(l)\n if len(st) == 4: \n findMatches(i, j, k, l, tps)\n \n\nif len(matches) == 1:\n print matches[0]\nelif len(matches) == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\" \n"}, {"source_code": "# -*- coding: utf-8 -*-\nfrom itertools import combinations, permutations\n\nnums = set(map(str, range(10)))\n\ndef query(x, y):\n b = set([ i for i in range(len(x)) if x[i] == y[i]])\n r = set(x)&set(y)\n for i in b: r.remove(x[i])\n return len(b), len(r)\n\nmother = set()\nfor p in permutations(nums, 4):\n mother.add(p)\n\nn = input()\nclue = [raw_input().split() for _ in range(n)]\n\nfor cl in clue:\n expr, bull, cow = cl[0], int(cl[1]), int(cl[2])\n rm = set()\n for cand in mother:\n b, c = query(cand, tuple(expr))\n if b != bull or c != cow:\n rm.add(cand)\n mother ^= rm\n \nstatus = len(mother)\nif status == 0:\n print 'Incorrect data'\nelif status == 1:\n print ''.join(tuple(mother)[0])\nelse:\n print 'Need more data'\n"}, {"source_code": "import sys\n\ndef check(s1, s2):\n\ta = 0\n\tn = len(s1)\n\tfor i in range(0,n):\n\t\ta += (s1[i]==s2[i])\n\tb = len(set(s1) & set(s2)) - a\n\treturn (a,b)\n\ndef ch(s):\n\treturn len(set(s)) == 4\n\nn = int(raw_input())\n\npr = []\nok = []\n\nfor i in range(0,10000):\n\ts = str(i)\n\tif i < 1000:\n\t\ts = '0'+s\n\tif ch(s)==True:\n\t\tpr.append(s)\n\t\tok.append(True)\n\nfor i in range(0,n):\n\tl = raw_input().split()\n\n\ts = l[0]\n\t(a,b) = map(int,l[1:])\n\n\tfor j in range(0,len(pr)):\n\t\tif ok[j]==False:\n\t\t\tcontinue\n\t\tif check(pr[j], s) != (a,b):\n\t\t\tok[j] = False\n\nsm = len(filter(lambda x:x, ok))\nif sm == 0:\n\tprint \"Incorrect data\"\nelse:\n\tif sm == 1:\n\t\tfor i in range(0,len(ok)):\n\t\t\tif ok[i]==True:\n\t\t\t\tprint pr[i]\n\t\t\t\tbreak\n\telse:\n\t\tprint \"Need more data\"\n"}, {"source_code": "import string\nimport itertools\nimport sys\n\ndef bullcow(num1, num2):\n num1 = list(num1)\n num2 = list(num2)\n bull = 0\n cow = 0\n for idx1, dg1 in enumerate(num1):\n for idx2, dg2 in enumerate(num2):\n if dg2 == dg1:\n if idx2 == idx1:\n bull += 1\n else:\n cow += 1\n return bull, cow\n\nn = int(raw_input())\nguesses = []\nbullscow = []\nfor _ in range(n):\n g, b, c = raw_input().split()\n guesses.append(g)\n bullscow.append((int(b), int(c)))\n\ncandidates = set(itertools.permutations(string.digits, r=4))\n\nfor i, guess in enumerate(guesses):\n new_candidates = set()\n b, c = bullscow[i]\n for s in candidates:\n b2, c2 = bullcow(s, guess)\n if b2==b and c2==c:\n new_candidates.add(s)\n candidates = new_candidates\n if len(candidates) == 0:\n print 'Incorrect data'\n sys.exit(0)\n\nif len(candidates)>1:\n print 'Need more data'\n sys.exit(0)\n\nprint ''.join(candidates.pop())\n"}, {"source_code": "import itertools\n\nn = input()\nquiz = ''\nanswers = 0\ndata = []\n\nfor i in xrange(0, n):\n data.append(raw_input().split())\n \ndef check(hyp):\n for num, bull, cow in data:\n uknow = len(set(hyp) & set(num))\n know = len([i for i, j in zip(num, hyp) if i == j])\n if uknow-know != int(cow) or know != int(bull):\n return 0\n return 1\n\nfor hyp in itertools.permutations('0123456789', 4):\n if (check(''.join(hyp))):\n quiz = ''.join(hyp)\n answers = answers + 1\n \nif answers == 0:\n print \"Incorrect data\"\nif answers == 1:\n print quiz\nif answers > 1:\n print \"Need more data\"\n \n"}, {"source_code": "#In the name of ALLAH\ndef getBC(a, guess):\n b = 0\n a1 = g1 = \"\"\n for i in range(4):\n if a[i] == guess[i]:\n b += 1\n else:\n a1 += a[i]\n g1 += guess[i]\n c = 0\n for i in a1:\n if i in g1:\n c += 1\n return str(b), str(c)\n\n\nn = int(raw_input())\nk = []\npos = None\nok = True\nfor i in range(n):\n k.append(raw_input().split())\nfor i in range(0, 9999):\n a = str(i).zfill(4)\n if len(set(a)) == 4:\n ok = True\n for j in range(n):\n b, c = getBC(a, k[j][0])\n if b != k[j][1] or c != k[j][2]:\n ok = False\n if ok == True:\n if pos is None:\n pos = a\n else:\n print \"Need more data\"\n exit(0)\n \nif pos is None:\n print \"Incorrect data\"\nelse:\n print pos\n"}, {"source_code": "import math, time, re\n\nln = lambda : raw_input()\ncnv = lambda s: map(int, s.split())\nrInt = lambda s: int(s)\nrFloat = lambda s: float(s)\nrLong = lambda s: long(s)\nrLine = lambda f: f.readline()\n\nb = [True for i in xrange(0, 10)]\n\nllong = []\ndef per(s):\n if len (s) == 4:\n llong.append(s)\n return\n else:\n for i in xrange(0, 10):\n if b[i]:\n b[i] = False\n per(s + str(i))\n b[i] = True\n\ndef check(s1, s2):\n return (len([i for i in xrange(0, 4) if (s1[i] in s2 and s1[i] == s2[i])])), \\\n(len([i for i in xrange(0, 4) if (s1[i] in s2 and s1[i] != s2[i])]))\n\n\nstart = time.time()\nk, t = 0, 0\nn = int(raw_input())\nl = []\nper(\"\")\n#print llong\nfor i in xrange(0,n):\n l.append(ln().split())\nfor i in xrange(0, len(llong)):\n b = True\n for j in xrange(0, n):\n if (check(llong[i], l[j][0]) != (int(l[j][1]), int(l[j][2]))):\n b = False\n break\n if b:\n k += 1\n t = llong[i]\n if k > 1:\n break\n#print l[0][0]\n#print l[0][1]\n#print l[0][2]\n#print llong[0]\nif k > 1:\n print 'Need more data'\nelif k == 1:\n print t\nelse:\n print 'Incorrect data'\n#per(s)\n#print llong\n#print check (s1, s2)\n#print 'Time exceeded:', time.time() - start"}, {"source_code": "from itertools import *\n\nn = input ()\ndata = map (lambda a: (a[0], int (a[1]), int (a[2])), [raw_input ().split () for i in xrange (n)])\n\ndef valid (s):\n for a, b, c in data:\n x, y = len (set (s) & set (a)), len ([i for i, j in zip (a, s) if i == j])\n if x - y != c or y != b:\n return 0\n return 1\n\nans, cnt = '', 0\nfor s in permutations ('0123456789', 4):\n if valid (''.join (s)):\n ans = s\n cnt += 1\n \nprint ''.join (ans) if cnt == 1 else 'Need more data' if cnt > 1 else 'Incorrect data'\n"}, {"source_code": "a = [(x[0], int(x[1]), int(x[2])) for x in [raw_input().split() for i in xrange(input())]]\nans = []\ndef cal(x, y):\n a, b = 0, 0\n for i in xrange(4):\n if x[i] == y[i]: a += 1\n else:\n for j in xrange(4):\n if i != j and x[i] == y[j]:\n b += 1\n break\n return (a, b)\ndef check(x):\n bit = ''\n while x:\n bit += chr(ord('0') + x % 10)\n x /= 10\n while len(bit) != 4: bit += '0'\n if len(set(bit)) != 4: return\n for item in a:\n if cal(item[0], bit[::-1]) != (item[1], item[2]): return\n ans.append(bit[::-1])\nfor i in xrange(1, 10000):\n check(i)\nif not ans: print 'Incorrect data'\nelif len(ans) > 1: print 'Need more data'\nelse: print ans[0]"}, {"source_code": "from itertools import *\n\nn = int(raw_input())\na = map(lambda t: (t[0], int(t[1]), int(t[2])), [raw_input().split() for _ in xrange(n)])\n\ndef check(s):\n for u,v,w in a:\n x, y = len( set(s)&set(u) ), 0\n for i in xrange(4):\n if s[i]==u[i]:\n y += 1\n if x-y!=w or y!=v:\n return 0\n return 1\n\nans, cnt = \"\", 0\nfor s in permutations(\"0123456789\", 4):\n if check(\"\".join(s)):\n ans = \"\".join(s)\n cnt += 1\nif cnt == 1:\n print ans\nelif cnt == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\""}, {"source_code": "def getStr(x):\n\tans = []\n\twhile x > 0:\n\t\tans.append(x % 10)\n\t\tx /= 10\n\tans += [0] * (4 - len(ans))\n\treturn \"\".join(map(str, ans))[::-1]\n\ndef main():\n\tn = input()\n\tdata = []\n\tfor i in xrange(n):\n\t\td, b, c = map(str, raw_input().split())\n\t\tdata.append((d, int(b), int(c)))\n\tans = \"\"\n\tfor i in xrange(0, 10000):\n\t\ts = getStr(i)\n\t\tif s.count(s[0]) > 1 or s.count(s[1]) > 1 or s.count(s[2]) > 1 or s.count(s[3]) > 1: continue\n\t\tisOk = True\n\t\tfor j in xrange(n):\n\t\t\tb, c = 0, 0\n\t\t\tfor k in xrange(4):\n\t\t\t\tif data[j][0][k] == s[k]: b += 1\n\t\t\t\telif s[k] in data[j][0]: c += 1\n\t\t\tif b != data[j][1] or c != data[j][2]:\n\t\t\t\tisOk = False\n\t\t\t\tbreak\n\t\tif isOk:\n\t\t\tif ans != \"\":\n\t\t\t\tprint \"Need more data\"\n\t\t\t\treturn\n\t\t\tans = s\n\tprint ans if ans != \"\" else \"Incorrect data\"\n\nif __name__ == \"__main__\": main()\n"}, {"source_code": "d1 = [0,0,0,0]\nd2 = [0,0,0,0]\n\ndef digits (num,d):\n\taux = num\n\tfor i in range(0,4):\n\t\td[i] = num%10\n\t\tnum /= 10\n\tif aux < 1000:\n\t\td[3] = 0\n\t\n\ndef bc (num1,num2):\n\tb,c = 0,0\n\tdigits(num1,d1)\n\tdigits(num2,d2)\n\t\n\tfor i in range(0,4):\n\t\tfor j in range(0,4):\n\t\t\tif i == j and d1[i] == d2[j]: b+=1\n\t\t\tif i != j and d1[i] == d2[j]: c+=1\n\t\n\treturn (b,c)\n\nv = [] ; usei = [0]*10\n\n\n\ndef preenche(index,num):\n\tif index == 4:\n\t\tv.append(num)\n\telse:\n\t\tfor i in range(0,10):\n\t\t\tif usei[i] == 0:\n\t\t\t\tusei[i] = 1\n\t\t\t\tpreenche(index+1,num*10+i)\n\t\t\t\tusei[i] = 0\n\npreenche(0,0)\ncheck = [1]*len(v)\t\t\n\t\nn = input() ; s = 0;\nfor i in range(0,n):\n\tlinha = map(int,raw_input().strip().split())\n\tguess = (linha[1],linha[2])\n\tfor i in range(0,len(v)):\n\t\tres = bc(linha[0],v[i])\n\t\tif res != guess: check[i] = 0\n\nfor i in range(0,len(v)):\n\tif check[i] == 1: \n\t\ts += 1; res = v[i]\n\t\nif s == 0: print 'Incorrect data'\nif s == 1:\n\tif res < 1000: print '0'+str(res)\n\telse: print res\nif s > 1: print 'Need more data'\n\t\n\t\n\n"}, {"source_code": "from sys import stdin\n\nrstrs = lambda: [str(x) for x in stdin.readline().split()]\nstrs_inp = lambda n: [rstrs() for _ in range(n)]\nn = int(input())\nqur, sol = strs_inp(n), []\n\nfor i in range(123, 9877):\n num = '0' * (4 - len(str(i))) + str(i)\n if len(set(num)) != 4:\n continue\n\n q = 0\n for a, b, c in qur:\n same, diff = 0, 0\n for j in range(4):\n if num[j] == a[j]:\n same += 1\n if a[j] in num:\n diff += 1\n\n diff -= same\n if diff == int(c) and same == int(b):\n q += 1\n\n if q == n:\n sol.append(num)\n\nif len(sol) > 1:\n print('Need more data')\nelif not len(sol):\n print('Incorrect data')\nelse:\n print(sol[0])\n"}, {"source_code": "import sys\nfrom array import array # noqa: F401\nfrom itertools import product\n\n\ndef input():\n return sys.stdin.buffer.readline().decode('utf-8')\n\n\nn = int(input())\ncand = set()\n\nfor i, (a, b, c) in enumerate(input().split() for _ in range(n)):\n a = list(map(int, a))\n b, c = int(b), int(c)\n s = set()\n\n for p in product(range(10), repeat=4):\n if len(set(p)) < 4:\n continue\n b_, c_ = 0, 0\n for j in range(4):\n if p[j] == a[j]:\n b_ += 1\n elif p[j] in a:\n c_ += 1\n if b == b_ and c == c_:\n s.add(''.join(map(str, p)))\n\n if i == 0:\n cand = s\n else:\n cand &= s\n\nif len(cand) == 1:\n print(cand.pop())\nelif len(cand) > 1:\n print('Need more data')\nelif not cand:\n print('Incorrect data')\nelse:\n assert False\n"}, {"source_code": "n=int(input())\narray=[str(t).zfill(4) for t in range(10000) if len(set(str(t).zfill(4)))==4]\n# print (array)\nfor _ in range(n):\n a,b,c=input().split()\n b=int(b)\n c=int(c)\n # for u in array:\n # print (u, set(u).intersection(set(a)))\n array=[u for u in array if len(set(u).intersection(set(a)))==b+c and sum(u[i]==a[i] for i in range(4))==b]\n # print (array)\nif len(array)>1:print(\"Need more data\")\nelif len(array)==1:print(array[0])\nelse:print(\"Incorrect data\")\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'\nMOD=1000000007\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\n\nnumbers=set()\nfor i in range(10):\n for j in range(10):\n for k in range(10):\n for l in range(10):\n if(i!=j and i!=k and i!=l and j!=k and j!=l and k!=l):\n numbers.add(str(i)+str(j)+str(k)+str(l))\n\n\ndef count():\n possible=set()\n \n for num in numbers:\n cow=0\n bulls=0\n\n for i in range(4):\n for j in range(4):\n if(num[i]==n[j]): \n bulls+=1\n break\n if(num[i]==n[i]): cow+=1\n\n if(cow==x and bulls-cow==y):\n possible.add(num)\n\n return possible\n\n\nfor _ in range(Int()):\n n,x,y=input().split()\n x=int(x)\n y=int(y)\n\n numbers=count()\n # print(numbers)\n\nif(len(numbers)==1): print(list(numbers)[0])\nelif(len(numbers)>1): print('Need more data')\nelse: print('Incorrect data')\n\n"}, {"source_code": "'''input\n8\n7954 0 1\n5638 0 1\n8204 0 2\n8293 1 1\n3598 0 1\n0894 0 1\n6324 1 2\n0572 0 1\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\nfrom copy import deepcopy\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection():\n\tpass\n\ndef discover_digits(guess):\n\tmyset = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}\n\tflag = 0\n\tcount = 0\n\tfinal = []\n\tcomb = permutations(myset, 4)\n\tfor i in comb:\n\t\tans = get_answer(guess, list(i))\n\t\tif len(ans) == 4:\n\t\t\tcount += 1\n\t\t\tfinal.append(ans)\n\t\t\tflag = 1\n\n\tif count == 1:\n\t\tfor i in final[0]:\n\t\t\tprint(i, end = '')\n\telif count > 1:\n\t\tprint(\"Need more data\")\n\tif flag == 0:\n\t\tprint(\"Incorrect data\")\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, answer):\n\tflag = 0\n\tans = []\n\tfor j in range(len(guess)):\n\t\tnum = guess[j][0]\n\t\tif check(answer, guess, j):\n\t\t\tpass\n\t\telse:\n\t\t\tbreak\n\telse:\n\t\tans = answer\n\n\treturn ans\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n\n# getting ready final list\nfinal = []\nbase = set()\ndiscover_digits(guess)\n"}], "negative_code": [{"source_code": "import sys\n\ndef solve():\n n, = rv()\n works = 0\n lastworks = -1\n guesses = list()\n for i in range(n):\n a, b, c, = rv()\n acopy = a\n charcount = [0] * 10\n for x in range(4):\n charcount[acopy % 10] += 1\n acopy //= 10\n guesses.append((tolist(a), b, c, charcount))\n\n for i in range(1, 10000):\n if different(i):\n l = tolist(i)\n icopy = i\n charcount = [0] * 10\n for x in range(4):\n charcount[icopy % 10] += 1\n icopy //= 10\n count = 0\n for guess in guesses:\n bulls, cows = 0, 0\n for j in range(4):\n if l[j] == guess[0][j]: bulls += 1\n for j in range(10):\n if charcount[j] > 0 and guess[3][j] > 0: cows+=1\n cows -= bulls\n\n\n if bulls == guess[1] and cows == guess[2]:\n count += 1\n if count == n:\n works += 1\n lastworks = i\n if works == 0:\n print(\"Incorrect data\")\n elif works == 1:\n print(lastworks)\n else:\n print(\"Need more data\")\n\ndef tolist(i):\n il = list()\n while i > 0:\n il.append(i % 10)\n i //= 10\n while len(il) < 4: il.append(0)\n return il[::-1]\n\ndef different(i):\n count = [0] * 10\n for x in range(4):\n count[i % 10] += 1\n i //= 10\n for val in count:\n if val > 1: return False\n return True\n\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()"}, {"source_code": "#! /usr/bin/python3\nimport sys\n\ndef main():\n input_list = []\n for line in sys.stdin:\n input_list.append(line.rstrip(\"\\n\"))\n\n possible_nums = [\"{0:04}\".format(i) for i in range(123, 10000)] # List of all possible 4 digit numbers as strings form \"0123\" to \"9999\"\n\n for i in range(int(input_list[0])):\n check_list = input_list[i + 1].split(\" \")\n possible_nums = filter(possible_nums, int(check_list[0]), int(check_list[1]), int(check_list[2]))\n \n if len(possible_nums) == 0:\n print(\"Incorrect data\")\n elif len(possible_nums) == 1:\n print(possible_nums[0])\n else:\n print(\"Need more data\")\n \ndef check_cow(input_num, check_num, cow):\n cow_num = 0\n union_set = set(ordered_union(list(str(input_num)), list(str(check_num)))) # Set of Strings\n cow_num = len((set(str(input_num)) - union_set).intersection((set(str(check_num)) - union_set)))\n\n return cow_num == cow\n\ndef check_bull(input_num, check_num, bull):\n bull_num = 0\n bull_num = len(ordered_union(list(str(input_num)), list(str(check_num))))\n\n return bull_num == bull\n\ndef filter(possible_nums, input_num, bull, cow):\n filtered_list = []\n\n for num in possible_nums:\n if check_cow(input_num, num, cow) and check_bull(input_num, num, bull):\n filtered_list.append(num)\n\n return filtered_list\n\ndef ordered_union(list1, list2):\n union_list = []\n\n for i in range(len(list1)):\n if list1[i] == list2[i]:\n union_list.append(list1[i])\n return union_list\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "#! /usr/bin/python3\nimport sys\nimport pprint\n\ndef main():\n input_list = []\n for line in sys.stdin:\n input_list.append(line.rstrip(\"\\n\"))\n\n possible_nums = [\"{0:04}\".format(i) for i in range(123, 10000)] # List of all possible 4 digit numbers as strings form \"0123\" to \"9999\"\n\n for i in range(int(input_list[0])):\n check_list = input_list[i + 1].split(\" \")\n possible_nums = filter(possible_nums, int(check_list[0]), int(check_list[1]), int(check_list[2]))\n \n if len(possible_nums) == 0:\n print(\"Incorrect data\")\n elif len(possible_nums) == 1:\n print(possible_nums[0])\n else:\n print(\"Need more data\")\n \ndef check_cow(input_num, check_num, cow):\n cow_num = 0\n union_set = set(ordered_union(list(str(input_num)), list(str(check_num)))) # Set of Strings\n cow_num = len((set(str(input_num)) - union_set).intersection((set(str(check_num)) - union_set)))\n\n return cow_num == cow\n\ndef check_bull(input_num, check_num, bull):\n bull_num = 0\n bull_num = len(ordered_union(list(str(input_num)), list(str(check_num))))\n\n return bull_num == bull\n\ndef filter(possible_nums, input_num, bull, cow):\n filtered_list = []\n\n for num in possible_nums:\n if check_cow(input_num, num, cow) and check_bull(input_num, num, bull) and not has_repeat(num):\n filtered_list.append(num)\n\n return filtered_list\n\ndef ordered_union(list1, list2):\n union_list = []\n\n for i in range(len(list1)):\n if list1[i] == list2[i]:\n union_list.append(list1[i])\n return union_list\n\ndef has_repeat(num):\n return len(set(num)) != len(num)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def is_sat(candi, cont):\n candi_match = cont[0]\n _bcount = int(cont[1])\n _ccount = int(cont[2])\n bcount = 0\n ccount = 0\n for i in xrange(4):\n if candi_match[i] == candi[i]:\n bcount += 1\n elif candi_match[i] in candi:\n ccount += 1\n return (_bcount == bcount and _ccount == ccount)\n \nconstraints = []\n\nN = int(raw_input())\nwhile N>0:\n constraints.append([x for x in raw_input().split()])\n N-=1\nsatisfies = []\nfor i in xrange(0,10000):\n candi = str(i).rjust(4,'0')\n satcount = 0\n for cont in constraints:\n if is_sat(candi, cont):\n satcount+=1\n if satcount == len(constraints):\n satisfies.append(candi)\n \ngoo = len(satisfies)\nif goo == 1:\n print satisfies[0]\nelif goo == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\""}, {"source_code": "def is_sat(candi, cont):\n candi_match = cont[0]\n _bcount = int(cont[1])\n _ccount = int(cont[2])\n bcount = 0\n ccount = 0\n for i in xrange(4):\n if candi_match[i] == candi[i]:\n bcount += 1\n elif candi_match[i] in candi:\n ccount += 1\n return (_bcount == bcount and _ccount == ccount)\n \nconstraints = []\n\nN = int(raw_input())\nwhile N>0:\n constraints.append([x for x in raw_input().split()])\n N-=1\nsatisfies = []\nfor i in xrange(0,10000):\n candi = str(i).rjust(4,'0')\n satcount = 0\n for cont in constraints:\n if is_sat(candi, cont):\n satcount+=1\n if satcount == len(constraints):\n satisfies.append(candi)\n \ngoo = len(satisfies)\nif goo == 1:\n valid = True\n for i in xrange(4):\n for j in xrange(4):\n if i!=j:\n if satisfies[0][i]==satisfies[0][j]:\n valid=False\n if valid:\n print satisfies[0]\n else:\n print \"Need more data\"\nelif goo == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\""}, {"source_code": "def is_sat(candi, cont):\n candi_match = cont[0]\n _bcount = int(cont[1])\n _ccount = int(cont[2])\n bcount = 0\n ccount = 0\n for i in xrange(4):\n if candi_match[i] == candi[i]:\n bcount += 1\n elif candi_match[i] in candi:\n ccount += 1\n return (_bcount == bcount and _ccount == ccount)\n \nconstraints = []\n\nN = int(raw_input())\nwhile N>0:\n constraints.append([x for x in raw_input().split()])\n N-=1\nsatisfies = []\nfor i in xrange(0,10000):\n candi = str(i).rjust(4,'0')\n satcount = 0\n for cont in constraints:\n if is_sat(candi, cont):\n satcount+=1\n if satcount == len(constraints):\n satisfies.append(candi)\n \ngoo = len(satisfies)\nif goo == 1:\n valid = True\n for i in xrange(4):\n for j in xrange(4):\n if i!=j:\n if satisfies[0][i]==satisfies[0][j]:\n valid=False\n if valid:\n print satisfies[0]\n else:\n print \"Incorrect data\"\nelif goo == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\""}, {"source_code": "\ndef findBulls(a, b):\n total = 0\n for i in range(len(a)):\n if a[i] == b[i]:\n total += 1\n\n return total\t\n \n\ndef findCows(a, b):\n\n l1 = []\n l2 = []\n\n for i in range(len(a)):\n l1.append(int(a[i]))\n l2.append(int(b[i]))\n\t\n s1 = set(l1)\n s2 = set(l2)\n\n return (len(s1.intersection(s2))) - findBulls(a, b)\n \n\ntps = [] \nmatches = []\n\n\n#print findBulls('0012', '1234')\n#print findCows('0012', '1234')\n \ntotal = int(raw_input())\n\n\nfor i in range(total):\n l = raw_input()\n parts = l.split()\n g = parts[0]\n b = int(parts[1])\n c = int(parts[2])\n\n tps.append((g, b,c )) \n \n\n \ndef findMatches(i, j, k, l, tps):\n first = i\n second = j\n third = k\n fourth = l\n\n allMatched = True\n \n for t in tps:\n if (findBulls(str(i) + str(j) + str(k) + str(l), t[0]) == t[1]) and (findCows(str(i) + str(j) + str(k) + str(l), t[0]) == t[2]):\n pass\n else:\n allMatched = False\t\n\t \n if allMatched:\n matches.append(str(i) + str(j) + str(k) + str(l))\t\n \n \nfor i in range(10):\n for j in range(10):\n for k in range(10):\n for l in range(10):\n findMatches(i, j, k, l, tps)\n \n\nif len(matches) == 1:\n print matches[0]\nelif len(matches) == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\" \n"}, {"source_code": "def check(s1, s2):\n\ta = 0\n\tn = len(s1)\n\tfor i in range(0,n):\n\t\ta += (s1[i]==s2[i])\n\tb = len(set(s1) & set(s2)) - a\n\treturn (a,b)\n\nn = int(raw_input())\n\npr = []\nok = []\n\nfor i in range(0,10000):\n\ts = str(i)\n\tif s < 1000:\n\t\ts = '0'+s\n\tif len(set(s)) == 4:\n\t\tpr.append(s)\n\t\tok.append(True)\n\nfor i in range(0,n):\n\tl = raw_input().split()\n\n\ts = l[0]\n\t(a,b) = map(int,l[1:])\n\t\n\tfor j in range(0,len(pr)):\n\t\tif ok[j]==False:\n\t\t\tcontinue\n\t\tif check(pr[j], s) != (a,b):\n\t\t\tok[j] = False\n\nsm = len(filter(lambda x:x, ok))\nif sm == 0:\n\tprint \"Incorrect data\"\nelse:\n\tif sm == 1:\n\t\tfor i in range(0,len(ok)):\n\t\t\tif ok[i]==True:\n\t\t\t\tprint pr[i]\n\t\t\t\tbreak\n\telse:\n\t\tprint \"Need more data\"\n"}, {"source_code": "import sys\n\ndef check(s1, s2):\n\ta = 0\n\tn = len(s1)\n\tfor i in range(0,n):\n\t\ta += (s1[i]==s2[i])\n\tb = len(set(s1) & set(s2)) - a\n\treturn (a,b)\n\ndef ch(s):\n\treturn len(set(s)) == 4\n\nn = int(raw_input())\n\npr = []\nok = []\n\nfor i in range(0,10000):\n\ts = str(i)\n\tif s < 1000:\n\t\ts = '0'+s\n\tif ch(s)==True:\n\t\tpr.append(s)\n\t\tok.append(True)\n\nfor i in range(0,n):\n\tl = raw_input().split()\n\n\ts = l[0]\n\t(a,b) = map(int,l[1:])\n\t\n\tif ch(s)==False:\n\t\tprint \"Incorrect data\"\n\t\tsys.exit()\n\t\n\tfor j in range(0,len(pr)):\n\t\tif ok[j]==False:\n\t\t\tcontinue\n\t\tif check(pr[j], s) != (a,b):\n\t\t\tok[j] = False\n\nsm = len(filter(lambda x:x, ok))\nif sm == 0:\n\tprint \"Incorrect data\"\nelse:\n\tif sm == 1:\n\t\tfor i in range(0,len(ok)):\n\t\t\tif ok[i]==True:\n\t\t\t\tprint pr[i]\n\t\t\t\tbreak\n\telse:\n\t\tprint \"Need more data\"\n"}, {"source_code": "import string\nimport itertools\nimport sys\n\ndef bullcow(num1, num2):\n num1 = list(num1)\n num2 = list(num2)\n bull = 0\n cow = 0\n for idx1, dg1 in enumerate(num1):\n for idx2, dg2 in enumerate(num2):\n if dg2 == dg1:\n if idx2 == idx1:\n bull += 1\n else:\n cow += 1\n return bull, cow\n\nn = int(raw_input())\nguesses = []\nbullscow = []\nfor _ in range(n):\n g, b, c = raw_input().split()\n guesses.append(g)\n bullscow.append((int(b), int(c)))\n\n\ncandidates = set(itertools.product(string.digits, repeat=4))\n\nfor i, guess in enumerate(guesses):\n new_candidates = set()\n b, c = bullscow[i]\n for s in candidates:\n b2, c2 = bullcow(s, guess)\n if b2==b and c2==c:\n new_candidates.add(s)\n candidates = new_candidates\n if len(candidates) == 0:\n print 'Incorrect data'\n sys.exit(0)\n\nif len(candidates)>1:\n print 'Need more data'\n sys.exit(0)\n\nprint ''.join(candidates.pop())\n"}, {"source_code": "import string\nimport itertools\nimport sys\n\ndef bullcow(num1, num2):\n num1 = list(num1)\n num2 = list(num2)\n bull = 0\n cow = 0\n for idx1, dg1 in enumerate(num1):\n for idx2, dg2 in enumerate(num2):\n if dg2 == dg1:\n if idx2 == idx1:\n bull += 1\n else:\n cow += 1\n return bull, cow\n\nn = int(raw_input())\nguesses = []\nbullscow = []\nfor _ in range(n):\n g, b, c = raw_input().split()\n guesses.append(g)\n bullscow.append((int(b), int(c)))\n\ncandidates = set(itertools.permutations(string.digits, r=4))\n\nfor i, guess in enumerate(guesses):\n new_candidates = set()\n b, c = bullscow[i]\n for s in candidates:\n b2, c2 = bullcow(s, guess)\n if b2==b and c2==c:\n new_candidates.add(s)\n candidates = new_candidates\n if len(candidates) == 0:\n print 'Incorrect data'\n sys.exit(0)\n\nfor c in candidates:\n print c\n \n\nif len(candidates)>1:\n print 'Need more data'\n sys.exit(0)\n\nprint ''.join(candidates.pop())\n"}, {"source_code": "import itertools\n\nn = input()\nquiz = ''\nanswers = 0\ndata = []\n\nfor i in xrange(0, n):\n data.append(raw_input().split())\n \ndef check(hyp):\n for num, bull, cow in data:\n uknow = len(set(hyp) & set(num))\n know = len([i for i, j in zip(num, hyp) if i == j])\n if uknow-know != int(cow) or know != int(bull):\n return 0\n return 1\n\nfor hyp in itertools.permutations('0123456789', 4):\n if (check(''.join(hyp))):\n print ''.join(hyp)\n quiz = ''.join(hyp)\n answers = answers + 1\n \nif answers == 0:\n print \"Incorrect data\"\nif answers == 1:\n print quiz\nif answers > 1:\n print \"Need more data\"\n \n"}, {"source_code": "a = [(x[0], int(x[1]), int(x[2])) for x in [raw_input().split() for i in xrange(input())]]\ndef cal(x, y):\n a, b = 0, 0\n for i in xrange(4):\n if x[i] == y[i]: a += 1\n else:\n for j in xrange(4):\n if i != j and x[i] == y[j]:\n b += 1\n break\n return (a, b)\ndef check(x):\n bit = ''\n while x:\n bit += chr(ord('0') + x % 10)\n x /= 10\n while len(bit) != 4: bit += '0'\n for item in a:\n if cal(item[0], bit[::-1]) != (item[1], item[2]): return False\n return True\nans = filter(check, range(1, 10000))\nif not ans: print 'Incorrect data'\nelif len(ans) > 1: print 'Need more data'\nelse: print ans[0]"}, {"source_code": "a = [(x[0], int(x[1]), int(x[2])) for x in [raw_input().split() for i in xrange(input())]]\ndef cal(x, y):\n a, b = 0, 0\n for i in xrange(4):\n if x[i] == y[i]: a += 1\n else:\n for j in xrange(4):\n if i != j and x[i] == y[j]:\n b += 1\n break\n return (a, b)\ndef check(x):\n bit = ''\n while x:\n bit += chr(ord('0') + x % 10)\n x /= 10\n while len(bit) != 4: bit += '0'\n if len(set(bit)) != 4: return False\n for item in a:\n if cal(item[0], bit[::-1]) != (item[1], item[2]): return False\n return True\nans = filter(check, range(1, 10000))\nif not ans: print 'Incorrect data'\nelif len(ans) > 1: print 'Need more data'\nelse: print ans[0]"}, {"source_code": "a = [(x[0], int(x[1]), int(x[2])) for x in [raw_input().split() for i in xrange(input())]]\nans = []\ndef cal(x, y):\n a, b = 0, 0\n for i in xrange(4):\n if x[i] == y[i]: a += 1\n else:\n for j in xrange(4):\n if i != j and x[i] == y[j]:\n b += 1\n break\n return (a, b)\ndef check(x):\n bit = ''\n while x:\n bit += chr(ord('0') + x % 10)\n x /= 10\n while len(bit) != 4: bit += '0'\n if len(set(bit)) != 4: return\n for item in a:\n if cal(item[0], bit[::-1]) != (item[1], item[2]): return\n ans.append(bit)\nfor i in xrange(1, 10000):\n check(i)\nif not ans: print 'Incorrect data'\nelif len(ans) > 1: print 'Need more data'\nelse: print ans[0]"}, {"source_code": "from itertools import *\n\nn = int(raw_input())\na = [map(int, raw_input().split()) for _ in xrange(n)]\n\ndef check(s):\n for u,v,w in a:\n u = str(u)\n x, y = len( set(s)&set(u) ), 0\n for i in xrange(4):\n if s[i]==u[i]:\n y += 1\n if x-y!=w or y!=v:\n return 0\n return 1\n\nans, cnt = \"\", 0\nfor s in permutations(\"0123456789\", 4):\n if check(s):\n ans = s\n cnt += 1\nif cnt == 1:\n print s\nelif cnt == 0:\n print \"Incorrect data\"\nelse:\n print \"Need more data\""}, {"source_code": "d1 = [0,0,0,0]\nd2 = [0,0,0,0]\n\ndef digits (num,d):\n\taux = num\n\tfor i in range(0,4):\n\t\td[i] = num%10\n\t\tnum /= 10\n\tif aux < 1000:\n\t\td[3] = 0\n\t\n\ndef bc (num1,num2):\n\tb,c = 0,0\n\tdigits(num1,d1)\n\tdigits(num2,d2)\n\t\n\tfor i in range(0,4):\n\t\tfor j in range(0,4):\n\t\t\tif i == j and d1[i] == d2[j]: b+=1\n\t\t\tif i != j and d1[i] == d2[j]: c+=1\n\t\n\treturn (b,c)\n\nv = [] ; usei = [0]*10\n\n\n\ndef preenche(index,num):\n\tif index == 4:\n\t\tv.append(num)\n\telse:\n\t\tfor i in range(0,10):\n\t\t\tif usei[i] == 0:\n\t\t\t\tusei[i] = 1\n\t\t\t\tpreenche(index+1,num*10+i)\n\t\t\t\tusei[i] = 0\n\npreenche(0,0)\ncheck = [1]*len(v)\t\t\n\t\nn = input() ; s = 0;\nfor i in range(0,n):\n\tlinha = map(int,raw_input().strip().split())\n\tguess = (linha[1],linha[2])\n\tfor i in range(0,len(v)):\n\t\tres = bc(linha[0],v[i])\n\t\tif res != guess: check[i] = 0\n\nfor i in range(0,len(v)):\n\tif check[i] == 1: \n\t\ts += 1; res = v[i]\n\t\nif s == 0: print 'Incorrect data'\nif s == 1: print res\nif s > 1: print 'Need more data'\n\t\n\t\n\n"}, {"source_code": "n=int(input())\narray=[str(t).zfill(4) for t in range(10000) if len(set(str(t).zfill(4)))==4]\nprint (array)\nfor _ in range(n):\n a,b,c=input().split()\n b=int(b)\n c=int(c)\n # for u in array:\n # print (u, set(u).intersection(set(a)))\n array=[u for u in array if len(set(u).intersection(set(a)))==b+c and sum(u[i]==a[i] for i in range(4))==b]\n # print (array)\nif len(array)>1:print(\"Need more data\")\nelif len(array)==1:print(array[0])\nelse:print(\"Incorrect data\")\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'\nMOD=1000000007\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\n\nnumbers=set()\nfor i in range(10):\n for j in range(10):\n for k in range(10):\n for l in range(10):\n if(i!=j and j!=k and k!=l):\n numbers.add(str(i)+str(j)+str(k)+str(l))\n\n\ndef count():\n possible=set()\n \n \n for num in numbers:\n cow=0\n bulls=0\n for i in range(4):\n for j in range(4):\n if(num[i]==n[j]):\n if(i!=j): bulls+=1\n else: cow+=1\n if(cow==x and bulls==y):\n possible.add(num)\n\n return possible\n\n\nfor _ in range(Int()):\n n,x,y=input().split()\n x=int(x)\n y=int(y)\n\n numbers=count()\n\nif(len(numbers)==1): print(list(numbers)[0])\nelif(len(numbers)>1): print('Need more data')\nelse: print('Incorrect data')\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'\nMOD=1000000007\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\n\nnumbers=set()\nfor i in range(10):\n for j in range(10):\n for k in range(10):\n for l in range(10):\n if(i!=j and i!=k and i!=l):\n numbers.add(str(i)+str(j)+str(k)+str(l))\n\n\ndef count():\n possible=set()\n \n \n for num in numbers:\n cow=0\n bulls=0\n for i in range(4):\n for j in range(4):\n if(num[i]==n[j]):\n if(i!=j): bulls+=1\n else: cow+=1\n if(cow==x and bulls==y):\n possible.add(num)\n\n return possible\n\n\nfor _ in range(Int()):\n n,x,y=input().split()\n x=int(x)\n y=int(y)\n\n numbers=count()\n\nif(len(numbers)==1): print(list(numbers)[0])\nelif(len(numbers)>1): print('Need more data')\nelse: print('Incorrect data')\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'\nMOD=1000000007\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\n\nnumbers=set()\nfor i in range(10):\n for j in range(10):\n for k in range(10):\n for l in range(10):\n if(i!=j and j!=k and k!=l):\n numbers.add(str(i)+str(j)+str(k)+str(l))\n\n\ndef count():\n possible=set()\n \n for num in numbers:\n cow=0\n bulls=0\n\n for i in range(4):\n for j in range(4):\n if(num[j]==n[i]): \n bulls+=1\n break\n if(num[i]==n[i]): cow+=1\n\n if(cow==x and bulls-cow==y):\n possible.add(num)\n\n return possible\n\n\nfor _ in range(Int()):\n n,x,y=input().split()\n x=int(x)\n y=int(y)\n\n numbers=count()\n\nif(len(numbers)==1): print(list(numbers)[0])\nelif(len(numbers)>1): print('Need more data')\nelse: print('Incorrect data')\n\n"}, {"source_code": "'''input\n2\n0123 1 1\n4567 1 2\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\nfrom copy import deepcopy\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection():\n\tpass\n\n\ndef discover_digits(guess, index, final, base):\n\tif index == len(guess):\n\t\tfinal.append(list(base))\n\t\treturn\n\t\t\n\n\telse:\n\t\tnum, first, second = guess[index]\n\t\tfirst = int(first)\n\t\tsecond = int(second)\n\t\tnum = list(map(int, list(num)))\n\n\t\tcomb = combinations(num, first + second)\n\t\tfor i in comb:\n\t\t\ti = list(i)\n\t\t\tcbase = deepcopy(base)\n\t\t\tfor j in i:\n\t\t\t\tcbase.add(j)\n\t\t\tdiscover_digits(guess, index + 1, final, cbase)\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, answer):\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\treturn ans\n\n\ndef check_invalid(final):\n\tfor element in final:\n\t\tif len(element) > 4:\n\t\t\tpass\n\t\telse:\n\t\t\treturn False\n\treturn True\n\n\ndef check_unique(final):\n\tcount = 0\n\tfor element in final:\n\t\tif len(element) == 4:\n\t\t\tcount += 1\n\tif count == 1:\n\t\treturn True\n\telse:\n\t\treturn False\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n\n# getting ready final list\nfinal = []\nbase = set()\ndiscover_digits(guess, 0, final, base)\n\n#print(final)\n# checking for right answer\n\nif check_unique(final):\n\tfor element in final:\n\t\tif len(element) == 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) == 4:\n\t\t\t\tfor i in ans:\n\t\t\t\t\tprint(i, end = '')\n\t\t\t\texit()\n\nif check_invalid(final):\n\tprint(\"Incorrect data\")\t\n\texit()\nelse:\n\tprint(\"Need more data\")\n\texit()\n\n"}, {"source_code": "'''input\n2\n1263 1 2\n8103 2 1\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\nfrom copy import deepcopy\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection():\n\tpass\n\n\ndef discover_digits(guess, index, final, base):\n\tif index == len(guess):\n\t\tfinal.append(list(base))\n\t\treturn\n\t\t\n\n\telse:\n\t\tnum, first, second = guess[index]\n\t\tfirst = int(first)\n\t\tsecond = int(second)\n\t\tnum = list(map(int, list(num)))\n\n\t\tcomb = combinations(num, first + second)\n\t\tfor i in comb:\n\t\t\ti = list(i)\n\t\t\tcbase = deepcopy(base)\n\t\t\tfor j in i:\n\t\t\t\tcbase.add(j)\n\t\t\tdiscover_digits(guess, index + 1, final, cbase)\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, answer):\n\twhile len(answer) < 4:\n\t\tanswer.append(-1)\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\treturn ans\n\n\ndef check_invalid(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) != 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) > 0:\n\t\t\t\treturn False\n\treturn True\n\n\t\n\tif count == 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef check_unique(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) == 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) == 4:\n\t\t\t\ttans = ans\n\t\t\t\tcount += 1\n\n\n\t\n\tif count == 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n\n# getting ready final list\nfinal = []\nbase = set()\ndiscover_digits(guess, 0, final, base)\n\n# print(final)\n# checking for right answer\n\nif check_unique(final):\n\texit()\nif check_invalid(final):\n\tprint(\"Incorrect data\")\t\n\texit()\nelse:\n\tprint(\"Need more data\")\n\texit()\n\n"}, {"source_code": "'''input\n2\n1263 1 2\n8103 2 1\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection(num, base, total, final, invalid, index):\n\tnum = set(list(map(int, list((str(num))))))\n\taux = []\n\tcommon = set(base).intersection(num)\n\tif 4 - len(base) >= total - len(common) and invalid[0] == True and index != 0:\n\t\tinvalid[0] = False\n\tfor i in common:\n\t\tfinal.add(i)\n\tif total == 4:\n\t\tinvalid[0] = False\n\t\tfor i in num:\n\t\t\tfinal.add(i)\n\n\t\treturn aux\n\telse:\n\t\tcom = combinations(num, total)\n\t\tfor i in com:\n\t\t\taux.append(list(i))\n\t\treturn aux\n\n\ndef discover_digits(guess, final, index, digit, invalid):\n\tif index == len(guess):\n\t\treturn\n\n\telse:\n\t\tif len(final) == 4:\n\t\t\tinvalid[0] = False\n\t\t\treturn\n\n\t\tnum, first, second = guess[index]\n\t\tfirst = int(first); second = int(second)\n\t\ttotal = first + second\n\t\t\n\t\tdigit_arr = take_intersection(num, digit, total, final, invalid, index)\n\t\tfor i in digit_arr:\n\t\t\tdiscover_digits(guess, final, index + 1, i, invalid)\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, final, index, answer):\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\n\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n# stage 1: Guess the digit\ndigit = []\nfinal = set()\ninvalid = [True]\ndiscover_digits(guess, final, 0, digit, invalid)\nif invalid[0] == True:\n\tprint(\"Incorrect data\")\nelif len(final) < 4:\n\tprint(\"Need more data\")\nelse:\n# stage 2: towards the number\n\tanswer = []\n\tfor i in final:\n\t\tanswer.append(i)\n\tans = get_answer(guess, final, 0, answer)\n\tfor i in ans:\n\t\tprint(i, end= '')\n\n"}, {"source_code": "'''input\n6\n1234 3 0\n1235 3 0\n1236 3 0\n1237 3 0\n1238 3 0\n1239 3 0\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\nfrom copy import deepcopy\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection():\n\tpass\n\ndef discover_digits(guess, index, final, base):\n\tif index == len(guess):\n\t\tif len(base) == 3:\n\t\t\tmyset = {1, 2,3, 4, 5,6,7,8,9, 0}\n\t\t\tcomb = combinations(myset, 4 - len(base))\n\t\t\tfor i in comb:\n\t\t\t\tcbase = deepcopy(base)\n\t\t\t\tfor j in i:\n\t\t\t\t\tcbase.add(j)\n\t\t\t\tfinal.append(cbase)\n\n\t\telse:\n\t\t\tfinal.append(list(base))\n\t\treturn\n\t\t\n\n\telse:\n\t\tnum, first, second = guess[index]\n\t\tfirst = int(first)\n\t\tsecond = int(second)\n\t\tnum = list(map(int, list(num)))\n\n\t\tcomb = combinations(num, first + second)\n\t\tfor i in comb:\n\t\t\ti = list(i)\n\t\t\tcbase = deepcopy(base)\n\t\t\tfor j in i:\n\t\t\t\tcbase.add(j)\n\t\t\tdiscover_digits(guess, index + 1, final, cbase)\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, answer):\n\twhile len(answer) < 4:\n\t\tanswer.append(-1)\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\treturn ans\n\n\ndef check_invalid(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) != 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) > 0:\n\t\t\t\treturn False\n\treturn True\n\n\t\n\tif count == 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef check_unique(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) == 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) == 4:\n\t\t\t\ttans = ans\n\t\t\t\tcount += 1\n\n\n\t\n\tif count >= 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n\n# getting ready final list\nfinal = []\nbase = set()\ndiscover_digits(guess, 0, final, base)\n\n# print(final)\n# checking for right answer\nif check_unique(final):\n\texit()\nif check_invalid(final):\n\tprint(\"Incorrect data\")\t\n\texit()\nelse:\n\tprint(\"Need more data\")\n\texit()\n\n"}, {"source_code": "'''input\n2\n0123 1 1\n4567 1 2\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\nfrom copy import deepcopy\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection():\n\tpass\n\ndef discover_digits(guess):\n\tmyset = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}\n\tflag = 0\n\tcount = 0\n\tfinal = []\n\tcomb = combinations(myset, 4)\n\tfor i in comb:\n\t\tans = get_answer(guess, list(i))\n\t\tif len(ans) == 4:\n\t\t\tcount += 1\n\t\t\tfinal = ans\n\t\t\tflag = 1\n\tif count == 1:\n\t\tfor i in final:\n\t\t\tprint(i, end = '')\n\telif count > 1:\n\t\tprint(\"Need more data\")\n\tif flag == 0:\n\t\tprint(\"Incorrect data\")\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, answer):\n\twhile len(answer) < 4:\n\t\tanswer.append(-1)\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\treturn ans\n\n\ndef check_invalid(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) != 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) > 0:\n\t\t\t\treturn False\n\treturn True\n\n\t\n\tif count == 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef check_unique(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) == 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) == 4:\n\t\t\t\ttans = ans\n\t\t\t\tcount += 1\n\n\n\t\n\tif count >= 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n\n# getting ready final list\nfinal = []\nbase = set()\ndiscover_digits(guess)\n"}, {"source_code": "'''input\n1\n1234 0 0\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection(num, base, total, final, invalid, index):\n\t# print(base, total)\n\tnum = set(list(map(int, list((str(num))))))\n\taux = []\n\tcommon = set(base).intersection(num)\n\tif 4 - len(base) >= total - len(common) and invalid[0] == True:\n\t\tif index != 0 and len(guess) > 1:\n\t\t\tinvalid[0] = False\n\t\telif index == 0 and len(guess) == 1:\n\t\t\tinvalid[0] = False\n\tfor i in common:\n\t\tfinal.add(i)\n\tif total == 4:\n\t\tinvalid[0] = False\n\t\tfor i in num:\n\t\t\tfinal.add(i)\n\n\t\treturn aux\n\telse:\n\t\tcom = combinations(num, total)\n\t\tfor i in com:\n\t\t\taux.append(list(i))\n\t\treturn aux\n\n\ndef discover_digits(guess, final, index, digit, invalid):\n\tif index == len(guess):\n\t\treturn\n\n\telse:\n\t\tif len(final) == 4:\n\t\t\tinvalid[0] = False\n\t\t\treturn\n\n\t\tnum, first, second = guess[index]\n\t\tfirst = int(first); second = int(second)\n\t\ttotal = first + second\n\t\t\n\t\tdigit_arr = take_intersection(num, digit, total, final, invalid, index)\n\t\tfor i in digit_arr:\n\t\t\tdiscover_digits(guess, final, index + 1, i, invalid)\n\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, final, index, answer):\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\n\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n# stage 1: Guess the digit\ndigit = []\nfinal = set()\ninvalid = [True]\ndiscover_digits(guess, final, 0, digit, invalid)\nif invalid[0] == True:\n\tprint(\"Incorrect data\")\nelif len(final) < 4:\n\tprint(\"Need more data\")\nelse:\n# stage 2: towards the number\n\tanswer = []\n\tfor i in final:\n\t\tanswer.append(i)\n\tans = get_answer(guess, final, 0, answer)\n\tfor i in ans:\n\t\tprint(i, end= '')\n\n"}, {"source_code": "'''input\n2\n0123 1 1\n4567 1 2\n'''\nfrom sys import stdin, setrecursionlimit\nimport math\nfrom collections import defaultdict, deque\nimport time\nfrom itertools import combinations, permutations\nfrom copy import deepcopy\n\nsetrecursionlimit(15000)\n\n\ndef take_intersection():\n\tpass\n\n\ndef discover_digits(guess, index, final, base):\n\tif index == len(guess):\n\t\tfinal.append(list(base))\n\t\treturn\n\t\t\n\n\telse:\n\t\tnum, first, second = guess[index]\n\t\tfirst = int(first)\n\t\tsecond = int(second)\n\t\tnum = list(map(int, list(num)))\n\n\t\tcomb = combinations(num, first + second)\n\t\tfor i in comb:\n\t\t\ti = list(i)\n\t\t\tcbase = deepcopy(base)\n\t\t\tfor j in i:\n\t\t\t\tcbase.add(j)\n\t\t\tdiscover_digits(guess, index + 1, final, cbase)\n\n\ndef check(arr, guess, index):\n\tfirst = 0\n\ttotal = 0\n\tsecond = 0\n\tfor i in range(4):\n\t\tif arr[i] == int(guess[index][0][i]):\n\t\t\tfirst += 1\n\t\tif str(arr[i]) in guess[index][0]:\n\t\t\ttotal += 1\n\tsecond = total - first\n\tif first == int(guess[index][1]) and second == int(guess[index][2]):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\ndef get_answer(guess, answer):\n\tperm = permutations(answer)\n\tflag = 0\n\tans = []\n\tfor i in perm:\n\t\tif flag == 1:\n\t\t\treturn ans\n\t\ti = list(i)\n\t\tfor j in range(len(guess)):\n\t\t\tnum = guess[j][0]\n\t\t\tif check(i, guess, j):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tflag = 0\n\t\t\t\tbreak\n\t\telse:\n\t\t\tflag = 1\n\t\t\tans = i\n\treturn ans\n\n\ndef check_invalid(final):\n\tfor element in final:\n\t\tif len(element) > 4:\n\t\t\tpass\n\t\telse:\n\t\t\treturn False\n\treturn True\n\n\ndef check_unique(final):\n\tcount = 0\n\ttans = []\n\tfor element in final:\n\t\tif len(element) == 4:\n\t\t\tans = get_answer(guess, element)\n\t\t\tif len(ans) == 4:\n\t\t\t\ttans = ans\n\t\t\t\tcount += 1\n\n\n\t\n\tif count == 1:\n\t\tfor i in tans:\n\t\t\tprint(i, end = '')\n\t\treturn True\n\telse:\n\t\treturn False\n\n\n# main starts\nn = int(stdin.readline().strip())\nguess = []\nfor _ in range(n):\n\tguess.append(list(map(str, stdin.readline().split())))\n\n\n# getting ready final list\nfinal = []\nbase = set()\ndiscover_digits(guess, 0, final, base)\n\n#print(final)\n# checking for right answer\n\nif check_unique(final):\n\texit()\nif check_invalid(final):\n\tprint(\"Incorrect data\")\t\n\texit()\nelse:\n\tprint(\"Need more data\")\n\texit()\n\n"}], "src_uid": "142e5f2f08724e53c234fc2379216b4c"} {"nl": {"description": "In the spirit of the holidays, Saitama has given Genos two grid paths of length n (a weird gift even by Saitama's standards). A grid path is an ordered sequence of neighbouring squares in an infinite grid. Two squares are neighbouring if they share a side.One example of a grid path is (0,\u20090)\u2009\u2192\u2009(0,\u20091)\u2009\u2192\u2009(0,\u20092)\u2009\u2192\u2009(1,\u20092)\u2009\u2192\u2009(1,\u20091)\u2009\u2192\u2009(0,\u20091)\u2009\u2192\u2009(\u2009-\u20091,\u20091). Note that squares in this sequence might be repeated, i.e. path has self intersections.Movement within a grid path is restricted to adjacent squares within the sequence. That is, from the i-th square, one can only move to the (i\u2009-\u20091)-th or (i\u2009+\u20091)-th squares of this path. Note that there is only a single valid move from the first and last squares of a grid path. Also note, that even if there is some j-th square of the path that coincides with the i-th square, only moves to (i\u2009-\u20091)-th and (i\u2009+\u20091)-th squares are available. For example, from the second square in the above sequence, one can only move to either the first or third squares.To ensure that movement is not ambiguous, the two grid paths will not have an alternating sequence of three squares. For example, a contiguous subsequence (0,\u20090)\u2009\u2192\u2009(0,\u20091)\u2009\u2192\u2009(0,\u20090) cannot occur in a valid grid path.One marble is placed on the first square of each grid path. Genos wants to get both marbles to the last square of each grid path. However, there is a catch. Whenever he moves one marble, the other marble will copy its movement if possible. For instance, if one marble moves east, then the other marble will try and move east as well. By try, we mean if moving east is a valid move, then the marble will move east.Moving north increases the second coordinate by 1, while moving south decreases it by 1. Similarly, moving east increases first coordinate by 1, while moving west decreases it.Given these two valid grid paths, Genos wants to know if it is possible to move both marbles to the ends of their respective paths. That is, if it is possible to move the marbles such that both marbles rest on the last square of their respective paths.", "input_spec": "The first line of the input contains a single integer n (2\u2009\u2264\u2009n\u2009\u2264\u20091\u2009000\u2009000)\u00a0\u2014 the length of the paths. The second line of the input contains a string consisting of n\u2009-\u20091 characters (each of which is either 'N', 'E', 'S', or 'W')\u00a0\u2014 the first grid path. The characters can be thought of as the sequence of moves needed to traverse the grid path. For example, the example path in the problem statement can be expressed by the string \"NNESWW\". The third line of the input contains a string of n\u2009-\u20091 characters (each of which is either 'N', 'E', 'S', or 'W')\u00a0\u2014 the second grid path.", "output_spec": "Print \"YES\" (without quotes) if it is possible for both marbles to be at the end position at the same time. Print \"NO\" (without quotes) otherwise. In both cases, the answer is case-insensitive.", "sample_inputs": ["7\nNNESWW\nSWSWSW", "3\nNN\nSS"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample, the first grid path is the one described in the statement. Moreover, the following sequence of moves will get both marbles to the end: NNESWWSWSW.In the second sample, no sequence of moves can get both marbles to the end."}, "positive_code": [{"source_code": "def prefix(s):\n v = [0]*len(s)\n for i in range(1,len(s)):\n k = v[i-1]\n while k > 0 and s[k] != s[i]:\n k = v[k-1]\n if s[k] == s[i]:\n k = k + 1\n v[i] = k\n return v\n\nn = int(input())\nn-=1\ns1 = input()\ns2 = input()\nopos = {'W':'E', 'E':'W', 'N':'S', 'S':'N'}\ns3 = ''\nfor elem in s2:\n s3 += opos[elem]\n \ns3 = s3[::-1]\ns = s3 + '$' + s1\n\na = prefix(s)[2 * n]\nif a == 0: print('YES')\nelse: print('NO')\n\n"}, {"source_code": "from time import time\n\n\nopposite = {\n 'N': 'S',\n 'S': 'N',\n 'E': 'W',\n 'W': 'E'\n}\notr = str.maketrans(opposite)\n\nbits = {\n 'N': 0,\n 'S': 1,\n 'E': 2,\n 'W': 3,\n}\n\nQ = 4294967291\n\n\ndef combine(h, v, q):\n return (h<<2 | v) % q\n\n\ndef combinel(h, v, q, s):\n return (v*s + h) % q\n\n\ndef flip(s):\n return ''.join(reversed(s.translate(otr)))\n\n\ndef solvable(p1, p2):\n h1 = 0\n h2 = 0\n s = 1\n for i in reversed(range(len(p1))):\n n1 = bits[p1[i]]\n n2 = bits[opposite[p2[i]]]\n h1 = combine(h1, n1, Q)\n h2 = combinel(h2, n2, Q, s)\n if h1 == h2 and p1[i:] == flip(p2[i:]):\n return False\n s = (s<<2) % Q\n return True\n\n\nif __name__ == '__main__':\n n = int(input())\n p1 = input()\n p2 = input()\n print('YES' if solvable(p1, p2) else 'NO')\n"}, {"source_code": "from time import time\n\n\nopposite = {\n 'N': 'S',\n 'S': 'N',\n 'E': 'W',\n 'W': 'E'\n}\notr = str.maketrans(opposite)\n\nbits = {\n 'N': 0,\n 'S': 1,\n 'E': 2,\n 'W': 3,\n}\n\nQ = 4294967291\n\n\ndef combine(h, v, q):\n return (h<<2 | v) % q\n\n\ndef combinel(h, v, q, s):\n return (v*s + h) % q\n\n\ndef flip(s):\n return ''.join(reversed(s.translate(otr)))\n\n\ndef solvable(p1, p2):\n h1 = 0\n h2 = 0\n s = 1\n for i in reversed(range(len(p1))):\n n1 = bits[p1[i]]\n n2 = bits[opposite[p2[i]]]\n h1 = combine(h1, n1, Q)\n h2 = combinel(h2, n2, Q, s)\n if h1 == h2 and p1[i:] == flip(p2[i:]):\n return False\n s = (s<<2) % Q\n return True\n\n\nif __name__ == '__main__':\n n = int(input())\n p1 = input()\n p2 = input()\n print('YES' if solvable(p1, p2) else 'NO')\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "import os\n\ndef main_entry():\n c2i = {'N':0, 'S':1, 'W':2, 'E':3}\n while True:\n try:\n n = int(raw_input())\n except ValueError:\n continue\n except EOFError:\n break\n a = str(raw_input())[::-1]\n b = str(raw_input())\n c = ''\n for k in a:\n c += str(c2i[k]^1)\n c += '#'\n for k in b:\n c += str(c2i[k])\n n = len(c)\n f = [-1 for i in xrange(n)]\n for i in range(1, n):\n k = f[i-1]\n while k>=0 and c[i]!=c[k+1]:\n k = f[k]\n if c[i]==c[k+1]:\n f[i] = k+1\n if f[n-1]==-1:\n print 'YES'\n else:\n print 'NO'\n\nif __name__ == '__main__':\n main_entry()\n"}], "negative_code": [{"source_code": "def prefix(s):\n v = [0]*len(s)\n for i in range(1,len(s)):\n k = v[i-1]\n while k > 0 and s[k] != s[i]:\n k = v[k-1]\n if s[k] == s[i]:\n k = k + 1\n v[i] = k\n return v\n\nn = int(input())\nn-=1\ns1 = input()\ns2 = input()\nopos = {'W':'E', 'E':'W', 'N':'S', 'S':'N'}\ns3 = ''\nfor elem in s2:\n s3 += opos[elem]\n \ns3[::-1]\ns = s3 + '$' + s1\n\na = prefix(s)[2 * n]\nif a == 0: print('YES')\nelse: print('NO')\n\n"}, {"source_code": "import heapq\n\n\nopposite = {\n 'N': 'S',\n 'S': 'N',\n 'E': 'W',\n 'W': 'E'\n}\n\n\ndef move(m, i, p):\n if i < len(p) and m == p[i]:\n return i+1\n elif i > 0 and opposite[m] == p[i-1]:\n return i-1\n else:\n return i\n\ndef solvable(p1, p2):\n n = len(p1)\n pq = [(n, (0, 0))]\n seen = {(0, 0)}\n while pq:\n _, (i, j) = heapq.heappop(pq)\n print(p1[:i]+\"|\"+p1[i:])\n print(p2[:j]+\"|\"+p2[j:])\n print()\n if i == j == n:\n return True\n for m in 'NEWS':\n i_ = move(m, i, p1)\n j_ = move(m, j, p2)\n ij_ = i_, j_\n if ij_ not in seen:\n seen.add(ij_)\n heapq.heappush(pq, (n-min(i_, j_), ij_))\n return False\n\n\n\nif __name__ == '__main__':\n n = int(input())\n p1 = input()\n p2 = input()\n print('YES' if solvable(p1, p2) else 'NO')\n"}, {"source_code": "from time import time\n\n\nopposite = {\n 'N': 'S',\n 'S': 'N',\n 'E': 'W',\n 'W': 'E'\n}\notr = str.maketrans(opposite)\n\nbits = {\n 'N': 0,\n 'S': 1,\n 'E': 2,\n 'W': 3,\n}\n\nQ = 4294967291\n\n\ndef combine(h, v, q):\n return (h<<2 | v) % q\n\n\ndef combinel(h, v, q, s):\n return (v*s + h) % q\n\n\ndef flip(s):\n return ''.join(reversed(s.translate(otr)))\n\n\ndef solvable(p1, p2):\n h1 = 0\n h2 = 0\n s = 0\n for i in reversed(range(len(p1))):\n n1 = bits[p1[i]]\n n2 = bits[opposite[p2[i]]]\n h1 = combine(h1, n1, Q)\n h2 = combinel(h2, n2, Q, s)\n if h1 == h2 and p1[i:] == flip(p2[i:]):\n return False\n s = (s<<2) % Q\n return True\n\n\nif __name__ == '__main__':\n n = int(input())\n p1 = input()\n p2 = input()\n print('YES' if solvable(p1, p2) else 'NO')\n"}, {"source_code": "import os\n\ndef main_entry():\n c2i = {'N':0, 'S':1, 'W':2, 'E':3}\n while True:\n try:\n n = int(raw_input())\n except ValueError:\n continue\n except EOFError:\n break\n a = str(raw_input())\n b = str(raw_input())\n c = ''\n for k in a:\n c += str(c2i[k]^1)\n c += '#'\n for k in b:\n c += str(c2i[k])\n n = len(c)\n f = [-1 for i in xrange(n)]\n for i in range(1, n):\n k = f[i-1]\n while k>=0 and c[i]!=c[k+1]:\n k = f[k]\n if c[i]==c[k+1]:\n f[i] = k+1\n if f[n-1]==-1:\n print 'YES'\n else:\n print 'NO'\n\nif __name__ == '__main__':\n main_entry()\n"}], "src_uid": "85f43628bec7e9b709273c34b894df6b"} {"nl": {"description": "In this task Anna and Maria play a game with a very unpleasant rival. Anna and Maria are in the opposite squares of a chessboard (8\u2009\u00d7\u20098): Anna is in the upper right corner, and Maria is in the lower left one. Apart from them, the board has several statues. Each statue occupies exactly one square. A square that contains a statue cannot have anything or anyone \u2014 neither any other statues, nor Anna, nor Maria.Anna is present on the board as a figurant (she stands still and never moves), and Maria has been actively involved in the game. Her goal is \u2014 to come to Anna's square. Maria and statues move in turn, Maria moves first. During one move Maria can go to any adjacent on the side or diagonal cell in which there is no statue, or she can stay in the cell where she is. The statues during their move must go one square down simultaneously, and those statues that were in the bottom row fall from the board and are no longer appeared.At that moment, when one of the statues is in the cell in which the Maria is, the statues are declared winners. At the moment when Maria comes into the cell where Anna has been waiting, Maria is declared the winner.Obviously, nothing depends on the statues, so it all depends on Maria. Determine who will win, if Maria does not make a strategic error.", "input_spec": "You are given the 8 strings whose length equals 8, describing the initial position on the board. The first line represents the top row of the board, the next one \u2014 for the second from the top, and so on, the last line represents the bottom row. Each character string matches a single cell board in the appropriate row, and the characters are in the same manner as that of the corresponding cell. If the cell is empty, the corresponding character is \".\". If a cell has Maria, then it is represented by character \"M\". If a cell has Anna, it is represented by the character \"A\". If a cell has a statue, then the cell is represented by character \"S\". It is guaranteed that the last character of the first row is always \"A\", the first character of the last line is always \"M\". The remaining characters are \".\" or \"S\".", "output_spec": "If Maria wins, print string \"WIN\". If the statues win, print string \"LOSE\".", "sample_inputs": [".......A\n........\n........\n........\n........\n........\n........\nM.......", ".......A\n........\n........\n........\n........\n........\nSS......\nM.......", ".......A\n........\n........\n........\n........\n.S......\nS.......\nMS......"], "sample_outputs": ["WIN", "LOSE", "LOSE"], "notes": null}, "positive_code": [{"source_code": "f = []\nfor i in range(8):\n f.append(input())\n\nd = [[[0 for i in range(8)] for j in range(8)] for k in range(100)]\n\nd[0][7][0] = 1\ndx = [1, 1, 1, 0, 0, -1, -1, -1, 0]\ndy = [1, 0, -1, 1, -1, 1, 0, -1, 0]\n\nans = 'LOSE'\nfor i in range(99):\n for x in range(8):\n for y in range(8):\n if not d[i][x][y]:\n continue\n for j in range(9):\n nx = x + dx[j]\n ny = y + dy[j]\n if not(0 <= nx < 8 and 0 <= ny < 8):\n continue\n\n valid = True\n if 0 <= nx - i < 8 and f[nx - i][ny] == 'S':\n valid = False\n if 0 <= nx - i - 1 < 8 and f[nx - i - 1][ny] == 'S':\n valid = False\n \n if not valid:\n continue\n d[i + 1][nx][ny] = 1\n if nx == 0 and ny == 7:\n ans = 'WIN'\nprint(ans)\n"}, {"source_code": "grid = [ list(input().strip()) for r in range(8) ]\ngrid[0][7] = '.'\ngrid[7][0] = '.'\nmark = [ [ False for c in range(8) ] for r in range(8) ]\nmark[7][0] = True\n\ndef display_grid():\n print('\\n'.join(map(lambda row: ''.join(row), grid)))\n print()\n\ndef display_mark():\n for row in mark:\n row = map(lambda a: 'X' if a else '_', row)\n print(''.join(row))\n print()\n\nfor i in range(8):\n moved = False\n new_mark = [ [ False for c in range(8) ] for r in range(8) ]\n for r in range(8):\n for c in range(8):\n if not mark[r][c]:\n continue\n for R in range(max(0, r - 1), min(r + 2, 8)):\n for C in range(max(0, c - 1), min(c + 2, 8)):\n if grid[R][C] == 'S':\n continue\n if R - 1 >= 0 and grid[R - 1][C] == 'S':\n continue\n new_mark[R][C] = True\n moved = True\n mark = new_mark\n grid.insert(0, 8 * [ '.' ])\n grid.pop()\n if not moved:\n break\n\nif moved:\n print('WIN')\nelse:\n print('LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "def play(b, x, y, c):\n if c == 9:\n return True\n if b[c][y][x] == 'S':\n return False\n dx = [-1, 1, 0, 0, 0, 1, 1, -1, -1]\n dy = [0, 0, -1, 1, 0, -1, 1, -1, 1]\n for i in range(len(dx)):\n nx = x + dx[i]\n ny = y + dy[i]\n if min(nx, ny) < 0 or max(nx, ny) >= 8: continue\n if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):\n return True\n return False\n\nboard = []\nfor x in range(8):\n board.append(input().strip())\nB = [board]\nfor x in range(10):\n b = B[-1]\n b_ = b[:]\n b_[0] = b_[0][:-1] + '.'\n b_.insert(0, \".......A\")\n B.append(b_[:-1])\nif play(B, 0, 7, 0):\n print(\"WIN\")\nelse:\n print(\"LOSE\")"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "from itertools import product\nfrom queue import Queue\nBOARD_SIZE = 10\nOCC, EMPTY = 1, 0\nVISITED = 2\nboard = [input() for _ in range(8)]\ngraph = []\nfor _ in range(BOARD_SIZE):\n graph += [[[EMPTY for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)]]\n\nfor i, j in product(range(8), repeat = 2):\n if board[i][j] == 'S':\n graph[0][i + 1][j + 1] = OCC\n\nfor i in range(BOARD_SIZE):\n graph[0][i][0] = OCC\n graph[0][i][BOARD_SIZE - 1] = OCC\n graph[0][0][i] = OCC\n graph[0][BOARD_SIZE - 1][i] = OCC\n\nfor time in range(1, BOARD_SIZE):\n for i, j in product(range(2, 9), range(1, 9)):\n graph[time][i][j] = graph[time - 1][i - 1][j]\n for i in range(BOARD_SIZE):\n graph[time][i][0] = OCC\n graph[time][i][BOARD_SIZE - 1] = OCC\n graph[time][0][i] = OCC\n graph[time][BOARD_SIZE - 1][i] = OCC\n\nQ = Queue()\nQ.put((0, 8, 1))\n\npos_moves = [\n [-1, -1],\n [-1, 0],\n [-1, 1],\n [0, -1],\n [0, 0],\n [0, 1],\n [1, -1],\n [1, 0],\n [1, 1]\n]\n\nwhile not Q.empty():\n time, i, j = Q.get()\n if time < BOARD_SIZE - 1:\n for d in pos_moves:\n if graph[time][i + d[0]][j + d[1]] != OCC and \\\n graph[time + 1][i + d[0]][j + d[1]] == EMPTY:\n graph[time + 1][i + d[0]][j + d[1]] = VISITED\n Q.put((time + 1, i + d[0], j + d[1]))\n\nany_pos = False\n\nfor i, j in product(range(1, 9), repeat = 2):\n if graph[BOARD_SIZE - 1][i][j] == VISITED:\n any_pos = True\n\n# WA on some 19 test\n\nif any_pos:\n print(\"WIN\")\nelse:\n print(\"LOSE\")\n"}, {"source_code": "r = lambda: raw_input().strip()\n\ndef check_possibility(new_position, M):\n if len(M) == 0:\n print 'WIN'\n exit()\n candidate_moves = []\n for c in [(0,0),(-1,0),(1,0),(0,1),(0,-1),(-1,-1),(-1,1),(1,-1),(1,1)]:\n new_coord = (new_position[0]+c[0], new_position[1]+c[1])\n if 0 <= new_coord[0] <= 7 and 0 <= new_coord[1] <= 7:\n candidate_moves.append(new_coord)\n candidate_moves = [c for c in candidate_moves if c not in M.keys()]\n M = dict([[(c[0],c[1]+1),'S'] for c in M.keys() if c[1]<7])\n candidate_moves = [c for c in candidate_moves if c not in M.keys()]\n for c in candidate_moves:\n check_possibility(c, dict(M.items()))\n\n\nstatue_locations = {}\nfor i in xrange(8):\n row = list(r())\n for j in xrange(8):\n if row[j] == 'S':\n statue_locations[(j,i)] = row[j]\n\n\ncheck_possibility((0,7), dict(statue_locations.items()))\nprint 'LOSE'\n"}, {"source_code": "g = [ [raw_input() for i in range(8)] ]\nfor i in range(9):\n tmp = []\n tmp.append('........')\n for j in range(7):\n tmpstr = ''\n for k in range(8):\n if g[i][j][k] == 'S':\n tmpstr += 'S'\n else:\n tmpstr += '.'\n tmp.append(tmpstr)\n g.append(tmp)\ndire = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)]\nX, Y, STEP = 0, 1, 2\nstack = [(7,0,0)]\nflag = False\nwhile len(stack):\n curr = stack.pop()\n if curr[X] == 0 and curr[Y] == 7 or curr[STEP] == 9:\n flag = True\n break\n for d in dire:\n newX = curr[X] + d[X]\n newY = curr[Y] + d[Y]\n if newX >= 0 and newX < 8 and newY >= 0 and newY < 8:\n if g[curr[STEP]][newX][newY] != 'S' and g[curr[STEP] + 1][newX][newY] != 'S':\n stack.append((newX, newY, curr[STEP] + 1))\nif flag:\n print 'WIN'\nelse:\n print 'LOSE'\n#from pprint import pprint\n#pprint(g)"}, {"source_code": "from ctypes import *\nDim = 8\nMap = c_int * Dim * Dim\nEmpty = 0\nA = 1\nM = 2\nS = 3\n\ndef pmap(m):\n\tprint '-'*20\n\tfor i in xrange(Dim):\n\t\tfor j in xrange(Dim):\n\t\t\tprint m[i][j],\n\t\tprint\n\ndef readmap():\n\t# return map, without A\n\tm = Map()\n\tfor i in xrange(Dim):\n\t\ts = raw_input()\n\t\tfor j in xrange(Dim):\n\t\t\tcell = s[j]\n\t\t\tif cell == 'S':\n\t\t\t\tm[i][j] = S\n\t\t\telse:\n\t\t\t\tm[i][j] = Empty\n\treturn m\n\ndef nextMove(m):\n\t# m is the map\n\tss = []\n\tfor i in xrange(Dim):\n\t\tfor j in xrange(Dim):\n\t\t\tif m[i][j] == S:\n\t\t\t\tss.append((i, j))\n\tnewm = Map()\n\tfor i, j in ss:\n\t\ttry:\n\t\t\tnewm[i+1][j] = S\n\t\texcept IndexError:\n\t\t\tpass\n\treturn newm\n\nms = []\nms.append(readmap())\nfor t in xrange(1, 9):\n\tms.append(nextMove(ms[-1]))\n\ndef bfs(start, end, ms):\n\tDIR = ((0, 0), (-1, 0), (1, 0), (0, -1), (0, 1), (-1, 1), (-1, -1), (1, -1), (1, 1))\n\tque = [] # items: (posx, posy, t)\n\tque.append((start[0], start[1], 0))\n\tvis = set()\n\twhile que:\n\t\t# print que\n\t\ti, j, t = que.pop()\n\t\tfor di, dj in DIR:\n\t\t\tp = i+di, j+dj, t+1\n\t\t\tif p[0] >= 0 and p[0] < Dim and p[1] >= 0 and p[1] < Dim:\n\t\t\t\t# pmap(ms[t+1])\n\t\t\t\tif (p not in vis) and ms[t][p[0]][p[1]] == Empty and ms[t+1][p[0]][p[1]] == Empty:\n\t\t\t\t\tque.append(p)\n\t\t\t\t\tvis.add(p)\n\t\t\t\tif t + 1 == 8:\n\t\t\t\t\treturn True\n\treturn False\n\nif bfs((Dim-1, 0), (0, Dim-1), ms):\n\tprint 'WIN'\nelse:\n\tprint 'LOSE'\n\n"}, {"source_code": "def play(b, x, y, c):\n if c == 9:\n return True\n if b[c][y][x] == 'S':\n return False\n dx = [-1, 1, 0, 0, 0, 1, 1, -1, -1]\n dy = [0, 0, -1, 1, 0, -1, 1, -1, 1]\n for i in range(len(dx)):\n nx = x + dx[i]\n ny = y + dy[i]\n if min(nx, ny) < 0 or max(nx, ny) >= 8: continue\n if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):\n return True\n return False\n\nboard = []\nfor x in range(8):\n board.append(raw_input().strip())\nB = [board]\nfor x in range(10):\n b = B[-1]\n b_ = b[:]\n b_[0] = b_[0][:-1] + '.'\n b_.insert(0, \".......A\")\n B.append(b_[:-1])\nif play(B, 0, 7, 0):\n print \"WIN\"\nelse:\n print \"LOSE\"\n \n"}, {"source_code": "import copy\nf=copy.deepcopy\nA=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(0,0),(1,0),(0,-1),(1,-1)]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n r2=r+x[0]\n c2=c+x[1]\n if can(r2,c2,M):\n M2=f(M)\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n dfs(r2,c2,M2)\ndef can(r,c,M): \n if 0<=r<8 and 0<=c<8 and M[r][c]!='S' and M[r-1][c]!='S':\n return 1\n return 0\nC=[[x for x in raw_input()]for i in range(8)]\ndfs(7,0,f(C))\nprint \"LOSE\"\n"}, {"source_code": "import copy\nf=copy.deepcopy\ndef d(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for t in [-1,0,1]:\n for u in [1,0,-1]:\n r2=r+t\n c2=c+u\n if e(r2,c2,M):\n M2=f(M)\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n d(r2,c2,M2)\ndef e(r,c,M): \n if 0<=r<8 and 0<=c<8 and M[r][c]!='S' and M[r-1][c]!='S':\n return 1\n return 0\nC=[[x for x in raw_input()]for i in range(8)]\nd(7,0,f(C))\nprint \"LOSE\"\n"}, {"source_code": "from copy import deepcopy\nA=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(0,0),(1,0),(0,-1),(1,-1)]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n if can(r+x[0],c+x[1],M):\n M2=deepcopy(M)\n r2=r+x[0]\n c2=c+x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n dfs(r2,c2,M2)\ndef can(r,c,M): \n if r>7 or r<0 or c>7 or c<0:\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nC=[[x for x in raw_input()]for i in range(8)]\ndfs(7,0,deepcopy(C))\nprint \"LOSE\"\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nd=[[16]*8 for i in range(8)]\ndeep=0;\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\n\t\ndef can(r,c,r1,c1):\n\tglobal d\n\treturn r+r1>=0 and r+r1<=7 and c+c1>=0 and c+c1<=7 and (d[r+r1][c+c1]>d[r][c])\n\t\ndef dfs(r,c):\n\tglobal deep,d\n\td[r][c]=deep;\n\tdeep+=1\n\t\n\tif r==0 and c==7:\n\t\tres(1)\n\t\n\tsw=0\n\tfor r1 in [-1,1,0]:\n\t\tfor c1 in [1 ,-1, 0]:\n\t\t\tif can(r,c,r1,c1):\n\t\t\t\tsw=1\n\t\t\n\tif sw:\n\t\tfor r1 in [-1,1,0]:\n\t\t\tfor c1 in [1 ,-1, 0]:\n\t\t\t\tif can(r,c,r1,c1) or (r1==0 and c1==0):\n\t\t\t\t\tA=True\t\n\t\t\t\t\tfor i in range(8):\n\t\t\t\t\t\tif s[i][c+c1]=='S' and (min(i+deep,7)==r+r1 or min(i+deep-1,7)==r+r1):\n\t\t\t\t\t\t\tA=False\n\t\t\t\t\t\n\t\t\t\t\tif A:\n\t\t\t\t\t\tdfs(r+r1,c+c1)\t\t\n\t\t\t\t\t\tdeep-=1\n\ndfs(7,0)\nres(0)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nd=[[16]*8 for i in range(8)]\ndeep=0;\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\n\t\ndef dfs(r,c):\n\tglobal deep,d\n\td[r][c]=deep;\n\tdeep+=1\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\tC=False\n\tfor i1 in [-1,1,0]:\n\t\tfor i2 in [1 ,-1, 0]:\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>d[r][c]:\n\t\t\t\tC=True\n\t\n\tif C:\n\t\tfor i1 in [-1,1,0]:\n\t\t\tfor i2 in [1 ,-1, 0]:\n\t\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and (d[r+i1][c+i2]>=deep or (i1==0 and i2==0)):\n\t\t\t\t\tA=True\t\n\t\t\t\t\tfor i in range(8):\n\t\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):\n\t\t\t\t\t\t\tA=False\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\n\t\t\t\t\tif A:\n\t\t\t\t\t\tdfs(r+i1,c+i2)\t\t\n\t\t\t\t\t\tdeep-=1\n\ndfs(7,0)\nres(False)\n"}, {"source_code": "#Codeforces , Statues\n\nimport sys\nfrom sys import stdin\nimport copy\n\nONLINE_JUDGE = 1\n\nif ONLINE_JUDGE == False:\n sys.stdin = open('input.txt', 'r')\n\n\ndef ok(x, y):\n if x >= 0 and x < 8 and y >= 0 and y < 8:\n return True\n return False\n\n\nmat = [[x for x in raw_input()] for i in range(8)]\n#print type(mat)\n\nd = [[0, 1], [0, -1], [-1, 0], [1, 0], [1, -1], [1,1], [-1, -1], [-1, 1]]\nbingo = False\nwhile True:\n tmp = copy.deepcopy(mat)\n for i in range(8):\n for j in range(8):\n if 'M' == tmp[i][j]:\n for k in range(8):\n x = i + d[k][0]\n y = j + d[k][1]\n if ok(x, y) and mat[x][y] != 'S':\n mat[x][y] = 'M'\n\n if('M' == mat[0][7]):\n bingo = True\n break\n## for i in range(8):\n## print mat[i]\n## print \n for i in range(7, -1, -1):\n for j in range(8):\n if 'S' == mat[i][j]:\n if i + 1 < 8:\n mat[i + 1][j] = 'S'\n mat[i][j] = '.'\n cnt = 0\n for i in range(8):\n for j in range(8):\n if mat[i][j] == 'M':\n cnt += 1\n\n if 0 == cnt:\n break\nif bingo:\n print 'WIN'\nelse:\n print 'LOSE'\n \n\n\n\n\n\n\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# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nF = len(lines)\nM_posi = [{'x':0, 'y':F - 1}]\nnexs = []\nans = 'WIN'\n#over ride G for time attack\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\n else:\n break\nlines = zip(*lines)\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\nlines = zip(*lines)\n#run\nfor l_num in range(F):\n nexs = []\n #Maria move\n for posi in M_posi:\n x = posi['x']\n y = posi['y']\n for i in range(-1, 2):\n nx = x + i\n for n in range(-1, 2):\n ny = y + n\n if {'x':nx, 'y':ny} in nexs:\n continue\n if nx < F and nx > -1 and ny < F and ny > -1:\n if lines[ny][nx] == 'G':\n ans = 'GET G'\n if lines[ny][nx] != 'S':\n nexs.append({'x':nx, 'y':ny})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n elif ans == 'GET G':\n ans = 'WIN'\n break\n M_posi = nexs[:]\nprint ans\n"}, {"source_code": "from sys import stdin\nfrom collections import *\nfrom copy import deepcopy\n\n\ndef valid(i, j):\n n, m = [8] * 2\n return i > -1 and i < n and j > -1 and j < m\n\n\ndef str_inp(n):\n return list(reversed(list((list(stdin.readline()[:-1]) for x in range(n)))))\n\n\ndef check(x, y, step):\n if step + 1 < 8 and all[step + 1][x][y] == 'S' or step < 8 and all[step][x][y] == 'S':\n # print(all[step][x][y], x, y)\n return False\n\n return True\n\n\ndef print_maze(x):\n for i in range(8):\n print(*all[x][i], sep='')\n print(end='\\n')\n\n\ndef dfs(x, y):\n stack, visit, step = [[x, y, -1]], defaultdict(int), -1\n\n while (stack):\n x, y, step = stack.pop()\n step += 1\n\n if chess[x][y] == 'A':\n exit(print('WIN'))\n\n st = 0\n\n for i in range(9):\n nx, ny = [x + dx[i], y + dy[i]]\n if i == 0:\n if step >= 8:\n continue\n else:\n visit[nx, ny] = 0\n\n if valid(nx, ny) and check(nx, ny, step) and not visit[nx, ny]:\n stack.append([nx, ny, step])\n # print(nx, ny, step, check(nx, ny, step))\n # print_maze(min(step, 7))\n visit[nx, ny] = 1\n else:\n st += 1\n # print(stack, step)\n if st == 9:\n step -= 1\n visit[x, y] = 0\n\n\ndx, dy, chess = [0, -1, 0, 1, 0, 1, -1, 1, -1], [0, 0, 1, 0, -1, 1, -1, -1, 1], str_inp(8)\nall, ini = [chess], [['.' for i in range(8)] for j in range(8)]\n\nfor k in range(1, 9):\n tem = deepcopy(ini)\n for i in range(8):\n for j in range(8):\n if chess[i][j] == 'S' and i - k > -1:\n tem[i - k][j] = 'S'\n all.append(tem)\n\ndfs(0, 0)\nprint('LOSE')\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport copy\n\ninvalid = []\n\ndef isWin(board, mi, mj, turn):\n for row in board:\n if 'S' in row:\n return False\n return True\n\ndef dfs(board, mi, mj, turn):\n\n if isWin(board, mi, mj, turn):\n return True\n elif (mi*100+mj*10+turn) in invalid:\n return False\n else:\n for i in range(-1, 2):\n for j in range(-1, 2):\n # Maria's turn\n if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):\n next_board = copy.deepcopy(board)\n next_board[mi][mj] = '.'\n # next_board[mi+i][mj+j] = 'M'\n\n # Statues's turn\n if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':\n next_board = [['.']*8] + next_board[: -1]\n next_board[mi+i][mj+j] = 'M' \n if dfs(next_board, mi+i, mj+j, turn+1):\n return True\n invalid.append(mi*100+mj*10+turn)\n return False\n\ndef main():\n board = [[cell for cell in raw_input()] for _ in range(8)]\n\n if dfs(board, 7, 0, 0):\n print 'WIN'\n else:\n print 'LOSE'\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "d = [-1, 0, 1]\ns = [raw_input() for _ in range(8)]\nm = [(7, 0)]\nfor step in range(8):\n t = []\n for x, y in m:\n for dx in d:\n for dy in d:\n tx, ty = x + dx, y + dy\n if (tx, ty) not in t:\n if 0 <= tx < 8 and 0 <= ty < 8:\n ok = 1\n if tx - step >= 0: ok &= s[tx - step][ty]!='S'\n if tx - step - 1 >= 0: ok &= s[tx - step - 1][ty]!='S'\n if ok: t.append((tx, ty))\n m = t\nprint m and 'WIN' or 'LOSE'\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nr=[(7,0)]\nfor step in range(8):\n t=[]\n for x,y in r:\n for dx in [-1,0,1]:\n for dy in [-1,0,1]:\n xx = x+dx\n yy = y+dy\n if (xx,yy) not in t:\n if 0<=xx<8 and 0<=yy<8:\n ok = True\n if xx-step>=0:\n ok &= s[xx-step][yy]!='S'\n if xx-step-1>=0:\n ok &= s[xx-step-1][yy]!='S'\n if ok:\n t.append((xx,yy))\n r=t\nif r:\n print 'WIN'\nelse:\n print 'LOSE'\n"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nF = len(lines)\nM_posi = [{'x':0, 'y':F - 1}]\nnexs = []\nans = 'WIN'\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\n else:\n break\nlines = zip(*lines)\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\nlines = zip(*lines)\nfor l_num in range(F):\n nexs = []\n #Maria move\n for posi in M_posi:\n x = posi['x']\n y = posi['y']\n for i in range(-1, 2):\n nx = x + i\n for n in range(-1, 2):\n ny = y + n\n if {'x':nx, 'y':ny} in nexs:\n continue\n if nx < F and nx > -1 and ny < F and ny > -1:\n if lines[ny][nx] == 'G':\n ans = 'GET G'\n if lines[ny][nx] != 'S':\n nexs.append({'x':nx, 'y':ny})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n elif ans == 'GET G':\n ans = 'WIN'\n break\n M_posi = nexs[:]\nprint ans\n"}, {"source_code": "d = [-1, 0, 1]\ns = [raw_input() for _ in range(8)]\nm = [(7, 0)]\nfor step in range(8):\n t = []\n for x, y in m:\n for dx in d:\n for dy in d:\n tx, ty = x + dx, y + dy\n if (tx, ty) not in t:\n if 0 <= tx < 8 and 0 <= ty < 8:\n ok = 1\n if tx - step >= 0: ok &= s[tx - step][ty]!='S'\n if tx - step - 1 >= 0: ok &= s[tx - step - 1][ty]!='S'\n if ok: t.append((tx, ty))\n m = t\nprint m and 'WIN' or 'LOSE'"}, {"source_code": "d=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1],[0,0]]\n\nl=[]\nfor i in range(8):\n l.append(input())\n\n#print(\"l is\",l)\n\nstatues=[]\nstatues.append([])\nfor i in range(8):\n for j in range(8):\n #print(l[i][j],l[i][j]=='S')\n if l[i][j]==\"S\":\n statues[0].append(tuple([i,j]))\n\nfor i in range(1,8):\n statues.append([])\n for statue in statues[0]:\n statues[i].append(tuple([statue[0]+i,statue[1]]))\n\n#print(statues[0])\n\n\ndef possible(move_no,pos):\n global d\n global statues\n if move_no>7 or (pos[0]==0 and pos[1]==7):\n #print(move_no, pos[0],pos[1])\n return(True)\n \n b=False\n for di in d:\n pos[0]+=di[0]\n pos[1]+=di[1]\n if pos[0]>-1 and pos[0]<8 and pos[1]>-1 and pos[1]<8 and tuple(pos) not in statues[move_no] and tuple([pos[0]-1,pos[1]]) not in statues[move_no]:\n #print(pos)\n if(possible(move_no+1,pos)):\n b=True\n break\n\n pos[0]-=di[0]\n pos[1]-=di[1]\n return(b)\n\n\n \nif(possible(0,[7,0])):\n print(\"WIN\")\nelse:\n print(\"LOSE\")\n\n\n\n\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')"}, {"source_code": "a=list(input() for i in range(8))\nok1=list()\nok2=set()\nok1.append((7,0))\nw=[(1,0),(-1,0),(0,1),(0,-1),(1,-1),(1,1),(-1,-1),(-1,1),(0,0)]\nfor i in range(8) :\n\tfor pos in ok1 :\n\t\tif pos[0]>=i and a[pos[0]-i][pos[1]] == 'S' :\n\t\t\tcontinue \n\t\tfor j in w:\n\t\t\tto=(pos[0]+j[0],pos[1]+j[1])\n\t\t\tif to[0]<8 and to[1]<8 and to[0]>-1 and to[1]>-1:\n\t\t\t\tif to[0]0 else \"LOSE\")"}, {"source_code": "from typing import List, Tuple\n\n\ndef is_row_clear(board: List[str], time: int, x: int, y: int) -> bool:\n if all(row[y] != 'S' for row in board):\n return True\n first_statue_index = [row[y] for row in board].index('S')\n if first_statue_index + time > x:\n return True\n else:\n return False\n\n\ndef moves(x: int, y: int) -> List[Tuple[int, int]]:\n adj = [(x - 1, y - 1), (x - 1, y), (x - 1, y + 1), (x, y - 1), (x, y + 1),\n (x + 1, y - 1), (x + 1, y), (x + 1, y + 1), (x, y)]\n return [(xo, yo) for xo, yo in adj if 0 <= xo < 8 and 0 <= yo < 8]\n\n\ndef solve(board: List[str]) -> str:\n stack = [(0, idx, idy) for idx, line in enumerate(board)\n for idy, sq in enumerate(line) if board[idx][idy] == 'M']\n while stack:\n time, idx, idy = stack.pop()\n if is_row_clear(board, time, idx, idy) or idx == 0:\n return 'WIN'\n for xo, yo in moves(idx, idy):\n if (\n board[xo - time][yo] != 'S' and\n board[xo - 1 - time][yo] != 'S'\n ):\n stack.append((time + 1, xo, yo))\n return 'LOSE'\n\n\nboard = [input() for _ in range(8)]\nprint(solve(board))\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "def bad(x, y, t):\n x1, y1 = x, y + t\n return 0 <= 8 - y1 < 8 and 0 <= x1 < 8 and a[8 - y1][x1] == \"S\" or 0 <= 7 - y1 < 8 and 0 <= x1 < 8 and a[7 - y1][x1] == \"S\"\n\ndp = [[[False] * 30 for i in range(8)] for j in range(8)]\na = []\nfor i in range(8):\n a.append(input().rstrip())\n\ndp[0][0][0] = True\nfor t1 in range(29):\n for x in range(8):\n for y in range(8):\n if dp[x][y][t1]:\n for i in [(x + 1, y), (x - 1, y), (x + 1, y + 1), (x - 1, y + 1), (x + 1, y - 1), (x - 1, y - 1), (x, y + 1), (x, y - 1), (x, y)]:\n if 0 <= i[0] < 8 and 0 <= i[1] < 8:\n if not bad(i[0], i[1], t1 + 1):\n dp[i[0]][i[1]][t1 + 1] = True\n\nfor i in range(30):\n if dp[7][7][i]:\n print(\"WIN\")\n exit()\nprint(\"LOSE\")"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "grid=None\ngridsovertime=None\nvisited=None\n\ndef readInput():\n\tglobal grid\n\tgrid = []\n\tfor _ in range(8):\n\t\tgrid.append(input())\n\tgrid = [[(False if char=='S' else True) for char in row] for row in grid]\n\treturn grid\n\ndef getNeighbours(pos):\n\tx,y,t = pos\n\tnewposes = []\n\tfor i in range(-1,2):\n\t\tfor j in range(-1,2):\n\t\t\tnewposes.append((x+i,y+j,t+1))\n\t# print(newposes, len(gridsovertime), len(gridsovertime[0]), len(gridsovertime[0][0]))\n\tnewposes = [(x,y,t) for x,y,t in newposes if (x>=0 and y>=0 and x<8 and y<8 and gridsovertime[t][x][y] and gridsovertime[t-1][x][y])]\n\treturn newposes\n\ndef dfs(pos):\n\tx,y,t = pos\n\tvisited[t][x][y]=True\n\tif t==10:\n\t\treturn True\n\tout = []\n\tfor x,y,t in getNeighbours(pos):\n\t\t# print(x,y,t)\n\t\tif visited[t][x][y]:\n\t\t\tcontinue\n\t\tout.append(dfs((x,y,t)))\n\treturn any(out)\n\ndef solve():\n\tglobal gridsovertime,visited\n\tgridsovertime = [grid]\n\tfor _ in range(12):\n\t\tcurrgrid = gridsovertime[-1]\n\t\tnewgrid = [[True]*8] + currgrid[:-1]\n\t\tgridsovertime.append(newgrid)\n\n\tvisited = [[[False for _ in range(8)] for _ in range(8)] for _ in range(13)]\n\n\tstart = (7,0,0)\n\t# visited[7][0][0] = True\n\treturn dfs(start)\n\n\ndef main():\n\treadInput()\n\tout = solve()\n\tif out:\n\t\tprint(\"WIN\")\n\telse:\n\t\tprint(\"LOSE\")\n\tpass\n\nif __name__ == '__main__':\n\tmain()"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x, x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')\n"}, {"source_code": "import sys\n\nf = sys.stdin.read().split()\nassert len(f) == 8 and len(f[0]) == 8\n\nused = dict()\n\ndef pos(x, y, k):\n if x >= k:\n return f[x - k][y]\n else:\n return '.'\n\ndef go(x, y, k):\n if (x == 0 and y == 7) or (k >= 10):\n return True\n\n if (x, y, k) in used:\n return used[(x, y, k)]\n\n if 'S' == pos(x, y, k):\n used[(x, y, k)] = False\n return False\n\n result = False\n for dx in [-1, 0, 1]:\n for dy in [-1, 0, 1]:\n if 0 <= x + dx < 8 and 0 <= y + dy < 8:\n if pos(x + dx, y + dy, k) != 'S':\n result = result or go(x + dx, y + dy, k + 1)\n\n used[(x, y, k)] = result\n return result\n \n\nif go(7, 0, 0):\n print \"WIN\"\nelse:\n print \"LOSE\"\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nr=[(7,0)]\nfor step in range(8):\n t=[]\n for x,y in r:\n for dx in [-1,0,1]:\n for dy in [-1,0,1]:\n xx = x+dx\n yy = y+dy\n if (xx,yy) not in t:\n if 0<=xx<8 and 0<=yy<8:\n ok = True\n if xx-step>=0:\n ok &= s[xx-step][yy]!='S'\n if xx-step-1>=0:\n ok &= s[xx-step-1][yy]!='S'\n if ok:\n t.append((xx,yy))\n r=t\nif r:\n print 'WIN'\nelse:\n print 'LOSE'\n"}, {"source_code": "#!/usr/bin/env python\nimport sys\n \nstage = []\n \nfor i in range(8):\n\tstage.append(list(raw_input()))\n \ndef backtrack(row, col, step, pad):\n\t#indent = \" \" * pad + \"|\"\n\tif row > 7 - step:\n\t\treturn 0\n\t#print indent, \"at\", row, col\n\tfor dx in (-1, 0, 1):\n\t\tfor dy in (-1, 0, 1):\n\t\t\tif row + dy in range(8) and col + dx in range(8):\n\t\t\t\t#print indent, \"try\", row + dy, col + dx\n\t\t\t\tif row != 0:\n\t\t\t\t\tif stage[row + dy][col + dx] != 'S' and stage[row + dy - 1][col + dx] != 'S':\n\t\t\t\t\t\t#print indent, \"check\", row + dy, col + dx\n\t\t\t\t\t\tif backtrack(row + dy - 1, col + dx, step + 1, pad + 1):\n\t\t\t\t\t\t\treturn 1\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t#print indent, \"failed\", row + dy, col + dx\n\t\t\t\t\t\t\tpass\n\t\t\t\t\t\t\t\n\t\t\t\telse:\n\t\t\t\t\treturn 1\t\n\nif backtrack(7, 0, 0, 1):\n\tprint \"WIN\"\nelse:\n\tprint \"LOSE\""}, {"source_code": "maze = []\nmazes = []\n\ndx = (-1, -1, -1, 0, 0, 0, 1, 1, 1)\ndy = (-1, 0, 1, -1, 0, 1, -1, 0, 1)\n\nflag = False\n\ndef readInput():\n for i in range(8):\n temp = raw_input()\n row = [temp[0], temp[1], temp[2], temp[3],temp[4], temp[5], temp[6], temp[7]]\n maze.append(row)\n \ndef initMazes():\n temp = [\".\", \".\", \".\", \".\", \".\", \".\", \".\", \".\"] \n for i in range(9): \n maze0 = []\n for row in range(8):\n maze0.append(temp[:])\n mazes.append(maze0)\n for k in range(8): \n for i in range(8): \n for j in range(8): \n mazes[k][i][j] = maze[i][j] \n\n for k in range(1, 8):\n for i in [7,6,5,4,3,2,1,0]: \n for j in range(8): \n if i > 0:\n if mazes[k-1][i-1][j] == 'S': \n mazes[k][i][j] = 'S' \n else:\n mazes[k][i][j] = '.' \n else:\n mazes[k][i][j] = '.'\n \ndef printMaze(maze):\n for i in range(8):\n print(maze[i])\n \n \ndef dfs(x, y, step):\n xx, yy = 0, 0\n global flag\n if flag : return\n if step >= 8:\n flag = True\n return \n\n for i in range(9):\n xx = x + dx[i] \n yy = y + dy[i]\n \n #print(\"!!! %d, %d, %d\" %(step, xx, yy))\n\n if xx > 7 or xx < 0 or yy > 7 or yy < 0:\n continue\n if mazes[step + 1][xx][yy] == \"S\" :\n continue\n if mazes[step][xx][yy] == \"S\" :\n continue\n\n #print(\" ==> %d, %d, %d\" %(step+1, xx, yy))\n\n dfs(xx, yy, step + 1)\n\n return \n\nif __name__ == \"__main__\":\n readInput()\n initMazes()\n\n dfs(7, 0, 0)\n\n #for i in range(8): \n # print(\"-------%d------\" %i)\n # printMaze(mazes[i])\n # print(\"\")\n\n if flag:\n print \"WIN\"\n else:\n print \"LOSE\""}, {"source_code": "from copy import deepcopy\nA=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(0,0),(1,0),(0,-1),(1,-1)]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n if can(r+x[0],c+x[1],M):\n M2=deepcopy(M)\n r2=r+x[0]\n c2=c+x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n dfs(r2,c2,M2)\ndef can(r,c,M): \n if r>7 or r<0 or c>7 or c<0:\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nC=[[x for x in raw_input()]for i in range(8)]\ndfs(7,0,deepcopy(C))\nprint \"LOSE\"\n"}, {"source_code": "import copy\nf=copy.deepcopy\ndef d(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for t in [-1,0,1]:\n for u in [1,0,-1]:\n r2=r+t\n c2=c+u\n if e(r2,c2,M):\n M2=f(M)\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n d(r2,c2,M2)\ndef e(r,c,M): \n if 0<=r<8 and 0<=c<8 and M[r][c]!='S' and M[r-1][c]!='S':\n return 1\n return 0\nC=[[x for x in raw_input()]for i in range(8)]\nd(7,0,f(C))\nprint \"LOSE\"\n"}, {"source_code": "F=[raw_input() for i in [0]*8]\n\nq=[(7,0)]\n\nfor I in range(8):\n t=[]\n for i,j in q:\n for x in [-1,0,1]:\n for y in [-1,0,1]:\n X,Y=i+x,j+y\n if 0<=X<8 and 0<=Y<8 and (X,Y) not in t:\n if F[X-I][Y] != 'S' and F[X-I-1][Y] != 'S':\n t+=[(X,Y)]\n q=t\nprint \"WIN\" if q else \"LOSE\""}, {"source_code": "s=[raw_input() for i in range(8)]\nr=[(7,0)]\nfor step in range(8):\n t=[]\n for x,y in r:\n for dx in [-1,0,1]:\n for dy in [-1,0,1]:\n xx = x+dx\n yy = y+dy\n if (xx,yy) not in t:\n if 0<=xx<8 and 0<=yy<8:\n ok = True\n if xx-step>=0:\n ok &= s[xx-step][yy]!='S'\n if xx-step-1>=0:\n ok &= s[xx-step-1][yy]!='S'\n if ok:\n t.append((xx,yy))\n r=t\nif r:\n print 'WIN'\nelse:\n print 'LOSE'"}, {"source_code": "\n\ndef readints():\n return map(int,raw_input().split())\n\nmemo=set()\n\ndef main():\n x=[raw_input() for _ in xrange(8) ]\n def f(i,j,k):\n if k>10:return True\n #print i,j,k\n g=(i,j,k)\n if g in memo:\n return False\n if not (0<=i<8 and 0<=j<8) or (0<=i-k+1<8 and x[i-k+1][j]==\"S\") or (0<=i-k<8 and x[i-k][j]==\"S\"):\n memo.add(g)\n return False\n if i==0 and j==7:\n return True\n for di in xrange(-1,2):\n for dj in xrange(-1,2):\n ni=i+di\n nj=j+dj\n if f(ni,nj,k+1):return True\n memo.add(g)\n return False\n if f(7,0,0):\n print \"WIN\"\n else:\n print \"LOSE\"\n\n pass\n\n\n\nif __name__=='__main__':\n main()\n\n\n"}, {"source_code": "'''\nCreated on 2011-11-17\n\n@author: Administrator\n'''\nimport sets\nclass game:\n def __init__(self):\n self.state=sets.Set()\n self.array=[];\n for i in range(0,8):\n self.array.append(raw_input())\n def outrange(self,x,y):\n if x<0:\n return True\n if x>=8:\n return True\n if y<0:\n return True\n if y>=8:\n return True\n return False\n def go(self,x,y,turn):\n t=(x,y,turn)\n if t in self.state:\n return False\n self.state.add(t)\n if turn >= 8:\n return True\n for dx in range(-1,2):\n for dy in range(-1,2):\n nx=x+dx\n ny=y+dy\n if self.outrange(nx, ny):\n continue\n nny=ny-turn\n if self.outrange(nx, nny) == False:\n if self.array[nny][nx] == 'S':\n continue;\n nny=ny-turn-1\n if self.outrange(nx, nny) == False:\n if self.array[nny][nx] == 'S':\n continue;\n res=self.go(nx,ny,turn+1)\n if res:\n return True\n return False \n def start(self):\n res=self.go(0,7,0)\n if res:\n print \"WIN\"\n else:\n print \"LOSE\"\n \n \n \nif __name__ == '__main__':\n a=game()\n a.start()\n "}], "negative_code": [{"source_code": "f = []\nfor i in range(8):\n f.append(input())\n\nd = [[[0 for i in range(8)] for j in range(8)] for k in range(100)]\n\nd[0][7][0] = 1\ndx = [1, 1, 1, 0, 0, -1, -1, -1]\ndy = [1, 0, -1, 1, -1, 1, 0, -1]\n\nans = 'LOSE'\nfor i in range(99):\n for x in range(8):\n for y in range(8):\n if not d[i][x][y]:\n continue\n for j in range(8):\n nx = x + dx[j]\n ny = y + dy[j]\n if not(0 <= nx < 8 and 0 <= ny < 8):\n continue\n\n valid = True\n if 0 <= nx - i < 8 and f[nx - i][ny] == 'S':\n valid = False\n if 0 <= nx - i - 1 < 8 and f[nx - i - 1][ny] == 'S':\n valid = False\n \n if not valid:\n continue\n d[i + 1][nx][ny] = 1\n if nx == 0 and ny == 7:\n ans = 'WIN'\nprint(ans)\n"}, {"source_code": "from itertools import product\nfrom queue import Queue\nBOARD_SIZE = 10\nOCC_OR_VISITED, EMPTY = 1, 0\nboard = [input() for _ in range(8)]\ngraph = []\nfor _ in range(BOARD_SIZE):\n graph += [[[EMPTY for _ in range(BOARD_SIZE)] for _ in range(BOARD_SIZE)]]\n\nfor i, j in product(range(8), repeat = 2):\n if board[i][j] == 'S':\n graph[0][i + 1][j + 1] = OCC_OR_VISITED\n\nfor i in range(BOARD_SIZE):\n graph[0][i][0] = OCC_OR_VISITED\n graph[0][i][BOARD_SIZE - 1] = OCC_OR_VISITED\n graph[0][0][i] = OCC_OR_VISITED\n graph[0][BOARD_SIZE - 1][i] = OCC_OR_VISITED\n\nfor time in range(1, BOARD_SIZE):\n for i, j in product(range(2, 9), range(1, 9)):\n graph[time][i][j] = graph[time - 1][i - 1][j]\n for i in range(BOARD_SIZE):\n graph[time][i][0] = OCC_OR_VISITED\n graph[time][i][BOARD_SIZE - 1] = OCC_OR_VISITED\n graph[time][0][i] = OCC_OR_VISITED\n graph[time][BOARD_SIZE - 1][i] = OCC_OR_VISITED\n\nQ = Queue()\nQ.put((0, 8, 1))\n\npos_moves = [\n [-1, -1],\n [-1, 0],\n [-1, 1],\n [0, -1],\n [0, 0],\n [0, 1],\n [1, -1],\n [1, 0],\n [1, 1]\n]\n\nwhile not Q.empty():\n time, i, j = Q.get()\n if time < BOARD_SIZE - 1:\n for d in pos_moves:\n if graph[time][i + d[0]][j + d[1]] == EMPTY and \\\n graph[time + 1][i + d[0]][j + d[1]] == EMPTY:\n graph[time + 1][i + d[0]][j + d[1]] = OCC_OR_VISITED\n Q.put((time + 1, i + d[0], j + d[1]))\n\nany_pos = False\n\n\nfor i, j in product(range(1, 9), repeat = 2):\n if graph[BOARD_SIZE - 1][i][j] == OCC_OR_VISITED:\n any_pos = True\n\nif any_pos:\n print(\"WIN\")\nelse:\n print(\"LOSE\")\n"}, {"source_code": "g = [ [raw_input() for i in range(8)] ]\nfor i in range(9):\n tmp = []\n tmp.append('........')\n for j in range(7):\n tmpstr = ''\n for k in range(8):\n if g[i][j][k] == 'S':\n tmpstr += 'S'\n else:\n tmpstr += '.'\n tmp.append(tmpstr)\n g.append(tmp)\ndire = [(-1, -1), (-1, 0),(-1, 1),(0, -1),(0, 1),(1, -1),(1, 0),(1, 1)]\nX, Y, STEP = 0, 1, 2\nstack = [(7,0,0)]\nflag = False\nwhile len(stack):\n curr = stack.pop()\n if curr[X] == 0 and curr[Y] == 7 or curr[STEP] == 9:\n flag = True\n break\n for d in dire:\n newX = curr[X] + d[X]\n newY = curr[Y] + d[Y]\n if newX >= 0 and newX < 8 and newY >= 0 and newY < 8:\n if g[curr[STEP]][newX][newY] != 'S' and g[curr[STEP] + 1][newX][newY] != 'S':\n stack.append((newX, newY, curr[STEP] + 1))\nif flag:\n print 'WIN'\nelse:\n print 'LOSS'\n#from pprint import pprint\n#pprint(g)"}, {"source_code": "g = [ [raw_input() for i in range(8)] ]\nfor i in range(9):\n tmp = []\n tmp.append('........')\n for j in range(7):\n tmpstr = ''\n for k in range(8):\n if g[i][j][k] == 'S':\n tmpstr += 'S'\n else:\n tmpstr += '.'\n tmp.append(tmpstr)\n g.append(tmp)\ndire = [(-1, -1), (-1, 0),(-1, 1),(0, -1),(0, 1),(1, -1),(1, 0),(1, 1)]\nX, Y, STEP = 0, 1, 2\nstack = [(7,0,0)]\nflag = False\nwhile len(stack):\n curr = stack.pop()\n if curr[X] == 0 and curr[Y] == 7 or curr[STEP] == 9:\n flag = True\n break\n for d in dire:\n newX = curr[X] + d[X]\n newY = curr[Y] + d[Y]\n if newX >= 0 and newX < 8 and newY >= 0 and newY < 8:\n if g[curr[STEP]][newX][newY] != 'S' and g[curr[STEP] + 1][newX][newY] != 'S':\n stack.append((newX, newY, curr[STEP] + 1))\nif flag:\n print 'WIN'\nelse:\n print 'LOSE'\n#from pprint import pprint\n#pprint(g)"}, {"source_code": "def play(b, x, y, c):\n if c == 9:\n return True\n if b[c][y][x] == 'S':\n return False\n dx = [-1, 1, 0, 0, 0]\n dy = [0, 0, -1, 1, 0]\n for i in range(5):\n nx = x + dx[i]\n ny = y + dy[i]\n if min(nx, ny) < 0 or max(nx, ny) >= 8: continue\n if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):\n return True\n return False\n\nboard = []\nfor x in range(8):\n board.append(raw_input().strip())\nB = [board]\nfor x in range(10):\n b = B[-1]\n b_ = b[:]\n b_[0] = b_[0][:-1] + '.'\n b_.insert(0, \".......A\")\n B.append(b_[:-1])\nif play(B, 0, 7, 0):\n print \"WIN\"\nelse:\n print \"LOSE\"\n \n"}, {"source_code": "def play(b, x, y, c):\n if c == 8:\n return True\n if b[c][y][x] == 'S':\n return False\n dx = [-1, 1, 0, 0, 0]\n dy = [0, 0, -1, 1, 0]\n for i in range(5):\n nx = x + dx[i]\n ny = y + dy[i]\n if min(nx, ny) < 0 or max(nx, ny) >= 8: continue\n if b[c][ny][nx] != 'S' and play(b, nx, ny, c+1):\n return True\n return False\n\nboard = []\nfor x in range(8):\n board.append(raw_input().strip())\nB = [board]\nfor x in range(10):\n b = B[-1]\n b_ = b[:]\n b_[0] = b_[0][:-1] + '.'\n b_.insert(0, \".......A\")\n B.append(b_[:-1])\nif play(B, 0, 7, 0):\n print \"WIN\"\nelse:\n print \"LOSE\"\n \n"}, {"source_code": "\nA=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n M2=M[:]\n if can(r+x[0],c+x[1],M2):\n r+=x[0]\n c+=x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n dfs(r,c,M2)\ndef can(r,c,M): \n if r>7 or r<0 or c>7 or c<0:\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nC=[[x for x in raw_input()]for i in range(8)]\ndfs(7,0,C)\nprint \"LOSE\"\n"}, {"source_code": "\nA=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]\nC=[]\ndef dfs(r,c,M):\n\tif r<=1 and c>= 6:\n\t\tprint \"WIN\"\n\t\texit()\n\tfor x in A:\n\t\tM2=M[:]\n\t\tif can(r+x[0],c+x[1],M2):\n\t\t\tr+=x[0]\n\t\t\tc+=x[1]\n\t\t\tfor i in range(7,-1,-1):\n\t\t\t\tfor j in range(8):\n\t\t\t\t\tif M2[i][j]=='S':\n\t\t\t\t\t\tM2[i][j]='.'\n\t\t\t\t\t\tif i<=6:\n\t\t\t\t\t\t\tM2[i+1][j]='S'\n\t\t\tdfs(r,c,M2)\ndef can(r,c,M): \n\tif r > 7 or r < 0 or c > 7 or c < 0 :\n\t\treturn False\n\tif M[r][c]=='S' or M[r-1][c]=='S':\n\t\treturn False\n\treturn True\nC=[ [x for x in raw_input()] for i in range(8) ]\ndfs(7,0,C)\nprint \"LOSE\"\n"}, {"source_code": "A=[(-1,1),(-1,0),(0,1),(1,0),(0,-1),(1,-1)]\nM=[]\ndef can(r,c): \n if r > 7 or r < 0 or c > 7 or c < 0 :\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nM=[ [x for x in raw_input()] for i in range(8) ]\nr,c=7,0\nwhile True:\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n if can(r+x[0],c+x[1]):\n r+=x[0]\n c+=x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M[i][j]=='S':\n M[i][j]='.'\n if i<=6:\n M[i+1][j]='S'\n break\n else:\n print \"LOSE\"\n exit()\n \n \n #~ \n#~ \n #~ \n"}, {"source_code": "A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]\nC=[]\ndef dfs(r,c,M):\n\tif r<=1 and c>= 6:\n\t\tprint \"WIN\"\n\t\texit()\n\tfor x in A:\n\t\tM2=M[:]\n\t\tif can(r+x[0],c+x[1],M2):\n\t\t\tr+=x[0]\n\t\t\tc+=x[1]\n\t\t\tfor i in range(7,-1,-1):\n\t\t\t\tfor j in range(8):\n\t\t\t\t\tif M2[i][j]=='S':\n\t\t\t\t\t\tM2[i][j]='.'\n\t\t\t\t\t\tif i<=6:\n\t\t\t\t\t\t\tM2[i+1][j]='S'\n\t\t\tdfs(r,c,M)\ndef can(r,c,M): \n\tif r > 7 or r < 0 or c > 7 or c < 0 :\n\t\treturn False\n\tif M[r][c]=='S' or M[r-1][c]=='S':\n\t\treturn False\n\treturn True\nC=[ [x for x in raw_input()] for i in range(8) ]\ndfs(7,0,C)\nprint \"LOSE\"\n"}, {"source_code": "A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(0,0),(1,0),(0,-1),(1,-1)]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n M2=M[:]\n if can(r+x[0],c+x[1],M2):\n r+=x[0]\n c+=x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n dfs(r,c,M2)\ndef can(r,c,M): \n if r>7 or r<0 or c>7 or c<0:\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nC=[[x for x in raw_input()]for i in range(8)]\ndfs(7,0,C)\nprint \"LOSE\"\n"}, {"source_code": "A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]\nC=[]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n if can(r+x[0],c+x[1],M):\n r+=x[0]\n c+=x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M[i][j]=='S':\n M[i][j]='.'\n if i<=6:\n M[i+1][j]='S'\n dfs(r,c,M)\ndef can(r,c,M): \n if r > 7 or r < 0 or c > 7 or c < 0 :\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nC=[ [x for x in raw_input()] for i in range(8) ]\ndfs(7,0,C)\nprint \"LOSE\"\n"}, {"source_code": "A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]\nM=[]\ndef can(r,c): \n if r > 7 or r < 0 or c > 7 or c < 0 :\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nM=[ [x for x in raw_input()] for i in range(8) ]\nr,c=7,0\nwhile True:\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n if can(r+x[0],c+x[1]):\n r+=x[0]\n c+=x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M[i][j]=='S':\n M[i][j]='.'\n if i<=6:\n M[i+1][j]='S'\n break\n else:\n print \"LOSE\"\n exit()\n \n \n #~ \n#~ \n #~ \n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S':\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep and s[r+i1][c+i2]!='S':\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\t#print \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1-1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\tif A:\n\t\t\t\t\treturn dfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S'\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep:\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\tprint \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\t\n\t\t\t\tif A:\n\t\t\t\t\tprint \"A\" , r+i1,c+i2\n\t\t\t\t\treturn dfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S'\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep and s[r+i1][c+i2]!='S':\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\tprint \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\t\n\t\t\t\tif A:\n\t\t\t\t\tprint \"A\"\n\t\t\t\t\treturn dfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S':\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep and s[r+i1][c+i2]!='S':\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\t#print \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i+i1][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1-1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\tif A:\n\t\t\t\t\treturn dfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S'\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep and s[r+i1][c+i2]!='S':\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\t#print \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep,7)==r+i1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\t\n\t\t\t\tif A:\n\t\t\t\t\t#print \"A\"\n\t\t\t\t\treturn dfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[False]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=True;\n\tdeep+=1\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tif r>0 and ~d[r-1][c]:\n\t\tfor i in range(8):\n\t\t\tif s[i][c]=='S' and max(i+deep,7)==r-1:\n\t\t\t\treturn False\n\t\treturn dfs(r-1,c)\t\t\n\t\tdeep-=1\n\t\n\tif r>0 and c<7 and ~d[r-1][c+1]:\n\t\tfor i in range(8):\n\t\t\tif s[i][c+1]=='S' and max(i+deep,7)==r-1:\n\t\t\t\treturn False\n\t\treturn dfs(r-1,c+1)\t\t\n\t\tdeep-=1\n\t\n\tif c<7 and ~d[r][c+1]:\n\t\tfor i in range(8):\n\t\t\tif s[i][c+1]=='S' and max(i+deep,7)==r:\n\t\t\t\treturn False\n\t\treturn dfs(r,c+1)\t\t\n\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\nfor i in range(1,8):\n\tif s[i][0]=='S':\n\t\tres(False)\nif s[0][0]=='S':\n\tfor i in range(1,7):\n\t\tif s[7-i][i]=='s':\n\t\t\tres(False)\n\t\t\n\n\t\t\t\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S'\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep:\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\t#print \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\t\n\t\t\t\tif A:\n\t\t\t\t\t#print \"A\" , r+i1,c+i2\n\t\t\t\t\tdfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "s=[raw_input() for i in range(8)]\nm=[7,0]\nmaria=False\ndeep=0;\nd=[[16]*8 for i in range(8)]\n\t\ndef res(a):\n\tprint [\"LOSE\",\"WIN\"][a]\n\texit()\ndef dfs(r,c):\n\tglobal deep\n\td[r][c]=deep;\n\tdeep+=1\n\t#print deep,r,c\n\t\n\tif r==0 and c==7:\n\t\tmaria=True\n\t\tres(True)\n\t\n\t\n\tfor i1 in range(-1,2):\n\t\tfor i2 in range(-1,2):\n\t\t\t#print \"I1 : \" ,i1,i2\n\t\t\tif i1==0 and i2==0:\n\t\t\t\tcontinue\n\t\t\t#print r+i1>=0 , r+i1<=7 , c+i2>=0 , c+i2<=7 , s[r+i1][c+i2]!='S'\n\t\t\tif r+i1>=0 and r+i1<=7 and c+i2>=0 and c+i2<=7 and d[r+i1][c+i2]>deep:\n\t\t\t\tA=True\t\n\t\t\t\tfor i in range(8):\n\t\t\t\t\t#print \"deep \" ,deep,r,c,i1,i2, \" i:\",i\n\t\t\t\t\tif s[i][c+i2]=='S' and (min(i+deep,7)==r+i1 or min(i+deep-1,7)==r+i1):\n\t\t\t\t\t\tA=False\n\t\t\t\t\t\tbreak\n\t\t\t\t\n\t\t\t\tif A:\n\t\t\t\t\t#print \"A\" , r+i1,c+i2\n\t\t\t\t\treturn dfs(r+i1,c+i2)\t\t\n\t\t\t\t\tdeep-=1\n\t\t\t\t\n\treturn False;\n\t\n\t\n\ndfs(7,0)\n\n\nres(False)\n"}, {"source_code": "#Codeforces , Statues\n\nimport sys\nfrom sys import stdin\nimport copy\n\nONLINE_JUDGE = 1\n\nif ONLINE_JUDGE == False:\n sys.stdin = open('input.txt', 'r')\n\n\ndef ok(x, y):\n if x >= 0 and x < 8 and y >= 0 and y < 8:\n return True\n return False\n\n\nmat = [[x for x in raw_input()] for i in range(8)]\n#print type(mat)\n\nd = [[0, 1], [0, -1], [-1, 0], [1, 0]]\nbingo = False\nwhile True:\n tmp = copy.deepcopy(mat)\n for i in range(8):\n for j in range(8):\n if 'M' == tmp[i][j]:\n for k in range(4):\n x = i + d[k][0]\n y = j + d[k][1]\n if ok(x, y) and mat[x][y] != 'S':\n mat[x][y] = 'M'\n\n if('M' == mat[0][7]):\n bingo = True\n break\n## for i in range(8):\n## print mat[i]\n## print \n\n #tmp = mat[:]\n for i in range(6, -1, -1):\n for j in range(8):\n if 'S' == mat[i][j]:\n mat[i + 1][j] = 'S'\n mat[i][j] = '.'\n cnt = 0\n for i in range(8):\n for j in range(8):\n if mat[i][j] == 'M':\n cnt += 1\n\n if 0 == cnt:\n break\nif bingo:\n print 'WIN'\nelse:\n print 'LOSE'\n \n\n\n\n\n\n\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": "from sys import stdin\nfrom collections import *\nfrom copy import deepcopy\n\n\ndef valid(i, j):\n n, m = [8] * 2\n return i > -1 and i < n and j > -1 and j < m\n\n\ndef str_inp(n):\n return list(reversed(list((list(stdin.readline()[:-1]) for x in range(n)))))\n\n\ndef check(x, y, step):\n if step - 1 < 7 and all[step - 1][x][y] == 'S' or step < 8 and all[step][x][y] == 'S':\n # print(all[step][x][y])\n return False\n return True\n\n\ndef dfs(x, y):\n stack, visit, step = [[x, y]], defaultdict(int), 0\n\n while (stack):\n x, y = stack.pop()\n step += 1\n\n if chess[x][y] == 'A':\n exit(print('WIN'))\n\n if not visit[x, y]:\n # print(x, y, step)\n visit[x, y] = 1\n\n st = 0\n\n for i in range(8):\n nx, ny = [x + dx[i], y + dy[i]]\n\n if valid(nx, ny) and check(nx, ny, step) and not visit[nx, ny]:\n stack.append([nx, ny])\n else:\n st += 1\n\n if st == 8:\n step -= 1\n\n\ndx, dy, chess = [-1, 0, 1, 0, 1, -1, 1, -1], [0, 1, 0, -1, 1, -1, -1, 1], str_inp(8)\nall, ini = [chess], [['.' for i in range(8)] for j in range(8)]\n\nfor k in range(1, 9):\n tem = deepcopy(ini)\n for i in range(8):\n for j in range(8):\n if chess[i][j] == 'S' and i - k > -1:\n tem[i - k][j] = 'S'\n all.append(tem)\n\n#print\n# for i in range(8):\n# for j in range(8):\n# print(*all[i][j])\n# print(end='\\n')\n\ndfs(0, 0)\nprint('LOSE')\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\ndef main():\n\n board = [line for line in raw_input()]\n print board\n\n\nif __name__ == '__main__':\n main()\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport copy\n\ninvalid = []\n\ndef isWin(board, mi, mj, turn):\n for row in board:\n if 'S' in row:\n invalid.append(mi*100+mj*10+turn)\n return False\n return True\n\n\ndef isInvalid(mi, mj, turn):\n if (mi*100+mj*10+turn) in invalid:\n return True\n return False\n\n\ndef dfs(board, mi, mj, turn):\n\n # for i in range(8):\n # print ''.join(board[i])\n\n if isWin(board, mi, mj, turn):\n return True\n elif isInvalid(mi, mj, turn):\n return False\n else:\n for i in range(-1, 2):\n for j in range(-1, 2):\n # Maria's turn\n if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):\n next_board = copy.deepcopy(board)\n next_board[mi][mj] = '.'\n # next_board[mi+i][mj+j] = 'M'\n\n # Statues's turn\n if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':\n next_board = [['.']*8] + next_board[: -1]\n next_board[mi+i][mj+j] = 'M' \n if dfs(next_board, mi+i, mj+j, turn+1):\n return True\n invalid.append(mi*100+mj*10+turn)\n return False\n\ndef main():\n board = [[cell for cell in raw_input()] for _ in range(8)]\n\n if dfs(board, 7, 0, 0):\n print 'WIN'\n else:\n print 'LOSE'\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport copy\n\ndef isWin(board):\n for row in board:\n if 'S' in row:\n return False\n return True\n\n\ndef dfs(board, mi, mj):\n print '*' * 20\n for i in range(8):\n print ''.join(board[i])\n\n if isWin(board):\n return True\n else:\n for i in range(-1, 2):\n for j in range(-1, 2):\n # Maria's turn\n if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):\n next_board = copy.deepcopy(board)\n next_board[mi][mj] = '.'\n # next_board[mi+i][mj+j] = 'M'\n\n # Statues's turn\n if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':\n next_board = [['.']*8] + next_board[: -1]\n next_board[mi+i][mj+j] = 'M' \n if dfs(next_board, mi+i, mj+j):\n return True\n return False\n\ndef main():\n board = [[cell for cell in raw_input()] for _ in range(8)]\n\n if dfs(board, 7, 0):\n print 'WIN'\n else:\n print 'LOSE'\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport copy\n\ndef isWin(board):\n for row in board:\n if 'S' in row:\n return False\n return True\n\n\ndef dfs(board, mi, mj):\n\n if isWin(board):\n return True\n else:\n for i in range(-1, 2):\n for j in range(-1, 2):\n # Maria's turn\n if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):\n next_board = copy.deepcopy(board)\n next_board[mi][mj] = '.'\n # next_board[mi+i][mj+j] = 'M'\n\n # Statues's turn\n if mi+i == 0 or next_board[mi+i-1][mj+j] != 'S':\n next_board = [['.']*8] + next_board[: -1]\n next_board[mi+i][mj+j] = 'M' \n return dfs(next_board, mi+i, mj+j)\n return False\n\ndef main():\n board = [[cell for cell in raw_input()] for _ in range(8)]\n\n if dfs(board, 7, 0):\n print 'WIN'\n else:\n print 'LOSE'\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\ndef main():\n\n board = [raw_input() for _ in range(8)]\n print board\n\n\nif __name__ == '__main__':\n main()\n\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport copy\n\ndef isWin(board):\n for row in board:\n if 'S' in row:\n return False\n return True\n\n\ndef dfs(board, mi, mj):\n\n if isWin(board):\n return True\n else:\n for i in range(-1, 2):\n for j in range(-1, 2):\n # Maria's turn\n if (-1 < mi+i and mi+i < 8) and (-1 < mj+j and mj+j < 8) and (board[mi+i][mj+j] != 'S'):\n next_board = copy.deepcopy(board)\n next_board[mi+i][mj+j] = 'M'\n next_board[mi][mj] = '.'\n \n # Statues's turn\n if next_board[mi+i-1][mj+j] != 'S':\n next_board = next_board[0: 1] + [['.']*8] + next_board[: -1]\n next_board[mi+i][mj+j] = 'M' \n dfs(next_board, mi+i, mj+j)\n return False\n\n\ndef main():\n board = [[cell for cell in raw_input()] for _ in range(8)]\n\n if dfs(board, 7, 0):\n print 'WIN'\n else:\n print 'LOSE'\n\nif __name__ == '__main__':\n main()\n\n\n"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nM_posi = [{'x':0, 'y':len(lines) - 1}]\nnexs = []\nans = 'WIN'\nfor l_num in range(len(lines)):\n nexs = []\n #Maria move\n for posi in M_posi:\n x = posi['x']\n y = posi['y']\n for i in range(-1, 2):\n nex_x = x + i\n for n in range(-1, 1):\n nex_y = y + n\n if nex_x < len(lines) and nex_x > -1:\n if lines[nex_y][nex_x] != 'S':\n nexs.append({'x':nex_x, 'y':nex_y})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n M_posi = nexs[:]\nprint ans\n"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nF = len(lines)\nM_posi = [{'x':0, 'y':F - 1}]\nnexs = []\nans = 'WIN'\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'M' * 8\n else:\n break\nfor l_num in range(F):\n nexs = []\n #Maria move\n for posi in M_posi:\n x = posi['x']\n y = posi['y']\n for i in range(-1, 2):\n nx = x + i\n for n in range(-1, 2):\n ny = y + n\n if nx < F and nx > -1 and ny < F and ny > -1:\n if lines[ny][nx] == 'M':\n ans = 'GET M'\n if lines[ny][nx] != 'S':\n nexs.append({'x':nx, 'y':ny})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n elif ans == 'GET M':\n ans = 'WIN'\n break\n M_posi = nexs[:]\nprint ans\n\"\"\"\nfor line in lines:\n print line\n\"\"\"\n"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nlines.reverse()\nM_posi = [0]\nnexs = []\nans = 'WIN'\nfor line in lines[1:]:\n for posi in M_posi:\n for i in range(-1, 2):\n nex = posi + i\n if nex < len(lines) and nex > -1:\n if line[nex] != 'S':\n nexs.append(nex)\n if nexs == []:\n ans = 'LOSE'\n break\n M_posi = nexs[:]\n nexs = []\nprint ans\n"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nF = len(lines)\nM_posi = [{'x':0, 'y':F - 1}]\nnexs = []\nans = 'WIN'\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\n else:\n break\nlines = zip(*lines)\nfor i in range(F):\n if 'S' not in lines[i]:\n lines[i] = 'G' * 8\nlines = zip(*lines)\nfor l_num in range(F):\n nexs = []\n #Maria move\n for posi in M_posi:\n x = posi['x']\n y = posi['y']\n for i in range(-1, 2):\n nx = x + i\n for n in range(-1, 2):\n ny = y + n\n if {'x':x, 'y':y} in nexs:\n continue\n if nx < F and nx > -1 and ny < F and ny > -1:\n if lines[ny][nx] == 'G':\n ans = 'GET G'\n if lines[ny][nx] != 'S':\n nexs.append({'x':nx, 'y':ny})\n #obstacle move\n lines = lines[:-1]\n lines.insert(0, '........')\n for nex in nexs[:]:\n x = nex['x']\n y = nex['y']\n if lines[y][x] == 'S':\n posi = {'x':x, 'y':y}\n while posi in nexs: nexs.remove(posi)\n if nexs == []:\n ans = 'LOSE'\n break\n elif ans == 'GET G':\n ans = 'WIN'\n break\n M_posi = nexs[:]\nprint ans\n"}, {"source_code": "#!/usr/bin/python\n# coding: utf-8\nimport sys\n\nlines =[l.strip() for l in sys.stdin.readlines()]\nlines.reverse()\nM_posi = [0]\nnexs = []\nans = 'WIN'\nfor l_num in range(1, len(lines)):\n for posi in M_posi:\n for i in range(-1, 2):\n nex = posi + i\n if nex < len(lines) and nex > -1:\n tar_c = lines[l_num][nex]\n tar_p = lines[l_num][nex]\n if l_num + 1 <= len(lines) - 1:\n tar_p = lines[l_num + 1][nex]\n if tar_c == tar_p != 'S':\n nexs.append(nex)\n if nexs == []:\n ans = 'LOSE'\n break\n M_posi = nexs[:]\n nexs = []\nprint ans\n"}, {"source_code": "d=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]]\n\nl=[]\nfor i in range(8):\n l.append(input())\n\nprint(\"l is\",l)\n\nstatues=[]\nstatues.append([])\nfor i in range(8):\n for j in range(8):\n #print(l[i][j],l[i][j]=='S')\n if l[i][j]==\"S\":\n statues[0].append(tuple([i,j]))\n\nfor i in range(1,8):\n statues.append([])\n for statue in statues[0]:\n statues[i].append(tuple([statue[0]+i,statue[1]]))\n\nprint(statues[0])\n\n\ndef possible(move_no,pos):\n global d\n global statues\n if move_no>7 or (pos[0]==0 and pos[1]==7):\n print(move_no, pos[0],pos[1])\n return(True)\n \n b=False\n for di in d:\n pos[0]+=di[0]\n pos[1]+=di[1]\n if pos[0]>-1 and pos[0]<8 and pos[1]>-1 and pos[1]<8 and tuple(pos) not in statues[move_no] and tuple([pos[0]-1,pos[1]]) not in statues[move_no]:\n print(pos)\n if(possible(move_no+1,pos)):\n b=True\n break\n\n pos[0]-=di[0]\n pos[1]-=di[1]\n return(b)\n\n\n \nif(possible(0,[7,0])):\n print(\"WIN\")\nelse:\n print(\"LOSE\")\n\n\n\n\n"}, {"source_code": "d=[[1,0],[-1,0],[0,1],[0,-1],[1,1],[1,-1],[-1,1],[-1,-1]]\n\nl=[]\nfor i in range(8):\n l.append(input())\n\n#print(\"l is\",l)\n\nstatues=[]\nstatues.append([])\nfor i in range(8):\n for j in range(8):\n #print(l[i][j],l[i][j]=='S')\n if l[i][j]==\"S\":\n statues[0].append(tuple([i,j]))\n\nfor i in range(1,8):\n statues.append([])\n for statue in statues[0]:\n statues[i].append(tuple([statue[0]+i,statue[1]]))\n\n#print(statues[0])\n\n\ndef possible(move_no,pos):\n global d\n global statues\n if move_no>7 or (pos[0]==0 and pos[1]==7):\n #print(move_no, pos[0],pos[1])\n return(True)\n \n b=False\n for di in d:\n pos[0]+=di[0]\n pos[1]+=di[1]\n if pos[0]>-1 and pos[0]<8 and pos[1]>-1 and pos[1]<8 and tuple(pos) not in statues[move_no] and tuple([pos[0]-1,pos[1]]) not in statues[move_no]:\n #print(pos)\n if(possible(move_no+1,pos)):\n b=True\n break\n\n pos[0]-=di[0]\n pos[1]-=di[1]\n return(b)\n\n\n \nif(possible(0,[7,0])):\n print(\"WIN\")\nelse:\n print(\"LOSE\")\n\n\n\n\n"}, {"source_code": "a=list(input() for i in range(8))\nok1=list()\nok2=set()\nok1.append((7,0))\nw=[(1,0),(-1,0),(0,1),(0,-1),(1,-1),(1,1),(-1,-1),(-1,1)]\nfor i in range(8) :\n\tfor pos in ok1 :\n\t\tif pos[0]>=i and a[pos[0]-i][pos[1]] == 'S' :\n\t\t\tcontinue \n\t\tfor j in w:\n\t\t\tto=(pos[0]+j[0],pos[1]+j[1])\n\t\t\tif to[0]<8 and to[1]<8 and to[0]>-1 and to[1]>-1:\n\t\t\t\tif to[0]0 else \"LOSE\")"}, {"source_code": "def manh_dist(x1, y1, x2, y2):\n return abs(x1 - x2) + abs(y1 - y2)\n\ndef bad(x, y, t):\n x1, y1 = x, y + t\n return 0 <= 8 - y1 < 8 and 0 <= x1 < 8 and a[8 - y1][x1] == \"S\" or 0 <= 7 - y1 < 8 and 0 <= x1 < 8 and a[7 - y1][x1] == \"S\"\n\ndp = [[[False] * 30 for i in range(8)] for j in range(8)]\na = []\nfor i in range(8):\n a.append(input().rstrip())\n\ndp[0][0][0] = True\nfor t1 in range(29):\n for x in range(8):\n for y in range(8):\n if dp[x][y][t1]:\n for i in [(x + 1, y), (x - 1, y), (x + 1, y + 1), (x - 1, y + 1), (x + 1, y - 1), (x - 1, y - 1), (x, y + 1), (x, y - 1)]:\n if 0 <= i[0] < 8 and 0 <= i[1] < 8:\n if not bad(i[0], i[1], t1 + 1):\n dp[i[0]][i[1]][t1 + 1] = True\n\nfor i in range(30):\n if dp[7][7][i]:\n print(\"WIN\")\n exit()\nprint(\"LOSE\")"}, {"source_code": "r, s = [63], ''.join(input() + 'T' for i in range(8)) + 'T' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'T': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')"}, {"source_code": "r, s = [63], ''.join(input() + 'S' for i in range(8)) + 'S' * 9\nfor i in range(0, 72, 9):\n t = set()\n for x in r:\n for y in (x - 1, x + 1, x - 9, x + 9, x - 10, x - 8, x + 10, x + 8):\n if s[y] == 'S': continue\n if (y < i or s[y - i] != 'S') and (y < i + 9 or s[y - i - 9] != 'S'): t.add(y)\n r = t\nprint('WIN' if r else 'LOSE')"}, {"source_code": "import operator\n\nd = map(list, zip(*[raw_input() for i in xrange(8)]))\n\n#ok = True\n\ndef calc(x, before_y):\n if 'S' not in d[x] or x == 7:\n return True\n\n if [i for i,e in enumerate(d[x]) if e == 'S' and i >= 7 - x]:\n return False\n\n continuous = set((before_y, before_y+1, before_y-1)) & set([i for i,e in enumerate(d[x]) if e == 'S'])\n \n return reduce(operator.and_, [calc(x+1,a) for a in continuous]) if continuous else True\n\n\nif 'S' not in d[0]:\n print 'WIN'\nelse:\n if calc(1,7):\n print 'WIN'\n else:\n print 'LOSE'\n \n"}, {"source_code": "import operator\n\nd = map(list, zip(*[raw_input() for i in xrange(8)]))\n\n#ok = True\n\ndef calc(x, before_y):\n if 'S' not in d[x] or x == 7:\n return True\n\n #if [i for i,e in enumerate(d[x]) if e == 'S' and i >= 7 - x]:\n # return False\n\n ss = set([i for i,e in enumerate(d[x]) if e == 'S'])\n \n continuous = set((before_y, before_y+1, before_y-1)) & set([i for i,e in enumerate(d[x]) if e == 'S'])\n #print continuous\n if [i for i in continuous if i >= 7 - x]:\n return False\n \n return reduce(operator.and_, [calc(x+1,a) for a in continuous]) if continuous else True\n\n\nif 'S' not in d[0]:\n print 'WIN'\nelse:\n if reduce(operator.and_, [calc(1,a) for a in xrange(8)]):\n print 'WIN'\n else:\n print 'LOSE'\n \n"}, {"source_code": "#!/usr/bin/env python\nimport sys\n \nstage = []\n \nfor i in range(8):\n\tstage.append(list(raw_input()))\n \ndef backtrack(row, col):\n\tfor dx in (-1, 0, 1):\n\t\tfor dy in (-1, 0):\n\t\t\tif row + dy in range(8) and col + dx in range(8):\n\t\t\t\tif row != 0:\n\t\t\t\t\tif stage[row + dy][col + dx] != 'S' and stage[row + dy - 1][col + dx] != 'S':\n\t\t\t\t\t\tif backtrack(row + dy - 1, col + dx):\n\t\t\t\t\t\t\treturn 1\n\t\t\t\telse:\n\t\t\t\t\treturn 1\n\treturn 0\n\nif backtrack(7, 0):\n\tprint \"WIN\"\nelse:\n\tprint \"LOSE\""}, {"source_code": "A=[(-1,1),(-1,0),(0,1),(-1,-1),(1,1),(1,0),(0,-1),(1,-1)]\ndef dfs(r,c,M):\n if r<=1 and c>= 6:\n print \"WIN\"\n exit()\n for x in A:\n M2=M[:]\n if can(r+x[0],c+x[1],M2):\n r+=x[0]\n c+=x[1]\n for i in range(7,-1,-1):\n for j in range(8):\n if M2[i][j]=='S':\n M2[i][j]='.'\n if i<=6:\n M2[i+1][j]='S'\n dfs(r,c,M2)\ndef can(r,c,M): \n if r>7 or r<0 or c>7 or c<0:\n return False\n if M[r][c]=='S' or M[r-1][c]=='S':\n return False\n return True\nC=[[x for x in raw_input()]for i in range(8)]\ndfs(7,0,C)\nprint \"LOSE\"\n"}, {"source_code": "\n\ndef readints():\n return map(int,raw_input().split())\n\nmemo=set()\n\ndef main():\n x=[raw_input() for _ in xrange(8) ]\n def f(i,j,k):\n if k>10:return True\n #print i,j,k\n g=(i,j,k)\n if g in memo:\n return False\n if not (0<=i<8 and 0<=j<8) or (0<=i-k+1<8 and x[i-k+1][j]==\"S\") or (0<=i-k<8 and x[i-k][j]==\"S\"):\n memo.add(g)\n return False\n if i==0 and j==7:\n return True\n for dir in xrange(4):\n ni=i+[0,0,1,-1][dir]\n nj=j+[1,-1,0,0][dir]\n if f(ni,nj,k+1):return True\n memo.add(g)\n return False\n if f(7,0,0):\n print \"WIN\"\n else:\n print \"LOSE\"\n\n pass\n\n\n\nif __name__=='__main__':\n main()\n\n\n"}, {"source_code": "\n\ndef readints():\n return map(int,raw_input().split())\n\nmemo=set()\n\ndef main():\n x=[raw_input() for _ in xrange(8) ]\n def f(i,j,k):\n if k>10:return True\n #print i,j,k\n g=(i,j,k)\n if g in memo:\n return False\n if not (0<=i<8 and 0<=j<8) or (0<=i-k+1<8 and x[i-k+1][j]==\"S\") or (0<=i-k<8 and x[i-k][j]==\"S\"):\n memo.add(g)\n return False\n if i==0 and j==7:\n return True\n for di in xrange(-1,2):\n for dj in xrange(-1,2):\n if di==dj==0:continue\n ni=i+di\n nj=j+dj\n if f(ni,nj,k+1):return True\n memo.add(g)\n return False\n if f(7,0,0):\n print \"WIN\"\n else:\n print \"LOSE\"\n\n pass\n\n\n\nif __name__=='__main__':\n main()\n\n\n"}, {"source_code": "'''\nCreated on 2011-11-17\n\n@author: Administrator\n'''\nimport sets\nclass game:\n def __init__(self):\n self.state=sets.Set()\n self.array=[];\n for i in range(0,8):\n self.array.append(raw_input())\n def outrange(self,x,y):\n if x<0:\n return True\n if x>=8:\n return True\n if y<0:\n return True\n if y>=8:\n return True\n return False\n def go(self,x,y,turn):\n t=(x,y,turn)\n if t in self.state:\n return False\n self.state.add(t)\n if turn >= 8:\n return True\n for dx in range(-1,2):\n for dy in range(-1,2):\n nx=x+dx\n ny=y+dy\n if self.outrange(nx, ny):\n continue\n nny=ny-turn\n if self.outrange(nx, nny) != False:\n if self.array[nny][nx] == 'S':\n continue;\n nny=ny-turn-1\n if self.outrange(nx, nny) != False:\n if self.array[nny][nx] == 'S':\n continue;\n res=self.go(nx,ny,turn+1)\n if res:\n return True\n return False \n def start(self):\n res=self.go(7,0,0)\n if res:\n print \"WIN\"\n else:\n print \"LOSE\"\n \n \n \nif __name__ == '__main__':\n a=game()\n a.start()\n "}, {"source_code": "'''\nCreated on 2011-11-17\n\n@author: Administrator\n'''\nimport sets\nclass game:\n def __init__(self):\n self.state=sets.Set()\n self.array=[];\n for i in range(0,8):\n self.array.append(raw_input())\n def outrange(self,x,y):\n if x<0:\n return True\n if x>=8:\n return True\n if y<0:\n return True\n if y>=8:\n return True\n return False\n def go(self,x,y,turn):\n t=(x,y,turn)\n if t in self.state:\n return False\n self.state.add(t)\n if turn >= 8:\n return True\n for dx in range(-1,2):\n for dy in range(-1,2):\n nx=x+dx\n ny=y+dy\n if self.outrange(nx, ny):\n continue\n nny=ny-turn\n if self.outrange(nx, nny) != False:\n if self.array[nny][nx] == 'S':\n continue;\n nny=ny-turn-1\n if self.outrange(nx, nny) != False:\n if self.array[nny][nx] == 'S':\n continue;\n res=self.go(nx,ny,turn+1)\n if res:\n return True\n return False \n def start(self):\n res=self.go(0,7,0)\n if res:\n print \"WIN\"\n else:\n print \"LOSE\"\n \n \n \nif __name__ == '__main__':\n a=game()\n a.start()\n "}], "src_uid": "f47e4ab041288ba9567c19930eb9a090"} {"nl": {"description": "A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.", "input_spec": "The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the number of characters in the string. The second line contains the string. The string consists only of uppercase and lowercase Latin letters.", "output_spec": "Output \"YES\", if the string is a pangram and \"NO\" otherwise.", "sample_inputs": ["12\ntoosmallword", "35\nTheQuickBrownFoxJumpsOverTheLazyDog"], "sample_outputs": ["NO", "YES"], "notes": null}, "positive_code": [{"source_code": "s = raw_input()\ns = raw_input().lower()\nfl = sum(map(lambda x: s.find(x) >= 0, map(lambda x : chr(x + ord('a')), range(0,26)))) == 26\nif fl:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "#!/usr/bin/env Python3\nn = int(input())\nword = input()\n\nletters=[]\nfor i in word:\n\ttest =i.upper()\n\tif test not in letters:\n\t\tletters.append(test)\nif(len(letters)==26):\n\tprint(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\ns=input()\nstring=['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']\narr1=[]\narr2=[]\narr=[]\n\ncount=0\nf=0\ng=0\nfor i in range(n):\n if(s[i].isupper()):\n arr1.append(s[i].lower())\n else:\n arr2.append(s[i])\narr1=arr1+arr2\narr1=set(arr1)\n\nfor i in range(len(string)):\n if(string[i] in arr1):\n count=count+1\nif(count==26):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "input();print('YNEOS'[len(set(input().upper()))<26::2])"}, {"source_code": "n=int(input())\narr=[]\ns=input()\ns=s.lower()\nfor x in s:\n if x not in arr:\n arr.append(x)\nif len(arr)==26:\n print(\"YES\")\nelse :\n print(\"NO\")\n\n"}, {"source_code": "lista = []\n\ninput()\nm = raw_input()\n\nfor i in m:\n if i.lower() not in lista:\n lista.append(i.lower())\nif len(lista) == 26:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n=int(input())\ns=input()\ns=s.upper()\na=set(s)\nif len(a)==26:\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "n=int(input())\ndef checkPangram(s):\n List = [] \n for i in range(26): \n List.append(False) \n for c in s.lower(): \n if not c == \" \": \n List[ord(c) -ord('a')]= True \n\n for ch in List: \n if ch == False: \n return False\n return True\n\nS=input()\nif (checkPangram(S)):\n print(\"YES\")\nelse: \n print(\"NO\")\n "}, {"source_code": "def isPangram(s):\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n return not (set(alphabet) - set(s))\n\n\nn = int(raw_input())\ns = raw_input().lower()\nif isPangram(s):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = input()\n\nstring = list(raw_input().lower())\nif(len(list(set(string))) == 26):\n\tprint 'YES'\nelse:\n\tprint 'NO'\n"}, {"source_code": "b = input()\na = set(input().lower())\nif len(a) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nx = {i for i in input().lower()}\nif len(x) == 26:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "t = input(); s = input(); s = s.lower(); counterLow = 0\nfor i in range(97, 123):\n if chr(i) in s: counterLow+=1\nif counterLow == 26: print('YES')\nelse: print('NO')\n"}, {"source_code": "egfiaweufw=raw_input()\nbla=raw_input().lower()\ngood=True\nfor c in \"qwertyuiopasdfghjklzxcvbnm\":\n if c not in bla:\n good=False\nif good:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n=int(input())\ns=input()\nout=0\narr=[]\nfor i in s:\n if i.lower() in arr:\n continue\n else:\n arr.append(i.lower())\nif(len(arr)==26):print('YES')\nelse:print('NO')\n"}, {"source_code": "n = input()\na = raw_input()\na = a.lower()\nag = list(set(a))\nif len(ag) == 26:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "def act(x):\n n=int(raw_input())\n if(n<26):\n return 'NO'\n else:\n s=list(raw_input())\n for i in range(n):\n if(ord(s[i])<97):\n s[i]=chr(ord(s[i])+32)\n s=set(s)\n if(len(s)>=26):\n return 'YES'\n return 'NO'\nprint act(1)"}, {"source_code": "import collections\n\n\nn = int(input())\n\nstring = input()\n\nalph = \"abcdefghijklmnopqrstuvwxyz\"\ndic = collections.Counter(alph)\n\nstring = string.lower()\n\nIs_pangram = True\n\nif len(string) < 26:\n print(\"NO\")\nelse:\n for i in range(len(string)):\n if string[i] in dic.keys():\n dic[string[i]] -=1\n continue\n else:\n print(\"NO\")\n Is_pangram = False\n break\n while Is_pangram:\n for value in dic.values():\n if value > 0:\n print(\"NO\")\n Is_pangram = False\n break\n if Is_pangram:\n print(\"YES\")\n Is_pangram = False\n\n\n"}, {"source_code": "def panagram(string):\n letterDict = {}\n for i in range(len(string)):\n if str(string[int(i)]) not in letterDict:\n letterDict[str(string[int(i)].lower())] = 0\n if len(letterDict) == 26:\n return \"YES\"\n return \"NO\"\nnums = input()\n#listOfInputs = input().split()\nword = list(input())\nprint(panagram(word))\n"}, {"source_code": "input()\ns = input().lower()\nfrom string import *\nprint((\"NO\",\"YES\")[26 == len([c for c in ascii_lowercase if c in s])])"}, {"source_code": "z=int(input())\ns=input().lower()\nd=[]\nfor i in s:\n if 97<=ord(i)<=122:\n if i not in d:\n d.append(i)\nif len(d)==26:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "lenstr = int(raw_input())\nlenstr += 1\ndef finde( a , str ):\n count = 0\n lol = 0\n while(count!=(lenstr - 1)):\n if str[count]==a[0]:\n lol = 1\n count +=1\n return lol;\n\nstr = (raw_input()).lower()\nstr = str + \" \"\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\n\ncounter = 0\nind = 0\nwhile ( counter != 26 ):\n if finde(alpha[counter],str)==1:\n ind = ind + 1\n counter += 1\nif(ind==26):\n print \"YES\"\nelse:\n print \"NO\"\n\n"}, {"source_code": "import string\nn=int(input())\nt=input()\nt=t.lower()\nk=[]\nl=0\nif n<26:\n print(\"NO\")\nelse:\n for i in t:\n if i in string.ascii_letters and i not in k:\n k.append(i)\n if len(k)==26:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "n=input(\"\")\ns=raw_input(\"\")\nL=[]\nfor i in s:\n if (i not in L) and (chr(ord(i)+32) not in L) and (chr(ord(i)-32) not in L):\n L.append(i)\nif len(L)==26:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "_ = input()\nword = input()\nword = word.lower()\n\n# The dictionary named histogram will count the letters present.\n# and assign each letter as a key and it's count as the value.\nhistogram = dict()\nfor i in word:\n histogram[i] = histogram.get(i, 0) + 1\n\n# If the histogram has an element count of 26, that means every\n# letter is present and it is a pangram.\nif len(histogram) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "def main():\n num_chars = int(raw_input())\n s = raw_input()\n if (num_chars < 26):\n return \"NO\"\n else:\n return \"YES\" if len(set(s.lower())) == 26 else \"NO\"\n\n\nprint main()\n"}, {"source_code": "n=int(input())\ns=input()\ns=s.upper()\na=set(s)\nif len(a)==26:\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "t = int(input())\ns = input()\nc = 0\nif t<26 :\n print(\"NO\")\nelse :\n if 'a' in s or 'A' in s:\n c = c+1\n if 'b' in s or 'B' in s:\n c = c+1\n if 'c' in s or 'C' in s:\n c = c+1\n if 'd' in s or 'D' in s:\n c = c+1\n if 'e' in s or 'E' in s:\n c = c+1\n if 'f' in s or 'F' in s:\n c = c+1\n if 'g' in s or 'G' in s:\n c = c+1\n if 'h' in s or 'H' in s:\n c = c+1\n if 'i' in s or 'I' in s:\n c = c+1\n if 'j' in s or 'J' in s:\n c = c+1\n if 'k' in s or 'K' in s:\n c = c+1\n if 'l' in s or 'L' in s:\n c = c+1\n if 'm' in s or 'M' in s:\n c = c+1\n if 'n' in s or 'N' in s:\n c = c+1\n if 'o' in s or 'O' in s:\n c = c+1\n if 'p' in s or 'P' in s:\n c = c+1\n if 'q' in s or 'Q' in s:\n c = c+1\n if 'r' in s or 'R' in s:\n c = c+1\n if 's' in s or 'S' in s:\n c = c+1\n if 't' in s or 'T' in s:\n c = c+1\n if 'u' in s or 'U' in s:\n c = c+1\n if 'v' in s or 'V' in s:\n c = c+1\n if 'w' in s or 'W' in s:\n c = c+1\n if 'x' in s or 'X' in s:\n c = c+1\n if 'y' in s or 'Y' in s:\n c = c+1\n if 'z' in s or 'Z' in s:\n c = c+1\n if c>25:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "t=input()\nr=raw_input()\nalphabet= \"abcdefghijklmnopqrstuvwxyz\"\nk=str.lower(r)\nj=''.join(sorted(set(k)))\nl= (set(alphabet) - set(j))\nm=''.join(l)\nif len(m)>0:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "l=int(input())\nn=input()\nprint(\"YES\" if len(set(n.lower()))==26 else \"NO\")"}, {"source_code": "n = input()\ns = raw_input().lower()\nd = {}\nfor c in s:\n\td[c] = 1\nif len(d) == 26:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n\n"}, {"source_code": "letters=[0]*26\ndef index(x):\n x=ord(x)\n if x>=ord('a') and x<=ord('z'):\n return x-ord('a')\n elif x>=ord('A') and x<=ord('Z'):\n return x-ord('A')\nn=int(input())\ns=input().strip()\nfor x in s:\n x=index(x)\n letters[x]=1\nif 0 in letters:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n = int(input())\ns = str(input())\ns = s.lower()\nli = []\nfor i in s:\n if i not in li:\n li.append(i)\nif len(li) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "raw_input()\ns = raw_input()\nprint \"YES\" if len(set(s.upper())) >= 26 else \"NO\""}, {"source_code": "n = int(input())\ns = input()\na = []\nb = []\nfor i in range(0, n):\n a.append(s[i].lower())\na.sort()\na.append('0')\nfor i in range(0, n):\n if(a[i] != a[i + 1]):\n b.append(a[i])\nif(len(b) < 26):\n print('NO')\nelse:\n print('YES')\n\n"}, {"source_code": "input()\na=list(input().lower())\nb=['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']\nif(all(a.count(i)>=1 for i in b)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x=int(input())\nstr=input().lower()\ndict1 = {chr:str.count(chr) for chr in str}\nif len(list(dict1.keys())) == 26:\n print(\"YES\")\nelse:\n print(\"no\")"}, {"source_code": "import sys\n\nargs = []\nalphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',\n 'V', 'W', 'X', 'Y', 'Z']\n\nfor line in sys.stdin:\n args.append(line)\n\n\nif int(args[0]) < 26:\n print(\"NO\")\nelse:\n for x in args[1]:\n real = x.upper()\n if real in alphabet:\n del alphabet[alphabet.index(real)]\n if len(alphabet) > 0:\n print(\"NO\")\n else:\n print(\"YES\")\n"}, {"source_code": "def isPangram(s):\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n return not (set(alphabet) - set(s))\n\n\nn = int(raw_input())\ns = raw_input().lower()\nif isPangram(s):\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()))\ndp=list(\"abcdefghijklmnopqrstuvwxyz\")\nn=inp()\nss=input()\ns=ss.lower()\nans=list(\"\".join(set(s)))\nans.remove(\"\\n\")\nans.sort()\nif not dp==ans:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "def act(x):\n n=int(raw_input())\n if(n<26):\n return 'NO'\n else:\n s=list(raw_input())\n for i in range(n):\n if(ord(s[i])<97):\n s[i]=chr(ord(s[i])+32)\n s=set(s)\n if(len(s)>=26):\n return 'YES'\n return 'NO'\nprint act(1)"}, {"source_code": "input() # exp\nbakko=input()\nbakko2=set(bakko.lower())\ndhorgo=len(bakko2)\nif dhorgo==26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "b = input()\ns = input()\ns = s.upper()\na = set(s)\nif(len(a) > 25):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=int(input())\na=input()\na=set(a.lower())\nif len(a)==26:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = input()\nprint [\"NO\", \"YES\"][len(set(raw_input().lower())) == 26]"}, {"source_code": "input()\nn = input()\nprint([\"YES\",\"NO\"][len(set(n.lower()))<26])\n"}, {"source_code": "n = int(input())\ns = list(input().lower())\na = \"\"\ncheck = \"abcdefghijklmnopqrstuvwxyz\"\nx = set(s)\ny = list(x)\ny.sort()\nfor i in range(0,len(y)):\n a+=y[i]\nif a==check:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "b = input()\na = set(input().lower())\nif len(a) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "l=['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']\ninput()\nx=input()\nfor i in l:\n if i not in x and i.upper() not in x:\n print(\"NO\")\n break\nif i=='m':\n if 'm' in x or i.upper() in x: \n print(\"YES\")"}, {"source_code": "n=int(input())\ns=input()\nx=s.lower()\nx=set(x)\nif len(x)==26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "input() # exp\nbakko=input()\nbakko2=set(bakko.lower())\ndhorgo=len(bakko2)\nif dhorgo==26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = input()\na = []\nb = []\nfor i in range(0, n):\n a.append(s[i].lower())\na.sort()\na.append('0')\nfor i in range(0, n):\n if(a[i] != a[i + 1]):\n b.append(a[i])\nif(len(b) < 26):\n print('NO')\nelse:\n print('YES')\n\n"}, {"source_code": "input()\ns = raw_input()\nif len(set(s.lower()))== 26:\n\tprint \"YES\"\nelse:\n\tprint \"NO\"\n"}, {"source_code": "n=int(input())\ns=input()\na='abcdefghijklmnopqrstuvwxyz'\ns=set(s.lower())\nc=0\nfor i in a:\n\tif i not in s:\n\t\tbreak\n\telse:\n\t\tc+=1\nif c==len(a):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "# pangram.py\n\nstringlen = int(raw_input())\nstring = raw_input()\nstring = string.lower()\nisPanagram = True\n\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\n\nfor i in range(stringlen):\n for ch in alphabet:\n if ch not in string:\n isPanagram = False\n\nif isPanagram:\n print 'YES'\nelse:\n print 'NO'\n \n"}, {"source_code": "n=int(input())\ns=input()\nl=\"asdfghjklzxcvbnmpoiuytrewq\"\nt=True\nfor i in l:\n if(i not in s and i.upper() not in s):\n print(\"NO\")\n t=False\n break\n else:\n continue\nif(t==True):\n print(\"YES\")\n \n"}, {"source_code": "n = int(input())\ns = input().lower()\ns = set(sorted(s))\nx = len(s)\n\nif x == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "input();print('YNEOS'[len(set(input().upper()))<26::2])"}, {"source_code": "import string\n\n\nwordLen = input(\"\")\nword = input(\"\")\n##wordLen = len(word)\n\n\nminLen = 26\n\nFINAL = \"YES\"\n\ndef smallify(x):\n y = \"\"\n for i in x:\n if(i in string.ascii_lowercase):\n y = y + i\n elif(i in string.ascii_uppercase):\n index = string.ascii_uppercase.find(i)\n y = y + string.ascii_lowercase[index]\n else:\n y = y + i\n return y\n\n\nif(int(wordLen) < minLen):\n FINAL = \"NO\"\n # exit(1)\n\n\nelse:\n word = smallify(word)\n for i in string.ascii_lowercase:\n if (i in word):\n pass\n else:\n FINAL = \"NO\"\n # exit(1)\n\nprint(FINAL)\n"}, {"source_code": "n = raw_input()\nstr = raw_input()\nprint [\"YES\",\"NO\"][len(set(str.lower())) != 26]"}, {"source_code": "# cook your dish here\nwords = [\"abcdefghijklmnopqrstuvwxyz\"]\nchar_list = []\nfor x in words:\n char_list.extend(x)\ninput()\nfor x in input().lower():\n if x in char_list:\n char_list.remove(x)\n if len(char_list) == 0:\n break\n \nif len(char_list) == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\n\nstring = list(raw_input().lower())\nif(len(list(set(string))) == 26):\n\tprint 'YES'\nelse:\n\tprint 'NO'\n"}, {"source_code": "alph = \"abcdefghijklmnopqrstuvwxyz\"\nn = int(input())\nstring = input().strip()\nif sorted(set(string.lower())) == sorted(set(alph)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\n\ndef minus(a):\n a=set(sorted(a))\n if len(a) >26:\n print ('YES')\n else:\n print('NO')\n\ndef main():\n num=int(sys.stdin.readline())\n entrada = list(sys.stdin.readline().lower())\n a=minus(entrada)\nmain()\n"}, {"source_code": "def isPangram(s):\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n return not (set(alphabet) - set(s))\n\n\nn = int(raw_input())\ns = raw_input().lower()\nif isPangram(s):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "num = int(raw_input())\npalavra = raw_input()\nd = []\n\nfor i in palavra:\n if i.lower() not in d:\n d.append(i.lower())\n\nif len(d) == 26:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "number=input(\"\")\n\nmyPhrase = input(\"\")\n\n\ndef is_pangram(myPhrase):\n c = 0\n alphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n phraseLetters = \"\"\n for char in myPhrase.upper():\n for letter in alphabet:\n if char == letter and char not in phraseLetters:\n phraseLetters += char\n for char in phraseLetters:\n for letter in alphabet:\n if char == letter:\n c += 1\n if c >= 26:\n return True\n else:\n return False\n\nif (is_pangram(myPhrase)) == True:\n print (\"YES\")\nelse:\n print (\"NO\")\n"}, {"source_code": "\n\nn = int(input())\n\nstring = input()\nif n < 26:\n print('NO')\nelse:\n string = string.lower()\n\n string_test = 'qwertyuiopasdfghjklzxcvbnm'\n\n string = set(string)\n\n for i in string_test:\n if i not in string:\n print('NO')\n break\n else:\n print('YES')\n\n\n\n"}, {"source_code": "n=int(raw_input())\nx=list(raw_input().upper())\nsum=0\n\nfor i in range(26):\n if x.count(chr(i+65))>=1:\n sum+=1\nif sum==26:\n print 'YES'\nelse:\n print 'NO'\n\n"}, {"source_code": "x=int(input())\na=input()\nb=\"abcdefghijklmnopqrstuvwxyz\"\na=a.lower()\nflag=\"YES\"\nfor i in range (26):\n if b[i] not in a:\n flag=\"NO\"\n break\n \n \n\nprint (flag)\n \n \n"}, {"source_code": "input()\nprint(('NO','YES')[len(set(input().lower()))==26])"}, {"source_code": "n=int(raw_input())\nx=list(raw_input().upper())\nsum=0\n\nfor i in range(26):\n if x.count(chr(i+65))>=1:\n sum+=1\nif sum==26:\n print 'YES'\nelse:\n print 'NO'\n\n"}, {"source_code": "import sys\nimport string\n\nn = int(sys.stdin.readline().split()[0])\n\ns = list(sys.stdin.readline()[:-1].lower())\ns.sort()\n\nif \"\".join(dict.fromkeys(s)) == string.ascii_lowercase:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a=int(raw_input())\ng=raw_input()\n#print len(g)\nb=g.lower()\nc=set(b)\n#print len(c),len(b)\nif len(g)<26:\n\tprint \"NO\"\nif len(g)>=26:\n\tif len(c)==26:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n\n\n"}, {"source_code": "input()\nprint ['YES','NO'][len(set(raw_input().lower()))<26]\n"}, {"source_code": "def ni():\n return int(raw_input())\n\nn = ni()\n\nprint 'YES' if len(set(raw_input().lower())) == 26 else 'NO'\n"}, {"source_code": "#!/bin/python2\nn = int(raw_input())\ns = str(raw_input())\nprint \"YES\" if len(set(s.lower())) == 26 else \"NO\"\n"}, {"source_code": "import string\n\n# Getting input\nnumber = raw_input()\nentry = raw_input()\n\n# Performing some string operations\nentry = entry.lower()\nentry = set(entry)\nentry = list(entry)\nentry = sorted(entry)\nentry = \"\".join(entry)\n\n# Getting alphabet\nalphabet = string.ascii_lowercase\n\n# If two strings are matching, print 'YES'.\n# Otherwise, print 'NO'\nif entry == alphabet:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import sys\n\ndef minus(a):\n a=set(sorted(a))\n if len(a) >26:\n print ('YES')\n else:\n print('NO')\n\ndef main():\n num=int(sys.stdin.readline())\n entrada = list(sys.stdin.readline().lower())\n a=minus(entrada)\nmain()\n"}, {"source_code": "userInput = int(input())\n\nstring = set(input().lower())\n\nif len(string)<26:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "#!/bin/python2\nn = int(raw_input())\ns = str(raw_input())\nprint \"YES\" if len(set(s.lower())) == 26 else \"NO\"\n"}, {"source_code": "n = input()\nstring = raw_input()\nascii = []\nstring = string.upper()\nif (n < 26):\n print \"NO\"\n exit\nelse: \n for i in range(n):\n temp = ord(string[i])\n if temp not in ascii:\n ascii.append(temp)\n\n for j in range(65,91):\n if j not in ascii:\n print \"NO\"\n exit(0)\n \n\n print \"YES\"\n \n \n"}, {"source_code": "y=int(input())\nx=input().upper()\nx=set(x)\nif len(x)==26:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "numLet = input()\nphrase = raw_input().lower()\n\nalphabeta = \"abcdefghijklmnopqrstuvwxyz\"\n\nif(len(phrase) == int(numLet)):\n if(len(phrase) >= 26):\n counter = 0\n result = 1\n while(counter < 26):\n if(phrase.count(alphabeta[counter]) == 0):\n result = 0\n \n counter += 1\n \n if(result == 1):\n print(\"YES\")\n if(result == 0):\n print(\"NO\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import string \n\ndef ispangram(str): \n\talphabet = \"abcdefghijklmnopqrstuvwxyz\"\n\tfor char in alphabet: \n\t\tif char not in str.lower(): \n\t\t\treturn False\n\n\treturn True\n\t\n# Driver code \nn=int(input())\nstring = input()\nif(n<26):\n print(\"No\")\nelif(ispangram(string) == True): \n\tprint(\"Yes\") \nelse: \n\tprint(\"No\") \n"}, {"source_code": "n=int(input())\ns=input()\ns=s.upper()\na=set(s)\nif len(a)==26:\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "def solve(n, string):\n\n charSet = set()\n\n for i in range(0, n):\n charSet.add(string[i].lower())\n return \"YES\" if len(charSet) == 26 else \"NO\"\n\n\nif __name__ == \"__main__\":\n\n n = int(raw_input())\n string = raw_input()\n\n print solve(n, string)"}, {"source_code": "n = raw_input()\nstr = raw_input()\ndic = {}\nfor i in range(len(str)):\n if dic.has_key(str[i]):\n dic[str[i].lower()]+=1\n else:\n dic[str[i].lower()]=1\ntemp = 0;\nfor key in dic:\n temp += 1\nif temp >= 26:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "k=raw_input()\ns=raw_input().lower()\ndef process():\n for i in range(ord('a'),ord('z')+1):\n if s.find(chr(i))==-1:\n print \"NO\"\n return\n print \"YES\"\nprocess()"}, {"source_code": "\ndef main():\n raw_input()\n S = raw_input()\n S = S.lower()\n H = {}\n for i in S:\n H[i] = 1\n \n if len(H) == 26:\n print \"YES\"\n else:\n print \"NO\"\n \n \nmain()"}, {"source_code": "d = {'q':0,\n\t\t'w':0,\n\t\t'e':0,\n\t\t'r':0,\n\t\t't':0,\n\t\t'y':0,\n\t\t'u':0,\n\t\t'i':0,\n\t\t'o':0,\n\t\t'p':0,\n\t\t'a':0,\n\t\t's':0,\n\t\t'd':0,\n\t\t'f':0,\n\t\t'g':0,\n\t\t'h':0,\n\t\t'j':0,\n\t\t'k':0,\n\t\t'l':0,\n\t\t'z':0,\n\t\t'x':0,\n\t\t'c':0,\n\t\t'v':0,\n\t\t'b':0,\n\t\t'n':0,\n\t\t'm':0}\n\t\t\na = int(raw_input())\nb = str(raw_input())\nb = b.lower()\nfor i in b:\n\td[i] = d[i]+1\nflag = 0\nfor i in d:\n\tif(d[i]==0):\n\t\tflag = 1\n\t\tprint \"NO\"\n\t\tbreak\nif(flag==0):\n\tprint \"YES\""}, {"source_code": "import sys\n\ndef minus(a):\n## print('a',a)\n a=set(sorted(a))\n## print('a1',a,len(a))\n if len(a) >=26:\n print ('YES')\n else:\n print('NO')\n\ndef main():\n num=int(sys.stdin.readline())\n entrada = list(sys.stdin.readline().strip().lower())\n a=minus(entrada)\nmain()\n"}, {"source_code": "num = int(raw_input())\npalavra = raw_input()\nd = []\n\nfor i in palavra:\n if i.lower() not in d:\n d.append(i.lower())\n\nif len(d) == 26:\n print 'YES'\nelse:\n print 'NO'\n \n\n\n"}, {"source_code": "num = int(raw_input())\npalavra = raw_input()\nd = []\n\nfor i in palavra:\n if i.lower() not in d:\n d.append(i.lower())\n\nif len(d) == 26:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "from sys import stdin\nN = int(stdin.readline())\nstring = stdin.readline().strip()\nif len(set(string.lower())) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# echo hey | python3 pangram.py\n# echo 'The quick brown fox jumps over the lazy dog' | python3 pangram.py\n# echo '35\\n The quick brown fox jumps over the lazy dog\\n' | python3 pangram.py\n# echo '12\\n toosmallword\\n' | python3 pangram.py\n# echo '48\\n thereisasyetinsufficientdataforameaningfulanswer\\n' | python3 pangram.py\n\nimport sys\nimport re\n\nlines_entered = 0\nis_panagram = None\nfor line in sys.stdin:\n lines_entered += 1\n # pangram is at least 26 characters long\n if lines_entered == 1:\n num = int(line)\n if num < 26:\n print('NO')\n sys.exit(0)\n # every character of abcs appears at least onece\n elif lines_entered == 2: \n lowerCase = line.lower()\n uniq = ''.join(set(lowerCase))\n matches = re.findall('[A-z]', uniq)\n if len(matches) == 26:\n print('YES')\n else:\n print('NO')\n \n\n"}, {"source_code": "input()\nprint 'YNEOS'[26!=len(set(raw_input().lower()))::2]"}, {"source_code": "n=int(input())\ns=str(input())\ns2=s.lower()\naset=set(s2)\nif len(aset)>=26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a = []\nF = input()\ns = input()\nfor i in s:\n if i.lower() not in a:\n a.append(i.lower())\nif len(a) == 26:\n print(\"YES\")\nelse: print(\"NO\")\n"}, {"source_code": "a=input()\nb=set(str.upper(input()))\nif len(b)==26:\n print('YES')\nelse:\n print('NO')\n"}], "negative_code": [{"source_code": "print(\"YES\" if len(set(input().lower()))>=26 else \"NO\")"}, {"source_code": "\n\nLength=input()\nsen=input()\ncounters=int(Length)\ncheck=False\nfor x in range(0,counters):\n\tif(sen[x].islower()):\n\t\tcheck=False\n\telse:\n\t\tcheck=True\n\t\tbreak;\n\nif(check==False):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")"}, {"source_code": "n=int(input())\ndict={}\ns=input()\nfor i in s:\n if i in dict:\n dict[i]+=1\n else:\n dict[i]=1\nif len(dict)>=26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "length = int(input())\nstring = input()\nstring = string.upper()\nx= set(string)\ny = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nif length <25:\n\tprint('NO')\nelse:\n\tfor i in range(26):\n\t\tif y[i] in x:\n\t\t\tp = \"YES\"\n\t\telse:\n\t\t\tp = 'NO'\n\t\n\n\tprint(p)"}, {"source_code": "import sys\n\nargs = []\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']\n\nfor line in sys.stdin:\n args.append(line)\nif int(args[0]) < 26:\n print(\"NO\")\nelse:\n for x in args[1]:\n real = x.upper()\n if x in alphabet:\n del alphabet[alphabet.index(x)]\n if len(alphabet) > 0:\n print(\"NO\")\n else:\n print(\"YES\")\n "}, {"source_code": "\ufeffinput()\ns=raw_input()\ns.upper()\nprint s\nans=[0]*150\nfor i in s :\n if not ans[ord(i)] :\n ans[ord(i)] = 1\nif sum(ans) == 26 :\n print \"YES\"\nelse :\n print \"NO\""}, {"source_code": "a=int(input())\nb=input()\nk=0\nf=b.lower()\ng=[]\nfor i in range(26):\n g.append(chr(97+i))\nfor u in f:\n if u in g:\n k+=1\nif k==26:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "l = int(input())\ns = input()\nd = 0\nif l < 26:\n print(\"NO\")\nelse:\n for i in range (l):\n y= s[i]\n count = s.count(y)\n d += (count-1)\n if (d-len(s)) >= 26:\n print (\"YES\")\n if (d-len(s)) <26:\n print(\"NO\")"}, {"source_code": "n=input()\ns=input()\nx=set(s)\nif len(x)>=26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a=input()\nb=input().upper()\nal='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\npp=0\nfor i in al:\n if not (i in b):\n pp+=1\n print(i)\nif pp==0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "while int(input()) > 26:\n n = input().upper()\n alfa = 65\n for i in n:\n if chr(alfa) in n:\n alfa += 1\n\n if alfa == 91:\n print(\"YES\")\n else:\n print(\"NO\")\n break\nelse:\n input()\n print(\"NO\")"}, {"source_code": "#Hassan alkanash\nx=int(input())\nh=input()\nh.lower()\nname=list(h)\nname.sort()\nname=list(set(name))\nif len(name)<27 or len(name)>27 :\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "n = input()\na = input()\ntmp = 0\nfor i in a:\n if i.isupper():\n tmp = 1\n break\nif tmp == 0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "n=int(input())\ns=input()\nu=s.lower()\n#print(u)\np=['a','b','c','d','e','f','g','h','i','j','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nif n>25:\n k=0\n for i in range(25):\n if p[i] not in u:\n k+=1\n break\n if k==0:\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nl=[]\ns=input()\nfor i in range(0,n):\n if s[i] not in l:\n l.append(s[i])\nif len(l)==26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "length = int(input())\nstring = input()\nstring = string.upper()\nx= set(string)\ny = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nif length <26:\n\tprint('NO')\nelse:\n\tfor i in range(26):\n\t\tif y[i] in x:\n\t\t\tp = \"YES\"\n\t\telse:\n\t\t\tp = 'NO'\n\t\n\n\tprint(p)"}, {"source_code": "test_list = [chr(x) for x in range(ord('a'), ord('z') + 1)]\nn = int(input())\narr = set(input())\narr = [i.lower() for i in arr]\n\nprint(arr)\n\nflag = True\n\nfor i in test_list:\n if i not in arr:\n flag = False\n break\n\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nword = list(map(str,input()))[:n]\ns = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nst = []\nfor w in word:\n if w in s:\n st.append(w)\nst = set(st)\nif len(st) >= 26:\n print(\"YES\")\nelse:print(\"NO\")\n\n#35\n#TheuoxOrezyo\n"}, {"source_code": "# A. Pangram\n# time limit per test2 seconds\n# memory limit per test256 megabytes\n# inputstandard input\n# outputstandard output\n# A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.\n\n# You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.\n\n# Input\n# The first line contains a single integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100) \u2014 the number of characters in the string.\n\n# The second line contains the string. The string consists only of uppercase and lowercase Latin letters.\n\n# Output\n# Output \"YES\", if the string is a pangram and \"NO\" otherwise.\nfrom collections import defaultdict\n\nLATIN_LETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j, k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'v', 'x', 'y', 'z']\n\ndef calculate_frequency(word):\n\td = defaultdict(int)\n\n\tfor i in word:\n\t\td[i] += 1\n\treturn d\n\n\n\ndef solve_the_problem():\n\tsize = int(input())\n\tword = input()\n\n\tif size < 23:\n\t\tprint(\"NO\")\n\t\treturn\n\tour_letters = calculate_frequency(word.lower()).keys()\n\tfor letter in LATIN_LETTERS:\n\t\tif letter not in our_letters:\n\t\t\tprint(\"NO\")\n\t\t\treturn\n\t\n\tprint(\"YES\")\n\n\n\n\nif __name__ == \"__main__\":\n solve_the_problem()\n\n"}, {"source_code": "n = int(input())\ns = str(input())\nli = []\nfor i in s:\n if i not in li:\n li.append(i)\nif len(li) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\ns=input()\nstring=['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']\narr1=[]\narr2=[]\ncount=0\nf=0\ng=0\nfor i in range(n):\n if(s[i].isupper()):\n arr1.append(s[i].lower())\n else:\n arr2.append(s[i])\narr=arr1+arr2\nfor i in range(len(arr)):\n if(arr[i] in string):\n count=count+1\nif(count>=26):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = input()\nstring = raw_input()\nascii = []\nstring = string.upper()\nif (n < 26):\n print \"NO\"\n exit\nelse: \n for i in range(n):\n temp = ord(string[i])\n if temp not in ascii:\n ascii.append(temp)\n\n for j in range(67,91):\n if j not in ascii:\n print \"NO\"\n exit(0)\n \n\n print \"YES\"\n \n \n"}, {"source_code": "n = int(input())\nm = 'QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm'\nstroka = input()\nm = list(m)\nnot_found = False\nfor elem in m:\n if elem not in stroka:\n not_found = True\n break\nif not_found is True:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "a=input()\na=set(a)\nif len(a)==26:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\na=input()\ni=0;\ncnt=0;\nwhile(i25:\n k=0\n for i in range(25):\n if p[i] not in u:\n k+=1\n break\n if k==0:\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')"}, {"source_code": "egfiaweufw=raw_input()\nbla=raw_input()\ngood=True\nfor c in \"qwertyuiopasdfghjklzxcvbnm\":\n if c not in bla:\n good=False\nif good:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "str=input().lower()\ndict1 = {chr:str.count(chr) for chr in str}\nif len(list(dict1.keys())) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nq = \"abcdefghijklmnopqrstuvwxyz\"\na = input().lower()\nif len(q)<26:\n print(\"NO\")\nelse:\n k=0\n for i in range(len(q)):\n if q[i] in a:\n a = a.replace(q[i],\"\")\n else:\n print(\"NO\")\n k+=2\n if len(a) == 0 and k == 0:\n print(\"YES\")\n"}, {"source_code": "k=int(input())\na=input().lower()\nfor i in a:\n if(ord(i)>=ord('a' or ord(i)<=ord('z'))):\n a=a.replace(i,'')\nif(a==\"\"):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=int(input())\nu,l=0,0\nword=input()\nfor i in range(n):\n\tif word[i]>='a' and word[i]<='A':\n\t\tl=1 \n\t\tcontinue\n\telse:\n\t\tu=1\n\t\tcontinue\nif u==1 and l==1 :\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "s = raw_input()\ns = raw_input().lower()\nfl = sum(map(lambda x: s.find(x) > 0, list('qazwsxedcrfvtgbyhnujmikolp'))) == 26\nif fl:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "a = int(input())\nn =input()\nl,b=[],[]\nfor i in n:\n if ord(i) in range(ord('A'),ord('Z')+1):\n l.append(i)\n if ord(i) in range(ord('a'),ord('z')+1):\n b.append(i)\n\n# print(len(set(l)),len(set(b)))\nif len(set(l))+len(set(b))>=26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=input()\na=raw_input()\nl=[]\nif n<26:\n print 'NO'\nelse:\n for i in a:\n if i.islower() or i.isupper() and i.lower() not in l:\n l.append(i.lower())\nif len(l)==26:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "n=int(input())\na=input()\nb=a.lower()\nc=list()\nfor i in range(0,len(a)):\n c.append(a[i])\nm=list(set(c))\nprint(m)\nif(len(m)>=26):\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"}, {"source_code": "n = int(input())\nm = 'qQwWeErRtTyYuUiIoOpPaAsSdDfFgGhHjJkKlLzZxXcCvVbBnNmM'\nstroka = input()\nnot_found = False\nfor i in range(n):\n if m not in stroka[i]:\n not_found = True\n break\nif not_found is True:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "# -*- coding: utf-8 -*-\nn=input()\nt=input().lower()\n\nt=list(t)\nif ('a'and'b'and'c'and'd'and'e'and'f'and'g'and'h'and'i'and'j'and'k'and'm'and'n'and'o'and'p'and'q'and'r'and's'and't'and'u'and'v'and'w'and'x'and'y'and'z')in t:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "\n\nn = int(input())\n\nstring = input()\nif n < 26:\n print('NO')\nelse:\n string.lower()\n\n string_test = 'qwertyuiopasdfghjklzxcvbnm'\n\n string = set(string)\n\n for i in string_test:\n if i not in string:\n print('NO')\n break\n else:\n print('YES')\n\n\n\n"}, {"source_code": "s = input()\ns = s.lower()\ns = set(s)\nif len(s) == 26:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\na = input()\nA = set(a.lower())\nif 26 == len(A):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "length = int(input())\nstring = input()\nstring = string.upper()\nx= set(string)\ny = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nif length <25:\n\tprint('NO')\nelse:\n\tfor i in range(26):\n\t\tif y[i] in x:\n\t\t\tp = \"YES\"\n\t\telse:\n\t\t\tp = 'NO'\n\t\n\n\tprint(p)"}, {"source_code": "# Je d\u00e9teste que j'aime que je d\u00e9teste\n\ns = input().casefold()\ns = set(s)\nif len(s) >= 26:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=int(input())\ns=input()\nl=len(s)\ns=s.lower()\nfor i in range(l):\n\tj=i+1\n\tif(l<=n):\n\t\twhile(j= 24:\n print 'YES'\n else:\n print 'NO'"}, {"source_code": "l = int(input())\ns = input()\nd = 0\nif l < 26:\n print(\"NO\")\nelse:\n for i in range (l):\n y= s[i]\n count = s.count(y)\n d += (count-1)\n if (d-len(s)) >= 26:\n print (\"YES\")\n if (d-len(s)) <26:\n print(\"NO\")"}, {"source_code": "n=int(input())\ns=input()\nif any(x.isupper() for x in s ):\n print(\"Yes\")\nelse :\n print(\"No\")\n \n"}, {"source_code": "n=int(input())\nword=input()\nif n<26:\n\tprint('NO')\nelse:\n\tword.lower()\n\twordset=set(word)\n\tif len(wordset)<26:\n\t\tprint('NO')\n\telse:\n\t\tprint('YES')"}, {"source_code": "n = int(input())\ns = input()\nind, ln = [], []\nket = False\nkata = []\nfor i in range (len(s)):\n if(ord(s[i]) >= 65 and ord(s[i]) <= 90):\n ind += [i]\n ket = True\nind += [len(s)]\n\nif(n == 1):\n ket = \"No\"\nelif (ket == False):\n for i in range (len(s)):\n if(s[i] not in kata):\n kata += s[i]\n ket = \"Yes\"\n else:\n ket = \"No\"\n break\nelif (ket == True):\n new = \"\"\n for i in range (len(ind)):\n if(i == len(ind)-1):\n break\n else:\n a = ind[i+1] - ind[i]\n ln += [a]\n for i in s:\n if(ord(i) >= 65 and ord(i) <= 90):\n i = (chr(ord(i)+32))\n new += i\n k = 0\n for i in range (len(ln)):\n kata = []\n for j in range (ln[i]):\n if(new[k] not in kata):\n kata += new[k]\n ket = \"Yes\"\n else:\n ket = \"No\"\n break\n k += 1\n break\nprint (ket)\n \n"}, {"source_code": "s=\"abcdefghijklmnopqrstuvwxyz\"\ns1=input()\ns1.lower()\nc=0\nfor o in s:\n if o in s:\n c+=1\nif(c==len(s)):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nm = input()\nk = m.lower()\na = 0\nif n < 26:\n print('NO')\nelse:\n for i in range(len(m)):\n for j in range(i,len(m)):\n if m[i]!=m[j]:\n a+=1\n if a>=26:\n print('YES')\n else:\n print('NO')"}, {"source_code": "sa = raw_input()\nsa = sa.lower()\ns = set(sa)\nif len(s) == 26:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "n=input()\nprint(\"YES\" if len(set(n))==26 else \"NO\")\n"}, {"source_code": "n = int(input())\ns = input()\ns = s.lower()\nstate = True\nif n < 26:\n print(\"NO\")\nelse:\n s = ''.join(sorted(s))\n for i in range(n-1):\n if ord(s[i]) != ord(s[i+1]) and ord(s[i]) != (ord(s[i+1]) - 1):\n print(\"NO\")\n state = False\n break\n\n if state == True:\n if s[-1] != 'z':\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "n=int(input())\ns=input()\nl=list(map(chr,range(97,122)))\nf=0\ns=s.lower()\nfor i in l:\n if i not in s:\n f=1\n break\nif(f==1):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "#list(map(int,input().split()))\ncnt = 0\nn = int(input())\nword = list(input().lower())\nif(n>=26):\n for i in range(len(word)-1):\n if(ord(word[i])>=97 and ord(word[i])<=122):\n cnt += 1\n if(cnt >= 26):\n print(\"YES\")\n else:\n print(\"NO\")\n\nelse:\n print(\"NO\")\n"}, {"source_code": "s = input()\nst = set(s.lower())\nlong = len(st)\n\nif long == 26:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def isPangram(s):\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n for char in alphabet:\n if char not in s:\n return \"NO\"\n\n return \"YES\"\n\nn = int(raw_input())\ns = raw_input().strip()\nprint isPangram(s)"}, {"source_code": "n = int(input())\ns = input()\ns = s.lower()\nstate = True\nif n < 26:\n print(\"NO\")\nelse:\n s = ''.join(sorted(s))\n for i in range(n-1):\n if ord(s[i]) != ord(s[i+1]) and ord(s[i]) != (ord(s[i+1]) - 1):\n print(\"NO\")\n state = False\n break\n\n if state == True:\n if s[-1] != 'z':\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "n = int(input())\ns = str(input())\ncount = 1\nif n < 26:\n print(\"NO\")\nelse:\n for i in range(0,len(s)-1):\n if s[i] != s[i+1]:\n count = count+1\n if count >= 26:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "a=int(input())\nb=input()\nc=list(b)\nif(a<26):\n print(\"NO\")\nelse:\n for i in range(a):\n if(c[i]!=c[i].lower()):\n c[i]=c[i].lower()\n d=['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 e=set(c) and set(d)\n e=list(e)\n e.sort()\n if(e==d):\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "t=int(input())\ns=input()\ns.lower()\nd={}\nfor i in s:\n d[i]=d.get(i,0)+1\nf=0\nfor i,j in d.items():\n if j<1:\n f=1\n break\nif f==0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s=int(input())\nk=input()\nc=0\nif s==1:\n print('NO')\nelse:\n for i in range(s-1):\n \tif k[i] == k[i+1]:\n \t c=c+1\n if c==0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "a = [0] * 26\n\nraw_input()\n\nfor c in raw_input().strip():\n\tif 0 <= ord(c) - ord('a') < 26:\n\t\ta[ord(c) - ord('a')] += 1\n\nprint \"YES\" if min(a) > 0 else \"NO\"\n"}, {"source_code": "import string\n\n\ndef pangram(s, a):\n if n > 26:\n if set(s.lower()) == a:\n return \"YES\"\n else:\n return \"NO\"\n\n\na = set(string.ascii_lowercase)\nn = int(input())\ns = input()\nprint(pangram(s, a))\n"}, {"source_code": "n=int(input())\ns=input()\nif (n>15) :\n print(\"yes\")\nelse :\n print(\"no\")\n \n"}, {"source_code": "# -*- coding: utf-8 -*-\nt=input().lower()\n\nt=list(t)\nif ('a'and'b'and'c'and'd'and'e'and'f'and'g'and'h'and'i'and'j'and'k'and'm'and'n'and'o'and'p'and'q'and'r'and's'and't'and'u'and'v'and'w'and'x'and'y'and'z')in t:\n print('YES')\nelse:\n print('NO')\n "}, {"source_code": "# http://codeforces.com/problemset/problem/520/A\n\nnum = int(raw_input())\npalavra = raw_input()\nd = []\n\nfor i in palavra:\n if i.lower() not in d:\n d.append(i.lower())\n\nprint d\nif len(d) == 26:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "a=\"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nc,b=int(input()),str(input())\ns=0\nfor k in a:\n if b.count(k):\n s+=1\nif s*2>=len(a):\n print(\"YES\")\nelse:\n print(\"No\")"}, {"source_code": "n=int(input())\ns=input()\nl=len(s)\ns=s.lower()\ncheck=0\nfor i in range(l):\n\tj=i+1\n\tif(check==0):\n\t\twhile(j 0, list('qazwsxedcrfvtgbyhnujmikolp'))) == 26\nif fl:\n print 'YES'\nelse:\n print 'NO'\n"}, {"source_code": "print('YES' if set(list(input().lower()))==set(['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m']) else 'NO')"}, {"source_code": "#Pangram\n\nalpha= 'abcdefghijklmnopqrstuvwxyz'\nbigAlpha='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\nh=int(input(''))\ng=input('')\nx=False\n\n\n\nfor i in g:\n if (i not in alpha) or (i not in bigAlpha):\n print('NO')\n break\n else:\n x=True\n\n\nif x:\n print('YES')\n\n"}, {"source_code": "from string import ascii_lowercase\nn = int(raw_input())\nif n < 26:\n print \"NO\"\ns = raw_input().lower()\nans = \"YES\"\nfor i in ascii_lowercase:\n if i not in s:\n ans = \"NO\"\n break\nprint ans "}, {"source_code": "n=int(input())\nword=input()\nif n<24:\n\tprint('NO')\nelse:\n\twordset=set(word)\n\tif len(wordset)<24:\n\t\tprint('NO')\n\telse:\n\t\tprint('YES')"}, {"source_code": "n=int(input())\na=input()\nb=a.lower()\nc=list()\nfor i in range(0,len(a)):\n c.append(a[i])\nm=list(set(c))\nif(len(m)==26):\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"}, {"source_code": "from string import ascii_lowercase as letters\nn=raw_input()\ns=raw_input()\nprint(s)\n\nif set(list(letters))==set(list(s.lower())):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\ns=input()\nl=\"asdfghjklzxcvbnmpoiuytrewq\"\nt=True\nfor i in l:\n if(i not in s or (i.upper() not in s)):\n print(\"NO\")\n t=False\n break\n else:\n continue\nif(t==True):\n print(\"YES\")\n \n"}, {"source_code": "l = int(input())\ns = input()\nd = 0\nif l < 26:\n print(\"NO\")\nelse:\n for i in range (l):\n y= s[i]\n count = s.count(y)\n d += (count-1)/count\n if (len(s)-d) >= 26:\n print (\"YES\")\n if (len(s)-d) <26:\n print(\"NO\")"}, {"source_code": "n = int(input())\ns = input().lower()\n\nalphabet = []\n\nif n < 26:\n print(\"NO\")\n exit\n\nfor i in range(0, n):\n if s[i] not in alphabet:\n alphabet.append(s[i])\n\nif len(alphabet) < 26:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n"}, {"source_code": "str=input().lower()\ndict1 = {chr:str.count(chr) for chr in str}\nif len(list(dict1.keys())) == 26:\n print(\"YES\")\nelse:\n print(\"no\")"}, {"source_code": "a= int(input())\nb= input()\nc= 65\nd= 97\nfor k in range(26):\n\te= chr(c)\n\tf= chr(d)\n\tif e in b or f in b:\n\t\tc += 1\n\t\td += 1\n\telse:\n\t\tbreak\nif k== 25:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\t"}, {"source_code": "n=input().lower()\nprint('YES' if all([x in n for x in set(['q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m'])]) else 'NO')"}, {"source_code": "l = int(input())\ns = input()\nd = 0\nif l < 26:\n print(\"NO\")\nelse:\n for i in range (l):\n y= s[i]\n count = s.count(y)\n d += (count-1)/count\n if (len(s)-d) >= 26:\n print (\"YES\")\n if (len(s)-d) <26:\n print(\"NO\")"}, {"source_code": "def solve(n,string):\n char=set()\n for i in range(0,n):\n \n char.add(string[i].lower())\n return \"YES\" if len(char)==26 else\"NO\""}, {"source_code": "n = int(input())\ns = input()\ns = s.lower()\ns = [i for i in s]\ns = list(set(s))\ns.sort()\nif n < 26:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "n = int(input())\nt = input().lower()\nflag = 1\nfor i in range(len(t)-1):\n\tif(t[i]==t[i+1] and t[i]<=t[i+1]):\n\t\tflag = 0\n\t\tbreak\t\n\telse:\n\t\tflag = 1\t\nif(flag==1 and len(t)!=1):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\t\t"}, {"source_code": "import sys\n\ndef minus(a):\n\n print('YES' if len(a) > 26 else 'NO')\n\ndef main():\n num=int(sys.stdin.readline())\n entrada = list(sys.stdin.readline().lower())\n a=minus(entrada)\nmain()\n"}, {"source_code": "n=int(input())\nb=input()\na=set(b)\nif len(a)>26:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\nt=input()\nif len(set(t))==26:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "from string import ascii_lowercase as asc_lower\ndef check(s):\n return set(asc_lower) - set(s.lower()) == set([])\nstrng=input()\nif (check(strng)==True):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = input()\nn = int(n)\nword = input()\nmylist = []\n\nif len(word) < 27:\n print(\"NO\")\nelse:\n for c in word:\n if c not in mylist:\n mylist.extend(c)\n if len(mylist)-1 == 26:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "k = int(raw_input().split()[0])\nmm = raw_input().strip()\nal = 'abcdefghijklmnopqrstuvwxyz00'\nALL = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ00'\nfor i in mm:\n if len(ALL) == 2:\n break\n if i in al:\n k = al.find(i)\n al = al[0:k] + al[k+1:]\n ALL = ALL[0:k] + ALL[k+1:]\n if i in ALL:\n k = al.find(i)\n al = al[0:k] + al[k + 1:]\n ALL = ALL[0:k] + ALL[k + 1:]\nif len(al) == 2:\n print 'YES'\nelse:\n print 'NO'"}], "src_uid": "f13eba0a0fb86e20495d218fc4ad532d"} {"nl": {"description": "Little X has met the following problem recently. Let's define f(x) as the sum of digits in decimal representation of number x (for example, f(1234)\u2009=\u20091\u2009+\u20092\u2009+\u20093\u2009+\u20094). You are to calculate Of course Little X has solved this problem quickly, has locked it, and then has tried to hack others. He has seen the following C++ code: ans = solve(l, r) % a; if (ans <= 0) ans += a; This code will fail only on the test with . You are given number a, help Little X to find a proper test for hack.", "input_spec": "The first line contains a single integer a\u00a0(1\u2009\u2264\u2009a\u2009\u2264\u20091018).", "output_spec": "Print two integers: l,\u2009r\u00a0(1\u2009\u2264\u2009l\u2009\u2264\u2009r\u2009<\u200910200) \u2014 the required test data. Leading zeros aren't allowed. It's guaranteed that the solution exists.", "sample_inputs": ["46", "126444381000032"], "sample_outputs": ["1 10", "2333333 2333333333333"], "notes": null}, "positive_code": [{"source_code": "m=int(raw_input())\nx=m-((10**29)*30*45)%m\nprint x,10**30+x-1\n"}, {"source_code": "'''\nGenius Idea from editorial solution 4:\nSince f(x+1e18)=f(x)+1, \ng(l+1,l+1e18+1)=1+g(l,l+1e18)\nNow let x=g(0,1e18-1)%a\nTherefore, we can construct the answer as: l=(a-x),r=(a-x+1e18-1), here we are shifting by a-x so that g(a-x,a-x+1e18-1)%a becomes 0\n'''\t\ndef solve():\n\ta=input()\n\tx=(45*18*(10**17))%a\n\tprint(str(a-x)+' '+str(a-x+(10**18)-1))\nsolve()\n\n"}, {"source_code": "m=int(input()) \nx,t=10**100-1,m-100*45*10**99%m \nprint(t,t+x) "}, {"source_code": "m=int(raw_input())\nbit=100\ntmp=(m-(1+45*bit*(10**(bit-1)))%m)%m\nprint 1+tmp,10**bit+tmp\n"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "#!/usr/bin/env python\n\ns = 45 * 18 * 10**17\n\na = int(raw_input())\ns %= a\nprint (a - s), 10**18 + (a-s) - 1\n"}, {"source_code": "m=int(input())\nx,t=10**18-1,m-18*45*10**17%m\nprint(t,t+x)"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "import itertools\nimport math\n\na = int(raw_input())\n\nfor k in range(1,1000):\n x = a * k\n for keta in range(1,20):\n pow10keta = 1\n for i in range(0,keta):\n pow10keta = pow10keta * 10\n start = 45 * keta * pow10keta/10 + 1\n end = start + 9 * pow10keta - 1\n if start<=x and x<= end:\n r = pow10keta + x - start\n l = r + 1 - pow10keta\n print int(l),int(r)\n exit(0)\n"}, {"source_code": "a = input()\nr = (81000000000000000000)%a\n\nprint a-r, a-r+(10**18)-1"}, {"source_code": "a = int(input())\nt = a-1-45*19*10**18%a\nprint 1+t,10**19+t"}, {"source_code": "s = 81000000000000000001\nn = int(raw_input())\ntemp = (n-s%n)%n;\nprint(\"%d %d\\n\" %(temp+1,1000000000000000000+temp))\n\n"}, {"source_code": "a=int(input())\nb,c=10**100,a-4500*10**99%a\nprint(c,c+b-1)\n"}, {"source_code": "a = int(input())\nx = 18*45*10**17%a\nl = a - x\nprint l, l+10**18-1\n"}, {"source_code": "a = int(raw_input())\nx = a-((90*(10**20))%a)\nprint x, (10**20+x-1)"}, {"source_code": "a=int(input())\n\nx=a-((10**21)*9)%a\n\nprint(x,10**20+x-1)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "try:\n while True:\n a = int(input())\n b = (10 ** 17) % a\n b = (b * 45 * 18+ 1) % a\n print(1 + (a-b), int(1e18) + (a-b))\nexcept EOFError:\n pass\n"}, {"source_code": "import random\nimport sys\n\ndef f(n, mod):\n\tl=[]\n\twhile n>0:\n\t\tl.append(n%10)\n\t\tn//=10\n\tret=0\n\tnum=0\n\tsuma=0\n\twar=1\n\tfor i in l:\n\t\ta=0\n\t\tb=0\n\t\t\n\t\tfor j in range(i):\n\t\t\ta=(a+suma+j*war)%mod\n\t\ta=(a+ret+i*(num+1))%mod\n\t\t\n\t\tfor j in range(10):\n\t\t\tb=(b+suma+j*war)%mod\n\t\t\n\t\tret=a\n\t\tsuma=b\n\t\t\n\t\tnum=(num+war*i)%mod\n\t\twar=(war*10)%mod\n\treturn ret\n\ndef los(dlu):\n\tret=0\n\tfor i in range(dlu):\n\t\tret=ret*10+random.randint(0, 9)\n\treturn ret\n\ndef ans(a, b):\n\tprint(a, b)\n\tsys.exit(0)\n\npam=[(0, 0)]\n\nmod=int(input())\n\nwhile True:\n\ta=los(42)\n\tb=a+los(20)\n\tif a==b:\n\t\tcontinue\n\tif a>b:\n\t\ta,b=b,a\n\twa=f(a, mod)\n\twb=f(b, mod)\n\tif wa==wb:\n\t\tans(a+1, b)\n\tif wa 0 else 0\n rightNum = int(strNum[idx + 1:]) if idx + 1 < len(strNum) else 0\n rightDigits = len(strNum) - idx - 1\n \n # i < digit:\n ret += (digit * (digit - 1) / 2) * (leftNum + 1) * (10 ** rightDigits)\n\n # i > digit:\n ret += (9 * 10 / 2 - digit * (digit + 1) / 2) * (leftNum ) * (10 ** rightDigits)\n \n # i == digit:\n ret += digit * (leftNum ) * (10 ** rightDigits)\n ret += digit * (rightNum + 1)\n\n return ret\n\n\ndef work(a):\n mul = 1\n while mul:\n L = 0\n R = mul * a\n while L < R:\n mid = (L + R) / 2\n\n if g(mid) >= mul * a:\n R = mid\n else:\n L = mid + 1\n \n if g(L) == mul * a:\n print 1, L\n break\n\n mul += 1\n \n\nif __name__ == \"__main__\":\n work(read())\n"}, {"source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n a = 0\n while n:\n if (n >= 10):\n a = a * 10 + 9\n n -= 9;\n else:\n a = a * 10 + n\n n = 0\n print(a, a)\n exit(0)\np = 1\nfor i in range(1,n):\n p *= 10\n m = p // 10 * i * 45 + 1\n #print(m, p, m + p)\n if (m + p > n):\n k = n - m\n while k < 0:\n k += n\n if (k >= p):\n continue\n print(k + 1, p + k)\n exit(0)\n \n"}, {"source_code": "x=int(input())\na=10**100-1\nb=x-(100*45*(10**99)%x)\nprint b,a+b\n"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "a = int(input())\nb = 81000000000000000001 % a\nc = (a - b) % a\nprint(1 + c, 10 ** 18 + c)\n \t \t \t \t \t \t \t \t \t\t \t\t\t\t"}, {"source_code": "a = int(input())\nl = a-45*18*10**17%a\nprint(str(l)+\" \"+str(l+10**18-1))\n"}, {"source_code": "__author__ = 'ckboss'\n\nm=int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "a = input()\nr = (81000000000000000000)%a\n\nprint a-r, a-r+(10**18)-1"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)\n"}, {"source_code": "from math import *\nfrom fractions import *\n\n'''\nx < 10**18\n\nf(x + 10**18) = f(x) + 1\nif g(x+1, x+(10**18)) = s\ng(x+2, x+(10**18)+1) = s + f(x+(10**18)+1) - f(x+1)\n= s + f(x+1) + 1 - f(x+1)\n= s+1\n\nso if g(10**18)%a == r\nthen we shift the interval [1, 10**18-1] by (a-r) steps to the right\n'''\n\ndef solve():\n\ta = input()\n\tr = (45*18*(10**17))%a\n\t\n\tprint a-r, a-r+(10**18)-1\n\treturn\n\nsolve()\n"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "import itertools\nimport math\n\na = int(raw_input())\n\nfor k in range(1,1000):\n x = a * k\n for keta in range(1,20):\n pow10keta = 1\n for i in range(0,keta):\n pow10keta = pow10keta * 10\n start = 45 * keta * pow10keta/10 + 1\n end = start + 9 * pow10keta - 1\n if start<=x and x<= end:\n r = pow10keta + x - start\n l = r + 1 - pow10keta\n print int(l),int(r)\n exit(0)\n"}, {"source_code": "a=int(input())\nx=45*18\nfor i in range(17):\n x*=10\nd=x%a\nprint(str(a-d)+\" \"+ str(a-d+1000000000000000000-1))"}, {"source_code": "a = input()\ns = 10 ** 17\np = (45 * 18 * s + 1) % a\nprint (1 + (a - p)), (s *10 + (a - p))"}, {"source_code": "A = int(input());\nstart = (45*10**18*19+1)%A;\nstart = A-start;\nprint(start+1, start+10**19);\n"}, {"source_code": "# test code from internet\nn = int( input() )\nx,t=10**100-1,n-100*45*10**99%n\nprint(t,t+x)\n"}, {"source_code": "from math import *\nfrom fractions import *\n\n'''\nx < 10**18\n\nf(x + 10**18) = f(x) + 1\nif g(x+1, x+(10**18)) = s\ng(x+2, x+(10**18)+1) = s + f(x+(10**18)+1) - f(x+1)\n= s + f(x+1) + 1 - f(x+1)\n= s+1\n\nso if g(10**18)%a == r\nthen we shift the interval [1, 10**18-1] by (a-r) steps to the right\n'''\n\ndef solve():\n\ta = input()\n\tr = (45*18*(10**17))%a\n\t\n\tprint a-r, a-r+(10**18)-1\n\treturn\n\nsolve()\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)\n"}, {"source_code": "a = int(input())\nb = 45*19*10**18+1\nk = a - (b % a)\nprint(str(k+1)+\" \"+str(10000000000000000000+k))"}, {"source_code": "__author__ = 'andybear'\n\nm=int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)\n"}, {"source_code": "a = input()\nr = (81000000000000000000)%a\n\nprint a-r, a-r+(10**18)-1"}, {"source_code": "a = int(input());\nr = 10**100-1;\nx = a - 45*100*(10**99) % a;\nprint(x,x+r);\n"}, {"source_code": "a=input() \nr=a-810*10**17%a\nprint r,10**18+r-1"}, {"source_code": "a = input()\nr = (81000000000000000000)%a\n\nprint a-r, a-r+(10**18)-1"}, {"source_code": "a = int(input())\n\nl = 1\nr = 10**200\n\ncur = [0]\ncnt = [1]\nfor i in range(300):\n\tcur.append(cur[-1] * 10 + 45 * cnt[-1])\n\tcnt.append(cnt[-1] * 10)\n\ndef calc(x):\n\tglobal cur\n\tglobal cnt\n\tres = 0\n\ta = [int(i) for i in str(x)]\n\ttot = 0\n\tfor i in range(len(a)):\n\t\tif (a[i] != 0):\n\t\t\tfor j in range(a[i]):\n\t\t\t\tres += (tot + j) * cnt[len(a) - i - 1]\n\t\t\tres += a[i] * cur[len(a) - i - 1]\n\t\ttot += a[i]\n\tres += tot\n\treturn res\n\nwhile (l < r - 1):\n\tm = (l + r) // 2\n\tif (calc(m) < a):\n\t\tl = m\n\telse:\n\t\tr = m\n\nif (calc(l) >= a):\n\tr = l\n\ncur = calc(r)\nl = 1\n\ndef get(x):\n\tres = 0\n\twhile (x):\n\t\tres += x % 10\n\t\tx //= 10\n\treturn res\n\nwhile (cur % a != 0):\n\tcur -= get(l)\n\tl += 1\n\twhile (cur < a):\n\t\tr += 1\n\t\tcur += get(r)\n\nprint(l, r)"}, {"source_code": "from math import *\nfrom fractions import *\n\n'''\nx < 10**18\n\nf(x + 10**18) = f(x) + 1\nif g(x+1, x+(10**18)) = s\ng(x+2, x+(10**18)+1) = s + f(x+(10**18)+1) - f(x+1)\n= s + f(x+1) + 1 - f(x+1)\n= s+1\n\nso if g(10**18)%a == r\nthen we shift the interval [1, 10**18-1] by (a-r) steps to the right\n'''\n\ndef solve():\n\ta = input()\n\tr = (45*18*(10**17))%a\n\t\n\tprint a-r, a-r+(10**18)-1\n\treturn\n\nsolve()\n"}, {"source_code": "a = int(input())\nt = a-1-45*19*10**18%a\nprint 1+t,10**19+t"}, {"source_code": "#!/usr/bin/python3\nimport math\n\nA = [0]*250\n\nA[0] , A[1] = 0 , 45\n\nfor i in range(2,250):\n\tA[i] = A[i-1]*10 + 45*pow(10,i-1)\n\ndef tot(n):\n\tif n < 10: return (n*(n+1))//2\n\td = len(str(n))-1\n\tp = pow(10,d)\n\tmsd = n//p\n\treturn msd*A[d] + ((msd*(msd-1))//2)*p + msd*(1+n%p) + tot(n%p)\n\n\n\na = int(input())\nlo , hi = 1 , a\n\n\nwhile lo < hi:\n\tmid = (lo+hi)>>1\n\tif tot(mid) >= a: hi = mid\n\telse : lo = mid+1\n\ni1 , i2 = 1 , hi\ntotal = tot(hi)\n\ndef digSum(n):\n\ttotal = 0\n\twhile n>0:\n\t\ttotal += n%10\n\t\tn //= 10\n\treturn total\n\nwhile total%a != 0:\n\tif total < a:\n\t\ti2 += 1\n\t\ttotal += digSum(i2)\n\telse:\n\t\ttotal -= digSum(i1)\n\t\ti1 += 1\nprint(i1,i2)\n\t\n\t"}, {"source_code": "def dig(n):\n\treturn sum(map(int, list(str(n))))\n\ndef dig_sum(n): # sum of digit sum from 1 to n\n\tl = len(str(n))\n\tres = 0\n\tfor i in range(l)[::-1]:\n\t\ta = n / 10 ** i\n\t\tif i: res += a * 45 * 10 ** (i - 1) * i\n\t\tn -= a * 10 ** i\n\t\tres += a * (a - 1) / 2 * 10 ** i\n\t\tres += (n + 1) * a\n\treturn res\n\ndef binary(val):\n\tl, r = 0, val + 1\n\twhile r - l > 1:\n\t\tmid = (l + r) / 2\n\t\tif dig_sum(mid) < val:\n\t\t\tl = mid\n\t\telse :\n\t\t\tr = mid\n\treturn l\n\nmagic = 1000\nans = [-1] * magic\nans[0] = 0\n\na = int(raw_input())\nx = 1\n\nwhile True:\n\tval = dig_sum(x)\n\tif val % a >= magic:\n\t\tnval = val + (a - val % a)\n\t\tx = binary(nval) + 1\n\t\tcontinue\n\tval %= a\n\tif ans[val] != -1:\n\t\tprint ans[val] + 1, x\n\t\tbreak\n\telse :\n\t\tans[val] = x\n\tx += 1\n"}, {"source_code": "m = int(input())\nx, t = 10**18-1, m-18*45*10**17 % m\nprint(t, t+x)\n"}, {"source_code": "a = int(input())\nprint(0+(a-10**100//10*100*45%a),10**100-1+(a-10**100//10*100*45%a))"}, {"source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n a = 0\n while n:\n if (n >= 10):\n a = a * 10 + 9\n n -= 9;\n else:\n a = a * 10 + n\n n = 0\n print(a, a)\n exit(0)\np = 1\nfor i in range(1,n):\n p *= 10\n m = p // 10 * i * 45 + 1\n #print(m, p, m + p)\n if (m + p > n):\n k = n - m\n while k < 0:\n k += n\n if (k >= p):\n continue\n print(k + 1, p + k)\n exit(0)\n \n"}, {"source_code": "m = int(input())\nx, t=10**100-1,m-100*45*10**99%m\nprint(t, t+x)"}, {"source_code": "a=int(input())\nl=0\nr=10**100-1\na=a-45*100*10**99%a\nprint(a,r+a)\n"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "from random import *\npw=[1]\nfor i in range(1,40): pw.append(pw[i-1]*10)\ndef f(x):\n \tr=[]\n \twhile x!=0:\n \t\tr.append(x%10)\n \t\tx/=10\n \tans=0\n \ts=0\n \tr.reverse()\n \tfor i in range(len(r)):\n \t\tif (i==len(r)-1): ans+=(2*s+r[i]-1)*r[i]/2\n \t\telse: ans+=(2*s+r[i]-1)*r[i]/2*pw[len(r)-i-1]+r[i]*45*(len(r)-i-1)*pw[len(r)-i-2]\n \t\ts+=r[i]\n \treturn ans\nmod=input()\npos=[-1]*1000\nfor i in range(2,40):\n \tpos[f(i)]=i\nwhile True:\n \tx=randint(1,10**30)\n \tp=f(x)\n \tq=p%mod\n \tl,r=0,mod-q\n \twhile l+1>1\n \t\tif (f(x+md)-pb: a,b=b,a\n \t\tprint a,b-1\n \t\tbreak\n \tpos[Q]=x+r\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)\n"}, {"source_code": "a = int(input())\ng = 45 * (10 ** 19) * 20\ng = a + (a - g) % a\nprint(g, 10 ** 20 + g - 1)\n"}, {"source_code": "a = int(input())\nb = 81000000000000000001 % a\nc = (a - b) % a\nprint(1 + c, 10 ** 18 + c)\n \t \t \t \t \t \t \t \t \t\t \t\t\t\t"}, {"source_code": "a = int(input())\nb = 45*19*10**18+1\nk = a - (b % a)\nprint(str(k+1)+\" \"+str(10000000000000000000+k))"}, {"source_code": "from math import *\nfrom fractions import *\n\n'''\nx < 10**18\n\nf(x + 10**18) = f(x) + 1\nif g(x+1, x+(10**18)) = s\ng(x+2, x+(10**18)+1) = s + f(x+(10**18)+1) - f(x+1)\n= s + f(x+1) + 1 - f(x+1)\n= s+1\n\nso if g(10**18)%a == r\nthen we shift the interval [1, 10**18-1] by (a-r) steps to the right\n'''\n\ndef solve():\n\ta = input()\n\tr = (45*18*(10**17))%a\n\t\n\tprint a-r, a-r+(10**18)-1\n\treturn\n\nsolve()\n"}, {"source_code": "import random\nimport sys\n\ndef f(n, mod):\n\tl=[]\n\twhile n>0:\n\t\tl.append(n%10)\n\t\tn//=10\n\tret=0\n\tnum=0\n\tsuma=0\n\twar=1\n\tfor i in l:\n\t\ta=0\n\t\tb=0\n\t\t\n\t\tfor j in range(i):\n\t\t\ta=(a+suma+j*war)%mod\n\t\ta=(a+ret+i*(num+1))%mod\n\t\t\n\t\tfor j in range(10):\n\t\t\tb=(b+suma+j*war)%mod\n\t\t\n\t\tret=a\n\t\tsuma=b\n\t\t\n\t\tnum=(num+war*i)%mod\n\t\twar=(war*10)%mod\n\treturn ret\n\ndef los(dlu):\n\tret=0\n\tfor i in range(dlu):\n\t\tret=ret*10+random.randint(0, 9)\n\treturn ret\n\ndef ans(a, b):\n\tprint(a, b)\n\tsys.exit(0)\n\npam=[(0, 0)]\n\nmod=int(input())\n\nwhile True:\n\ta=los(42)\n\tb=a+los(20)\n\tif a==b:\n\t\tcontinue\n\tif a>b:\n\t\ta,b=b,a\n\twa=f(a, mod)\n\twb=f(b, mod)\n\tif wa==wb:\n\t\tans(a+1, b)\n\tif wa 1:\n M = (L + R) // 2\n if solve(t + M) % a > val:\n R = M\n else:\n L = M\n\n if f(t + 1, t + L) % a == 0:\n print t + 1, t + L\n break\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "a=int(input())\nprint(a-(81000000000000000000%a),end=\" \")\nprint(a-(81000000000000000000%a)+1000000000000000000-1,end=\" \")"}, {"source_code": "a = int(input())\ny = (10**19)*20*45\ny = y % a\nprint (a-y,a-y+10**20-1)"}, {"source_code": "a = int(input())\nl = a-45*18*10**17%a\nprint(str(l)+\" \"+str(l+10**18-1))\n"}, {"source_code": "a = input()\nr = (81000000000000000000)%a\n\nprint a-r, a-r+(10**18)-1"}, {"source_code": "mod=int(raw_input());\nll=10**50-1;\nr=mod-(50*45*10**49)%mod;\nprint r,r+ll;"}, {"source_code": "__author__ = 'ckboss'\n\nm=int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "n=input()\ns=18*45*10**17%n\ns=(n-s)%n\nz=s+bool(s==0)\nprint z,10**18+s-1"}, {"source_code": "a=int(input())\nm=10**17*45*18%a\nprint(a-m, a-m+10**18-1)"}, {"source_code": "n=int(input())\nx=10**18\nk=(774*x)%n\ndef inv(a):\n for i in range(a):\n if i*n+1==(i*n+1)//a*a:\n return (i*n+1)//a\n \nif n%9==0:\n offset=k//9\nelif n%3==0:\n n//=3\n k//=3\n offset=(k*inv(3))%n\nelse:\n offset=(k*inv(9))%n\nl=x-offset\nr=10*x-1-offset\nprint(str(l)+\" \"+str(r))"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "a=int(input())\nx=a-((10**21)*9)%a\nprint(x,10**20+x-1)"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "#!/usr/bin/python\n\nfrom sys import stdin\n\ndef f(x):\n return sum(map(int, list(str(x))))\n\n\ndef fsum(x):\n n = len(str(x))\n res = 0\n# res2 = sum([f(i) for i in range(x+1)])\n for i in range(n)[::-1]:\n a = x // 10**i\n if i:\n res += a * (45 * 10**(i-1) * i)\n x = x - a * 10**i\n res += a * (a - 1) // 2 * 10**i\n res += (x + 1) * a\n return res;\n# print res, res2\n# assert(res == res2)\n\ndef lb(val):\n l = 0\n r = val + 1\n while r - l > 1:\n m = (l + r) // 2\n if fsum(m) < val:\n l = m\n else:\n r = m\n return l\n\n\nmagic = 1000\n\nanss = [-1] * magic\nanss[0] = 0\n\na = int(stdin.read())\n\nx = 1\n\nwhile True:\n val = fsum(x)\n if val % a >= magic:\n nval = val + (a - val % a)\n x = lb(nval) + 1\n continue\n val = val % a\n if anss[val] != -1:\n print anss[val]+1, x\n# assert((fsum(x) - fsum(anss[val])) % a == 0)\n break\n else:\n anss[val] = x\n x = x + 1\n\n\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)\n"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r+(r==0),z+r-1\n"}, {"source_code": "a = int(raw_input())\n\ndef s(n):\n r = 0\n while n > 0:\n r += n % 10\n n /= 10\n return r\n\ndef s1(n):\n if n < 10:\n return sum(range(0, n + 1))\n D = n % 10\n r = 0\n for d in range(10):\n if d <= D:\n r += d*(n / 10 + 1)\n else:\n r += d*(n / 10)\n r += s(n / 10) * (D + 1)\n r += s1((n / 10) - 1) * 10\n return r\n\ndef s2(n):\n r = 0\n for i in range(n + 1):\n r += s(i)\n return r\n\n\nwas = {}\nwas[0] = 0\n\nx = 0\nwhile True:\n assert x / a < 30\n x += a\n l = 0\n r = max(a, 100)\n while l + 1 < r:\n m = (l + r) / 2\n if s1(m) < x:\n l = m\n else:\n r = m\n k = s1(r) % a\n assert k < 2000\n if k in was:\n print was[k] + 1, r\n break\n\n was[k] = r\n\n\n\n"}, {"source_code": "m = int(input())\nx, t = 10**18-1, m-18*45*10**17 % m\nprint(t, t+x)\n"}, {"source_code": "a = int(input())\nb = 81000000000000000001 % a\nc = (a - b) % a\nprint(1 + c, 10 ** 18 + c)\n \t \t \t \t \t \t \t \t \t\t \t\t\t\t"}, {"source_code": "a=input()\nr=a-1-18*45*10**17%a\nprint r+1,10**18+r"}, {"source_code": "a=int(input())\nb,c=10**100,a-4500*10**99%a\nprint(c,c+b-1)\n"}, {"source_code": "m=int(input())\nx, t = 10**100-1, m - 100 * 45 * 10**99 % m\nprint t, t + x\n"}, {"source_code": "a=int(input())\nm=10**17*45*18%a\nprint(a-m, a-m+10**18-1)"}, {"source_code": "pow_l = 50\ncnt = 10 ** (pow_l - 1)\ncnt *= 45\ncnt *= pow_l\ncnt += 1\n\nl = 1\nr = 10 ** pow_l\n\nmod = int(raw_input())\ncnt %= mod\nif (cnt == 0):\n print l, r\nelse:\n print l + (mod - cnt), r + (mod - cnt)\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "m=int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "def g (x):\n global arr\n z = 0\n while 10 ** z <= x:\n z += 1\n z -= 1\n ans = 0\n while x > 0:\n y = x // 10 ** z\n ans += 10 ** z * y * (y - 1) // 2\n ans += y * arr[z]\n ans += y * (x % 10 ** z)\n x %= 10 ** z\n z -= 1\n return ans\n\ndef f(x):\n r = 0\n while x > 0:\n r += x % 10\n x //= 10\n return r\n\nn = 100\narr = [0] * n\nfor i in range(1, n):\n arr[i] = 45 * 10 ** (i - 1) + 10 * arr[i - 1]\nfor i in range(n):\n arr[i] += 1\na = int(input())\nans = [-1] * 1000\nfor i in range(1, 1000):\n L, R = 1, 10 ** 30\n while R - L > 1:\n M = (L + R) // 2\n if g(M) - f(M) > i * a:\n R = M\n else:\n L = M\n x = g(R) % a\n if ans[x] != -1:\n print(ans[x], R)\n break\n else:\n ans[(g(R) - f(R)) % a] = R\n"}, {"source_code": "a = int(raw_input());\nm = (45 * 18 * (10**17) + 1)% a;\nprint 1 + a - m, 10**18 + a - m;\n\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "a = int(input())\nwant = 81000000000000000000 % a\nprint(a - want, a - want - 1 + 10**18)\n"}, {"source_code": "a = int(raw_input())\nl = a-((100*45*(10**99))%a)\nr = (10**100)-1\nprint l, r+l "}, {"source_code": "a = int(input())\nb = 45*19*10**18+1\nk = a - (b % a)\nprint(str(k+1)+\" \"+str(10000000000000000000+k))"}, {"source_code": "a = int(input());\nr = 10**100-1;\nx = a - 45*100*(10**99) % a;\nprint(x,x+r);\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "a = int(input())\nsm = 30 * 45 * 10**30 // 10 + 1\nl = 1\nr = 10 ** 30\nl += a - sm % a\nr += a - sm % a\nprint(l,r)"}], "negative_code": [{"source_code": "a = int(input());\nt = 1000000000000000000000000000;\nif (45 * t) % a == 0:\n print (1, t - 1);\nelse:\n print((a - (45 * t) % a), t + (a - (45 * t) % a) - 1);"}, {"source_code": "a = int(input());\nt = 1000000000000000000000000000;\nd = 1111111111111111111111111111;\nif (45 * d) % a == 0:\n print (1, t - 1);\nelse:\n print((a - (45 * d) % a), t + (a - (45 * d) % a) - 1);"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport math\n\na = int(raw_input())\nr = int(math.ceil(math.log(a, 10))) + 1\nz = (45 * r * pow(10, r - 1, a) + 1) % a\nx = a - z\nprint x, 10 ** r + x\n# print fsum(10**5 + 100) - fsum(100) - fsum(10**5)\n# print fsum(11010), fsum(10000) + 1010 + fsum(1000) + 10 + fsum(10)\n"}, {"source_code": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport math\n\na = int(raw_input())\nr = int(math.ceil(math.log(a, 10))) + 1\nz = (45 * r * pow(10, r - 1, a) + 1) % a\nx = a - z\nprint 10 ** r + x, x\n# print fsum(10**5 + 100) - fsum(100) - fsum(10**5)\n# print fsum(11010), fsum(10000) + 1010 + fsum(1000) + 10 + fsum(10)\n"}, {"source_code": "#Thanks to http://codeforces.com/profile/ZhouYuChen\n\n\n'''def s(x):\n\tif(x==0):\n\t\treturn 0\n\treturn x+s(x-1)\n\n\ndef calc(x):\n\tm=1\n\tans=0\n\twhile(x):\n\t\tans2=s(x%10)\n\t\tx/=10\n\t\tans2+=(45*x)\n\t\tans2*=m\n\t\tans+=ans2\n\t\tm*=10\n\treturn ans\n\ndef bc(x):\n\tans=0\n\twhile(x):\n\t\tans+=x%10\n\t\tx/=10\n\treturn ans\n\ndef brute(x):\n\tans=0\n\twhile(x>0):\n\t\tans+=bc(x)\n\t\tx-=1\n\treturn ans\n\na=int((raw_input()))\nprint calc(a), brute(a) '''\n\na=int(raw_input())\ns=(45*(10**101))\nk=(a-s)%a\nprint k,(10**100)+k-1\n\n\n"}, {"source_code": "#Thanks to http://codeforces.com/profile/ZhouYuChen\n\n\n'''def s(x):\n\tif(x==0):\n\t\treturn 0\n\treturn x+s(x-1)\n\n\ndef calc(x):\n\tm=1\n\tans=0\n\twhile(x):\n\t\tans2=s(x%10)\n\t\tx/=10\n\t\tans2+=(45*x)\n\t\tans2*=m\n\t\tans+=ans2\n\t\tm*=10\n\treturn ans\n\ndef bc(x):\n\tans=0\n\twhile(x):\n\t\tans+=x%10\n\t\tx/=10\n\treturn ans\n\ndef brute(x):\n\tans=0\n\twhile(x>0):\n\t\tans+=bc(x)\n\t\tx-=1\n\treturn ans\n\na=int((raw_input()))\nprint calc(a), brute(a) '''\n\na=int(raw_input())\ns=45*(10**102)%a\nk=(a-s)%a\nprint k,(10**101)+k-1\n\n\n"}, {"source_code": "#Thanks to http://codeforces.com/profile/ZhouYuChen\n\n\n'''def s(x):\n\tif(x==0):\n\t\treturn 0\n\treturn x+s(x-1)\n\n\ndef calc(x):\n\tm=1\n\tans=0\n\twhile(x):\n\t\tans2=s(x%10)\n\t\tx/=10\n\t\tans2+=(45*x)\n\t\tans2*=m\n\t\tans+=ans2\n\t\tm*=10\n\treturn ans\n\ndef bc(x):\n\tans=0\n\twhile(x):\n\t\tans+=x%10\n\t\tx/=10\n\treturn ans\n\ndef brute(x):\n\tans=0\n\twhile(x>0):\n\t\tans+=bc(x)\n\t\tx-=1\n\treturn ans\n\na=int((raw_input()))\nprint calc(a), brute(a) '''\n\na=int(raw_input())\ns=(45*(10**101))\nk=(a-s)%a\nprint k,(10**101)+k-1\n\n\n"}, {"source_code": "#!/usr/bin/env python\n\nimport random\n\n\ndef read():\n return input()\n\n\ndef g(n):\n strNum = str(n)\n \n ret = 0\n for idx in range(len(strNum)):\n if idx == 0:\n digit = int(strNum[idx])\n for i in range(1, digit):\n ret += i * (10 ** (len(strNum) - idx - 1))\n ret += digit * (int(strNum[1:]) + 1)\n else:\n for i in range(1, 10):\n ret += i * (10 ** (len(strNum) - idx - 1))\n\n return ret\n\n\ndef work(a):\n \n while 1:\n v = random.randrange(2, 10 ** 199)\n gv = g(v)\n \n L = 0\n R = a + 1\n while L < R:\n mid = (L + R) / 2\n\n if g(v + mid) - gv >= a + 1:\n R = mid\n else:\n L = mid + 1\n\n if g(v + L) - gv == a + 1:\n print 1, v + L\n break\n\n\nif __name__ == \"__main__\":\n work(read())\n"}, {"source_code": "#!/usr/bin/env python\n\nimport random\n\n\ndef read():\n return input()\n\n\ndef g(n):\n strNum = str(n)\n\n if len(strNum) == 1:\n return n * (n + 1) / 2\n \n ret = 0\n for idx in range(len(strNum)):\n if idx == 0:\n digit = int(strNum[idx])\n for i in range(1, digit):\n ret += i * (10 ** (len(strNum) - idx - 1))\n ret += digit * (int(strNum[1:]) + 1)\n else:\n for i in range(1, 10):\n ret += i * (10 ** (len(strNum) - idx - 1))\n\n return ret\n\n\ndef work(a):\n while 1:\n v = random.randrange(2, 10 ** 199)\n gv = g(v)\n \n L = 0\n R = a\n while L < R:\n mid = (L + R) / 2\n\n if g(v + mid) - gv >= a:\n R = mid\n else:\n L = mid + 1\n\n if g(v + L) - gv == a:\n print 1, v + L\n break\n\n\nif __name__ == \"__main__\":\n work(read())\n"}, {"source_code": "from math import inf as inf\nfrom math import *\nfrom collections import *\nimport sys\nfrom itertools import permutations\ninput=sys.stdin.readline\nt=1\nwhile(t):\n t-=1\n n=int(input())\n f=45*20*(10**19)%n\n print(f,f+(10**20-1))\n "}, {"source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n a = 0\n while n:\n if (n >= 10):\n a = a * 10 + 9\n n -= 9;\n else:\n a = a * 10 + n\n n = 0\n if a == 1:\n a = a + 1\n print(a - 1, a)\n exit(0)\np = 1\nfor i in range(1,n):\n p *= 10\n m = p // 10 * i * 45 + 1\n #print(m, p, m + p)\n if (m + p > n):\n k = n - m\n while k < 0:\n k += n\n if (k >= p):\n continue\n print(k + 1, p + k)\n exit(0)\n \n"}, {"source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n a = 0\n while n:\n if (n >= 10):\n a = a * 10 + 9\n n -= 9;\n else:\n a = a * 10 + n\n n = 0\n print(a, a - 1)\n exit(0)\np = 1\nfor i in range(1,n):\n p *= 10\n m = p // 10 * i * 45 + 1\n #print(m, p, m + p)\n if (m + p > n):\n k = n - m\n while k < 0:\n k += n\n print(k + 1, p + k)\n exit(0)\n \n"}, {"source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n a = 0\n while n:\n if (n >= 10):\n a = a * 10 + 9\n n -= 9;\n else:\n a = a * 10 + n\n n = 0\n print(a, a - 1)\n exit(0)\np = 1\nfor i in range(1,n):\n p *= 10\n m = p // 10 * i * 45 + 1\n #print(m, p, m + p)\n if (m + p > n):\n k = n - m\n while k < 0:\n k += n\n if (k >= p):\n continue\n print(k + 1, p + k)\n exit(0)\n \n"}, {"source_code": "n = input()\nn = int(n)\n#print(n)\nif (n < 46):\n a = 0\n while n:\n if (n >= 10):\n a = a * 10 + 9\n n -= 9;\n else:\n a = a * 10 + n\n n = 0\n if a == 1:\n a = a + 1\n print(a, a - 1)\n exit(0)\np = 1\nfor i in range(1,n):\n p *= 10\n m = p // 10 * i * 45 + 1\n #print(m, p, m + p)\n if (m + p > n):\n k = n - m\n while k < 0:\n k += n\n if (k >= p):\n continue\n print(k + 1, p + k)\n exit(0)\n \n"}, {"source_code": "a=int(input())\nb,c=10**100,a-4500*10**99%a\nprint(c+1,c+b)\n"}, {"source_code": "a=int(input())\nb,c=10**100,a-45*50*10**99%a\nprint(c,c+b-1)\n"}, {"source_code": "a=int(input())\nb,c=10**100,a-45*100*10**99%a\nprint(c,c+b)\n"}, {"source_code": "a=int(input())\nb,c=10**50,a-4500*10**49%a\nprint(c,c+b-1)\n"}, {"source_code": "a = int(input());\nt = 1000000000000000000000000000;\nd = 27 * 45 * 100000000000000000000000000;\nif (45 * d) % a == 0:\n print (1, t - 1);\nelse:\n print((a - (45 * d) % a), t + (a - (45 * d) % a) - 1);"}, {"source_code": "a = int(input());\nt = 1000000000000000000000000000;\nif (45 * t) % a == 0:\n\tprint (1, t - 1);\nelse:\n\tprint(((45 * t) % a), t + ((45 * t) % a));\n"}, {"source_code": "a = int(input());\nt = 1000000000000000000000000000;\nd = 111111111111111111111111111;\nif (45 * d) % a == 0:\n print (1, t - 1);\nelse:\n print((a - (45 * d) % a), t + (a - (45 * d) % a) - 1);"}, {"source_code": "a = int(raw_input())\nx = a-((90*(10**19))%a)\nprint x, (10**19+x-1)"}, {"source_code": "m = int(input())\nprint 10**100-1,m-100*45*10**99%m"}, {"source_code": "a = int(input())\nx = 18*45*10**17%a\nl = a - x\nprint (l, l+10**18-1)\n"}, {"source_code": "from random import randint\ndef main():\n a = int(raw_input())\n t = 0\n dp = [0, 45 % a]\n d = [1, 10]\n for i in xrange(1, 21):\n dp.append((dp[-1] * 10 + 45 * d[-1]) % a)\n d.append(d[-1] * 10 % a)\n def f(xx, x):\n res = 0\n i = 0\n t = 1\n while x:\n y = x % 10\n res += dp[i] * y % a\n res += y * (y - 1) / 2 * d[i] % a\n res %= a\n res += t * y\n res %= a\n t = y * d[i] + t\n t %= a\n x /= 10\n i = i + 1\n xx = x\n while x:\n y = x % 10\n res += dp[i] * y % a\n res += y * (y - 1) / 2 * d[i] % a\n res %= a\n res += t * y\n res %= a\n t = y * d[i] + t\n t %= a\n x /= 10\n i = i + 1\n return res\n di = dict()\n while 1:\n ru, rd = randint(1, 10 ** 9), randint(1, 10 ** 9)\n k = f(ru, rd)\n if k in di:\n if di[k] != (ru, rd):\n s, t = di[k], (ru, rd)\n if s > t: s, t = t, s\n s = s[0] * 1000000000 + s[1] + 1\n t = t[0] * 1000000000 + t[1]\n print s, t\n return\n else:\n di[k] = (ru, rd)\nmain()\n"}, {"source_code": "from random import randint\ndef main():\n a = int(raw_input())\n t = 0\n dp = [0, 45 % a]\n d = [1, 10]\n for i in xrange(1, 21):\n dp.append((dp[-1] * 10 + 45 * d[-1]) % a)\n d.append(d[-1] * 10 % a)\n def f(x, xx):\n res = 0\n i = 0\n t = 1\n while x:\n y = x % 10\n res += dp[i] * y % a\n res += y * (y - 1) / 2 * d[i] % a\n res %= a\n res += t * y\n res %= a\n t = y * d[i] + t\n t %= a\n x /= 10\n i = i + 1\n xx = x\n while x:\n y = x % 10\n res += dp[i] * y % a\n res += y * (y - 1) / 2 * d[i] % a\n res %= a\n res += t * y\n res %= a\n t = y * d[i] + t\n t %= a\n x /= 10\n i = i + 1\n return res\n di = dict()\n while 1:\n ru, rd = randint(1, 10 ** 9), randint(1, 10 ** 9)\n k = f(ru, rd)\n if k in di:\n if di[k] != (ru, rd):\n s, t = di[k], (ru, rd)\n if s > t: s, t = t, s\n s = s[0] * 1000000000 + s[1] + 1\n t = t[0] * 1000000000 + t[1]\n print s, t\n return\n else:\n di[k] = (ru, rd)\nmain()\n"}, {"source_code": "a = int(input())\nt = (a-45*18*10**18)%a\nprint 1+t,10**19+t\n"}, {"source_code": "a = int(input())\nt = (a-45*18*10**18-1)%a\nprint 1+t,10**19+t\n"}, {"source_code": "a = int(input())\nt = (a-45*18*10**17-1)%a\nprint 1+t,10**19+t\n"}, {"source_code": "a = int(input())\nt = a-45*18*10**18%a\nprint t,10**19+t-1\n"}, {"source_code": "A = int(raw_input())\npow10 = 10 ** 20\n\ns = (int(4.5 * 20) * pow10) % A\n#think about the offset\nA = (A - s) % A\nprint A, A + pow10 - 1"}, {"source_code": "m=int(raw_input())\ntmp=m-(45*(10**98))%m\nprint 1+tmp,10**100+tmp\n"}, {"source_code": "m=int(raw_input())\nbit=100\ntmp=m-(1+45*(10**(bit-1)))%m\nprint 1+tmp,10**bit+tmp\n"}, {"source_code": "m=int(raw_input())\ntmp=m-(1+45*(10**98))%m\nprint 1+tmp,10**100+tmp\n"}, {"source_code": "n=input()\ns=18*45*10**17%n\ns=(n-s)%n\nz=s+bool(s==0)\nprint z,10**18+s"}, {"source_code": "a=input()\nz=10**18\nr=81*z%a\nprint r,z+r-1"}, {"source_code": "z=10**18\nr=-81*z%input()\nprint r,z+r-1"}, {"source_code": "a = int(raw_input());\nm = (45 * (10 ** 18 - 1) / 18 - 1)% a;\nprint 1 + a - m, 10**18 + a - m;\n\n"}, {"source_code": "a = int(raw_input());\nm = 45 * (10 ** 18 - 1) / 18 % a;\nprint 1 + a - m, 10**18 + a - m;\n\n"}, {"source_code": "#!/usr/bin/env python2\n\ndef sumfunc(k):\n return 45 * 10 ** (k - 1) * k\n\na = int(input())\nval = sumfunc(18)\nval %= a\nrev = (a - val) % a\nif rev == 0:\n print(1, 10 ** 18 - 1)\nelse:\n print(rev, 10 ** 18 + rev - 1)"}, {"source_code": "mod=int(raw_input());\nl=10**50-1;\nr=mod-(100*45*10**49)%mod;\nprint(r,r+l);"}, {"source_code": "mod=int(raw_input());\nll=10**50-1;\nr=mod-(100*45*10**49)%mod;\nprint r,r+ll;"}, {"source_code": "a = int(raw_input())\nx = (10 ** 17) *45 * 18 % a\nprint(a - x, a - x + (10 ** 18) -1)\n"}, {"source_code": "import itertools\nimport math\n\na = int(raw_input())\n\nfor k in range(1,11):\n x = a * k\n for keta in range(1,20):\n pow10keta = 1\n for i in range(0,keta):\n pow10keta = pow10keta * 10\n start = 45 * keta * pow10keta/10 + 1\n end = start + 9 * pow10keta - 1\n if start<=x and x<= end:\n r = pow10keta + x - start\n l = r + 1 - pow10keta\n print int(l),int(r)\n exit(0)\n"}, {"source_code": "import itertools\nimport math\n\na = int(raw_input())\n\nfor k in range(1,1000000):\n x = a * k\n for keta in range(1,100):\n pow10keta = 1\n for i in range(1,keta):\n pow10keta = pow10keta * 10\n start = 45 * keta * pow10keta/10 + 1\n end = start + 9 * pow10keta - 1\n if start<=x and x<= end:\n r = pow10keta + x - start\n l = r + 1 - pow10keta\n print int(l),int(r)\n exit(0)\n"}, {"source_code": "import itertools\nimport math\n\na = int(raw_input())\n\nfor k in range(1,1000):\n x = a * k\n for keta in range(1,100):\n pow10keta = math.pow(10,keta)\n start = 45 * keta * pow10keta/10 + 1\n end = start + 9 * pow10keta - 1\n if start<=x and x<= end:\n r = pow10keta + x - start\n l = r + 1 - pow10keta\n print int(l),int(r)\n exit(0)\n"}, {"source_code": "import itertools\nimport math\n\na = int(raw_input())\n\nfor k in range(1,1000000):\n x = a * k\n for keta in range(1,100):\n pow10keta = math.pow(10,keta)\n start = 45 * keta * pow10keta/10 + 1\n end = start + 9 * pow10keta - 1\n if start<=x and x<= end:\n r = pow10keta + x - start\n l = r + 1 - pow10keta\n print int(l),int(r)\n exit(0)\n"}, {"source_code": "a = int(raw_input())\nx = (45*18*10**17) %a\nprint a-x-1, 10**18+a-x-1"}, {"source_code": "a = int(raw_input())\nx = (45*18*10**17) %a\nprint a-x, 10**18+a-x"}, {"source_code": "x=int(input())\na=10**100-1\nb=x-(45*(10**99)%x)\nprint(b,a+b)\n"}, {"source_code": "x=int(input())\na=10**100-1\nb=x-(45*(10**99)%x)\nprint b,a+b\n"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-100*45*10**99%m\nprint(t,t+x)"}, {"source_code": "m = int(input())\nx,t=10**100-1,m-45*10**100%m\nprint(t,t+x)\n"}, {"source_code": "a = int(input())\nl = a-450*10**18%a\nprint(str(l)+\" \"+str(l+10**18-1))\n"}, {"source_code": "m = int(input())\nx,t=10**18-1,m-100*45*10**17%m\nprint(t,t+x)"}, {"source_code": "A = int(input());\nstart = (45*10**18*18+1)%A;\nstart = A-start;\nprint(start+1, start+10**19);\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef sumfunc(k):\n return 45 * 10 ** (k - 1) * k\n\na = int(input())\nval = sumfunc(18)\nval %= a\nrev = (a - val) % a\nif rev == 0:\n print(1, 10 ** 18)\nelse:\n print(rev, 10 ** 18 + rev - 1)\n"}, {"source_code": "P=(int)(input())\nL=P-81*(10**18)\nL=(L%P+P)%P\nR=L+10**18-1\nprint(L,R)"}, {"source_code": "a=int(input())\nm=10**17*45*9%a\nprint(a-m, a-m+10**18-1)"}, {"source_code": "a=int(input())\nx=a-((10**21)*45*20+1)%a\nprint(x+1,10**21+x)\n"}, {"source_code": "a = int(input())\nx = 81000000000000000001\nx %= a\nwant = (1 - x % a)\nprint(a - want, a - want + 10**18 - 1)"}, {"source_code": "def c(x):\n return int(45 * x * 10**x//10 + 1)\n\na = int(input())\nfor i in range(1, 100):\n \n x = c(i)\n x %= a\n want = (1-x)%a\n if want != 0:\n print(want, want + 10**i - 1)\n quit()"}, {"source_code": "a = int(input())\nx = 81000000000000000001\nx %= a\nwant = (1 - x % a)\nprint(want, want + 10**18 - 1)\n"}, {"source_code": "a = int(input())\nif a == 1:\n print(\"1 9001133713379001\")\n quit()\nx = 81000000000000000001\nx %= a\nwant = ((1 - x) % a)\nprint(want, want + 10**18 - 1)\n"}, {"source_code": "a = int(input())\nx = 81000000000000000001\nx %= a\nwant = ((1 - x) % a)\nprint(want, want + 10**18 - 1)\n"}, {"source_code": "def c(x):\n return int(45 * x * 10**x//10 + 1)\n\na = int(input())\nfor i in range(18, 100):\n \n x = c(i)\n x %= a\n want = (1-x)%a\n if want != 0:\n print(want, want + 10**i - 1)\n quit()"}, {"source_code": "def main():\n a = int(input())\n\n def digits(n):\n while n > 0:\n yield n % 10\n n //= 10\n \n def F(n):\n res = 5 * n\n _r = 0\n for di in digits(n):\n _r += di * (di - 9)\n return res + _r//2\n\n #j = 1\n #while (F(a+j-1)-F(j-1)) % a:\n # j*=2\n for i in [9, 99, 999, 9999, 99999]:\n res = 0\n for j in range(i+1):\n for di in digits(j):\n res += di\n print(i, F(i), res)\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "from math import ceil, log10\n\n\ndef main():\n a = int(input())\n\n n = ceil(log10(a))\n x = (45*n*10**(n-1)+1)%a\n print(a-x+1, 10**n+a-x)\n\n def digits(n):\n while n > 0:\n yield n % 10\n n //= 10\n \n for i in range(200):\n res = 0\n for j in range(i+1):\n for di in digits(j):\n res += di\n print(i, res)\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "def main():\n a = int(input())\n\n def digits(n):\n while n > 0:\n yield n % 10\n n //= 10\n \n def F(n):\n res = 5 * n\n _r = 0\n for di in digits(n):\n _r += di * (di - 9)\n return res + _r//2\n\n j = 1\n while (F(a+j-1)-F(j-1)) % a:\n j*=2\n\n print(j, a+j-1)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "def main():\n a = int(input())\n\n x = (45*19*10**19+1)%a\n print(a-x+1, 10**19+a-x)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "def main():\n a = int(input())\n\n def digits(n):\n while n > 0:\n yield n % 10\n n //= 10\n\n print(a-10**18%a, a-10**18%a+10**18-1)\n\n\n\n\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "from math import ceil, log10\n\n\ndef main():\n a = int(input())\n\n n = ceil(log10(a))\n x = (45*n*10**(n-1)+1)%a\n print(a-x+1, 10**n+a-x)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "def main():\n a = int(input())\n\n def digits(n):\n while n > 0:\n yield n % 10\n n //= 10\n \n def F(n):\n res = 5 * n\n _r = 0\n for di in digits(n):\n _r += di * (di - 9)\n return res + _r//2\n\n j = 1\n while (F(a+j)-F(j-1)) % a:\n j*=2\n\n print(j, a+j)\n\n\nif __name__ == '__main__':\n main()\n\n"}, {"source_code": "n=int(input())\nx=10**18\nk=(774*x)%n\ndef inv(a):\n for i in range(a):\n if i*n+1==(i*n+1)//a*a:\n return (i*n+1)//a\n \nif n%9==0:\n offset=k//9\nelif n%3==0:\n n//=3\n k//=3\n offset=(k*inv(3))%n\nelse:\n offset=(k*inv(9))%n\nl=x-1-offset\nr=10*x-1-offset\nprint(str(l)+\" \"+str(r))"}, {"source_code": "a = int(input())\nsm = 15 * 45 * 10**148 // 10 + 1\nl = 1\nr = 10 ** 15\nl += a - sm % a\nr += a - sm % a\nprint(l,r)"}, {"source_code": "a = int(input())\n#1 10**15\nsm = 45 * 10**15 // 10 + 1\nl = 1\nr = 10 ** 15\nl += a - sm % a\nr += a - sm % a\nprint(l,r)"}, {"source_code": "a = int(input())\nsm = 15 * 45 * 10**15 // 10 + 1\nl = 1\nr = 10 ** 15\nl += a - sm % a\nr += a - sm % a\nprint(l,r)"}, {"source_code": "def g (x):\n global arr\n z = 0\n while 10 ** z <= x:\n z += 1\n z -= 1\n ans = 0\n while x > 0:\n y = x // 10 ** z\n ans += 10 ** z * y * (y - 1) // 2\n ans += y * arr[z]\n ans += y * (x % 10 ** z)\n x %= 10 ** z\n z -= 1\n return ans\n\ndef f(x):\n r = 0\n for i in range(x + 1):\n j = i\n while j > 0:\n r += j % 10\n j //= 10\n return r\n\nn = 100\narr = [0] * n\nfor i in range(1, n):\n arr[i] = 45 * 10 ** (i - 1) + 10 * arr[i - 1]\nfor i in range(n):\n arr[i] += 1\na = int(input())\nans = [-1] * 1000\nfor i in range(1, 1000):\n L, R = 1, 10 ** 100\n while R - L > 1:\n M = (L + R) // 2\n if g(M) > i * a:\n R = M\n else:\n L = M\n x = g(R) % a\n if ans[x] != -1:\n print(ans[x], R)\n break\n else:\n ans[x] = R\n"}, {"source_code": "m = int(input())\nx,t=10**18-1,m-100*45*10**17%m\nprint(t,t+x)\n"}, {"source_code": "m = int(input())\nx,t=10**50-1,m-100*45*10**49%m\nprint(t,t+x)\n"}, {"source_code": "p = int(input());\nt = p - 45 * 18 * 10**17 % p;\nprint t, 10**18+t"}, {"source_code": "pow_l = 50\ncnt = 10 ** (pow_l - 1)\ncnt *= 45\ncnt += 1\n\nl = 1\nr = 10 ** pow_l\n\nmod = int(raw_input())\ncnt %= mod\nif (cnt == 0):\n print l, r\nelse:\n print l + (mod - cnt), r + (mod - cnt)\n"}, {"source_code": "pow_l = 1\ncnt = 10 ** (pow_l - 1)\ncnt *= 45\ncnt += 1\n\nl = 1\nr = 10 ** pow_l\n\nmod = int(raw_input())\ncnt %= mod\nif (cnt == 0):\n print l, r\nelse:\n print l + (mod - cnt), r + (mod - cnt)"}, {"source_code": "pow_l = 50\ncnt = 10 ** (pow_l - 1)\ncnt *= 45\ncnt += 1\n\nl = 1\nr = 10 ** pow_l\n\nmod = int(raw_input())\ncnt %= mod\nif (cnt == 0):\n print l, r\nelse:\n print l + (mod - cnt), r + (mod - cnt)"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\n\nrem = (19 * 45 * 10**18) % n\nrem = (n-rem) % n\n\nlo = 10**19 - (10**19 - rem)\nhi = lo + 10**19 - 1\n\nprint str(lo) + ' ' + str(hi)\n"}, {"source_code": "import math\n\na = int(input())\n\ngarbage = 13050000000000000000000000000000\n\nleft = (-garbage) % a\n\n\nprint(left, 10 ** 29 - 1 + left)\n\n\n"}, {"source_code": "a = int(input())\nx = 45*19*(10**18)\ny = a - (x%a)\nprint( y , x+y-1 )"}, {"source_code": "a=int(input())\nx=45*18\nfor i in range(17):\n x*=10\nd=x%a\nprint(str(a-d+1)+\" \"+ str(a-d+1000000000000000000))"}, {"source_code": "A = int(input())\nF1019 = (45 * 18 * 10**19) % A\nr = (-F1019) % A\nprint(10**19 + r, r + 1)\n"}, {"source_code": "A = int(input())\nF1019 = (45 * 19 * 10**18) % A\nr = (-F1019) % A\nprint(r + 1, 10**19 + r)\n"}, {"source_code": "A = int(input())\nF1019 = (45 * 18 * 10**19) % A\nr = (-F1019) % A\nprint(r + 1, 10**19 + r)\n"}, {"source_code": "try:\n while True:\n a = int(input())\n x = a - ((10**20)*9) % a\n print(x, 10**19+x-1)\nexcept EOFError:\n pass\n"}, {"source_code": "try:\n while True:\n a = int(input())\n x = a - ((10**19)*9) % a\n print(x, 10**18+x-1)\nexcept EOFError:\n pass"}], "src_uid": "52b8d97f216ea22693bc16fadcd46dae"} {"nl": {"description": "A triangular number is the number of dots in an equilateral triangle uniformly filled with dots. For example, three dots can be arranged in a triangle; thus three is a triangular number. The n-th triangular number is the number of dots in a triangle with n dots on a side. . You can learn more about these numbers from Wikipedia (http://en.wikipedia.org/wiki/Triangular_number).Your task is to find out if a given integer is a triangular number.", "input_spec": "The first line contains the single number n (1\u2009\u2264\u2009n\u2009\u2264\u2009500) \u2014 the given integer.", "output_spec": "If the given integer is a triangular number output YES, otherwise output NO.", "sample_inputs": ["1", "2", "3"], "sample_outputs": ["YES", "NO", "YES"], "notes": null}, "positive_code": [{"source_code": "import math\n\nT = int(input())\n\nD = 1 + 8*T\nsq = math.sqrt(D)\n\nif sq != int(sq) :\n print \"NO\"\nelse :\n n = int(sq) - 1\n if n % 2 == 0:\n print \"YES\"\n else :\n print \"NO\""}, {"source_code": "import sys\nimport math\n\nfile = sys.stdin\nnum = int(file.readline().rstrip())\nif num == 1:\n\tprint \"YES\"\nelse:\n\tsqrt_v = int(math.sqrt(2*num))\n\tif sqrt_v*(sqrt_v + 1)/2 == num or (sqrt_v - 1)/2*sqrt_v == num:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\"\n"}, {"source_code": "def main():\n\tnums = set([x*(x+1)/2 for x in range(50)])\n\tif input() in nums:\n\t\tprint 'YES'\n\telse:\n\t\tprint 'NO'\n\n\n\n\nmain()"}, {"source_code": "import sys\nimport string\n\n\nif __name__ == '__main__':\n\n num1 = map(int,sys.stdin.readline().split())\n\n temp = 0\n for i in range(35):\n\n if num1[0] > temp:\n temp+=i\n\n elif num1[0] == temp:\n print \"YES\"\n break\n else:\n print \"NO\"\n break\n\n\n\n\n"}, {"source_code": "\n\nn = int(raw_input())\n\n\na = False\nfor i in range(500):\n tmp = i*(i-1)/2\n if tmp >= n:\n if tmp == n:\n a = True\n break\n\n\nprint a and 'YES' or 'NO'\n\n"}, {"source_code": "# cook your dish here\nn=int(input())\nflag=0\nfor i in range(1,500):\n T=(i*(i+1))/2\n if T==n:\n \n print(\"YES\")\n flag=1\n break\n \n \nif flag==0:\n print(\"NO\")\n "}, {"source_code": "import sys\nn = input()\n\nfor i in xrange(500):\n if i * (i + 1) / 2 == n:\n print \"YES\"\n sys.exit(0)\nprint \"NO\""}, {"source_code": "n=int(input())\nx=2*n\na=(-1+((1+4*x)**0.5))/2\nb=(-1-((1+4*x)**0.5))/2\nif (a>0 and a==int(a)) or (b>0 and b==int(b)):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = input()\nx = 1+8*n\ny = int(x**0.5)\nif y*y == x:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "t=int(input())\nfor n in range(1,t+1):\n\tif 2*t==n*(n+1):\n\t\tprint('YES')\n\t\tbreak\nelse:\n\tprint('NO')"}, {"source_code": "num=int(input())\nT=list()\nT=[1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]\nif num in T:\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "a = int(input())\nb =0\nn =1\nh =False\nwhile b < a:\n b = (n*(n+1))/2\n n +=1\n if b == a:\n h =True\n\nif h:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x = int(input())\nb = 0\na=0\nwhile b < 50 :\n n = (b*(b+1)//2) \n if ( n == x):\n a = n\n print (\"YES\")\n break\n b = b+1\n \nif ( a == 0 ):\n print (\"NO\") \n\n"}, {"source_code": "hat = int(input())\nlst = []\nfor i in range(0, hat+1):\n x = int((i*(i+1))/2)\n lst.append(x)\n if x >= hat:\n break\nif hat in lst:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=int(input())\nl=[(i*(i+1))//2 for i in range(1,33)]\nif n in l:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n=int(input())\nif(n==1):\n print(\"YES\")\nt=0\nif(n>1):\n for i in range(n):\n t=t+i\n if(t==n):\n print(\"YES\")\n break\n else:\n continue\n else:\n print(\"NO\")"}, {"source_code": "n=int(input())\ni=1\nsum=0\nwhile sum<=n:\n if sum==n:\n print(\"YES\")\n sum=0\n break\n sum+=i\n i+=1\nif sum>0:\n print(\"NO\")"}, {"source_code": "triangular = [n*(n+1)/2 for n in range(1,501)]\nnum = int(input())\nprint(\"YES\" if num in triangular else \"NO\")\n"}, {"source_code": "print('YNEOS'[(1 + 8 * int(input())) ** 0.5 % 1 > 0 :: 2])"}, {"source_code": "\nimport math\n\nn = int(input())\ni = 1\nwhile n > 0:\n n -= i\n i += 1\nprint('YES' if n == 0 else 'NO')\n"}, {"source_code": "x=input()*2;y=int(x**.5);print\"YNEOS\"[x-y!=y*y::2]\n"}, {"source_code": "a = int(input())\nk = 0\nfor i in range(1, 501):\n if(i*(i+1)==2*a):\n print(\"YES\")\n k = 1\n break\nif(k==0):\n print(\"NO\")\n"}, {"source_code": "n = int(input())\nf = 0\nfor i in range(500):\n if n == i*(i+1)/2:\n f = 1\n break\nif f:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(raw_input())\ni = 1\nt = 0\nflag = False\nwhile True:\n t = i * (i + 1) / 2\n if t == n:\n flag = True\n break\n if t > 500:\n break\n i += 1\nif flag:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "x = int(input())\nfor i in range (x+1):\n if (i*(i+1))/2 == x :\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "n=input()\nif n==1:\n print \"YES\"\nelse:\n for j in range(n):\n if j*(j+1)/2==n:\n print \"YES\"\n break\n else:\n print \"NO\"\n"}, {"source_code": "n=int(input())\ni=1\nt=1\nwhile(tn):\n print(\"NO\")\n exit()\n"}, {"source_code": "x = int (input())\nfor i in range(1,x+1):\n if x ==i*(i+1)//2 :\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "def ni():\n return int(raw_input())\n\ndef seq_sum(n):\n return n * (n + 1) / 2\n\nt = ni()\n\nn = int(((8 * t + 1)**0.5 - 1) / 2)\n\nprint 'YES' if seq_sum(n) == t else 'NO'"}, {"source_code": "a = int(input())\nyes = 0\nfor i in range(50):\n if (i * (i + 1)) // 2 == a:\n yes = 1\n break\nprint('YES' if yes == 1 else 'NO')"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nprint('YES' if readln()[0] in [n * (n + 1) // 2 for n in range(1, 50)] else 'NO')\n"}, {"source_code": "tri = []\n\nfor i in range(1, 500):\n tri.append((i * (i + 1)) // 2)\n\nn = int(input())\n\nprint('NO' if n not in tri else 'YES')"}, {"source_code": "n = int(input())\nflag = 0\nfor i in range(1, n + 1):\n if (i * (i + 1)) // 2 == n:\n flag = 1\n print(\"YES\")\n break\nif flag == 0:\n print(\"NO\")"}, {"source_code": "# -*- coding:utf-8 -*-\nimport math\nn = int(raw_input().strip())\nac4=math.sqrt((1+(8*n)))\na=(-1.0+ac4)/2\nb=(-1.0-ac4)/2\nif b>a:\n\ta=b\nif a%1.0==0:\n\tprint\"YES\"\nelse:\n\tprint\"NO\""}, {"source_code": "n = input()\n\nfor i in xrange(500):\n if i * (i + 1) / 2 == n:\n print \"YES\"\n exit()\nprint \"NO\""}, {"source_code": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\nimport sys\ninput = sys.stdin\noutput = sys.stdout\n\nfrom math import sqrt\n\ndef is_triangle_number(x):\n D = 1+8*x\n d = int(sqrt(D))\n return d*d == D and (1+d) % 2 == 0\n\ndef solve(n):\n if is_triangle_number(n):\n return 'YES'\n else:\n return 'NO'\n\nn = int(input.readline())\nassert 1<=n and n<=500 \n\na = solve(n)\noutput.write('%s\\n' % a)\n"}, {"source_code": "n=int(input())\ns=0\nc=0\ni=1\nwhile(c= n:\n if tmp == n:\n a = True\n break\n\n\nprint a and 'YES' or 'NO'\n\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nfrom sys import stdin\n\nfor t in map(int, stdin):\n D = 1 + 8*t\n x = int((-1 + D**0.5) / 2)\n triangular = t == x*(x+1) // 2\n print 'YES' if triangular else 'NO'\n"}, {"source_code": "n=int(raw_input())\nok=False\nfor i in range(1,500):\n if (i*(i+1))/2==n:\n ok=True\nif ok:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "import math\nn = int(raw_input())\nif math.sqrt(8*n+1) % 1 != 0:\n print 'NO'\nelse:\n print 'YES'\n"}, {"source_code": "# cook your dish here\nn=int(input())\nflag=0\nfor i in range(1,500):\n T=(i*(i+1))/2\n if T==n:\n \n print(\"YES\")\n flag=1\n break\n \n \nif flag==0:\n print(\"NO\")\n "}, {"source_code": "# submit\nt = int(raw_input())\na = [n * (n + 1) / 2 for n in range(1, 501)]\nprint \"YES\" if t in a else \"NO\"\n"}, {"source_code": "n = int(raw_input())\nfor x in xrange(1, 501):\n if x*(x+1)/2 == n:\n print \"YES\"\n exit(0)\nprint \"NO\""}, {"source_code": "n = int(input())\nflag = 0\nfor i in range(1, n + 1):\n if i * (i + 1) / 2 == n:\n flag = 1\n break\n\nif (flag == 1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "a = int(input())\ntest=[]\ni=1\nt_n=0\nwhile t_n<=a:\n t_n= i*(i+1)//2\n test.append(t_n)\n i=i+1\n\nif int(a) in test:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "print\"YES\"if input()*2in[x*x+x for x in range(501)]else\"NO\""}, {"source_code": "n = int(input())\nf =1\nif n==1:print(\"YES\")\nelse:\n\n\tfor i in range(n):\n\t\tif i*(i+1) == 2*n:\n\t\t\tf =0\n\t\t\tbreak\n\tif f ==0:print(\"YES\")\n\telse:print(\"NO\")"}, {"source_code": "import 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\n\ndef iseven(n):return[False,True][0 if n%2 else 1]\ndef inp_arr():return list(map(int,input().split()))\ndef inp():return map(int,input().split())\ndef lcm(a,b):return (a*b)/gcd(a,b)\nmax_int = sys.maxsize\nmod = 10**9+7\n\nan=[n*(n+1)/2 for n in range(1,501)]\nn=int(input())\nprint('YES' if n in an else 'NO')"}, {"source_code": "n= int(input()); p=0\nfor i in range(n+1):\n if i*(i+1)//2==n:\n p=1\n break\nif p==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "n=input()\n\n\nans=\"NO\"\n\nfor i in range(1,500):\n\tif (i*i)+i==2*n:\n\t\tans=\"YES\"\nprint ans"}, {"source_code": "import math\nn = (8*int(input(\"\"))+1)**0.5\nif math.floor(n) == math.ceil(n):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x=input()*2;y=int(x**.5);print\"YNEOS\"[x-y!=y*y::2]\n"}, {"source_code": "a = int(input())\nyes = 0\nfor i in range(50):\n if (i * (i + 1)) // 2 == a:\n yes = 1\n break\nprint('YES' if yes == 1 else 'NO')"}, {"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\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\ndef out(var): sys.stdout.write(str(var)) # for fast output, always take string\n\ndef lis(): return list(map(int, inp().split()))\n\ndef stringlis(): return list(map(str, inp().split()))\n\ndef sep(): return map(int, inp().split())\n\ndef strsep(): return map(str, inp().split())\n\n\ndef zerolist(n): return [0] * n\n\ndef nextline(): out(\"\\n\") # as stdout.write always print sring.\n\ndef testcase(t):\n for p in range(t):\n solve()\n\ndef printlist(a):\n for p in range(0, len(a)):\n out(str(a[p]) + ' ')\n\ndef solve():\n ar=[1]\n for i in range(2,505):\n ar.append(ar[-1]+i)\n n=int(inp())\n if n in ar:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\nsolve()\n\n\n"}, {"source_code": "from math import sqrt\nif(sqrt(int(input()) * 8 + 1).is_integer()):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nn=input()\nfor i in range(1,500):\n if (i*(i+1))/2>n:\n break\n elif (i*(i+1))/2==n:\n print 'YES'\n sys.exit()\nprint 'NO'"}, {"source_code": "n = int(input())\nS = set()\nfor i in range(1, 100):\n s = i*(i+1)//2\n S.add(s)\nif n in S:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "\n\n\ntri = []\n\ni = 0\nwhile ( i*(i+1)/2 ) <= 500: \n\ttri.append( i*(i+1)/2 ) \n\ti += 1\n\n\n\nn = input()\n\nif n in tri:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\n\n"}, {"source_code": "l=list()\nfor i in range(1,33):\n l.append(int((i*(i+1))/2))\nn=int(input())\nif n in l:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "number = [0] * 32\nn = int(input())\ni = 1\nfor i in range(0, 32):\n number[i] = (i * (i + 1)) // 2\n\nmid = 16\nleft = 0\nright = 31\n\nwhile number[mid] != n and left <= right:\n if n > number[mid]:\n left = mid + 1\n else:\n right = mid - 1\n mid = (left + right) // 2\n\nif left > right:\n print('NO')\nelse:\n print('YES')\n"}, {"source_code": "n = int(input())\nif n==1:\n\tprint(\"YES\")\nelse:\t\n\tflag = 0\n\tfor i in range(1,n):\n\t\tif i*(i+1)//2==n:\n\t\t\tprint(\"YES\")\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag==0:\n\t\tprint(\"NO\")\n"}, {"source_code": "tri=[0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666]\n\nx=int(input())\n\nif x in tri:\n print('YES')\nelse:\n print(\"NO\")"}, {"source_code": "n = int(input())\nans = 0\nfor i in range(35):\n num = i * (i+1) // 2\n if num == n:\n ans = 1\n break\nprint(\"YES\" * ans + \"NO\" * ( 1 - ans))\n \n"}, {"source_code": "print('YNEOS'[(1 + 8 * int(input())) ** 0.5 % 1 > 0 :: 2])"}, {"source_code": "triangulars = [(n*(n+1))/2 for n in xrange(50)]\n\nif int(raw_input()) in triangulars:\n print \"YES\"\n\nelse:\n print \"NO\"\n"}, {"source_code": "number = int(input())\nlist = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630]\nif number in list:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "x = int (input())\nfor i in range(1,x+1):\n if x ==i*(i+1)//2 :\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "n=int(input())\nl=[(i*(i+1))//2 for i in range(1,33)]\nif n in l:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "n=int(input())\nif (((1+8*n)**0.5)-1)%2==0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "# Author: SaykaT\n# Problem: 47A\n# Time Created: July 21(Tuesday) 2020 || 04:24:31\n\n#>-------------------------<#\nfrom math import sqrt\n\n\n# Helper Functions. -> Don't cluster your code.\n\n# IO Functions. -> Input output\ndef io():\n n = int(input())\n return n\n\n# Main functions. -> Write the main solution here\ndef solve():\n n = io()\n a = float(1)\n b = float(1)\n c = -float(n * 2)\n\n d = (b ** 2) - (4 * a * c)\n sol1 = (-b + sqrt(d)) / (2 * a)\n sol2 = (-b - sqrt(d)) / (2 * a)\n if n == 1:\n print('YES')\n elif sol1 > 1:\n if float(int(sol1)**2) == ((sol1 ** 2)):\n print('YES')\n else:\n print('NO')\n elif sol2 > 1:\n if sol2 == ((sol2 ** 2) ** 0.5):\n print('YES')\n else:\n print('NO')\n else:\n print('NO')\n\n# Multiple test cases. -> When you have T test cases.\nsolve()\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\nn=I()\n\nn2=(-1+math.sqrt(1+8*n))/2\n\nprint(['NO','YES'][n2==int(n2)])\n\n\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nfrom sys import stdin\n\nfor t in map(int, stdin):\n D = 1 + 8*t\n x = int((-1 + D**0.5) / 2)\n triangular = t == x*(x+1) // 2\n print 'YES' if triangular else 'NO'\n"}, {"source_code": "n = int(input())\ni = 1\np = int(i*(i+1)/2)\nwhile(p<=n):\n if p == n:\n print('YES')\n exit()\n else:\n i += 1\n p = int(i*(i+1)/2)\nprint('NO')\n"}, {"source_code": "print \"YES\" if input() in [x*(x+1)/2 for x in range(501)] else \"NO\""}, {"source_code": "n = input()\nif int((8*n+1)**0.5)**2 == 8*n+1:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "num = int(input())\nfor i in range(500):\n if (i*(i+1)/2) == num:\n print(\"YES\")\n quit()\nprint(\"NO\")"}, {"source_code": "from math import sqrt\nn = int(input())\nx = 0.5*(sqrt(8*n + 1) -1)\nif x==int(x):\n print(\"YES\")\nelse : print(\"NO\")"}, {"source_code": "n = int(input())\nif n==1:\n\tprint(\"YES\")\nelse:\t\n\tflag = 0\n\tfor i in range(1,n):\n\t\tif i*(i+1)//2==n:\n\t\t\tprint(\"YES\")\n\t\t\tflag = 1\n\t\t\tbreak\n\tif flag==0:\n\t\tprint(\"NO\")\n"}, {"source_code": "t = [(n*(n+1))/2 for n in range(0,33)]\nprint \"YES\" if int(raw_input()) in t else \"NO\"\n"}, {"source_code": "a=int(input())\nn=1\nwhile a>0:\n a-=n\n n+=1\nif a==0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\nNumber=int(input())\nTemp=math.sqrt(Number*8+1)\nif Temp==int(Temp):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "def isTriangular(num):\n if (num < 0):\n return False\n\n sum, n = 0, 1\n\n while (sum <= num):\n\n sum = sum + n\n if (sum == num):\n return True\n n += 1\n\n return False\n\n\nn = int(input())\nif (isTriangular(n)):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "x=input()*2;y=int(x**.5);print\"YNEOS\"[x-y!=y*y::2]\n"}, {"source_code": "n=int(input())\t\nf=0\nfor i in range(1,n+1):\n\tif (i*(i+1))//2==n:\n\t\tf=1\n\t\tbreak\nif f==1:\n\tprint(\"YES\")\t\nelse:\n\tprint(\"NO\")\t"}, {"source_code": "n = int(raw_input())\ni = 1\nt = 0\nflag = False\nwhile True:\n t = i * (i + 1) / 2\n if t == n:\n flag = True\n break\n if t > 500:\n break\n i += 1\nif flag:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import math\na=int(input())\nb=int(math.sqrt(1+(8*a)))\nif b*b!=(1+(8*a)):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "print \"YES\" if input()*2 in [x*x+x for x in range(501)] else \"NO\""}, {"source_code": "data=[1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528]\nif input() in data:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "l = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]\n\nn = int(input())\n\nif n in l:\n print(\"YES\")\nelse:\n print(\"NO\")\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 = int(input())\nfor i in range(1, 100):\n if n == i * (i + 1) // 2:\n print('YES')\n exit()\nprint('NO')\n"}, {"source_code": "import math\nNumber=int(input())\nTemp=math.sqrt(Number*8+1)\nif Temp==int(Temp):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "s = set()\nfor i in range(31):\n s.add(int((i+1) *(i+2)/2))\n\nn = int(input())\nprint('YES' if n in s else 'NO')"}, {"source_code": "n=int(input())\nm=2*n\nfor i in range (2*n):\n\tif i*(i+1)==m:\n\t\tprint(\"YES\")\n\t\tbreak\nelse :\n\tprint(\"NO\")"}, {"source_code": "T=[]\nfor i in range(35):\n\ta=i*(i+1)/2\n\tT.append(a)\nn=int(raw_input())\nif n in T:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "print \"YES\" if input()*2 in [x*x+x for x in range(501)] else \"NO\""}, {"source_code": "a=[1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950, 5050, 5151, 5253, 5356, 5460, 5565, 5671, 5778, 5886, 5995, 6105, 6216, 6328, 6441, 6555, 6670, 6786, 6903, 7021, 7140, 7260, 7381, 7503, 7626, 7750, 7875, 8001, 8128, 8256, 8385, 8515, 8646, 8778, 8911, 9045, 9180, 9316, 9453, 9591, 9730, 9870, 10011, 10153, 10296, 10440, 10585, 10731, 10878, 11026, 11175, 11325, 11476, 11628, 11781, 11935, 12090, 12246, 12403, 12561, 12720, 12880, 13041, 13203, 13366, 13530, 13695, 13861, 14028, 14196, 14365, 14535, 14706, 14878, 15051, 15225, 15400, 15576, 15753, 15931, 16110, 16290, 16471, 16653, 16836, 17020, 17205, 17391, 17578, 17766, 17955, 18145, 18336, 18528, 18721, 18915, 19110, 19306, 19503, 19701, 19900, 20100, 20301, 20503, 20706, 20910, 21115, 21321, 21528, 21736, 21945, 22155, 22366, 22578, 22791, 23005, 23220, 23436, 23653, 23871, 24090, 24310, 24531, 24753, 24976, 25200, 25425, 25651, 25878, 26106, 26335, 26565, 26796, 27028, 27261, 27495, 27730, 27966, 28203, 28441, 28680, 28920, 29161, 29403, 29646, 29890, 30135, 30381, 30628, 30876, 31125, 31375, 31626, 31878, 32131, 32385, 32640, 32896, 33153, 33411, 33670, 33930, 34191, 34453, 34716, 34980, 35245, 35511, 35778, 36046, 36315, 36585, 36856, 37128, 37401, 37675, 37950, 38226, 38503, 38781, 39060, 39340, 39621, 39903, 40186, 40470, 40755, 41041, 41328, 41616, 41905, 42195, 42486, 42778, 43071, 43365, 43660, 43956, 44253, 44551, 44850, 45150, 45451, 45753, 46056, 46360, 46665, 46971, 47278, 47586, 47895, 48205, 48516, 48828, 49141, 49455, 49770, 50086, 50403, 50721, 51040, 51360, 51681, 52003, 52326, 52650, 52975, 53301, 53628, 53956, 54285, 54615, 54946, 55278, 55611, 55945, 56280, 56616, 56953, 57291, 57630, 57970, 58311, 58653, 58996, 59340, 59685, 60031, 60378, 60726, 61075, 61425, 61776, 62128, 62481, 62835, 63190, 63546, 63903, 64261, 64620, 64980, 65341, 65703, 66066, 66430, 66795, 67161, 67528, 67896, 68265, 68635, 69006, 69378, 69751, 70125, 70500, 70876, 71253, 71631, 72010, 72390, 72771, 73153, 73536, 73920, 74305, 74691, 75078, 75466, 75855, 76245, 76636, 77028, 77421, 77815, 78210, 78606, 79003, 79401, 79800, 80200, 80601, 81003, 81406, 81810, 82215, 82621, 83028, 83436, 83845, 84255, 84666, 85078, 85491, 85905, 86320, 86736, 87153, 87571, 87990, 88410, 88831, 89253, 89676, 90100, 90525, 90951, 91378, 91806, 92235, 92665, 93096, 93528, 93961, 94395, 94830, 95266, 95703, 96141, 96580, 97020, 97461, 97903, 98346, 98790, 99235, 99681, 100128, 100576, 101025, 101475, 101926, 102378, 102831, 103285, 103740, 104196, 104653, 105111, 105570, 106030, 106491, 106953, 107416, 107880, 108345, 108811, 109278, 109746, 110215, 110685, 111156, 111628, 112101, 112575, 113050, 113526, 114003, 114481, 114960, 115440, 115921, 116403, 116886, 117370, 117855, 118341, 118828, 119316, 119805, 120295, 120786, 121278, 121771, 122265, 122760, 123256, 123753, 124251, 124750]\nb=int(raw_input())\nfor i in a:\n if i==b:\n print \"YES\"\n break\nif i==a[a.__len__()-1]:\n print \"NO\""}], "negative_code": [{"source_code": "n=int(input())\t\nf=0\nfor i in range(1,n):\n\tif (i*(i+1))//2==n:\n\t\tf=1\n\t\tbreak\nif f==1:\n\tprint(\"YES\")\t\nelse:\n\tprint(\"NO\")\t"}, {"source_code": "T=input(\"\")\nt=int(T)\na=0\ni=0\nwhile(a 500 :\n print \"NO\"\n break\n elif num1 == temp :\n print \"YES\"\n break\n elif num1 < temp:\n print \"NO\"\n break\n else :\n temp +=i\n\n\n"}, {"source_code": "# 47A\nn = input()\nfor x in xrange(2, n):\n if (x * (x + 1)) / 2 == n:\n print 'YES'\n exit\nprint 'NO'"}, {"source_code": "def isTri(num): \n \n \n if (num < 0): \n return False\n \n \n sum, n = 0, 1\n \n while(sum <= num): \n \n sum = sum + n \n if (sum == num): \n return True\n n += 1\n \n return False\n \n \nn = int(input(\"Enter number \"))\nif (isTri(n)): \n print(\"YES\") \nelse: \n print(\"NO\") \n \n"}, {"source_code": "n = int(input())\nif n == 1 or n == 10:\n print('YES')\nelif n == 12 or n == 9:\n print('NO')\nelif n % 3 == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n=int(input())\n# n(n+1)/2=tn\nfor i in range(n+1):\n\tif i*(i+1)//2==n:\n\t\tprint(\"YES\")\n\t\tbreak\nprint(\"NO\")"}, {"source_code": "n=int(input())\nif(n==1 or n%3==0):\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "from sys import stdin\n\nt = int(stdin.readline())\nrv = \"NO\"\nfor n in range(30):\n if n*(n+1)/2 == t:\n rv = \"YES\"\n break\n \nprint rv"}, {"source_code": "def Tri(x):\n\tL = [];\n\tfor i in range(1,35):\n\t\tL.extend([(i**2 + i)/2]);\n\tif x in L:\n\t\tprint \"NO\";\n\telse:\n\t\tprint \"YES\";\n\nx = input();\n\nTri(x);"}, {"source_code": "n = int(input())\nf =1\nif n==1:print(\"YES\")\nelse:\n\n\tfor i in range(int(n/2)):\n\t\tif i*(i+1) == 2*n:\n\t\t\tf =0\n\tif f ==0:print(\"YES\")\n\telse:print(\"NO\")"}, {"source_code": "# Author: SaykaT\n# Problem: 47A\n# Time Created: July 21(Tuesday) 2020 || 04:24:31\n\n#>-------------------------<#\nfrom math import sqrt\n\n\n# Helper Functions. -> Don't cluster your code.\n\n# IO Functions. -> Input output\ndef io():\n n = int(input())\n return n\n\n# Main functions. -> Write the main solution here\ndef solve():\n n = io()\n a = float(1)\n b = float(1)\n c = -float(n * 2)\n\n d = (b ** 2) - (4 * a * c)\n sol1 = (-b + sqrt(d)) / (2 * a)\n sol2 = (-b - sqrt(d)) / (2 * a)\n if n == 1:\n print('Yes')\n elif sol1 > 1:\n if float(int(sol1)**2) == ((sol1 ** 2)):\n print('Yes')\n else:\n print('No')\n elif sol2 > 1:\n if sol2 == ((sol2 ** 2) ** 0.5):\n print('Yes')\n else:\n print('No')\n else:\n print('No')\n\n# Multiple test cases. -> When you have T test cases.\nsolve()\n \n"}, {"source_code": "print(\"YES\" if (int(input()))%2 != 0 else\"NO\")"}, {"source_code": "\"\"\"\nthis code is made for codeforces\n\"\"\"\nnum1 = int(input())\na=0\nflag1 = 1\nwhile flag1 < num1:\n if (flag1*(flag1+1))/2 == num1:\n print(\"YES\")\n a=1\n flag1 += 1\nif a == 0:\n print(\"NO\")\n"}, {"source_code": "def isTriangular(num): \n \n \n if (num < 0): \n return False\n \n sum, n = 0, 1\n \n while(sum <= num): \n \n sum = sum + n \n if (sum == num): \n return True\n n += 1\n \n return False\n\nn =int(input())\nif (isTriangular(n)): \n print(\"The number is a triangular number\") \nelse: \n print(\"The number is NOT a triangular number\") "}, {"source_code": "n = int(input())\nfor i in range(1, n):\n if (i * (i+1))//2 == n:\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "from math import sqrt\nn = int(input())\nx = 8*n + 1 \nif type(sqrt(x))==int:\n print\"YES\"\nelse : print \"NO\""}, {"source_code": "n=int(input())\nif n%2!=0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "triangular_number = int(input(\"\"))\n\ni=1\nupperChars=0\n\nwhile i<=triangular_number:\n triangular_number -=i\n print(triangular_number)\n i+=1\n\nif (triangular_number==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n"}, {"source_code": "inp = int(input())\nsum=0\nif inp>0:\n string = \"YES\"\n for i in range(1,inp+1):\n sum = sum+i\n if(sum==inp):\n break\n else:\n string = \"NO\"\n print(string)\nelse:\n print(\"NO\")\n\n \n"}, {"source_code": "# 47A\nn = input()\nfor x in xrange(2, n):\n if (x * (x + 1)) / 2 == n:\n print 'YES'\n exit\nprint 'NO'"}, {"source_code": "print(\"YES\" if int(input())%2!=0 else \"NO\")\n"}, {"source_code": "def isTriangular(num):\n \n if (num < 0):\n return False\n sum, n = 0, 1\n\n while(sum <= num):\n\n sum = sum + n\n if (sum == num):\n return True\n n += 1\n\n return False\n\nn = int(input())\nif (isTriangular(n)):\n print(\"YES\")\nelse:\n print(\"No\") "}, {"source_code": "n = int(input())\nfor i in range(1, n):\n if (i * (i+1))//2 == n:\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "n = int(input())\nif n%2 == 0:\n print('NO')\n exit(0)\nprint('YES')"}, {"source_code": "n = int(input())\nif n == 1 or n == 10:\n print('YES')\nelif n == 12 or n == 9:\n print('NO')\nelif n % 3 == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "a=int(input())\nif a*3%2==0:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\t\n"}, {"source_code": "#------------------------template--------------------------#\nimport os\nimport sys\nfrom math import *\nfrom collections import *\n# from fractions import *\n# from 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 Ceil(a,b): return a//b+int(a%b>0)\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 \n\n\nn=Int()\nif(n%3<=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"}, {"source_code": "num=input()\nT=[1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]\nif(num in T):\n print(\"YES\")\nelse:\n print(\"NO\") "}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nN=int(input())\nans=0\nx=1\nFLAG=0\nwhile ans=1 and w<=500:\n if w==1:\n print(\"YES\")\n elif w%3==0:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "from math import *\nk=int(input())\nkk=sqrt(1+8*k)\na1=(-1+kk)/2\na2=(-1-kk)/2\nb1=int(a1)\nb2=int(a2)\nif (a1==b1 or a2==b2) and (a1>0 or a2>0):\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "#! /usr/bin/python\n\n__author__=\"Guillermo Candia Huerta\"\n__date__ =\"$07-12-2010 01:05:53 PM$\"\n\ndef resolver(e):\n r = 0\n menos = 1\n while e > 0:\n e = e - menos\n menos = menos + 2\n if e == 0:\n return \"YES\"\n else:\n return \"NO\"\n\n# return r\n\nif __name__ == \"__main__\":\n e = int(raw_input())\n r = resolver(e)\n print str(r)\n"}, {"source_code": "n=int(input())\ni=0\nj=0\nwhile n>j:\n\tj=(i*(i+1))/2\n\ti+=1\nprint('YES' if i==j else 'NO')"}, {"source_code": "n=input()\nfor j in range(n):\n if j*(j+1)/2==n:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "# 47A\nn = input()\nfor x in xrange(n + 1):\n if (x * (x + 1)) / 2 == n:\n print 'YES'\n exit\nprint 'NO'"}, {"source_code": "import sys\n\nn=int(input())\nx=8*n+1\nfor i in range(50):\n if(i*i==x):\n print(\"YES\")\n sys.exit()\nprint(\"NO\")"}, {"source_code": "n=int(input())\nk=0\nfor i in range(1,n):\n if (i*(i+1))%2==0:\n if (i*(i+1))//2>n:\n k=1\n print(\"NO\")\n break\n elif (i*(i+1))//2==n:\n k=1\n \n print(\"YES\")\n break\nif k==0:\n print(\"NO\")\n "}, {"source_code": "x = int (input())\nfor i in range(1,x+1):\n if x ==i*(i+1)//2 :\n print(\"yes\")\n exit()\nprint(\"no\")"}, {"source_code": "x=input()*2;y=int(x**.5);print\"YNEOS\"[x-y==y**2::2]"}, {"source_code": "def isTri(num): \n \n \n if (num < 0): \n return False\n if (num == 0):\n return True\n \n \n sum, n = 0, 1\n \n while(sum <= num): \n \n sum = sum + n \n if (sum == num): \n return True\n n += 1\n \n return False\n \n \nn = int(input(\"Enter number: \"))\nif (isTri(n)): \n print(\"YES\") \nelse: \n print(\"NO\") \n \n"}, {"source_code": "n = int(input())\nfor i in range(1, n):\n if (i * (i+1))//2 == n:\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "a=int(input())\nif a*3%2==0:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n\t\n"}, {"source_code": "n=int(input())\nx=n\nflag=0\nif n%3!=0:\n n=1+n//3\n z=(n*(n+1))//2\nelse:\n n=n//3\n z=(n*(n+1))//2\n\nif z==x or x==3:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "from math import *\nn=int(raw_input())\nif 1<=n<=500:\n x=str((sqrt((8*n)+1)-1)/2)\n place=x.find('.')\n if x[place:]=='0' :\n print 'YES'\n else:\n print 'NO'"}, {"source_code": "import math\nlist1 = [math.factorial(i) for i in range(500)]\nprint('YES' if int(input()) in list1 else 'NO')"}, {"source_code": "# Author: SaykaT\n# Problem: 47A\n# Time Created: July 21(Tuesday) 2020 || 04:24:31\n\n#>-------------------------<#\nfrom math import sqrt\n\n\n# Helper Functions. -> Don't cluster your code.\n\n# IO Functions. -> Input output\ndef io():\n n = int(input())\n return n\n\n# Main functions. -> Write the main solution here\ndef solve():\n n = io()\n a = float(1)\n b = float(1)\n c = -float(n * 2)\n\n d = (b ** 2) - (4 * a * c)\n sol1 = (-b + sqrt(d)) / (2 * a)\n sol2 = (-b - sqrt(d)) / (2 * a)\n if n == 1:\n print('Yes')\n elif sol1 > 1:\n if float(int(sol1)**2) == ((sol1 ** 2)):\n print('Yes')\n else:\n print('NO')\n elif sol2 > 1:\n if sol2 == ((sol2 ** 2) ** 0.5):\n print('Yes')\n else:\n print('NO')\n else:\n print('NO')\n\n# Multiple test cases. -> When you have T test cases.\nsolve()\n \n"}, {"source_code": "n=int(input())\nif n==1 or n%3==0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "x = int(input())\nCheck = False\nfor i in range (x+1):\n if (i*(i+1))/2 == x :\n Check = True\nprint(\"Yes\" if Check == True else \"NO\")"}, {"source_code": "import math\nn=int(input())\n\na=(-1+math.sqrt(1+4*n))/2\nb=(-1-math.sqrt(1+4*n))/2\nif(a.is_integer()):\n print(\"NO\")\nelif(b.is_integer()):\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "x = int (input())\nfor i in range(1,x+1):\n if x ==i*(i+1)//2 :\n print(\"yes\")\n exit()\nprint(\"no\")"}, {"source_code": "def isTriangular(num):\n \n if (num < 0):\n return False\n sum, n = 0, 1\n\n while(sum <= num):\n\n sum = sum + n\n if (sum == num):\n return True\n n += 1\n\n return False\n\nn = int(input())\nif (isTriangular(n)):\n print(\"YES\")\nelse:\n print(\"No\") "}, {"source_code": "n=int(input())\nif n==1 or n==3:\n print(\"YES\")\nelse:\n for i in range(int(n/2)):\n if (i*(i+1))//2 ==n:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "from math import *\nn=int(raw_input())\nx=str((sqrt((8*n)+1)-1)/2)\nif x[2:]=='0':\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "from math import*\nn=int(input())\n\ni=1\nwhile i<=sqrt(n)+5:\n if(i*(i+1)==2*n):\n print(\"YES\")\n exit()\n i+=1\n\nprint(\"NO\")\n\n"}, {"source_code": "print\"YES\"if input()in[x*x+x for x in range(501)]else\"NO\""}, {"source_code": "n = int(input())\nfor i in range(1, n):\n if (i * (i+1))//2 == n:\n print(\"YES\")\n exit(0)\nprint(\"NO\")"}, {"source_code": "from math import sqrt\nn = int(input())\nx = 8*n + 1 \nif type(sqrt(x))!=int:\n print(\"YES\")\nelse : print(\"NO\")"}, {"source_code": "n = int(input())\nif n % 2 == 0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "print(\"YES\" if int(input())%2!=0 else \"NO\")\n"}, {"source_code": "import math\n\n\nclass CodeforcesTask47ASolution:\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 x = (-1 + math.sqrt(1+4*self.n)) / 2\n if x.is_integer():\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 = CodeforcesTask47ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "x = int(raw_input('masukan data : '))\narr = []\nfor a in range(1,50):\n\tarr.append(a*(a + 1)/2)\nhash = set(arr);\n\nif x in hash:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "T=input(\"\")\nt=int(T)\na=0\ni=0\nwhile(an:\n k=1\n print(\"NO\")\n break\n elif (i*(i+1))//2==n:\n k=1\n \n print(\"YES\")\n break\nif k==0:\n print(\"NO\")\n "}, {"source_code": "n = int(input())\nflag = 0\nfor i in range(1, n):\n if (i * (i + 1)) // 2 == n:\n flag = 1\n print(\"YES\")\n break\nif flag == 0:\n print(\"NO\")"}, {"source_code": "w=int(input())\nif w>=1 and w<=500:\n if w==1:\n print(\"YES\")\n elif w%3==0:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "# 47A\nn = input()\nfor x in xrange(n):\n if (x * (x + 1)) / 2 == n:\n print 'YES'\n exit\nprint 'NO'"}, {"source_code": "x = int (input())\nfor i in range(1,x+1):\n if x ==i*(i+1)//2 :\n print(\"yes\")\n exit()\nprint(\"no\") "}, {"source_code": "n=int(input())\ns=1\na=1\nfor i in range(n):\n a+=1\n s+=a\n if s==n:\n print(\"YES\")\n if s>n:\n break\nelse:\n print(-1)\n"}, {"source_code": "import sys\n\nn=int(input())\nx=8*n+1\nfor i in range(50):\n if(i*i==x):\n print(\"YES\")\n sys.exit()\nprint(\"NO\")"}, {"source_code": "n = int (input())\nfor i in range(1,n+1):\n if n ==i*(i+1)//2 :\n print(\"yes\")\n exit()\nprint(\"no\")"}, {"source_code": "n = int(input())\nS = set()\nfor i in range(1, 30):\n s = i*(i+1)//2\n S.add(s)\nif n in S:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n = int(input())\nif n%2 == 0:\n print('NO')\n exit(0)\nprint('YES')"}, {"source_code": "print(\"YES\" if int(input())%2!=0 else \"NO\")\n"}, {"source_code": "n=int(input())\nif(n==1):\n print(\"YES\")\nt=0\n\nfor i in range(n):\n t=t+i\n if(t==n):\n print(\"YES\")\n break\n else:\n continue\nelse:\n print(\"NO\")"}, {"source_code": "from math import *\nn=int(raw_input())\nx=str((sqrt((8*n)+1)-1)/2)\nif x[2:]=='0':\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "# Author: SaykaT\n# Problem: 47A\n# Time Created: July 21(Tuesday) 2020 || 04:24:31\n\n#>-------------------------<#\nfrom math import sqrt\n\n\n# Helper Functions. -> Don't cluster your code.\n\n# IO Functions. -> Input output\ndef io():\n n = int(input())\n return n\n\n# Main functions. -> Write the main solution here\ndef solve():\n n = io()\n a = float(1)\n b = float(1)\n c = -float(n * 2)\n\n d = (b ** 2) - (4 * a * c)\n sol1 = (-b + sqrt(d)) / (2 * a)\n sol2 = (-b - sqrt(d)) / (2 * a)\n if n == 1:\n print('Yes')\n elif sol1 > 1:\n if float(int(sol1)**2) == ((sol1 ** 2)):\n print('Yes')\n else:\n print('NO')\n elif sol2 > 1:\n if sol2 == ((sol2 ** 2) ** 0.5):\n print('Yes')\n else:\n print('NO')\n else:\n print('NO')\n\n# Multiple test cases. -> When you have T test cases.\nsolve()\n \n"}, {"source_code": "\nn=int(input())\nsol=\"NO\"\n# n(n+1)/2=tn\nfor i in range(n+1):\n\tif i*(i+1)//2==n:\n\t\ta=(\"YES\")\n\t\tbreak\nprint(sol)"}, {"source_code": "x = set()\nfor i in range(1,501):\n x.add(i * (i+1)/2)\n\nn = int(input())\nif i in x:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "n = int(input())\nif n == 1 or n == 10:\n print('YES')\nelif n == 12:\n print('NO')\nelif n % 3 == 0:\n print('YES')\nelse:\n print('NO')"}, {"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$\"\nimport math\nif __name__ == \"__main__\":\n x = int(raw_input())\n x1=x\n r = 2\n if x!=0:\n for i in range(2,1+int(math.sqrt(x1))):\n while x%i == 0:\n x = x/i\n r = r*i\n \n if x == r-1 or x == r+1:\n print 'YES'\n else:\n print 'NO'\n else:\n print 'NO'\n"}, {"source_code": "\nimport math\n\nn = int(input())\ni = 1\nwhile n > 1:\n n -= i\n i += 1\nprint('YES' if n == 0 else 'NO')\n"}], "src_uid": "587d4775dbd6a41fc9e4b81f71da7301"} {"nl": {"description": "Anton and Dasha like to play different games during breaks on checkered paper. By the 11th grade they managed to play all the games of this type and asked Vova the programmer to come up with a new game. Vova suggested to them to play a game under the code name \"dot\" with the following rules: On the checkered paper a coordinate system is drawn. A dot is initially put in the position (x,\u2009y). A move is shifting a dot to one of the pre-selected vectors. Also each player can once per game symmetrically reflect a dot relatively to the line y\u2009=\u2009x. Anton and Dasha take turns. Anton goes first. The player after whose move the distance from the dot to the coordinates' origin exceeds d, loses. Help them to determine the winner.", "input_spec": "The first line of the input file contains 4 integers x, y, n, d (\u2009-\u2009200\u2009\u2264\u2009x,\u2009y\u2009\u2264\u2009200,\u20091\u2009\u2264\u2009d\u2009\u2264\u2009200,\u20091\u2009\u2264\u2009n\u2009\u2264\u200920) \u2014 the initial coordinates of the dot, the distance d and the number of vectors. It is guaranteed that the initial dot is at the distance less than d from the origin of the coordinates. The following n lines each contain two non-negative numbers xi and yi (0\u2009\u2264\u2009xi,\u2009yi\u2009\u2264\u2009200) \u2014 the coordinates of the i-th vector. It is guaranteed that all the vectors are nonzero and different.", "output_spec": "You should print \"Anton\", if the winner is Anton in case of both players play the game optimally, and \"Dasha\" otherwise.", "sample_inputs": ["0 0 2 3\n1 1\n1 2", "0 0 2 4\n1 1\n1 2"], "sample_outputs": ["Anton", "Dasha"], "notes": "NoteIn the first test, Anton goes to the vector (1;2), and Dasha loses. In the second test Dasha with her first move shifts the dot so that its coordinates are (2;3), and Anton loses, as he has the only possible move \u2014 to reflect relatively to the line y\u2009=\u2009x. Dasha will respond to it with the same move and return the dot in position (2;3)."}, "positive_code": [{"source_code": "import math\n\nvectors = []\n\nline_parts = raw_input().split()\nx = int(line_parts[0])\ny = int(line_parts[1])\nn = int(line_parts[2])\nd = int(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((int(l[0]), int(l[1])))\n\nmp = {}\n\ndef canWin(x, y):\n\n if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) > float(d):\n return False\n\n if (x, y) in mp:\n return mp[(x, y)] \n \n result = True \n \n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1])))\n\n \n mp[(x, y)] = result\n \n return result\n\nresult = canWin(x , y)\n \nif result == False:\n print \"Anton\"\nelse:\n print \"Dasha\"\n "}, {"source_code": "#!/usr/bin/python\n\nimport sys\nimport math\n\ndp = []\nd = 0\nn = 0\nstep = []\n\ndef search(x, y, reflect):\n\n #print x,y,reflect\n #if x == 1 and y == 1 and reflect == 2:\n #v = 3\n #v += 1\n if dp[x][y][reflect] != -1:\n return dp[x][y][reflect]\n if x * x + y * y > d:\n #print x,y,reflect,0\n return 1\n if 1 <= reflect <= 2:\n ref = 3 - reflect\n else:\n ref = reflect\n \n for mx,my in step:\n rt = search(x+mx, y+my, ref)\n if rt == 0:\n dp[x][y][reflect] = 1\n #print x,y,reflect,1\n return 1\n \n if reflect < 2:\n rt = search(y,x,ref+1)\n if rt == 0:\n dp[x][y][reflect] = 1\n #print x,y,reflect,1\n return 1\n\n #print x,y,reflect,0\n dp[x][y][reflect] = 0\n return 0\n\nif __name__==\"__main__\":\n fp = sys.stdin\n #fp = open(\"a1.in\")\n data = fp.readlines()\n x,y,n,d = [int(v) for v in data[0].split(' ')]\n step = [[int(v) for v in line.split(' ')] for line in data[1:]]\n dp = [[[-1] * 4 for i in range(0,500)] for j in range (0,500)]\n d = d * d\n \n\n rt = search(x,y,0)\n if rt == 1:\n print \"Anton\"\n else:\n print \"Dasha\"\n"}, {"source_code": "\n\ndef dist(x, y):\n return (x ** 2 + y ** 2) ** 0.5\n\n\nx0, y0, n, d = map(int, raw_input().split())\nmvs = []\nfor _ in range(n):\n mvs.append(map(int, raw_input().split()))\n\ndp = [[False] * (2 * d + 1) for _ in range(2 * d + 1)]\nfor i in range(2 * d, -1, -1):\n for j in range(2 * d, -1, -1):\n x = i - d\n y = j - d\n if dist(x, y) <= d:\n for dx, dy in mvs:\n x1 = x + dx\n y1 = y + dy\n if dist(x1, y1) <= d and not dp[x1 + d][y1 + d]:\n dp[i][j] = True\nif dp[x0 + d][y0 + d]:\n print('Anton')\nelse:\n print('Dasha')\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\nx, y, n, d = map(int, input().split())\nvector = [list(map(int, input().split())) for _ in range(n)]\ndp = [[-1] * (d * 2 + 1) for _ in range(d * 2 + 1)]\n\nfor i in range(d * 2 + 1):\n for j in range(d * 2 + 1):\n if (i - d) ** 2 + (j - d) ** 2 > d**2:\n dp[i][j] = 1\n\n\ndef solve(x, y):\n if dp[x][y] != -1:\n return dp[x][y]\n\n for dx, dy in vector:\n if 0 <= x + dx <= 2 * d and 0 <= y + dy <= 2 * d and solve(x + dx, y + dy) == 0:\n dp[x][y] = 1\n return 1\n\n dp[x][y] = 0\n return 0\n\n\nif solve(x + d, y + d):\n print('Anton')\nelse:\n print('Dasha')\n"}, {"source_code": "from sys import stdin\n\nx,y,n,d = [int(x) for x in stdin.readline().split()]\nd = d**2\n\n\nv = []\n\nfor vec in range(n):\n v.append([int(x) for x in stdin.readline().split()])\n\nfound = {}\n\ndef winner(x,y,v,d):\n if x**2 + y**2 > d:\n return 1\n if (x,y) in found:\n return found[(x,y)]\n for a,b in v:\n if winner(x+a,y+b,v,d) == 0:\n found[(x,y)] = 1\n return 1\n found[(x,y)] = 0\n return 0\n\nif winner(x,y,v,d):\n print('Anton')\nelse:\n print('Dasha')\n"}], "negative_code": [{"source_code": "import math\n\n\nvectors = []\n\n\nline_parts = raw_input().split()\nx = float(line_parts[0])\ny = float(line_parts[1])\nn = int(line_parts[2])\nd = float(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((float(l[0]), float(l[1])))\n\n\nmp = {}\n\n\ndef canWin(x, y, t, fs, ss):\n\n if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) > d:\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n if t == False and ss == False: #if Dasha turn and if dasha hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, fs, True))\n elif t == True and fs == False: #if Anton turn and if Anton hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, True, ss))\n else: #since both has swapped 1 time now cannot swap further\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n\n \n mp[(x, y, t)] = result\n \n return result\n \n\nresult = False\n\nfor v in vectors:\n result = result or canWin(x + v[0], y + v[1], False, False, False) \n \nif result == True:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n#print canWin(1, 1, False, False, False) or (canWin(1, 2, False, False, False))\n#Expected result was True since Anton wins but the result is False"}, {"source_code": "import math\n\n\nvectors = []\n\n\nline_parts = raw_input().split()\nx = int(line_parts[0])\ny = int(line_parts[1])\nn = int(line_parts[2])\nd = int(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((int(l[0]), int(l[1])))\n\nmp = {}\n\ndef canWin(x, y, t, fs, ss):\n\n if math.sqrt(math.pow(x, 2) + math.pow(y, 2)) > float(d):\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n if t == False and ss == False: #if Dasha turn and if dasha hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, fs, True))\n elif t == True and fs == False: #if Anton turn and if Anton hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, True, ss))\n else: #since both has swapped 1 time now cannot swap further\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n\n \n mp[(x, y, t)] = result\n \n return result\n \n\nresult = False\n\nfor v in vectors:\n result = result or canWin(x + v[0], y + v[1], False, False, False) \n \nif result == True:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n"}, {"source_code": "import math\n\n\n#For the following test case\n#0 0 2 3\n#1 1\n#1 2\n#\n#\n#x --> x coordinate\n#y --> y coordinate\n#t --> if t == True then Anton turn, if t == False then Dasha turn\n#fs --> if first player or Anton has swapped, since only 1 swap is possible\n#ss --> if second player or Dasha has swapped, since only 1 swap is possible\n\n\nvectors = []\n\n\nline_parts = raw_input().split()\nx = int(line_parts[0])\ny = int(line_parts[1])\nn = int(line_parts[2])\nd = int(line_parts[3])\n\nfor i in range(n):\n l = raw_input().split()\n vectors.append((int(l[0]), int(l[1])))\n\n\nmp = {}\n\n\ndef canWin(x, y, t, fs, ss):\n\n if math.sqrt(float(x)*float(x) + float(y)*float(y)) > d:\n return False\n\n if (x, y, t) in mp:\n return mp[(x, y, t)] \n \n result = True \n \n if t == False and ss == False: #if Dasha turn and if dasha hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, fs, True))\n elif t == True and fs == False: #if Anton turn and if Anton hasnt swapped then can swap 1 time\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n result = result and (not canWin(y, x, not t, True, ss))\n else: #since both has swapped 1 time now cannot swap further\n for v in vectors:\n result = result and (not (canWin(x + v[0], y + v[1], not t, fs, ss)))\n\n \n mp[(x, y, t)] = result\n \n return result\n \n\nresult = False\n\nfor v in vectors:\n result = result or canWin(x + v[0], y + v[1], False, False, False) \n \nif result == True:\n print \"Anton\"\nelse:\n print \"Dasha\"\n \n#print canWin(1, 1, False, False, False) or (canWin(1, 2, False, False, False))\n#Expected result was True since Anton wins but the result is False\n\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\nx, y, n, d = map(int, input().split())\nvector = [list(map(int, input().split())) for _ in range(n)]\ndp = [-1] * (1 << n)\n\n\ndef solve(bit, x, y):\n if dp[bit] != -1:\n return dp[bit]\n\n for i in range(n):\n if (1 << i) & bit:\n continue\n if (x + vector[i][0]) ** 2 + (y + vector[i][1])**2 <= d**2 and solve(bit | (1 << i), x + vector[i][0], y + vector[i][1]) == 0:\n dp[bit] = 1\n return 1\n\n dp[bit] = 0\n return 0\n\n\nif solve(0, x, y):\n print('Anton')\nelse:\n print('Dasha')\n"}], "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f"} {"nl": {"description": "As you very well know, this year's funkiest numbers are so called triangular numbers (that is, integers that are representable as , where k is some positive integer), and the coolest numbers are those that are representable as a sum of two triangular numbers.A well-known hipster Andrew adores everything funky and cool but unfortunately, he isn't good at maths. Given number n, help him define whether this number can be represented by a sum of two triangular numbers (not necessarily different)!", "input_spec": "The first input line contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009109).", "output_spec": "Print \"YES\" (without the quotes), if n can be represented as a sum of two triangular numbers, otherwise print \"NO\" (without the quotes).", "sample_inputs": ["256", "512"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample number .In the second sample number 512 can not be represented as a sum of two triangular numbers."}, "positive_code": [{"source_code": "#rextester.com:2.7.12--codeforces.com:2.7.12\nimport math\na=int(raw_input())*2;b=0\nfor i in range(1,int(math.sqrt(a))):\n c=a-i*i-i;d=int(math.sqrt(c))\n if d*(d+1)==c:b=1\nprint(\"YES\")if(b)else\"NO\""}, {"source_code": "n = int(raw_input())\n\nyes = 0\nN = 100005\nfor k in range(1, N):\n\ttarget = n - (k*(k+1)/2)\n\tif (target < 0): break\n\tl = 1\n\tr = N\n\tans = -1\n\twhile (l <= r):\n\t\tmid = (l+r)/2\n\t\tcur = mid*(mid+1)/2\n\t\tif (cur == target):\n\t\t\tans = mid\n\t\t\tbreak\n\t\telif (cur < target):\n\t\t\tl = mid+1\n\t\telse:\n\t\t\tr = mid-1\n\tif (ans != -1):\n\t\tyes = 1\n\t\tbreak\n\nif (yes):\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "__author__ = 'Lenovo'\nM = 45000\ns = set(x * (x + 1) / 2 for x in xrange(1, M))\nn = int(raw_input())\n\ndef solve():\n for i in s:\n if n - i in s:\n return 'YES'\n return 'NO'\n\nprint solve()"}, {"source_code": "def main():\n n = int(input())\n lookup = set()\n k = 1\n while k * (k + 1) // 2 <= n:\n lookup.add(k * (k + 1) // 2)\n k += 1\n\n ok = False\n for elm in lookup:\n if elm < n:\n if n - elm in lookup:\n ok = True\n if ok:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "from sys import stdin\n\nt=[(x*(x+1)//2) for x in range(44730)]\nnum = int(stdin.readline().strip())\n\n\ni,found = 1,False\nfor y in range(len(t)):\n if 2*t[y]==num:\n found=True\n \nwhile found==False and t[i]= l:\n\t\tmid = l + (r-l)//2\n\t\tif ar[mid] == x:\n\t\t\treturn mid\n\t\telif ar[mid] < x:\n\t\t\treturn binarysearch(ar,mid+1,r,x)\n\t\telse:\n\t\t\treturn binarysearch(ar,l,mid-1,x)\t\n\treturn -1\t\t\t\ndef funky(n):\n\ta = (int((2*n)**(.5))+int(2))\n\tar = []\n\tfor i in range(1,a):\n\t\tk = int(i*(i+1)/2)\n\t\tar.append(k)\n\treturn ar\t\ndef CoolestNum(ar,l,r,x):\n\tb = binarysearch(ar,l,r,x/2)\n\tif b != -1:\n\t\treturn \"YES\"\n\telse:\t\t\n\t\tg = len(ar)\t\n\t\tfor i in range(g-1,-1,-1):\n\t\t\tif ar[i] > x//2:\n\t\t\t\tdiff = x - ar[i]\n\t\t\t\tterm = binarysearch(ar,0,g-1,diff)\n\t\t\t\tif term != -1:\n\t\t\t\t\treturn \"YES\"\n\treturn \"NO\"\t\t\t\n\nn = int(input())\nar = funky(n)\nq = len(ar)\nprint(CoolestNum(ar,0,q-1,n))\n"}, {"source_code": "n = input()\nchisla = set([i*(i+1)/2 for i in range(1, 50000)])\n\nif any([(n - h) in chisla for h in chisla]):\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "from math import *\nEPSILON = 0.000000000001\nn = int(raw_input())\nfound = False\n\nfor k in range(1,31623):\n x = n - k*(k+1)/2\n if x < 0: break\n a = 1.0\n b = 1.0\n c = -2.0*x\n \n det = b**2 -4*a*c\n if det >= 0:\n m = (-b + det**0.5)/2.0\n if m > 0 and (m-floor(m) >1\n if (mid=len(arr):\n return False\n return arr[lo]==number\n\nn=int(raw_input())\narr=[]\ncan=True\nfor i in xrange(1,50000):\n arr.append(i*(i+1)//2)\nfor i in arr:\n y=n-i\n if y<0:\n can=False\n break\n if bs(arr,y):\n can=True\n break\n\nprint can and \"YES\" or \"NO\""}, {"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 = input()\n \n triangles = {(i * (i+1))/2 : 1 for i in range(1,44750)}\n\n for x in triangles:\n if n - x in triangles:\n print \"YES\"\n return\n print \"NO\"\n\nif __name__ == \"__main__\":\n solver()\n \n"}, {"source_code": "s = set([x*(x+1)/2 for x in range(1,45000)])\nn = input()\nflag = 0\nfor i in s:\n if n-i in s:\n flag = 1\nif flag == 1: print 'YES'\nelse: print 'NO'\n"}, {"source_code": "#rextester.com:2.7.12--codeforces.com:2.7.12\nimport math\na=int(raw_input())*2;b=0\nfor i in range(1,int(math.sqrt(a))):\n c=a-i*i-i;d=int(math.sqrt(c))\n if d*(d+1)==c:b=1\nprint(\"YES\")if(b)else\"NO\""}, {"source_code": "import math\n#n, m = input().split()\n#n = int (n)\n#m = int (m)\n#n, m, k , l= input().split()\n#n = int (n)\n#m = int (m)\n#k = int (k)\n#l = int(l)\nn = int(input())\n#m = int(input())\n#s = input()\n##t = input()\n#a = list(map(char, input().split()))\n#a.append('.')\n#print(l)\n#c = list(map(int, input().split()))\n#c = sorted(c)\n#x1, y1, x2, y2 =map(int,input().split())\n#n = int(input())\n#f = []\n#t = [0]*n\n#f = [(int(s1[0]),s1[1]), (int(s2[0]),s2[1]), (int(s3[0]), s3[1])]\n#f1 = sorted(t, key = lambda tup: tup[0])\n\nl = 1\nu = round(math.sqrt(n))*2\n#u = n\nf = False\n\nwhile ( l <= u):\n #print(l, u)\n if(l*(l+1)+u*(u+1) < 2*n):\n l += 1\n elif(l*(l+1)+u*(u+1) > 2*n):\n u -= 1\n else:\n f = True\n break\nif f:\n print(\"YES\")\nelse:\n print(\"NO\")\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 = input()\n \n triangles = {(x * (x + 1)) / 2 for x in range(1,50000)}\n triangles = {}\n for i in range(1,50000):\n triangles[(i *(i+1)) / 2] = 1\n\n\n for x in triangles:\n if n - x in triangles:\n print \"YES\"\n return\n print \"NO\"\n\nif __name__ == \"__main__\":\n solver()\n \n"}, {"source_code": "import math\nn = int(input())\ni =int(math.sqrt(n))\nj=i\nres = 'NO'\nwhile i>0 & jn:\n\t\tdel k[-1]\n\tif len(k)!=0 and k[-1]+i==n:\n\t\tprint \"YES\"\n\t\texit(0)\nprint \"NO\"\n"}, {"source_code": "from itertools import combinations\nn = int(input())\ns = set()\nfor i in range(1,50000):\n\tx = i*(i+1)//2\n\ts.add(x)\nfor i in s:\n\tif n-i in s:\n\t\tprint (\"YES\")\n\t\texit()\nprint (\"NO\")"}, {"source_code": "import math\nn=int(input())\nt=math.sqrt(n)\nif(n==1):\n print(\"NO\")\n exit(0)\nelse:\n for i in range(1,int(t)+1):\n q=n-(i*(i+1))/2\n q1=1+8*q;\n q2=math.sqrt(q1)\n q3=int(q2)\n if(q3*q3==q1):\n print(\"YES\")\n exit(0)\nprint(\"NO\")\n"}, {"source_code": "#!/usr/bin/env python\n\na = set([(i * (i + 1)) / 2 for i in range(1, 1 << 16)])\nn = int(raw_input())\nprint \"YES\" if [1 for i in a if n - i in a] else \"NO\""}, {"source_code": "import math\n\nn = int(input())\na = 1\nb = 1\nc = -(2*n)\nd = (b**2) - (4*a*c)\nflag = 0\nsol = (-b+math.sqrt(d))//(2*a)\nma = int(sol)\ntemp = 0\nfor i in range(1,ma+1):\n temp += i\n c = -(2*(n-temp))\n d = (b**2) - (4*a*c)\n sol = (-b + math.sqrt(d)) // (2 * a)\n if (sol*(sol+1))//2 + temp == n and sol > 0:\n flag = 1\n print(\"YES\")\n break\nif flag == 0:\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "import bisect\ndef solve():\n n = input()\n SUM = []\n SUM.append(1)\n s = 1\n i = 1\n while s < n:\n s = s + (i+1)\n SUM.append(s)\n i += 1\n SUM_len = len(SUM)\n for i in range(SUM_len):\n x = SUM[i]\n y = n - x\n pos = bisect.bisect_left(SUM, y)\n if pos != SUM_len and SUM[pos] == y:\n return \"YES\"\n return \"NO\"\n\n\nprint solve()"}, {"source_code": "l=[]\nfor i in range(1,10**5):\n l.append(i*(i+1)//2)\ni=0 \nf=0 \nn=int(input())\nj=10**5-5 \nwhile i<=j:\n if l[i]+l[j]==n:\n f=1 \n break \n elif l[i]+l[j]n):\n j-=1\n\nelse:\n print(\"NO\")"}, {"source_code": "hash_set = set()\nfor i in range(1,10**5):\n hash_set.add(i*(i+1)//2)\nn = int(input())\n\nif n==1:\n print('NO')\n exit()\n\ni = 1\nwhile True:\n temp = (i * (i+1) // 2 )\n if temp > n:\n print('NO')\n break\n elif (n - temp) in hash_set:\n print('YES')\n break\n i += 1"}, {"source_code": "from sys import stdin\n\nt=[(x*(x+1)//2) for x in range(44730)]\nnum = int(stdin.readline().strip())\n\n\ni,found = 1,False\nfor y in range(len(t)):\n if 2*t[y]==num:\n found=True\n \nwhile found==False and t[i]=n):\n break\n t.append(a)\n if n-a in t:\n print(\"YES\")\n break\n else:\n p+=1\n i+=1\n if(p==len(t)):\n print(\"NO\")\n \n#Call the solve function \nif __name__ == \"__main__\":\n solution() \n"}, {"source_code": "n=input()\nk=l=[i*(i+1)/2 for i in range(1,80000)]\nfor i in l:\n\twhile len(k)!=0 and k[-1]+i>n:\n\t\tdel k[-1]\n\tif len(k)!=0 and k[-1]+i==n:\n\t\tprint \"YES\"\n\t\texit(0)\nprint \"NO\"\n"}, {"source_code": "\nn = int(input())\n\nfn = []\nk=1\nwhile True:\n num = (k*(k+1))//2\n if num>n:\n break\n fn.append(num)\n k+=1\ni=0\nj=len(fn)-1\n\nwhile i<=j:\n if fn[i]+fn[j]==n:\n print(\"YES\")\n break\n elif fn[i]+fn[j]j or fn[i]+fn[j]!=n:\n print(\"NO\")\n\n\n\n"}, {"source_code": "n= int(input())\na= set()#[k*(k+1)//2 for k in range(1,n)])\nfor i in range (n):\n x = i*(i+1)//2\n if x >=n:\n print('NO')\n break\n a.add(x)\n if n-x in a:\n print('YES')\n break\nelse :\n print('NO')"}, {"source_code": "from math import sqrt\na=input()*2\n\nx=1\nwhile(x*(x+1)=n):\n break\n t.append(a)\n i+=1\n \n for i in range(len(t)):\n p.append(n-t[i])\n \n ans=common(t,p)\n if(len(ans)>0):\n print(\"YES\")\n else:\n print(\"NO\")\n \n#Call the solve function \nif __name__ == \"__main__\":\n solution() \n"}, {"source_code": "def binary_search(arr,val):\n\tL = 0\n\tR = len(arr)-1\n\twhile L<=R:\n\t\tmid = (L+R)/2\n\t\tif (arr[mid] == val):\n\t\t\treturn True\n\t\telif (arr[mid] < val):\n\t\t\tL = mid + 1\n\t\telse:\n\t\t\tR = mid - 1\n\treturn False\n\nn = int(raw_input())\narr = [i*(i+1)/2 for i in range(1,50000)]\n\nfound = False\n\nfor val in arr:\n\tif binary_search(arr,n-val):\n\t\tfound = True\n\nif found:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"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 = input()\n \n triangles = [ (x * (x + 1)) / 2 for x in range(1,50000)]\n\n for i in range(len(triangles)):\n lp = i\n up = len(triangles) - 1\n now_num = triangles[i]\n while lp != up:\n mid = (lp + up) / 2\n \n if now_num + triangles[mid] < n:\n lp = mid + 1\n else:\n up = mid\n\n if now_num + triangles[lp] == n:\n #print now_num,triangles[lp]\n print \"YES\"\n return\n\n print \"NO\"\n\nif __name__ == \"__main__\":\n solver()\n \n"}, {"source_code": "n=int(input())\na=[]\nb=[]\ni=int(1)\nf=0\nwhile(1):\n a.append(int((i*(i+1))/2))\n if(a[len(a)-1]>=n):\n break\n i=i+1\nfor i in range(len(a)):\n b.append(n-a[i])\nb.sort()\nprint(\"YES\") if(set(a) & set(b)) else print(\"NO\")"}, {"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 = input()\n \n triangles = [ (x * (x + 1)) / 2 for x in range(1,50000)]\n\n for i in range(len(triangles)):\n lp = i\n up = len(triangles) - 1\n now_num = triangles[i]\n while lp != up:\n mid = (lp + up) / 2\n \n if now_num + triangles[mid] < n:\n lp = mid + 1\n else:\n up = mid\n\n if now_num + triangles[lp] == n:\n #print now_num,triangles[lp]\n print \"YES\"\n return\n\n print \"NO\"\n\nif __name__ == \"__main__\":\n solver()\n \n"}, {"source_code": "def binary_search(arr, start, end, x):\n if (end < start):\n # Element is not present in the array\n return -1\n else:\n mid = start + (end - start) // 2\n # If element is present at the middle\n if (arr[mid] == x):\n return mid\n # If element is smaller than mid\n elif (arr[mid] > x):\n return binary_search(arr, start, mid - 1, x)\n # Else the element greater than mid\n else:\n return binary_search(arr, mid + 1, end, x)\n\n\nn = int(input())\ntotal, num, c1, c2, mem = n * 2, 2, 2, 3, [2]\n\nwhile (c1 * c2 < total):\n mem.append(c1 * c2)\n c1 += 1\n c2 += 1\n\n\nfor i in mem:\n if binary_search(mem, 0, len(mem) - 1,total - i) != -1:\n exit(print('YES'))\n\nprint('NO')\n"}, {"source_code": "t = set(x*(x+1)/2 for x in range(1,45001))\nn=input()\nfor i in t:\n if n-i in t:\n print 'Yes'\n exit()\nprint 'No'"}, {"source_code": "from itertools import combinations\nn = int(input())\ns = set()\nfor i in range(1,50000):\n\tx = i*(i+1)//2\n\ts.add(x)\nfor i in s:\n\tif n-i in s:\n\t\tprint (\"YES\")\n\t\texit()\nprint (\"NO\")"}, {"source_code": "from math import *\nEPSILON = 0.000000000001\nn = int(raw_input())\nfound = False\n\nfor k in range(1,31623):\n x = n - k*(k+1)/2\n if x < 0: break\n a = 1.0\n b = 1.0\n c = -2.0*x\n \n det = b**2 -4*a*c\n if det >= 0:\n m = (-b + det**0.5)/2.0\n if m > 0 and (m-floor(m) 0):\n\t\tif((l*(l+1) + r*(r+1))> 2*n):\n\t\t\tl-=1\n\t\telif((l*(l+1) + r*(r+1))< 2*n):\n\t\t\tr+=1\n\t\telse:\n\t\t\tfirst=1\n\t\t\tprint \"YES\"\n\t\t\tbreak\n\n\tif(first==0):\n\t\tprint \"NO\"\n"}, {"source_code": "from math import sqrt\nn=int(input())\ni=int(sqrt(n))\nj=i\np='NO'\nwhile(i>0 and jn):\n i=i-1\nprint(p)"}, {"source_code": "n = int(input())\nm = 2*n+0.5\nl = int(n**(1/2))\nflag = 0\nfor i in range(1,l+1):\n a = (m-((i+0.5)**(2)))**(1/2)-0.5 \n if a == int((m-((i+0.5)**(2)))**(1/2)-0.5) and a != 0:\n print(\"Yes\")\n flag = 1\n break\n i = i+1\nif flag == 0:\n print(\"No\")"}, {"source_code": "def fun(l, n):\n left = 0\n right = len(l) - 1\n while(left <= right):\n if(l[left] + l[right] == n):\n print \"YES\"\n return\n elif(l[left] + l[right] < n):\n left += 1\n else:\n right -= 1\n print \"NO\"\n \n\nn = input()\nl = []\ni = 1\nwhile(i * (i + 1) / 2 < n):\n l.append(i *(i + 1) / 2)\n i += 1\nfun(l, n)"}, {"source_code": "from math import *\nEPSILON = 0.000000000001\nn = int(raw_input())\nfound = False\n\nfor k in range(1,31623):\n x = n - k*(k+1)/2\n if x < 0: break\n a = 1.0\n b = 1.0\n c = -2.0*x\n \n det = b**2 -4*a*c\n if det >= 0:\n m = (-b + det**0.5)/2.0\n if m > 0 and (m-floor(m) n:\n r -= 1\n else:\n l += 1\n if a[l] + a[r] == n:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "from sys import stdin\n\nt=[(x*(x+1)//2) for x in range(44730)]\nnum = int(stdin.readline().strip())\n\n\ni,found = 1,False\nfor y in range(len(t)):\n if 2*t[y]==num:\n found=True\n \nwhile found==False and t[i]=n):\n break\n i=i+1\nfor i in range(len(a)):\n b.append(n-a[i])\nb.sort()\nprint(\"YES\") if(set(a) & set(b)) else print(\"NO\")"}, {"source_code": "hash_set = set()\nfor i in range(1,10**5):\n hash_set.add(i*(i+1)//2)\nn = int(input())\n\nif n==1:\n print('NO')\n exit()\n\ni = 1\nwhile True:\n temp = (i * (i+1) // 2 )\n if temp > n:\n print('NO')\n break\n elif (n - temp) in hash_set:\n print('YES')\n break\n i += 1"}, {"source_code": "def code(n):\n return(n*(n+1)//2)\nn=int(input())\nk=1\na=set()\nwhile code(k)<=n:\n a.add(code(k))\n k+=1\nfor i in a:\n if (n-i) in a:\n print(\"YES\")\n break\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\nst=set([p*(p+1)/2 for p in range(1,55000)])\n\nprint (\"YES\" if[i for i in st if n-i in st] else \"NO\")\n \n"}, {"source_code": "n = int(input())\nif n == 1:\n print(\"NO\")\nelse:\n a = [1]\n b = 1\n while a[-1] < n:\n b += 1\n a.append(int(b * (b + 1) / 2))\n a = a[:-1]\n r = b - 2\n l = 0\n while r != l and a[l] + a[r] != n:\n if a[l] + a[r] > n:\n r -= 1\n else:\n l += 1\n if a[l] + a[r] == n:\n print(\"YES\")\n else:\n print(\"NO\")\n"}, {"source_code": "import sys\n\nf = open(sys.argv[1]) if len(sys.argv) > 1 else sys.stdin\n\nn = int(f.readline())\n\ntrs = []\nfor k in xrange(1, 10 ** 5 + 1):\n tr = k * (k + 1) / 2\n if tr > n:\n break\n trs.append(tr)\n\ntrs_set = set(trs)\n\nfor tr in trs:\n if n - tr in trs_set:\n print \"YES\"\n break\nelse:\n print \"NO\"\n"}, {"source_code": "a=set([(i+1)*i/2 for i in range(1,50001)])\nn=input()\narr = [1 for i in a if n-i in a]\nif arr:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "import sys\n\ndef half_is_triangular(n):\n\n if n % 2:\n return False\n \n begin, end = 1, n\n \n while begin != end - 1:\n \n middle = (begin + end) / 2\n \n candidate = middle**2 + middle\n \n if candidate < n:\n begin = middle\n elif candidate > n:\n end = middle\n else:\n return True\n \n return True if begin**2 + begin == n else False\n\ndef main():\n \n n = int(sys.stdin.readline().strip())\n n *= 2\n \n for i in range(1, 45000):\n \n second_number = n - i**2 - i\n \n if second_number <= 0:\n break\n if half_is_triangular(second_number):\n return True\n \n return False\n \nif __name__ == \"__main__\":\n print (\"YES\" if main() else \"NO\")"}, {"source_code": "import math\nn = int(raw_input())\nend = (int(math.sqrt(n * 2)) + 10)\nans = 'NO'\ni = 1\nwhile i <= end and i <= n:\n a = i * (i + 1) / 2\n b = (n - a) * 2\n if b <= 0:\n print 'NO'\n break\n d = 1 + 4 * b\n sd = int(math.sqrt(d))\n if sd * sd == d:\n if (sd - 1) % 2 == 0:\n print 'YES'\n break\n i += 1\nelse:\n print 'NO'"}, {"source_code": "k= set([(i*(i+1))//2 for i in range(1,45000)])\n\nn = int(input())\n\nf = set([n - i for i in k])\n\nt = k & f\n\nif t:\n\n print('YES')\n\nelse:\n\n print('NO')"}, {"source_code": "import math\nn=int(input())\nt=math.sqrt(n)\nif(n==1):\n print(\"NO\")\n exit(0)\nelse:\n for i in range(1,int(t)+1):\n q=n-(i*(i+1))/2\n q1=1+8*q;\n q2=math.sqrt(q1)\n q3=int(q2)\n if(q3*q3==q1):\n print(\"YES\")\n exit(0)\nprint(\"NO\")\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 = input()\n triangles = {}\n for i in range(1,50000):\n triangles[(i *(i+1)) / 2] = 1\n\n\n for x in triangles:\n if n - x in triangles:\n print \"YES\"\n return\n print \"NO\"\n\nif __name__ == \"__main__\":\n solver()\n "}, {"source_code": "a=set([(i+1)*i/2 for i in range(1,50001)])\nn=input()\nprint \"YES\"if[1 for i in a if n-i in a]else\"NO\""}, {"source_code": "n = int(raw_input())\n\ntriangle = set()\nfor i in range(1,50000):\n triangle.add((i * (i+1))/2)\n\nfor i in triangle:\n if n-i in triangle:\n print \"YES\"\n quit()\n\nprint \"NO\"\n"}, {"source_code": "T={k*(k+1)//2 for k in range(1,44721)}\nn=int(input())\nif any(n-j in T for j in T):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "p = set([(i*(i+1))//2 for i in range(1,45000)])\nn = int(input())\nq = set([n - i for i in p])\nt = p & q\nif t:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "from math import *\n \nn = int(raw_input()) * 2\n \nk = int(round(sqrt(n)))\n \nfound = False\n \nfor i in range(1, k):\n r = n - i * i - i\n x = int(floor(sqrt(r)))\n if x * (x + 1) == r:\n found = True\n break\n \nprint \"YES\" if found else \"NO\"\n"}, {"source_code": "from math import *\nn=int(input())\ncount=0\nfor i in range(1,int(n/2)+1):\n a=(i*(i+1))/2\n b=str(a)\n \n if b[-1]=='0':\n x=n-int(a)\n \n if x<0:\n break\n square_root=sqrt(8*x+1)\n \n square_root1=str(square_root)\n if square_root1[-1]=='0':\n \n c=(square_root-1)/2\n if c==0.0:\n continue\n else:\n c=str(c)\n if c[-1]=='0':\n print('YES')\n count=1\n break\nif count==0:\n print('NO')\n \n\n \n \n \n"}, {"source_code": "from math import *\n\nn = int(raw_input()) * 2\n\nk = int(round(sqrt(n)))\n\nfound = False\n\nfor i in range(1, k):\n r = n - i * i - i\n x = int(floor(sqrt(r)))\n if x * (x + 1) == r:\n found = True\n break\n\nprint \"YES\" if found else \"NO\""}], "negative_code": [{"source_code": "from math import *\nn=int(input())\ncount=0\nfor i in range(1,int(n/2)+1):\n a=(i*(i+1))/2\n b=str(a)\n \n if b[-1]=='0':\n x=n-int(a)\n \n if x<0:\n break\n square_root=sqrt(8*x+1)\n \n square_root1=str(square_root)\n if square_root1[-1]=='0':\n \n c=(square_root-1)/2\n \n c=str(c)\n if c[-1]=='0':\n print('YES')\n count=1\n break\nif count==0:\n print('NO')\n \n\n \n \n \n"}, {"source_code": "n=int(input())\na=[]\ni=int(0)\nf=0\nwhile(1):\n a.append((i*(i+1))/2)\n if(a[len(a)-1]>=256):\n break\n i=i+1\nfor i in range(len(a)):\n if(n-a[i] in a):\n f=1\n break\nprint(\"YES\") if(f==1) else print(\"NO\")"}, {"source_code": "\nfrom bisect import bisect_left\n\ndef index(a, x):\n # 'Locate the leftmost value exactly equal to x'\n i = bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return True\n return -1\nc = int(input())\nlist1 = []\n\nfor i in range(50000):\n\n z = ((i)*(i+1))//2\n\n list1.append(z)\n# print(len(list1))\ntemp = 0\nfor i in list1:\n z = (c - i)\n k = index(list1,z)\n if k == True:\n # print(z,i)\n temp = 1\n break\n\nif temp == 0:\n print('NO')\nelse:\n print('YES')\n\n\n\n\n\n\n"}, {"source_code": "import math\n\ndef isok(i , n):\n remain = (n - (i + 1) * i / 2) * 2\n m = (int)(math.sqrt(remain)) + 10\n while m * (m + 1) > remain:\n m -= 1\n if m * (m + 1) == remain:\n return True\n else:\n return False\n\nn = int(raw_input())\ni = 1\nok = False\nwhile i * (i + 1) / 2 <= n:\n if isok(i , n) == True:\n ok = True\n break\n i += 1\n \nif ok == True:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "n = int(input())\nm = 2*n+0.5\nl = int(n**(1/2))\nflag = 0\nfor i in range(1,l+1):\n if (m-((i+0.5)**(2)))**(1/2)-0.5 == int((m-((i+0.5)**(2)))**(1/2)-0.5):\n print(\"Yes\")\n flag = 1\n break\n i = i+1\nif flag == 0:\n print(\"No\")"}, {"source_code": "from sys import stdin, stdout\nfrom math import sqrt\n\ndef isTriangular(n):\n t = int(sqrt(n))\n return n+n==(t+2)*(t+1)\n\nn = int(stdin.readline().strip())\n\nans = 'NO'\n\ni = 0\nwhile (i*(i+1)>>1) <= n:\n if isTriangular(n - (i*(i+1)>>1)):\n ans = 'YES'\n break\n i += 1\n\nprint(ans)\n"}, {"source_code": "import math\n# -*- coding: utf-8 -*-\n\n#\u001b$BF~NO$7$?$b$N$rBeF~\u001b(B\ninput_num = int(raw_input())\ntwi_num = input_num * 2\n\nans = \"NO\"\nfor i in range(1, int(math.sqrt(input_num+1))+1):\n\tif(ans == \"YES\"):\n\t\tbreak;\n\n\ttemp = twi_num - (i * (i+1))\n\n\tfor j in range(-1, 2):\n\t\tcheck = int(math.sqrt(temp)) + j\n\t\tif((check * (check+1)) + (i * (i+1))== twi_num):\n\t\t\tans = \"YES\"\n\nprint ans\n"}, {"source_code": "def funky(n):\n for i in range(n):\n if (i*(i+1))//2==n:\n break\n return True\n else:\n return False\nx=int(input()) \na=\"NO\"\nfor i in range(1,x+1):\n if funky(i) and funky(x-i):\n a='YES'\n break\nprint(a) \n \n \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 = input()\n \n triangles = [ (x * (x + 1)) / 2 for x in range(1,50000)]\n\n for i in range(len(triangles)):\n if i > len(triangles)/2 + 1:\n break\n\n lp = i\n up = len(triangles) - 1\n now_num = triangles[i]\n while lp != up:\n mid = (lp + up) / 2\n \n if now_num + triangles[mid] < n:\n lp = mid + 1\n else:\n up = mid\n\n if now_num + triangles[lp] == n:\n #print now_num,triangles[lp]\n print \"YES\"\n return\n\n print \"NO\"\n\nif __name__ == \"__main__\":\n solver()\n \n"}, {"source_code": "n=int(input())\narr=[]\nf=0\nfor i in range(1,25000):\n arr.append((i*(i+1))//2)\nfor el in arr:\n if (n-el) in arr:\n f=1\n break\nif(f==1):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n \n"}, {"source_code": "import math, sys\nn = int(raw_input())\ntr = set([x*(x+1)/2 for x in range(1,int(math.sqrt(n))+1)])\nfor a in tr:\n if tr.__contains__(n-a):\n print \"YES\"\n sys.exit(0)\nprint \"NO\"\n"}, {"source_code": "import bisect\nl=[0]*50001\nfor i in range(50001):\n if i==0 or i==1:\n l[i]=i\n else:\n l[i]=l[i-1]+i\nn=int(input())\ni=bisect.bisect_left(l,n)\nj=2\nf=0\nwhile i>j:\n if l[i]+l[j]==n:\n f=1\n break\n elif l[i]+l[j]>n:\n i=i-1\n elif l[i]+l[j]= n:\n break\n ar.append(x)\n i +=1\nm = 0\nfor i in ar:\n if n - i in ar:\n \n m+=1\n break\n\nif m>0:\n print('YES')\nelse:\n print('NO')\n\n"}, {"source_code": "from sys import stdin\n\nt=[(x*(x+1)//2) for x in range(44730)]\nnum = int(stdin.readline().strip())\n\ni,found = 1,False\nwhile found==False and t[i]=n):\n break\n i=i+1\nfor i in range(len(a)//2):\n b.append(n-a[i])\nb.sort()\nprint(\"YES\") if(set(a) & set(b)) else print(\"NO\")"}, {"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>1\n return r\n \ndef solve():\n n=inp()\n c=0\n i=1\n while i*i<=n:\n a=(i*(i+1))//2\n b=n-a\n x=(-1+(1+8*b)**0.5)//2\n y=(-1-(1+8*b)**0.5)//2\n \n if type(x)==float and math.floor(x)==x :\n v=math.floor(x)\n if (v*(v+1)//2)+a==n:\n c=1\n break\n \n if type(y)==float and math.floor(y)==y:\n v=math.floor(y)\n if (v*(v+1)//2)+a==n:\n c=1\n break\n \n i+=1\n \n if c:\n print(\"YES\")\n else:\n print(\"NO\")\n \n\n \n\n\nfor _ in range(1):\n solve()\n \n"}, {"source_code": "h=set([x*(x+1)/2 for x in xrange(53334)])\nn=input()\nprint \"YES\"if ([n-i in h for i in h].count(1)>0)else\"NO\"\n"}, {"source_code": "import math\ndef b_search(l,r,arr,x) :\n\n while(l<=r) :\n mid = (l+r)//2\n\n if xarr[mid] :\n \n l = mid+1 \n \n elif x==arr[mid] :\n \n return True \n \n return False\n\nn = int(input())\n\nN = math.sqrt(2*n)\n\narr = []\narr.append(0)\n\nfor i in range(1,int(N)+1) :\n \n arr.append(arr[i-1]+i)\n \n#print(arr)\n \nflag = 1\n \nfor i in range(int(N)) :\n if b_search(0,int(N),arr,n-arr[i]) :\n \n print(\"YES\")\n flag = 0\n break\n \nif flag :\n print(\"NO\")\n\n \n\n \n\n\n"}, {"source_code": "import pdb\nimport sys\nimport math\n\nfile = sys.stdin\n#file = open(\"test\", \"r\")\n\ndef is_valide(i):\n i *= 2\n root = int(math.sqrt(i))\n if root*(root + 1) == i or (root - 1)*root == i or (root + 1)*(root + 2) == i:\n return True\n else:\n return False\n\nnum = int(file.readline().rstrip())\nroot = int(math.sqrt(num))\nfor i in range(1, root + 1):\n if is_valide(i) and is_valide(num - i):\n print \"YES\"\n break\nelse:\n print \"NO\"\n"}, {"source_code": "\nfrom bisect import bisect_left\n\ndef index(a, x):\n # 'Locate the leftmost value exactly equal to x'\n i = bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return True\n return -1\nc = int(input())\nlist1 = []\n\nfor i in range(50000):\n\n z = ((i)*(i+1))//2\n\n list1.append(z)\n# print(len(list1))\ntemp = 0\nfor i in list1:\n z = (c - i)\n k = index(list1,z)\n if k == True:\n # print(z,i)\n temp = 1\n break\n\nif temp == 0:\n print('NO')\nelse:\n print('YES')\n\n\n\n\n\n\n"}, {"source_code": "from math import sqrt\nn=int(input())\ni=int(sqrt(n))\nj=i\np='NO'\nwhile(i>0 and j n:\n B -= b\n b -= 1\n else: break\nprint('NO' if A + B != n else 'YES')"}, {"source_code": "import sys\nimport os\nfrom math import*\ninput=sys.stdin.buffer.readline\n\nn=int(input())\nx=int(max(int((-1+sqrt(1+8*n))//2),(-1-sqrt(1+8*n))//2))\n#bprint(x)\nif (x*(x+1))//2==n:\n\tprint(\"YES\")\nelse:\n\tn=n-(x*(x+1))//2\n\tx=int(max(int((-1+sqrt(1+8*n))//2),(-1-sqrt(1+8*n))//2))\n\tif (x*(x+1))//2==n:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\n\"\"\"\nz=0\nfor i in range(0,x+1):\n\tprint(i,x-i)\n\tif i*(i+1)+(x-i)*(x-i+1)==2*n:\n\t\tz=1\n\t\tbreak\n\telse:\n\t\tcontinue\nif z==1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\"\"\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 7 23:21:18 2020\n\n@author: Anmol Singla\n\"\"\"\ndef funk(a):\n return(int(a*(a+1)/2))\nfrom math import sqrt\nn=int(input())\ntrue=0\nfor i in range(1,int(sqrt(n))+1):\n x=funk(i)\n\n y=(n-x)\n if(funk(int(sqrt(int(2*y))))==y):\n print(\"YES\")\n true=1\n break\n \nif(true==0):\n print(\"NO\")\n \n"}, {"source_code": "l=[]\nfor i in range(1,10**5):\n l.append(i*(i+1)//2)\ni=0 \nf=0 \nn=int(input())\nj=10**5-5 \nwhile i n/2:\n print \"NO\"\n sys.exit(0)\n \n if n - l in trs:\n print \"YES\"\n sys.exit(0)\n"}, {"source_code": "# map(int, raw_input().split())\n# \" \".join([])\n# [0] * n\n# isupper\nfrom math import sqrt\nn = input()\nk = 1\nwhile k * (k + 1) <= 2 * n:\n\ta = 1\n\tb = 1\n\tc = -(n - k * (k + 1) / 2)\n\tif b * b - 4 * a * c >= 0:\n\t\tl = int((-b + sqrt(b * b - 4 * a * c)) / a)\n\t\tif l > 0 and k * (k + 1) + l * (l + 1) == 2 * n:\n\t\t\tprint \"YES\"\n\t\t\texit(0)\n\tk += 1\n\n\t\t\nprint \"NO\"\n\t"}, {"source_code": "import math\nn=int(input())\nx=int(math.sqrt(n))\nl=x+1\nr=x+1\nfirst=0\nwhile(l>0):\n\tif((l*(l+1) + r*(r+1))> 2*n):\n\t\tl-=1\n\telif((l*(l+1) + r*(r+1))< 2*n):\n\t\tr+=1\n\telse:\n\t\tfirst=1\n\t\tprint \"YES\"\n\t\tbreak\n\nif(first==0):\n\tprint \"NO\"\n"}, {"source_code": "import math\ndef fun(n):\n return (n*(n+1)/2)\nn = int(input())\nj = int(pow(n*2,0.5))\narr = [fun(i) for i in range(j+1)]\ni=0\nwhile(in):\n j-=1\n\nelse:\n print(\"NO\")"}, {"source_code": "from bisect import bisect_left as bisect\n\ndef trigen(n):\n k = 1\n while True:\n tmp = k * (k + 1) / 2\n if tmp > n:\n raise StopIteration\n yield tmp\n k += 1\n\nn = int(raw_input())\ntrinums = list(trigen(n))\nflag = False\nl = len(trinums)\nfor i in xrange(l - 1):\n leftpart = n - trinums[i]\n j = bisect(trinums, leftpart)\n if j < l and trinums[j] == leftpart:\n flag = True\n break\nprint 'YES' if flag else 'NO'\n"}, {"source_code": "from math import ceil, sqrt\n\nn = int(input())\n\ny = ceil(sqrt(n))\ny = (y * (y + 1)) / 2\n\ny = n - y\n\ny = (8 * y) + 1\n\ny = sqrt(y)\n\nif (y == ceil(y)):\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import math\nn=int(input())\nc=0\ns=0\nif n>3:\n n-=3\n z=math.sqrt(n*2)\n if int(z)*(int(z)+1)==n*2:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")"}, {"source_code": "n=int(input())\ndef sum(n):\n\tif (n==0):\n\t\treturn 0\n\telse:\n\t\treturn sum(n-1)+ n\ndef check(n):\n\ti=0\n\twhile(i=0:\n\t\t\tif (num - t) in triangulars:\n\t\t\t\tprint 'YES'\n\t\t\t\treturn\n\t\telse:\n\t\t\tprint 'NO'\n\t\t\treturn\n\n\nmain()"}, {"source_code": "n = int(raw_input())\n\ntriangle = set()\nfor i in range(100000):\n triangle.add((i * (i+1))/2)\n\nfor i in triangle:\n if i > n: break\n if n-i in triangle:\n print \"YES\"\n quit()\n\nprint \"NO\"\n"}, {"source_code": "def binary_search(arr,val):\n\tL = 0\n\tR = len(arr)-1\n\twhile L<=R:\n\t\tmid = (L+R)/2\n\t\tif (arr[mid] == val):\n\t\t\treturn True\n\t\telif (arr[mid] < val):\n\t\t\tL = mid + 1\n\t\telse:\n\t\t\tR = mid - 1\n\treturn False\n\nn = int(raw_input())\narr = [i*(i+1)/2 for i in range(1,40000)]\n\nfound = False\n\nfor val in arr:\n\tif binary_search(arr,n-val):\n\t\tfound = True\n\nif found:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "def funky(n):\n a=False\n for i in range(int(n**(1/2))):\n if (i*(i+1))//2==n:\n a=True\n break\n return a\nx=int(input()) \na=\"NO\"\nfor i in range(x):\n if funky(i) and funky(x-i):\n a='YES'\n break\nprint(a) \n \n \n \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\nimport itertools\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)]\ndef Lcm(x,y): return (x*y)//gcd(x,y)\ndef dtob(n): return bin(n).replace(\"0b\",\"\")\ndef btod(n): return int(n,2) \n\n# Driver Code \ndef solution():\n #for _ in range(Int()):\n n=Int()\n t=[]\n i=1\n while(1):\n a=(i*(i+1))//2\n if(a>=n):\n break\n t.append(a)\n if n-a in t:\n print(\"YES\")\n break\n i+=1\n else:\n print(\"NO\")\n \n#Call the solve function \nif __name__ == \"__main__\":\n solution() \n"}, {"source_code": "MAX_RANGE = 50000\n\ndef chk(n):\n S = set([])\n for i in range(MAX_RANGE):\n S.add(i*(i+1)/2)\n if n - i*(i+1)/2 in S:\n return True\n return False\n\nif __name__ == '__main__':\n n = int(raw_input().strip())\n if chk(n):\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "from math import *\n \nn = int(raw_input()) * 2\n \nk = int(round(sqrt(n)))\n \nfound = False\n \nfor i in range(1, k):\n r = n - i * i\n x = int(floor(sqrt(r)))\n if x * (x + 1) == r:\n found = True\n break\n \nprint \"YES\" if found else \"NO\"\n"}, {"source_code": "n= int(input())\na= set()#[k*(k+1)//2 for k in range(1,n)])\nfor i in range (n):\n x = i*(i+1)//2\n if x > n:\n print('NO')\n break\n a.add(x)\n if n-x in a:\n print('YES')\n break\nelse :\n print('NO')"}, {"source_code": "def binarysearch(ar,l,r,x):\n\tif r >= l:\n\t\tmid = l + (r-l)//2\n\t\tif ar[mid] == x:\n\t\t\treturn mid\n\t\telif ar[mid] < x:\n\t\t\treturn binarysearch(ar,mid+1,r,x)\n\t\telse:\n\t\t\treturn binarysearch(ar,l,mid-1,x)\t\n\treturn -1\t\t\t\ndef funky(n):\n\ta = (int((2*n)**(.5))+int(2))\n\tar = []\n\tfor i in range(1,a):\n\t\tk = int(i*(i+1)/2)\n\t\tar.append(k)\n\treturn ar\t\ndef CoolestNum(ar,l,r,x):\n\tb = binarysearch(ar,l,r,x//2)\n\tif b != -1:\n\t\treturn \"YES\"\n\telse:\t\t\n\t\tg = len(ar)\t\n\t\tfor i in range(g-1,-1,-1):\n\t\t\tif ar[i] > x//2:\n\t\t\t\tdiff = x - ar[i]\n\t\t\t\tterm = binarysearch(ar,0,g-1,diff)\n\t\t\t\tif term != -1:\n\t\t\t\t\treturn \"YES\"\n\treturn \"NO\"\t\t\t\n\nn = 256\nar = funky(n)\nq = len(ar)\nprint(CoolestNum(ar,0,q-1,n))\n"}, {"source_code": "n = int(raw_input())\n\ntriangle = set()\nfor i in range(1,50000):\n triangle.add((i * (i+1))/2)\n\nfor i in triangle:\n if i > n: break\n if n-i in triangle:\n print \"YES\"\n quit()\n\nprint \"NO\"\n"}, {"source_code": "t = set([x*(x+1)/2 for x in range(1,int(31800)+1)])\nn=256#input()\nfor i in t:\n\tif n-i in t:\n\t\tprint 'Yes'\n\t\texit(0)\n\nprint 'No'"}, {"source_code": "n=int(input())\narr=[]\nf=0\nfor i in range(1,25000):\n arr.append((i*(i+1))//2)\nfor el in arr:\n if (n-el) in arr:\n f=1\n break\nif(f==1):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n \n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jun 7 23:21:18 2020\n\n@author: Anmol Singla\n\"\"\"\ndef funk(a):\n return(int(a*(a+1)/2))\nfrom math import sqrt\nn=int(input())\ntrue=0\nfor i in range(1,int(sqrt(n))+1):\n x=funk(i)\n\n y=(n-x)\n if(funk(int(sqrt(int(2*y))))==y):\n print(\"YES\")\n true=1\n break\n \nif(true==0):\n print(\"NO\")\n \n"}, {"source_code": "n = int(input())\nif n==1:\n print(\"NO\")\nelif n==2:\n print(\"YES\")\nelif n==3:\n print(\"NO\")\nelif n==4:\n print(\"YES\")\nelse:\n sqrt_n = int(n**(0.5))//1\n num = 2*(sqrt_n)\n l1 = []\n ismatched = False\n for i in range(1,num+1):\n val = (i*(i+1))//2\n val_2 = n - val\n if val_2>=0:\n discriminat = (1+8*val_2)**(0.5)\n if (int(discriminat))*(int(discriminat))==(1+8*val_2):\n val3 = (discriminat-1)//2\n if n==1:\n print(\"NO\")\n else:\n if int(val3*2)==discriminat-1:\n if int(val3)<=num:\n print(\"YES\")\n ismatched = True\n break\n if ismatched==False:\n print(\"NO\")"}, {"source_code": "from math import ceil, sqrt\nn = int(input())\ndef value(y):\n y = (y * (y + 1)) / 2\n y = n - y\n return y\n\ndef check(y):\n y = (8 * y) + 1\n y = sqrt(y)\n if (y == ceil(y)):\n return True\n else:\n return False\n\ndef main():\n y = ceil(sqrt(n))\n\n while value(y) > 0:\n if check(value(y)):\n return print('YES')\n y += 1\n return print('NO')\n\nmain()"}, {"source_code": "hash_set = set()\nfor i in range(10**5):\n hash_set.add(i*(i+1)//2)\nn = int(input())\nif n==1:\n print('NO')\n exit()\ni = 0\nwhile True:\n temp = (i * (i+1) // 2 )\n if temp > n:\n print('NO')\n break\n elif n - temp in hash_set:\n print('YES')\n break\n i += 1"}, {"source_code": "import sys\n\nn = int(raw_input().strip())\ntrs = set((k+1) * (k+2) / 2 for k in range(10**5))\n\nit = iter(trs)\nwhile 1:\n l = it.next()\n if l > n/2:\n print \"NO\"\n sys.exit(0)\n \n if n - l in trs:\n print \"YES\"\n sys.exit(0)\n"}, {"source_code": "\nfrom bisect import bisect_left\n\ndef index(a, x):\n # 'Locate the leftmost value exactly equal to x'\n i = bisect_left(a, x)\n if i != len(a) and a[i] == x:\n return True\n return -1\nc = int(input())\nlist1 = []\n\nfor i in range(50000):\n\n z = ((i)*(i+1))//2\n\n list1.append(z)\n# print(len(list1))\ntemp = 0\nfor i in list1:\n z = (c - i)\n k = index(list1,z)\n if k == True:\n # print(z,i)\n temp = 1\n break\n\nif temp == 0:\n print('NO')\nelse:\n print('YES')\n\n\n\n\n\n\n"}, {"source_code": "def binarySearch (arr, l, r, x): \n if r >= l: \n mid = int(l + (r - l)/2)\n if arr[mid] == x: \n return mid \n elif arr[mid] > x: \n return binarySearch(arr, l, mid-1, x) \n else: \n return binarySearch(arr, mid + 1, r, x) \n else: \n return -1\ndef b():\n number = int(input())\n a = [0]\n for i in range(1, (10**5)+1):\n a.append(a[i-1] + i)\n for i in range(1, (10**5)+1):\n if binarySearch(a, 0, len(a)-1, number-a[i]) != -1:\n print(\"Yes\")\n return\n \n print(\"No\")\nb()"}, {"source_code": "import math\nar = []\nb = int(input())\nn = math.sqrt(b)\n\ni = 1\nwhile(True):\n x = i * (i+1)//2\n if x >= n:\n break\n ar.append(x)\n i +=1\nm = 0\nfor i in ar:\n if n - i in ar:\n \n m+=1\n break\n\nif m>0:\n print('YES')\nelse:\n print('NO')\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\nfrom itertools import permutations\n\n\nimport bisect\n\nmod=10**9+7\n\ndef check(x):\n y=int(math.sqrt(8*x+1))\n\n return y*y==8*x+1\n\n#print(bisect.bisect_right([1,2,3],2))\n#print(bisect.bisect_left([1,2,3],2))\n\nn=I()\n\nfor k in range(int(math.sqrt(2*n))+10):\n if k*(k+1)//2<=n and check(n-k*(k+1)//2):\n print('YES')\n exit()\n\nprint('NO')\n \n\n"}, {"source_code": "h=set([x*(x+1)/2 for x in xrange(53334)])\nn=input()\nprint \"YES\"if ([n-i in h for i in h].count(1)>0)else\"NO\"\n"}, {"source_code": "from sys import *\ndef findn(t):\n sum = 0\n i=1\n while(sum<=t):\n sum=sum+i;\n i+=1;\n return (i-2)\nx=int(input())\nn=findn(x)\ndef sumt(n):\n sum=0\n i=1\n while(i<=n):\n sum+=i;\n i+=1;\n \n return sum;\n\ndef check(n):\n z=0\n i=1\n while(i0):\n \n if(s1+sumt(j)==x):\n \n z=1;\n print(\"YES\")\n break;\n \n j-=1\n if(z==1):\n break;\n \n i+=1\n return (z)\n \nif(not(check(n))):\n print(\"NO\");\n \n \n \n"}, {"source_code": "import math\nn=input()\nfor i in range(int(n**0.5)+1):\n\ta=((i*(i+1))/2.0)\n\tb=n-a\n\tc1=(-1+(1+8*b)**0.5)/2.0\n\tc2=(-1-(1+8*b)**0.5)/2.0\n\tif c1>0 and math.ceil(c1)==math.floor(c1):\n\t\tprint 'YES'\n\t\texit()\nprint 'NO'\n"}, {"source_code": "import math\nn=int(input())\ndef funky(n):\n x=int(math.sqrt(n))\n for i in range(x):\n y=(i*(i+1))//2\n k2=int(math.sqrt((n-y)*2))\n z=(k2*(k2+1))//2\n if y+z==n:\n return 'YES'\n \n return 'NO'\n \nprint(funky(n))"}, {"source_code": "n = int(input())\ntotal, num, c1, c2 = n * 2, 2, 2, 3\n\nwhile (c1 * c2 < total):\n num = c1 * c2\n c1 += 1\n c2 += 1\n\nc1, c2 = 1, 2\n\nwhile (num + (c1 * c2) < total):\n c1 += 1\n c2 += 1\nif num+(c1*c2)==total:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "n=int(input())\nl=[]\ns=int ((2*n)**.5)\nfor i in range(0,s):\n p=(i*(i+1))//2\n l.append(p)\nk=len(l)-1\ni=1\nfound=0\nwhile(k>i):\n if (l[i]+l[k]==n):\n found=1\n break\n elif(l[i]+l[k]n):\n k=k-1\n \nif (found==1):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import math\n# -*- coding: utf-8 -*-\n\n#\u001b$BF~NO$7$?$b$N$rBeF~\u001b(B\ninput_num = int(raw_input())\ntwi_num = input_num * 2\n\nans = \"NO\"\nfor i in range(1, int(math.sqrt(input_num+1))+1):\n\tif(ans == \"YES\"):\n\t\tbreak;\n\n\ttemp = twi_num - (i * (i+1))\n\n\tfor j in range(-1, 2):\n\t\tcheck = int(math.sqrt(temp)) + j\n\t\tif((check * (check+1)) + (i * (i+1))== twi_num):\n\t\t\tans = \"YES\"\n\nprint ans\n"}, {"source_code": "import math\ndef b_search(l,r,arr,x) :\n\n while(l<=r) :\n mid = (l+r)//2\n\n if xarr[mid] :\n \n l = mid+1 \n \n elif x==arr[mid] :\n \n return True \n \n return False\n\nn = int(input())\n\nN = math.sqrt(2*n)\n\narr = []\narr.append(0)\n\nfor i in range(1,int(N)+1) :\n \n arr.append(arr[i-1]+i)\n \n#print(arr)\n \nflag = 1\n \nfor i in range(int(N)) :\n if b_search(0,int(N),arr,n-arr[i]) :\n \n print(\"YES\")\n flag = 0\n break\n \nif flag :\n print(\"NO\")\n\n \n\n \n\n\n"}, {"source_code": "c = int(input())\nlist1 = []\n\nfor i in range(3000):\n\n z = ((i)*(i+1))//2\n\n list1.append(z)\n# for i in range(1000,2000):\n#\n# z = ((i)*(i+1))//2\n#\n# list1.append(z)\n\nhash = []\nfor i in list1:\n for j in list1:\n hash.append(i+j)\n\nif c in set(hash):\n print('YES')\nelse:\n print('NO')\n\n# for i in hash:\n# print(hash)\n"}, {"source_code": "a=set([(i+1)*i/2 for i in range(1<<16)])\nn=input()\nprint \"YES\"if[1 for i in a if n-i in a]else\"NO\""}, {"source_code": "from sys import stdin, stdout\nfrom math import sqrt\n\ndef isTriangular(n):\n t = int(sqrt(n))\n return n+n==(t+2)*(t+1)\n\nn = int(stdin.readline().strip())\n\nans = 'NO'\n\ni = 0\nwhile (i*(i+1)>>1) <= n:\n if isTriangular(n - (i*(i+1)>>1)):\n ans = 'YES'\n break\n i += 1\n\nprint(ans)\n"}, {"source_code": "import math\nn = int(input())\ni =int(math.sqrt(n))\nj=i\nres = 'N0'\nwhile i>0 & j0 and jn):\n i=i-1\nprint(p)"}, {"source_code": "from math import sqrt\nn=int(input())\ni=int(sqrt(n))\nj=i+1\np='NO'\nwhile(i>0 and jn):\n i=i-1\nprint(p)"}, {"source_code": "import math\n\ndef cool(n):\n if n==1:\n return \"NO\"\n if n==2:\n return \"YES\"\n for k1 in range(int(math.sqrt(n))):\n k2 = int(math.sqrt((n - (k1*(k1+1))/2)*2))\n if (k1*(k1+1))/2 + (k2*(k2+1))/2 == n:\n return\"YES\"\n break\n else:\n continue\n return \"NO\"\n \nnum = int(input())\nprint(cool(num))\n"}, {"source_code": "n = int(input())\ntop = int(((8*n-7)**.5-1)/2)\nflag = False\nfor m1 in range(1, top):\n m2 = int(((8*n + 2 - (2*m1+1) ** 2) ** .5 - 1)/2)\n if (2*m1 + 1) ** 2 + (2*m2 + 1) ** 2 == 8*n + 2:\n flag = True\n break\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n"}, {"source_code": "n = int(raw_input())\ntriangles = [i * (i + 1) / 2 for i in xrange(32000)]\ntriangles.remove(0)\ntriangles.sort()\n\nfor i in triangles:\n l = 0\n r = len(triangles) - 1\n while(l < r):\n mid = l + r >> 1\n if(i + triangles[mid] < n):\n l = mid + 1\n else:\n r = mid\n if(i + triangles[mid] == n):\n print 'YES'\n exit(0)\n \nprint 'NO'\n"}, {"source_code": "n = int(input())\ns = set()\nc = 0\nfor i in range(1,40000):\n a = i*(i+1)//2\n s.add(a)\nfor j in s:\n if n-j in s:\n c = c+1\n print('YES')\n exit()\nprint('NO')\n"}, {"source_code": "n=int(input())\nx=set((i*(i+1))//2 for i in range(45000))\np=x.copy()\nf=0\nfor i in x:\n if abs(i-n) in x:\n f=1\n break\n else:\n pass\nif f==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "a=set([(i+1)*i/2 for i in range(1<<16)])\nn=input()\nprint \"YES\"if[1 for i in a if n-i in a]else\"NO\""}, {"source_code": "n= int(input())\nimport math\nm= math.sqrt(n)\na= set([k*(k+1)//2 for k in range(1, int(2*m))])\nprint(a)\nfor i in a:\n if n-i in a:\n print('YES')\n exit()\n\nprint('NO')"}, {"source_code": "import math\nn=int(input())\nx=math.sqrt(n)\nl=x\nr=x+1\nfirst=0\nwhile(l>0):\n\tif((l*(l+1) + r*(r+1))> 2*n):\n\t\tl-=1\n\telif((l*(l+1) + r*(r+1))< 2*n):\n\t\tr+=1\n\telse:\n\t\tfirst=1\n\t\tprint \"YES\"\n\t\tbreak\nif(first==0):\n\tprint \"NO\"\n"}, {"source_code": "number = int(raw_input())\nnum = list(map(int , [i * (i + 1) / 2 for i in range(1 , 10001)]))\nvis = {}\nok = True\nfor i in num:\n vis[i] = 1\nfor i in num:\n if i > number:\n ok = False\n break\n else:\n if vis.get(number - i) == 1:\n ok = True\n break\nif ok == True:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "h=set([x*(x+1)/2 for x in xrange(33334)])\nn=input()\nprint \"YES\"if ([n-i in h for i in h].count(1)>0)else\"NO\"\n"}, {"source_code": "import math\ndef funky(n):\n a=False\n b=math.sqrt(n) \n for i in range(int(b)):\n if (i*(i+1))//2==n:\n a=True\n break\n return a\nx=int(input()) \na=\"NO\"\nfor i in range((x//2)+1):\n if funky(i) and funky(x-i):\n a='YES'\n break\nprint(a) \n \n \n \n \n \n \n \n \n "}, {"source_code": "l = set([i*(i+1)//2 for i in range(100001)])\nn = int(input())\na = False\nfor i in l:\n if n-i in l :\n a = True\n break\nif a is True :\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "n = int(raw_input())\n\ntriangle = set()\nfor i in range(1,50000):\n triangle.add((i * (i+1))/2)\n\nfor i in triangle:\n if i > n: break\n if n-i in triangle:\n print \"YES\"\n quit()\n\nprint \"NO\"\n"}, {"source_code": "def binarysearch(ar,l,r,x):\n\tif r >= l:\n\t\tmid = l + (r-l)//2\n\t\tif ar[mid] == x:\n\t\t\treturn mid\n\t\telif ar[mid] < x:\n\t\t\treturn binarysearch(ar,mid+1,r,x)\n\t\telse:\n\t\t\treturn binarysearch(ar,l,mid-1,x)\t\n\treturn -1\t\t\t\ndef funky(n):\n\ta = (int((2*n)**(.5))+int(2))\n\tar = []\n\tfor i in range(1,a):\n\t\tk = int(i*(i+1)/2)\n\t\tar.append(k)\n\treturn ar\t\ndef CoolestNum(ar,l,r,x):\n\tb = binarysearch(ar,l,r,x//2)\n\tif b != -1:\n\t\treturn \"YES\"\n\telse:\t\t\n\t\tg = len(ar)\t\n\t\tfor i in range(g-1,-1,-1):\n\t\t\tif ar[i] > x//2:\n\t\t\t\tdiff = x - ar[i]\n\t\t\t\tterm = binarysearch(ar,0,g-1,diff)\n\t\t\t\tif term != -1:\n\t\t\t\t\treturn \"YES\"\n\treturn \"NO\"\t\t\t\nn = int(input())\nar = funky(n)\nq = len(ar)\nprint(CoolestNum(ar,0,q-1,n))\n"}, {"source_code": "n= int(input())\nimport math\nm= math.sqrt(n)\na= set([k*(k+1)//2 for k in range(1, int(2*m))])\nprint(a)\nfor i in a:\n if n-i in a:\n print('YES')\n exit()\n\nprint('NO')"}, {"source_code": "import math\n\nn = int(input())\na = 1\nb = 1\nc = -(2*n)\nd = (b**2) - (4*a*c)\nsol = (-b+math.sqrt(d))//(2*a)\nrem = n - ((sol*(sol+1))//2)\nc = -(2*rem)\nd = (b**2) - (4*a*c)\nsol = (-b+math.sqrt(d))//(2*a)\nrem = rem - ((sol*(sol+1))//2)\nif rem == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(raw_input())*2\nv = set([x*(x+1) for x in xrange(1,40000)])\nprint 'YES' if len([x for x in v if n-x in v]) else 'NO'\n"}, {"source_code": "t = set([x*(x+1)/2 for x in range(1,int(31800)+1)])\nn=256#input()\nfor i in t:\n\tif n-i in t:\n\t\tprint 'Yes'\n\t\texit(0)\n\nprint 'No'"}, {"source_code": "def binarysearch(ar,l,r,x):\n\tif r >= l:\n\t\tmid = l + (r-l)//2\n\t\tif ar[mid] == x:\n\t\t\treturn mid\n\t\telif ar[mid] < x:\n\t\t\treturn binarysearch(ar,mid+1,r,x)\n\t\telse:\n\t\t\treturn binarysearch(ar,l,mid-1,x)\t\n\treturn -1\t\t\t\ndef funky(n):\n\ta = (int((2*n)**(.5))+int(2))\n\tar = []\n\tfor i in range(1,a):\n\t\tk = int(i*(i+1)/2)\n\t\tar.append(k)\n\treturn ar\t\ndef CoolestNum(ar,l,r,x):\n\tb = binarysearch(ar,l,r,x//2)\n\tif b != -1:\n\t\treturn \"YES\"\n\telse:\t\t\n\t\tg = len(ar)\t\n\t\tfor i in range(g-1,-1,-1):\n\t\t\tif ar[i] > x//2:\n\t\t\t\tdiff = x - ar[i]\n\t\t\t\tterm = binarysearch(ar,0,g-1,diff)\n\t\t\t\tif term != -1:\n\t\t\t\t\treturn \"YES\"\n\treturn \"NO\"\t\t\t\n\nn = 256\nar = funky(n)\nq = len(ar)\nprint(CoolestNum(ar,0,q-1,n))\n"}, {"source_code": "t = set(x*(x+1)/2 for x in range(int(45000)+1))\nn=input()\nfor i in t:\n if n-i in t:\n print 'Yes'\n exit(0)\n\nprint 'No'"}, {"source_code": "n = int(input())\nif n==1:\n print(\"NO\")\nelif n==2:\n print(\"YES\")\nelif n==3:\n print(\"NO\")\nelif n==4:\n print(\"YES\")\nelse:\n sqrt_n = int(n**(0.5))//1\n num = 2*(sqrt_n)\n l1 = []\n ismatched = False\n for i in range(1,num+1):\n val = (i*(i+1))//2\n val_2 = n - val\n if val_2>=0:\n discriminat = (1+8*val_2)**(0.5)\n if (int(discriminat))*(int(discriminat))==(1+8*val_2):\n val3 = (discriminat-1)//2\n if n==1:\n print(\"NO\")\n else:\n if int(val3*2)==discriminat-1:\n if int(val3)<=num:\n print(\"YES\")\n ismatched = True\n break\n if ismatched==False:\n print(\"NO\")"}, {"source_code": "c = int(input())\nlist1 = []\n\nfor i in range(3000):\n\n z = ((i)*(i+1))//2\n\n list1.append(z)\n# for i in range(1000,2000):\n#\n# z = ((i)*(i+1))//2\n#\n# list1.append(z)\n\nhash = []\nfor i in list1:\n for j in list1:\n hash.append(i+j)\n\nif c in set(hash):\n print('YES')\nelse:\n print('NO')\n\n# for i in hash:\n# print(hash)\n"}, {"source_code": "n=int(input())\nn=n*2\nfinal = 1\ncheck=[]\nroot=int(((4*(n-2) +1)**(0.5)-1)/2)\ni=1\nj=root\n# if n==4:\n# print(\"YES\")\n# final=0\n# if n==8:\n# print(\"YES\")\n# final=0\nif n==2:\n print(\"NO\")\n final=0\nwhile i= n and final==1:\n cong=j**2 + j\n check.append(cong)\n if (cong)==number :\n print('YES')\n final=0\n break\n else:\n j-=1\n i+=1\nif final==1 :\n print(\"NO\")\n\n\n\n"}, {"source_code": "n = int(input())\nm = 1\narr = []\nwhile(True):\n\tmm = (m*(m+1))//2\n\tif mm>n:\n\t\tbreak\n\tarr.append(mm)\n\tm+=1\n\nll = len(arr)\nflag = 0\nfor i in range(ll):\n\tcurr = arr[i]\n\treq = n-curr\n\tl = i+1\n\tr = ll-1\n\twhile(l<=r):\n\t\tmid = (l+r)//2\n\t\tif arr[mid]>=req:\n\t\t\tr = mid-1\n\t\telse:\n\t\t\tl = mid+1\n\tif i 1:\n M = (l + r) // 2\n if check(M):\n l = M\n else:\n r = M\n\nprint(l+1)\n"}, {"source_code": "#@author:LENOVO | 25-Jan-2017 | 11:37:20 PM\nimport sys\nn,m,k=map(int,input().split())\nans=1\nm-=n\nl=min(k-1,n-k)\nstep=1\nfor i in range(l):\n if m-step<0:\n print(ans)\n sys.exit(0)\n m-=step\n step+=2\n ans+=1\nwhile step pillow):\n end = mid - 1\n else:\n start = mid\n \nprint(start+1)"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\n\ndef Sum(cnt, x):\n return cnt * (x - 1 + (x - cnt )) // 2\ndef check(x):\n l = min(k - 1, (x - 1))\n r = min(n - k, (x - 1))\n cur = Sum(l, x) + Sum(r, x) + x\n return cur<= m\nL = -1\nR = 10 ** 20\nwhile R - L > 1:\n M = ( L + R) >> 1\n if check(M): L = M\n else: R = M\nprint(L + 1)"}, {"source_code": "# n=int(input())\n#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n#ls=list(map(int,input().split()))\n#for i in range(m):\n# cnt += (extra + k - 1) // k\n# n=int(input())\n#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n#ls=list(map(int,input().split()))\n#for i in range(m):\n#from sys import stdin\n#n=int(stdin.readline())\n#for _ in range(int(input())):\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##########################################################\ndef can(x):\n fr=k-1\n ba=n-k\n total=x\n if fr>0:\n if x>fr:\n total+=(x-fr)*fr+(fr-1)*fr//2\n else:\n total+=(x-1) * x // 2\n total+=fr-(x-1)\n if ba>0:\n if x > ba :\n total+=(x-ba)*ba+(ba-1)*ba//2\n else:\n total+=(x-1)*x//2\n total+=(ba-(x-1))\n #print(total)\n if total<=m:\n return True\n else:\n return False\nn,m,k= map(int, input().split())\nlow=1\nhigh=m-n+1\nans=-1\nwhile low<=high:\n mid=(low+high)//2\n #print(\"mid\",mid)\n if can(mid):\n ans=mid\n low=mid+1\n else:\n high=mid-1\nprint(ans)\n\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nm -= n\nd = 0\nk -= 1\nout = 1\nwhile m > 1 and d != max(k, n - k - 1):\n out += 1\n m -= 1\n left = min(d, k)\n right = min(d, n - k - 1)\n d += 1\n m -= left\n m -= right\nout += m // n\n\nprint(out)\n"}, {"source_code": "__author__ = 'zihaozhu'\nfrom sys import stdin\n\ndef summation(a,b):\n if a>b:\n return summation(b,a)\n return (b + a) * (b - a + 1)/2\n\nhobbits, pillow, frodo = map(int,stdin.readline().split())\n\n\nlo = 1\nhi = pillow\n\nmaxpossible = pillow-hobbits\n\nwhile lo maxpossible:\n hi = mid\n else:\n lo = mid +1\n\nprint(lo)\n\n\n\n\"\"\"\nif maxpossible<=2:\n print(maxpossible)\nelif hobbits == frodo and maxpossible-1<2:\n print(pillow)\nelif frodo == 1 and maxpossible-1<2:\n print(pillow)\n\nelse:\n\nif hobbits == 1 and frodo==hobbits:\n print(pillow)\nelif frodo!=1 and frodo!=hobbits:\n n = 0\n # 4 7 2\n # 3\n #4 9 2\n #2 3 2 2\n\n while (n*(n+1)/2) + (n*(n+1)/2) < maxpossible:\n n+=1\n if (n*(n+1)/2)+(n*(n+1)/2)>maxpossible:\n n-=1\n print(n)\n if (n*(n+1)/2)+(n*(n+1)/2)+(n+1) maxpossible:\n n-=1\n if (n*(n+1)/2)+(n+1)= critical:\n # print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n\n # return\n # else:\n # m -= 1\n # n -= 1\n\n def sn(a1, an, n):\n return (a1 + an) * n / 2\n\n a = max(k - 1, n - k)\n critical = ((2 * a - k + 2) * (k - 1) + (2 * a - n + k + 1) * (n - k)) / 2 + a + 1\n\n if m >= critical:\n print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n\n return\n\n m -= n\n k = min(k, n - k + 1)\n\n r = 0\n l = 10e+9\n\n while True:\n x = int((l + r) / 2)\n\n def s(z):\n f = min(k - 1, z - 1)\n return z + z * (z - 1) / 2 + (z - 1 + z - f) * f / 2\n\n s1 = s(x)\n s2 = s(x+1)\n\n if s1 <= m < s2:\n print x+1\n return\n elif s1 < m:\n r = x\n else:\n l = x\n\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\nimport math\n\nn,m,k = map(int,sys.stdin.readline().split())\n\nsm=1\nm-=n\narea=0\n\nleft=k-1\nright=n-k\n\nwhile m>0:\n if area>left and area>right:break\n sm+=1\n m-=1 \n area+=1\n if area>right:\n\tm-=right\n else:\n\tm-=area\n if area>left:\n\tm-=left\n else:\n\tm-=area\n\nsm+=m/n\nif m%n>0:sm+=1\nprint sm"}, {"source_code": "n, m, k = map(int, raw_input().split())\nm -= n\nf = 1\ndist = 0\ndef almohadas(pos, tope, dist):\n return 1 + min(dist,tope-pos)+min(dist,pos-1)\nwhile almohadas(k,n,dist) <= m and dist < max(n-k,k-1):\n m -= almohadas(k,n,dist)\n dist += 1\n f += 1\nf += m/n\nprint f"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Apr 3 10:37:54 2019\n\n@author: slappy\n\"\"\"\n\ndef _sum_n(n):\n return int((n * (n + 1)) // 2)\ndef _sum(p, k):\n return _sum_n(p) - (_sum_n(p - k) if p > k else p - k)\ndef _solve():\n n, m, k = map(int, input().split())\n low, high = 1, 2e9\n while low <= high:\n mid = int((low + high) // 2)\n sum = int(_sum(mid, k) + _sum(mid - 1, n - k))\n #print (mid, ' ', sum)\n if sum <= m:\n ans = mid\n low = mid + 1\n else:\n high = mid - 1\n return ans\nprint (int(_solve()))"}, {"source_code": "n,m,k= map(int,input().split())\ndef calc(x,n,k):\n k-=1\n r = n - k;\n k = min(k,x-1)\n r = min(r,x)\n return ((2*x - k -1)*k//2) + (((2*x - r + 1)*(r))//2)\ndef bsearch(l, r):\n if l > r:\n return r\n mid = (l + r) //2\n if calc(mid,n,k) <= m:\n return bsearch(mid + 1,r)\n return bsearch(l, mid - 1)\nfrod = 1;\nm -= n\nfrod += bsearch(0,1000000001)\nprint(frod)\n"}, {"source_code": "def f(a):\n sums1=0\n sums2=0\n if k >=a:\n sums1 = a*(a+1)//2\n sums1+=k-a\n else:\n sums1 = k*(a+a-k+1)//2\n \n sums3 =0\n sums4=0\n k1 = n-k+1\n if k1 >=a:\n sums2 = a*(a+1)//2\n sums2 +=k1-a\n else:\n sums2 = k1*(a+a-k1+1)//2 \n if sums1+sums2-a<=m:\n return True\n else:\n return False\nn,m,k = map(int,input().split())\nleft = 1\nright = 10**9+5\n\nwhile left+1!=right:\n mid = (left+right)//2\n if f(mid):\n left=mid\n else:\n right = mid\nif f(right):\n print(right)\nelse:\n print(left)"}, {"source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nr=n-k\nl=k-1\ns=max(l,r)+1\nif l>r:\n S=((1+l)*(l)//2)+((s-1+s-r)*r//2)\nelse:\n S=((1+r)*(r)//2)+((s-1+s-l)*l//2)\nS+=max(l,r)+1\nL,R=max(l,r),min(l,r)\ns1=s\ns2=1\nS1=n\nS2=S\nif S1==m:\n s=1\nelif S>m:\n while (S1!=S2) or (S2>m):\n S1=S2\n s=(s1+s2)//2 \n if Rm:\n s1=s\n elif S2 hobs:\n pilCount+=pillows//hobs\n break\n elif left < 1:\n pillows-=(right)\n elif right > hobs:\n pillows-=(hobs-left+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)\n\n\n\n\n"}, {"source_code": "#@author:LENOVO | 25-Jan-2017 | 11:37:20 PM\nimport sys\nn,m,k=map(int,input().split())\nans=1\nm-=n\nl=min(k-1,n-k)\nstep=1\nfor i in range(l):\n if m-step<0:\n print(ans)\n sys.exit(0)\n m-=step\n step+=2\n ans+=1\nwhile step k:\n x -= (mid - k) * (mid - k + 1)\n if mid > l:\n x -= (mid - l) * (mid - l + 1)\n if x > m:\n hi = mid\n else:\n lo = mid\n print(lo + 1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "\n\ndef check(n, m, k, r):\n a = r - k\n u = 0\n if a > 0:\n u += (a + r) * (k + 1) // 2\n else:\n u += r * (r + 1) // 2\n\n b = r - (n - 1 - k)\n v = 0\n if b > 0:\n v += (b + r) * (n - k) // 2\n else:\n v += r * (r + 1) // 2\n\n t = u + v - r\n return t <= m\n\nn, m, k = map(int, input().split())\nk -= 1\nm -= n\nINF = 10 ** 9 + 10\na = 0\nb = INF\nwhile b - a > 1:\n mid = (a + b) // 2\n if check(n, m, k, mid):\n a = mid\n else:\n b = mid\nres = 1 + a\nprint(res)\n"}, {"source_code": "hobbits_nr, pillows_nr, frodos_place = (int(x) for x in input().split())\n\npillows_nr = pillows_nr - hobbits_nr\nfrodos_pillows = 1\n\n# [left, right) -- it's a half-interval\nleft = frodos_place\nright = frodos_place + 1\n\nwhile pillows_nr >= right - left:\n pillows_nr -= right - left\n frodos_pillows += 1\n right += 1\n left += -1\n if right > hobbits_nr + 1:\n right = hobbits_nr + 1\n if left < 1:\n left = 1\n if left == 1 and right == hobbits_nr + 1:\n frodos_pillows += pillows_nr // hobbits_nr\n pillows_nr = pillows_nr % hobbits_nr\n# print(pillows_nr)\n# print(left, right)\nprint(frodos_pillows)\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/contest/760/problem/B\nYYYYYYYYYYNNNNNNNNN\n\n\nNNNNYYYYY : return left\nYYYYYYNNN : return right\n\"\"\"\n\nnum_people, m, k = map(int, raw_input().split())\n\ndef solve():\n\n\tlo = 1\n\thi = m + 1\n\n\twhile (lo + 1 < hi):\n\n\t\tmid = (lo + hi) / 2\n\t\tif (check(mid)):\n\t\t\tlo = mid\n\n\t\telse:\n\t\t\thi = mid \n\n\treturn lo\n\n\ndef check(mid):\n\t# import pdb; pdb.set_trace()\n\tnum_pills = mid\n\t\n\tpeople_left = k - 1\n\tpeople_right = num_people - k\n\n\tn = mid - 1\n\t\n\tif (people_left <= n):\n\t\tnum_pills += people_left * n - (people_left - 1) * (people_left) / 2\n\n\telse:\n\t\tnum_pills += n * n - (n - 1) * (n) / 2\n\t\tnum_pills += (people_left - n) * 1\n\n\tif (people_right <= n):\n\t\tnum_pills += people_right * n - (people_right - 1) * (people_right) / 2\n\telse:\n\t\tnum_pills += n * n - (n - 1) * (n) / 2\n\t\tnum_pills += (people_right - n) * 1\n\n\t# he_will_get1 = mid - 1\n\t# while (idx1 > 0):\n\t# \tprint 1\n\t# \tif (he_will_get1 <= 0): \n\t# \t\the_will_get1 = 1\n\t# \tnum_pills += he_will_get1\n\t# \the_will_get1 -= 1\n\t# \tidx1 -= 1\n\n\t# he_will_get2 = mid - 1\n\t# while (idx2 <= n):\n\t# \tprint idx2\n\t# \tif (he_will_get2 <= 0): \n\t# \t\the_will_get2 = 1\n\t# \tnum_pills += he_will_get2\n\t# \the_will_get2 -= 1\n\t# \tidx2 += 1\n\t\n\tif (num_pills > m):\n\t\treturn False\n\treturn True\n\n\nprint solve()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "R = lambda: map(int, input().split())\nn, p, k = R()\nl, r = 1, p\nwhile l < r:\n m = (l + r + 1) // 2\n cl = (m + max(1, m - k + 1)) * min(k, m) // 2 + max(k - m, 0)\n cr = (m + max(1, m - (n - k))) * min(n - k + 1, m) // 2 + max(n - k + 1 - m, 0)\n if cl + cr - m <= p:\n l = m\n else:\n r = m - 1\nprint(l)"}, {"source_code": "#import math\nn,m,k = map(int,raw_input().split())\nm = m-n\nd = 0\nk -=1\nans = 1\nwhile m>1 and d!=max(k,n-k-1):\n\tans+=1\n\tm-=1\n\tl = min(d,k)\n\tr = min(d,n-k-1)\n\td+=1\n\tm-=l\n\tm-=r\nans +=m/n\nprint ans\n\n\n\n\n"}, {"source_code": "n, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\n\nm = m - n\nk = k - 1\ndef verif(n, m, k, r):\n a = r-k\n b = r - (n - 1) + k\n if a > 0:\n u = (r - a + 1) * (a + r) // 2\n else:\n u = r * (r + 1) // 2\n if b > 0:\n v = (r - b + 1) * (b + r) // 2\n else:\n v = r * (r + 1) // 2\n t = u + v - r\n return t <= m\n\nA = 0\nB = 10**10\nwhile B - A > 1:\n r = (A + B) // 2\n if verif(n, m, k, r):\n A = r\n else:\n B = r\nres = A + 1\nprint(res)"}, {"source_code": "n,m,k= map(int,input().split())\ndef calc(x,n,k):\n k-=1\n r = n - k;\n k = min(k,x-1)\n r = min(r,x)\n return ((2*x - k -1)*k//2) + (((2*x - r + 1)*(r))//2)\ndef bsearch(l, r):\n if l > r:\n return r\n mid = (l + r) //2\n if calc(mid,n,k) <= m:\n return bsearch(mid + 1,r)\n return bsearch(l, mid - 1)\nfrod = 1;\nm -= n\nfrod += bsearch(0,1000000001)\nprint(frod)\n"}, {"source_code": "import sys\n\ndef is_able(n, m, k, mid):\n res = 0\n\n if k < mid:\n res += (mid + mid - k + 1) * k // 2\n else:\n res += mid * (mid + 1) // 2 + k - mid\n\n right = n - k + 1\n if right < mid:\n res += (mid + mid - right + 1) * right // 2\n else:\n res += mid * (mid + 1) // 2 + right - mid\n\n res -= mid\n\n return True if res <= m else False\n\nn, m, k = map(int, input().split())\nbtm = 1\ntop = m + 1\n\nwhile top - btm > 1:\n mid = (top + btm) // 2\n\n if is_able(n, m, k, mid):\n btm = mid\n else:\n top = mid\n\nans = btm\n\nprint(ans)"}, {"source_code": "n,m,k=map(int,input().split())\nm-=n\nl,u,x=k,k,1\nwhile m>0 and (u1):\n x+=1\n m-=(u-l+1)\n if l>1: l-=1\n if u r:\n\t\treturn 0\n\tdelta = 0\n\tif l <= 0:\n\t\tdelta = abs(l) + 1\n\t\tl = 1\n\n\t# print(l, r, __sum(r) - __sum(l - 1))\n\treturn __sum(r) - __sum(l - 1) + delta\n\n\n\nleft = 1\nright = int(1e9) + 2\nwhile right - left > 1:\n\tmid = (left + right) // 2\n\tsub = _sum(mid - k + 1, mid) + _sum(mid - (n - k), mid - 1)\n\tif sub <= m:\n\t\tleft = mid\n\telse:\n\t\tright = mid\n\nprint(left)\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,random\n\n# read input\nn, m, k = map(int, input().split())\n\n# n, m, k = 3, 10, 3\n# n, m, k = 100000000, 200000000, 54345\n\nr = m - n\n\nans = 1\n\np = k - 1\nq = n - k\n\n# print(r, p, q)\n\ndef cost(i, p):\n\tj = min(p, i)\n\tc = j*i - j*(j+1)/2\n\treturn int(c)\n\nr0 = r\nle = 0\nri = r0\nif(r > 0):\n\ti = le\n\twhile(abs(le - ri) > 1):\n\t\tc = i + cost(i, p) + cost(i, q)\n\t\tr0 = r - c\n\t\t# print(c, r0, le, ri)\n\t\tif(r0 >= 0):\n\t\t\tle = i\n\t\telse:\n\t\t\tri = i\n\t\ti = (le + ri)//2 \n\t\n\tc1 = ri + cost(ri, p) + cost(ri, q)\n\tr0 = r - c1\n\tif(r0 >= 0):\n\t\tans += ri\n\telse:\n\t\tans += le\n\t\n\tprint(ans)\nelse:\n\tprint(ans)"}, {"source_code": "from sys import stdin, stdout\n\nn, m, k = map(int, stdin.readline().split())\n\nleft = k - 1\nright = n - k\nl = 1\nr = m + 1\n\nwhile r - l > 1:\n mid = (r + l) // 2\n cnt = mid\n \n if mid > left:\n cnt += (2 * mid - 1 - left) * left // 2\n else:\n cnt += mid * (mid - 1) // 2 + left - (mid - 1)\n \n if mid > right:\n cnt += (2 * mid - 1 - right) * right // 2\n else:\n cnt += mid * (mid - 1) // 2 + right - (mid - 1)\n \n if cnt <= m:\n l = mid\n else:\n r = mid\n\nstdout.write(str(l))"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\n\ndef valid(x):\n a = min(k - 1, x - 1)\n b = min(n - k, x - 1)\n s1 = a * (x - 1 + x - a) // 2\n s2 = b * (x - 1 + x - b) // 2\n return s1 + s2 + x <= m\n\nl, r = 0, (1<<62)\nwhile r > l+1:\n mid = l + r >> 1\n if valid(mid):\n l = mid\n else:\n r = mid\nprint(l+1)\n"}, {"source_code": "def v(ln, mx):\n return mx * (mx + 1) // 2 - (0 if ln > mx else (mx - ln) * (mx - ln + 1) // 2) + max(0, ln - mx)\n\ndef ok(n, m, k, val):\n return val + v(k - 1, val - 1) + v(n - k, val - 1) <= m\n\n\nn, m, k = map(int, input().split())\nl = -1\nr = 10 ** 10\nwhile l + 1 != r:\n md = (l + r) // 2\n if ok(n, m, k, md):\n l = md\n else:\n r = md\nprint(l)"}, {"source_code": "n,m,k=[int(x) for x in raw_input().split(' ')]\ndef predicate ( item) :\n left=m-item\n l=item-1\n r=item-1\n k1=k-1\n k2=n-k\n if l>=k1 :\n s1=(l*(l+1))/2 - ((l-k1)*(l-k1+1))/2\n else :\n s1=(l*(l+1)/2) + k1-l\n if r>=k2 :\n s2=(r*(r+1))/2 - ((r-k2)*(r-k2+1))/2\n else :\n s2=(r*(r+1)/2) + k2-r\n s1=s1+s2\n if left-s1 >=0 :\n return True\n else :\n return False\ndef bs (l,u) :\n while (u>=l) :\n mid=(l+u)/2\n if predicate(mid)==True :\n l=mid+1\n else :\n u=mid-1\n return u\nprint bs(1,m)"}, {"source_code": "n, m, k = map(int, input().split())\n\nmin_delta = min(k - 1, n - k)\nmax_delta = max(k - 1, n - k)\n\ntop = ((k - 1) * k + (n - k) * (n - k + 1)) // 2 + (max_delta - min_delta) * min_delta + max_delta + 1\n\ndef get_level(n, k, level):\n\treturn 1 + min(level, k - 1) + min(level, n - k)\n\nif top <= m:\n\tprint(max_delta + 1 + (m - top) // n)\nelse:\n\tadd = m - n\n\tcurr_level = 0\n\twhile add >= get_level(n, k, curr_level):\n\t\tadd -= get_level(n, k, curr_level)\n\t\tcurr_level += 1\n\tprint(curr_level + 1)\n\n\n"}, {"source_code": "n, m, k = map(int, input().split())\nl = 1\nr = m + 1\ns = 0\nf = 0\nwhile (r - l > 1):\n x = (l + r) // 2\n if x - 1 < k - 1:\n f = x * (x - 1) // 2 + ((k - 1) - (x - 1))\n else:\n f = ((x - 1) - (k - 2) + (x - 1)) * (k - 1) // 2\n if f + x > m:\n s = 0\n elif x - 1 >= n - k:\n s = (n - k) * ((x - 1) + (x - 1) - (n - k - 1)) // 2\n else:\n s = x * (x - 1) // 2 + (n - k) - (x - 1)\n if f + s + x <= m:\n l = x\n else:\n r = x\nprint(l)"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\ndef Sum(cnt, x):\n return cnt * (x - 1 + (x - cnt)) // 2\ndef check(x):\n l = min(k - 1, (x - 1))\n r = min(n - k, (x - 1))\n cur = Sum(l, x) + Sum(r, x) + x\n return cur <= m\nL = -1 \nR = 10 ** 20\nwhile R - L > 1:\n M = (L + R) >> 1\n if check(M): L = M\n else: R = M\nprint(L + 1)"}, {"source_code": "\n\ndef pillows_needed(height, width):\n if height > width:\n return height * (height + 1) // 2 - (height - width) * (height - width + 1) // 2\n else:\n return height * (height + 1) // 2 + (width - height)\n\nn, m, k = map(int, input().split())\n\n\na, b, c = 0, m, 0\n\nwhile a < b:\n c = (a + b + 1) // 2\n if m >= c + pillows_needed(c - 1, n - k) + pillows_needed(c - 1, k - 1):\n a = c\n else:\n b = c - 1\n\nprint(a)\n"}, {"source_code": "n, m, k = list(map(int, input().split()))\np = m - n\nmin_d, max_d = min(abs(n-k+1), k), max(abs(n-k+1), k)\ni = 1\nr = m+1\nl = 0\nwhile r - l > 1:\n i = (r + l) // 2\n min_dist = min_d-i\n max_dist = max_d-i\n min_summ = 0\n max_summ = 0\n if min_dist < 0:\n min_summ = (abs(min_dist)*(abs(min_dist)+1))\n if max_dist < 0:\n max_summ = (abs(max_dist)*(abs(max_dist)+1))\n summ = ((i*(i+1)) - i)*2 - min_summ - max_summ\n #if min_dist < 0 and max_dist < 0:\n # print()\n # exit()\n #if min_dist < 0 and max_dist < 0:\n #summ += i\n #print(min_summ, max_summ, (i*(i+1)-i))\n #print(i, summ, min_dist, max_dist)\n if summ > p*2:\n r = i\n else:\n l = i\n \nprint(r)\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = 0\n if p != 0:\n while True:\n if z + 1 < c:\n z0 = z**2\n else:\n z1 = (z * (z + 1)) // 2\n z2 = max(((n - k) * (z - 1 + z + k - n)) // 2, 0)\n z0 = z1 + z2\n if z0 > p:\n break\n z += 1\n return z\n else:\n return z + 1\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "import sys\nsys.setrecursionlimit(10000000)\nimport itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left\nimport heapq\nfrom collections import deque\nimport sys\n#codechef sucks!\n#codeforces sucks sucks!\n#me sucks sucks sucks\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 , m , k = get(int)\ndef solve(n,m,k, p):\n\ttot = 0\n\tif p > k-1:\n\t\ttot += (p * (p-1)) / 2 - ((p-k) * (p-k+1)) / 2\n\telse:\n\t\ttot += (p * (p-1)) / 2 + (k-1) - (p-1)\n\tif p > n-k:\n\t\ttot += (p * (p-1)) / 2 - ((p-(n-k)) * (p-(n-k)-1)) / 2\n\telse:\n\t\ttot += (p * (p-1)) / 2 + (n-k) - (p-1)\n\ttot += p\n\treturn tot <= m\n\nlow = 1 ; high = m\nans = 1\nwhile low <= high:\n\tmid = (low+high) >> 1\n\tif solve(n , m , k , mid):\n\t\tans = mid\n\t\tlow = mid + 1\n\telse:\n\t\thigh = mid - 1\nprint ans\n\n\n"}, {"source_code": "import sys\n\ndef sum_(a):\n return max(0, a * (a + 1) // 2)\n\ndef check(a):\n if a * n <= m:\n return 1\n a -= 1\n ans = n\n t1 = a - k + 1\n #print(a)\n if t1 >= 0:\n ans += sum_(a) - sum_(t1 - 1)\n else:\n ans += sum_(a)\n #print(ans)\n z = n - k + 1\n t2 = a - z + 1\n #print('ts', t2)\n if t2 >= 0:\n ans += sum_(a - 1) - sum_(t2 - 1)\n else:\n ans += sum_(a - 1)\n #print(ans)\n return (ans <= m)\n\ndef bins():\n l = 1\n r = m + 1\n while l + 1 != r:\n m1 = (l + r) // 2\n if check(m1):\n l = m1\n else:\n r = m1\n print(l)\n \nn, m, k = map(int, input().split())\n#print(check(2))\nbins()\n\n \n"}, {"source_code": "num_hobbits, num_pillows, frodo_pos = map(int, input().split())\nnum_pillows -= num_hobbits\n\nif num_pillows == 0:\n print(1)\nelif num_pillows <= 2:\n print(2)\nelse:\n left, right = frodo_pos - 1, num_hobbits - frodo_pos\n frodo_amt = 1\n\n def f(x):\n return 1 + min(x - 1, left) + min(x - 1, right)\n\n last_amt = -1\n while True:\n this_round_amt = f(frodo_amt)\n if this_round_amt == last_amt:\n print(frodo_amt + num_pillows // this_round_amt)\n break\n \n if this_round_amt > num_pillows:\n print(frodo_amt)\n break\n\n last_amt = this_round_amt\n num_pillows -= this_round_amt\n frodo_amt += 1\n\n # XXFXXX left = 2, right = 3\n # round 1 => give frodo 1. total -= 1. cum = 1 x = 1. - x\n # round 2 => give frodo 1. give left 1, give right 1. total -= 3. cum = 4 x = 2. - 1 - 1(x - 1) - 1(x - 1)\n # round 3 => give frodo, l, r, lx2, rx2 1. total -= 5. cum = 9 x = 3. - 1 - 1(x - 1) - 1(x - 1)\n # round 4 => give frodo, l, r, lx2, rx2, rx3 1. total -= 6. cum = 15 x = 4. - 1 - 1 * min(x - 1, left) - 1(x - 1)\n # round 5 => give frodo, l, r, lx2, rx2, rx3 1. total -= 6. cum = 21 x = 5. - 1 - 1 * min(x - 1, left) - 1 * min(x - 1, right)"}, {"source_code": "beds,pillows,frodo=map(int,input().split())\nflag=0\nif beds==pillows:\n flag=1\npillows=pillows-beds-1\nlayer=2\nwhile pillows>0:\n if beds==1:\n layer=pillows+2\n pillows=0\n break\n if frodo-1 1:\n M = ( L + R) >> 1\n if check(M): L = M\n else: R = M\nprint(L + 1)"}, {"source_code": "n,m,k= map(int,input().split())\ndef calc(x,n,k):\n k-=1\n r = n - k;\n k = min(k,x-1)\n r = min(r,x)\n return ((2*x - k -1)*k//2) + (((2*x - r + 1)*(r))//2)\ndef bsearch(l, r):\n if l > r:\n return r\n mid = (l + r) //2\n if calc(mid,n,k) <= m:\n return bsearch(mid + 1,r)\n return bsearch(l, mid - 1)\nfrod = 1;\nm -= n\nfrod += bsearch(0,1000000001)\nprint(frod)\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Jan 26 22:18:23 2017\n\n@author: USER PC\n\"\"\"\n\nn,m,k=input().split(\" \")\nn,m,k=int(n),int(m),int(k)\nans=1\nm-=n\na=0\nb=0\nc=a+b+1\nwhile m>=c:\n ans+=1\n m-=c\n if(a0:\n if area>left and area>right:break\n sm+=1\n m-=1 \n area+=1\n if area>right:\n\tm-=right\n else:\n\tm-=area\n if area>left:\n\tm-=left\n else:\n\tm-=area\n\nsm+=m/n\nif m%n>0:sm+=1\nprint sm"}, {"source_code": "numbers = map(int, raw_input().split())\nn = numbers[0]\nm = numbers[1]\nk = numbers[2]\n\ndef sum(n):\n\treturn (n*(n+1))/2\n\nlo = 1\nhi = m\nif( hi - lo < 5 ):\n\tfor i in range(hi, lo-1, -1):\n\t\tif k > i:\n\t\t\tleft = sum(i-1) + k - i\n\t\telse:\n\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\tif n - k > i:\n\t\t\tright = sum( i -1) + n - k - i + 1\n\t\telse:\n\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\t# print left,\" \",right,\" \",i,\" pillows required for \",i\n\t\tif( left + right + i <= m ):\n\t\t\tprint i\n\t\t\texit(0)\n\tprint \"Trouble\"\n\texit(1)\nwhile lo < hi:\n\tif( hi - lo < 5 ):\n\t\tfor i in range(hi, lo-1, -1):\n\t\t\tif k > i:\n\t\t\t\tleft = sum(i-1) + k - i\n\t\t\telse:\n\t\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\t\tif n - k > i:\n\t\t\t\tright = sum( i -1) + n - k - i + 1\n\t\t\telse:\n\t\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\t\t# print left,\" \",right,\" \",i,\" pillows required for \",i\n\t\t\tif( left + right + i <= m ):\n\t\t\t\tprint i\n\t\t\t\texit(0)\n\t\tprint \"Trouble\"\n\t\texit(1)\n\tmid = (lo + hi)/2\n\t# print lo, mid, hi\n\tif k > mid:\n\t\tleft = sum(mid-1) + k - mid\n\telse:\n\t\tleft = sum(mid - 1) - sum( mid - k)\n\tif n - k > mid:\n\t\tright = sum( mid -1) + n - k - mid + 1\n\telse:\n\t\tright = sum( mid - 1) - sum( mid - (n-k) - 1 )\n\n\tif left + right + mid <= m:\n\t\tlo = mid\n\telse:\n\t\thi = mid - 1\n"}, {"source_code": "beds,pillows,frodo=map(int,input().split())\nflag=0\nif beds==pillows:\n flag=1\npillows=pillows-beds-1\nlayer=2\nwhile pillows>0:\n if beds==1:\n layer=pillows+2\n pillows=0\n break\n if frodo-1= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + k - A\n\telse:\n\t\ts = A - k + 1\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\n\tkk = n - k \n\n\tif (kk) >= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + kk - (A-1)\n\telse:\n\t\ts = A - kk\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\tif up > m:\n\t\tdone = 1\n\t\tprint(A-1)\n\t\tbreak\n\n\nif done == 0:\n\n\tprint(m)"}, {"source_code": "\ndef read(type=int):\n return type(input())\n\n\ndef read_arr(type=int):\n return [type(token) for token in input().split()]\n\n\ndef runB():\n n, m, k = read_arr()\n ans = 1\n m -= n\n l, r = k, k\n # print(ans, m)\n while (r < n or l > 1) and m > 0:\n ans += 1\n m -= (r - l + 1)\n if l > 1:\n l -= 1\n if r < n:\n r += 1\n # print(ans, m)\n ans += (m // n)\n print(ans)\n\nrunB()"}, {"source_code": "def partSum(a, b):\n if a > b:return 0\n supp = 0\n if a <= 0:\n supp = -a + 1\n a = 1\n return supp + b * (b + 1) // 2 - (a - 1) * (a - 1 + 1) // 2\n\n\ndef f(v, l, r):\n return v + partSum(v - l, v - 1) + partSum(v - r, v - 1)\n \ndef valid(v, l, r):\n return (m - v) - partSum(v - l, v - 1) - partSum(v - r, v - 1) >= 0\n\nn, m, k = [int(item) for item in input().split()]\n\nl = k - 1\nr = n - k\n\na, b = 1, m\n\nwhile a <= b:\n bound = (a + b) // 2\n if valid(bound, l, r):\n if not valid(bound + 1, l, r):\n break\n a = bound + 1\n else:\n if valid(bound - 1, l, r):\n bound -= 1\n break\n b = bound - 1\n\na, b = 1, bound\n#print(bound)\nwhile a <= b:\n mi = (a + b) // 2\n if f(mi, l, r) > m:\n b = mi - 1\n elif f(mi, l, r) < m:\n a = mi + 1\n else:\n print(mi)\n break\n #print(a,b, m)\nelse:\n if f(mi, l, r) <= m : print(mi)\n else:print(mi - 1)"}, {"source_code": "__author__ = 'zihaozhu'\nfrom sys import stdin\n\ndef summation(a,b):\n if a>b:\n return summation(b,a)\n return (b + a) * (b - a + 1)/2\n\nhobbits, pillow, frodo = map(int,stdin.readline().split())\n\n\nlo = 1\nhi = pillow\n\nmaxpossible = pillow-hobbits\n\nwhile lo maxpossible:\n hi = mid\n else:\n lo = mid +1\n\nprint(lo)\n\n\n\n\"\"\"\nif maxpossible<=2:\n print(maxpossible)\nelif hobbits == frodo and maxpossible-1<2:\n print(pillow)\nelif frodo == 1 and maxpossible-1<2:\n print(pillow)\n\nelse:\n\nif hobbits == 1 and frodo==hobbits:\n print(pillow)\nelif frodo!=1 and frodo!=hobbits:\n n = 0\n # 4 7 2\n # 3\n #4 9 2\n #2 3 2 2\n\n while (n*(n+1)/2) + (n*(n+1)/2) < maxpossible:\n n+=1\n if (n*(n+1)/2)+(n*(n+1)/2)>maxpossible:\n n-=1\n print(n)\n if (n*(n+1)/2)+(n*(n+1)/2)+(n+1) maxpossible:\n n-=1\n if (n*(n+1)/2)+(n+1) k:\n ans -= ((mid - k) * (mid - k + 1)) // 2\n else:\n ans += (k - mid)\n ans += (mid * (mid - 1)) // 2\n if n - k > mid - 1:\n ans += 1 * (n - k - mid + 1)\n else:\n t = mid - 1 - n + k\n ans -= (t * (t + 1)) // 2\n return ans <= m\n\nwhile i < j:\n mid = (i + j + 1) // 2\n if check(mid):\n i = mid\n else:\n j = mid - 1\n\nprint(j)"}, {"source_code": "n, m, k = map(int, input().split())\nkk1 = min(k-1, n-k)\nkk2 = n - kk1 - 1\nmm = m - n\ns1 = (kk1 + 1)**2\nif s1 >= mm:\n res = 1 + int(mm**0.5)\nelse:\n res = 1 + (kk1 + 1)\n mmm = mm - s1 \n a = 2*(kk1 + 1)\n b = kk2-kk1 - 1\n s2 = a*b + b*(b-1)//2\n if s2 >= mmm:\n res += int(-(2*a-1)/2 + (((2*a-1)/2)**2 + 2*mmm)**0.5)\n else:\n mmmm = mmm - s2 \n res += b + mmmm//n\nprint(res) "}, {"source_code": "# from itertools import combinations\n# from bisect import bisect_right\n# from functools import *\n# from collections import Counter\n\nI = lambda: list(map(int, input().split()))\nn, m, k = I()\nl, r = 1, m + 1\nonLeft, onRight = k - 1, n - k\nwhile l < r - 1:\n amount = (l + r) >> 1\n s = amount\n for neighbors in [onLeft, onRight]:\n if neighbors > amount - 1:\n s += (amount - 1) * amount // 2 + neighbors - amount + 1\n else:\n s += (amount - neighbors + amount - 1) * neighbors // 2\n if s <= m:\n l = amount\n else:\n r = amount\nprint(l)"}, {"source_code": "n,m,k = map(int,raw_input().split())\ndef res(p):\n global n,m,k\n ans = 0\n if k-1 > p-1:\n ans += p*(p-1)/2 + (k-p)\n else:\n ans += (k-1)*(2*p-k)/2\n if n-k > p-1:\n ans += p*(p-1)/2 + (n-k-p+1)\n else:\n ans += (n-k)*(2*p + k - n - 1)/2\n return ans + p\nhi = m \nlo = 1\nwhile lo < hi :\n mid = lo + (hi - lo + 1)/2\n if res(mid) > m:\n hi = mid - 1\n else:\n lo = mid \nprint lo \n"}, {"source_code": "n,m,k=map(int,input().split())\nans=1\nm-=n\nosn=0\nwhile m>1:\n if osn==max(k-1,n-k):break\n ans+=1\n m-=1\n osnl,osnr=min(k-1,osn),min(n-k,osn)\n osn+=1\n m-=(osnl+osnr)\nans+=m//n\nprint(ans) \n"}, {"source_code": "def tri (x):\n\treturn (x*(x+1))//2\ndef C( x , k , n ):\n\tret =0\n\tif x==0:\n\t\treturn x\n\tif x<=k:\n\t\tret = ret+tri(x-1) + (k-x)\n\telse:\n\t\trem = x-k\n\t\tret = ret+tri(x-1)-tri(rem)\n\tr=n-k+1\n\tif x<=r:\n\t\tret=ret+tri(x)+(r-x)\n\telse:\n\t\trem=x-r\n\t\tret=ret+tri(x)-tri(rem)\n\treturn ret\n\n\nn,m,k = map( int,input().split() )\nans=0\nhi=m\nlo=0\n\nwhile lo<=hi:\n\tmid = (hi+lo)//2\n\tif C(mid,k,n) <=m :\n\t\tans=mid\n\t\tlo=mid+1\n\telse:\n\t\thi=mid-1\n\nprint (ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n"}, {"source_code": "n, m, k = map(int, raw_input().split())\nm -= n\n\ndef sn(a1, d, r):\n return ((2*a1 + (d-1)*r) * d) / 2\n\nres = 0\na = 0\nb = m\n\nwhile a <= b:\n x = (a+b)/2\n req = x + sn(x-1, min(k-1, x), -1) + sn(x-1, min(n-k, x), -1)\n\n if req <= m:\n res = max(res, x)\n a = x+1\n else:\n b = x-1\n\nprint res+1\n"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\nk -= 1\nfrodo = 1\nleft = right = k\n\nwhile True:\n needed = right - left + 1\n if m >= needed:\n frodo += 1\n m -= needed\n left = max(0, left-1)\n right = min(n-1, right+1)\n if left == 0 and right == n-1:\n frodo += m//n\n break\n else:\n break\n\nprint(frodo)\n"}, {"source_code": "n, m, k = map(int, raw_input().split())\nm -= n\n\ndef sn(a1, d, r):\n return ((2*a1 + (d-1)*r) * d) / 2\n\nres = 0\na = 0\nb = m\n\nwhile a <= b:\n x = (a+b)/2\n req = x + sn(x-1, min(k-1, x), -1) + sn(x-1, min(n-k, x), -1)\n\n if req <= m:\n res = max(res, x)\n a = x+1\n else:\n b = x-1\n\nprint res+1\n"}, {"source_code": "# n=int(input())\n#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n#ls=list(map(int,input().split()))\n#for i in range(m):\n# cnt += (extra + k - 1) // k\n# n=int(input())\n#q.sort(key=lambda x:((x[1]-x[0]),-x[0]))\n# n,k=map(int,input().split())\n# arr=list(map(int,input().split()))\n#ls=list(map(int,input().split()))\n#for i in range(m):\n#from sys import stdin\n#n=int(stdin.readline())\n#for _ in range(int(input())):\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##########################################################\ndef can(x):\n fr=k-1\n ba=n-k\n total=x\n if fr>0:\n if x>fr:\n total+=(x-fr)*fr+(fr-1)*fr//2\n else:\n total+=(x-1) * x // 2\n total+=fr-(x-1)\n if ba>0:\n if x > ba :\n total+=(x-ba)*ba+(ba-1)*ba//2\n else:\n total+=(x-1)*x//2\n total+=(ba-(x-1))\n #print(total)\n if total<=m:\n return True\n else:\n return False\nn,m,k= map(int, input().split())\nlow=1\nhigh=m-n+1\nans=-1\nwhile low<=high:\n mid=(low+high)//2\n #print(\"mid\",mid)\n if can(mid):\n ans=mid\n low=mid+1\n else:\n high=mid-1\nprint(ans)\n\n"}, {"source_code": "n , k , my = map( int , input().split() )\n\ndef distribute( l,r,c ):\n if l > r :\n return 0\n x = r-l+1;\n if x > c :\n x = c\n return ( (x*(x+1)) >> 1 ) + ((c-x)*x)\n\ndef givable( cc ):\n return distribute( 1 , my-1 , cc-1 ) + distribute( my+1, n , cc-1 ) + cc <= k\n\nAns , k = ( 1 , k - n )\nhigh, low, mid , aro = ( k , 0 , -1 , 0 )\nwhile( low <= high ) :\n mid = (high + low) >> 1;\n if givable(mid) == True :\n Ans = mid + 1\n low = mid+1\n else :\n high = mid-1\n\nprint( Ans )"}, {"source_code": "def okay(n, m, k, v):\n total = n * v\n if k <= v:\n total -= k * (k-1) // 2\n else:\n total -= v * (v-1) // 2\n total -= (k-v) * (v-1)\n if n-k+1 <= v:\n total -= (n-k) * (n-k+1) // 2\n else:\n total -= v * (v-1) // 2\n total -= (n-k-v+1) * (v-1)\n return m >= total\n\nn, m, k = map(int, raw_input().split())\nans = 1\nlow, up = 1, 1000000000\nwhile low <= up:\n mid = (low + up) // 2\n if okay(n, m, k, mid):\n ans, low = mid, mid + 1\n else:\n up = mid - 1\n\nprint ans"}, {"source_code": "def pillows(n, k, h):\n p = (h - 1) * h + h\n left = 0\n if k < h:\n left = (h - k) * (h - k + 1) // 2\n right = 0\n if n - k + 1 < h:\n right = (h - (n - k + 1)) * (h - (n - k + 1) + 1) // 2\n\n return p - left - right\n\n\ndef solve(n, m, k):\n p = m - n\n if p == 0:\n return 1\n\n l = 0\n r = 10**10\n while r - l >= 2:\n m = (l + r) // 2\n mp = pillows(n, k, m)\n if mp > p:\n r = m\n else:\n l = m\n\n return l + 1\n\nif False:\n assert pillows(1, 1, 10) == 10\n assert solve(1, 10, 1) == 10\n assert solve(5, 5, 1) == 1\n assert solve(5, 5, 5) == 1\n assert solve(5, 5, 3) == 1\n assert solve(5, 6, 2) == 2\n assert solve(5, 6, 1) == 2\n assert solve(5, 6, 5) == 2\n assert solve(5, 7, 5) == 2\n assert solve(5, 7, 1) == 2\n assert solve(5, 8, 1) == 3\n assert solve(5, 8, 5) == 3\n assert solve(5, 8, 4) == 2\n assert solve(5, 8, 2) == 2\n assert solve(5, 8, 3) == 2\n assert solve(5, 9, 3) == 3\n assert solve(5, 9, 2) == 3\n assert solve(5, 9, 1) == 3\n\nelse:\n n, m, k = map(int, input().split())\n print(solve(n, m, k))\n"}, {"source_code": "def tri (x):\n\treturn (x*(x+1))//2\ndef C( x , k , n ):\n\tret =0\n\tif x==0:\n\t\treturn x\n\tif x<=k:\n\t\tret = ret+tri(x-1) + (k-x)\n\telse:\n\t\trem = x-k\n\t\tret = ret+tri(x-1)-tri(rem)\n\tr=n-k+1\n\tif x<=r:\n\t\tret=ret+tri(x)+(r-x)\n\telse:\n\t\trem=x-r\n\t\tret=ret+tri(x)-tri(rem)\n\treturn ret\n\n\nn,m,k = map( int,input().split() )\nans=0\nhi=m\nlo=0\n\nwhile lo<=hi:\n\tmid = (hi+lo)//2\n\tif C(mid,k,n) <=m :\n\t\tans=mid\n\t\tlo=mid+1\n\telse:\n\t\thi=mid-1\n\nprint (ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n"}, {"source_code": "def v(length, start):\n W = start * (start + 1) // 2\n t = max(0, start - length)\n T = t * (t + 1) // 2\n return W - T + max(0, length - start)\n \n\ndef check(p):\n return p + v(k - 1, p - 1) + v(n - k, p - 1) <= m\n\nn, m, k = map(int, input().split())\nl = 0\nr = 10 ** 100\nwhile r - l > 1:\n mid = (l + r) // 2\n if not check(mid):\n r = mid\n else:\n l = mid\nprint(l)"}, {"source_code": "n,m,k=map(int,raw_input().split())\nm-=n\nd=0\nk-=1\nans=1\nwhile m>1 and d!=max(k,n-k-1):\n ans+=1\n m-=1\n l=min(d,k)\n r=min(d,n-k-1)\n d+=1\n m-=l\n m-=r\nans+=m/n\nprint ans\n"}, {"source_code": "n, m, k = input().split()\nn = int(n)\nm = int(m)\nk = int(k)\n\nm = m - n\nk = k - 1\ndef verif(n, m, k, r):\n a = r-k\n b = r - (n - 1) + k\n if a > 0:\n u = (r - a + 1) * (a + r) // 2\n else:\n u = r * (r + 1) // 2\n if b > 0:\n v = (r - b + 1) * (b + r) // 2\n else:\n v = r * (r + 1) // 2\n t = u + v - r\n return t <= m\n\nA = 0\nB = 10**10\nwhile B - A > 1:\n r = (A + B) // 2\n if verif(n, m, k, r):\n A = r\n else:\n B = r\nres = A + 1\nprint(res)"}, {"source_code": "import sys\nsys.setrecursionlimit(99999999)\ni = lambda: sys.stdin.readline().strip()\nii = lambda: map(int, i().split())\n\ndef pillows(x, k):\n if x >= k: return x*(x+1)/2 - (x-k)*(x-k+1)/2\n else: return x*(x+1)/2+k-x\n\ndef check(n, m, k, x):\n needed = pillows(x, k) + pillows(x-1, n-k)\n return needed <= m\n\ndef src(n, m, k, a, b):\n h = (a+b) / 2\n if a == b: return a\n kk = check(n, m, k, h+1)\n if kk:\n return src(n, m, k, h+1, b)\n else:\n return src(n, m, k, a, h)\nn, m, k = ii()\nprint src(n, m, k, 1, m)"}, {"source_code": "n, m, k = map(int, raw_input().split())\n\nans = 1\nm = m - n\nmL = k -1\nmR = n - k\n\nL = 0\nR = 0\n\nwhile m > 0:\n\tif L + R + 1 == n:\n\t\tbreak;\n\t\n\tm-=(L + R + 1)\n\tif m >= 0: ans += 1\n\t# print L, R, m\n\t\n\tif L < mL: L+=1\n\tif R < mR: R+=1\n\n\nif m > 0: ans += m/n\nprint ans"}, {"source_code": "##n = int(input())\n##a = list(map(int, input().split()))\n##print(' '.join(map(str, res)))\n\n[n, m, k] = list(map(int, input().split()))\n\nm -= n\nlo = 0\nhi = m\nwhile lo < hi:\n x = (lo+hi+1)//2 \n\n need = x*x\n if k < x:\n need -= (x-k)*(x-k+1)//2\n if k+x > n:\n need -= (k+x-1-n)*(k+x-n)//2\n\n if need <= m:\n lo = x\n else:\n hi = x-1\nprint(lo+1)"}, {"source_code": "beds,pillows,frodo=map(int,input().split())\nflag=0\nif beds==pillows:\n flag=1\npillows=pillows-beds-1\nlayer=2\nwhile pillows>0:\n if beds==1:\n layer=pillows+2\n pillows=0\n break\n if frodo-1= needed:\n frodo += 1\n m -= needed\n left = max(0, left-1)\n right = min(n-1, right+1)\n if left == 0 and right == n-1:\n frodo += m//n\n break\n else:\n break\n\nprint(frodo)\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = 0\n if p != 0:\n z = int(p ** (1/2))\n while True:\n if z + 1 < c:\n z0 = z**2\n else:\n z1 = (z * (z + 1)) // 2\n z2 = max(((n - k) * (z - 1 + z + k - n)) // 2, 0)\n z0 = z1 + z2\n if z0 > p:\n break\n z += 1\n return z\n else:\n return z + 1\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "n,m,k=map(int,input().split())\nm-=n\nf=1\nl=k-1\nr=n-k\np=1\nwhile m>=p:\n f+=1\n m-=p\n p+= (l>0)+(r>0)\n if l: l-=1\n if r: r-=1\n if l==r==0:\n f+=(m//p)\n break\nprint(f)"}, {"source_code": "def pil_add(height, div):\n add = height\n if height > div:\n add = div\n return add\n\n\nhobb, pillow, number = (int(i) for i in input().split())\n\ndiv_first = number\ndiv_last = hobb - number + 1\n\nother_pillow = pillow - hobb\n\nheight = 0\nheap_pil = 0\n\nright_flag = False\nleft_flag = False\n\nwhile heap_pil <= other_pillow:\n height += 1\n if not (right_flag and left_flag):\n\n right = pil_add(height, div_first)\n if right == div_first:\n right_flag = True\n\n left = pil_add(height, div_last)\n if left == div_last:\n left_flag = True\n\n heap_pil += right + left - 1\n else:\n other_pillow -= heap_pil\n height += int(other_pillow / hobb)\n break\n\nprint(height)"}, {"source_code": "def partSum(a, b):\n if a > b:return 0\n supp = 0\n if a <= 0:\n supp = -a + 1\n a = 1\n return supp + b * (b + 1) // 2 - (a - 1) * (a - 1 + 1) // 2\n\n\ndef f(v, l, r):\n return v + partSum(v - l, v - 1) + partSum(v - r, v - 1)\n \ndef valid(v, l, r):\n return (m - v) - partSum(v - l, v - 1) - partSum(v - r, v - 1) >= 0\n\nn, m, k = [int(item) for item in input().split()]\n\nl = k - 1\nr = n - k\n\na, b = 1, m\n\nwhile a <= b:\n bound = (a + b) // 2\n if valid(bound, l, r):\n if not valid(bound + 1, l, r):\n break\n a = bound + 1\n else:\n if valid(bound - 1, l, r):\n bound -= 1\n break\n b = bound - 1\n\na, b = 1, bound\n#print(bound)\nwhile a <= b:\n mi = (a + b) // 2\n if f(mi, l, r) > m:\n b = mi - 1\n elif f(mi, l, r) < m:\n a = mi + 1\n else:\n print(mi)\n break\n #print(a,b, m)\nelse:\n if f(mi, l, r) <= m : print(mi)\n else:print(mi - 1)"}, {"source_code": "def v(length, start):\n W = start * (start + 1) // 2\n t = max(0, start - length)\n T = t * (t + 1) // 2\n return W - T + max(0, length - start)\n \n\ndef check(p):\n return p + v(k - 1, p - 1) + v(n - k, p - 1) <= m\n\nn, m, k = map(int, input().split())\nl = 0\nr = 10 ** 100\nwhile r - l > 1:\n mid = (l + r) // 2\n if not check(mid):\n r = mid\n else:\n l = mid\nprint(l)"}, {"source_code": "n, m, k = map(int, input().split())\nbest = 1\nsleva = k - 1\nsprava = n - k\nm -= n\n\nput = 1\n\nwhile (m >= put):\n m -= put\n best+= 1\n put += (sleva > 0) + (sprava > 0)\n if sleva:\n sleva -= 1\n if sprava:\n sprava -= 1\n if sleva == sprava == 0:\n best += (m // put)\n break\n \nprint(best)"}, {"source_code": "def okay(n, m, k, v):\n total = n * v\n if k <= v:\n total -= k * (k-1) // 2\n else:\n total -= v * (v-1) // 2\n total -= (k-v) * (v-1)\n if n-k+1 <= v:\n total -= (n-k) * (n-k+1) // 2\n else:\n total -= v * (v-1) // 2\n total -= (n-k-v+1) * (v-1)\n return m >= total\n\nn, m, k = map(int, raw_input().split())\nans = 1\nlow, up = 1, 1000000000\nwhile low <= up:\n mid = (low + up) // 2\n if okay(n, m, k, mid):\n ans, low = mid, mid + 1\n else:\n up = mid - 1\n\nprint ans"}, {"source_code": "n , k , my = map( int , input().split() )\n\ndef distribute( l,r,c ):\n if l > r :\n return 0\n x = r-l+1;\n if x > c :\n x = c\n return ( (x*(x+1))//2 ) + ((c-x)*x)\n\ndef givable( cc ):\n return distribute( 1 , my-1 , cc-1 ) + distribute( my+1, n , cc-1 ) + cc <= k\n\nAns = 1\nk = k - n\n\nhigh, low, mid , additional = ( k , 0 , -1 , 0 )\nwhile( low <= high ) :\n mid = (high + low)//2;\n if givable(mid)==True :\n additional = mid\n low = mid+1\n else :\n high = mid-1\n\nprint( Ans + additional )"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\nd = 0\nk -= 1\nans = 1\nwhile m > 1 and d != max(k, n - k - 1):\n ans += 1\n m -= 1\n l = min(d, k)\n r = min(d, n - k - 1)\n d += 1\n m -= l\n m -= r\nans += m // n\n\nprint(ans)"}, {"source_code": "import sys\n\ndef sum_(a):\n return max(0, a * (a + 1) // 2)\n\ndef check(a):\n if a * n <= m:\n return 1\n a -= 1\n ans = n\n t1 = a - k + 1\n #print(a)\n if t1 >= 0:\n ans += sum_(a) - sum_(t1 - 1)\n else:\n ans += sum_(a)\n #print(ans)\n z = n - k + 1\n t2 = a - z + 1\n #print('ts', t2)\n if t2 >= 0:\n ans += sum_(a - 1) - sum_(t2 - 1)\n else:\n ans += sum_(a - 1)\n #print(ans)\n return (ans <= m)\n\ndef bins():\n l = 1\n r = m + 1\n while l + 1 != r:\n m1 = (l + r) // 2\n if check(m1):\n l = m1\n else:\n r = m1\n print(l)\n \nn, m, k = map(int, input().split())\n#print(check(2))\nbins()\n\n \n"}, {"source_code": "n,m,k = map(int,input().split())\nk1=n-k+1\ndef case(x):\n res=x\n if k==x:res+=x*(x-1)//2\n elif k>x:res+=x*(x-1)//2+k-x\n else:res+=x*(x-1)//2-((x-k)*(x-k+1)//2)\n if k1==x:res+=x*(x-1)//2\n elif k1>x:res+=x*(x-1)//2+k1-x\n else:res+=x*(x-1)//2-((x-k1)*(x-k1+1)//2)\n return res\ni,j=0,m\nwhile i+1= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + k - A\n\telse:\n\t\ts = A - k + 1\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\n\tkk = n - k \n\n\tif (kk) >= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + kk - (A-1)\n\telse:\n\t\ts = A - kk\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\tif up > m:\n\t\tdone = 1\n\t\tprint(A-1)\n\t\tbreak\n\n\nif done == 0:\n\n\tprint(m)"}, {"source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nr=n-k\nl=k-1\ns=max(l,r)+1\nif l>r:\n S=((1+l)*(l)//2)+((s-1+s-r)*r//2)\nelse:\n S=((1+r)*(r)//2)+((s-1+s-l)*l//2)\nS+=max(l,r)+1\nL,R=max(l,r),min(l,r)\ns1=s\ns2=1\nS1=n\nS2=S\nif S1==m:\n s=1\nelif S>m:\n while (S1!=S2) or (S2>m):\n S1=S2\n s=(s1+s2)//2 \n if Rm:\n s1=s\n elif S2 left + 1:\n d = med - left\n ans += (med + d) * (med - d + 1) // 2\n else:\n ans += med * (med + 1) // 2\n left -= (med - 1)\n ans += left\n #print(ans)\n if med > right + 1:\n d = med - right\n ans += (med + d) * (med - d + 1) // 2\n else:\n ans += med * (med + 1) // 2\n right -= (med - 1)\n ans += right\n #print(ans)\n if ans - med <= m:\n return True\n else:\n return False\n\nn, m, k = map(int, input().split())\nl = 1\nr = m + 1\nwhile r - l > 1:\n med = (r + l) // 2\n if f(med):\n l = med\n else:\n r = med\nprint(l)\n"}, {"source_code": "n, m, k = map(int, input().split())\n\nf = lambda k, s: (2 * s - k + 1) * k - s if k < s else (s - 2) * s + 2 * k\n\ns, m = m // n + 1, 2 * m + 1\n\nwhile f(k, s) + f(n - k + 1, s) < m: s += 1\n\nprint(s - 1)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "q,w,e=map(int,input().split())\nw-=q\nz=e-1\nx=q-e\nz,x=min(z,x),max(z,x)\nans=1\nt=1\nwhile (w-t)>=0:\n w-=t\n ans+=1\n if z==x==0:\n ans+=w//t\n break\n if z>0:\n z-=1\n t+=1\n if x>0:\n x-=1\n t+=1\nprint(ans)\n"}, {"source_code": "from random import randint\nn,m,k=map(int,raw_input().split())\n\nlow=1\nhigh=m\nl=k-1\nr=n-k\nwhile lowl:\n ans+=mid*l-l*(l+1)/2\n else:\n dec=mid-1\n ans+=mid*dec-dec*(dec+1)/2\n ans+=l-dec\n l=r\n if mid>l:\n ans+=mid*l-l*(l+1)/2\n else:\n dec=mid-1\n ans+=mid*dec-dec*(dec+1)/2\n ans+=l-dec\n l=k-1\n if ans<=m:\n low=mid\n else:\n high=mid-1\nprint low\n \n \n"}, {"source_code": "def calc(a, b):\n\tif b >= 0:\n\t\ta += b * (b + 1) // 2\n\telse:\n\t\ta += b\n\treturn a\n\ndef test(ans, n , m, k):\n\tif m - ans < n - 1:\n\t\treturn False\n\t\n\tals = m - ans\n\text = ans - 1 - n + k\n\tals -= ans * (ans - 1) // 2\n\tals = calc(als, ext)\n\text = ans - k\n\tals -= ans * (ans - 1) // 2\n\tals = calc(als, ext)\n\treturn als >= 0\n\n\nn, m, k = map(int, raw_input().split())\n\nl, r = 1, m\n\nwhile l < r:\n\tmid = (l + r + 1) // 2\n\tif not test(mid, n , m, k):\n\t\tr = mid - 1\n\telse:\n\t\tl = mid\n\nprint l\n"}, {"source_code": "n, m, k = tuple(int(_) for _ in input().split())\n\nextra_pillows = m - n\nmax_pillow = 1\n\nif n == 1:\n print(m)\nelif n == 2:\n if m % 2 == 0:\n print(int(m / 2))\n else:\n print(int(m / 2) + 1)\nelse:\n for i in range(extra_pillows):\n step_pillows = 1 + min(k - 1, i) + min(n - k, i)\n if extra_pillows >= step_pillows:\n extra_pillows -= step_pillows\n max_pillow += 1\n else:\n break\n\n print(max_pillow)\n"}, {"source_code": "n,m,k = [int(i) for i in input().split()]\nres = 1\nm= m-n\nif m>0:\n m-=1\n res+=1\nl =k-1\nr =k+1\nt1=l\nt2 = r \nwhile(m>0):\n if l<=0 and r>n:\n break\n else:\n if l==0:\n l+=1\n if r>n:\n r-=1\n temp = (r-l+1)\n m-=temp\n if m>=0:\n res+=1\n if l>0:\n l-=1\n if r<=n:\n r+=1\nif m>0:\n print(res+(m//n))\nelse:\n print(res)"}, {"source_code": "def I(): return(list(map(int,input().split())))\ndef f(k):\n\ts=0\n\tif k-idx>1:\n\t\ts-=(k-idx-1)*(k-idx)//2\n\tif k-(n-idx-1)>1:\n\t\ts-=(k-(n-idx-1)-1)*(k-(n-idx-1))//2\n\ts+=k**2\n\treturn s\n\nn,m,idx=I()\nidx-=1\nm=m-n\nl=0\nr=m\nwhile(l<=r):\n\tmid=(r-l)//2+l\n\tif f(mid)<=m:l=mid+1\n\telse:r=mid-1\n\t# print(f(mid),mid)\nprint(r+1)\n\n\t\n"}, {"source_code": "def bin_search(l, r, func):\n while l < r:\n c = (l + r) // 2\n val = func(c)\n\n if l + 1 == r:\n if func(r):\n return r\n if func(l):\n return l\n\n if val:\n l = c\n else:\n r = c - 1\n # print('l: %s, r: %s' % (l, r))\n if l == r:\n return l\n else:\n return 1\n\ndef solve(n, m, k):\n hr, hl = k-1, n-k\n s_one_n = lambda n: n * (1.0 + n) / 2.0\n def s_n_m(n, m):\n return (m-n+1) * (n+m) / 2.0\n def snm(n, m):\n return s_one_n(max(n,m)) - s_one_n(min(n,m)-1)\n def calc_side(ft, hs):\n if hs == 0:\n return 0\n return s_n_m(max(1, ft - hs), ft - 1) + max(0, hs - ft + 1)\n f = lambda x: calc_side(x, hl) + calc_side(x, hr) + x <= m\n print(bin_search(1, m*3, f))\n\nn,m,k = map(int, input().split(' '))\nsolve(n,m,k)"}, {"source_code": "def main():\n n, m, k = map(int, raw_input().split())\n\n # while True:\n # k = min(k, n - k + 1)\n #\n # a = max(k - 1, n - k)\n # critical = ((2 * a - k + 2) * (k - 1) + (2 * a - n + k + 1) * (n - k)) / 2 + a + 1\n #\n # print critical\n #\n # if m >= critical:\n # print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n\n # return\n # else:\n # m -= 1\n # n -= 1\n\n def sn(a1, an, n):\n return (a1 + an) * n / 2\n\n a = max(k - 1, n - k)\n critical = ((2 * a - k + 2) * (k - 1) + (2 * a - n + k + 1) * (n - k)) / 2 + a + 1\n\n if m >= critical:\n print (m + k * (k - 1) / 2 + (n - k) * (n - k + 1) / 2) / n\n return\n\n m -= n\n k = min(k, n - k + 1)\n\n r = 0\n l = 10e+9\n\n while True:\n x = int((l + r) / 2)\n\n def s(z):\n f = min(k - 1, z - 1)\n return z + z * (z - 1) / 2 + (z - 1 + z - f) * f / 2\n\n s1 = s(x)\n s2 = s(x+1)\n\n if s1 <= m < s2:\n print x+1\n return\n elif s1 < m:\n r = x\n else:\n l = x\n\n\n\nif __name__ == '__main__':\n main()\n"}], "negative_code": [{"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n if left <= 2 and right >= hobs-1:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs-1:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n## print(pillows)\n## print(pilCount)\n## print(left, right)\n if left <= 2 and right >= hobs-1:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs-1:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)\n\n\n\n\n"}, {"source_code": "import sys\n\ndef sum_(a):\n return a * (a + 1) // 2\n\ndef check(a):\n global k\n if a * n <= m:\n return 1\n ans = 0\n t1 = a - k + 1\n ans += sum_(a) - sum_(t1 - 1)\n z = n - k + 1\n t2 = a - z + 1\n ans += sum_(a - 1) - sum_(t2 - 1)\n #print(ans)\n return (ans <= m)\n\ndef bins():\n l = 1\n r = m + 1\n while l + 1 != r:\n m1 = (l + r) // 2\n if check(m1):\n l = m1\n else:\n r = m1\n print(l)\n \nn, m, k = map(int, input().split())\nbins()\n\n \n"}, {"source_code": "import math\ndef c(k,n):\n return (k-1)*(k-1)+(n-k*2+1)*(n-k*2)/2+(k*2-1)*(n-k*2+1)\n\nn,m,k=list(map(int,input().split()))\nm=m-n\nif k>n/2:\n k=n-k+1\n\nif k*k>=m:\n if int(m**0.2)==m**0.2:\n print(int(m**0.2))\n else:\n print(int(m**0.2)+1)\n exit()\nelif c(k,n)>=m:\n #m=m-(k-1)*(k-1)\n #for i in range(n+5):\n # if i*((i-1)/2+k*2)>m:\n # print(i+k)\n # exit()\n m=m-(k-1)*(k-1)\n x=k-1\n for i in range(n+5):\n if i+k*2-1>m:\n print(i+x+1)\n exit()\n m=m-i-k*2+1\nelse:\n m=m-c(k,n)\n print(int(m//n+n-k+1))\n"}, {"source_code": "num_hobbits, num_pillows, frodo_idx = map(int, input().split())\nnum_pillows -= num_hobbits\n\nfrodo_idx -= 1\nleft = right = frodo_idx\n\nfrodo_pillows = 2\nnum_pillows -= 1\nwhile num_pillows > 0:\n left = max(left - 1, 0)\n right = min(right + 1, num_hobbits - 1)\n\n # Includes Frodo's\n num_pillows -= right - left + 1\n\n if num_pillows >= 0:\n frodo_pillows += 1\n\nprint(frodo_pillows)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n print(pillows)\n print(pilCount)\n print(left, right)\n if left < 1 and right > hobs:\n pilCount+=pillows//hobs\n break\n elif left < 1 or right > hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)"}, {"source_code": "n, m, k = map(int, input().split())\nf = lambda k, s: max((2 * s - k) * k, (s + 1) * s + 2 * (k - s)) - s\ns, m = 2, 2 * m + 1\nwhile f(k, s) + f(n - k, s) < m: s += 1\nprint(s - 1)"}, {"source_code": "#!/usr/bin/env python\n\n\ndef sum_range(l, r):\n return (l + r) * (r - l + 1) / 2\n\n\ndef main():\n n, m, k = map(int, raw_input().split(' '))\n L, R = 0, m\n while L + 1 < R:\n x = L + (R - L) / 2\n l, r = x - (k - 1), x - (n - k)\n sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)\n if l < 1:\n sl += 1 - l\n if r < 1:\n sr += 1 - r\n if sl + sr - x <= m:\n L = x\n else:\n R = x \n print max(L, 1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, m, k = map(int, input().split())\n\ndone = 0\n\nfor A in range(m // n,m+1):\n\n\tup = A\n\n\tif (k-1) >= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + k - A\n\telse:\n\t\ts = A - k + 1\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\n\tkk = n - k \n\n\tif (kk-1) >= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + kk - A\n\telse:\n\t\ts = A - kk\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\tif up > m:\n\t\tdone = 1\n\t\tprint(A-1)\n\t\tbreak\n\n\nif done == 0:\n\n\tprint(m)"}, {"source_code": "#import math\nn,m,k = map(int,raw_input().split())\nm = m-n\nd = 0\nk -=1\nans = 1\nwhile m>1 and d!=max(k,n-k-1):\n\tans+=1\n\tm-=1\n\tl = min(d,k)\n\tr = min(d,n-k-1)\n\td+=1\n\tm-=1\n\tm-=r\nans +=m/n\nprint ans\n\n\n\n\n"}, {"source_code": "#!/usr/bin/env python3\ndef ri():\n return map(int, input().split())\n\nn, m, k = ri()\n\ndef area(h, n, k):\n a = [h+i-k if h+i-k >= 1 else 1 for i in range(1, k)]\n b = [h-i+k if h-i+k >= 1 else 1 for i in range(k, n+1)]\n return sum(a) + sum(b)\n\nh1 = 1\nh2 = m\nhmax = 0\nhprev = 0\nwhile True:\n hh = (h2+h1)//2\n if hh == hprev:\n break\n hprev = hh\n mm = area(hh, n, k)\n print(h1, h2, hmax, hh, mm, m)\n if mm > m:\n h2 = hh\n else:\n h1 = hh\n hmax = max(hmax, hh)\n\nprint(hmax)"}, {"source_code": "def partSum(a, b):\n if a < 0:a = 1\n return b * (b + 1) // 2 - (a - 1) * (a - 1 + 1) // 2\n\n\ndef f(v, l, r):\n return v + partSum(v - l, v - 1) + partSum(v - r, v - 1)\n\nn, m, k = [int(item) for item in input().split()]\n\nl = k - 1\nr = n - k\nbound = m - (n - 1)\n\n\na, b = 1, bound\n\nwhile a <= b:\n mi = (a + b) // 2\n if f(mi, l, r) > m:\n b = mi - 1\n elif f(mi, l, r) < m:\n a = mi + 1\n else:\n print(mi)\n break\n #print(a,b, m)\nelse:\n if f(mi, l, r) <= m : print(mi)\n else:print(mi - 1)"}, {"source_code": "\n# x is the number of pillows Frodo wants\n\ndef is_ok(x, y):\n \n if y > (x - 1):\n val = (((x-1) * x) >> 1) + y - (x - 1)\n else:\n val = (y * (x - 1 + x - y)) >> 1\n \n return val \n\n\nhobbits, pillows, k = [int(x) for x in input().split()]\n\nif hobbits == 15:\n print(pillows)\nelse:\n \n l = 1 \n r = pillows\n \n while l < r:\n m = (l + r) >> 1\n \n valor = is_ok(m, k) + is_ok(m, hobbits - k) + m\n print(valor, m, l, r)\n \n if valor < pillows:\n l = m + 1\n else:\n r = m - 1\n \n print(l)\n\n\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\ndef res(p):\n global n,m,k\n ans = 0\n if k-1 > p-1:\n ans += p*(p-1)/2 + (k-p)\n else:\n ans += (k-1)*(2*p-k)/2\n if n-k > p-1:\n ans += p*(p-1)/2 + (n-k-p+1)\n else:\n ans += (n-k)*(2*p + k - n + 1)/2\n return ans + p\nhi = m \nlo = 1\nwhile lo < hi :\n mid = lo + (hi - lo + 1)/2\n if res(mid) > m:\n hi = mid - 1\n else:\n lo = mid \nprint lo "}, {"source_code": "\n# x is the number of pillows Frodo wants\n\ndef is_ok(x, y):\n \n if y > (x - 1):\n val = (((x-1) * x) >> 1) + y - (x - 1)\n else:\n val = (y * (x - 1 + x - y)) >> 1\n \n return val \n\n\nhobbits, pillows, k = [int(x) for x in input().split()]\n\nif hobbits == 15:\n print(pillows)\nelse:\n \n l = 1 \n r = pillows\n \n while l < r:\n m = (l + r) >> 1\n \n valor = is_ok(m, k) + is_ok(m, hobbits - k) + m\n print(valor, m, l, r)\n \n if valor < pillows:\n l = m + 1\n else:\n r = m - 1\n \n print(l)\n\n\n"}, {"source_code": "n,m,k = map(int,raw_input().split())\ndef res(p):\n global n,m,k\n return (k-1)*(2*p-k)/2 + p + (n-k)*(2*p + k - n - 1)/2\nhi = m - n \nlo = 0\nwhile lo < hi :\n mid = lo + (hi - lo + 1)/2\n if res(mid) > m - n:\n hi = mid - 1\n else:\n lo = mid \nprint lo + 1\n"}, {"source_code": "import math\ndef c(k,n):\n return (k-1)*(k-1)+(n-k*2+1)*(n-k*2)/2+(k*2-1)*(n-k*2+1)\n\nn,m,k=list(map(int,input().split()))\nm=m-n\nif k>n/2:\n k=n-k+1\n\nif k*k>=m:\n for i in range(k):\n if i*i>m:\n print(i)\n exit()\n print(i+1)\n exit()\nelif c(k,n)>=m:\n m=m-(k-1)*(k-1)\n for i in range(n+5):\n if i*((i-1)/2+k*2)>m:\n print(i+k)\n exit()\nelse:\n m=m-c(k,n)\n print(m//n+n-k+1)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n if left <= 2 and right >= hobs-1:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs-1:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)"}, {"source_code": "def just_sum(n):\n return (n * (n + 1)) // 2\n\n\ndef get_sum(a, b):\n return just_sum(b) - just_sum(a - 1)\n\n\ndef check(middle):\n left = k - 1\n right = n - k\n \n if left < m:\n left_sum = get_sum(middle - left, middle - 1)\n else:\n left_sum = just_sum(middle - 1) + (left - (middle - 1))\n \n if right < m:\n right_sum = get_sum(middle - right, middle - 1)\n else:\n right_sum = just_sum(middle - 1) + (right - (middle - 1))\n \n return left_sum + right_sum + middle <= m\n \n \nn, m, k = map(int, input().split())\n\nl = 1\nr = m + 1\nwhile l < r - 1:\n middle = (l + r) // 2\n if check(middle):\n l = middle\n else:\n r = middle\n \nprint(l)"}, {"source_code": "n, m, k = map(int, input().split())\nl = 1\nr = m + 1\ns = 0\nf = 0\nwhile (r - l > 1):\n x = (l + r) // 2\n if x - 1 < k - 1:\n f = x * (x - 1) // 2 + ((k - 1) - (x - 1))\n else:\n f = ((x - 1) - (k - 2) + (x - 1)) * (k - 1) // 2\n if f + x > m:\n s = 0\n elif x - 1 >= n - k:\n s = (n - k) * ((x - 1) + (x - 1) - (n - k - 1)) // 2\n else:\n s = x * (x - 1) // 2 + (n - k) - (x - 1)\n print(f, s)\n if f + s + x <= m:\n l = x\n else:\n r = x\nprint(l)"}, {"source_code": "#import math\nn,m,k = map(int,raw_input().split())\nm = m-n\nd = 0\nk -=1\nans = 1\nwhile m>1 and d!=max(k,n-k-1):\n\tans+=1\n\tm-=1\n\tl = min(d,k)\n\tr = min(d,n-k-1)\n\td+=1\n\tm-=1\n\tm-=r\nans +=m//n\nprint ans\n\n\n\n\n"}, {"source_code": "def f(tar,n,m,k):\n p=0\n if k==1 or k==n:\n k=n\n p+=((tar*(tar+1))//2)\n p+=(max(0,n-tar))\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p-=max(0,b)\n else:\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p+=(a-b)\n p+=(max(0,k-tar))\n u=n-k\n v=tar-u-1\n c=(v*(v+1))//2\n p+=(a-c)\n d=k+tar-1\n e=n-d\n p+=(max(0,e))\n p-=tar\n if p<=m:\n return True\n else:\n return False\n \nimport sys\n\nn,m,k=map(int,input().split())\nif n==m:\n print(1)\n sys.exit()\n \nlow,high,ans=m//n,10**18,m//n\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(mid,n,m,k)\n if x:\n ans=max(ans,mid)\n low=mid+1\n else:\n high=mid-1\n \nprint(ans)"}, {"source_code": "numbers = map(int, raw_input().split())\nn = numbers[0]\nm = numbers[1]\nk = numbers[2]\n\ndef sum(n):\n\tsum =0\n\tfor i in range(1, n+1):\n\t\tsum += i\n\treturn sum\n\nlo = 1\nhi = m\nwhile lo < hi:\n\tif( hi - lo < 5 ):\n\t\tfor i in range(hi, lo-1, -1):\n\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\t\t# print left+right +i,\" pillows required for \",i\n\t\t\tif( left + right + i <= m ):\n\t\t\t\tprint i\n\t\t\t\texit(0)\n\tmid = (lo + hi)/2\n\t# print lo, mid, hi\n\tleft = sum(mid - 1) - sum( mid - k)\n\tright = sum( mid - 1) - sum( mid - (n-k) - 1 )\n\tif left + right + mid <= m:\n\t\tlo = mid\n\telse:\n\t\thi = mid - 1\n"}, {"source_code": "import bisect\nn,m,k=map(int,input().split())\nl=1\nr=m-n+1\nf=1\nwhile lmid-1:\n ans+=(mid*(mid-1)//2)+k-1-(mid-1)\n else:\n ans+=(k-1)*(2*mid-1-(k-1))//2\n if n-k>mid-1:\n ans += (mid*(mid - 1)//2)+n-k-(mid-1)\n else:\n ans+=(n-k)*(2*mid-1-(n-k))//2\n #ans +=(n-k)*(mid - (k - 1) + 1)//2\n if ans==m:\n f=l\n if ans>=m:\n r=mid\n if ansr:\n S=((1+l)*(l)//2)+((l+n)*r//2)\nelse:\n S=((1+r)*(r)//2)+((r+n)*l//2)\nS+=k\ns=max(l,r)+1\nL,R=max(l,r),min(l,r)\nif L!=R:\n B=False\n L-=1\nelse:\n L-=1\n R-=1\n B=True\ni=0\nwhile S>m:\n s=s-1\n S-=l+r\n S-=1\n if L==0 :\n s-=1\n S-=n-2*i\n i+=1\n if L>0:\n L-=1\n if B:\n R-=1\n elif L==R:\n B=True\n \n \nif S!=m and (m-S)//n!=0:\n s+=(m-S)//n\nprint(s)\n\n \n \n\n \n"}, {"source_code": "from sys import stdin, stdout\n\nn, m, k = map(int, stdin.readline().split())\nm = m - n + 1\n\nans = min(2, m)\nm -= min(2, m)\n\nif k == 1 or k == n:\n cnt = min(n, 2)\n while m - cnt >= 0:\n ans += 1\n m -= cnt\n cnt += 1\n cnt = min(cnt, n)\n \n if cnt == n:\n break\n \n ans += m // cnt\n \n \nelse:\n cnt = min(n, 3)\n while m - cnt >= 0:\n ans += 1\n m -= cnt\n cnt += 2\n cnt = min(cnt, n)\n\n if cnt == n:\n break\n \n ans += m // cnt\n\nstdout.write(str(ans))"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\n\ndef Sum(cnt, x):\n if cnt == 0: return 0\n return cnt * (x + (x - cnt )) // 2\ndef check(x):\n l = min(k - 1, (x - 1))\n r = min(n - k, (x - 1))\n cur = Sum(l, x) + Sum(r, x) + x\n return cur<= m\nL = -1\nR = 10 ** 12\nwhile R - L > 1:\n M = ( L + R) >> 1\n if check(M): L = M\n else: R = M\nprint(L + 1)"}, {"source_code": "from math import ceil\n\nn, m, k = map(int, input().split())\n\n\ndef check(middle, n, m, k):\n if k != 1 and k != n:\n return middle - ((m - middle) // (n - 1)) < 2\n return middle - ceil((m - middle) / (n - 1)) < 2\n\nleft = 0\nright = m\nwhile right - left > 1:\n middle = (right + left) // 2\n if check(middle, n, m, k):\n left = middle\n else:\n right = middle\nprint(left)\nprint(check(3, n, m , k))"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n print(pillows)\n print(pilCount)\n print(left, right)\n if left <= 2 and right >= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)\n\n\n\n\n"}, {"source_code": "n, m, k = map(int, input().split(' '))\n\nprint((m//n)+1)\n\n"}, {"source_code": "n, m, k = map(int, input().split())\n\ndone = 0\n\nfor A in range(m // n,m+1):\n\n\tup = A\n\n\tif (k-1) >= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + k - A\n\telse:\n\t\ts = A - k + 1\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\n\tkk = n - k \n\n\tif (kk-1) >= (A-1):\n\t\tup = up + A * (A-1) / 2\n\t\tup = up + kk - A\n\telse:\n\t\ts = A - kk\n\t\tup = up + (s + (A - 1)) * (A - s) / 2\n\n\tif up > m:\n\t\tdone = 1\n\t\tprint(A-1)\n\t\tbreak\n\n\nif done == 0:\n\n\tprint(m)"}, {"source_code": "__author__ = 'zihaozhu'\nfrom sys import stdin\n\nhobbits, pillow, frodo = map(int,stdin.readline().split())\n\nmaxpossible = pillow- hobbits\n\"\"\"\nif maxpossible<=2:\n print(maxpossible)\nelif hobbits == frodo and maxpossible-1<2:\n print(pillow)\nelif frodo == 1 and maxpossible-1<2:\n print(pillow)\n\nelse:\n\"\"\"\nif frodo!=1 and frodo!=hobbits:\n n = 0\n \"\"\"\n while ((n)*(n+1)/2)+((n)*(n+1)/2)= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n z = int(p ** (1/2))\n return z + l\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "n, m, k = [int(i) for i in input().split()]\n\ndef one_sided(slots, x):\n if slots >= x-1:\n return (slots - x + 1) + (x-1)* x // 2\n else:\n return slots * ( 2* x - slots -1 ) // 2\n\ndef pillows_used(x):\n left_slot = k -1\n right_slot = n-k\n return x + one_sided(left_slot, x) + one_sided(right_slot, x) <= m\n\ndef main():\n left = 1\n right = m\n mid = (left + right) // 2\n if left == right:\n return mid\n while left != right:\n if pillows_used(mid):\n left = mid + 1\n else:\n right = mid\n mid = (left + right) // 2\n return mid - 1\n\nprint(main())"}, {"source_code": "import math\n\n\ndef read(type=int):\n return type(input())\n\n\ndef read_arr(type=int):\n return [type(token) for token in input().split()]\n\n\ndef foo_c(n, i):\n return i * (n - i + 1)\n\n\ndef triangle(k, i):\n a, b = 1, (i + 1) // 2\n while a < b:\n m = (a + b + 1) // 2\n c = foo_c(i, m)\n if c > k:\n b = m - 1\n else:\n a = m\n return a\n\n\ndef foo2(m, i):\n k = int(math.sqrt(2 * m))\n return k if k * (k - 1) <= 2 * m else k - 1\n\n\ndef runB():\n n, m, k = read_arr()\n ans = 1\n m -= n\n k = min(k, n + 1 - k)\n if k > 1:\n t = 2 * k - 3\n a = triangle(m, t)\n m -= foo_c(t, a)\n ans += a + (m // n)\n if m >= t + 2:\n ans += 1\n m -= (t + 2)\n ans += m // n\n print(ans)\n else:\n a = min(n, foo2(m, n))\n ans += a\n m -= (a * (a + 1)) // 2\n if m >= a + 1:\n ans += 1\n m -= a + 1\n ans += m // n\n print(ans)\n\nrunB()\n"}, {"source_code": "import math\n\n\ndef read(type=int):\n return type(input())\n\n\ndef read_arr(type=int):\n return [type(token) for token in input().split()]\n\n\ndef foo_c(n, i):\n return i * (n - i + 1)\n\n\ndef triangle(k, i):\n a, b = 1, (i + 1) // 2\n while a < b:\n m = (a + b + 1) // 2\n c = foo_c(i, m)\n if c > k:\n b = m - 1\n else:\n a = m\n return a\n\n\ndef foo2(m, i):\n k = int(math.sqrt(2 * m))\n return k if k * (k - 1) <= 2 * m else k - 1\n\n\ndef runB():\n n, m, k = read_arr()\n ans = 1\n m -= n\n k = min(k, n + 1 - k)\n if k > 1:\n t = 2 * k - 3\n a = triangle(m, t)\n m -= foo_c(t, a)\n ans += a \n l = a + max(a-1, k-1)\n if m >= l:\n ans += 1\n m -= l\n ans += m // n\n print(ans)\n else:\n a = min(n, foo2(m, n))\n ans += a\n m -= (a * (a + 1)) // 2\n if m >= a + 1:\n ans += 1\n m -= a + 1\n ans += m // n\n print(ans)\n\nrunB()\n"}, {"source_code": "def works(n, m, k, h):\n height = h\n pillows = h\n for i in range(k+1, n+1):\n height -= 1\n if height == 0: break\n pillows += height\n height = h\n for i in range(k-1, 0, -1):\n height -= 1\n if height == 0: break\n pillows += height\n return pillows <= m\n\nn, m, k = map(int, raw_input().split())\nhi = 1000000500\nlo = 1\nwhile lo + 1 < hi:\n mid = (lo + hi) / 2\n if works(n, m, k, mid):\n lo = mid\n else:\n hi = mid\n\nprint lo\n"}, {"source_code": "n, m, k = map(int, input().split())\nl = 1\nr = m + 1\ns = 0\nf = 0\nwhile (r - l > 1):\n x = (l + r) // 2\n if x - 1 < k - 1:\n f = x * (x - 1) // 2 + ((k - 1) - (x - 1))\n else:\n f = ((x - 1) - (k - 2) + (x - 1)) * (k - 1) // 2\n if f + x > m:\n s = 0\n elif x - 1 >= k - 1:\n s = (n - k) * ((x - 1) + (x - 1) - (n - k - 1)) // 2\n else:\n s = x * (x - 1) // 2 + (n - k) - (x - 1)\n if f + s + x <= m:\n l = x\n else:\n r = x\nprint(l)"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,random\n\n# read input\nn, m, k = map(int, input().split())\n\n# n, m, k = 3, 10, 3\n\nr = m - n\n\nans = 1\n\np = k - 1\nq = n - k\n\n# print(r, p, q)\n\ndef cost(i, p):\n\tc = max(p*i - p * (p+1)/2, 0)\n\treturn int(c)\n\nr0 = r\nle = 0\nri = r0\nif(r > 0):\n\ti = le\n\twhile(abs(le - ri) > 1):\n\t\tc = i + cost(i, p) + cost(i, q)\n\t\tr0 = r - c\n\t\t# print(c, r0, le, ri)\n\t\tif(r0 >= 0):\n\t\t\tle = i\n\t\telse:\n\t\t\tri = i\n\t\ti = (le + ri)//2 \n\t\n\tc1 = ri + cost(ri, p) + cost(ri, q)\n\tr0 = r - c1\n\tif(r0 >= 0):\n\t\tans += ri\n\telse:\n\t\tans += le\n\t\n\tprint(ans)\nelse:\n\tprint(ans)"}, {"source_code": "import math\nn, m, k = map(int, input().split(' '))\n\ndiv = (m/n)\nmod = m%n\n\nif mod == 0 or mod == 1:\n if div%2 == 0:\n print(math.ceil(div+1))\n else:\n print(math.ceil(div))\nelse:\n print(mod)\n\n"}, {"source_code": "\n\nn, m , k = [int(i) for i in input().split()]\n\n\ndef get_min_pillow(bed,x):\n res = (x-1) *x /2\n if bed >x-1:\n res += bed -x + 1\n elif bed 1:\n mid = (l + r) >> 1\n if check(mid):\n ans = mid\n l = mid\n else:\n r = mid\nprint(ans)\n\n\n"}, {"source_code": "n, m, k = map(int,raw_input().split())\nx = max(k,n-k+1)\nx_min = min(k-1,n-k)\ns_min = sum(range(x_min+1))\nx_max = max(k-1,n-k)\ns_max = sum(range(x_max+1))\no = m + s_min + s_max\nx = (o-o%n)/n\npods = x*n - s_min - s_max\nif(m>=n*x_max - s_min - s_max):\n print x\nelse:\n x = 1\n pods = n\n \n add = 0\n add_r = 0\n add_l = 0\n lim_l = 0\n for j in range(n):\n add_r = j\n if(j<=x_min):\n add_l += j\n if(j+1>x_min):\n lim_l = j\n else:\n add_l += lim_l\n add += 1 + add_r + add_l\n print add, add_l, add_r\n if(pods+add<=m):\n \n x += 1\n else:\n print pods,add-1-add_r-add_l \n print x\n break"}, {"source_code": "# from itertools import combinations\n# from bisect import bisect_right\n# from functools import *\n# from collections import Counter\n\ndef sum(n):\n return n * (n + 1) // 2\n\ndef sumRange(l, r):\n if l > r:\n return 0\n return sum(r) - sum(l - 1)\n\nI = lambda: list(map(int, input().split()))\nn, m, k = I()\nl, r = 1, m + 1\nwhile l < r - 1:\n mid = (l + r) >> 1\n s = sumRange(mid - k + 1, mid) + sumRange(mid - n + k, mid - 1)\n if s <= m:\n l = mid\n else:\n r = mid\nprint(l)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n## print(pillows)\n## print(pilCount)\n## print(left, right)\n if left <= 2 and right >= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)\n\n\n\n\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,random\n\n# read input\n# n, m, k = map(int, input().split())\n\nn, m, k = 10, 20, 5\n\nr = m - n\n\nans = 1\n\np = k - 1\nq = n - k\n\n# print(r, p, q)\n\ndef cost(i, p):\n\tc = p*i - p * (p+1)/2\n\treturn int(c)\n\nr0 = r\nle = 0\nri = r0\nif(r > 0):\n\ti = le\n\twhile(abs(le - ri) > 1):\n\t\tc = i + cost(i, p) + cost(i, q)\n\t\tr0 = r - c\n\t\tprint(c, r0, le, ri)\n\t\tif(r0 == 0):\n\t\t\tbreak\n\t\tif(r0 > 0):\n\t\t\tle = i\n\t\telse:\n\t\t\tri = i\n\t\ti = (le + ri)//2 \n\t\n\tans += le\n\t\n\tprint(ans)\nelse:\n\tprint(ans)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n left-=1\n right+=1\n if left <= 1 and right >= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 1 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n\n pilCount+=1\n turn+=1\nprint(pilCount)"}, {"source_code": "numbers = map(int, raw_input().split())\nn = numbers[0]\nm = numbers[1]\nk = numbers[2]\n\ndef sum(n):\n\treturn (n*(n+1))/2\n\nlo = 1\nhi = m\nif( hi - lo < 5 ):\n\tfor i in range(hi, lo-1, -1):\n\t\tif k > i:\n\t\t\tleft = sum(i-1) + k - i\n\t\telse:\n\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\tif n - k > i:\n\t\t\tright = sum( i -1) + n - k - i + 1\n\t\telse:\n\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\tprint left,\" \",right,\" \",i,\" pillows required for \",i\n\t\tif( left + right + i <= m ):\n\t\t\tprint i\n\t\t\texit(0)\n\tprint \"Trouble\"\n\texit(1)\nwhile lo < hi:\n\tif( hi - lo < 5 ):\n\t\tfor i in range(hi, lo-1, -1):\n\t\t\tif k > i:\n\t\t\t\tleft = sum(i-1) + k - i\n\t\t\telse:\n\t\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\t\tif n - k > i:\n\t\t\t\tright = sum( i -1) + n - k - i + 1\n\t\t\telse:\n\t\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\t\tprint left,\" \",right,\" \",i,\" pillows required for \",i\n\t\t\tif( left + right + i <= m ):\n\t\t\t\tprint i\n\t\t\t\texit(0)\n\t\tprint \"Trouble\"\n\t\texit(1)\n\tmid = (lo + hi)/2\n\t# print lo, mid, hi\n\tif k > mid:\n\t\tleft = sum(mid-1) + k - mid\n\telse:\n\t\tleft = sum(mid - 1) - sum( mid - k)\n\tif n - k > mid:\n\t\tright = sum( mid -1) + n - k - mid + 1\n\telse:\n\t\tright = sum( mid - 1) - sum( mid - (n-k) - 1 )\n\n\tif left + right + mid <= m:\n\t\tlo = mid\n\telse:\n\t\thi = mid - 1\n"}, {"source_code": "n, m, k = map(int, input().split())\nl = 1\nr = m + 1\ns = 0\nf = 0\nwhile (r - l > 1):\n x = (l + r) // 2\n if x - 1 < k - 1:\n f = x * (x - 1) // 2 + ((k - 1) - (x - 1))\n else:\n f = ((x - 1) - (k - 2) + (x - 1)) * (k - 1) // 2\n if x - 1 >= k - 1:\n s = (n - k) * ((x - 1) + (x - 1) - (n - k - 1)) // 2\n else:\n s = x * (x - 1) // 2 + (n - k) - (x - 1)\n if f + s + x <= m:\n l = x\n else:\n r = x\nprint(l)"}, {"source_code": "def f(tar,n,m,k):\n p=0\n if k==1 or k==n:\n k=n\n p+=((tar*(tar+1))//2)\n p+=(max(0,n-tar))\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p-=max(0,b)\n else:\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p+=(a-b)\n p+=(max(0,k-tar))\n u=n-k\n v=tar-u-1\n c=(v*(v+1))//2\n p+=(a-c)\n d=k+tar-1\n e=n-d\n p+=(max(0,e))\n p-=tar\n if p<=m:\n return True\n else:\n return False\n\nn,m,k=map(int,input().split())\n\nlow,high,ans=m//n,10**18,m//n\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(mid,n,m,k)\n if x:\n ans=max(ans,mid)\n low=mid+1\n else:\n high=mid-1\n\nprint(ans)"}, {"source_code": "n, m, k = map(int,raw_input().split())\nx = 1\npods = n\nx_min = min(k-1,n-k)\nx_max = max(k-1,n-k)\nadd = 0\nadd_r = 0\nadd_l = 0\nlim_l = 0\nfor j in range(n):\n add_r = j\n if(j<=x_min):\n add_l += j\n if(j+1>x_min):\n lim_l = j\n else:\n add_l += lim_l\n add += 1 + add_r + add_l\n #print add,add_r,add_l\n if(pods+add<=m):\n x += 1\n else: \n print x\n break"}, {"source_code": "def num(t):\n t = t - 1\n r = t * t + n\n r -= max(0, ((t - k) * (t - k + 1)) // 2)\n r -= max(0, ((t - (n - k + 1)) * (t - (n - k))) // 2)\n return r\n\ns = input().split()\n\nn = int(s[0])\nm = int(s[1])\nk = int(s[2])\n\nlo = 1\nhi = 10 ** 9 + 10\n\nwhile lo < hi:\n #print(\"lo =\", lo)\n #print(\"hi =\", hi)\n mid = (lo + hi + 1) // 2\n #print(\"mid =\", mid)\n #print(\"pillows =\", num(mid))\n if num(mid) <= m:\n lo = mid\n else:\n hi = mid - 1\n\nprint(str(lo))\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = 0\n if p != 0:\n while True:\n z1 = (z * (z + 1)) // 2\n z2 = min(max(((n - k) * (z - 1 + z + k - n)) // 2, 0), z1)\n if z1 + z2 > p:\n break\n z += 1\n return z\n else:\n return z + 1\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = int(p ** (1/2))\n while True:\n z1 = (z * (z + 1)) // 2\n z2 = ((n - k) * (z - 1 + z + k - n)) // 2\n if z1 + z2 > p:\n break\n z += 1\n return z\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nif k!=n:\n r=n-k\nif k!=1:\n l=k-1\nif l>r:\n S=((1+l)*(l)//2)+((l+n)*r//2)\nelse:\n S=((1+r)*(r)//2)+((r+n)*l//2)\nS+=k\ns=max(l,r)+1\ni=0\nwhile S>=m:\n s=s-1\n S-=l+r\n if l==0 and r==0:\n s-=1\n S-=n-2*i\n i+=1\n if l>0:\n l-=1\n if r>0:\n r-=1\n\nif(m-S)//n!=0:\n s+=(m-S)//n\nprint(s)\n\n \n \n\n \n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/contest/760/problem/B\nYYYYYYYYYYNNNNNNNNN\n\n\nNNNNYYYYY : return left\nYYYYYYNNN : return right\n\"\"\"\n\nn, m, k = map(int, raw_input().split())\n\ndef solve():\n\n\tlo = 0\n\thi = m\n\n\twhile (lo + 1 < hi):\n\t\tmid = (lo + hi) / 2\n\n\t\tif (check(mid)):\n\t\t\tlo = mid\n\n\t\telse:\n\t\t\thi = mid \n\n\treturn lo\n\n\ndef check(mid):\n\t\n\tidx1 = k - 1\n\tidx2 = k + 1\n\n\tnum_pills = mid\n\n\the_will_get1 = mid - 1\n\twhile (idx1 > 0):\n\t\tif (he_will_get1 <= 0): \n\t\t\the_will_get1 = 1\n\t\tnum_pills += he_will_get1\n\t\the_will_get1 -= 1\n\t\tidx1 -= 1\n\n\the_will_get2 = mid - 1\n\twhile (idx2 <= n):\n\t\tif (he_will_get2 <= 0): \n\t\t\the_will_get2 = 1\n\t\tnum_pills += he_will_get2\n\t\the_will_get2 -= 1\n\t\tidx2 += 1\n\t# import pdb; pdb.set_trace()\n\tif (num_pills > m):\n\t\treturn False\n\treturn True\n\n\nprint solve()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nr=n-k\nl=k-1\ns=max(l,r)+1\nif l>r:\n S=((1+l)*(l)//2)+((s-1+s-r)*r//2)\nelse:\n S=((1+r)*(r)//2)+((s-1+s-l)*l//2)\nS+=max(l,r)+1\nL,R=max(l,r),min(l,r)\ns1=s\ns2=1\nS1=n\nS2=S\nif S1==m:\n s=1\nelif S>m:\n while (S1!=S2) or (S2>m):\n S1=S2\n s=(s1+s2)//2 \n if Rm:\n s1=s\n elif S2= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)\n\n\n\n\n"}, {"source_code": "r=list(map(int,input().split()))\nn=r[0]\nm=r[1]\nk=r[2]\n\ni=m%n\nprint(m//n+1)\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = 0\n if p != 0:\n while True:\n z1 = (z * (z + 1)) // 2\n z2 = min(max(((n - k) * (z - 1 + z + k - n)) // 2, 0), z1)\n if z1 + z2 > p:\n break\n z += 1\n return z\n else:\n return z + 1\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\nwhile True:\n if left<= 1 and right >= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 1 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\nprint(pilCount)\n\n\n\n\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = int(p ** (1/2))\n while z ** 2 < p:\n z1 = (z * (z + 1)) // 2\n z2 = ((n - k) * (z - 1 + z + k - n)) // 2\n if z1 + z2 > p:\n break\n z += 1\n return z + l\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "import math\ndef c(k,n):\n return (k-1)*(k-1)+(n-k*2+1)*(n-k*2)/2+(k*2-1)*(n-k*2+1)\n\nn,m,k=list(map(int,input().split()))\nm=m-n\nif k>n/2:\n k=n-k+1\n\nif k*k>=m:\n for i in range(k):\n if i*i>m:\n print(i)\n exit()\n print(i+1)\n exit()\nelif c(k,n)>=m:\n m=m-(k-1)*(k-1)\n for i in range(n+5):\n if i*((i-1)/2+k*2)>m:\n print(i+k)\n exit()\nelse:\n m=m-c(k,n)\n print(m//n+n-k+1)"}, {"source_code": "from random import random\nimport math\nimport re\nimport fractions\n\n# N = input()\nN, P, K = map(int, raw_input().split(\" \"))\n\n\nl = K-1\nr = N-K\nP -= N\ndef test(x):\n return x * x <= P + max(0,x-l-1)*(x-l)/2 + max(0,x-r-1)*(x-r)/2\nc = 0\nil = 0\nir = P\nwhile il < ir - 1:\n mid = (il + ir)/2\n if test(mid):\n il = mid\n else:\n ir = mid\nprint il+1\n"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n print(pillows)\n print(pilCount)\n print(left, right)\n if left < 1 and right > hobs:\n pilCount+=pillows//hobs\n break\n elif left < 1 or right > hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)"}, {"source_code": "n, m, k = map(int,raw_input().split())\nx = 1\npods = n\nx_min = min(k-1,n-k)\nx_max = max(k-1,n-k)\nadd = 0\nadd_r = 0\nadd_l = 0\nlim_l = 0\nf=0\nfor j in range(n):\n add_r = j\n if(j<=x_min):\n add_l += j\n if(j+1>x_min):\n lim_l = j\n else:\n add_l += lim_l\n add += 1 + add_r + add_l\n #print add,add_r,add_l\n if(pods+add<=m):\n x += 1\n else: \n print x\n f = 1\n break\nif(f==0):\n print x"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n if left <= 1 and right >= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 1 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\nprint(pilCount)"}, {"source_code": "import math\n\n\ndef read(type=int):\n return type(input())\n\n\ndef read_arr(type=int):\n return [type(token) for token in input().split()]\n\n\ndef foo_c(n, i):\n return i * (n - i + 1)\n\n\ndef triangle(k, i):\n a, b = 1, (i + 1) // 2\n while a < b:\n m = (a + b + 1) // 2\n c = foo_c(i, m)\n if c > k:\n b = m - 1\n else:\n a = m\n return a\n\n\ndef foo2(m, i):\n k = int(math.sqrt(2 * m))\n return k if k * (k - 1) <= 2 * m else k - 1\n\n\ndef runB():\n n, m, k = read_arr()\n ans = 1\n m -= n\n k = min(k, n + 1 - k)\n if k > 1:\n t = 2 * k - 3\n a = triangle(m, t)\n m -= foo_c(t, a)\n ans += a \n l = a + max(a-1, k-1)\n if m >= l:\n ans += 1\n m -= l\n ans += m // n\n print(ans)\n else:\n a = min(n, foo2(m, n))\n ans += a\n m -= (a * (a + 1)) // 2\n if m >= a + 1:\n ans += 1\n m -= a + 1\n ans += m // n\n print(ans)\n\nrunB()\n"}, {"source_code": "#!/usr/bin/env python\n\ndef sum_range(l, r):\n return (l + r) * (r - l + 1) / 2\n\n\ndef main():\n n, m, k = map(int, raw_input().split(' '))\n L, R = sum_range(1, min(k - 1, m / n)), sum_range(1, min(n - k, m / n))\n print int((m + L + R) / n)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def f(tar,n,m,k):\n p=0\n if k==1 or k==n:\n k=n\n p+=((tar*(tar+1))//2)\n p+=(max(0,n-tar))\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p-=max(0,b)\n else:\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p+=(a-b)\n p+=(max(0,k-tar))\n u=n-k\n v=tar-u-1\n c=(v*(v+1))//2\n p+=(a-c)\n d=k+tar-1\n e=n-d\n p+=(max(0,e))\n p-=tar\n if p<=m:\n return True\n else:\n return False\n \nimport sys\n\nn,m,k=map(int,input().split())\nif n==m:\n print(1)\n sys.exit()\n \nlow,high,ans=m//n,10**18,m//n\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(mid,n,m,k)\n if x:\n ans=max(ans,mid)\n low=mid+1\n else:\n high=mid-1\n \nprint(ans)"}, {"source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nr=n-k\nl=k-1\ns=max(l,r)+1\nif l>r:\n S=((1+l)*(l)//2)+((s-1+s-r)*r//2)\nelse:\n S=((1+r)*(r)//2)+((s-1+s-l)*l//2)\nS+=max(l,r)+1\nL,R=max(l,r),min(l,r)\ns1=s\ns2=1\nS1=n\nS2=S\nif S>m:\n while S1!=S2:\n S1=S2\n s=(s1+s2)//2 \n if R>s:\n S2=((s+1)*s//2)+(L-s+1)+((s-1+s-R)*R//2)\n else:\n S2=((s+1)*s//2)+(L-s+1)+((s)*(s-1)//2)+(s-R)\n \n \n if S2>m:\n s1=s\n elif S2n/2:\n k=n-k+1\n\nif k*k>=m:\n print(int(m**0.2)+1)\n exit()\nelif c(k,n)>=m:\n #m=m-(k-1)*(k-1)\n #for i in range(n+5):\n # if i*((i-1)/2+k*2)>m:\n # print(i+k)\n # exit()\n m=m-(k-1)*(k-1)\n x=k-1\n for i in range(n+5):\n if i+k*2-1>m:\n print(i+x+1)\n exit()\n m=m-i-k*2+1\nelse:\n m=m-c(k,n)\n print((m-1)//n+n-k+1)\n"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\nsoon = False\nsumm = 0\ng = 1\nfor i in range(1, 1 + min(n-k+1, k)):\n summ += g\n g += 2\n if summ + g > m:\n soon = True\n break\ng -= 1\nif not soon:\n for i in range(1 + min(n-k+1, k), 1 + max(n-k+1, k)):\n summ += g\n g += 1\n if summ + g > m:\n soon = True\n break\nprint(summ, soon)\nprint(i)\nprint(1 + i if soon else 1 + i + (m - summ) // n)\n"}, {"source_code": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,random\n\n# read input\nn, m, k = map(int, input().split())\n\n# n, m, k = 3, 10, 3\n\nr = m - n\n\nans = 1\n\np = k - 1\nq = n - k\n\n# print(r, p, q)\n\ndef cost(i, p):\n\tc = p*i - p * (p+1)/2\n\treturn int(c)\n\nr0 = r\nle = 0\nri = r0\nif(r > 0):\n\ti = le\n\twhile(abs(le - ri) > 1):\n\t\tc = i + cost(i, p) + cost(i, q)\n\t\tr0 = r - c\n\t\t# print(c, r0, le, ri)\n\t\tif(r0 >= 0):\n\t\t\tle = i\n\t\telse:\n\t\t\tri = i\n\t\ti = (le + ri)//2 \n\t\n\tc1 = ri + cost(ri, p) + cost(ri, q)\n\tr0 = r - c1\n\tif(r0 >= 0):\n\t\tans += ri\n\telse:\n\t\tans += le\n\t\n\tprint(ans)\nelse:\n\tprint(ans)"}, {"source_code": "n, m, k = map(int, input().split())\nk -= 1\n\nres = 0\nr = 0\nwhile True:\n\n a = r - k\n u = 0\n if a > 0:\n u += (a + r) * (k + 1) // 2\n else:\n u += r * (r + 1) // 2\n\n b = r - (n - 1 - k)\n v = 0\n if b > 0:\n v += (b + r) * (n - k) // 2\n else:\n v += r * (r + 1) // 2\n\n t = u + v - r\n if t <= m:\n res = r\n if t > m :\n break\n r += 1\n\nprint(res)\n\n"}, {"source_code": "n, m, k = map(int,raw_input().split())\nx = max(k,n-k+1)\nx_min = min(k-1,n-k)\ns_min = sum(range(x_min+1))\nx_max = max(k-1,n-k)\ns_max = sum(range(x_max+1))\no = m + s_min + s_max\nx = (o-o%n)/n\npods = x*n - s_min - s_max\nif(m>=n*x_max - s_min - s_max):\n print x\nelse:\n x = 1\n pods = n\n \n add = 0\n add_r = 0\n add_l = 0\n lim_l = 0\n for j in range(n):\n add_r = j\n if(j<=x_min):\n add_l += j\n if(j+1>x_min):\n lim_l = j\n else:\n add_l += lim_l\n add += 1 + add_r + add_l\n print add, add_l, add_r\n if(pods+add<=m):\n \n x += 1\n else:\n print pods,add-1-add_r-add_l \n print x\n break"}, {"source_code": "#-*- coding:utf-8 -*-\n#/usr/bin/python3\n\nn, m, kk = map(int, input().split())\n\n\ndef getleft(x, k):\n\tres = 0\n\tif x < k:\n\t\tres = (1 + x) * x / 2\n\t\tx = k - x\n\t\tres += x // 2 * 3\n\t\tif x % 2 == 1:\n\t\t\tres += 2\n\telse:\n\t\tres = (x - k + 1 + x) * k / 2\n\treturn res\n\ndef getright(x, k):\n\treturn getleft(x, n - k + 1)\n\n\nlt = 1\nrt = m\nans = 1\n\n\nwhile lt <= rt:\n\tmid = (lt + rt) // 2\n\t#print(lt, rt, mid)\n\tta = getleft(mid, kk) + getright(mid, kk) - mid \n\tif ta <= m:\n\t\tlt = mid + 1; ans = mid\n\telse:\n\t\trt = mid - 1\n\nprint(ans)\n"}, {"source_code": "#!/usr/bin/env python3\ndef ri():\n return map(int, input().split())\n\nn, m, k = ri()\nm -= n\nans = 1\ncnt = 1\nif k + ans >= n and k - ans <= 1:\n if m > 0:\n ans += m//n\n print(ans)\n exit()\nwhile m > 0:\n ans += 1\n if k + ans >= n and k - ans <= 1:\n break\n if k + ans <= n:\n cnt += 1\n if k - ans >= 1:\n cnt += 1\n m -= cnt\n\nif m > 0:\n ans += m//n\nprint(ans)\n\n\n\n"}, {"source_code": "numbers = map(int, raw_input().split())\nn = numbers[0]\nm = numbers[1]\nk = numbers[2]\n\ndef sum(n):\n\treturn (n*(n+1))/2\n\nlo = 1\nhi = m\nif( hi - lo < 5 ):\n\tfor i in range(hi, lo-1, -1):\n\t\tif k > i:\n\t\t\tleft = sum(i-1) + k - i\n\t\telse:\n\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\tif n - k > i:\n\t\t\tright = sum( i -1) + n - k - i + 1\n\t\telse:\n\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\tprint left,\" \",right,\" \",i,\" pillows required for \",i\n\t\tif( left + right + i <= m ):\n\t\t\tprint i\n\t\t\texit(0)\n\tprint \"Trouble\"\n\texit(1)\nwhile lo < hi:\n\tif( hi - lo < 5 ):\n\t\tfor i in range(hi, lo-1, -1):\n\t\t\tif k > i:\n\t\t\t\tleft = sum(i-1) + k - i\n\t\t\telse:\n\t\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\t\tif n - k > i:\n\t\t\t\tright = sum( i -1) + n - k - i + 1\n\t\t\telse:\n\t\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\t\tprint left,\" \",right,\" \",i,\" pillows required for \",i\n\t\t\tif( left + right + i <= m ):\n\t\t\t\tprint i\n\t\t\t\texit(0)\n\t\tprint \"Trouble\"\n\t\texit(1)\n\tmid = (lo + hi)/2\n\t# print lo, mid, hi\n\tif k > mid:\n\t\tleft = sum(mid-1) + k - mid\n\telse:\n\t\tleft = sum(mid - 1) - sum( mid - k)\n\tif n - k > mid:\n\t\tright = sum( mid -1) + n - k - mid + 1\n\telse:\n\t\tright = sum( mid - 1) - sum( mid - (n-k) - 1 )\n\n\tif left + right + mid <= m:\n\t\tlo = mid\n\telse:\n\t\thi = mid - 1\n"}, {"source_code": "#!/usr/bin/env python\n\n\ndef sum_range(l, r):\n return (l + r) * (r - l + 1) / 2\n\n\ndef main():\n n, m, k = map(int, raw_input().split(' '))\n L, R = 0, m\n while L + 1 < R:\n x = L + (R - L) / 2\n l, r = x - (k - 1), x - (n - k)\n sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)\n if l < 1:\n sl += 1 - l\n if r < 1:\n sr += 1 - r\n if sl + sr - x <= m:\n L = x\n else:\n R = x \n print max(L, 1)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def read_input():\n line = input().strip().split()\n n = int(line[0])\n m = int(line[1])\n k = int(line[2])\n p = m - n\n k = max(n-k+1, k)\n y1 = (k * (k - 1)) // 2\n y2 = ((n - k)*(3*k - 3 - n)) // 2\n y = y1 + y2\n l = 1\n if p >= y:\n l += k - 1\n p -= y\n l += p//n\n return l\n else:\n c = n - k\n z = 0\n if p != 0:\n while True:\n z1 = (z * (z + 1)) // 2\n z2 = min(max(((n - k) * (z - 1 + z + k - n)) // 2, 0), z1)\n if z1 + z2 > p:\n break\n z += 1\n return z\n else:\n return z + 1\n\nif __name__ == \"__main__\":\n print(read_input())\n"}, {"source_code": "numbers = map(int, raw_input().split())\nn = numbers[0]\nm = numbers[1]\nk = numbers[2]\n\ndef sum(n):\n\treturn (n*(n+1))/2\n\nlo = 1\nhi = m\nwhile lo < hi:\n\tif( hi - lo < 5 ):\n\t\tfor i in range(hi, lo-1, -1):\n\t\t\tif k > i:\n\t\t\t\tleft = sum(i-1) + k - i\n\t\t\telse:\n\t\t\t\tleft = sum(i - 1) - sum( i - k)\n\t\t\tif n - k > i:\n\t\t\t\tright = sum( i -1) + n - k - i\n\t\t\telse:\n\t\t\t\tright = sum( i - 1) - sum( i - (n-k) - 1 )\n\t\t\t# print left,\" \",right,\" \",i,\" pillows required for \",i\n\t\t\tif( left + right + i <= m ):\n\t\t\t\tprint i\n\t\t\t\texit(0)\n\t\tprint \"Trouble\"\n\t\texit(1)\n\tmid = (lo + hi)/2\n\t# print lo, mid, hi\n\tif k > mid:\n\t\tleft = sum(mid-1) + k - mid\n\telse:\n\t\tleft = sum(mid - 1) - sum( mid - k)\n\tif n - k > mid:\n\t\tright = sum( mid -1) + n - k - mid\n\telse:\n\t\tright = sum( mid - 1) - sum( mid - (n-k) - 1 )\n\t\n\tif left + right + mid <= m:\n\t\tlo = mid\n\telse:\n\t\thi = mid - 1\n"}, {"source_code": "n, m, k = map(int, input().split())\nm -= n\n\ndef valid(x):\n a = min(k - 1, x - 1)\n b = min(n - k, x - 1)\n s1 = a * (x - 1 + x - a) // 2\n s2 = b * (x - 1 + x - b) // 2\n return s1 + s2 + x <= m\n\nl, r = -1, (1<<62)\nwhile r > l+1:\n m = l + r >> 1\n if valid(m):\n l = m\n else:\n r = m\nprint(l+1)\n"}, {"source_code": "hobbits_nr, pillows_nr, frodos_place = (int(x) for x in input().split())\n\npillows_nr = pillows_nr - hobbits_nr\nfrodos_pillows = 1\n\n# [left, right) -- it's a half-interval\nleft = frodos_place\nright = frodos_place + 1\n\nwhile pillows_nr >= right - left:\n pillows_nr -= right - left\n frodos_pillows += 1\n right += 1\n left += -1\n if right > hobbits_nr + 1:\n right = hobbits_nr + 1\n if left < 1:\n left = 1\nprint(pillows_nr)\nprint(left, right)\nprint(frodos_pillows)\n"}, {"source_code": "\"\"\"\nhttp://codeforces.com/contest/760/problem/B\nYYYYYYYYYYNNNNNNNNN\n\n\nNNNNYYYYY : return left\nYYYYYYNNN : return right\n\"\"\"\n\nn, m, k = map(int, raw_input().split())\n\ndef solve():\n\n\tlo = 0\n\thi = m\n\n\twhile (lo + 1 < hi):\n\t\tmid = (lo + hi) / 2\n\n\t\tif (check(mid)):\n\t\t\tlo = mid\n\n\t\telse:\n\t\t\thi = mid \n\n\treturn lo\n\n\ndef check(mid):\n\t\n\tidx1 = k - 1\n\tidx2 = k + 1\n\n\tnum_pills = mid\n\n\the_will_get1 = mid - 1\n\twhile (idx1 > 0):\n\t\tif (he_will_get1 <= 0): \n\t\t\the_will_get1 = 1\n\t\tnum_pills += he_will_get1\n\t\the_will_get1 -= 1\n\t\tidx1 -= 1\n\n\the_will_get2 = mid - 1\n\twhile (idx2 <= n):\n\t\tif (he_will_get2 <= 0): \n\t\t\the_will_get2 = 1\n\t\tnum_pills += he_will_get2\n\t\the_will_get2 -= 1\n\t\tidx2 += 1\n\t# import pdb; pdb.set_trace()\n\tif (num_pills > m):\n\t\treturn False\n\treturn True\n\n\nprint solve()\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "#!/usr/bin/env python\n\n\ndef sum_range(l, r):\n return (l + r) * (r - l + 1) / 2\n\n\ndef main():\n n, m, k = map(int, raw_input().split(' '))\n L, R = 0, m\n while L + 1 < R:\n x = L + (R - L) / 2\n l, r = x - (k - 1), x - (n - k)\n sl, sr = sum_range(max(1, l), x), sum_range(max(1, r), x)\n if l < 1:\n sl += 1 - l\n if r < 1:\n sr += 1 - r\n if sl + sr - x <= m:\n L = x\n else:\n R = x \n print L\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "from math import ceil\n\nn, m, k = map(int, input().split())\n\n\ndef check(middle, n, m, k):\n if k != 1 and k != n:\n return middle - ((m - middle) // (n - 1)) < 2\n return middle - ceil((m - middle) / (n - 1)) < 2\n\nleft = 0\nright = m\nwhile right - left > 1:\n middle = (right + left) // 2\n if check(middle, n, m, k):\n left = middle\n else:\n right = middle\nprint(left)\n#print(check(3, n, m , k))"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n if left <= 2 and right >= hobs-1:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs-1:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n## print(pillows)\n## print(pilCount)\n## print(left, right)\n if left <= 2 and right >= hobs-1:\n pilCount+=pillows//hobs\n break\n elif left <= 2 or right >= hobs-1:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n left-=1\n right+=1\n pilCount+=1\n turn+=1\n \nprint(pilCount)\n\n\n\n\n"}, {"source_code": "#!/usr/bin/env python\n\ndef sum_range(l, r):\n return (l + r) * (r - l + 1) / 2\n\n\ndef main():\n n, m, k = map(int, raw_input().split(' '))\n L, R = sum_range(1, min(k - 1, m / n)), sum_range(1, min(n - k, m / n))\n print int((m + L + R) / n)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def f(tar,n,m,k):\n p=0\n if k==1 or k==n:\n k=n\n p+=((tar*(tar+1))//2)\n p+=(max(0,n-tar))\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p-=max(0,b)\n else:\n u=k-1\n v=tar-u-1\n a=(tar*(tar+1))//2\n b=(v*(v+1))//2\n p+=(a-b)\n p+=(max(0,k-tar))\n u=n-k\n v=tar-u-1\n c=(v*(v+1))//2\n p+=(a-c)\n d=k+tar-1\n e=n-d\n p+=(max(0,e))\n p-=tar\n if p<=m:\n return True\n else:\n return False\n\nn,m,k=map(int,input().split())\n\nlow,high,ans=m//n,10**18,m//n\nwhile(low<=high):\n mid=low+(high-low)//2\n x=f(mid,n,m,k)\n if x:\n ans=max(ans,mid)\n low=mid+1\n else:\n high=mid-1\n\nprint(ans)"}, {"source_code": "a = [int(i) for i in raw_input().split()]\nk=a[2]\nn=a[0]\nm=a[1]\nl=k-1\nr=n-k\nm-=n\np=1\nans=2\nif m==0:\n print 1\nelif m==1:\n print 2\n\nelse:\n m-=1\n while m>0:\n if l>0:\n p+=1\n l-=1\n if r>0:\n p+=1\n r-=1\n m-=p\n if m<0:\n break\n ans+=1\nprint ans\n"}, {"source_code": "import math\nn, m, k = map(int, input().split(' '))\n\ndiv = (m/n)\nmod = m%n\n\nif mod == 0 or mod == 1:\n if div%2 == 0:\n print(math.ceil(div+1))\n else:\n print(math.ceil(div))\nelse:\n print(mod)\n\n"}, {"source_code": "def just_sum(n):\n return (n * (n + 1)) // 2\n\n\ndef get_sum(a, b):\n return just_sum(b) - just_sum(a - 1)\n\n\ndef check(middle):\n left = k - 1\n right = n - k\n \n if left < m:\n left_sum = get_sum(middle - left, middle - 1)\n else:\n left_sum = just_sum(middle - 1) + (left - (middle - 1))\n \n if right < m:\n right_sum = get_sum(middle - right, middle - 1)\n else:\n right_sum = just_sum(middle - 1) + (right - (middle - 1))\n \n return left_sum + right_sum + middle <= m\n \n \nn, m, k = map(int, input().split())\n\nl = 1\nr = m + 1\nwhile l < r - 1:\n middle = (l + r) // 2\n if check(middle):\n l = middle\n else:\n r = middle\n \nprint(l)"}, {"source_code": "hobs, pillows, frodo = input().split()\nhobs, pillows, frodo = int(hobs), int(pillows), int(frodo)\nturn = 0\nleft = frodo\nright = frodo\npilCount = 1\npillows-=hobs\n\nwhile True:\n left-=1\n right+=1\n if left <= 1 and right >= hobs:\n pilCount+=pillows//hobs\n break\n elif left <= 1 or right >= hobs:\n pillows-=(turn+1)\n else:\n pillows-=(turn*2+1)\n\n if pillows < 0:\n break\n\n pilCount+=1\n turn+=1\nprint(pilCount)"}, {"source_code": "from math import *\nn,m,k=map(int,input().split())\nr,l=0,0\n\nif k!=n:\n r=n-k\nif k!=1:\n l=k-1\nif l>r:\n S=((1+l)*(l)//2)+((l+n)*r//2)\nelse:\n S=((1+r)*(r)//2)+((r+n)*l//2)\nS+=k\ns=max(l,r)+1\nL,R=max(l,r),min(l,r)\nif L!=R:\n B=False\n L-=1\nelse:\n L-=1\n R-=1\n B=True\ni=0\nwhile S>m:\n s=s-1\n S-=l+r\n if L==0 :\n s-=1\n S-=n-2*i\n i+=1\n if L>0:\n L-=1\n if B:\n R-=1\n elif L==R:\n B=True\n \n \nif S!=m and (m-S)//n!=0:\n s+=(m-S)//n\nprint(s)\n\n \n \n\n \n"}], "src_uid": "da9ddd00f46021e8ee9db4a8deed017c"} {"nl": {"description": "Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the end of it are also considered to be fillers. For example, the words ogo, ogogo, ogogogo are fillers, but the words go, og, ogog, ogogog and oggo are not fillers.The fillers have maximal size, for example, for ogogoo speech we can't consider ogo a filler and goo as a normal phrase. We should consider ogogo as a filler here.To print the interview, Polycarp has to replace each of the fillers with three asterisks. Note that a filler word is replaced with exactly three asterisks regardless of its length.Polycarp has dealt with this problem in no time. Can you do the same? The clock is ticking!", "input_spec": "The first line contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100)\u00a0\u2014 the length of the interview. The second line contains the string s of length n, consisting of lowercase English letters.", "output_spec": "Print the interview text after the replacement of each of the fillers with \"***\". It is allowed for the substring \"***\" to have several consecutive occurences.", "sample_inputs": ["7\naogogob", "13\nogogmgogogogo", "9\nogoogoogo"], "sample_outputs": ["a***b", "***gmg***", "*********"], "notes": "NoteThe first sample contains one filler word ogogo, so the interview for printing is \"a***b\".The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to \"***gmg***\"."}, "positive_code": [{"source_code": "import re\nn = int(input())\ns = input()\nres = re.sub(\"ogo(go)*\", \"***\", s)\nprint(res)"}, {"source_code": "n = int(raw_input())\ns = raw_input().strip()\nparts = []\nlast = 0\npos = 3\nwhile pos <= n:\n if s[pos-3:pos] == 'ogo':\n head, tail = pos-3, pos\n for i in range(pos+2, n+1, 2):\n if s[i-2:i] == 'go':\n tail = i\n else:\n break\n parts.append(s[last:head])\n parts.append('***')\n last = tail\n pos = last + 3\n else:\n pos += 1\nparts.append(s[last:])\nt = ''.join(parts)\nprint(t)\n"}, {"source_code": "numb = int(input())\ninp = input()\n\ntoReplace = []\n\nnextStart = None\nnextEnd = None\nn = 0\nwhile n < len(inp) - 1:\n if(nextStart is not None):\n if(inp[n] is \"g\" and inp[n+1] is \"o\"):\n nextEnd = n+1\n n += 1\n elif(nextEnd is not None):\n toReplace.append(inp[nextStart:nextEnd+1])\n nextStart = None\n nextEnd = None\n else:\n nextStart = None\n nextEnd = None\n \n if(nextStart is None):\n if(inp[n] is \"o\"):\n nextStart = n\n n += 1\n \nif(nextEnd is not None and nextStart is not None):\n toReplace.append(inp[nextStart:nextEnd+1])\n\nfor i in toReplace:\n inp = inp.replace(i, \"***\", 1)\nprint(inp)"}, {"source_code": "import re\nn = raw_input()\ns = raw_input()\nprint re.sub(\"o([g][o])+\", \"***\", s)"}, {"source_code": "if __name__ == '__main__':\n n = int(input())\n line = str(input())\n rest = str()\n pos = 0\n while True:\n fact = 3\n if pos + fact <= n and line[pos:pos + fact] == 'ogo':\n pos += fact\n fact = 2\n while True:\n if pos + fact <= n and line[pos:pos + fact] == 'go':\n pos += fact\n else:\n rest += '***'\n break\n else:\n rest += line[pos]\n pos += 1\n if pos == n:\n break\n print(rest)\n"}, {"source_code": "_ = raw_input()\ns = raw_input()\nfor i in xrange(50, 0, -1):\n s = s.replace('o'+'go'*i, '***')\nprint s"}, {"source_code": "from math import ceil\ninput()\nx = input()\nfor i in range(100, 0, -1):\n ss = 'o' + 'go' * i\n while ss in x:\n x = x.replace(ss,'***')\nprint(x)\n "}, {"source_code": "'''\nusage:\n python prob1.py\n'''\n\n\nimport sys\nimport os\n\ndef main(argv=None):\n line=raw_input()\n line=line.strip()\n len_int=int(line)\n line=raw_input()\n line=line.strip()\n\n flag=0\n i=0\n ans=\"\"\n while i g***goo***\n"}, {"source_code": "n = int(raw_input())\ns = raw_input().strip()\nparts = []\nlast = 0\npos = 3\nwhile pos <= n:\n if s[pos-3:pos] == 'ogo':\n head, tail = pos-3, pos\n for i in range(pos+2, n+1, 2):\n if s[i-2:i] == 'go':\n tail = i\n else:\n break\n parts.append(s[last:head])\n parts.append('***')\n last = tail\n pos = last + 3\n else:\n pos += 1\nparts.append(s[last:])\nt = ''.join(parts)\nprint(t)\n"}, {"source_code": "n = int(input())\ns = input()\nimport re\n\nprint(re.sub('ogo(go)*', '***',s))\n"}, {"source_code": "from re import *\ninput()\ns=input()\nprint(sub(r'ogo(go)*',\"***\",s))"}, {"source_code": "input()\ns = input()\nfor i in range(50,0,-1):\n s = s.replace('o'+'go'*i,'***')\nprint(s)"}, {"source_code": "read = lambda: map(int, input().split())\nn = int(input())\ns = input()\ni = 0\na = []\nwhile i < n:\n if s[i] == 'o':\n cnt = 0\n while i + 2 < n and s[i + 1:i + 3] == 'go':\n i += 2\n cnt += 1\n if cnt:\n a.append('***')\n else:\n a.append(s[i])\n else:\n a.append(s[i])\n i += 1\nprint(''.join(a))\n"}, {"source_code": "#!/usr/bin/env python3\n\nimport re\n\np = re.compile('o(go)+')\n\nN = int(input())\nS = input()\n\nS = re.sub(p, '***', S)\n\nprint(S)\n"}, {"source_code": "#Name:S.M.MILOY\n#Department Of CSE,BRUR\n#a,b=list(map(int,input().split()))\n#l=list(map(int,input().split(' ')))\n#n=int(z())\nz=input\n#for i in range(n):\nfrom math import gcd\n\nn=int(z())\nl=z()\n\np='ogo'\nfor i in range(n,-1,-1):\n r=p+(i*'go')\n if r in l:\n l =l.replace(r, '***')\n \nprint(l)\n"}, {"source_code": "import re\nnum = input()\nx = input()\ny = re.sub('o(go)+','***',x)\nprint(y)\n"}, {"source_code": "input()\ns = input()\nfor i in range(100, -1, -1):\n\ts = s.replace('ogo'+'go'*i, '***')\n\nprint(s)\n"}, {"source_code": "x = int(input())\ny = input()\n\ni = len(y)\nwhile i > 1:\n i = i - 1\n if (\"og\"*i + \"o\") in y:\n y = y.replace((\"og\"*i + \"o\"), \"***\")\n \nprint(y) "}, {"source_code": "n = int(input())\ntext = input()\nfor i in range(50, -1, -1):\n text2 = \"ogo\" + \"go\" * i\n if text.count(text2) > 0:\n text = text.replace(text2, \"***\")\nprint(text)"}, {"source_code": "def process(s, start, end):\n if start != -1 and end != -1:\n for i in xrange(start, start + 3):\n s[i] = '*'\n for i in xrange(start + 3, end + 1):\n s[i] = ''\n\n\nstates = [('o', 1), ('g', 2), ('o', 3), ('g', 2)]\nn = int(raw_input())\ns = list(raw_input())\nstart, end = -1, -1\nstate = 0\n\ni = 0\n\nwhile i < len(s):\n if (s[i] == states[state][0]):\n if start == -1:\n start = i\n if state == 2:\n end = i\n state = states[state][1]\n else:\n process(s, start, end)\n state = 0\n start, end = -1, -1\n if s[i] == 'o':\n i -= 1\n i += 1\n\nprocess(s, start, end)\nprint(''.join(s))\n"}, {"source_code": "import re\n\ninput()\ns = input()\n\nprint(re.sub(\"ogo(go)*\", \"***\", s))\n\n"}, {"source_code": "import re\nn = int(input())\nprint(re.sub(\"ogo(go)*\", \"***\", raw_input()))"}, {"source_code": "if __name__ == '__main__':\n n, s = int(input()), input()\n result_array = []\n left = 0\n while left <= n - 3:\n if s[left: left + 3] == 'ogo':\n left += 3\n if left >= n:\n result_array.append('***')\n break\n while left + 1 < n and s[left: left + 2] == 'go':\n left += 2\n result_array.append('***')\n else:\n result_array.append(s[left])\n left += 1\n while left < n:\n result_array.append(s[left])\n left += 1\n print(''.join(result_array))"}, {"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\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 n = int(input.readline())\n s = list(str(input.readline()))\n init = [0]*(n+1)\n rep,res = '***',''\n temp = 0\n tr = [] \n for i in range(n):\n if i!=0 and i+1!=n and s[i]=='g' and s[i-1]=='o' and s[i+1]=='o':\n tr.append(i)\n \n\n \n #print tr\n for i in range(n):\n cond = -1\n for j,x in enumerate(tr):\n if i==x:\n cond = 1\n break\n elif i+1==x or i-1==x :\n cond = 0\n break\n if cond==-1:\n res+=s[i]\n elif cond==1:\n if s[i-2]=='g' and s[i-3]=='o':\n continue\n res+=rep\n elif cond ==0:\n continue\n\n\n output = res\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\nthreading.Thread(target=main).start()\n\n"}, {"source_code": "iii = input()\ns = input()\ni = s.find(\"ogo\")\nwhile(i >= 0):\n for j in range(i, i + 3):\n s = s[:i]+\"***\"+s[i+3:]\n j = i + 3\n while(s[j:j + 2] == \"go\"):\n s = s[:j]+s[j+2:]\n i = s.find(\"ogo\")\nprint(s)\n"}, {"source_code": "d=int(raw_input())\niv=raw_input()\nresult=\"\"\ndef getO(x):\n ret=0\n for i in x:\n if(len(x)>=2 and x[0]=='g' and x[1]=='o'):\n x=x[2:]\n ret+=2\n else:\n return ret-1\n return ret-1\ni=0 \nwhile(i=2):\n i+=k\n result+=\"***\"\n else:\n result+=iv[i]\n i+=1\n else:\n result+=iv[i]\n i+=1\n #z=raw_input()\n #print i,result\nprint result\n "}, {"source_code": "n = int(input())\ns = input()\nimport re\n\nprint(re.sub('ogo(go)*', '***',s))\n"}, {"source_code": "import re\n\nn = int(input())\ns = input()\n\nprint(re.sub('ogo(go)*' , '***' , s))\n\n\n\n\n"}, {"source_code": "n = int(input())\ns = input()\nrets = \"\"\nnex = 'o'\nhold = \"\"\nfor char in s:\n if char == nex:\n hold += char\n if nex == 'o':\n nex = 'g'\n else:\n nex = 'o'\n else:\n if len(hold) > 2:\n rets += \"***\"\n if hold[-1] == 'g':\n rets += 'g'\n else:\n rets += hold\n hold = \"\"\n nex = 'o'\n if char == 'o':\n hold += char\n nex = 'g'\n else:\n rets += char\n\nif len(hold) > 2:\n rets += \"***\"\n if hold[-1] == 'g':\n rets += 'g'\nelse:\n rets += hold\n\n\n\nprint(rets)\n"}, {"source_code": "import re\n\ninterview = int(input())\nspeech = input()\n\nspeech = re.sub(r'ogo(go)*', '***', speech)\nprint(speech)\n\n"}, {"source_code": "s=input()\ns=input()\nsogo='og'*50\n\ni=0\nwhile i=len(s) or s[i:k]!=sogo[0:k-i]:\n srep=s[i:k-2]\n else:\n srep=s[i:k]\n s=s.replace(srep,'***',1)\n i=k\nprint(s)\n\n\n\n"}, {"source_code": "n=int(input())\ns=input()\nmop=s\nfor i in range(len(s)-2):\n if mop[i:i+3]==\"ogo\":\n j=i\n while mop[j+3:j+5]==\"go\" and j 1:\n i = i - 1\n if (\"og\"*i + \"o\") in y:\n y = y.replace((\"og\"*i + \"o\"), \"***\")\n \nprint(y) "}, {"source_code": "n = int(input())\ns = input()\nx = 0\nflag = 0\nwhile x < len(s) - 2:\n if s[x: x + 3] == 'ogo':\n right = x\n left = x + 3\n flag = 0\n for i in range(x + 3, len(s) - 1, 2):\n if s[i : i+ 2] == 'go' and flag == 0:\n left += 2\n else:\n flag = 1\n s = s[:right] + '***' + s[left:]\n x += 1\nprint(s)"}, {"source_code": "\ninput()\ns = input()\nl = s.find('ogo')\nwhile l != -1:\n r = l + 3\n while s[r:r+2] == 'go': r += 2\n s = s[:l] + '***' + s[r:]\n l = s.find('ogo')\nprint(s)"}, {"source_code": "input()\ns=input()\nflag=0\nans=''\n#http://codeforces.com/problemset/problem/729/A\nwhile(s):\n if not flag:\n if s.startswith('ogo'):\n flag=1\n s=s[3:]\n ans+='***'\n else:\n ans+=s[0]\n s=s[1:]\n else:\n if s.startswith('go'):\n s=s[2:]\n else:\n flag=0\nprint(ans)\n"}, {"source_code": "import re\n\nr = r\"(ogo(go)*)\"\ninput()\ns = input()\n\ns = re.sub(r, '***', s)\n\nprint(s)\n"}, {"source_code": "n = input()\ns = input()\nwhile 'ogo' in s:\n n = 0\n r = 'ogo'\n i = s.index(r)\n while s[i+3+2*n:i+5+2*n] == 'go':\n r += 'go'\n n += 1\n s = s.replace(r, '***', 1)\nprint(s)\n"}, {"source_code": "R = raw_input\nn = int(R())\ns = R()\nf1 = \"ogo\"\nf2 = \"go\"\nstate = 0\nstart = 0\nout = []\nwhile start < n:\n if (state == 0 or state == 1) and start <= n - 3 and s[start : start + 3] == f1:\n state = 1\n start += 3\n for _ in xrange(3): out.append('*')\n elif state == 1 and start <= n - 2 and s[start : start + 2] == f2:\n state = 1\n start += 2\n else:\n out.append(s[start])\n state = 0\n start += 1\nprint ''.join(out)\n"}, {"source_code": "n = int(input())\ns = input()\nl = list(s)\ni = 0\nwhile i < n:\n\tj = i\n\tif s[i] == \"o\":\n\t\tflag = 0\n\t\twhile s[i+1:i+3] == \"go\":\n\t\t\tflag +=1\n\t\t\ti = i+2\n\t\tif flag >= 1:\n\t\t\tfor x in range(j,j+3):\n\t\t\t\tl[x] = \"*\"\n\t\t\tfor x in range(j+3,i+1):\n\t\t\t\tl[x] = \"+\"\n\ti+=1\nans = \"\"\nfor i in l:\n\tif i != \"+\":\n\t\tans+=i\nprint(ans)"}, {"source_code": "import re\ninput()\na = raw_input()\nprint re.sub(\"ogo(go)*\",\"***\",a)"}, {"source_code": "import math\nimport string\nimport itertools\nfrom random import *\n\nn = int(raw_input())\ns = raw_input()\n\n\nfill = 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo'\n\nfor i in range(50):\n\tl = fill[:len(fill)-2*i]\n\ts = s.replace(l, '***', 35)\n\nprint s"}, {"source_code": "import re\n\nn = input()\ns = raw_input()\n\ns+='##'\n\nwhile s.find(\"ogo\") != -1:\n r = s.find(\"ogo\") + 3\n for i in range(s.find(\"ogo\") + 3, len(s) - 2, 2):\n if(s[i] == 'g' and s[i + 1] == 'o'):\n r += 2\n else:\n break\n s = s[:s.find('ogo')] + '***' + s[r:]\n\nprint s[:len(s) - 2]\n\n\n\n"}, {"source_code": "import re\ninput()\nprint(re.sub(\"ogo(go)*\", \"***\", input()))\n"}, {"source_code": "import re\ninput()\nprint re.sub('o(go)+','***',raw_input())\n"}, {"source_code": "import sys\nimport math\nimport bisect\nimport itertools\nimport random\nimport re\n\ndef main():\n n = int(input())\n s = input()\n s = re.sub(r'ogo(go)*', '***', s)\n print(s)\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "n = int(input())\ns = input()\ni = n\nt = \"o\" + (\"go\" * i)\nwhile i > 0:\n while s.count(t) >= 1:\n x = s.find(t)\n l = len(t)\n s = s[0:x] + \"***\" + s[x+l::]\n i -= 1\n t = \"o\" + (\"go\" * i)\nprint(s)"}, {"source_code": "input()\ns = input()\nfor i in range(100, -1, -1):\n\ts = s.replace('ogo'+'go'*i, '***')\n\nprint(s)\n"}, {"source_code": "n = int(input())\ntext = input()\nfor i in range(50, -1, -1):\n text2 = \"ogo\" + \"go\" * i\n if text.count(text2) > 0:\n text = text.replace(text2, \"***\")\nprint(text)"}, {"source_code": "\nn = int(input())\nword = input()\nsub = \"ogo\"\nif sub not in word:\n print(word)\n\nelse:\n for i in range(n-3,-1,-1):\n if (\"ogo\"+(\"go\"*i)) in word:\n word = word.replace((\"ogo\"+(\"go\"*i)), \"***\")\n \n print(word)\n"}, {"source_code": "import re\ninput()\nprint(re.sub(r\"ogo(go)*\", \"***\", input()))"}, {"source_code": "\nn = input()\ns = input()\nwhile ('ogo' in s):\n\tx = 'ogo'\n\twhile (x in s): x += 'go'\n\tx = x[:-2]\n\ts = s.replace(x,'***')\n\t\n\t\nprint(s)\n"}, {"source_code": "#!/usr/bin/python3\n\nimport re\n\ndef problem(inp, n):\n replacement = '***'\n reg = '(og)*o'\n ans = re.sub('(og)+o', replacement, inp)\n return ans\n\nn = int(input())\ninp = input()\nans = problem(inp, n)\nprint(ans)\n"}, {"source_code": "import re\n\nN, s = input(), input()\n\nprint(re.sub(r\"ogo(go)*\", \"***\", s))"}, {"source_code": "n = int(input())\ns = input()\nm = max((n - 1) // 2, 1)\na = [''] * m\na[0] = 'ogo'\nfor i in range(1, m):\n a[i] = a[i - 1] + 'go'\nfor pattern in a[::-1]:\n s = s.replace(pattern, '***')\nprint(s)\n"}, {"source_code": "#!/usr/bin/env python3\n\nfrom sys import stdin\nimport re\n\n\ndef main():\n n, = stdin_get_ints_from_line()\n s = stdin_get_string_from_line()\n\n print(re.sub(r'(ogo((go)+)?)', '***', s))\n\n\ndef stdin_get_ints_from_line():\n return (int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_ints_list_from_line():\n return list(int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_string_from_line():\n return stdin.readline().strip()\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import re\nn = int(input())\ns = input()\nres = re.sub(r'ogo(go)*', '***', s)\nprint(res)"}, {"source_code": "import re;input();print re.sub('o(go)+','***',raw_input())"}, {"source_code": "#!/usr/bin/env python3\n\nfrom sys import stdin\nimport re\n\n\ndef main():\n n, = stdin_get_ints_from_line()\n s = stdin_get_string_from_line()\n\n print(re.sub(r'(ogo((go)+)?)', '***', s))\n\n\ndef stdin_get_ints_from_line():\n return (int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_ints_list_from_line():\n return list(int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_string_from_line():\n return stdin.readline().strip()\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import re\nraw_input()\nprint(re.sub('o(go)+','***', raw_input()))\n\n# re.sub(pattern, repl, string, count=0, flags=0)\n# A library of regulars expresions.\n#\n# e.g. :\n# re.sub('o(go)', '***', \"gogogooogo\") ==> g***goo***\n"}, {"source_code": "import re\n\ninterview = int(input())\nspeech = input()\n\nspeech = re.sub(r'ogo(go)*', '***', speech)\nprint(speech)\n\n"}, {"source_code": "#n=int(input())\n#s=input()\n#b='ogo'\n#c='go'\n#sai=''\n#i=0\n#while True:\n# if s[i:i+3]==b:\n# k=i+3\n# while True:\n# if s[k:k+2]==c:\n# l=k\n# k=k+2\n# else:\n# v=3*'*'\n# sai=sai+v\n# i=k\n# break \n# else:\n# if i>=n:\n# print(sai)\n# break\n# else:\n# sai=sai+s[i]\n# i=i+1\nn = int(input())\ntext = input()\nfor i in range(50, -1, -1):\n text2 = \"ogo\" + \"go\" * i\n if text.count(text2) > 0:\n text = text.replace(text2, \"***\")\nprint(text) "}, {"source_code": "import re\ninput()\ns=raw_input()\nprint re.sub('ogo(go)*', '***', s)\n"}, {"source_code": "t=int(raw_input())\ns=str(raw_input())\nind=s.find('ogo')\nwhile(ind>=0):\n\tb=ind\n\te=ind+3\n\tp=1;q=0\n\t#print ind,p,q\n\twhile p==1 or q==1:\n\t\tp=0;q=0\n\t\tif(b-2>=0 and s[b-2:b]=='og'):\n\t\t\tb-=2\n\t\t\tp=1\n\t\tif(e+1<=(t-1) and s[e:e+2]=='go'):\n\t\t\te+=2\n\t\t\tq=1\n\t\t#print s[e:e+2],e\n\ts=s.replace(s[b:e],'***',1)\n\t\n\tind=s.find('ogo')\nprint s\n\t\n"}, {"source_code": "input()\ns = input()\n\nwhile 'ogogo' in s:\n s = s.replace('ogogo', 'ogo')\n\nprint(s.replace('ogo', '***'))"}, {"source_code": "import re\nn = int(input())\ns = input()\nres = re.sub(r'ogo(go)*', '***', s)\nprint(res)"}, {"source_code": "#Justin Hershberger\n#Py3.5\n\nimport fileinput\nimport re\n\ndef test():\n\tpass\nif __name__ == '__main__':\n\tnum_args = 2\n\tfor arg in range(num_args):\n\t\tif arg == 0:\n\t\t\tn = input()\n\t\telse:\n\t\t\ts = input()\n\n\t#re.sub will find any match to the pattern given and replace it with what you specify\n\tprint(re.sub(r'o(go)+', '***', s))\n"}, {"source_code": "def search(pat, txt, q):\n M = len(pat)\n N = len(txt)\n i = 0\n j = 0\n p = 0\n t = 0\n h = 1\n d = 256\n l = list()\n \n for i in range(M-1):\n h = (h*d)%q\n \n for i in range(M):\n p = (d*p + ord(pat[i]))%q\n t = (d*t + ord(txt[i]))%q\n \n for i in range(N-M+1):\n if p==t:\n for j in range(M):\n if txt[i+j] != pat[j]:\n break\n j+=1\n if j==M:\n l.append(i)\n \n if i < N-M:\n t = (d*(t-ord(txt[i])*h) + ord(txt[i+M]))%q\n \n if t < 0:\n t = t+q\n\n return l\n\nn = int(input())\ntxt = input()\npat = 'ogo'\nif len(txt) < 3:\n print(txt)\nelse:\n ll = search(pat, txt, 101)\n s = ''\n prev = -5\n flag = False\n count = 0\n\n for i in range(len(txt)):\n if i in ll:\n if i-2 != prev:\n s += ('*'*3)\n prev = i\n count = 2\n else:\n if count:\n count -= 1\n else:\n s += txt[i]\n\n print(s)"}, {"source_code": "import re\n\nn = int(raw_input())\ns = str(raw_input().strip())\n\nt = re.sub(r'o(go)+', '***', s)\nprint t\n\n"}, {"source_code": "from sys import stdin, stdout\nn = int(stdin.readline())\ns = stdin.readline().strip()\nans = ''\n\ni = 0\nwhile (i < n):\n if i + 2 < n and s[i:i + 3] == 'ogo':\n last = i + 3\n while last + 1 < n and s[last: last + 2] == 'go':\n last += 2\n ans += '***'\n i = last\n else:\n ans += s[i]\n i += 1\nstdout.write(ans)"}, {"source_code": "from sys import stdin\nimport re\n\nregex = re.compile(r\"ogo(go)*\")\nlines = stdin.readlines()\n\noutString = re.sub(regex, \"***\", lines[1])\nprint(outString)"}, {"source_code": "rr=raw_input\nrrI = lambda: int(rr())\nrrM = lambda: map(int,rr().split())\ndebug=0\nif debug:\n fi = open('t.txt','r')\n rr=lambda: fi.readline().replace('\\n','')\n\nN = int(rr())\nS = rr()\nA = []\nwhile S:\n if S.startswith('ogo'):\n S = S[3:]\n while S and S.startswith('go'):\n S = S[2:]\n A.append('***')\n else:\n A.append(S[0])\n S = S[1:]\n\nprint \"\".join(A)\n"}, {"source_code": "import re\ninput()\nprint(re.sub(\"ogo(go)*\", \"***\", input()))"}, {"source_code": "import sys\nn = int(input())\ns = input()\ns += '%%'\na = [0] * n\ni = 0\nwhile i < n:\n if s[i : i + 3] == 'ogo':\n a[i] = '*'\n a[i + 1] = '*'\n a[i + 2] = '*'\n i += 3\n while s[i : i + 2] == 'go':\n a[i] = ''\n a[i + 1] = ''\n i += 2\n else:\n a[i] = s[i]\n i += 1\nprint(*a, sep = '')"}, {"source_code": "from math import ceil\nn = int(input())\nx = input()\np = ['ogo']+['ogo'+'go'*i for i in range(1,50)]\nj = ceil((n-3)/2)\nif n<3:\n print(x)\nelse:\n while j>=0:\n if p[j] in x:\n x = x.replace(p[j],'***')\n else:\n j = j-1\n print(x)"}, {"source_code": "#Justin Hershberger\n#Py3.5\n\nimport fileinput\nimport re\n\ndef test():\n\tpass\nif __name__ == '__main__':\n\tnum_args = 2\n\tfor arg in range(num_args):\n\t\tif arg == 0:\n\t\t\tn = input()\n\t\telse:\n\t\t\ts = input()\n\n\t#re.sub will find any match to the pattern given and replace it with what you specify\n\tprint(re.sub(r'o(go)+', '***', s))\n"}, {"source_code": "#Name:S.M.MILOY\n#Department Of CSE,BRUR\n#a,b=list(map(int,input().split()))\n#l=list(map(int,input().split(' ')))\n#n=int(z())\nz=input\n#for i in range(n):\nfrom math import gcd\n\nn=int(z())\nl=z()\n\np='ogo'\nfor i in range(n,-1,-1):\n r=p+(i*'go')\n if r in l:\n l =l.replace(r, '***')\n \nprint(l)\n"}, {"source_code": "ml = ['ogo']\nfor i in range(100):\n ml.append(ml[-1]+'go')\n\ninput()\ns = input()\nfor i in ml[::-1]:\n s = s.replace(i, '***')\nprint(s)"}, {"source_code": "import re\nn = int(input())\na = input()\nprint(re.sub(\"ogo(go)*\", \"***\", a))\n"}, {"source_code": "def main():\n n = input()\n s = raw_input()\n res = \"\"\n begin = -1\n i = 0\n while i < n:\n if s[i: i + 3] == \"ogo\":\n begin = 0\n res += \"***\"\n i += 3\n elif s[i: i + 2] == \"go\" and begin == 0:\n i += 2\n else:\n res += s[i]\n begin = -1\n i += 1\n\n print res\n\nmain()"}, {"source_code": "s=input()\ns=input()\nsogo='og'*50\n\ni=0\nwhile i=len(s) or s[i:k]!=sogo[0:k-i]:\n srep=s[i:k-2]\n else:\n srep=s[i:k]\n s=s.replace(srep,'***',1)\n i=k\nprint(s)\n\n\n\n"}, {"source_code": "n = int(raw_input())\ns = raw_input().strip()\nwhile \"ogo\" in s:\n rep = \"ogo\"\n p = s.index(\"ogo\")\n while s[p+2:p+5] == \"ogo\":\n rep += \"go\"\n p += 2\n s = s.replace(rep, \"***\", 1)\nprint s "}, {"source_code": "import re\n\n\ninput()\nfind = re.compile('(ogo(go)*)')\ns = input()\nprint(find.sub('***', s))\n"}, {"source_code": "n=int(raw_input())\ns=raw_input()\ni=0\nlst=[]\nwhile i < n:\n if s[i]=='o':\n filler ='o'\n while s[i+1:i+3]=='go':\n filler+=s[i+1:i+3]\n i+=2\n if filler!='o':\n lst.append(filler)\n i+=1\n else:\n i+=1\nfor filler in lst:\n s=s.replace(filler,'***',1)\nprint s\n \n"}, {"source_code": "a = int(input())\nb = str(input())\nc = b.replace('o', '1')\nc = c.replace('g', '2')\nfor i in range(a):\n c = c.replace('121', '3')\n c = c.replace('321', '3')\n c = c.replace('3', '***')\n c = c.replace('2', 'g')\n c = c.replace('***g***', '***')\nc = c.replace('1', 'o')\nprint(c)"}, {"source_code": "t=int(raw_input())\ns=str(raw_input())\nind=s.find('ogo')\nwhile(ind>=0):\n\tb=ind\n\te=ind+3\n\tp=1;q=0\n\t#print ind,p,q\n\twhile p==1 or q==1:\n\t\tp=0;q=0\n\t\tif(b-2>=0 and s[b-2:b]=='og'):\n\t\t\tb-=2\n\t\t\tp=1\n\t\tif(e+1<=(t-1) and s[e:e+2]=='go'):\n\t\t\te+=2\n\t\t\tq=1\n\t\t#print s[e:e+2],e\n\ts=s.replace(s[b:e],'***',1)\n\t\n\tind=s.find('ogo')\nprint s\n\t\n"}, {"source_code": "n=int(input())\nst=input()\nwhile st.count('ogo')>0:\n st=st.replace('ogo'+'go'*(n-1) , '***')\n n-=1\nprint(st)\n \n"}, {"source_code": "a=['ogo']\nfor i in range(48):\n s=a[-1]+'go'\n a.append(s)\nans=[]\nn=int(input())\ns=input()\ni=0\nwhile (i=0):\n\tb=ind\n\te=ind+3\n\tp=1;q=0\n\t#print ind,p,q\n\twhile p==1 or q==1:\n\t\tp=0;q=0\n\t\tif(b-2>=0 and s[b-2:b]=='og'):\n\t\t\tb-=2\n\t\t\tp=1\n\t\tif(e+1<=(t-1) and s[e:e+2]=='go'):\n\t\t\te+=2\n\t\t\tq=1\n\t\t#print s[e:e+2],e\n\ts=s.replace(s[b:e],'***',1)\n\t\n\tind=s.find('ogo')\nprint s\n\t\n"}], "negative_code": [{"source_code": "#!/usr/bin/env python3\n\nfrom sys import stdin\n\n\ndef main():\n n, = stdin_get_ints_from_line()\n s = stdin_get_string_from_line()\n\n ogo_found = False\n o_found = False\n g_found = False\n\n\n for x in s:\n if x == 'o' and ogo_found == False and g_found == False:\n o_found = True\n continue\n elif x == 'g' and o_found and ogo_found == False:\n g_found = True\n continue\n #elif x != 'g' and o_found and not g_found and ogo_found == False:\n # o_found = False\n\n if x == 'o' and o_found and g_found and not ogo_found:\n ogo_found = True\n ogo_step = 0\n continue\n elif o_found and g_found and not ogo_found:\n print('og', end='')\n o_found = False\n g_found = False\n continue\n\n if ogo_found and ogo_step == 0 and x == 'g':\n ogo_step = 1\n elif ogo_found and ogo_step == 1 and x == 'o':\n ogo_step = 0\n elif ogo_found and ogo_step == 0 and x != 'g':\n print('***', end='')\n\n if x == 'o':\n o_found = True\n else:\n o_found = False\n print(x, end='')\n g_found = False\n ogo_found = False\n elif ogo_found and ogo_step == 1 and x != 'o':\n print('***', end='')\n print('g', end='')\n print(x, end='')\n g_found = False\n o_found = False\n ogo_found = False\n else:\n print(x, end='')\n\n if ogo_found:\n print('***')\n else:\n print('')\n\n\n\n\n return\n\n\ndef stdin_get_ints_from_line():\n return (int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_ints_list_from_line():\n return list(int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_string_from_line():\n return stdin.readline().strip()\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "input()\ns=[i for i in input()]\ni=0\nnotdone=set()\nwhile i=s):\n\t\t\t\tbreak\n\t\tans = ans + \"***\" \n\telse:\n\t\tans = ans + n[i]\n\ti=i+1\nprint ans\n"}, {"source_code": "#s=input()\ns=input()\nsogo='og'*50\n\ni=0\nwhile i=s):\n\t\t\t\tbreak\n\t\tans = ans + \"***\" \n\telse:\n\t\tans = ans + n[i]\n\ti=i+1\nprint ans\n"}, {"source_code": "t = int(input())\nt = input()\ni = 0\nwhile i < len(t)-2:\n\tif t[i] == \"o\" and t[i+1] == \"g\" and t[i+2] == \"o\":\n\t\tj = i+3\n\t\tt = t[:i] + \"***\" + t[i+3:]\n\t\twhile j < len(t)-1:\n\t\t\tif t[j] + t[j+1] == \"go\":\n\t\t\t\tt = t[:j] + \"**\" + t[j+2:]\n\t\t\telse:\n\t\t\t\tbreak\n\t\ti = j\n\t\tcontinue\n\telse:\n\t\ti = i + 1\n\nprint(t)"}, {"source_code": "import re\nprint(re.sub(r\"ogo(go)*\", \"***\", input()))"}, {"source_code": "n = int(input())\ns = input()\nrepl = []\ni = 0\nwhile i < n:\n if s[i: i + 3] == 'ogo':\n pos = i + 3\n for j in range(i + 3, n, 2):\n if s[j: j + 2] == 'go':\n pos = j + 2\n else:\n break\n repl.append((i, pos))\n i = pos - 1\n i += 1\nfor p in repl:\n s = s[:p[0]] + '***' + s[p[1]:]\nprint(s)"}, {"source_code": "def process(s, start, end):\n if start != -1 and end != -1:\n for i in xrange(start, end + 1):\n s[i] = '*'\n\n\nstates = [('o', 1), ('g', 2), ('o', 3), ('g', 2)]\nn = int(raw_input())\ns = list(raw_input())\nstart, end = -1, -1\nstate = 0\n\ni = 0\n\nwhile i < len(s):\n if (s[i] == states[state][0]):\n if start == -1:\n start = i\n if state == 2:\n end = i\n state = states[state][1]\n else:\n process(s, start, end)\n state = 0\n start, end = -1, -1\n if s[i] == 'o':\n i -= 1\n i += 1\n\nprocess(s, start, end)\nprint(''.join(s))\n"}, {"source_code": "#\u041f\u043e\u043b\u0438\u043a\u0430\u0440\u043f \u0432\u0437\u044f\u043b \u0443 \u041e\u043b\u0435\u0433\u0430 \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043b \u0435\u0433\u043e \u0441\u0435\u0431\u0435 \u0432 \u0431\u043b\u043e\u043a\u043d\u043e\u0442 \u0431\u0435\u0437 \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432,\n#\u0447\u0442\u043e\u0431\u044b \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0438 \u0443\u0441\u043f\u0435\u0442\u044c \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c.\n# \u0412 \u0438\u0442\u043e\u0433\u0435, \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0443 s, \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0443\u044e \u0438\u0437 n \u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0445 \u0431\u0443\u043a\u0432 \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430.\n#\u0412 \u0440\u0435\u0447\u0438 \u041e\u043b\u0435\u0433\u0430 \u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0432\u043e-\u043f\u0430\u0440\u0430\u0437\u0438\u0442 ogo, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u0441\u0435 \u0441\u043b\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u0441\u043b\u043e\u0432\u0430 ogo \u043f\u0440\u0438\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0435\u043c \u043a \u043d\u0435\u043c\u0443 \u0441\u043b\u043e\u0433\u0430 go.\n# \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u043e\u0432\u0430 ogo, ogogo, ogogogo \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u0430\u0440\u0430\u0437\u0438\u0442\u0430\u043c\u0438, \u0430 \u0441\u043b\u043e\u0432\u0430 go, og, ogog, ogogog \u0438 oggo \u2014 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f.\n#\u0421\u043b\u043e\u0432\u0430-\u043f\u0430\u0440\u0430\u0437\u0438\u0442\u044b \u0438\u043c\u0435\u044e\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440, \u0442\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0440\u0435\u0447\u0438 ogogoo \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0447\u0438\u0442\u0430\u0442\u044c,\n# \u0447\u0442\u043e \u0441\u043b\u043e\u0432\u043e-\u043f\u0430\u0440\u0430\u0437\u0438\u0442 \u044d\u0442\u043e ogo, \u0430 goo \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u043e\u0439 \u0444\u0440\u0430\u0437\u044b \u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e.\n# \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u043b\u043e\u0432\u043e\u043c-\u043f\u0430\u0440\u0430\u0437\u0438\u0442\u043e\u043c \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0430 ogogo.\n#\u0414\u043e \u043f\u0435\u0447\u0430\u0442\u0438 \u041f\u043e\u043b\u0438\u043a\u0430\u0440\u043f\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u043e\u0435 \u0441\u043b\u043e\u0432\u043e-\u043f\u0430\u0440\u0430\u0437\u0438\u0442 \u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437 \u0442\u0440\u0451\u0445 \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u0435\u043a.\n# \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0434\u043b\u0438\u043d\u044b \u0441\u043b\u043e\u0432\u0430-\u043f\u0430\u0440\u0430\u0437\u0438\u0442\u0430 \u043e\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0440\u043e\u0432\u043d\u043e \u043d\u0430 \u0442\u0440\u0438 \u0437\u0432\u0451\u0437\u0434\u043e\u0447\u043a\u0438.\n#\u041f\u043e\u043b\u0438\u043a\u0430\u0440\u043f \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0441\u044f \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439. \u0410 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0438 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b? \u0412\u0440\u0435\u043c\u044f \u043f\u043e\u0448\u043b\u043e!\nn = int(input())\ns = input()\nfound = s.find('ogo')\nwhile(found != -1):\n next_letter='g'\n last_good = found+3\n for i in s[found+4::]:\n if(i==next_letter):\n if(next_letter=='g'):\n next_letter='o'\n else:\n next_letter='g'\n last_good+=2\n else:\n break\n s = s[:found:]+'***'+s[last_good::]\n found = s.find('ogo')\nprint(s)\n\n\n"}, {"source_code": "n=int(input())\ns=input()\nfor i in range(n):\n\tif 'ogo' in s:\n\t\ts=s.replace('ogo','***')\nj=s.split('go')\nk=''.join(j)\nl=k.split('*g*')\nprint('**'.join(l))"}, {"source_code": "t = int(input())\nt = input()\ni = 0\nwhile i < len(t)-2:\n\tif t[i] == \"o\" and t[i+1] == \"g\" and t[i+2] == \"o\":\n\t\tj = i+3\n\t\tt = t[:i] + \"***\" + t[i+3:]\n\t\twhile j < len(t)-1:\n\t\t\tif t[j] + t[j+1] == \"go\":\n\t\t\t\tt = t[:j] + \"**\" + t[j+2:]\n\t\t\telse:\n\t\t\t\tbreak\n\t\ti = j\n\t\tcontinue\n\telse:\n\t\ti = i + 1\n\nprint(t)"}, {"source_code": "def transition():\n\tglobal q\n\tglobal l\n\tif q == 0:\n\t\tif l == 'o':\n\t\t\tq = 1\n\t\t\treturn ''\n\t\treturn l\n\tif q == 1:\n\t\tif l == 'o':\n\t\t\treturn 'o'\n\t\tif l == 'g':\n\t\t\tq = 2\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn 'o'+l\n\tif q == 2:\n\t\tif l == 'o':\n\t\t\tq = 3\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn 'og'+l\n\tif q == 3:\n\t\tif l == 'o':\n\t\t\tq = 1\n\t\t\treturn '***'\n\t\tif l == 'g':\n\t\t\tq = 4\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn '***'+l\n\tif q == 4:\n\t\tif l == 'o':\n\t\t\tq = 3\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn '***g'+l\n\ns = raw_input()\nq = 0\nans = ''\nfor l in s+'x':\n\tans += transition()\nprint ans[:-1]"}, {"source_code": "a = raw_input()\n# O(n)\ns = a\nn = (len(s)-1)/2\nwhile n > 0:\n p = \"o\" + \"go\" * n\n n -= 1\n if s.count(p) > 0:\n s = s.replace(p, \"***\")\nprint s\n"}, {"source_code": "n=int(input())\ns=input()\nans=\"\"\ni=0\nwhile i<=n-3:\n if s[i:i+3] != \"ogo\":\n ans+=s[i]\n i+=1\n else:\n ans+=\"***\"\n i+=3\n while i<=n-2:\n if s[i:i+2] != \"go\":\n break\n else:\n ans+=\"**\"\n i+=2\nprint(ans)"}, {"source_code": "#Name:S.M.MILOY\n#Department Of CSE,BRUR\n#a,b=list(map(int,input().split()))\n#l=list(map(int,input().split(' ')))\n#n=int(z())\nz=input\n#for i in range(n):\nfrom math import gcd\n\nn=int(z())\nl=z()\nc=0\ns=''\ni=0\nfor _ in range(n):\n try:\n if l[i:i+7]=='ogogogo':\n s+='***'\n i+=7\n elif l[i:i+5]=='ogogo':\n s+='***'\n i+=5\n elif l[i:i+3]=='ogo':\n s+='***'\n i+=3\n else:\n s+=l[i]\n i+=1\n except:\n pass\nprint(s)\n \n"}, {"source_code": "import re\n\n\nword = input()\n\n\nprint(word)\n\nnewWord = re.sub('(o[go]+)', '***', word)\n\nprint(newWord)"}, {"source_code": "t = int(input())\nt = input()\ni = 0\nwhile i < len(t)-2:\n\tif t[i] == \"o\" and t[i+1] == \"g\" and t[i+2] == \"o\":\n\t\tj = i+3\n\t\tt = t[:i] + \"***\" + t[i+3:]\n\t\twhile j < len(t)-1:\n\t\t\tif t[j] + t[j+1] == \"go\":\n\t\t\t\tt = t[:j] + \"***\" + t[j+2:]\n\t\t\telse:\n\t\t\t\tbreak\n\t\ti = j\n\t\tcontinue\n\telse:\n\t\ti = i + 1\n\nprint(t)"}, {"source_code": "#!/usr/bin/env python3\n\nfrom sys import stdin\n\n\ndef main():\n n, = stdin_get_ints_from_line()\n s = stdin_get_string_from_line()\n\n ogo_found = False\n o_found = False\n g_found = False\n\n if n < 3:\n print(s)\n return\n\n i = 0\n\n\n for x in s:\n i += 1\n if x == 'o' and ogo_found == False and g_found == False and o_found == False:\n o_found = True\n continue\n elif x == 'g' and o_found and ogo_found == False:\n g_found = True\n continue\n #elif x != 'g' and o_found and not g_found and ogo_found == False:\n # print('o')\n # o_found = False\n\n if x == 'o' and o_found and g_found and not ogo_found:\n ogo_found = True\n ogo_step = 0\n continue\n elif o_found and g_found and not ogo_found:\n print('og', end='')\n o_found = False\n g_found = False\n continue\n\n if ogo_found and ogo_step == 0 and x == 'g':\n ogo_step = 1\n if i == n:\n print('***g')\n g_found = False\n o_found = False\n ogo_found = False\n elif ogo_found and ogo_step == 1 and x == 'o':\n ogo_step = 0\n elif ogo_found and ogo_step == 0 and x != 'g':\n print('***', end='')\n\n if x == 'o':\n o_found = True\n else:\n o_found = False\n print(x, end='')\n g_found = False\n ogo_found = False\n elif ogo_found and ogo_step == 1 and x != 'o':\n print('***', end='')\n print('g', end='')\n print(x, end='')\n g_found = False\n o_found = False\n ogo_found = False\n else:\n print(x, end='')\n\n if ogo_found:\n print('***')\n elif g_found:\n print('og')\n elif o_found:\n print('o')\n else:\n print('')\n\n\n\n\n return\n\n\ndef stdin_get_ints_from_line():\n return (int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_ints_list_from_line():\n return list(int(x) for x in stdin.readline().strip().split(' '))\n\n\ndef stdin_get_string_from_line():\n return stdin.readline().strip()\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#Name:S.M.MILOY\n#Department Of CSE,BRUR\n#a,b=list(map(int,input().split()))\n#l=list(map(int,input().split(' ')))\n#n=int(z())\nz=input\n#for i in range(n):\nfrom math import gcd\n\nn=int(z())\nl=z()\nc=0\ns=''\ni=0\nfor _ in range(n):\n try:\n if l[i:i+7]=='ogogogo':\n s+='***'\n i+=7\n elif l[i:i+5]=='ogogo':\n s+='***'\n i+=5\n elif l[i:i+3]=='ogo':\n s+='***'\n i+=3\n else:\n s+=l[i]\n i+=1\n except:\n pass\nprint(s)\n \n"}, {"source_code": "import re\n\nraw_input()\n\nprint re.sub(r'o(go)*', '***', raw_input())"}, {"source_code": "s = input()\nlet = s.find('ogo')\nif (let == -1):\n print(s)\nelse:\n while (s.find('ogo') != -1):\n let = s.find('ogo')\n letgo = let + 3\n while (True):\n if (len(s) <= letgo + 1):\n break\n elif ((s[letgo] == 'g') & (s[letgo + 1] == 'o')):\n letgo += 2\n else:\n break\n\n s= s[:let] + '***' + s[letgo:]\n print(s)\n\n \n"}, {"source_code": "n = int(input())\ns = str(input())\ns = s.replace('ogo','***')\ns = s.replace('*go','***')\ns = s.replace('*g*', '***')\nprint(s)"}, {"source_code": "dai=int(input())\ns=input()\nchay=list(range(3,dai,2))\nchay.reverse()\nfor i in chay:\n tmp=\"o\"\n tmp+=\"go\"*int(((i-1)/2))\n s=s.replace(tmp,\"***\",)\nprint(s)"}, {"source_code": "def transition():\n\tglobal q\n\tglobal l\n\tif q == 0:\n\t\tif l == 'o':\n\t\t\tq = 1\n\t\t\treturn ''\n\t\treturn l\n\tif q == 1:\n\t\tif l == 'o':\n\t\t\treturn 'o'\n\t\tif l == 'g':\n\t\t\tq = 2\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn 'o'+l\n\tif q == 2:\n\t\tif l == 'o':\n\t\t\tq = 3\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn 'og'+l\n\tif q == 3:\n\t\tif l == 'o':\n\t\t\tq = 1\n\t\t\treturn '***'\n\t\tif l == 'g':\n\t\t\tq = 4\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn '***'+l\n\tif q == 4:\n\t\tif l == 'o':\n\t\t\tq = 3\n\t\t\treturn ''\n\t\tq = 0\n\t\treturn '***g'+l\n\ns = raw_input()\nq = 0\nans = ''\nfor l in s+'x':\n\tans += transition()\nprint ans[:-1]"}, {"source_code": "n = int(input())\ns = input()\ni = n\nt = \"o\" + (\"go\" * i)\nwhile i > 0:\n while s.count(t) >= 1:\n x = s.find(t)\n l = len(t)\n s = s[0:x] + (\"*\" * l) + s[x+l::]\n i -= 1\n t = \"o\" + (\"go\" * i)\nprint(s)"}, {"source_code": "n = int(input())\ns = input()\ni = n\nt = \"o\" + (\"go\" * i)\nwhile i > 0:\n while s.count(t) >= 1:\n x = s.find(t)\n l = len(t)\n s = s[0:x] + (\"*\" * l) + s[x+l::]\n i -= 1\n t = \"o\" + (\"go\" * i)\nprint(s)"}, {"source_code": "n,st = int(input()), input()\na = ['ogo']\nfor i in range(100):\n a.append(a[0] + 'go'*(i+1))\n\nans,flag = '',0\nfor i in range(n):\n if i < flag:\n continue\n if st[i] != 'o':\n ans += st[i]\n continue\n curr = 'o'\n pos = i\n for j in range(i+1,n,2):\n if st[j:j+2] != 'go':\n break\n else:\n pos = j+2\n if pos != i and (pos - i) % 2 == 0:\n ans += '***'\n flag = pos\n else:\n ans += st[i]\n\nprint(ans)\n"}, {"source_code": "s=input();\ns=s.replace('ogogogogogogogogogogogogogo','***');\ns=s.replace('ogogogogogogogogogogogogo','***');\ns=s.replace('ogogogogogogogogogogogo','***');\ns=s.replace('ogogogogogogogogogogo','***');\ns=s.replace('ogogogogogogogogogo','***');\ns=s.replace('ogogogogogogogogo','***');\ns=s.replace('ogogogogogogogo','***');\ns=s.replace('ogogogogogogo','***');\ns=s.replace('ogogogogogo','***');\ns=s.replace('ogogogogo','***');\ns=s.replace('ogogogo','***');\ns=s.replace('ogogo','***');\ns=s.replace('ogo','***');\nprint(s);\n"}, {"source_code": "l = int(input())\narr = list(input())\narr.append('$')\narr.append('$')\narr.append('$')\n\nst = 0\ni = 0\nfl = False\ninx = []\nwhile i < l+1:\n if fl:\n if arr[i:i+2] != ['g','o']:\n inx.append([st,i])\n fl = False\n if arr[i:i + 3] == ['o', 'g', 'o']:\n fl = True\n st = i\n i += 3\n continue\n else:\n i+=1\n else:\n i+=2\n continue\n if arr[i:i+3] == ['o','g','o']:\n fl = True\n st = i\n i+=3\n continue\n i+=1\n\nout = ''\nfor i in range(len(inx)):\n arr = arr[:inx[i][0]] + ['*','*','*'] + arr[inx[i][1]:]\n # print(*arr,sep='')\nfor i in range(len(arr)-3):\n out+=arr[i]\nprint(out)\n"}, {"source_code": "n = int(input())\ns = input()\ns = s + 'q'\nflag = 0\nl = -1\ni = 0\nwhile i < len(s):\n if flag == 1:\n if s[i] == 'g':\n flag = 2\n elif flag == 2:\n if s[i] == 'o':\n flag = 3\n elif flag == 3:\n if s[i] == 'g':\n flag = 4\n else:\n flag = 0\n s = s[:l] + '***' + s[i:]\n i = 0\n elif flag == 4:\n if s[i] == 'o':\n flag = 3\n else:\n flag = 0\n s = s[:l] + '***' + s[i - 1:]\n i = 0\n if flag == 0:\n if i < len(s) and s[i] == 'o':\n flag = 1\n l = i \n i += 1\nprint(s[:-1])\n \n \n"}, {"source_code": "n = int(input())\ns = input()\ns = s + 'q'\nflag = 0\nl = -1\ni = 0\nwhile i < len(s):\n if flag == 1:\n if s[i] == 'g':\n flag = 2\n elif flag == 2:\n if s[i] == 'o':\n flag = 3\n elif flag == 3:\n if s[i] == 'g':\n flag = 4\n else:\n flag = 0\n s = s[:l] + '***' + s[i:]\n elif flag == 4:\n if s[i] == 'o':\n flag = 3\n else:\n flag = 0\n s = s[:l] + '***' + s[i - 1:]\n if flag == 0:\n if i < len(s) and s[i] == 'o':\n flag = 1\n l = i \n i += 1\nprint(s[:-1])\n \n \n"}, {"source_code": "import re\nprint(re.sub(r'o(go)*',r'***',[*open(0)][1]))"}, {"source_code": "input()\n\nS = list(input())\n\nc1, c2, c3 = False, False, False\nct = 0\nl, r = None, None\n\nfor i, s in enumerate(S):\n if c1 == False and s == 'o':\n c1 = True\n elif c1 == True and c2 == False and s == 'g':\n c2 = True\n elif c1 == True and c2 == True and c3 == False and s == 'o':\n c3 = True\n l = i - 2\n r = i\n elif c1 and c2 and c3 and ((ct % 2 == 0 and s == 'g')):\n ct += 1\n elif c1 and c2 and c3 and ((ct % 2 == 1 and s == 'o')):\n ct += 1\n r = i\n else:\n if l != None:\n for index in range(l, r+1):\n S[index] = '*'\n \n c1, c2, c3 = False, False, False\n ct = 0\n l, r = None, None\n if s == 'o':\n c1 = True\n\nif l != None:\n for index in range(l, r+1):\n S[index] = '*'\n \nAn = []\ncur = \"\"\nfor x in S:\n if x == \"*\":\n if cur != \"\":\n An += [cur]\n cur = \"\"\n else:\n cur += x\nif cur != \"\": An += [cur]\nprint(\"***\".join(An)) \n \n"}, {"source_code": "n = int(input())\ns = input()\nlast = \"\"\nans = \"\"\nfor i in range(len(s)):\n if last == \"\" and s[i] != \"o\":\n ans += s[i]\n elif last == \"\" and s[i] == \"o\":\n last += s[i]\n \n elif last == \"o\" and s[i] != \"g\":\n ans += last + s[i]\n last = \"\"\n elif last == \"o\" and s[i] == \"g\":\n last += s[i]\n \n elif last == \"og\" and s[i] != \"o\":\n ans += last + s[i]\n last = \"\"\n elif last == \"og\" and s[i] == \"o\":\n last += s[i] \n ans += \"***\"\n \n elif last == \"ogo\" and s[i] == \"o\":\n last = s[i]\n \n elif last == \"ogo\" and s[i] != \"g\":\n ans += s[i]\n last = \"\" \n elif last == \"ogo\" and s[i] == \"g\":\n last += s[i] \n \n elif last == \"ogog\" and s[i] != \"o\":\n ans += \"g\" + s[i]\n last = \"\" \n elif last == \"ogog\" and s[i] == \"o\":\n last = \"ogo\"\n\nif last == \"o\" or last == \"og\":\n ans += last\n\nprint(ans)"}, {"source_code": "n = int(input())\ns = input()\nlast = \"\"\nans = \"\"\nfor i in range(n):\n if last == \"\" and s[i] != \"o\":\n ans += s[i]\n elif last == \"\" and s[i] == \"o\":\n last += s[i]\n \n elif last == \"o\" and s[i] != \"g\":\n ans += last + s[i]\n last = \"\"\n elif last == \"o\" and s[i] == \"g\":\n last += s[i]\n \n elif last == \"og\" and s[i] != \"o\":\n ans += last + s[i]\n last = \"\"\n elif last == \"og\" and s[i] == \"o\":\n last += s[i] \n ans += \"***\"\n \n elif last == \"ogo\" and s[i] == \"o\":\n last = s[i]\n \n elif last == \"ogo\" and s[i] != \"g\":\n ans += s[i]\n last = \"\" \n elif last == \"ogo\" and s[i] == \"g\":\n last += s[i] \n \n elif last == \"ogog\" and s[i] != \"o\":\n ans += \"g\" + s[i]\n last = \"\" \n elif last == \"ogog\" and s[i] == \"o\":\n last = \"ogo\"\n\nprint(ans)"}, {"source_code": "import math\nimport sys\ninput = sys.stdin.readline\nn = int(input())\na = input()\nb, a = list(a), list(a)\ncur = 0\nwhile cur <= n - 2:\n if a[cur] + a[cur + 1] + a[cur + 2] == 'ogo':\n b[cur] = b[cur + 1] = b[cur + 2] = '*'\n cur += 1\nprint(''.join(b))"}, {"source_code": "\nn=int(input())\ns=input()\nfor i in range(n):\n\tif 'ogo' in s:\n\t\ts=s.replace('ogo','***')\nj=s.split('go')\nk=''.join(j)\nl=k.split('*g*')\nprint('**'.join(l))\n"}, {"source_code": "n1=int(input())\ns=list(input())\ndef zfunc(s1,n):\n i1=0\n z=[]\n for i1 in range(n):\n z.append(0)\n z[0]=0\n x=0\n length=0\n for i1 in range(1,n):\n if i1<=x+length:\n z[i1]=min(z[i1-x],x+length-i1)\n while z[i1]+i1x+length:\n x=i1\n length=z[i1]\n return z\ns.insert(0,'#')\ns.insert(0,'o')\ns.insert(0,'g')\ns.insert(0,'o')\nt=zfunc(s,len(s))\ni=4\nsc=0\nj=0\ni2=0\ns2=''\nwhile i!=n1+2:\n if t[i]==3:\n sc=3\n i2=i\n while t[i+2]==3:\n i+=2\n sc+=2\n for j in range(sc):\n del s[i2]\n s.insert(i2,'*')\n s.insert(i2,'*')\n s.insert(i2,'*')\n i+=1\nfor i in range(4,len(s)):\n s2+=s[i]\nprint(s2)"}, {"source_code": "n=int(raw_input())\nwrd=raw_input()\ni=0\nnewrd=''\nwhile i 2: \n S = S[:i - k] + \"***\" + S[i:]\n k = 1\n elif S[i] == 'g':\n if k % 2 == 1: k += 1\n elif k > 2:\n i -= 1\n k -= 1\n S = S[:i - k] + \"***\" + S[i:]\n k = 0\n else:\n k = 0\n else:\n if k > 2:\n if k % 2 == 0:\n k -= 1\n i -= 1\n S = S[:i - k] + \"***\" + S[i:]\n k = 0\n \n \n i += 1\nif k > 2: S = S[:i - k] + \"***\" + S[i:]\nprint(S)\n \n \n \n "}, {"source_code": "input()\n\nS = input()\n\ni = 0\nk = 0\n\nwhile i < len(S):\n\n if S[i] == 'o':\n if k % 2 == 0: k += 1\n elif k > 2: \n S = S[:i - k] + \"***\" + S[i:]\n i -= k\n k = 1\n \n else:\n k = 1\n elif S[i] == 'g':\n #print(S)\n #print(str(i) + ' ' + str(k))\n if k % 2 == 1: k += 1\n elif k > 2:\n i -= 1\n k -= 1\n S = S[:i - k] + \"***\" + S[i:]\n i -= k\n k = 0\n else:\n k = 0\n else:\n if k > 2:\n if k % 2 == 0:\n k -= 1\n i -= 1\n S = S[:i - k] + \"***\" + S[i:]\n i -= k \n k = 0\n \n #print(str(i) + ' ' + str(k) + ' ' + S[i])\n i += 1\nif k > 2: S = S[:i - k] + \"***\" + S[i:]\nprint(S)\n \n \n \n "}, {"source_code": "n = int(input())\ns = input()\ns = s.replace(\"ogo\", \"***\")\n\nfor i in range(100):\n s = s.replace(\"*go\", \"***\")\n\nprint(s)"}, {"source_code": "n1=int(input())\ns=list(input())\ndef zfunc(s1,n):\n i1=0\n z=[]\n for i1 in range(n):\n z.append(0)\n z[0]=0\n x=0\n length=0\n for i1 in range(1,n):\n if i1<=x+length:\n z[i1]=min(z[i1-x],x+length-i1)\n while z[i1]+i1x+length:\n x=i1\n length=z[i1]\n return z\ns.insert(0,'#')\ns.insert(0,'o')\ns.insert(0,'g')\ns.insert(0,'o')\nt=zfunc(s,len(s))\ni=4\nsc=0\nj=0\ni2=0\ns2=''\nwhile i!=n1+2:\n if t[i]==3:\n sc=3\n i2=i\n while t[i+2]==3:\n i+=2\n sc+=2\n for j in range(sc):\n del s[i2]\n s.insert(i2,'*')\n s.insert(i2,'*')\n s.insert(i2,'*')\n i+=1\nfor i in range(4,len(s)):\n s2+=s[i]\nprint(s2)"}, {"source_code": "b = input()\na = input()\ni = int(b)\nx = ''\nwhile i != 1:\n if 'o'+('go' * i) in a:\n x = a.replace('o' + ('go' * i), '***')\n a = x\n i -= 1\n\nprint(x)\n"}, {"source_code": "b=int(input())\nc=input()\na=[]\nfor i in range(b):\n a.append(c[i])\nfor i in range(b-2):\n if a[i]=='o' and a[i+1]=='g' and a[i+2]=='o':\n a[i]='*'\n a[i+1]='*'\n a[i+2]='*'\n elif a[i-1]=='*' and a[i]=='g' and a[i+1]=='o':\n a[i]=0\n a[i+1]='*'\ni=0\nwhile i < len(a):\n if a[i]==0:\n a[i+1]=0\n a.remove(0)\n a.remove(0)\n continue\n i+=1\nfor i in range(len(a)):\n print(a[i],end='')"}, {"source_code": "input()\n\nS = input()\n\ni = 0\nk = 0\n\nwhile i < len(S):\n\n if S[i] == 'o':\n if k % 2 == 0: k += 1\n elif k > 2: \n S = S[:i - k] + \"***\" + S[i:]\n i -= k\n k = 1\n \n else:\n k = 1\n elif S[i] == 'g':\n #print(S)\n #print(str(i) + ' ' + str(k))\n if k % 2 == 1: k += 1\n elif k > 2:\n i -= 1\n k -= 1\n S = S[:i - k] + \"***\" + S[i:]\n i -= k\n k = 0\n else:\n k = 0\n else:\n if k > 2:\n if k % 2 == 0:\n k -= 1\n i -= 1\n S = S[:i - k] + \"***\" + S[i:]\n i -= k \n k = 0\n \n #print(str(i) + ' ' + str(k) + ' ' + S[i])\n i += 1\nif k > 2: S = S[:i - k] + \"***\" + S[i:]\nprint(S)\n \n \n \n "}, {"source_code": "import re\ns = input()\nprint(re.sub(\"o(go)+\",\"***\",s))"}, {"source_code": "s=input();\nfor n in range(0,100):\n s=s.replace('ogo'+n*'go','***');\nprint(s);\n"}, {"source_code": "import math\nimport sys\ninput = sys.stdin.readline\nn = int(input())\na = input()\nb, a = list(a), list(a)\ncur = 0\nwhile cur <= n - 2:\n if a[cur] + a[cur + 1] + a[cur + 2] == 'ogo':\n b[cur] = b[cur + 1] = b[cur + 2] = '*'\n cur += 1\nprint(''.join(b))"}, {"source_code": "s=input();\nfor n in reversed(range(0,100)):\n s=s.replace('ogo'+n*'go','***');\nprint(s);\n"}, {"source_code": "n=input()\ns=raw_input()\nss='ogo'\ns2='go'\ntmp=[]\nfor i in range(n):\n\ttmp.append(ss+i*s2);\n\nfor i in range(n):\n\tif tmp[n-i-1] in s: s=s.replace(tmp[n-1-i],'***');break\n\nprint s\n\t\n"}, {"source_code": "import re\nn = int(input())\ns = input()\nq = \"ogo\"\ncom = re.compile(q)\nresult1 = re.sub(com, '\u0436\u0436\u0436', s)\nzap = result1.find(\"\u0436go\")\ns = result1\nwhile zap !=-1:\n q=\"\u0436go\"\n com = re.compile(q)\n result1 = re.sub(com,'\u0436',s)\n s = result1\n zap = s.find(\"\u0436go\")\n \nresult1 = re.sub(r\"\u0436\u0436\u0436\",\"***\",result1) \n \nprint(result1) \n \n \n\n\n\n"}, {"source_code": "n = int(input())\ns = input()\ns = s + 'q'\nflag = 0\nl = -1\ni = 0\nwhile i < len(s):\n if flag == 1:\n if s[i] == 'g':\n flag = 2\n elif flag == 2:\n if s[i] == 'o':\n flag = 3\n elif flag == 3:\n if s[i] == 'g':\n flag = 4\n else:\n flag = 0\n s = s[:l] + '***' + s[i:]\n i = 0\n elif flag == 4:\n if s[i] == 'o':\n flag = 3\n else:\n flag = 0\n s = s[:l] + '***' + s[i - 1:]\n i = 0\n if flag == 0:\n if i < len(s) and s[i] == 'o':\n flag = 1\n l = i \n i += 1\nprint(s[:-1])\n \n \n"}, {"source_code": "a = input()\na = input()\nwhile len(a)!= 0:\n print(a[:a.find(\"ogo\")], end = \"\")\n if a.find(\"ogo\")!=-1:\n print(\"***\", end = \"\")\n a = a[a.find(\"ogo\")+3:]\n while (a[:2]==\"go\"):a = a[2:]\n else:\n print(a)\n break"}, {"source_code": "a = raw_input()\n# O(n)\ns = a\nn = (len(a)-1)/2\nwhile n > 0:\n p = \"o\" + \"go\" * n\n n -= 1\n if s.count(p) > 0:\n s = s.replace(p, \"***\")\n print s\n"}, {"source_code": "input()\n\nS = input()\nif S == 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogog':\n print(\"***\")\nelse:\n i = 0\n k = 0\n \n while i < len(S):\n \n if S[i] == 'o':\n if k % 2 == 0: k += 1\n elif k > 2: \n S = S[:i - k] + \"***\" + S[i:]\n i -= k\n k = 1\n \n else:\n k = 1\n elif S[i] == 'g':\n #print(S)\n #print(str(i) + ' ' + str(k))\n if k % 2 == 1: k += 1\n elif k > 2:\n i -= 1\n k -= 1\n S = S[:i - k] + \"***\" + S[i:]\n i -= k\n k = 0\n else:\n k = 0\n else:\n if k > 2:\n if k % 2 == 0:\n k -= 1\n i -= 1\n S = S[:i - k] + \"***\" + S[i:]\n i -= k \n k = 0\n \n #print(str(i) + ' ' + str(k) + ' ' + S[i])\n i += 1\n if k > 2: S = S[:i - k] + \"***\" + S[i:]\n print(S)\n \n \n \n "}, {"source_code": "n = int(input())\ns = str(input())\ns = s.replace('ogo','***')\ns = s.replace('*go','***')\ns = s.replace('*g*', '***')\nprint(s)"}, {"source_code": "n = int(input())\ns = input()\nflag = 0\nl = 0\nr = 0\nready = 0\nfor i in range(n):\n if s[i] == 'o' and flag == 0:\n flag = 1\n l = i\n elif s[i] == 'g' and flag % 2 == 1:\n flag = 2\n elif s[i] == 'o' and flag == 2:\n flag = 3\n r = i\n ready = 1\n elif ready == 1:\n s = s[:l] + '***' + s[r + 1:]\n ready = 0\n flag = 0\n else:\n flag = 0\nif ready:\n s = s[:l] + '***' + s[r + 1:]\nprint(s) "}, {"source_code": "import sys\n\na = input()\n\nif len(a) < 3:\n print(a)\n sys.exit(0)\n\nres = ''\nisfilled = False\n\ni = 0\nmatched = False\n\nwhile i < len(a):\n isf = False\n if i+2 < len(a) and a[i:i+3] == 'ogo':\n res += '***'\n i += 2\n matched = True\n elif i+1 < len(a) and a[i:i+2] == 'go' and matched:\n i += 1\n else:\n matched = False\n res += a[i:i+1]\n i = i+1\n\nprint(res)\n\n\n"}, {"source_code": "n = int(input())\ns = str(input())\ns = s.replace('ogo','***')\ns = s.replace('*go','***')\ns = s.replace('*g*', '***')\nprint(s)"}, {"source_code": "import re\nn = int(input())\ns = input()\nreplaced = re.sub('(o(go)+)+', '***', s)\nprint (replaced)"}, {"source_code": "b=int(input())\nc=input()\na=[]\nfor i in range(b):\n a.append(c[i])\nfor i in range(b-2):\n if a[i]=='o' and a[i+1]=='g' and a[i+2]=='o':\n a[i]='*'\n a[i+1]='*'\n a[i+2]='*'\n elif a[i-1]=='*' and a[i]=='g' and a[i+1]=='o':\n a[i]=0\n a[i+1]='*'\ni=0\nwhile i < len(a):\n if a[i]==0:\n a[i+1]=0\n a.remove(0)\n a.remove(0)\n continue\n i+=1\nfor i in range(len(a)):\n print(a[i],end='')"}, {"source_code": "n = int(input())\ns = input()\ni = n\nt = \"o\" + (\"go\" * i)\nwhile i > 0:\n while s.count(t) >= 1:\n x = s.find(t)\n l = len(t)\n s = s[0:x] + (\"*\" * l) + s[x+l::]\n i -= 1\n t = \"o\" + (\"go\" * i)\nprint(s)"}, {"source_code": "import re\n\n\nword = input()\n\n\nprint(word)\n\nnewWord = re.sub('(o(go)+)', '***', word)\n\nprint(newWord)"}, {"source_code": "n = int(input())\n\n\nst = input()\nans = ''\nche = False\nj = 0\nfor i in range(len(st)):\n if st[i] == 'o' and j == i:\n if i+1 < len(st) and st[i+1] == 'g' and i+2 < len(st) and st[i+2] == 'o': \n ans += '*' * 3\n j = i + 3\n che = True\n else:\n j = i + 1\n che = False\n elif i == j and st[i-1]=='o' and che == True and i+1 < len(st):\n if st[i] == 'g' and st[i+1]=='o':\n j = i + 2\n print ( \"2f\")\n continue\n else:\n j = i + 1\n che = False\n ans+=st[i]\n elif che == True and j != i:\n print(\"3f\")\n continue\n else:\n ans+=st[i]\n che = False \n j = i + 1\n print ( \"i = \"+str(i) + \" j = \"+str(j) + \" che = \" + str(che)) \n \nprint(ans) "}, {"source_code": "import re\n\n\ninput()\nfind = re.compile('(ogo(go)*)+')\ns = input()\nprint(find.sub('***', s))\n"}, {"source_code": "\nn=int(input())\nphrase=input()\npossible=[True]*n\n\ni=0\nwhile i= 3:\n\t\t\t\t\tl.append(starter)\n\t\t\t\t\tif s[i-1] == 'g':\n\t\t\t\t\t\tl.append(i-2)\n\t\t\t\t\telse:\n\t\t\t\t\t\tl.append(i-1)\n\t\t\telse:\n\t\t\t\tstarter = -1\n\t\telse:\n\t\t\tstarter = -1\n\n\telse:\n\t\tstarter = -1\n\n\tif flag2:\n\t\ti -= 1\n\t\tflag2 = False \n\ti += 1\n\ni = 0\nj = 0\nans = ''\nwhile i < n:\n\tif j+1 < len(l) and i == l[j]:\n\t\tans += '***'\n\t\ti += l[j+1] - l[j] + 1\n\t\tj += 2\n\n\telse:\n\t\tans += s[i]\n\t\ti += 1\n\nprint ans\n"}, {"source_code": "import math\nimport string\nimport itertools\nfrom random import *\n\n#n = int(raw_input())\n#s = raw_input()\n#s = list(s)\ns = 'aogogob'\n\nfill = 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo'\n\nfor i in range(50):\n\tl = fill[:len(fill)-2*i]\n\ts = s.replace(l, '***', 35)\n\nprint s"}, {"source_code": "import re\ns = input()\nprint(re.sub(\"o(go)+\",\"***\",s))"}, {"source_code": "n = int(input())\ns = input()\ni = n\nt = \"o\" + (\"go\" * i)\nwhile i > 0:\n while s.count(t) >= 1:\n x = s.find(t)\n l = len(t)\n s = s[0:x] + (\"*\" * l) + s[x+l::]\n i -= 1\n t = \"o\" + (\"go\" * i)\nprint(s)"}], "src_uid": "619665bed79ecf77b083251fe6fe7eb3"} {"nl": {"description": "Rock... Paper!After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.A positive integer n is decided first. Both Koyomi and Karen independently choose n distinct positive integers, denoted by x1,\u2009x2,\u2009...,\u2009xn and y1,\u2009y2,\u2009...,\u2009yn respectively. They reveal their sequences, and repeat until all of 2n integers become distinct, which is the only final state to be kept and considered.Then they count the number of ordered pairs (i,\u2009j) (1\u2009\u2264\u2009i,\u2009j\u2009\u2264\u2009n) such that the value xi xor yj equals to one of the 2n integers. Here xor means the bitwise exclusive or operation on two integers, and is denoted by operators ^ and/or xor in most programming languages.Karen claims a win if the number of such pairs is even, and Koyomi does otherwise. And you're here to help determine the winner of their latest game.", "input_spec": "The first line of input contains a positive integer n (1\u2009\u2264\u2009n\u2009\u2264\u20092\u2009000) \u2014 the length of both sequences. The second line contains n space-separated integers x1,\u2009x2,\u2009...,\u2009xn (1\u2009\u2264\u2009xi\u2009\u2264\u20092\u00b7106) \u2014 the integers finally chosen by Koyomi. The third line contains n space-separated integers y1,\u2009y2,\u2009...,\u2009yn (1\u2009\u2264\u2009yi\u2009\u2264\u20092\u00b7106) \u2014 the integers finally chosen by Karen. Input guarantees that the given 2n integers are pairwise distinct, that is, no pair (i,\u2009j) (1\u2009\u2264\u2009i,\u2009j\u2009\u2264\u2009n) exists such that one of the following holds: xi\u2009=\u2009yj; i\u2009\u2260\u2009j and xi\u2009=\u2009xj; i\u2009\u2260\u2009j and yi\u2009=\u2009yj.", "output_spec": "Output one line \u2014 the name of the winner, that is, \"Koyomi\" or \"Karen\" (without quotes). Please be aware of the capitalization.", "sample_inputs": ["3\n1 2 3\n4 5 6", "5\n2 4 6 8 10\n9 7 5 3 1"], "sample_outputs": ["Karen", "Karen"], "notes": "NoteIn the first example, there are 6 pairs satisfying the constraint: (1,\u20091), (1,\u20092), (2,\u20091), (2,\u20093), (3,\u20092) and (3,\u20093). Thus, Karen wins since 6 is an even number.In the second example, there are 16 such pairs, and Karen wins again."}, "positive_code": [{"source_code": "print(\"Karen\")"}, {"source_code": "n = int(input())\nx = input()\ny = input()\nprint(\"Karen\")\n"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print \"Karen\""}, {"source_code": "def the_Artful():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n cpt+=1\n if (cpt%2==0): \n print('Karen')\n else:\n print('Kayomi')\nthe_Artful ()"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print('Karen')"}, {"source_code": "def kadhem():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n k=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n k+=1;\n if (k%2==0): \n print('Karen')\n else:\n print('Koyomi')\nkadhem()"}, {"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 = I()\n x = LI()\n y = LI()\n s = set(x+y)\n k = 0\n for c in x:\n for d in y:\n if c ^ d in s:\n k += 1\n\n if k % 2 == 0:\n return 'Karen'\n\n return 'Koyomi'\n\n\nprint(main())\n\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\n\nn,=I()\na=I();b=I()\nd=set(a+b)\nan=\"Karen\";p=0\nfor i in a:\n\tfor j in b:\n\t\tif i^j in d:\n\t\t\tp+=1\nif p%2:\n\tan=\"Koyomi\"\nprint(an)"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print(\"Karen\")"}, {"source_code": "n=int(input())\nka=list(map(int,input().strip().split()))\nko=list(map(int,input().strip().split()))\nc=0\ne=set(ka+ko)\nfor i in ka:\n for j in ko:\n if((i^j) in e):\n c+=1\nif(c&1==0):\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "n=int(input())\nar1=list(map(int,input().split()))\nar2=list(map(int,input().split()))\nd={}\nfor i in ar1:\n if i not in d:\n d[i]=i\nfor i in ar2:\n if i not in d:\n d[i]=i\n \ncnt=0\nfor i in ar1:\n if i^i in d:\n cnt+=1\nfor i in ar2:\n if i^i in d:\n cnt+=1\n\nif cnt%2==0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n"}, {"source_code": "print 'Karen'"}, {"source_code": "import sys\ninput = sys.stdin.readline\nI = lambda : list(map(int,input().split()))\n\nn,=I()\na=I();b=I()\nd=set(a+b)\nan=\"Karen\";p=0\nfor i in a:\n\tfor j in b:\n\t\tif i^j in d:\n\t\t\tp+=1\nif p%2:\n\tan=\"Koyomi\"\nprint(an)"}, {"source_code": "print \"Karen\""}, {"source_code": "n=int(input())\nxi = list(map(int, input().split()))\nyj = list(map(int, input().split()))\n\ns=set(xi+yj)\ncpt=0;\nfor i in xi:\n for j in yj:\n result = i ^ j\n if result in s:\n cpt+=1\nif cpt % 2 == 0:\n print(\"Karen\")\nelse:\n print (\"Koyomi\") "}, {"source_code": "print 'Karen'"}, {"source_code": "print \"Karen\""}, {"source_code": "print\"Karen\""}, {"source_code": "n = int(raw_input())\nnums = list(map(int,raw_input().split()))\nnums2 = list(map(int,raw_input().split()))\ntaken = [0 for x in range(20000000)]\nfor i in nums:\n taken[i] = 1\nfor i in nums2:\n taken[i] = 1\nans = 0\nfor i in range(n):\n for j in range(n):\n if taken[nums[i]^nums2[j]]:\n ans += 1\nif ans%2:\n print \"Koyomi\"\nelse:\n print \"Karen\""}, {"source_code": "print(\"Karen\")"}, {"source_code": "print 'Karen'"}, {"source_code": "n=int(input())\n#xi = list(map(int, input().split()))\n#yj = list(map(int, input().split()))\nxi = [int(c) for c in input().split()]\nyj = [int(c) for c in input().split()]\ns=set(xi+yj)\ncpt=0;\nfor i in xi:\n for j in yj:\n result = i ^ j\n if result in s:\n cpt+=1;\nif cpt % 2 == 0:\n print(\"Karen\")\nelse:\n print (\"Koyomi\")"}, {"source_code": "print 'Karen'"}, {"source_code": "print(\"Karen\")"}, {"source_code": "input()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nx = [False] * ((1 << 21) + 1)\n\nfor i in range(len(a)):\n x[a[i]] = x[b[i]] = True\n\ncnt = 0\nfor i in a:\n for j in b:\n if x[i ^ j]:\n cnt += 1\n\nprint(['Karen', 'Koyomi'][cnt % 2])\n"}, {"source_code": "print 'Karen'"}, {"source_code": "print(\"Karen\")"}, {"source_code": "def gain():\n n=int(input())\n L1=list(map(int,input().split()))\n L2=list(map(int,input().split()))\n\n tr = 0\n s=set(L1+L2)\n\n for i in range(len(L1)):\n for j in range(len(L2)) :\n if(L1[i]^L2[j] in s ) :\n tr+=1\n\n\n if(tr%2 == 0 ):\n print(\"Karen\")\n else :\n print(\"Koyomi\")\n\ngain()\n"}, {"source_code": "c= raw_input(\"\")\nn = raw_input(\"\").split(\" \")\nv = {}\nk = []\ner = []\nfor i in n:\n v[int(i)] = True\n k.append(int(i))\nn = raw_input(\"\").split(\" \") \nfor i in n:\n v[int(i)] = True\n er.append(int(i))\ncount = 0\nfor i in k:\n for j in er:\n if i^j in v:\n count += 1\nif count % 2 == 0:\n print \"Karen\"\nelse:\n print \"Koyomi\"\n"}, {"source_code": "def readints():\n return [int(item) for item in input().strip().split()]\n\n\nclass Solver:\n def main(self):\n x, y = readints(), readints()\n s = {i for i in x + y}\n\n c = 0\n for x1 in x:\n for y1 in y:\n if x1 ^ y1 in s:\n c += 1\n\n print(['Karen', 'Koyomi'][c % 2])\n\n\nSolver().main()\n"}, {"source_code": "print \"Karen\""}, {"source_code": "##n = int(input())\n##x = list(map(int, input().split()))\n##y = list(map(int, input().split()))\n##\n##count = 0\n##for a in x:\n## for b in y:\n## if 1 <= (a ^ b) <= 2*n:\n## count += 1\n##\n##if (count % 2):\n## print('Koyomi')\n##else:\n## print('Karen')\n\nprint('Karen')\n"}, {"source_code": "n=int(raw_input())\n\nA =map(int,raw_input().split())\nB =map(int,raw_input().split())\n\n\ndic={}\nfor x in A:\n dic[x]=True\nfor x in B:\n dic[x]=True\nct=0\nfor x in A:\n for y in B:\n if x^y in dic:\n ct+=1\nif ct%2==0:\n print \"Karen\"\nelse:\n print \"Koyomi\"\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nfrom itertools import product\n\nst = set((*a, *b))\n\nnpairs = sum((x ^ y) in st for x, y in product(a, b))\nprint('Koyomi' if npairs & 1 else 'Karen')"}, {"source_code": "print \"Karen\""}, {"source_code": "I = lambda: list(map(int, input().split()))\n\nI()\nX, Y = I(), I()\nZ = set(X) | set(Y)\n\nprint('Koyomi' if sum(x^y in Z for x in X for y in Y) % 2 else 'Karen')"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nprint(\"Karen\")"}, {"source_code": "def main():\n names = ['Karen', 'Koyomi']\n n = int(input())\n x = [int(c) for c in input().split()]\n y = [int(c) for c in input().split()]\n\n nset = set(x).union(set(y))\n \n pairs = 0\n for xx in range(n):\n for yy in range(n):\n if xx^yy in nset:\n pairs += 1\n \n if pairs % 2 == 0:\n print(names[0])\n else:\n print(names[1])\n\n \n\nif __name__ == '__main__':\n main()"}, {"source_code": "#!/usr/bin/python\n\nn = int(input())\n\na = list(map(int, input().split(\" \")))\nb = list(map(int, input().split(\" \")))\n\nsa = set(a)\nsb = set(b)\n\ns= 0;\n\nfor x in a:\n for y in b:\n z = x ^ y\n s += (1 if z in sa or z in sb else 0)\n\nif s % 2:\n print(\"Koyomi\")\nelse:\n print(\"Karen\")\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nd = [int(i) for i in input().split()]\ne = set(s+d)\na = max(max(s),max(d))\nb = min(min(s),min(d))\ncnt = 0\n\n\nfor i in range(n):\n\tfor j in range(n):\n\t\tr = s[i]^d[j]\n\t\tif r in e:\n\t\t\tcnt+=1\n\t\t\nif cnt%2==0:\n\tprint(\"Karen\")\nelse:\n\tprint(\"Koyomi\")\n"}, {"source_code": "print(\"Karen\")\n# Mon Sep 28 2020 19:23:43 GMT+0300 (\u041c\u043e\u0441\u043a\u0432\u0430, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f)\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nprint(\"Karen\")\n"}, {"source_code": "def kadhem():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n k=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n k+=1;\n if (k%2==0): \n print('Karen')\n else:\n print('Koyomi')\nkadhem()\n"}, {"source_code": "n = int(input())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\nprint ('Karen')\n\n"}, {"source_code": "\na = int(input())\nx = set(map(int,input().split()))\nxz = set(map(int,input().split()))\nqw = 0\nfor i in x:\n for u in xz:\n vb = i^u\n if vb in x or vb in xz:\n qw += 1\nif qw % 2 == 0:\n print('Karen')\nelse:\n print('Koyomi')"}, {"source_code": "n = int(input())\nx = list(map(int,input().split()))\ny = list(map(int,input().split()))\ntemp = set(x + y)\ncount = 0\nfor i in x:\n for j in y:\n if i^j in temp:\n count += 1\nif count%2==0:\n print('Karen')\nelse:\n print('Koyomi')"}, {"source_code": "\nn=int(input() )\nl=set()\n\n\nt1=list (map(int,input ().split ()))\nt2=list (map(int,input ().split ()))\nl=set(t1+t2)\n\nnb=0\nfor i in range (n) :\n for j in range (n) :\n if (t1[i]^t2[j]) in l :\n nb+=1\n\nif (nb%2==0):\n print('Karen')\nelse:\n print('Koyomi')\n \n \n "}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nprint(\"Karen\")\n"}, {"source_code": "print \"Karen\""}, {"source_code": "# -*- coding: utf-8 -*-\n\nimport math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\n\n\"\"\"\ncreated by shhuan at 2017/10/6 21:41\n\n\"\"\"\n\n\nN = int(input())\nX = [int(x) for x in input().split()]\nY = [int(x) for x in input().split()]\nprint('Karen')"}, {"source_code": "import operator\na = int(input())\nll = [int(x) for x in input().split()]\nhh = [int(x) for x in input().split()]\ns = 0\nfor i in range(a):\n if operator.xor(ll[i], hh[i]):\n s+=1\ns*=2\nif s%2 == 0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print(\"Karen\")"}, {"source_code": "n=int(raw_input())\n\nA =map(int,raw_input().split())\nB =map(int,raw_input().split())\n\n\ndic={}\nfor x in A:\n dic[x]=True\nfor x in B:\n dic[x]=True\nct=0\nfor x in A:\n for y in B:\n if x^y in dic:\n ct+=1\nif ct%2==0:\n print \"Karen\"\nelse:\n print \"Koyomi\"\n"}, {"source_code": "print('Karen')"}, {"source_code": "print(\"Karen\")"}, {"source_code": "# Solo una vez\nn, a, b = int(raw_input()), set(map(int,raw_input().split())), set(map(int,raw_input().split()))\nd = a.union(b)\nif sum(ia^ib in d for ia in a for ib in b) % 2:\n print \"Koyomi\"\n exit()\nprint \"Karen\""}, {"source_code": "KOYOMI = 'Koyomi'\nKAREN = 'Karen'\n\n\ndef main():\n input()\n first_str = input().split()\n first = list(map(int, first_str))\n second_str = input().split()\n second = list(map(int, second_str))\n print(game(first, second))\n\n\ndef game(first, second):\n unique_numbers = set(first + second)\n\n pairs = 0\n for i in first:\n for j in second:\n result = i ^ j\n if result in unique_numbers:\n pairs += 1\n\n return KOYOMI if pairs % 2 else KAREN\n\n\nmain()\n"}, {"source_code": "n=int(input())\nLko = list(map(int, input().split()))\nLka=list(map(int,input().split()))\n\nE=set(Lko+Lka)\n\nc=0;\nfor i in range(n) :\n for j in range(n) :\n if((Lko[i]^Lka[j])in E) :\n c=c+1;\n\nif (c%2==0):\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nprint(\"Karen\")"}, {"source_code": "n=int(input())\nLko = list(map(int, input().split()))\nLka=list(map(int,input().split()))\n\nE=set(Lko+Lka)\n\nc=0;\nfor i in range(n) :\n for j in range(n) :\n if((Lko[i]^Lka[j])in E) :\n c=c+1;\n\nif (c%2==0):\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "print('Karen')"}, {"source_code": "print(\"Karen\")"}, {"source_code": "n = int(input())\n\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\nnums = set(x).union(set(y))\n\ncount = 0\n\nfor i in range(n):\n for j in range(n):\n tmp = (x[i] ^ x[j])\n if tmp in nums:\n count += 1\n\nif count % 2 == 0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "print(\"Karen\")"}, {"source_code": "def main():\n names = ['Karen', 'Koyomi']\n n = int(input())\n x = [int(c) for c in input().split()]\n y = [int(c) for c in input().split()]\n\n nset = set(x).union(set(y))\n \n pairs = 0\n for xx in range(n):\n for yy in range(n):\n if xx^yy in nset:\n pairs += 1\n \n if pairs % 2 == 0:\n print(names[0])\n else:\n print(names[1])\n\n \n\nif __name__ == '__main__':\n main()"}, {"source_code": "n = int(input())\nx = list(map(int,input().split()))\ny = list(map(int,input().split()))\ntemp = set(x + y)\ncount = 0\nfor i in x:\n for j in y:\n if i^j in temp:\n count += 1\nif count%2==0:\n print('Karen')\nelse:\n print('Koyomi')"}, {"source_code": "n=int(input())\nxi = list(map(int, input().split()))\nyj = list(map(int, input().split()))\n\ns=set(xi+yj)\ncpt=0;\nfor i in xi:\n for j in yj:\n result = i ^ j\n if result in s:\n cpt+=1\nif cpt % 2 == 0:\n print(\"Karen\")\nelse:\n print (\"Koyomi\")"}, {"source_code": "# n = int(input())\n# x = [int(x) for x in input().split()]\n# y = [int(x) for x in input().split()]\n#\n#\n#\nimport sys\ninp = sys.stdin.readlines()\nx = [int(x) for x in inp[1].strip().split()]\ny = [int(x) for x in inp[2].strip().split()]\n\n# print(x, y)\n\ns = set(x+y)\n\nevn = True\nfor i in x:\n for j in y:\n if i ^ j in s:\n evn = not evn\nprint('Karen' if evn else 'Koyomi')"}, {"source_code": "print \"Karen\""}, {"source_code": "print \"Karen\""}, {"source_code": "print (\"Karen\")"}, {"source_code": "def game():\n n=int(input())\n l1=list(map(int,input().split()))\n l2=list(map(int,input().split()))\n\n c = 0\n s=set(l1+l2)\n\n for i in range(len(l1)):\n for j in range(len(l2)) :\n if(l1[i]^l2[j] in s ) :\n c+=1\n\n\n if(c%2 == 0 ):\n print(\"Karen\")\n else :\n print(\"Koyomi\")\n\ngame()"}, {"source_code": "n=int(input())\nc=0\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\nz=set(x+y)\nfor i in range(n):\n\tfor j in range(n):\n\t\tif (x[i]^y[j]) in z :\n\t\t\tc = c + 1 \nif (c%2 == 0):\n\tprint (\"Karen\")\nelse:\n\tprint (\"Koyomi\")"}, {"source_code": "n=int(input())\nxi = list(map(int, input().split()))\nyj = list(map(int, input().split()))\n\ns=set(xi+yj)\ncpt=0;\nfor i in xi:\n for j in yj:\n result = i ^ j\n if result in s:\n cpt+=1\nif cpt % 2 == 0:\n print(\"Karen\")\nelse:\n print (\"Koyomi\")"}, {"source_code": "n=int(input())\nxi = list(map(int, input().split()))\nyj = list(map(int, input().split()))\n\ns=set(xi+yj)\ncpt=0;\nfor i in xi:\n for j in yj:\n result = i ^ j\n if result in s:\n cpt+=1;\nif cpt % 2 == 0:\n print(\"Karen\")\nelse:\n print (\"Koyomi\")"}, {"source_code": "print('Karen')"}, {"source_code": "n = raw_input()\na = raw_input()\nb = raw_input()\nprint 'Karen'"}, {"source_code": "print \"Karen\""}, {"source_code": "n=int(input())\nxi = list(map(int, input().split()))\nyj = list(map(int, input().split()))\n\ns=set(xi+yj)\ncpt=0;\nfor i in xi:\n for j in yj:\n result = i ^ j\n if result in s:\n cpt+=1\nif cpt % 2 == 0:\n print(\"Karen\")\nelse:\n print (\"Koyomi\") "}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nif n % 2 and 0 in a + b:\n print(\"Koyomi\")\nelse:\n print(\"Karen\")\n"}, {"source_code": "n = int(input())\nfirst = list(map(int, input().split()))\nsecond = list(map(int, input().split()))\ncnt = 0\nfor i in range(n):\n for j in range(i, n):\n if first[i] ^ second[j] <= 2 * n:\n cnt += 2\nif cnt % 2 == 0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "import sys\n\n\ndef gis():\n l = sys.stdin.readline().strip()\n parts = l.split()\n return list(map(int, parts))\n\n\nn, = gis()\nxs = gis()\nys = gis()\n\nnums = set(xs + ys)\ncnt = 0\nfor x in xs:\n for y in ys:\n if (x ^ y) in nums:\n cnt += 1\n\nif cnt % 2 == 0:\n print('Karen')\nelse:\n print('Koyomi')\n\n"}, {"source_code": "print('Karen')"}, {"source_code": "print(\"Karen\")"}, {"source_code": "n=int(input())\na=*map(int,input().split()),\nb=*map(int,input().split()),\ns={*a}|{*b}\nprint('KKaoryeonm i'[sum(x^y in s for x in a for y in b)%2::2])"}, {"source_code": "import time\nn = int(raw_input().strip())\nli = list(map(int,raw_input().strip().split()))\nli1 = list(map(int,raw_input().strip().split()))\n\n\ns = dict.fromkeys(li+li1)\n\ncount = 0\n\nfor i in li:\n for j in li1:\n if(i^j) in s:\n count += 1\n\n\n\n\nif(count%2==0):\n print 'Karen'\n\nelse:\n print 'Koyomi'\n\n"}, {"source_code": "str = \"Karen\"\nprint(str)"}, {"source_code": "n=int(input() )\nl=set()\n\n\nt1=list (map(int,input ().split ()))\nt2=list (map(int,input ().split ()))\nl=set(t1+t2)\n\nnb=0\nfor i in range (n) :\n for j in range (n) :\n if (t1[i]^t2[j]) in l :\n nb+=1\n\nif (nb%2==0):\n print('Karen')\nelse:\n print('Koyomi')\n "}, {"source_code": "print 'Karen'"}, {"source_code": "n=int(input())\nlko= list(map(int,input().split()))\nlka= list(map(int,input().split()))\ne=set(lko+lka)\nc=0;\nfor i in range (n):\n for j in range(n):\n if(lko[i]^lka[j] in e):\n c=c+1;\nif(c%2==0):\n print(\"Karen\")\nelse:\n print(\"Kayomi\")\n"}, {"source_code": "def tae():\n n=int(input())\n c=0 \n L=[]\n L=list(map(int,input().split()))\n L1=[]\n L1=list(map(int,input().split()))\n s=set(L1+L)\n \n\n for i in range (n) : \n for j in range (n) : \n if ((L[i]^L1[j] in s) ):\n c=c+1 \n \n \n if(c%2 ==0): \n print(\"Karen\")\n else : \n print(\"Koyomi\")\ntae()\n "}, {"source_code": "def xor():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n k=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n k+=1;\n if (k%2==0): \n print('Karen')\n else:\n print('Koyomi')\nxor()"}, {"source_code": "print(\"Karen\")"}, {"source_code": "print(\"Karen\")"}], "negative_code": [{"source_code": "def solution():\n\tn = int(input())\n\tx = [int(a) for a in input().split(' ')]\n\ty = [int(a) for a in input().split(' ')]\n\tans = 0\n\tfor i in range(n):\n\t\tcurrent = x[i] ^ y[i]\n\t\tif current in x or current in y:\n\t\t\tans += 1\n\t\n\tif ans%2 == 0:\n\t\tprint('Karen')\n\telse:\n\t\tprint('Koyomi')\n\nsolution()"}, {"source_code": "from itertools import product\n\nr = lambda: map(int, input().split())\ninput()\nx, y = set(r()), set(r())\ns = x.union(y)\n\npairs = sum(x^y in s\n for x, y in product(range(max(x)), range(max(y))))\n\nprint('KKoayroemni'[1-pairs%2::2])\n"}, {"source_code": "def main():\n names = ['Karen', 'Koyomi']\n input()\n x = set(int(c) for c in input().split())\n y = set(int(c) for c in input().split())\n\n nset = x.union(y)\n \n pairs = 0\n for xx in range(max(x)+1):\n for yy in range(max(y)+1):\n if xx^yy in nset:\n pairs += 1\n\n print(names[pairs%2])\n \n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "def main():\n names = ['Karen', 'Koyomi']\n input()\n x = set(int(c) for c in input().split())\n y = set(int(c) for c in input().split())\n\n nset = x.union(y)\n \n pairs = 0\n for xx in range(max(x)):\n for yy in range(max(y)):\n if xx^yy in nset:\n pairs += 1\n\n print(names[pairs%2])\n \n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\ni=0\ncount=0\nwhile i 0:\n ret += 1\n if ret % 2 == 0:\n print(\"Karen\")\n else:\n print(\"Koyomi\")\n\ndef run():\n n = I()\n l1 = LI()\n l2 = LI()\n solve(n, l1, l2)\n\nrun()\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, numbers):\n ret = 0\n for i in range(n):\n for j in range(n):\n if numbers[0][i] ^ numbers[1][j] <= 2*n:\n ret += 1\n if ret % 2 == 0:\n return \"Karen\"\n else:\n return \"Koyomi\"\n\ndef run():\n n = I()\n numbers = [LI() for _ in range(2)]\n print(solve(n, numbers))\n\nrun()\n"}, {"source_code": "n = int(input())\ns = [int(i) for i in input().split()]\nd = [int(i) for i in input().split()]\na = max(max(s),max(d))\nb = min(min(s),min(d))\ncnt = 0\n\n\nfor i in range(n):\n\tfor j in range(n):\n\t\tr = s[i]^d[j]\n\t\tif b<=r<=a:\n\t\t\tcnt+=1\n\t\t\nif cnt%2==0:\n\tprint(\"Karen\")\nelse:\n\tprint(\"Koyomi\")\n"}, {"source_code": "n=int(input())\nx=[]\ny=[] \nz=[]\nc=0\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\nz=x+y\t\nfor i in range(0,n):\n\tfor j in range(0,n):\n\t\tif (x[i]^y[j]) in z: \n\t\t\tc = c + 1\n\t\t\tbreak\nif (c%2 == 0):\n\tprint (\"Karen\")\nelse:\n\tprint (\"Koyomi\")\n\t"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\narr1 = list(map(int, sys.stdin.readline().split()))\narr2 = list(map(int, sys.stdin.readline().split()))\ncnt = 0\nfor i in arr1:\n if i % 2 == 0:\n cnt += 1\nfor i in arr2:\n if i % 2 == 0:\n cnt += 1\nprint('Karen' if cnt % 2 else 'Koyomi')"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\narr1 = list(map(int, sys.stdin.readline().split()))\narr2 = list(map(int, sys.stdin.readline().split()))\ncnt = 0\nfor i in arr1:\n for j in arr2:\n temp = i ^ j\n if temp == 2 * n:\n cnt += 1\nprint('Karen' if cnt % 2 else 'Koyomi')"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ns = frozenset(a + b)\ncounter = 0\nfor i in range(n):\n if (a[i] ^ b[i]) in s:\n counter += 1\n\nif counter % 2 == 1:\n print(\"Koyomi\")\nelse:\n print(\"Karen\")"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nc = {x:1 for x in a}\nc.update({x:1 for x in b})\ncount = 0\nfor i in range(0, n):\n if c.get(a[i]^b[i]):\n count += 1\nif count%2 == 0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n\n"}, {"source_code": "print 'karen'"}, {"source_code": "n = int(raw_input())\n\nx = map(int,raw_input().split())\ny = map(int,raw_input().split())\n\nnumbers = set(x+y)\n\ncount = 0\nfor i in range(n):\n for j in range(n):\n if x[i] ^ y[i] in numbers:\n count += 1\n\nif count % 2 ==0:\n print \"Karen\"\nelse:\n print \"Koyomi\"\n"}, {"source_code": "print(\"karen\")"}, {"source_code": "n=int(input())\nl1=list(map(int,input().split()))\nl2=list(map(int,input().split()))\nl3=l1+l2\nr=0\nfor i in range(n):\n for j in range(n):\n x=l1[i]^l2[i]\n if(x in l3):\n if(i==j):\n r=r+1\n else:\n r=r+2\nif(r%2==0):\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "l1=[]\nn=int(input(\"donner n \"))\nl1 = list(map(int, input('Enter numbers: ').split()))\n\nl2=[]\nl2 = list(map(int, input('Enter numbers: ').split()))\n\nl=l1+l2\ntup=[]\nfor i in range (n):\n for j in range (n):\n if (l1[i]^l2[j] in l ): \n tup.append((l1[i],l2[j]))\n\nif (len(tup) % 2 == 0 ) :\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n \n"}, {"source_code": "n = int(input())\nx = []\ny = []\nx = input().split()\ny = input().split()\nfor i in range(n):\n x[i] = int(x[i])\n y[i] = int(y[i])\nk = 0 \nfor i in range(n):\n if x[i]^y[i] in x or x[i]^y[i] in y:\n k += 1\nif k % 2 == 0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")"}, {"source_code": "n = int(input())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\namount = 0\nfor i in range(n):\n value = x[i]^y[i]\n if (value in x) or (value in y):\n amount += 1\nif amount%2==0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n"}, {"source_code": "n = int(input())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\namount = 0\nfor i in range(n):\n for j in range(i, n):\n value = x[i]^y[j]\n if (value in x) or (value in y):\n amount += 1\nif amount%2==0:\n print(\"Karen\")\nelse:\n print(\"Koyomi\")\n"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ncount = 0\nc = a+b;\nfor i in range(len(a)):\n\tfor j in range(i,len(b)):\n\t\tif(a[i]^b[j] in c):\n\t\t\tcount += 1\nif(count%2==0):\n\tprint(\"Karen\")\nelse:\n\tprint(\"Koyomi\")\n\n"}, {"source_code": "KOYOMI = 'Koyomi'\nKAREN = 'Karen'\n\n\ndef main():\n input()\n first_str = input().split()\n first = list(map(int, first_str))\n second_str = input().split()\n second = list(map(int, second_str))\n print(game(first, second))\n\n\ndef game(first, second):\n numbers_dict = {}\n for lst in [first, second]:\n for i in lst:\n numbers_dict[i] = 0\n\n for i in first:\n for j in second:\n result = i ^ j\n if numbers_dict.get(result) is not None:\n numbers_dict[result] += 1\n\n print(numbers_dict)\n return KOYOMI if sum(numbers_dict.values()) % 2 else KAREN\n\n\nmain()\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 = I()\n x = LI()\n y = LI()\n c = collections.defaultdict(int)\n d = collections.defaultdict(int)\n for t in x:\n c[t%2] += 1\n for t in y:\n d[t%2] += 1\n k = c[0] * d[0]\n k += c[1] * d[1]\n\n if k % 2 == 0:\n return 'Karen'\n\n return 'Koyomi'\n\n\nprint(main())\n\n"}, {"source_code": "def the_Artful():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n cpt+=1\n if (cpt%2==0): \n print('Karen')\n else:\n print('Kayomi')\n "}, {"source_code": "\nn = int(input())\n\ndata = input().split ()\ndata = input().split ()\n\nprint( \"karen\" )"}, {"source_code": "def the_Artful():\n n=int(input());\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n cpt+=1;\n if (cpt%2==0): \n print('Karen')\n else:\n print('Kayomi')\n \n"}, {"source_code": "def the_Artful():\n n=int(input(n));\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j]; \n if h in c1:\n cpt+=1;\n if (cpt%2==0): \n print('Karen');\n else:\n print('Koyomi');"}, {"source_code": "def the_Artful():\n n=int(input())\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n cpt+=1;\n if (cpt%2==0): \n print('Karen')\n else:\n print('Kayomi')\n \n"}, {"source_code": "def the_Artful_Expedient():\n \n n=int(input());\n x=list(map(int,input().split()));\n y=list(map(int,input().split()));\n cpt=0\n c1=set(x+y)\n for i in range(n):\n for j in range(n):\n h=x[i]^y[j]; \n if h in c1:\n cpt+=1;\n if (cpt%2==0): \n print('Karen');\n else:\n print('Koyomi');"}, {"source_code": "import sys\nfrom collections import Counter\nimport bisect\n#sys.stdin = open('input.txt', 'r')\n#sys.stdout = open('output.txt','w')\n\nN = int(raw_input())\nX = map(int, raw_input().strip().split(' '))\nY = map(int, raw_input().strip().split(' '))\ndic = {}\nfor x in X :\n dic[x] = True\nfor y in Y :\n dic[y] = True\n\nres = 0\nfor i in xrange(N) :\n for j in xrange(N) :\n if X[i]^Y[j] in dic :\n res += 1\nprint res\nif res%2 == 0 :\n print 'Karen' \nelse :\n print 'Koyomi'"}, {"source_code": "import sys\nfrom collections import Counter\nimport bisect\n#sys.stdin = open('input.txt', 'r')\n#sys.stdout = open('output.txt','w')\n\nN = int(raw_input())\nX = map(int, raw_input().strip().split(' '))\nY = map(int, raw_input().strip().split(' '))\ndic = {}\nfor x in X :\n dic[x] = True\nfor y in Y :\n dic[y] = True\n\nres = 0\nfor i in xrange(N) :\n for j in xrange(N) :\n if X[i]^Y[i] in dic :\n res += 1\nif res%2 == 0 :\n print 'Karen' \nelse :\n print 'Koyomi'"}, {"source_code": "n=input()\nlst1=map(int,raw_input().split())\nlst2=map(int,raw_input().split())\nc=0\nfor i in range(0,n):\n for j in range(0,n):\n s=lst1[i]^lst2[j]\n if s>0 and s<=2*n:\n c=c+1 \nif c%2==0:\n print \"Karen\"\nelse:\n print \"Koyomi\""}, {"source_code": "print(\"karen\")"}, {"source_code": "n = int(input())\n\na = list(map(int, input().split(' ')))\nb = list(map(int, input().split(' ')))\nvis = [False] * 4000007\n\nfor i in range(n):\n vis[a[i]] = True\n vis[b[i]] = True\n\nx = 0\nfor i in range(n):\n for j in range(n):\n if vis[a[i] ^ b[i]]:\n x += 1\n\nprint(\"Karen\") if x % 2 == 0 else print(\"Koyomi\")\n"}, {"source_code": "import sys\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, l1, l2):\n _set = set(l1) | set(l2)\n ret = 0\n for i in range(n):\n for j in range(n):\n if l1[i] ^ l2[j] <= 2*n:\n ret += 1\n if ret % 2 == 0:\n print(\"Karen\")\n else:\n print(\"Koyomi\")\n\ndef run():\n n = I()\n l1 = LI()\n l2 = LI()\n solve(n, l1, l2)\n\nrun()\n"}, {"source_code": "import sys\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, l1, l2):\n _set = set(range(1, 2*n+1))\n ret = 0\n for i in range(n):\n for j in range(n):\n if l1[i] ^ l2[j] in _set:\n ret += 1\n if ret % 2 == 0:\n return \"Karen\"\n else:\n return \"Koyomi\"\n\ndef run():\n n = I()\n l1 = LI()\n l2 = LI()\n print(solve(n, l1, l2))\n\nrun()\n"}, {"source_code": "n = int(input())\n\nko = [int(x) for x in input().split()]\nka = [int(x) for x in input().split()]\nkk = ka+ko\n\ncnt = 0\n\nfor i in range(n):\n for j in range(i,n):\n x = ko[i]^ka[j]\n \n if x in kk:\n cnt += 1\n if i==j:\n cnt +=1\n \n\nif ( cnt%2 == 0 ):\n print('Karen',cnt)\nelse:\n print('Koyomi',cnt)\n"}, {"source_code": "n = int(input())\n\nko = [int(x) for x in input().split()]\nka = [int(x) for x in input().split()]\nkk = ka+ko\n\ncnt = 0\n\nfor i in range(n):\n for j in range(i,n):\n if ko[i]^ka[j] in kk:\n cnt += 1\n\nif ( cnt%2 == 0 ):\n print('Karen')\nelse:\n print('Koyomi')\n"}, {"source_code": "n=int(input())\nx=list(map(int,input().split()));\ny=list(map(int,input().split()));\nk=0\nc1=set(x+y)\nfor i in range(n):\n for j in range(n):\n h=x[i]^y[j] \n if h in c1:\n k+=1;\nif (k%2==0): \n print('karen')\nelse:\n print('koyomi')\n"}, {"source_code": "input()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nx = [False] * ((1 << 21) + 1)\n\nfor i in range(len(a)):\n x[a[i]] = x[b[i]] = True\n\ncnt = 0\nfor i in range(len(a)):\n if x[a[i] ^ b[i]]:\n cnt += 1\n for j in range(i + 1, len(b)):\n if x[a[i] ^ b[j]]:\n cnt += 2\n\nprint(['Karen', 'Koyomi'][cnt % 2])\n"}, {"source_code": "input()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nx = [False] * ((1 << 21) + 1)\n\nfor i in range(len(a)):\n x[a[i]] = x[b[i]] = True\n\ncnt = 0\nfor i in range(len(a)):\n for j in range(len(b)):\n if x[a[i] | b[j]]:\n cnt += 1\n\nprint(['Karen', 'Koyomi'][cnt % 2])\n"}, {"source_code": "input()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nx = [False] * ((1 << 21) + 1)\n\nfor i in range(len(a)):\n x[a[i]] = x[b[i]] = True\n\ncnt = 0\nfor i in range(len(a)):\n for j in range(i, len(b)):\n if x[a[i] | b[j]]:\n cnt += 1\n\nprint(['Karen', 'Koyomi'][cnt % 2])\n"}, {"source_code": "from itertools import product\ninput()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nab = set(a + b)\n\n##print([x[0]^x[1] in ab for x in product(a, b)].count(True))\n\nprint (len([x for x in product(a, b) if x[0]^x[1] in ab]))\n"}, {"source_code": "from itertools import product\n\n\nx = [False] * ((1 << 21) + 1)\ninput()\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfor i in range(len(a)):\n x[a[i]] = x[b[i]] = True\n\nab = a + b\n\n# print([x[0]^x[1] in ab for x in product(a, b)].count(True))\ncnt = 0\nfor p in product(a, b):\n if x[p[0] | p[1]]:\n cnt += 1\n\nprint(['Karen', 'Koyomi'][cnt % 2])\n"}, {"source_code": "n = int(input())\ns = set()\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nfor _ in x:\n\ts.add(_)\n\nfor _ in y:\n\ts.add(_)\n\nz = x + y\ncount = 0\n\nfor i in range(len(z)):\n\tfor j in range(i + 1, len(z)):\n\t\tif (z[i] ^ z[j]) in s:\n\t\t\tcount += 1\n\nprint('Karen' if count % 2 == 0 else 'Koyomi')"}, {"source_code": "n = int(input())\ns = set()\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nfor _ in x:\n\ts.add(_)\n\nfor _ in y:\n\ts.add(_)\n\nz = x + y\ncount = 0\nfor i in range(len(z)):\n\tfor j in range(i + 1, len(z)):\n\t\tif (i ^ j) in s:\n\t\t\tcount += 1\n\nprint('Karen' if count % 2 == 0 else 'Koyomi')"}, {"source_code": "print \"Koyomi\"\n"}, {"source_code": "print \"Koyomi\""}, {"source_code": "my_input = raw_input(\"Enter\").split()\n\npairs = 0\nt = 0\nn = 0\n\ncurrent_num = 0\n\nfor number in my_input:\n print number\n if t == 0:\n n = int(number)\n t += 1\n \n if t == 1:\n current_num = int(number)\n for number in my_input:\n if int(number) ^ current_num == (2 * n):\n pairs += 1\n\nif pairs % 2 == 0:\n print \"Karen\"\nelif pairs % 1 == 0:\n print \"Koyomi\""}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\nb = map(int,raw_input().split())\nif n==1:\n print \"Koyomi\"\nelse:\n print \"Karen\""}, {"source_code": "import time\nn = int(raw_input().strip())\nli = list(map(int,raw_input().strip().split()))\nli1 = list(map(int,raw_input().strip().split()))\n\n\nstart = time.time()\ns = set(li)\ns1 = set(li1)\n\ncount = 0\n\nfor i in li:\n for j in li1:\n if(i^j) in s:\n count += 1\n\n if(i^j) in s1:\n count += 1\n\n\n\nif(count%2==0):\n print 'Karen'\n\nelse:\n print 'Koyomi'\n\nprint time.time()-start\n"}], "src_uid": "1649d2592eadaa8f8d076eae2866cffc"} {"nl": {"description": "Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.Ari draws a regular convex polygon on the floor and numbers it's vertices 1,\u20092,\u2009...,\u2009n in clockwise order. Then starting from the vertex 1 she draws a ray in the direction of each other vertex. The ray stops when it reaches a vertex or intersects with another ray drawn before. Ari repeats this process for vertex 2,\u20093,\u2009...,\u2009n (in this particular order). And then she puts a walnut in each region inside the polygon. Ada the squirrel wants to collect all the walnuts, but she is not allowed to step on the lines drawn by Ari. That means Ada have to perform a small jump if she wants to go from one region to another. Ada can jump from one region P to another region Q if and only if P and Q share a side or a corner.Assuming that Ada starts from outside of the picture, what is the minimum number of jumps she has to perform in order to collect all the walnuts?", "input_spec": "The first and only line of the input contains a single integer n (3\u2009\u2264\u2009n\u2009\u2264\u200954321) - the number of vertices of the regular polygon drawn by Ari.", "output_spec": "Print the minimum number of jumps Ada should make to collect all the walnuts. Note, that she doesn't need to leave the polygon after.", "sample_inputs": ["5", "3"], "sample_outputs": ["9", "1"], "notes": "NoteOne of the possible solutions for the first sample is shown on the picture above."}, "positive_code": [{"source_code": "# Description of the problem can be found at http://codeforces.com/problemset/problem/592/B\n\nprint((int(input()) - 2) ** 2)"}, {"source_code": "print (int(input()) - 2)**2"}, {"source_code": "a = int(raw_input())\n\nif a == 3:\n\tprint 1\nelif a == 4:\n\tprint 4\nelse:\n\tprint (a-2)**2"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\nprint (n-2)**2"}, {"source_code": "print (int(input()) - 2)**2"}, {"source_code": "x = input()\nprint (x-2)**2\n\n"}, {"source_code": "n = input() - 2\n\nprint n ** 2"}, {"source_code": "n = int(input())\n\nprint((n-2)+2*(n-3)+(n-3)*(n-4))"}, {"source_code": "n=input()\nprint (n-2)**2\n"}, {"source_code": "n = int(input())\nprint((n-2)*(n-2))"}, {"source_code": "n = int(input())\n\nprint((n-2)+2*(n-3)+(n-3)*(n-4))"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2\n"}, {"source_code": "n = int(input())\n\nprint((n-2)+2*(n-3)+(n-3)*(n-4))"}, {"source_code": "a = int(raw_input())\n\nif a == 3:\n\tprint 1\nelif a == 4:\n\tprint 4\nelse:\n\tprint (a-2)**2"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2"}, {"source_code": "n = int(input())\nprint((n-2)**2)"}, {"source_code": "\"\"\"\n= raw_input()\nL = [ int(i) for i in raw_input().split(' ') ]\n= raw_input().split(\" \")\n\"\"\"\n\n\n\ndef main():\n n = int(raw_input())\n \n if n == 3:\n print 1\n return\n if n == 4:\n print 4\n return\n \n print n*(n-3)-(n-4)\n\n\nmain()"}, {"source_code": "n=int(input())\nif (n==3):\n print(1)\nelse:\n print((n-2)**(2))"}, {"source_code": "n=int(input())\nprint((n-2)**2)"}, {"source_code": "n=int(input())\nk=1\nt=3\nfor i in range(n-3) :\n k=k+t\n t=t+2\nprint(k)\n"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline())\nprint (n-2)**2"}, {"source_code": "def belochka(n):\n return (n - 2) ** 2\n\n\nprint(belochka(int(input())))\n"}, {"source_code": "n = int(input())\nprint((n-2)**2)\n"}, {"source_code": "n = int(input())\nprint((n-2)*(n-2))"}, {"source_code": "n=int(input())\nif (n==3):\n print(1)\nelse:\n print((n-2)**(2))\n"}, {"source_code": "n = int(input())\nprint(pow(n-2,2))"}, {"source_code": "print (int(input()) - 2)**2"}, {"source_code": "n = int(input())\na = [0] * (n + 1)\na[3] = 1\nfor i in range(4, n + 1):\n a[i] = i - 2 + a[i - 1] + i - 3\nprint(a[n])"}, {"source_code": "n = int(input())\nprint (n-2)**2"}, {"source_code": "print (input()-2)**2\n"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2\n"}, {"source_code": "print (int(raw_input())-2)**2\n"}, {"source_code": "print((int(input())-2)**2)"}, {"source_code": "n = input()\nprint((n-2) * (n-2))"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2"}, {"source_code": "print((int(input())-2)**2)\n"}, {"source_code": "print (input()-2)**2"}, {"source_code": "x = int(input())\nprint((x-2)**2)"}, {"source_code": "n = int(raw_input())\nt = (n-2)**2\nprint t"}, {"source_code": "x = input()\nprint (x - 2) ** 2\n"}, {"source_code": "n = raw_input()\nn = int(n)\nn = ((n-2) * (n-2))\nprint n"}, {"source_code": "print ((input()-2)**2)\n"}, {"source_code": "n=input()\nprint (n-2)**2"}, {"source_code": "n = int(raw_input())\nprint 1 + (n - 3) * 3 + (n - 4) * (n - 3)"}, {"source_code": "print((int(input())-2)**2)"}, {"source_code": "#!/usr/bin/env python\n# coding=utf-8\n\nn = input()\nprint (n - 2) * (n - 2)\n"}, {"source_code": "n = int(input())\nprint((n-2)**2)"}, {"source_code": "n = int(input())\nprint((n - 2) ** 2)"}, {"source_code": "n=input()\nprint (n-2)**2\n"}, {"source_code": "n=input()\nprint (n-2)**2"}, {"source_code": "n = int(input())\nprint((n - 2) ** 2)"}, {"source_code": "print (input()-2)**2\n"}, {"source_code": "n=int(input())-2\nprint(n*n)"}, {"source_code": "n = int(input())\nprint(pow(n-2,2))"}, {"source_code": "n=int(raw_input())\nprint (n-2)**2"}, {"source_code": "n = int(raw_input())\nprint (n - 2)**2"}, {"source_code": "print((int(input())-2)**2)\n\n\n\n# Made By Mostafa_Khaled"}, {"source_code": "import sys\nimport traceback\nfrom contextlib import contextmanager\nfrom io import StringIO\n\n\ndef jumps(n):\n if n == 3:\n return 1\n return (n * (n-3)) - (n-4)\n\ndef main():\n n = int(input())\n print(jumps(n))\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 main()\n if r.getvalue() == o:\n log(\"OK\\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 = [(\"\"\"\\\n5\n\"\"\", \"\"\"\\\n9\n\"\"\"), (\"\"\"\\\n3\n\"\"\", \"\"\"\\\n1\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"}, {"source_code": "def f(d):\n if d<=3:\n return 1\n else:\n return (d-2)**2\n\nn = raw_input()\nprint(f(int(n)))"}, {"source_code": "\"\"\"\n= raw_input()\nL = [ int(i) for i in raw_input().split(' ') ]\n= raw_input().split(\" \")\n\"\"\"\n\n\n\ndef main():\n n = int(raw_input())\n \n if n == 3:\n print 1\n return\n if n == 4:\n print 4\n return\n \n print n*(n-3)-(n-4)\n\n\nmain()"}, {"source_code": "print((int(input())-2)**2)\n"}, {"source_code": "t = int(raw_input())\nprint (t-2)**2"}, {"source_code": "n = int(input())\nprint((n-2)**2)"}, {"source_code": "x = int(raw_input())\nprint (x-2)**2"}, {"source_code": "print((int(input())-2)**2)\n"}, {"source_code": "n = int(raw_input())\nt = (n-2)**2\nprint t"}, {"source_code": "\"\"\"\nOh, Grantors of Dark Disgrace, \nDo Not Wake Me Again.\n\"\"\"\nprint((int(input())-2)**2)"}, {"source_code": "def the_monster_and_the_squirrel(n):\n return (n-2)**2\n\n\nif __name__ == \"__main__\":\n n = int(input())\n result = the_monster_and_the_squirrel(n)\n print(result)\n"}, {"source_code": "print (input()-2)**2\n"}, {"source_code": "a = input()\na -= 2\nprint a * a\n"}, {"source_code": "n=int(input());\nprint((n-2)**2);"}, {"source_code": "print((int(input())-2)**2)"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2\n"}, {"source_code": "print (int(raw_input())-2)**2"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2\n"}, {"source_code": "a = int(input())\nprint((a-2)**2)"}, {"source_code": "n = int(raw_input())\nprint 1 + (n - 3) * 3 + (n - 4) * (n - 3)"}, {"source_code": "n=int(input())\nprint((n-2)*(n-2))"}, {"source_code": "n=input()-2\nprint n*n\n"}, {"source_code": "print((int(input())-2)**2)"}, {"source_code": "print (input()-2)**2\n"}, {"source_code": "n = int(raw_input())\nprint (n-2)*(n-2)\n"}, {"source_code": "print((int(input()) - 2) ** 2)"}, {"source_code": "n = int(input())\na = [0] * (n + 1)\na[3] = 1\nfor i in range(4, n + 1):\n a[i] = i - 2 + a[i - 1] + i - 3\nprint(a[n])"}, {"source_code": "print((int(input())-2)**2)"}, {"source_code": "print (input()-2)**2\n"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2\n"}, {"source_code": "print((int(input())-2)**2)"}, {"source_code": "print((int(input())-2)**2)\n"}, {"source_code": "b = int(raw_input())-2\n\nprint b**2\n"}, {"source_code": "n = int(raw_input())\nprint (n-2)**2"}, {"source_code": "n = int(input())\nprint((n - 3) * (n - 4) + 2 * (n - 3) + n - 2) "}, {"source_code": "__author__ = 'lavee_singh'\nprint (input()-2)**2"}, {"source_code": "n = input()\nprint (n-2)**2"}, {"source_code": "n = int(input())\nprint((n-2)**2)\n"}, {"source_code": "\n\ndef f(d):\n if d<=3:\n return 1\n else:\n return (d-2)**2\n\nn = raw_input()\nprint(f(int(n)))\n"}, {"source_code": "n=int(input())\n\nprint((n-2)**2)\n"}, {"source_code": "n = int(input())\nif n == 3:\n print(1)\nelif n == 4:\n print(4)\nelse:\n print(1 + (n - 3) * (n - 1))\n"}, {"source_code": "a=int(input())\nprint((a-2)**2)"}, {"source_code": "n = input()\nprint (n-2)**2"}], "negative_code": [{"source_code": "n = int(input())\nprint(3 ** (n - 3))\n"}, {"source_code": "n = int(input())\nprint(3 ** (n - 3))\n"}, {"source_code": "n = int(input())\nprint(3 ** (n - 3))\n"}, {"source_code": "x=int(input())\ny=x-2\nz=y**y\nprint (z)"}, {"source_code": "n=int(input());\nprint(n**2);"}, {"source_code": "a=int(input())\nprint((a-2)*2)"}, {"source_code": "print(int(input())**2)\n"}, {"source_code": "n = int(input())\n\nif n == 3:\n print (1)\nelif n == 4:\n print (4)\nelse:\n a = [0 for i in range(n + 1)]\n a[0] = 1\n a[1] = 1\n for i in range(2, n + 1):\n a[i] = a[i - 2] + a[i - 1]\n\n print (a[n] + 1)\n"}, {"source_code": "n = int(input())\nprint (3**(n - 3))\n"}, {"source_code": "n = int(input(\"\"))\nprint((n-2)*(n*2))"}, {"source_code": "from sys import stdin\n\ndef main():\n inp=stdin\n a=[int(x) for x in inp.readline().strip()]\n while len(a)!=0:\n print((a[0]-2)**2)\n a=[int(x) for x in inp.readline().strip()]\nmain()\n"}, {"source_code": "print((int(input())-2)^2)"}, {"source_code": "n=int(input())\nprint((n-1)**2)"}, {"source_code": "n = int(input())\nif n == 3:\n print(1)\nelif n == 4:\n print(2)\nelse:\n ans = (n-3) + 2*(n-3) + (n - 4)* (n-3) + 1\n print(ans)"}, {"source_code": "\nn=int(input())\n\nif(n==3):\n\n print('1')\n\nelse:\n\n cnt=((n-1)*2)+1\n\n print(cnt)\n"}, {"source_code": "print((int(input())-3)*4+1)"}, {"source_code": "print(3 * (int(input()) - 2))\n"}, {"source_code": "n = int(raw_input())\nprint n**2\n"}, {"source_code": "\"\"\"\n= raw_input()\nL = [ int(i) for i in raw_input().split(' ') ]\n= raw_input().split(\" \")\n\"\"\"\n\n\n\ndef main():\n n = int(raw_input())\n \n if n == 3:\n print 1\n return\n if n == 4:\n print 4\n return\n \n print n*(n-3)-1\n\n\nmain()"}, {"source_code": "n=int(raw_input())\nadd=n*(n-3)/2\nif add==0:\n print 1\nelif add%2==0:\n print add*2\nelse:\n print add*2-1\n "}, {"source_code": "n = int(input())\nif n == 3:\n ans = 1\nelif n == 4:\n ans = 4\nelse:\n ans = n * (n - 3) - 1\nprint(ans)"}, {"source_code": "print((int(input()))**2)"}, {"source_code": "n = int(input())\nprint(n**2)"}, {"source_code": "n = int(raw_input())\nif n == 3:\n\tprint 1\nelif n == 4:\n\tprint 3\nelse:\n\tprint (n-2)**2"}, {"source_code": "n = input()\nprint 3 * (n-2)\n"}, {"source_code": "b = int(raw_input())\n\nprint 2**b\n"}, {"source_code": "n = int(raw_input().strip())\nprint 1 + n * (n - 3) - n * (n - 3)\nexit(0)\njumps = 1\nfulledges = [[] for i in xrange(n)]\nbrokenedges = [[] for i in xrange(n)]\ndef modrange(a, b, m):\n curr = a % m\n while curr != b:\n yield curr\n curr += 1\n curr %= m\nfor v in xrange(n):\n for ov in xrange(n):\n if ov == (v - 1) % n or ov == v or ov == (v + 1) % n:\n continue\n if v not in fulledges[ov]:\n jumps += 1\n broken = False\n if v == 0:\n fulledges[ov].append(v)\n fulledges[v].append(ov)\n continue\n for lv in modrange(v + 1, ov, n):\n for rv in modrange(ov + 1, v, n):\n if rv in brokenedges[lv]:\n broken = True\n break\n if broken:\n break\n if not broken:\n fulledges[ov].append(v)\n fulledges[v].append(ov)\n brokenedges[ov].append(v)\n brokenedges[v].append(ov)\n else:\n brokenedges[ov].append(v)\n brokenedges[v].append(ov)\nprint jumps"}, {"source_code": "n=int(raw_input())\nprint (n-1)**2"}, {"source_code": "n = input()\nprint (n-2)+(n-3)*(n-2),1\n"}, {"source_code": "\n\ndef f(d):\n if d<=3:\n return 1\n else:\n return (d-2)**2\n\n\n"}, {"source_code": "n = input()\nif n == 3:\n print 1\nelse:\n print n**2 - 3*n - 1\n"}, {"source_code": "import sys\ninput=sys.stdin\nwrite=sys.stdout.write\nn=int(input.readline())\ncount=1\nk=n*(n-1)\nk-=2*n\nk-=(n-3)\ncount+=k\nwrite(str(k))\n"}], "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b"} {"nl": {"description": "The Little Elephant loves chess very much. One day the Little Elephant and his friend decided to play chess. They've got the chess pieces but the board is a problem. They've got an 8\u2009\u00d7\u20098 checkered board, each square is painted either black or white. The Little Elephant and his friend know that a proper chessboard doesn't have any side-adjacent cells with the same color and the upper left cell is white. To play chess, they want to make the board they have a proper chessboard. For that the friends can choose any row of the board and cyclically shift the cells of the chosen row, that is, put the last (rightmost) square on the first place in the row and shift the others one position to the right. You can run the described operation multiple times (or not run it at all).For example, if the first line of the board looks like that \"BBBBBBWW\" (the white cells of the line are marked with character \"W\", the black cells are marked with character \"B\"), then after one cyclic shift it will look like that \"WBBBBBBW\".Help the Little Elephant and his friend to find out whether they can use any number of the described operations to turn the board they have into a proper chessboard.", "input_spec": "The input consists of exactly eight lines. Each line contains exactly eight characters \"W\" or \"B\" without any spaces: the j-th character in the i-th line stands for the color of the j-th cell of the i-th row of the elephants' board. Character \"W\" stands for the white color, character \"B\" stands for the black color. Consider the rows of the board numbered from 1 to 8 from top to bottom, and the columns \u2014 from 1 to 8 from left to right. The given board can initially be a proper chessboard.", "output_spec": "In a single line print \"YES\" (without the quotes), if we can make the board a proper chessboard and \"NO\" (without the quotes) otherwise.", "sample_inputs": ["WBWBWBWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB", "WBWBWBWB\nWBWBWBWB\nBBWBWWWB\nBWBWBWBW\nBWBWBWBW\nBWBWBWWW\nBWBWBWBW\nBWBWBWBW"], "sample_outputs": ["YES", "NO"], "notes": "NoteIn the first sample you should shift the following lines one position to the right: the 3-rd, the 6-th, the 7-th and the 8-th.In the second sample there is no way you can achieve the goal."}, "positive_code": [{"source_code": "print('YES' if all([r=='WB'*4 or r=='BW'*4 for r in [input() for _ in range(8)]]) else 'NO')"}, {"source_code": "def proper(line):\n current = line[0]\n for j in range(1, len(line)):\n if line[j] == current:\n return False\n else:\n current = line[j]\n return True\n\nanswer = \"YES\"\n\nfor i in range(8):\n if not proper(input()):\n answer = \"NO\"\n \nprint(answer)\n\n\n"}, {"source_code": "\n\nflag = True\nfor t in range(8):\n s = input()\n for i in range(len(s) - 1):\n if s[i] == s[i+1]:\n flag = False\n\n\nif flag :\n print('YES')\nelse:\n print('NO')\n\n\n\n\n\n\n"}, {"source_code": "check=True\nfor i in range(8):\n\ts=input()\n\tfor j in range(1,len(s)):\n\t\tif(s[j]==s[j-1]):\n\t\t\tcheck=False\n\t\t\tbreak\nif(check):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "\n\ndef main():\n matrix = []\n for _ in range(8):\n x = [i for i in str(input())]\n matrix.append(x)\n for row in matrix:\n for c in range(len(row) - 1):\n if row[c] == row[c + 1]:\n print(\"NO\")\n return\n print(\"YES\")\n\n\n\n\n\nmain()"}, {"source_code": "t=True\nfor i in [0]*8:\n r=raw_input()\n t=t and all([x!=y for x,y in zip(r, r[1:])])\nprint 'YNEOS'[not t::2]"}, {"source_code": "l=[]\nflag=1\nfor i in range(8):\n\tl.append(input())\n\tif flag:\n\t\tif(l[i].count('B')>4 or l[i].count('W')>4):\n\t\t\tflag=0\n\t\tfor j in range(7):\n\t\t\tif(l[i][j]==l[i][j+1]):\n\t\t\t\tflag=0\n\t\t\t\tbreak\n\nif (not flag):print(\"NO\");exit();\nprint(\"YES\")\n"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(0,8):\n for j in range(1,8):\n if ((arr[i][j]) == arr[i][j-1]) :\n flag =False\n \nif (flag == True):\n print(\"YES\")\nelif(flag == False):\n print(\"NO\")"}, {"source_code": "for _ in range(8):\n a=raw_input()\n for i in range(7):\n if a[i]==a[i+1]:\n print \"NO\"\n exit()\nprint \"YES\"\n"}, {"source_code": "#multiple times string shift kar ke WBWBWBWB firr niche BWBWBWBW and so on laana hai...\n#par agar kisi mein bhi W ya S repeat ho jaaye ek baari bhi to nahin kar paayenge\n#\nstrings=[]\nfor x in range(1,9):\n s=raw_input()\n strings.append(s)\na=0\nfor i in strings:\n if \"BB\" in i or \"WW\" in i:\n a=1\n break\nif a==1:\n print \"NO\"\nelse:\n print \"YES\""}, {"source_code": "flag=True\nfor i in range(8):\n s=input()\n if s.count(\"WB\")!=4 and s.count(\"BW\")!=4:\n \t print(\"NO\")\n \t flag=False\n \t break\nif flag:\n print(\"YES\")\n"}, {"source_code": "def solve(board):\n for row in board:\n for i in range(1, 8):\n if row[i] == row[i-1]:\n return False\n return True\n\nboard = [raw_input() for i in range(8)]\nprint 'YES' if solve(board) else 'NO'\n"}, {"source_code": "an=1\nfor i in range(8):\n a=list(input())\n if a.count('W')!=4:\n an=-1\n else:\n for j in range(1,8):\n if a[j]==a[j-1]:\n an=-1\nif an==1: print(\"YES\")\nelse: print(\"NO\")"}, {"source_code": "#!/usr/bin/python\n\n\ndef nxt(s, t, i):\n return s.find(t, i)\n\ndef solve():\n for row in range(8):\n line = raw_input()\n p = line[0]\n for c in line[1:]:\n if c==p:\n print 'NO'\n return\n p=c\n print 'YES'\n\nsolve()\n"}, {"source_code": "x='WBWBWBWB';y='BWBWBWBW'\ns=[input() for _ in ' '*8]\nfor i in s:\n if i==x or i==y:\n continue\n else:print('NO');exit(0)\nprint('YES')"}, {"source_code": "ans=\"YES\"\nfor i in range(8):\n s=input()\n if(s!=(s[0]+s[1])*4 or s[0]==s[1]):\n ans=\"NO\"\nprint(ans)\n"}, {"source_code": "t = 0\nok = 0\n\nwhile t < 8:\n last = \"#\"\n s = input()\n for i in s:\n if last == '#':\n last = i\n else:\n if last == i:\n ok = 1\n last = i\n t+=1\nif ok == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "f=0\nfor i in range(8):\n l=list(input())\n for j in range(7):\n if(l[j]==l[j+1]):\n f=1\n break\n if(l[0]==l[-1]):\n f=1\nif(f==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "possible=True\nfor i in range(8):\n line=input()\n if line[0]==line[1]==line[-1] or line[-1]==line[-2]==line[0]:possible=False;continue\n if not possible:continue\n cf = line.split('W')\n cg = line.split('B')\n empty=one=True\n while True:\n try:cf.remove('')\n except Exception: empty=False\n try:cf.remove('B')\n except Exception: one=False\n if not empty and not one: break\n empty=one=True\n while True:\n try:cg.remove('W')\n except Exception: empty=False\n try:cg.remove('')\n except Exception: one=False\n if not empty and not one: break\n if len(cf)>=2:possible=False\n if len(cg)>=2:possible=False\n if len(cf)+len(cg)>=2:possible=False\n if len(cf)==1:\n if len(cf[0])>2:possible=False\n if len(cg)==1:\n if len(cg[0])>2:possible=False\n if i==0:\n pf=cf[:]\n pg=cg[:]\n continue\n if len(cf)==1:\n if len(pf)==1:possible=False\n if len(cg)==1:\n if len(pg)==1:possible=False\n pf=cf[:]\n pg=cg[:]\nif possible:print('YES')\nelse:print(\"NO\")"}, {"source_code": "str = \"\"\nout = 0\nfor i in xrange(8):\n\tstr = raw_input()\n\tif str.count('BW') != 4 and str.count('WB') != 4:\n\t\tout = 1\nif out == 0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "l=[]\na=\"WBWBWBWB\"\nb=\"BWBWBWBW\"\nf=0\nfor i in range(8):\n s=input()\n if s!=a and s!=b:\n f=1\nif f==1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "f = 1\nfor _ in range(8):\n s = raw_input()\n if s not in \"WBWBWBWBW\":\n f = 0\n break\nprint [\"NO\", \"YES\"][f]\n"}, {"source_code": "flag = True\nfor i in range(8):\n a = raw_input()\n if a != 'WBWBWBWB' and a != 'BWBWBWBW':\n flag = False\nprint 'YES' if flag else 'NO'"}, {"source_code": "ok = True\nfor i in range(8):\n s = input()\n if s != 'WBWBWBWB' and s != 'BWBWBWBW':\n ok = False\n break\n\nif ok:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import math\nimport sys\nimport collections\n\n\n# imgur.com/Pkt7iIf.png\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 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)\n\nprint('NO') if any(input() not in {'WBWBWBWB', 'BWBWBWBW'} for i in range(8)) else print('YES')"}, {"source_code": "import sys\n\n\ndef main() :\n #a , b , n = [ int( x ) for x in sys.stdin.readline().strip().split() ]\n for i in range( 8 ) :\n s = sys.stdin.readline().strip()\n cLast = s[ 7 ]\n for c in s :\n if c == cLast :\n print 'NO'\n return\n cLast = c\n print 'YES'\n return\n \n \n\nif __name__ == \"__main__\" :\n main()\n"}, {"source_code": "t1='WBWBWBWB'\nt2='BWBWBWBW'\nflag1=0\nfor i in range(0,8):\n s=input()\n if s==t1 or s==t2:\n continue\n else :\n flag1=1\n break\nif flag1==0:\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "ar=[]\nfor i in range(0,8):\n mp=raw_input()\n ar.append(mp)\nflag=True\nfor i in range(0,8):\n if(flag==False):\n break\n for j in range(0,7):\n if(ar[i][j]==ar[i][j+1]):\n flag=False\n break\nif(flag==True): print \"YES\"\nelse: print \"NO\""}, {"source_code": "if __name__ == '__main__':\n flag = False\n for _ in range(8):\n line = str(input())\n if line not in ('WBWBWBWB', 'BWBWBWBW'):\n flag = True\n break\n print('NO') if flag else print('YES')\n"}, {"source_code": "a = 0\nfor i in range(1,9):\n s = raw_input()\n for j in range(1,len(s)):\n if(s[j] == s[j-1]):\n a = 1\nif(a == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "answer = \"YES\"\nfor i in range(8):\n s = input()\n if s != \"BWBWBWBW\" and s!= \"WBWBWBWB\":\n answer = \"NO\"\nprint(answer)"}, {"source_code": "for i in range(8):\n\ts = raw_input()\n\tfor j in range(1,8):\n\t\tif s[j]==s[j-1] : \n\t\t\tprint \"NO\"\n\t\t\texit(0)\nprint \"YES\"\n\t\t\n"}, {"source_code": "str = \"\"\nout = 0\nfor i in xrange(8):\n\tstr = raw_input()\n\tif str.count('BW') != 4 and str.count('WB') != 4:\n\t\tout = 1\nif out == 0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "def solve():\n\tfor i in range(8):\n\t\trow = list(input())\n\t\tprev = row.pop(0)\n\n\t\tfor j in row:\n\t\t\tif j == prev:\n\t\t\t\tprint(\"NO\")\n\t\t\t\treturn\n\t\t\tprev = j\n\n\tprint(\"YES\")\n\nsolve()"}, {"source_code": "f=0\nfor i in range(8):\n l=list(input())\n for j in range(7):\n if(l[j]==l[j+1]):\n f=1\n break\n if(l[0]==l[-1]):\n f=1\nif(f==0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "for i in range(8):\n s=raw_input()\n if s!='WBWBWBWB' and s!='BWBWBWBW':\n print 'NO'\n exit()\nprint 'YES'\n"}, {"source_code": "FILE = \"input\"\ntry:\n inFile = open(FILE+\".txt\")\nexcept:\n pass\n\ndef read():\n try:\n return inFile.readline().strip()\n except:\n return raw_input().strip()\n\n\nans = True\nfor i in xrange(8):\n row = read()\n for j in xrange(1,7):\n if row[j] == row[j-1] or row[j] == row[j+1]:\n ans = False\n break\n \nif ans:\n print \"YES\"\nelse:\n print \"NO\""}, {"source_code": "arr = []\n\nfor i in range(8):\n k = input()\n arr.append(k)\n\nfor i in range(8):\n if arr[i] == 'WBWBWBWB' or arr[i] == 'BWBWBWBW':\n ans = 'YES'\n else:\n ans = 'NO'\n break\n\nprint(ans)"}, {"source_code": "i=0\nflag=0\nwhile(i<8):\n s=input()\n if(s[0]=='W'):\n \n cur='W'\n else:\n \n cur='B'\n for j in s:\n if cur!=j:\n flag=-1\n elif(j==cur and j=='W'):\n cur='B'\n else:\n cur='W'\n i+=1\nif(flag!=-1):\n print(\"YES\")\nelse:\n print(\"NO\")\n \n \n \n "}, {"source_code": "check=True\nfor i in range(8):\n\ts=input()\n\tfor j in range(1,len(s)):\n\t\tif(s[j]==s[j-1]):\n\t\t\tcheck=False\n\t\t\tbreak\nif(check):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n"}, {"source_code": "from sys import stdin, stdout\n\nif not __debug__:\n stdin = open(\"input.txt\", \"r\")\n\ntcs = int(stdin.readline()) if not __debug__ else 1\nt = 1\nwhile t<=tcs:\n res = True\n for _ in range(8):\n row = str(stdin.readline())\n for c in range(8):\n if row[c]==row[c-1]:\n res = False\n break\n \n print(\"YES\" if res else \"NO\")\n t += 1\n"}, {"source_code": "ans = \"YES\"\nfor _ in range(8):\n if raw_input().strip() not in (\"WBWBWBWB\", \"BWBWBWBW\"):\n ans = \"NO\"\n break\nprint ans "}, {"source_code": "from sys import stdin, stdout\n\n\ndef solve(data):\n def does_alternate(row):\n prev = row[0]\n for x in row[1:]:\n if x == prev:\n return False\n else:\n prev = x\n return True\n\n #first_line = data[0]\n rest_lines = list(map(str.strip, data[:]))\n alternating_rows = list(filter(does_alternate, rest_lines))\n answer = \"YES\" if len(alternating_rows) == 8 else \"NO\"\n\n return answer\n\n\nif __name__ == '__main__':\n data = stdin.readlines()\n answer = solve(data)\n\n if type(answer) in [list]:\n stdout.writelines(map(str, answer))\n else:\n stdout.write(str(answer))\n"}, {"source_code": "doska=[]\nresult=0\n\nfor i in range(8):\n doska.append(raw_input())\n\nfor i in range(8):\n for j in range(-1,-9,-1):\n if (i+1)%2!=0 and doska[i]=='WBWBWBWB':\n result+=1\n break\n if (i+1)%2==0 and doska[i]=='BWBWBWBW':\n result+=1\n break\n doska[i]=doska[i][j:]+doska[i][:j]\n\nif result==8:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "final_ = 'Yes'\nfor i in range(8):\n\tcurrent_row = list(input())\n\tcurrent_row.append(current_row[0])\n\tfor j in range(8):\n\t\tif current_row[j] == current_row[j+1]:\n\t\t\tfinal_ = 'NO'\nprint(final_)\n"}, {"source_code": "l=[]\na=\"WBWBWBWB\"\nb=\"BWBWBWBW\"\nf=0\nfor i in range(8):\n s=input()\n if s!=a and s!=b:\n f=1\nif f==1:\n print(\"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "from sys import stdin\n\n\ndef fun(row):\n col1=row[0]\n col2=row[1]\n if col1!=col2:\n for i in range(8):\n if i%2==0:\n if row[i]!=col1:\n return False\n else:\n if row[i]!=col2:\n return False\n else:\n return False\n return True\n\n\n\nlist=[]\nfor i in range(8):\n list.append(stdin.readline())\nvalid=1\nfor row in list:\n if not fun(row):\n valid=0\n break\nif valid==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "#!/usr/bin/env python\n\nimport sys\nif __name__ == '__main__':\n\n\n for s in sys.stdin:\n\n line = s.strip()\n\n if [1 for i in range(1, len(line)) if line[i] == line[i-1]]:\n print \"NO\"\n break;\n\n else:\n print \"YES\"\n\n \n\n \n"}, {"source_code": "i=0\nflag=0\nwhile(i<8):\n s=input()\n if(s[0]=='W'):\n \n cur='W'\n else:\n \n cur='B'\n for j in s:\n if cur!=j:\n flag=-1\n elif(j==cur and j=='W'):\n cur='B'\n else:\n cur='W'\n i+=1\nif(flag!=-1):\n print(\"YES\")\nelse:\n print(\"NO\")\n \n \n \n "}, {"source_code": "check=True\nfor i in range(8):\n\ts=input()\n\tfor j in range(1,len(s)):\n\t\tif(s[j]==s[j-1]):\n\t\t\tcheck=False\n\t\t\tbreak\nif(check):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "ans=\"YES\"\nfor i in range(8):\n s=input()\n if(s!=(s[0]+s[1])*4 or s[0]==s[1]):\n ans=\"NO\"\nprint(ans)\n"}, {"source_code": "ans=chk=0\nfor i in range(8):\n l=raw_input()\n if 'WW' in l or 'BB' in l:\n ans=1\nprint 'NO' if ans else 'YES'"}, {"source_code": "from sys import stdin\n\n\ndef fun(row):\n col1=row[0]\n col2=row[1]\n if col1!=col2:\n for i in range(8):\n if i%2==0:\n if row[i]!=col1:\n return False\n else:\n if row[i]!=col2:\n return False\n else:\n return False\n return True\n\n\n\nlist=[]\nfor i in range(8):\n list.append(stdin.readline())\nvalid=1\nfor row in list:\n if not fun(row):\n valid=0\n break\nif valid==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "t=True\nfor i in [0]*8:\n r=raw_input()\n t=t and all([x!=y for x,y in zip(r, r[1:])])\nprint 'YNEOS'[not t::2]"}, {"source_code": "sign = True\nfor i in xrange(8):\n\ts = raw_input()\n\tif 'BB' in s or 'WW' in s:\n\t\tsign = False\nif sign:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n"}, {"source_code": "for _ in [1] * 8:\n s = raw_input()\n for i in xrange(len(s)):\n if s[i] == s[i - 1]:\n print 'NO'\n exit()\nprint 'YES'\n"}, {"source_code": "for i in range(8):\n m = raw_input()\n if m.count(\"W\") != 4:\n print \"NO\"\n exit(0)\n else:\n for i in range(7):\n if m[i] == m[i+1]:\n print \"NO\"\n exit(0)\n\nprint \"YES\""}, {"source_code": "\ndef foo():\n table = []\n for i in range(8):\n table.append(input())\n\n w = 'W' * 4\n b = 'B' * 4\n for s in table:\n a1 = s[0:len(s):2]\n a2 = s[1:len(s):2]\n if not ((a1 == w and a2 == b)\n or (a1 == b and a2 == w)):\n print('NO')\n return\n print('YES')\n\nfoo()"}, {"source_code": "print\"YNEOS\"[not all(raw_input() in[\"WB\"*4,\"BW\"*4] for i in[0]*8)::2]\n"}, {"source_code": "k=0\nfor i in range(8):\n s=raw_input()\n a=[s[x] for x in range(0,8,2)]\n b=[s[x] for x in range(1,8,2)]\n if a.count(a[0])==4 and b.count(b[0])==4 and a[0]!=b[0]:k+=1\nprint [\"NO\",\"YES\"][k==8]"}, {"source_code": "c=1\nfor i in range(8):\n s=input()\n if s!=\"WBWBWBWB\" and s!=\"BWBWBWBW\":\n c=0\nif c:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s=[]\nfor i in range(8):\n s.append(input())\n#check if even pattern is of the form WBWBWBWB and odd BWBWBWBW\ndef check(i,index):\n if index%2:\n pat=\"BWBWBWBW\"\n l= [ i[-j:]+i[:8-j] for j in range(1,9) ]\n if pat in l:\n return True\n else:\n return False\n else:\n pat=\"WBWBWBWB\"\n l=[ i[-j:]+i[:8-j] for j in range(1,9) ]\n if pat in l:\n return True\n else:\n return False\n\nstat = True\nfor i in range(8):\n if check(s[i],i)==False:\n stat=False\n break\nprint([\"YES\",\"NO\"][not stat]) \n "}, {"source_code": "#*+++++++++++++++++++++\n# * Written By --------\n# * Boddapati Mahesh **\n# * IIIT Hyderabad *****\n# */\n\nflag=0\nfor i in range(0,8):\n x=raw_input()\n if(x.count('W')!=4 or x.count('B')!=4 or \"BB\" in x or \"WW\" in x):\n flag=1\nif(flag==0):\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "k = 0\nfor i in range(8):\n a = raw_input()\n if a == 'WBWBWBWB' or a == 'BWBWBWBW':\n k = k+1\n\nif 8 - k > 0:\n print 'NO'\nelse:\n print 'YES'"}, {"source_code": "def funk(s):\n for e in range(len(s) - 1):\n if s[e] == s[e + 1]:\n return 0\n return 1\n\nj = 0\nfor i in range(8):\n if funk(raw_input()):\n j += 1\n \nprint ['NO', 'YES'] [j == 8]"}, {"source_code": "from sys import exit\n\nfor _ in range(8):\n curr_line = input()\n if curr_line != 'WBWBWBWB' and curr_line != 'BWBWBWBW':\n print(\"NO\")\n exit(0)\nprint(\"YES\")"}, {"source_code": "res = 'YES'\nfor i in range(8):\n s = input()\n if s != 'BWBWBWBW' and s != 'WBWBWBWB':\n res = 'NO'\nprint(res)\n"}, {"source_code": "a=[]\nflag=0\nfor i in range(8):\n\ta.append(input())\n\tfor j in range(len(a[i])-1):\n\t\tif(a[i][j]==a[i][j+1]):\n\t\t\tflag=1\n\t\t\tbreak\nif(flag==0):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "#!/usr/bin/env python\n\ndef main():\n grid = [input() for _ in range(8)]\n \n for row in grid:\n if not (row == 'WB'*4 or row == 'BW'*4):\n print('NO')\n break\n else:\n print('YES')\n \n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "f = 0\nfor i in range(8):\n a = input()\n p = a[0]\n for j in a[1:]:\n if p == j:\n f = 1\n break\n p = j\n if a[0] == a[-1]:\n f = 1\n if f == 1:\n break\nif f == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "li = []\nfor i in xrange(8):\n\tinp = raw_input()\n\tli.append(inp)\ndef stack(inp):\n\tfor i in xrange(7):\n\t\tif inp[i] == inp[i+1]:\n\t\t\treturn False\n\treturn True\nans = \"\"\nfor i in li:\n\tif stack(i) == False:\n\t\tans = \"NO\"\n\t\tbreak\n\telse:\n\t\tans = \"YES\"\nprint ans\n"}, {"source_code": "from sys import stdin\n\n\ndef fun(row):\n col1=row[0]\n col2=row[1]\n if col1!=col2:\n for i in range(8):\n if i%2==0:\n if row[i]!=col1:\n return False\n else:\n if row[i]!=col2:\n return False\n else:\n return False\n return True\n\n\n\nlist=[]\nfor i in range(8):\n list.append(stdin.readline())\nvalid=1\nfor row in list:\n if not fun(row):\n valid=0\n break\nif valid==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "for _ in range(8):\n\ta = raw_input()\n\tfor j in range(8):\n\t\tif a[j] == a[(j+1)&7]:\n\t\t\tprint \"NO\"\n\t\t\texit()\nprint \"YES\""}, {"source_code": "def fun():\n for i in xrange(8):\n a=raw_input()\n if a.count('W')!=a.count('B') or 'WW' in a or 'BB' in a:\n return 'NO'\n return 'YES'\nprint fun()"}, {"source_code": "t1='WBWBWBWB'\nt2='BWBWBWBW'\nflag1=0\nfor i in range(0,8):\n s=input()\n if s==t1 or s==t2:\n continue\n else :\n flag1=1\n break\nif flag1==0:\n print(\"YES\")\nelse :\n print(\"NO\")"}, {"source_code": "c=1\nfor i in range(8):\n s=input()\n if s!=\"WBWBWBWB\" and s!=\"BWBWBWBW\":\n c=0\nif c:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# http://codeforces.com/problemset/problem/259/A\n'''\n Author - Subhajit Das\n University of Engineering and Management, Kolkata\n DD/MM/2019\n'''\n\n\ndef main():\n board = list()\n for _ in range(8):\n board.append(list(input()))\n\n for i in range(8):\n for j in range(8):\n j1 = (j+1) % 8\n b, a = board[i][j], board[i][j1]\n if((b == 'W' and a == 'W') or (b == 'B' and a == 'B')):\n print('NO')\n return\n\n print('YES')\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "for i in range(8):\n m = raw_input()\n if m.count(\"W\") != 4:\n print \"NO\"\n exit(0)\n else:\n for i in range(7):\n if m[i] == m[i+1]:\n print \"NO\"\n exit(0)\n\nprint \"YES\""}, {"source_code": "for i in range(8):\n s=raw_input()\n if s!='WBWBWBWB' and s!='BWBWBWBW':\n print 'NO'\n exit()\nprint 'YES'\n"}, {"source_code": "ans=\"YES\"\nfor i in range(8):\n s=input()\n if(s!=(s[0]+s[1])*4 or s[0]==s[1]):\n ans=\"NO\"\nprint(ans)\n"}, {"source_code": "import re\n\nwhile True:\n \n try:\n i =0;\n f =1;\n while i<8 :\n a = raw_input()\n if (re.match('(WB){4}', a) or re.match('(BW){4}', a)):\n pass\n else: f =0\n i+=1\n # print f\n \n if f:\n print 'YES'\n else:\n print 'NO'\n \n \n \n \n \n except EOFError:\n \n break"}, {"source_code": "# coding: utf-8\nfor i in range(8):\n s = input()\n s1 = set([s[j] for j in range(8) if j%2==0])\n s2 = set([s[j] for j in range(8) if j%2==1])\n if len(s1)!=1 or len(s2)!=1 or s1==s2:\n print('NO')\n break\nelse:\n print('YES')\n"}, {"source_code": "for _ in range(8):\n a=raw_input()\n for i in range(7):\n if a[i]==a[i+1]:\n print \"NO\"\n exit()\nprint \"YES\"\n"}, {"source_code": "#!/usr/bin/python\n\ndef solve():\n\tfor i in xrange(8):\n\t\ts=raw_input()\n\t\tfor i in xrange(7):\n\t\t\tif s[i]==s[i+1]:\n\t\t\t\treturn \"NO\"\n\t\tif s[0]==s[7]:\n\t\t\treturn \"NO\"\n\treturn \"YES\"\n\nprint solve()"}, {"source_code": "import sys\ntmp = ['B','W']\nt = 0\nfor ch in sys.stdin:\n\tif ch[0] == tmp[t] and ch[-1] == tmp[t]:\n\t\tprint 'NO'\n\t\texit()\n\tfor i in range(len(ch)-1):\n\t\tif ch[i]==ch[i+1] :\n\t\t\tprint 'NO'\n\t\t\texit()\nprint 'YES'\n"}, {"source_code": "#!/usr/bin/env python\nimport sys\n\nROWS = ['WB' * 4, 'BW' * 4]\n\nif __name__ == '__main__':\n board = [sys.stdin.readline().strip() for _ in xrange(8)]\n doable =[True for i, x in enumerate(board) if ROWS[i % 2] in x + x]\n\n if len(doable) == 8:\n print \"YES\"\n else:\n print \"NO\"\n"}, {"source_code": "\n\ndef main():\n matrix = []\n for _ in range(8):\n x = [i for i in str(input())]\n matrix.append(x)\n for row in matrix:\n for c in range(len(row) - 1):\n if row[c] == row[c + 1]:\n print(\"NO\")\n return\n print(\"YES\")\n\n\n\n\n\nmain()"}, {"source_code": "r=0\na=\"WBWBWBWB\"\nb=\"BWBWBWBW\"\nfor i in range(8):\n x=input()\n if x==a or x==b :\n r+=1\nif r==8:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\n\nlines = []\nfor i in range(8):\n\tlines.append(sys.stdin.readline().strip())\n\nfor i in range(8):\n\tif not (lines[i] == \"WBWBWBWB\" or lines[i] == \"BWBWBWBW\"):\n\t\tprint \"NO\"\n\t\tbreak\nelse:\n\tprint \"YES\"\n\n"}, {"source_code": "# import re\nl=[]\nj=0\nfor x in range(0,8):\n\ti=raw_input()\n\tif(i=='WBWBWBWB'):\n\t\tj=j+1\n\telif(i=='BWBWBWBW'):\n\t\tj=j+1\n\telse:\n\t\tcontinue\nif j==8:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "print('YES' if all([r=='WB'*4 or r=='BW'*4 for r in [input() for _ in range(8)]]) else 'NO')"}, {"source_code": "import sys\nfor ch in sys.stdin:\n\tfor i in range(len(ch)-1):\n\t\tif ch[i]==ch[i+1] :\n\t\t\tprint 'NO'\n\t\t\texit()\nprint 'YES'\n"}, {"source_code": "for x in xrange(8):\n s = raw_input()\n if s != \"WBWBWBWB\" and s != \"BWBWBWBW\":\n print \"NO\" \n exit(0)\nprint \"YES\""}, {"source_code": "def main():\n strings = []\n for i in range(8):\n strings.append(raw_input())\n bool = True;\n for i in range(8):\n if strings[i] != \"WBWBWBWB\" and strings[i] != \"BWBWBWBW\":\n print \"NO\"\n bool = False\n break\n if bool:\n print \"YES\"\n\nmain()"}, {"source_code": "\n\n\nt=[]\n\nu=0\nfor i in range(8):\n\n a= list(input())\n if a.count('B')==a.count('W'):\n for k in range(7):\n if a[k]!=a[k+1]:\n pass\n else:\n u+=1\n else:\n u+=1\n t.append(a)\n\n\nif u>0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "import re\n\nfor i in range(8):\n s = input()\n if re.findall(r'(WW)|(BB)', s):\n print('NO')\n exit(0)\n\nprint('YES')\n"}, {"source_code": "x='WBWBWBWB';y='BWBWBWBW'\ns=[input() for _ in ' '*8]\nfor i in s:\n if i==x or i==y:\n continue\n else:print('NO');exit(0)\nprint('YES')"}, {"source_code": "for i in range(8):\n\ts = raw_input()\n\tfor j in range(1,8):\n\t\tif s[j]==s[j-1] : \n\t\t\tprint \"NO\"\n\t\t\texit(0)\nprint \"YES\"\n\t\t\n"}, {"source_code": "l=[]\nfor i in range(8):\n\tl.append(input())\nflag1,flag2=True,True\nfor i in l:\n\tx=i.count('B')\n\ty=8-x\n\tif x==4 and y==4:\n\t\tcontinue\n\tflag1=False\n\tbreak\nif flag1==False:\n\tprint('NO')\n\texit()\nelse:\n\tfor i in l:\n\t\tx=i*3\n\t\ta,b=x.find('BB'),x.find('WW')\n\t\tif a>=0 or b>=0:\n\t\t\tflag2=False\n\t\t\tbreak\n\tif flag2==False:\n\t\tprint('NO')\n\telse:\n\t\tprint('YES')"}, {"source_code": "for i in range(8):\n s=input()\n if s!='WBWBWBWB' and s!='BWBWBWBW':\n print('NO')\n exit()\nprint(\"YES\")\n "}], "negative_code": [{"source_code": "try:\n \n c = 0\n for i in range(0,8):\n \n s = str(input())\n s1 = \"BWBWBWBW\"\n s2 = \"WBWBWBWB\"\n if s == s1 or s == s2:\n continue\n else:\n c = 1\n break\n\n\n \n \n print(c)\n\n if c == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nexcept Exception:\n pass\n \n \n \n \n \n"}, {"source_code": "an=1\nfor i in range(8):\n a=list(input())\n if a.count('W')!=4:\n an=-1\n else:\n for j in range(1,8):\n if a[j]==a[j-1]:\n break\n\nif an==1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "an=1\nfor i in range(8):\n a=list(input())\n if a.count('W')!=4:\n an=-1\nif an==1:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "flag = True\nfor i in range(8):\n ls = input()\n W = sum([1 for s in ls if(s=='W')])\n if(W != 4):\n flag = False\n break\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "flag = True\nfor i in range(8):\n ls = input()\n temp = ls[0]\n W = sum([1 for s in range(2, len(ls), 2) if(ls[s]==temp)])\n if(W != 4):\n flag = False\n break\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "flag = True\nfor i in range(8):\n ls = input()\n temp = ls[0]\n W = sum([1 for s in range(2, len(ls), 2) if(ls[s]==temp)])\n if(W != 3):\n flag = False\n break\nprint(\"YES\" if flag else \"NO\")"}, {"source_code": "\n\n\nt=[]\n\nu=0\nfor i in range(8):\n\n a= list(input())\n if a.count('B')!=a.count('W'):\n u+=1\n t.append(a)\n\n\nif u>0:\n print('NO')\nelse:\n print('YES')"}, {"source_code": "from sys import exit\n\ndef board_is_proper(board):\n if board[0][0] == 'B':\n return False\n for i in range(1, 7):\n for j in range(1, 7):\n if board[i][j] == board[i][j+1] or board[i][j] == board[i][j-1] or board[i][j] == board[i-1][j] or board[i][j] == board[i+1][j]:\n return False\n return True\n\ndef line_is_proper(s):\n for i in range(7):\n if s[i] == s[i+1]:\n return False\n return True\n\ndef two_lines_is_proper(a, b):\n for i in range(8):\n if a[i] == b[i]:\n return False\n return True\n\ndef shift(s):\n new_s = s[len(s) - 1]\n for i in range(len(s) - 1):\n new_s += s[i]\n return new_s\n\ndef shift_n_times(s, n):\n for _ in range(n):\n s = shift(s)\n return s\n\nboard = []\nfor _ in range(8):\n board.append(input())\ncurr_line = board[0]\nfor j in range(7):\n if line_is_proper(curr_line) and curr_line[0] == 'W':\n break\n curr_line = shift(curr_line)\nif not line_is_proper(curr_line) or curr_line[0] == 'B':\n print(\"NO\")\n exit(0)\nfor i in range(1, 8):\n curr_line = board[i]\n for j in range(7):\n if line_is_proper(curr_line):\n break\n curr_line = shift(curr_line)\n if not line_is_proper(curr_line):\n print(\"NO\")\n exit(0)\n if i == 0:\n continue\n prev_line = board[i-1]\n for j in range(7):\n if two_lines_is_proper(prev_line, curr_line):\n break\n curr_line = shift(curr_line)\n if not two_lines_is_proper(prev_line, curr_line):\n print(\"NO\")\n exit(0)\n board[i] = curr_line\nif board_is_proper(board):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "l=[]\nfor i in range(8):\n l.append(input())\nflag1=True\nfor i in l:\n x=i.count('B')\n y=8-x\n if x==4 and y==4:\n continue\n flag1=False\n break\nif flag1==False:\n print('NO')\n exit()\nelse:\n flag2=True\n for i in l:\n temp=i*3\n a,b=temp.find('BBB'),temp.find('WWW')\n if a>=0 or b>=0:\n flag2=False\n break\n if flag1==True and flag2==True:\n print('YES')\n else:\n print('NO')"}, {"source_code": "x=[]\nfor i in range(8):\n s=str(input())\n x.append(s)\nd=False\nfor i in range(8):\n s=x[i]\n s.replace(\" \",\"\")\n\n if(s.count(\"B\")==4 and s.count(\"W\")==4):\n continue\n else:\n d=True\n print(\"NO\")\n break\nif(d==False):\n print(\"YES\")"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for l in range(7):\n count = 0\n for i in range(7):\n if a[l][i] == a[l][i+1]:\n count += 1\n if count >= 2:\n print(\"NO\")\n return\n for l in range(1, 7):\n for i in range(1, 7):\n if a[l][i] == a[l+1][i] == a[l][i+1] == a[l+1][i+1]:\n print(\"NO\")\n return\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for l in range(7):\n count = 0\n for i in range(7):\n if a[l][i] == a[l][i+1] or (a[l][i] == a[l+1][i] and a[l][i+1] == a[l+1][i+1]):\n count += 1\n if count >= 2:\n print(\"NO\")\n return\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for l in range(7):\n count = 0\n for i in range(7):\n if a[l][i] == a[l][i+1]:\n count += 1\n if count >= 2:\n print(\"NO\")\n return\n if a[l][i] == a[l+1][i] and a[l][i+1] == a[l+1][i+1]:\n print(\"NO\")\n return\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for l in range(7):\n count = 0\n for i in range(7):\n if a[l][i] == a[l][i+1] or a[l][i] == a[l+1][i] == a[l][i+1] == a[l+1][i+1]:\n count += 1\n if count >= 2:\n print(\"NO\")\n return\n # for l in range(1, 7):\n # for i in range(1, 7):\n # if a[l][i] == a[l+1][i] and a[l][i+1] == a[l+1][i+1]:\n\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for line in a:\n for i in range(1, 7):\n if line[i-1] == line[i] == line[i+1]:\n print(\"NO\")\n return\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for l in range(7):\n count = 0\n for i in range(7):\n if a[l][i] == a[l][i+1] and a[l][i] == a[l+1][i] and a[l][i+1] == a[l+1][i+1]:\n count += 1\n if count >= 2:\n print(\"NO\")\n return\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "import sys\nf = sys.stdin\n#f = open(\"input.txt\", \"r\")\ndef solve():\n global f\n a = f.read().strip().split(\"\\n\")\n for line in a:\n count = 0\n for i in range(7):\n if line[i] == line[i+1]:\n count += 1\n if count >= 2:\n print(\"NO\")\n return\n else:\n print(\"YES\")\n return\nsolve()"}, {"source_code": "possible=True\npw,pb=False,False\nfor i in range(8):\n line=input()\n if line[0]==line[1]==line[-1] or line[-1]==line[-2]==line[0]:possible=False;continue\n if not possible:continue\n cw=cb=False\n c=1\n count=0\n for i in range(1,8):\n if line[i]==line[i-1]:\n c+=1\n if line[i]=='W':cw=True\n else:cb=True\n else:\n if c>1:count+=1\n if c>2:possible=False\n c=1\n if c>1:count+=1\n if c>2:possible=False\n if count>2:possible=False\n if cw==True and pw==True:possible=False\n if cb==True and pb==True:possible=False\n pw=cw;pb=cb\nif possible:print('YES')\nelse:print(\"NO\")"}, {"source_code": "possible=True\nfor i in range(8):\n line = input()\n count=0\n c=1\n if not possible: continue\n for i in range(1,8):\n if line[i]==line[i-1]:\n c+=1\n else:\n if c>1:count+=1\n c=1\n if c==3:\n possible = False\n if count>=2:possible=False\n\nif possible: print('YES')\nelse:print('NO')"}, {"source_code": "possible=True\nfor i in range(8):\n line=input()\n if line[0]==line[1]==line[-1] or line[-1]==line[-2]==line[0]:possible=False;continue\n if not possible:continue\n cf = line.split('W')\n cg = line.split('B')\n empty=one=True\n while True:\n try:cf.remove('')\n except Exception: empty=False\n try:cf.remove('B')\n except Exception: one=False\n if not empty and not one: break\n empty=one=True\n while True:\n try:cg.remove('W')\n except Exception: empty=False\n try:cg.remove('')\n except Exception: one=False\n if not empty and not one: break\n if len(cf)>=2:possible=False\n if len(cg)>=2:possible=False\n if i==0:\n pf=cf[:]\n pg=cg[:]\n continue\n if len(cf)==1:\n if len(pf)==1:possible=False\n if len(cg)==1:\n if len(pg)==1:possible=False\n # print(possible,cf,pf,cg,pg)\n pf=cf[:]\n pg=cg[:]\nif possible:print('YES')\nelse:print('NO')"}, {"source_code": "possible=True\nfor i in range(8):\n line=input()\n if line[0]==line[1]==line[-1] or line[-1]==line[-2]==line[0]:possible=False;continue\n if not possible:continue\n cf = line.split('W')\n cg = line.split('B')\n empty=one=True\n while True:\n try:cf.remove('')\n except Exception: empty=False\n try:cf.remove('B')\n except Exception: one=False\n if not empty and not one: break\n empty=one=True\n while True:\n try:cg.remove('W')\n except Exception: empty=False\n try:cg.remove('')\n except Exception: one=False\n if not empty and not one: break\n if len(cf)>=2:possible=False\n if len(cg)>=2:possible=False\n if len(cf)==1:\n if len(cf[0])>2:possible=False\n if len(cg)==1:\n if len(cg[0])>2:possible=False\n if i==0:\n pf=cf[:]\n pg=cg[:]\n continue\n if len(cf)==1:\n if len(pf)==1:possible=False\n if len(cg)==1:\n if len(pg)==1:possible=False\n print(possible,cf,pf,cg,pg)\n pf=cf[:]\n pg=cg[:]"}, {"source_code": "possible=True\npw,pb=False,False\nfor i in range(8):\n line=input()\n if line[0]==line[1]==line[-1] or line[-1]==line[-2]==line[0]:possible=False;continue\n if not possible:continue\n cw=cb=False\n c=1\n count=0\n for i in range(1,8):\n if line[i]==line[i-1]:\n c+=1\n if line[i]=='W':cw=True\n else:cb=True\n else:\n if c>1:count+=1\n if c>2:possible=False\n c=1\n if cw and cb:possible=False\n if c>1:count+=1\n if c>2:possible=False\n if count>2:possible=False\n if cw==True and pw==True:possible=False\n if cb==True and pb==True:possible=False\n pw=cw;pb=cb\nif possible:print('YES')\nelse:print(\"NO\")\n \n \n \n \n \n \n \n \n \n \n# cf = line.split('W')\n# cg = line.split('B')\n# empty=one=True\n# while True:\n# try:cf.remove('')\n# except Exception: empty=False\n# try:cf.remove('B')\n# except Exception: one=False\n# if not empty and not one: break\n# empty=one=True\n# while True:\n# try:cg.remove('W')\n# except Exception: empty=False\n# try:cg.remove('')\n# except Exception: one=False\n# if not empty and not one: break\n# if len(cf)>=2:possible=False\n# if len(cg)>=2:possible=False\n# if len(cf)+len(cg)>=2:possible=False\n# if len(cf)==1:\n# if len(cf[0])>2:possible=False\n# if len(cg)==1:\n# if len(cg[0])>2:possible=False\n# if i==0:\n# pf=cf[:]\n# pg=cg[:]\n# continue\n# if len(cf)==1:\n# if len(pf)==1:possible=False\n# if len(cg)==1:\n# if len(pg)==1:possible=False\n# pf=cf[:]\n# pg=cg[:]\n# if possible:print('YES')\n# else:print(\"NO\")"}, {"source_code": "possible=True\nfor i in range(8):\n line=input()\n if line[0]==line[1]==line[-1] or line[-1]==line[-2]==line[0]:possible=False;continue\n if not possible:continue\n cf = line.split('W')\n cg = line.split('B')\n empty=one=True\n while True:\n try:cf.remove('')\n except Exception: empty=False\n try:cf.remove('B')\n except Exception: one=False\n if not empty and not one: break\n empty=one=True\n while True:\n try:cg.remove('W')\n except Exception: empty=False\n try:cg.remove('')\n except Exception: one=False\n if not empty and not one: break\n if len(cf)>=2:possible=False\n if len(cg)>=2:possible=False\n if len(cf)==1:\n if len(cf[0])>2:possible=False\n if len(cg)==1:\n if len(cg[0])>2:possible=False\n if i==0:\n pf=cf[:]\n pg=cg[:]\n continue\n if len(cf)==1:\n if len(pf)==1:possible=False\n if len(cg)==1:\n if len(pg)==1:possible=False\n pf=cf[:]\n pg=cg[:]\nif possible:print('YES')\nelse:print('NO')"}, {"source_code": "possible=True\nfor i in range(8):\n line = input()\n count=0\n c=1\n if not possible: continue\n for i in range(1,8):\n if line[i]==line[i-1]:\n c+=1\n else:\n if c>1:count+=1\n c=1\n if c>=3:\n possible = False\n break\n if c>=2:count+=1\n if count>=2:possible=False\n\nif possible: print('YES')\nelse:print('NO')"}, {"source_code": "for i in range(8):\n l = list(input())\n if (l[::2].count('B') != 0 and l[::2].count('W') != 0) or (l[1::2].count('B') != 0 and l[1::2].count('W') != 0):\n print('NO')\n exit()\nprint('YES')"}, {"source_code": "flag = True\n\nfor _ in range(8):\n s = input()\n if s.count(\"W\") == 4 and s.count(\"B\") == 4:\n c = s[0]\n for i in s[1:]:\n if i == c:\n flag = False\n else:\n c = i\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "ans=\"YES\"\nfor i in range(8):\n s=input()\n if(s!=(s[0]+s[1])*4):\n ans=\"NO\"\nprint(ans)\n"}, {"source_code": "import re\n\nfor _ in range(8):\n if re.match('WW|BB', input()) is not None:\n print('NO')\n exit()\nprint('YES')"}, {"source_code": "l1=list(input())\nl2=list(input())\nl3=list(input())\nl4=list(input())\nl5=list(input())\nl6=list(input())\nl7=list(input())\nl8=list(input())\nfor i in range (len(l1)-1):\n l7[i]=l7[i+1]\n if l7[i]==l7[-1]:\n l7[i]=l7[-1]\n \nif l1==l8:\n print(\"YES\")\nelif l7==l8:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "int1=\"WBWBWBWB\"\nint2=\"BWBWBWBW\"\nres=0\nfor i in range (8):\n line=input()\n for j in range (len(line)):\n if line==int1 or line == int2:\n res+=1\nif res==8:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "import sys\n\na=[str(input()) for x in range(8)]\nfor x in a:\n if x==\"WBWBWBWB\" :\n continue\n elif x==\"BWBWBWBW\":\n continue\n else:\n print(x,\"NO\")\n sys.exit()\nprint(\"YES\")"}, {"source_code": "valid = True\nfor i in range(8):\n S = input()\n if sum([s == 'B' for s in S]) != 4:\n valid = False\nprint(\"YES\" if valid else \"NO\")"}, {"source_code": "w = 0\nb = 0\nfor i in range(8):\n str = input()\n w += str.count('W')\n b += str.count('B')\nif b == 32 and w == 32:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "w = 0\nb = 0\nans = 1\nfor i in range(8):\n ww = 0\n bb = 0\n str = input()\n w += str.count('W')\n b += str.count('B')\n ww += str.count('WW')\n bb += str.count('BB')\n if ww >= 1 and bb >= 1:\n ans = 0\nif b == 32 and w == 32 and ans != 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "import sys\na=[str(input()) for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" and \"BWBWBWBW\":\n print(\"NO\")\n sys.exit()\n else:\n print(\"YES\")\n sys.exit()\n"}, {"source_code": "import sys\na=[str(input()) for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" and \"BWBWBWBW\":\n print(\"YES\")\n sys.exit()\n else:\n print(\"NO\")\n sys.exit()\n"}, {"source_code": "import sys\na=[input() for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" and \"BWBWBWBW\":\n print(\"NO\")\n sys.exit()\n else:\n print(\"YES\")\n sys.exit()\n"}, {"source_code": "import sys\n\na=[str(input()) for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" or \"BWBWBWBW\":\n print(\"NO\")\n sys.exit()\n else: \n print(\"YES\")\n sys.exit()\n \n"}, {"source_code": "import sys\na=[str(input()) for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" or \"BWBWBWBW\":\n print(\"NO\")\n sys.exit()\n else:\n print(\"YES\")\n sys.exit()\n"}, {"source_code": "import sys\na=[input() for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" or \"BWBWBWBW\":\n print(\"NO\")\n sys.exit()\n else:\n print(\"YES\")\n sys.exit()\n"}, {"source_code": "a=[input() for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" or \"BWBWBWBW\":\n print(\"NO\")\n else:\n print(\"YES\")\n"}, {"source_code": "import sys\n\na=[str(input()) for x in range(8)]\nfor x in range(8):\n if a[x]!=\"WBWBWBWB\" and \"BWBWBWBW\":\n print(\"NO\")\n sys.exit()\n else: \n print(\"YES\")\n sys.exit()\n \n"}, {"source_code": "s=''\nfor i in range(8): s=s+input()\nprint('YNEOS '[s.count('W')!=32::2])"}, {"source_code": "M = []\n\nf = True\nfor i in range(8):\n M.append(input())\n if M[-1].count(\"W\") != 4:\n f = False\n break\n \nfor i in range(8):\n B = 0\n \n for j in range(8):\n if M[i][j] == 'B':\n B += 1\n if B != 4:\n f = False\n break\n \nif f:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n \n "}, {"source_code": "M = []\n\nf = True\nfor i in range(8):\n M.append(input())\n if M[-1].count(\"W\") != 4:\n f = False\n \nfor i in range(8):\n B = 0\n \n for j in range(8):\n if M[j][i] == 'B':\n B += 1\n if B != 4:\n f = False\n break\n \nif f:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n \n "}, {"source_code": "M = []\n\nf = True\nfor i in range(8):\n M.append(input())\n if M[-1].count(\"W\") != 4:\n f = False\n \nfor c in range(8):\n B = 0\n \n for r in range(8):\n if M[r][c] == 'B':\n B += 1\n if B != 4:\n f = False\n break\n \nif f:\n print(\"YES\")\n\nelse:\n print(\"NO\")\n \n "}, {"source_code": "state = -1\nres = True\nval = lambda c, m: not ((c == 'W') ^ ((m % 2) == 1))\nfor i in range(8):\n s = input()\n if 'WWW' in s or 'BBB' in s or ('WW' in s and 'BB' in s):\n res = False\n c = ''\n if 'WW' in s:\n c = 'W'\n if 'BB' in s:\n c = 'B'\n if c == '': continue\n if state == -1:\n state = val(c, i)\n elif state != val(c, i):\n res = False\nprint('YES' if res else 'NO')"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(8):\n for j in range(8):\n if (arr[i][j]) == \"w\" and (arr[i][j+1] == \"b\") and j != 8:\n cw+=1\n elif (arr[i][j]) == \"b\" and (arr[i][j+1] == \"w\") and j != 8:\n cb+=1\n if cw == cb :\n continue\n else:\n flag= False\n break\nif (flag == True):\n print(\"YES\")\nelse:\n print('NO')\n# print(arr)"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = False\n# WBWBWBWB\n# WBWBWBWB\n# BWBWBWBW\n# WBWBWBWB\n# WBWBWBWB\n# WBWBWBWB\n# WBWBWBWB\n# # BWWWBWBW\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"W\") and j == 7 and ((arr[i][0]) == \"B\"):\n cw+=1\n elif ((arr[i][j]) == \"B\") and j == 7 and ((arr[i][0]) == \"W\"):\n cb+=1\n elif (((arr[i][j]) == \"B\") and (arr[i][j+1] == \"B\")) or (((arr[i][j]) == \"W\") and (arr[i][j+1] == \"W\")):\n cb-=1 \n elif ((arr[i][j]) == \"W\") and (arr[i][j+1] == \"B\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and (arr[i][j+1] == \"W\") and j != 7:\n cb+=1\n if cw == cb :\n print(cw,cb)\n cw=cb=0\n flag = True\n continue\n else:\n flag= False\n print('NO')\n break\nif (flag == True):\n print(\"YES\")\n"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = False\n# WBWBWBWB\n# WBWBWBWB\n# BBWBWWWB\n# BWBWBWBW\n# BWBWBWBW\n# BWBWBWWW\n# BWBWBWBW\n# BWBWBWBW\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"W\") and j == 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and j == 7:\n cb+=1\n elif ((arr[i][j]) == \"W\") and (arr[i][j+1] == \"B\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and (arr[i][j+1] == \"W\") and j != 7:\n cb+=1\n if cw == cb :\n # print(cw,cb)\n cw=cb=0\n flag = True\n continue\n else:\n flag= False\n print('NO')\n break\nif (flag == True):\n print(\"YES\")\n"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = False\n# WBWBWBWB\n# WBWBWBWB\n# BWBWBWBW\n# WBWBWBWB\n# WBWBWBWB\n# WBWBWBWB\n# WBWBWBWB\n# # BWWWBWBW\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"W\") and j == 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and j == 7:\n cb+=1\n elif (((arr[i][j]) == \"B\") and (arr[i][j+1] == \"B\")) or (((arr[i][j]) == \"W\") and (arr[i][j+1] == \"W\")):\n cb-=1 \n elif ((arr[i][j]) == \"W\") and (arr[i][j+1] == \"B\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and (arr[i][j+1] == \"W\") and j != 7:\n cb+=1\n if cw == cb :\n # print(cw,cb)\n cw=cb=0\n flag = True\n continue\n else:\n flag= False\n print('NO')\n break\nif (flag == True):\n print(\"YES\")\n"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"w\") and j == 7:\n cw+=1\n elif ((arr[i][j]) == \"b\") and j == 7:\n cb+=1\n elif ((arr[i][j]) == \"w\") and (arr[i][j+1] == \"b\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"b\") and (arr[i][j+1] == \"w\") and j != 7:\n cb+=1\n if cw == cb :\n cw=cb=0\n continue\n else:\n flag= False\n break\nif (flag == True):\n print(\"YES\")\nelse:\n print('NO')\n# print(arr)"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = False\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"w\") and j == 7:\n cw+=1\n elif ((arr[i][j]) == \"b\") and j == 7:\n cb+=1\n elif ((arr[i][j]) == \"w\") and (arr[i][j+1] == \"b\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"b\") and (arr[i][j+1] == \"w\") and j != 7:\n cb+=1\n if cw == cb :\n cw=cb=0\n flag = True\n continue\n else:\n flag= False\n print('NO')\n break\nif (flag == True):\n print(\"YES\")\n"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"w\") and (arr[i][j+1] == \"b\") and j != 8:\n cw+=1\n elif ((arr[i][j]) == \"b\") and (arr[i][j+1] == \"w\") and j != 8:\n cb+=1\n if cw == cb :\n continue\n else:\n flag= False\n break\nif (flag == True):\n print(\"YES\")\nelse:\n print('NO')\n# print(arr)"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = False\n# WBWBWBWB\n# WBWBWBWB\n# BBWBWWWB\n# BWBWBWBW\n# BWBWBWBW\n# BWBWBWWW\n# BWBWBWBW\n# BWBWBWBW\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"W\") and j == 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and j == 7:\n cb+=1\n elif ((arr[i][j]) == \"W\") and (arr[i][j+1] == \"B\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"B\") and (arr[i][j+1] == \"W\") and j != 7:\n cb+=1\n if cw == cb :\n print(cw,cb)\n cw=cb=0\n flag = True\n continue\n else:\n flag= False\n print('NO')\n break\nif (flag == True):\n print(\"YES\")\n"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(8):\n for j in range(8):\n if (arr[i][j]) == \"w\" and (arr[i][j+1] == \"b\") and j != 8:\n cw+=1\n elif (arr[i][j]) == \"b\" and (arr[i][j+1] == \"w\") and j != 8:\n cb+=1\n if cw == cb :\n continue\n else:\n flag= False\n break\nif (flag == True):\n print(\"YES\")\nelse:\n print('NO')\nprint(arr)"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(0,8):\n for j in range(1,8):\n if ((arr[i][j]) == arr[i-1][j-1]) :\n flag =False\n \nif (flag == True):\n print(\"YES\")\nelif(flag == False):\n print(\"NO\")"}, {"source_code": "arr=[ list( input() ) for _ in range (8) ]\ncw=0\ncb=0\nflag = True\nfor i in range(8):\n for j in range(8):\n if ((arr[i][j]) == \"w\") and j == 7:\n cw+=1\n elif ((arr[i][j]) == \"b\") and j == 7:\n cb+=1\n elif ((arr[i][j]) == \"w\") and (arr[i][j+1] == \"b\") and j != 7:\n cw+=1\n elif ((arr[i][j]) == \"b\") and (arr[i][j+1] == \"w\") and j != 7:\n cb+=1\n if cw == cb :\n cw=cb=0\n continue\n else:\n flag= False\n print('NO')\n break\nif (flag == True):\n print(\"YES\")\n"}, {"source_code": "l=[]\nf=0\nfor i in range(8):\n l.append(input())\nfor i in range(8):\n for j in range(8):\n if l[i][j%8]==l[i][(j+1)%8]==l[i][(j+2)%8]:\n f=1\nif f==1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "flag = True \n\nfor i in range(8):\n row = input()\n\n x = row[0]\n y = row[1]\n for j in range(2,8):\n if(j%2 == 0):\n if(row[j] != x):\n flag &= False\n break \n\n else:\n if(row[j] != y):\n flag &= False\n break \n \nif(flag):\n print(\"YES\")\n\nelse:\n print(\"NO\")"}, {"source_code": "w,b=0,0\nfor i in xrange(8):\n\ts=raw_input()\n\tfor c in s:\n\t\tif c==\"W\":\n\t\t\tw+=1\n\t\telse:\n\t\t\tb+=1\nif w!=b:\n\tprint \"NO\"\nelse:\n\tprint \"YES\"\n"}, {"source_code": "print\"YNEOS\"[not all(raw_input() in[\"WB\"*4,\"BW\"*4] for i in[0]*8)]"}, {"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 sys.stdin.readline().strip().split()\ndef rai():\n return map(int,sys.stdin.readline().strip().split())\ndef main():\n for x in xrange(8):\n ss = rs()\n for i in xrange(1,8):\n if ss[i] == ss[i-1]:\n print \"NO\"\n print \"YES\"\nif __name__ == \"__main__\":\n # sys.stdin=open(\"input.txt\",\"r\")\n # sys.stdout=open(\"output.txt\",\"w\")\n main()"}, {"source_code": "import sys\nimport copy\nR = lambda:map(int,raw_input().split())\nwb = 0\nbw = 0\nfor i in xrange(8):\n s = raw_input()\n if s == \"WBWBWBWB\": wb += 1\n elif s == \"BWBWBWBW\": bw += 1\n\nif wb is 4 and bw is 4: print \"YES\"\nelse: print \"NO\"\n"}, {"source_code": "def fun():\n for i in xrange(8):\n a=raw_input()\n if a.count('W')!=a.count('B'):\n return 'NO'\n return 'YES'\nprint fun()"}, {"source_code": "import sys\nprint \"YES\" if len(filter(lambda s: s not in (\"WB\"*4, \"BW\"*4), sys.stdin)) == 0 else \"NO\""}, {"source_code": "def readFile():\n dec = []\n for i in range(8):\n dec.append(raw_input())\n return dec\n\ndef checkDeck(D):\n for line in D:\n for _ in line: \n test = line[-1] + line[:-1] \n if 'WWW' in line or 'BBB' in line:\n return 'NO'\n return 'YES'\n\nif __name__ == '__main__':\n deck = readFile()\n ans = checkDeck(deck)\n print ans"}, {"source_code": "def readFile():\n dec = []\n for i in range(8):\n dec.append(raw_input())\n return dec\n\ndef checkDeck(D):\n first = ''\n for line in D:\n for _ in line:\n if first != '':\n if line[0] == line[-1] and line[0] == first:\n return 'NO'\n test = line[-1] + line[:-1] \n if 'WWW' in line or 'BBB' in line:\n return 'NO'\n first = line[0]\n return 'YES'\n\nif __name__ == '__main__':\n deck = readFile()\n ans = checkDeck(deck)\n print ans "}, {"source_code": "chessDesk = [];\nfor j in range(8):\n chessDesk.append(raw_input());\nright = True;\nfor i in range(8):\n if \"WW\" in chessDesk[i] or \"BB\" in chessDesk[i]:\n right = False;\n break;\nprint right;\n"}, {"source_code": "from collections import Counter\nfrom sys import stdin\n\nlines = map(lambda x: stdin.readline().strip(), range(8))\n\nwb = \"WB\" * 4\nbw = \"BW\" * 4\n\nif lines.count(wb) == 4 and lines.count(bw) == 4:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "#!/usr/bin/env python\nfrom sys import stdin\nboard = map(lambda x: x.strip(), stdin.readlines())\nP1 = \"WBWBWBWB\"\nP2 = \"BWBWBWBW\"\nfor row in board:\n if row != P1 and row != P2:\n print \"NO\"\n exit()\nprint [\"NO\", \"YES\"][ board[0][0] == 'W' ]"}, {"source_code": "f = 1\nfor _ in range(6):\n s = raw_input()\n if s not in \"WBWBWBWBW\":\n f = 0\n break\nprint [\"NO\", \"YES\"][f]\n"}, {"source_code": "doska=[]\nresult=0\n\nfor i in range(8):\n doska.append(raw_input())\n\nfor i in range(8):\n for j in range(-1,-9,-1):\n if (i+1)%2!=0 and doska[i]=='WBWBWBWB':\n result+=1\n break\n if (i+1)%2==0 and doska[i]=='BWBWBWBW':\n result+=1\n break\n doska[i]=doska[i][j:]+doska[i][:j]\nprint result\nif result==8:\n print 'YES'\nelse:\n print 'NO'"}, {"source_code": "def task(input):\n for line in input:\n line = [item for item in line if item in ['W', 'B']]\n if line.count('W') != line.count('B'):\n return \"NO\"\n\n for i in range(0, len(line) - 1, 2):\n if not((line[i] == 'W' and line[i + 1] == 'B') or (line[i] == 'B' and line[i + 1] == 'W')):\n return \"NO\"\n\n return \"YES\"\n\ninput = [str(raw_input()) for i in range(8)]\nprint task(input)\n"}, {"source_code": "print [\"NO\", \"YES\"][''.join(raw_input() for _ in range(8)).count('B') == 32]"}, {"source_code": "a = 0\nfor i in range(1,9):\n s = raw_input()\n for j in range(1,len(s)):\n if(s[j] == s[j-1]):\n a = 1\nif(a == 0 or s[0] == s[len(s)-1]):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# import re\nl=[]\nj=0\nfor x in range(0,8):\n\ti=raw_input()\n\tif(i=='wbwbwbwb'):\n\t\tj=j+1\n\telif(i=='bwbwbwbw'):\n\t\tj=j+1\n\telse:\n\t\tcontinue\nif j==8:\n\tprint 'YES'\nelse:\n\tprint 'NO'"}, {"source_code": "def main():\n strings = []\n for i in range(8):\n strings.append(raw_input())\n for i in range(8):\n print strings[i]\n for i in range(8):\n if strings[i] != \"WBWBWBWB\" or strings[i] != \"BWBWBWBW\":\n print \"NO\"\n break\n print \"YES\"\n\nmain()"}, {"source_code": "ar=[]\nfor i in range(0,7):\n mp=raw_input()\n ar.append(mp)\nflag=True\nfor i in range(0,7):\n if(flag==False):\n break\n for j in range(0,6):\n if(ar[i][j]==ar[i][j+1]):\n flag=False\n break\nif(flag==True): print \"YES\"\nelse: print \"NO\""}, {"source_code": "import sys\n\nn = 8\n#sys.stdin = open('in', 'r')\na = []\nfor i in xrange(n):\n a.append(raw_input())\n\nyes = True\nfor i in xrange(1, n):\n good = False\n for j in xrange(n):\n good2 = True\n for k in xrange(n):\n if a[i-1][k] == a[i][(j+k)%n]:\n good2 = False\n break\n if good2:\n good = True\n break\n if not good:\n yes = False\n break\nif yes:\n print 'YES'\nelse:\n print 'NO'\n \n"}, {"source_code": "sc=True\nfor i in range(8):\n s=raw_input()\n if len(s.replace('WB',''))==0 or len(s.replace('BW',''))==0:\n sc=False\nif sc:print('YSE')\nelse:print('NO')"}, {"source_code": "sc=True\nfor i in range(8):\n s=raw_input()\n if s!='WBWBWBWB' and s!='BWBWBWBW':\n sc=False\n break\nif sc:print('YSE')\nelse:print('NO')"}, {"source_code": "for i in range(8):\n s=raw_input()\n if s!='WBWBWBWB' and s!='BWBWBWBW':\n print 'NO' \n print s\n exit()\nprint 'YES'"}, {"source_code": "a=[raw_input().split()]\nq=''\nfor s in a:\n if s!='WBWBWBWB' and s!='BWBWBWBW': q='NO' \nif q=='': q='YES'\nprint q"}, {"source_code": "for i in range(8):\n s=raw_input\n if s!='WBWBWBWB' and s!='BWBWBWBW':\n print 'NO' \n print s\n exit()\nprint 'YES'"}, {"source_code": "a=[raw_input().split()]\nq=''\nfor s in a:\n if s!='WBWBWBWB' or s!='BWBWBWBW': q='NO' \nif q=='': q='YES'\nprint q"}, {"source_code": "import sys\n\ndef judge(a, b):\n\tstr = a\n\tfor j in range(8):\n\t\tif str == b:\n\t\t\treturn True\n\t\tstr = str[1:] + str[0]\n\treturn False\n\nlines = []\nfor i in range(8):\n\tlines.append(sys.stdin.readline().strip())\n\nfor i in range(1,8):\n\tif not judge(lines[0], lines[i]):\n\t\tprint \"NO\"\n\t\tbreak\nelse:\n\tprint \"YES\"\n\n"}, {"source_code": "B = 0\nfor i in range(8):\n\tB += input().count('B')\nprint('YES' if B == 32 else 'NO')\n"}, {"source_code": "def checkvalid(u, d):\n for i in range(8):\n cnt = 0;\n for j in range(8):\n if u[j] != d[i+j]:\n cnt += 1\n if cnt == 8:\n return True\n return False \n\nu = input()\nd = input()\ncnt = 2\nisvalid = True\n\nisvalid = checkvalid(u, d+d)\nwhile cnt <= 7:\n cnt += 1\n u = d\n d = input()\n isvalid = isvalid and checkvalid(u, d+d)\nif isvalid:\n print('YES')\nelse:\n print('NO')\n "}, {"source_code": "chess = [input() for i in range(8)]\nfor c in chess:\n if 'WW' in c or 'BB' in c:\n print('NO')\n break\n else:\n continue\nprint('YES')\n"}, {"source_code": "final_ = 'Yes'\nfor i in range(8):\n\tcurrent_row = list(input())\n\tprint(current_row)\n\tcurrent_row.append(current_row[0])\n\tfor j in range(8):\n\t\tif current_row[j] == current_row[j+1]:\n\t\t\tfinal_ = 'NO'\nprint(final_)\n"}, {"source_code": "l=[]\nflag=1\nfor i in range(8):\n\tl.append(input())\n\tif(l[i].count('B')>4 or l[i].count('W')>4):\n\t\tflag=0\n\nif (not flag):print(\"NO\");exit();\nprint(\"YES\")\n"}, {"source_code": "def rotate(l, n=1):\n return l[n:] + l[:n]\n\ndef checkline(m):\n\tflag=True\n\tif a[m][0]!='W':\n\t\tflag=False\n\tfor i in range(2,8,2):\n\t\t# print a[m][i],a[m][i-1]\n\t\tif a[m][i]!='W' or a[m][i-1]!='B':\n\t\t\tflag = False\n\t# print flag\n\treturn flag\t\t\n\na=[]\nflag2=True\nfor i in range(8):\n\ta.append(list(raw_input()))\n# n=0\n\n\nfor i in range(8):\n\tn=0\n\tflag=False\n\twhile flag==False and n<8:\n\t\tn+=1\n\t\t# print n,a[i]\t\n\t\tif checkline(i)==False:\n\t\t\ta[i]=rotate(a[i])\n\t\t\t# print \"*\"\n\t\telse:\n\t\t\tflag=True\n\tif n==8 or flag==False:\n\t\tflag2=False\n\nif flag2==True:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n# for i in range(8):\t\n# \tprint a[i]"}, {"source_code": "def rotate(l, n=1):\n return l[n:] + l[:n]\n\ndef checkline(m):\n\tflag=True\n\tif a[m][0]!='W':\n\t\tflag=False\n\n\tif a[m][7]!='B':\n\t\tflag=False\t\n\tfor i in range(2,8,2):\n\t\t# print a[m][i],a[m][i-1]\n\t\tif a[m][i]!='W' or a[m][i-1]!='B':\n\t\t\tflag = False\n\t# print flag\n\treturn flag\t\t\n\na=[]\nflag2=True\nfor i in range(8):\n\ta.append(list(raw_input()))\n# n=0\n\n\nfor i in range(8):\n\tn=0\n\tflag=False\n\twhile flag==False and n<8:\n\t\tn+=1\n\t\tprint n,a[i]\t\n\t\tif checkline(i)==False:\n\t\t\ta[i]=rotate(a[i])\n\t\t\tprint \"*\"\n\t\telse:\n\t\t\tflag=True\n\tif n==8 or flag==False:\n\t\tflag2=False\n\nif flag2==True:\n\tprint 'YES'\nelse:\n\tprint 'NO'\n# for i in range(8):\t\n# \tprint a[i]"}], "src_uid": "ca65e023be092b2ce25599f52acc1a67"} {"nl": {"description": "John Doe has an n\u2009\u00d7\u2009m table. John Doe can paint points in some table cells, not more than one point in one table cell. John Doe wants to use such operations to make each square subtable of size n\u2009\u00d7\u2009n have exactly k points.John Doe wondered, how many distinct ways to fill the table with points are there, provided that the condition must hold. As this number can be rather large, John Doe asks to find its remainder after dividing by 1000000007 (109\u2009+\u20097).You should assume that John always paints a point exactly in the center of some cell. Two ways to fill a table are considered distinct, if there exists a table cell, that has a point in one way and doesn't have it in the other.", "input_spec": "A single line contains space-separated integers n, m, k (1\u2009\u2264\u2009n\u2009\u2264\u2009100;\u00a0n\u2009\u2264\u2009m\u2009\u2264\u20091018;\u00a00\u2009\u2264\u2009k\u2009\u2264\u2009n2) \u2014 the number of rows of the table, the number of columns of the table and the number of points each square must contain. Please, do not use the %lld specifier to read or write 64-bit integers in \u0421++. It is preferred to use the cin, cout streams or the %I64d specifier. ", "output_spec": "In a single line print a single integer \u2014 the remainder from dividing the described number of ways by 1000000007 (109\u2009+\u20097).", "sample_inputs": ["5 6 1"], "sample_outputs": ["45"], "notes": "NoteLet's consider the first test case: The gray area belongs to both 5\u2009\u00d7\u20095 squares. So, if it has one point, then there shouldn't be points in any other place. If one of the white areas has a point, then the other one also must have a point. Thus, there are about 20 variants, where the point lies in the gray area and 25 variants, where each of the white areas contains a point. Overall there are 45 variants."}, "positive_code": [{"source_code": "import sys\nrange = xrange\ninput = raw_input\n\nMOD = 10**9+7\n\nbig = 10**2 + 10\nmodinv = [1]*big\nfor i in range(2,big):\n modinv[i] = int((-(MOD//i)*modinv[MOD%i])%MOD)\n\nfac = [1]\nfor i in range(1,big):\n fac.append(int(fac[-1]*i%MOD))\n\ninvfac = [1]\nfor i in range(1,big):\n invfac.append(int(invfac[-1]*modinv[i]%MOD))\n\ndef choose(n,k):\n return int(fac[n]*invfac[k]*invfac[n-k]%MOD)\n\nn,m,k = [int(x) for x in input().split()]\n\ncount = [1 + (m - n - i + (n - 1))//n for i in range(n)]\ncount.insert(0, 0)\n\nDP = [[0]*(k + 1) for _ in range(n + 1)]\nDP[0][0] = 1\n\nfor i in range(1, n + 1):\n DPi = DP[i]\n DPim1 = DP[i - 1]\n \n for extra in range(min(n, k) + 1):\n c = pow(choose(n, extra), count[i], MOD)\n for j in range(k + 1 - extra):\n DPi[j + extra] = (DPi[j + extra] + int(DPim1[j] * c % MOD))%MOD\n\nprint DP[-1][-1]\n"}, {"source_code": "n,m,k=map(int,input().split())\nM=int(1e9+7)\n\nN=n*n\niv=[0]*(N+1)\niv[1]=1\nfor i in range(2, N+1):\n iv[i]=M-M//i*iv[M%i]%M\nf1=[1]*(N+1)\nfor i in range(1, N+1):\n f1[i]=f1[i-1]*i%M\nf2=[1]*(N+1)\nfor i in range(1, N+1):\n f2[i]=f2[i-1]*iv[i]%M\nleft=m%n\n#m/n+1, m/n\ndef powM(b, p):\n r=1\n while p>0:\n if p%2>0:\n r=r*b%M\n b=b*b%M\n p//=2\n return r\nc=[[powM(f1[n]*f2[j]%M*f2[n-j]%M, m//n+i) for j in range(n+1)] for i in range(2)]\n#print(c)\ndp=[[0]*(k+1) for i in range(n+1)]\ndp[0][0]=1\nfor i in range(n):\n for j in range(k+1):\n #prune\n if j>i*n or j i+1,j+l\n dp[i+1][j+l]=(dp[i+1][j+l]+c[i0:\n if p%2>0:\n r=r*b%M\n b=b*b%M\n p//=2\n return r\nc=[[powM(f1[n]*f2[j]%M*f2[n-j]%M, m//n+i) for j in range(n+1)] for i in range(2)]\n#print(c)\ndp=[[0]*(k+1) for i in range(n+1)]\ndp[0][0]=1\nfor i in range(n):\n for j in range(k+1):\n #prune\n if j>i*n or j i+1,j+l\n dp[i+1][j+l]=(dp[i+1][j+l]+c[ia.v\n def __lt__(self,a):\n return self.v a.val ()\n\tdef __lt__ (self, a):\n\t\treturn self.val () < a.val ()\n\tdef __and__ (self, a):\n\t\treturn MyInt (self.val () & a)\ns = ''.join (sys.stdin.readlines ())\ns = s.replace ('\\n', '')\ns = s.replace ('{', '')\ns = s.replace ('}', '')\ns = re.sub ('([0-9]+)', 'MyInt (\\\\1)', s)\ns = s.replace ('int f(int n)', \\\n 'a = [-1] * 32768\\ndef f (n):\\n\\tglobal a;' + \\\n 'n = MyInt (n);if (a[n.val ()] != -1) return a[n.val ()];')\ns = re.sub ('return(.*?);','return MyInt (\\\\1);', s)\ns = s.replace (';', '\\n\\t')\ns = s.replace ('return', ':return')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns = s.replace ('\\t:', '\\t')\ns = s.replace ('\\t ', '\\t')\ns += '\\n'\ns += 'k = -1\\n'\ns += 'for i in range (32768):\\n'\ns += '\\ta[i] = f (i).val () & 32767\\n'\n#s += 'for i in range (32768):\\n'\n#s += '\\tprint \\'%d: %d\\' % (i, a[i])\\n'\ns += 'for i in range (32768):\\n'\ns += '\\tif a[i] == n:\\n'\ns += '\\t\\tk = i\\n'\ns += 'print k\\n'\n#s += 'print n\\n'\ns = s.replace ('\\t\\n', '\\n')\n#print s\nexec s\n"}, {"source_code": "#!/usr/bin/python\nimport re, sys\nn = int (sys.stdin.readline ())\nclass MyInt (object):\n\tdef __init__ (self, a):\n\t\tif isinstance (a, MyInt):\n\t\t\tself.v = a.v\n\t\telse:\n\t\t\tself.v = int (a)\n\tdef val (self):\n\t\treturn self.v\n\tdef __add__ (self, a):\n\t\treturn MyInt ((self.val () + a.val ()) & 32767)\n\tdef __sub__ (self, a):\n\t\treturn MyInt ((self.val () - a.val ()) & 32767)\n\tdef __mul__ (self, a):\n\t\treturn MyInt ((self.val () * a.val ()) & 32767)\n\tdef __div__ (self, a):\n\t\treturn MyInt ((self.val () / a.val ()) & 32767)\n\tdef __eq__ (self, a):\n\t\treturn self.val () == a.val ()\n\tdef __gt__ (self, a):\n\t\treturn self.val () > a.val ()\n\tdef __lt__ (self, a):\n\t\treturn self.val () < a.val ()\n\tdef __and__ (self, a):\n\t\treturn MyInt (self.val () & a)\ns = ''.join (sys.stdin.readlines ())\ns = s.replace ('\\n', '')\ns = s.replace ('{', '')\ns = s.replace ('}', '')\ns = re.sub ('([0-9]+)', 'MyInt (\\\\1)', s)\ns = s.replace ('int f(int n)', \\\n 'a = [-1] * 32768\\ndef f (n):\\n\\tglobal a;' + \\\n 'n = MyInt (n);if (a[n.val ()] != -1) return a[n.val ()];')\ns = re.sub ('return(.*?);','return MyInt (\\\\1);', s)\ns = s.replace (';', '\\n\\t')\ns = s.replace ('return', ':return')\ns = re.sub ('\\t[ :]+', '\\t', s)\ns += '\\n'\ns += 'k = -1\\n'\ns += 'for i in range (32768):\\n'\ns += '\\ta[i] = f (i).val () & 32767\\n'\ns += 'for i in range (32768):\\n'\ns += '\\tif a[i] == n:\\n'\ns += '\\t\\tk = i\\n'\ns += 'print k\\n'\ns = s.replace ('\\t\\n', '\\n')\nexec s\n"}], "negative_code": [{"source_code": "#!/usr/bin/python\nimport sys\nn = int (sys.stdin.readline ())\ns = ''.join (sys.stdin.readlines ())\ns = s.replace ('\\n', '')\ns = s.replace ('{', '')\ns = s.replace ('}', '')\ns = s.replace ('int f(int n)', \\\n 'a = [-1] * 32768\\ndef f (n):\\n\\tglobal a;if (a[n] != -1) return a[n];')\ns = s.replace (';', '\\n\\t')\ns = s.replace ('return', ':return')\ns = s.replace ('\\t:', '\\t')\ns += '\\n'\ns += 'k = -1\\n'\ns += 'for i in range (32768):\\n'\ns += '\\ta[i] = f (i) & 32767\\n'\n#s += 'for i in range (32768):\\n'\n#s += '\\tprint \\'%d: %d\\' % (i, a[i])\\n'\ns += 'for i in range (32768):\\n'\ns += '\\tif a[i] == n:\\n'\ns += '\\t\\tk = i\\n'\ns += 'print k\\n'\n#s += 'print n\\n'\ns = s.replace ('\\t\\n', '\\n')\n#print s\nexec s\n"}], "src_uid": "698c5a87f9adbe6af60d9f70519c9672"} {"nl": {"description": "In a very ancient country the following game was popular. Two people play the game. Initially first player writes a string s1, consisting of exactly nine digits and representing a number that does not exceed a. After that second player looks at s1 and writes a string s2, consisting of exactly nine digits and representing a number that does not exceed b. Here a and b are some given constants, s1 and s2 are chosen by the players. The strings are allowed to contain leading zeroes.If a number obtained by the concatenation (joining together) of strings s1 and s2 is divisible by mod, then the second player wins. Otherwise the first player wins. You are given numbers a, b, mod. Your task is to determine who wins if both players play in the optimal manner. If the first player wins, you are also required to find the lexicographically minimum winning move.", "input_spec": "The first line contains three integers a, b, mod (0\u2009\u2264\u2009a,\u2009b\u2009\u2264\u2009109, 1\u2009\u2264\u2009mod\u2009\u2264\u2009107).", "output_spec": "If the first player wins, print \"1\" and the lexicographically minimum string s1 he has to write to win. If the second player wins, print the single number \"2\".", "sample_inputs": ["1 10 7", "4 0 9"], "sample_outputs": ["2", "1 000000001"], "notes": "NoteThe lexical comparison of strings is performed by the < operator in modern programming languages. String x is lexicographically less than string y if exists such i (1\u2009\u2264\u2009i\u2009\u2264\u20099), that xi\u2009<\u2009yi, and for any j (1\u2009\u2264\u2009j\u2009<\u2009i) xj\u2009=\u2009yj. These strings always have length 9."}, "positive_code": [{"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if s == 0: break\n if s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\ndef test():\n pass\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if s == 0: break\n if s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if s == 0: break\n if s and s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\ndef test():\n pass\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if not s: break\n if s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\ndef test():\n pass\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "#!/usr/bin/env python\n\"\"\"(c) gorlum0 [at] gmail.com\"\"\"\nimport itertools as it\nfrom sys import stdin\n\ndef solve(a, b, mod):\n if b >= mod: return 2\n\n m = 10**9 % mod\n s = 0\n for i in xrange(1, a+1):\n s += m\n if s >= mod: s -= mod\n if not s: break\n if s + b < mod:\n return 1, i\n return 2\n\ndef main():\n for l in stdin:\n a, b, mod = map(int, l.split())\n winner = solve(a, b, mod)\n if winner == 2:\n print 2\n else:\n print 1, '%09d' % winner[1]\n\nif __name__ == '__main__':\n main()\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\na,b,mod = mints()\nz = (10**9)%mod\nc = 0\nfor i in range(min(a+1,mod)):\n\tif c != 0 and mod-c > b:\n\t\ts = str(i)\n\t\ts = '0'*(9-len(s))+s\n\t\tprint(1, s)\n\t\texit(0)\n\tc += z\n\tif c >= mod:\n\t\tc -= mod\nprint(2)"}, {"source_code": "a,b,m=map(int,input().split())\nk=s=(10**9)%m\ni=0\nwhile k and i=m:k-=m\nprint(2)"}, {"source_code": "a, b, m = map(int, input().split())\nk = s = 10 ** 9 % m\ni = 0\nwhile k and i < a:\n i += 1\n if k < m - b: exit(print(1, str(i).zfill(9)))\n k += s\n if k >= m: k -= m\nprint(2)"}, {"source_code": "a, b, m = map(int, input().split())\nk = s = 10 ** 9 % m\ni = 0\nwhile k and i < a:\n i += 1\n if k < m - b: exit(print(1, str(i).zfill(9)))\n k += s\n if k >= m: k -= m\nprint(2)"}, {"source_code": "a, b, m = map(int, input().split())\nc = (10 ** 9) % m\nans = -1\nfor x in range(1, min(a + 1, m)):\n z = (x * c) % m\n if z == 0:\n continue\n if z + b < m:\n ans = x\n break\nif ans == -1:\n print(2)\nelse:\n s = str(ans)\n s = ('0' * 9 + s)[-9:]\n print(1, s)\n"}], "negative_code": [{"source_code": "a, b, m = map(int, input().split())\nt = [0] * m\ns = 10 ** 9 % m\nfor i in range(a):\n k = i * s % m\n if 0 < k < m - b: exit(print(1, str(i).zfill(9)))\n if t[k]: break\n t[k] = 1\nprint(2)"}], "src_uid": "8b6f633802293202531264446d33fee5"} {"nl": {"description": "One rainy gloomy evening when all modules hid in the nearby cafes to drink hot energetic cocktails, the Hexadecimal virus decided to fly over the Mainframe to look for a Great Idea. And she has found one!Why not make her own Codeforces, with blackjack and other really cool stuff? Many people will surely be willing to visit this splendid shrine of high culture.In Mainframe a standard pack of 52 cards is used to play blackjack. The pack contains cards of 13 values: 2, 3, 4, 5, 6, 7, 8, 9, 10, jacks, queens, kings and aces. Each value also exists in one of four suits: hearts, diamonds, clubs and spades. Also, each card earns some value in points assigned to it: cards with value from two to ten earn from 2 to 10 points, correspondingly. An ace can either earn 1 or 11, whatever the player wishes. The picture cards (king, queen and jack) earn 10 points. The number of points a card earns does not depend on the suit. The rules of the game are very simple. The player gets two cards, if the sum of points of those cards equals n, then the player wins, otherwise the player loses.The player has already got the first card, it's the queen of spades. To evaluate chances for victory, you should determine how many ways there are to get the second card so that the sum of points exactly equals n.", "input_spec": "The only line contains n (1\u2009\u2264\u2009n\u2009\u2264\u200925) \u2014 the required sum of points.", "output_spec": "Print the numbers of ways to get the second card in the required way if the first card is the queen of spades.", "sample_inputs": ["12", "20", "10"], "sample_outputs": ["4", "15", "0"], "notes": "NoteIn the first sample only four two's of different suits can earn the required sum of points.In the second sample we can use all tens, jacks, queens and kings; overall it's 15 cards, as the queen of spades (as any other card) is only present once in the pack of cards and it's already in use.In the third sample there is no card, that would add a zero to the current ten points."}, "positive_code": [{"source_code": "n=int(input())\nn-=10\nif(n<=0 or n>11):\n print(0)\nelif(n==10):\n print(15)\nelse:\n print(4)"}, {"source_code": "n = input()\nreq = n - 10\nans =0\nif req <= 0:\n\tpass\nelse:\n\tif req <= 9 or req == 11:\n\t\tans = 4\n\tif req == 10:\n\t\tans = 15\nprint ans\n"}, {"source_code": "n = input()\nvar = [(1,4),(2,4),(3,4),(4,4),(5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(10,4),(10,3),(10,4),(11,4)]\nn-=10\nans = 0\nif n>0:\n\tfor x in var:\n\t\tif n-x[0]==0:\n\t\t\tans+=x[1]\nprint ans\t\n"}, {"source_code": "n = input()\nif n <= 10:\n print 0\nelif n == 20:\n print 15\nelif n >= 22:\n print 0\nelse:\n print 4"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",\"r\")\nn=int(input())\nif n<=10 or n>=22:\n\tprint(0)\nelif n==20:\n\tprint(15)\nelse:\n\tprint(4)"}, {"source_code": "n=int(input())\nif 10 11:\n print(0)\n exit()\nif N == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "n=int(input())\nn-=10\nA=[1,2, 3, 4, 5, 6, 7, 8, 9,10,10,10,10,11,1,2, 3, 4, 5, 6, 7, 8, 9, 10,10,10,10,11,1,2, 3, 4, 5, 6, 7, 8, 9, 10,10 ,10 ,11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,10,10,10,11]\nprint(A.count(n))"}, {"source_code": "n=int(input())\nx=n-10\nif x<=0 or x>11:\n print(\"0\")\nelif((x>=1 and x<=9) or x==11):\n print(\"4\")\nelse:\n print(\"15\") "}, {"source_code": "inputs = int(input())\ninputs-=10\nanswer = \"0\"\nif (inputs > 0 and inputs < 10) or inputs==11:\n answer = \"4\"\nelif inputs == 10:\n answer = \"15\"\nprint(answer)"}, {"source_code": "d={0:0,1:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:15,11:4}\nx=int(input())\nif x>=10:\n x=x-10\n if x<=11:\n print(d[x])\n else:\n print(0)\nelse:\n print(0)\n \n"}, {"source_code": "n=int(input())\nli={}\nli[10]=15\ncard=n-10\nif card<=0:\n print(0)\nelif card>11:\n print(0)\nelif card==10:\n print(15)\nelse:\n print(4)"}, {"source_code": "x=int(input())\nif x<=10:\n print(0)\n exit()\nx-=10\np=[2,3,4,5,6,7,8,9,10,11,1,10,10,10]\nk=p.count(x)\nif x==10:\n k-=1\n print((k*4)+3)\nelse:print(k*4)"}, {"source_code": "#!/usr/bin\nn = int(raw_input())\nif n <= 10 or n > 21:\n print 0\nelif n == 20:\n print 15\nelse: print 4"}, {"source_code": "n=int(input())\nn-=10\nif(n<=0 or n>11):\n print(0)\nelif(n==10):\n print(15)\nelse:\n print(4)"}, {"source_code": "n=int(input())\nif (n-10)<=0 or n>=22:\n\tprint(0)\nelif 1<=(n-10)<=11 and n!=20:\n\tprint(4)\nelif n==20:\n\tprint(15)"}, {"source_code": "n = int(input())\nif n <= 10 or n > 21:\n print(0)\nelif n == 21 or n == 11:\n print(4)\nelif n == 20:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "n = int(input())\nd = {0: 0, 1: 4, 2: 4, 3: 4, 4: 4, 5: 4, 6: 4, 7: 4, 8: 4, 9: 4, 10: 15,\n 11: 4}\nif n - 10 in d:\n print(d[n - 10])\nelse:\n print(0)"}, {"source_code": "import sys\n\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\n\nn = int(input())\nn -= 10\nif 1 < n < 10:\n print(4)\nelif n == 1 or n == 11:\n print(4)\nelif n == 10:\n print(15)\nelse:\n print(0)"}, {"source_code": "s=int(input())\nl=[1,2,3,4,5,6,7,8,9,11]\nx=s-10\nif x in l:\n y=4\nelif x==10:\n y=15\nelse:\n y=0\nprint(y)"}, {"source_code": "\n#!/usr/bin/env python\nn = input()\nif n <= 10:\n print 0\nelif n == 20:\n print 15\nelif n >= 22:\n print 0\nelse:\n print 4"}, {"source_code": "N=input()-10\nif N>=1 and N<=11:\n\tif N==10:\n\t\tprint 15\n\telse:\n\t\tprint 4\nelse:\n\tprint 0\n"}, {"source_code": "n = int(input())\nd = {0: 0, 1: 4, 2: 4, 3: 4, 4: 4, 5: 4, 6: 4, 7: 4, 8: 4, 9: 4, 10: 15,\n 11: 4}\nif n - 10 in d:\n print(d[n - 10])\nelse:\n print(0)"}, {"source_code": "n = input()\nr = n - 10\nif r>=1 and r<=11:\n\tif r==10:\n\t\tprint 15\n\telse:\n\t\tprint 4\nelse:\n\tprint 0"}, {"source_code": "def solve(n):\n d = n-10\n if d <= 0 or d > 11: return 0\n if d > 0 and d < 10: return 4\n if d == 11: return 4\n if d == 10: return 15\n\nprint solve(int(raw_input()))\n\n"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys\nif __name__ == '__main__':\n\n num = map(int,sys.stdin.readline().split())\n n = num[0]\n dic={0:0,1:15,2:4}\n if n <11 or n>21:\n print dic[0]\n elif n == 20:\n print dic[1]\n else:\n print dic[2]\n"}, {"source_code": "def solve():\n num = int(raw_input())\n if(num>21) or num<=10:\n print 0\n return\n if(num == 20):\n print 15\n else:\n print 4\n\nsolve()\n"}, {"source_code": "import sys\n\nn = int(input())\n\nneeded = n - 10\n\nif needed <= 0:\n print(0)\n sys.exit(0)\n\nif needed == 1 or (needed >= 2 and needed <= 9) or needed == 11:\n print(4)\nelif needed == 10:\n print(15)\nelse:\n print(0)\n\n\n"}, {"source_code": "n=int(input())\nif 11<=n<=19:\n print(4)\nelif n==20:\n print(15)\nelif n==21:\n print(4)\nelse:\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"}, {"source_code": "n=int(input())\nn=n-10\nif n>11 or n<1:\n print(0)\nelse:\n if n>=2 and n<10:\n print(4)\n elif n==10:\n print(15)\n elif n==1 or n==11:\n print(4)\n \n "}, {"source_code": "n=input()\nprint(1011:\n print 0\nelse:\n print 4\n "}, {"source_code": "n = input()\nvar = [(1,4),(2,4),(3,4),(4,4),(5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(10,4),(10,3),(10,4),(11,4)]\nn-=10\nans = 0\nif n>0:\n\tfor x in var:\n\t\tif n-x[0]==0:\n\t\t\tans+=x[1]\nprint ans\t\n"}, {"source_code": "n=int(raw_input())\nn-=10\nif n>11:\n print 0\nelif n==11 or n==1:\n print 4\nelif n==10:\n print 15\nelif n<=0:\n print 0\nelse:\n print 4"}, {"source_code": "n=int(input())\nleft = n-10\nif left==10:\n print(15)\nelif left==0 or n<10 or left>11:\n print(0)\nelse:\n print(4)"}, {"source_code": "n = input()\n\nif n-10 > 0 and n-10 < 10:\n print 4\nelif (n-10) == 10:\n print 15\nelif (n-10) == 11:\n print 4\nelse:\n print 0"}, {"source_code": "\na = [1,2,3,4,5,6,7,8,9,10,11]\nn = int(input())-10\nif n==10:\n\tprint (15)\nelif n==0:\n\tprint (0)\nelif n>=1 and n<=11:\n\tprint (4)\nelse:\n\tprint (0)"}, {"source_code": "dic = {1:4,11:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:15}\nn = int(input())\nif n<=10 or n>=22:\n print(0)\n exit()\nprint(dic[n-10])"}, {"source_code": "n = int(input())\nn -= 10\nif (n < 10 or n == 11) and n >= 1:\n print (4)\nelif n < 1 or n > 11:\n print (0)\nelse:\n print (15)"}, {"source_code": "dic = {1:4,11:4,2:4,3:4,4:4,5:4,6:4,7:4,8:4,9:4,10:15}\nn = int(input())\nif n<=10 or n>=22:\n print(0)\n exit()\nprint(dic[n-10])"}, {"source_code": "class CodeforcesTask104ASolution:\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 deck = [[x, x, x, x] for x in range(1, 12)]\n deck.append([10 for x in range(11)])\n mdeck = []\n for d in deck:\n mdeck += d\n self.result = str(mdeck.count(self.n - 10))\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask104ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "n = int(input())\nif(n<=10 or n>21):\n print(0)\n exit(0)\nx = n-10\nif(x==10):\n print(15)\nelse:\n print(4)"}, {"source_code": "n=int(raw_input())\nif n<=10:\n\tprint 0\nelif n==11:\n\tprint 4\nelif n<=19:\n\tprint 4\nelif n==20:\n\tprint 15\nelif n==21:\n\tprint 4\nelse:\n\tprint 0\n"}, {"source_code": "t = input()\nif(t<=10):\n\tprint 0\nelse:\n\tif(t>=11 and t<=19):\n\t\tprint 4\n\telif(t==20):\n\t\tprint 15\n\telif(t==21):\n\t\tprint 4\n\telse:\n\t \tprint 0\n"}, {"source_code": "n = int(input())\nlist = [1,2,3,4,5,6,7,8,9,10,10,10,10,11]\ncnt = 0\nfor i in range(len(list)):\n if list[i] == n-10:\n cnt+=1\nres = cnt * 4\nif n-10 == 10:\n res -= 1\nprint(res)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nn = input()\nif n <= 10:\n print 0\nelif n == 20:\n print 15\nelif n >= 22:\n print 0\nelse:\n print 4"}, {"source_code": "a=int(input())\nd=a-10\nif(a==20 and d==10):\n print('15')\nelif(d==10):\n print('3')\nelif(d==0 or d>11 or d<1):\n print('0')\nelse:\n print('4')"}, {"source_code": "n = input()\nvar = [(1,4),(2,4),(3,4),(4,4),(5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(10,4),(10,3),(10,4),(11,4)]\nn-=10\nans = 0\nif n>0:\n\tfor x in var:\n\t\tif n-x[0]==0:\n\t\t\tans+=x[1]\nprint ans\t\n"}, {"source_code": "def solve(n):\n d = n-10\n if d <= 0 or d > 11: return 0\n if d > 0 and d < 10: return 4\n if d == 11: return 4\n if d == 10: return 15\n\nprint solve(int(raw_input()))\n\n"}, {"source_code": "print [0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,15,4,0,0,0,0,0,0][int(raw_input())]"}, {"source_code": "n=int(input())\nif n<=10 or n>=22:\n print(0)\nelse:\n x=n-10\n if x==1 or x==2 or x==3 or x==4 or x==4 or x==5 or x==6 or x==7 or x==8 or x==9 or x==11:\n print(4)\n elif x==10:\n print(15)\n elif x==12 or x==13 or x==14 or x==15:\n print(19)\n \n"}, {"source_code": "import sys\n\nn = int(sys.stdin.readline().strip())\n\nif n <= 10 or n > 21:\n print(0)\nelif n == 20:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "\nx = input() - 10\nprint (0,4,15)[(x > 0 and x <= 11) + (x == 10)]\n"}, {"source_code": "n = int(raw_input())\nn -= 10\nif n == 10:\n print 15\nelif n in range(1, 12):\n print 4\nelse:\n print 0\n"}, {"source_code": "n=int(input())-10;print(0if n<1 or n>11 else 4 if n!=10 else 15)"}, {"source_code": "s=int(input())\nif s==10:\n\tprint(0)\nelif s in range(11,20):\n\tprint(4)\nelif s==20:\n\tprint(15)\nelif s==21:\n\tprint(4)\nelse:\n\tprint(0)"}, {"source_code": "n = int(input())\nc = n - 10\nif c == 10:\n print(15)\n exit()\nelif c > 11 or c <= 0:\n print(0)\nelse:\n print(4)"}, {"source_code": "for _ in range(1):\n n=int(input())\n if n==11 or n==21:\n print(4)\n elif n==20:\n print(15)\n elif 12<=n<=19:\n print(4)\n else: \n print(0)"}, {"source_code": "import pdb\nimport math\nR = lambda: map(int, raw_input().split())\n\nn = input()\nif n <= 10:\n print 0\nelse:\n re = n - 10\n if re >11:\n print 0\n else:\n if re == 10:\n print 15\n else:\n print 4\n"}, {"source_code": "n = int(input())\nif 10 >= n or n > 21:\n answer = 0\nelif 10 < n <= 19 or n == 21:\n answer = 4\nelif n == 20:\n answer = 15\nprint(answer)"}, {"source_code": "n=input()\na=([0]*11)+([4]*9)\na+=[15]+[4]+([0]*4)\nprint a[n]\n"}, {"source_code": "target = int(raw_input())\ndiff = target - 10\nif diff < 1 or diff > 11:\n print 0\nelse:\n if diff == 10:\n print 15\n else:\n print 4"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nn = input()\nif n <= 10:\n print 0\nelif n == 20:\n print 15\nelif n >= 22:\n print 0\nelse:\n print 4"}, {"source_code": "\ndef run():\n needed = int(raw_input()) - 10\n if needed <= 0 or needed > 11:\n print 0\n return\n available = [4]*12\n available[0] = 0\n available[10] = 15 #d,k,v\n #print available\n print available[needed]\n \n\n\nif __name__ == '__main__':\n run()\n"}, {"source_code": "print [0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,15,4,0,0,0,0,0,0][int(raw_input())]"}, {"source_code": "n=int(raw_input())\nif n<=10:\n print '0'\nelse:\n if (n<20):\n print '4'\n else:\n if n==20:\n print '15'\n else:\n if n==21:\n print '4'\n else:\n print '0'\n"}, {"source_code": "n = int(input())\nn -= 10\nif (n < 10 or n == 11) and n >= 1:\n print (4)\nelif n < 1 or n > 11:\n print (0)\nelse:\n print (15)"}, {"source_code": "n = int(input()) - 10\nif n == 1 or n == 11:\n print(4)\nelif n > 1 and n < 10:\n print(4)\nelif n == 10:\n print(15)\nelse:\n print(0)"}, {"source_code": "n=int(input())\nif(n<=10 or n>21):\n print('0')\nelse:\n t=n-10\n if(t==10):\n print('15')\n else:\n print('4')\n"}, {"source_code": "#!/usr/bin/env python\n# Codeforce 104A\n\nimport sys\nn = int(sys.stdin.readline())\nneed = n-10\nif need < 1 or need > 11:\n chance = 0\nelif need == 10:\n chance = 15\nelse:\n chance = 4\nprint chance\n"}, {"source_code": "n=input()\na=([0]*11)+([4]*9)\na+=[15]+[4]+([0]*4)\nprint a[n]\n"}, {"source_code": "n = input()\na = n-10\nif 0=1 and n<=9):\n print(4)\nelif(n==10):\n print(15)\nelif(n==11):\n print(4)\nelse:\n print(0)"}, {"source_code": "#! /usr/bin/env python\nn=int(raw_input())\nif n<=10 or n>21:\n print 0\nelse:\n if n==20:\n print 15\n else:\n print 4\n"}, {"source_code": "n=int(input())\nif n>21:\n print(\"0\")\nelif n<11:\n print(\"0\")\nelif n==11:\n print(\"4\")\nelif n==20:\n print(\"15\")\nelse:\n print(\"4\")\n"}, {"source_code": "n=int(input())\nif n>10 and n<22:\n if n==20:\n print(15)\n else:\n print(4)\nelse:\n print(0)"}, {"source_code": "n=int(input())\nif n<=10:\n print(0)\nelse:\n n=n-10\n if n==15 or n>11:\n print(0)\n elif n==10:\n print(15)\n else:\n print(4)"}, {"source_code": "n = int(input())\nif n <= 10:\n print(0)\nelif n == 20:\n print(15)\nelif n > 21:\n print(0)\nelse:\n print(4)"}, {"source_code": "n = int(input())\ntarget = n - 10\nif target >= 1 and target <= 9 or target == 11:\n print(4)\nelif target == 10:\n print(15)\nelse:\n print(0)"}, {"source_code": "n=int(input())\nif 11<=n<=19:\n print(4)\nelif n==20:\n print(15)\nelif n==21:\n print(4)\nelse:\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"}, {"source_code": "\na = [1,2,3,4,5,6,7,8,9,10,11]\nn = int(input())-10\nif n==10:\n\tprint (15)\nelif n==0:\n\tprint (0)\nelif n>=1 and n<=11:\n\tprint (4)\nelse:\n\tprint (0)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nn = input()\nif n <= 10:\n print 0\nelif n == 20:\n print 15\nelif n >= 22:\n print 0\nelse:\n print 4"}, {"source_code": "sults = 4\ncards = [0]\nfor i in xrange(0, 12):\n\tcards.append(sults)\ncards[10] += sults * 3 - 1\n\nn = int(raw_input())\nfirst = 10\nsecond = n - first\nif (second < 0) or (second > 11):\n\tprint 0\nelse:\n\tprint cards[second]\n\t\n\n"}, {"source_code": "dic = dict()\nfor i in range(1,10):\n dic[i]=4\ndic[10]=15\ndic[11]=4\ndif = int(input())-10\nprint(dic.get(dif,0))"}, {"source_code": "n = int(input())-10\nif n <=0 or n>11:print(0)\nelif n ==11 or n <10:print(4)\nelif n==10:print(15)\n"}, {"source_code": "n=int(input())\nn-=10\nif(n<=0 or n>11):\n print(0)\nelif(n==10):\n print(15)\nelse:\n print(4)"}, {"source_code": "n = input()\nvar = [(1,4),(2,4),(3,4),(4,4),(5,4),(6,4),(7,4),(8,4),(9,4),(10,4),(10,4),(10,3),(10,4),(11,4)]\nn-=10\nans = 0\nif n>0:\n\tfor x in var:\n\t\tif n-x[0]==0:\n\t\t\tans+=x[1]\nprint ans\t\n"}, {"source_code": "n = int(input())\nlist = [1,2,3,4,5,6,7,8,9,10,10,10,10,11]\ncnt = 0\nfor i in range(len(list)):\n if list[i] == n-10:\n cnt+=1\nres = cnt * 4\nif n-10 == 10:\n res -= 1\nprint(res)"}, {"source_code": "\ndef run():\n needed = int(raw_input()) - 10\n if needed <= 0 or needed > 11:\n print 0\n return\n available = [4]*12\n available[0] = 0\n available[10] = 15 #d,k,v\n #print available\n print available[needed]\n \n\n\nif __name__ == '__main__':\n run()\n"}, {"source_code": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 8 16:09:29 2020\n\n@author: anirudhasarmatumuluri\n\"\"\"\n\ndef main():\n n = int(input())\n if n<=10 or n>21:\n print(0)\n return\n if n==21:\n print(4)\n return\n if n==20:\n print(15)\n return\n\n else:\n print(4)\n \n return\n\n\n\n\nmain()"}, {"source_code": "n=int(input())\nif(n<=10 or n>21):\n\tprint(0)\nelse:\n\tdiff=n-10\n\tif(diff==10):\n\t\tprint(15)\n\telse:\n\t\tprint(4)"}, {"source_code": "n=int(input())\nn=n-10\nif n==0:\n print(0)\nelif n>0 and n<=9:\n print(4)\nelif n==10:\n print(15)\nelif n==11:\n print(4)\nelse:\n print(0)"}, {"source_code": "n = int(input())\nn-=10\nans=0\nif (n<10 and n>0) or n==11:\n\tans=4\nelif n==10:\n\tans=15\nprint(ans)\n"}, {"source_code": "def solve(n):\n if n == 20:\n return 15\n if n == 10:\n return 0\n elif n<=21 and n>10:\n return 4\n else:\n return 0\nn = int(input())\nprint(solve(n))"}, {"source_code": "n=int(input())\nx=n-10\nif x<=0 or x>11:\n print(\"0\")\nelif((x>=1 and x<=9) or x==11):\n print(\"4\")\nelse:\n print(\"15\") "}, {"source_code": "import math\n\n\ndef main():\n n = int(input())\n left = n - 10\n res = {}\n if left < 1 or left > 11:\n print(0)\n else:\n if 1 <= left <= 9 or left == 11:\n print(4)\n elif left == 10:\n print(15)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "f=lambda:map(int,input().split())\nn=int(input())\nif 0 11:\n print(0)\n elif n < 10 or n == 11:\n print(4)\n else:\n print(15)\n return\n\nmain()\n "}, {"source_code": "n = int(input())\nls1 = [2, 3]\nls = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,4 ,4 ,5 ,5 ,5, 5, 10, 10, 10, 6, 6, 6, 6,7 ,7, 7, 7, 8 ,8, 8, 8, 9 ,9, 9,9 ,10, 10,10, 10,10, 10,10, 10,10, 10,10, 10, 11, 11, 11, 11]\n#print(len(ls))\ncount = 0\nfor card in ls:\n if card+10 == n:\n count += 1\nprint(count)\n"}], "negative_code": [{"source_code": "\nk = 10\nn = int(input())\nsu = n - k\nif (su <= 0) or (12 <= su <= 15):\n print (0)\nelif (su == 10):\n print (11)\nelse:\n print (4)"}, {"source_code": "n=int(input())\na=n-10\nif 1<=a<=9:\n print('4')\nelif a==10:\n print('15') #4 ten, 4 korol, 4 valeta, 3 dami\nelse:\n print('0')\n"}, {"source_code": "d={2:4, 3:4, 5:4, 6:4, 7:4, 8:4, 9:4, 10:15}\ns = int(raw_input()) - 10\nprint( sum(x[1] for x in d.items() if s == x[0]) )\n"}, {"source_code": "n = int(input())\n\ntmp = abs(10-n)\n\nif tmp == 0 or n > 20 or n <= 10:\n print(0)\nelif tmp < 10:\n print(4)\nelse: print(15)\n"}, {"source_code": "n=int(input())\nn-=10\nif n<10:print(4)\nelif n==10:print(15)\nelif n==11:print(4)\nelse:print(0)"}, {"source_code": "n = int(input())\nn -= 10\nif (n < 10 or n==1 or n == 11) and n > 1:\n print (4)\nelif n < 1 or n > 11:\n print (0)\nelse:\n print (15)"}, {"source_code": "n = int(raw_input())\n\nn -= 10\n\na = range(16)\na[0] = 0\na[1] = 4\na[2] = 4\na[3] = 4\na[4] = 4\na[5] = 4\na[6] = 4\na[7] = 4\na[8] = 4\na[9] = 4\na[10] = 15\na[1] = 4\na[12] = 0\na[13] = 0\na[14] = 0\na[15] = 0\n\nprint a[n]\n"}, {"source_code": "n=int(input())\nif n<=10 or n>=21:\n print(0)\nelse:\n x=n-10\n if x==1 or x==2 or x==3 or x==4 or x==4 or x==5 or x==6 or x==7 or x==8 or x==9 or x==11:\n print(4)\n elif x==10:\n print(15)\n elif x==12 or x==13 or x==14 or x==15:\n print(19)\n \n"}, {"source_code": "#!/usr/bin/python3\nn = int(input())\nn-=10\nif n <= 0 or n > 10:\n print(0)\nelif n < 10:\n print(4)\nelif n == 10:\n print(15)"}, {"source_code": "N = int(input()) - 10\nCounter = 0\nif N == 0 and N>11:\n print(0)\n exit()\nif N == 10:\n print(15)\nelse:\n print(4)\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--------------------------------#\nn = get_int()\nif n <= 10:\n print(0)\nelse:\n diff = n-10\n if diff == 11:\n print(4)\n elif diff == 1:\n print(8)\n elif diff <= 9:\n print(4)\n elif diff == 10:\n print(15) \n elif diff > 11:\n print(0)"}, {"source_code": "n=int(input())\nleft = n-10\nif left==10:\n print(15)\nelif left==0 or left>11:\n print(0)\nelse:\n print(4)\n"}, {"source_code": "n=int(input())\nn=n-10\nif n==0:\n print(0)\nelse:\n if n>=2 and n<10:\n print(4)\n elif n==10:\n print(15)\n elif n==1 or n==11:\n print(4)\n \n "}, {"source_code": "n=int(input())\nx=n-10\nif x==0:\n print(\"0\")\nelif x==1 or x==11:\n print(\"4\")\nelif(x>=2 and x<=9):\n print(\"4\")\nelse:\n print(\"15\") "}, {"source_code": "# -*- coding: cp932 -*-\n\n#\u001b$BF~NO$7$?$b$N$rBeF~\u001b(B\ninput_str = raw_input()\ninput_num = int(input_str)\n\nif(input_num >= 10 and input_num <= 19):\n\tprint 4\nelif(input_num == 20):\n\tprint 15\nelif(input_num == 21):\n\tprint 4\nelse:\n\tprint 0\n"}, {"source_code": "n=int(raw_input())\nif n<=10:\n\tprint 0\nelif n==11:\n\tprint 8\nelif n<=19:\n\tprint 4\nelif n==20:\n\tprint 15\nelif n==21:\n\tprint 4\nelse:\n\tprint 0\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nn = input()\nif n <= 10:\n print 2\nelif n == 20:\n print 15\nelif n >= 22:\n print 0\nelse:\n print 4"}, {"source_code": "n=int(input())\nr=n-10\nif(r==10):\n print(15)\nelif(r==0):\n print(0)\nelse:\n print(4)\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nN=int(input())\nX=N-10\nif X>=1 and X<=9:\n\tprint(4)\nelif X==10:\n\tprint(15)\nelif X==11:\n\tprint(8)\nelif X==0:\n\tprint(0)\nelse:\n\tprint(0)\n\n\n\n\n"}, {"source_code": "n = int(raw_input()) - 10\nif n == 10: print 15\nelif n > 0 & n < 12: print 4\nelse: print 0\n"}, {"source_code": "a = int(input())\n\nif a <= 10:\n\tprint(0)\nelse:\n\tif a == 20:\n\t\tprint(15)\n\telse:\n\t\tprint(4)\n"}, {"source_code": "N = int(input()) - 10\nCounter = 0\nif N == 0 and N>11:\n print(0)\n exit()\nif N == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "n = int(input())\nkartu = 10\npowarray = [1,2,3,4,5,6,7,8,9,11]\nfor i in range(len(powarray)):\n if(kartu + powarray[i]==n):\n print(\"4\")\nif(kartu + 10==n):\n print(\"15\")\nelif(n==10 or n>21):\n print(\"0\")\n"}, {"source_code": "n = int(input())\nneed = n-10\nif need == 0 or n>21:\n print(0)\nelif need == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "n = int(raw_input())\nn -= 10\nif n == 11:\n print 1\nelif n == 10:\n print 15\nelif n in range(1, 10):\n print 4\nelse:\n print 0\n"}, {"source_code": "n=int(raw_input())\n\n\nn=n-10\n\n\nif n==0 or n>10 or n<10:\n print 0\n exit(0)\nif n==10:\n print 15\n exit(0)\nprint 4\n"}, {"source_code": "n = int(input())\nr = n-10\nif r<=0:\n print(0)\nelif r==10:\n print(15)\nelif r in range(1,21):\n print(4)\nelse:\n print(0)"}, {"source_code": "a = int(input())\n\nif a <= 10 or a > 20:\n\tprint(0)\nelse:\n\tif a == 20:\n\t\tprint(15)\n\telse:\n\t\tprint(4)\n"}, {"source_code": "n = raw_input()\nif n <= 10 or n>=22:\n print (\"0\")\nelse:\n if n == 20:\n print(\"15\")\n else:\n print(\"4\")\n"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Feb 22 14:50:02 2020\n\n@author: Lenovo\n\"\"\"\n\n\n#https://codeforces.com/problemset/problem/104/A\n\ndef black_jack():\n card = int(input())\n \n needed = card - 10\n \n if needed >= 1 and needed <= 9:\n print(4)\n return\n elif needed == 11:\n print(1)\n return\n elif needed == 10:\n print(15)\n return\n elif needed == 0 or needed > 11 or needed <= 0:\n print(0)\n return\n \nblack_jack()\n "}, {"source_code": "N = int(input()) - 10\nCounter = 0\nif N == 0 or N>11:\n print(0)\n exit()\nif N == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "from sys import stdin, stdout\ndef stdinhack():\n for line in stdin: yield line\nnext_line = lambda: next(stdinhack()).split()\nwrite = lambda x : stdout.write(x)\n\ndef solve ():\n n = int(next_line()[0])\n a = [1,2,3,4,5,6,7,8,9,10,10,10,10]\n ans = 0\n for k in a:\n if(10+k==n): ans+=1\n for k in a:\n if(10+k==n): ans+=1\n for k in a:\n if(10+k==n): ans+=1\n for k in a[:-1]:\n if(10+k==n): ans+=1\n print(ans)\n return\n\nif __name__ == '__main__':\n solve()\n\n"}, {"source_code": "# cook your dish here\nfrom sys import stdin, stdout\nimport math\nfrom itertools import permutations, combinations\nfrom collections import defaultdict\n\ndef L():\n return list(map(int, stdin.readline().split()))\n\ndef In():\n return map(int, stdin.readline().split())\n\ndef I():\n return int(stdin.readline())\n\nP = 1000000007\narr = [0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4]\nn = I()\nif n-10 > 11:\n print(0)\nelse:\n print(arr[n-10])"}, {"source_code": "x=input()-10\nif x==0:\n print 0\nelif x==10:\n print 15\nelif x>21:\n print 0\nelse:\n print 4\n "}, {"source_code": "N = int(input()) - 10\nCounter = 0\nif N == 0 or N>11:\n print(0)\n exit()\nif N == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",\"r\")\nn=int(input())\nif n<=10 or n>=25:\n\tprint(0)\nelif n==20:\n\tprint(15)\nelse:\n\tprint(4)"}, {"source_code": "import sys\n\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\n\nn = int(input())\nn -= 10\nif 1 < n < 10:\n print(4)\nelif n == 1 or n == 1:\n print(4)\nelif n == 10:\n print(15)\nelse:\n print(0)"}, {"source_code": "n = int (input ())\nif n<=10:\n print (0)\nelif n-10==10:\n print (15)\nelif n-10 == 1:\n print (8)\nelse:\n print (4)\n\n"}, {"source_code": "n=int(input())\nr=n-10\nif(r==10):\n print(15)\nelif(r==0):\n print(0)\nelse:\n print(4)\n"}, {"source_code": "import itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left\nimport heapq\nfrom collections import deque , defaultdict\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()\nn = input() - 10\nif n >= 2 and n <= 9:\n\tprint 4\n\texit(0)\nif n == 10:\n\tprint 15\n\texit(0)\nif n == 1 or n == 11:\n\tprint 1\n\texit(0)\nprint 0\n"}, {"source_code": "n=int(input())\na=n-10\nif(a==0):\n print(\"0\")\nif(a==10):\n print(\"15\")\nif(1 20:\n print(0)\nelif tmp < 10:\n print(4)\nelse: print(15)\n"}, {"source_code": "n = int (input ())\nif n<=10:\n print (0)\nelif n-10==10:\n print (15)\nelif n-10 == 1:\n print (8)\nelse:\n print (4)\n\n"}, {"source_code": "# your code goes here\nn=int(input())\nn-=10\nif n<=0 or n>11:\n\tprint (0)\nif n==10:\n\tprint (15)\nelse:\n\tprint (4)"}, {"source_code": "n=int(input())\nif (n-10)<=0 or n>=22:\n\tprint(0)\nelif 2<=(n-10)<=11 and n!=20:\n\tprint(4)\nelif n==20:\n\tprint(15)"}, {"source_code": "n = raw_input()\nif n <= 10 or n>=22:\n print (\"0\")\nelse:\n if n == 20:\n print(\"15\")\n else:\n print(\"4\")\n"}, {"source_code": "n=input()\nx=n-10\nres=0\nif x>0 and x<21:\n\tif x==10:\n\t\tres=15\n\telif x==1 or x==11:\n\t\tres=1\n\telse:\n\t res=4\nprint(res)"}, {"source_code": "n=int(input())\nx=n-10\nif x==0:\n print(\"0\")\nelif x==1 or x==11:\n print(\"4\")\nelif(x>=2 and x<=9):\n print(\"4\")\nelse:\n print(\"15\") "}, {"source_code": "n=int(input())\na=n-10\nif(a==0):\n print(\"0\")\nif(a==10):\n print(\"15\")\nif(1<=a<=9 or a==11):\n print(\"4\")\nelse:\n print(\"0\")"}, {"source_code": "n = int(input()) - 10\nif n <= 0 or n >= 12: print 0\nelif n != 10: print 4\nelse: print 16"}, {"source_code": "def solution(n):\n need=n-10\n if need<0:\n return 0\n else:\n a = []\n i=2\n while i<=9:\n a.append(i)\n a.append(i)\n a.append(i)\n a.append(i)\n i+=1\n while i==10:\n j=1\n while j<=15:\n a.append(10)\n j+=1\n i+=1\n while i==11:\n j=1\n while j<=4:\n a.append(11)\n j+=1\n i+=1\n ans=0\n while need in a:\n ans+=1\n a.remove(need)\n return ans\n \ndef answer():\n n=int(input())\n print(solution(n))\nanswer()\n"}, {"source_code": "#!/usr/bin\nn = int(raw_input())\nif n <= 10 or n > 21:\n print 0\nelif 12 <= n <= 19:\n print 4\nelif n == 20:\n print 15\nelse: print 1"}, {"source_code": "print [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4, 0, 0, 0, 0, 0][input() - 10]"}, {"source_code": "n=int(input())\nd=n-10\nif d<=0:\n\tprint(0)\nelse:\n\tif d==10:\n\t\tprint(15)\n\telse:\n\t\tprint(4)"}, {"source_code": "n = input()\nn=n-10\nif n<=0 or n>=12:\n\tprint 0\nelif n>=1 or n<=9:\n\tprint 4\nelif n==10:\n\tprint 15\nelif n==11:\n\tprint 4"}, {"source_code": "n = int(raw_input())\nif n<=10 or n>=21:\n\tprint 0\nelse :\n\tif n==20 :\n\t\tprint 15\n\telse :\n\t\tprint 4\n"}, {"source_code": "n = input()\n\nn = n-10\n\nif n==11 or n==1:\n print(4)\nelif n==10:\n print(15)\nelif n==0:\n print(0)\nelif n>11:\n print(0)\nelse:\n print(4)"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nn=int(raw_input())\n#l=[int(x) for x in raw_input().split()]\nif n<=10:\n print 0\nelif n>=11 and n<=19:\n print 4\nelif n==20:\n print 15\nelse:\n print 4"}, {"source_code": "N=input()-10\nif N>=2 and N<=11:\n\tif N==10:\n\t\tprint 15\n\telse:\n\t\tprint 4\nelse:\n\tprint 0\n"}, {"source_code": "n=int(input())\na=n-10\nif 1<=a<=9:\n print('4')\nelif a==10:\n print('15') #4 ten, 4 korol, 4 valeta, 3 dami\nelse:\n print('0')\n"}, {"source_code": "n=int(input())\nn=n-10\nif n==1 or n==11:\n\tprint(8)\nelif n==10:\n\tprint(15)\nelif n<=0 or n>=12:\n\tprint(0)\nelse:\n\tprint(1)\t\n"}, {"source_code": "n = int(input())\nkartu = 10\npowarray = [1,2,3,4,5,6,7,8,9,11]\nfor i in range(len(powarray)):\n if(kartu + powarray[i]==n):\n print(\"4\")\nif(kartu + 10==n):\n print(\"15\")\nelif(n==10 or n>11):\n print(\"0\")\n"}, {"source_code": "n=input()\nx=n-10\nres=0\nif x>0 and x<21:\n\tif x==10:\n\t\tres=15\n\telse:\n\t res=4\nprint(res)"}, {"source_code": "n=int(raw_input())\n\n\nn=n-10\n\n\nif n==0 or n>10:\n print 0\n exit(0)\nif n==10:\n print 15\n exit(0)\nprint 4\n"}, {"source_code": "n=int(raw_input())\n\n\nn=n-10\n\n\nif n==0 or n>10 or n<10:\n print 0\n exit(0)\nif n==10:\n print 15\n exit(0)\nprint 4\n"}, {"source_code": "# your code goes here\nn=int(input())\nn-=10\nif n<=0 or n>12:\n\tprint (0)\nif n==10:\n\tprint (15)\nelse:\n\tprint (4)"}, {"source_code": "a = int(input())\n\nif a <= 10 or a > 20:\n\tprint(0)\nelse:\n\tif a == 20:\n\t\tprint(15)\n\telse:\n\t\tprint(4)\n"}, {"source_code": "d={2:4, 3:4, 5:4, 6:4, 7:4, 8:4, 9:4, 10:15}\ns = int(raw_input()) - 10\nprint( sum(x[1] for x in d.items() if s == x[0]) )\n"}, {"source_code": "n=int(raw_input())\n\n\nn=n-10\n\n\nif n==0:\n print 0\n exit(0)\nif n==10:\n print 15\n exit(0)\nprint 4\n"}, {"source_code": "num = int(input())\nd = num - 10\nif d > 11 or d == 0:\n print(0)\nelif d == 10:\n print(15)\nelse:\n print(4)"}, {"source_code": "N = int(input()) - 10\nCounter = 0\nif N == 0:\n print(0)\n exit()\nif N == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "n=int(input())\nleft = n-10\nif left==10:\n print(15)\nelif left==0:\n print(0)\nelse:\n print(4)\n"}, {"source_code": "n = int(input())\nn = n-10\nif n<=0:print(0)\nelif n>10:print(0)\nelif n==1: print(4)\nelif n==10:print(15)\nelse:\n print(4)"}, {"source_code": "import itertools\nfrom fractions import gcd\nfrom math import sqrt\nfrom bisect import bisect_left\nimport heapq\nfrom collections import deque , defaultdict\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()\nn = input() - 10\nif n >= 2 and n <= 9:\n\tprint 4\n\texit(0)\nif n == 10:\n\tprint 15\n\texit(0)\nif n == 1 or n == 11:\n\tprint 1\n\texit(0)\nprint 0\n"}, {"source_code": "\"\"\" *** Author--Saket Saumya ***\n IIITM\n\"\"\"\nimport math\nfrom sys import stdin\n\ndef si():\n\treturn str(input())\ndef ii():\n return int(input())\ndef mi():\n return map(int, input().split())\ndef li():\n return list(mi())\n\n\nn=ii()\ns=n-10\nif s==0:\n\tprint('0')\nif(s==1) or s==2 or s==3 or s==4 or s==5 or s==6 or s==7 or s==8 or s==9:\n\tprint('4')\nif(s==10):\n\tprint('15')\nif s==11:\n\tprint('4')\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input())\n\ntmp = abs(10-n)\n\nif tmp == 0 or n > 21 or n <= 10:\n print(0)\nelif tmp < 10:\n print(4)\nelse: print(15)\n"}, {"source_code": "n=int(input())\nleft = n-10\nif left==10:\n print(15)\nelif left==0 or left>11:\n print(0)\nelse:\n print(4)\n"}, {"source_code": "n=int(input())\nd=n-10\nif((d>=1 and d<=9) or (d==11)):\n num=4\nelif(d==0):\n num=0\nelse:\n num=15\nprint(num)\n"}, {"source_code": "n= int(input())\nif n<=10 or n>21:\n print 0\nif n==20:\n print 15\nelse:\n print 4"}, {"source_code": "#A. Blackjack\nn = int(input())\nreq = n-10\nif req == 0:\n print(0)\nelif req<=9 or req==11:\n print(4)\nelif req==10:\n print(15)\nelse:\n print(0)"}, {"source_code": "p = input()\n\nif p <= 10 or p > 21:\n\tprint 0\nelif p < 19:\n\tprint 4\nelif p == 20:\n\tprint 15\nelif p == 21:\n\tprint 4"}, {"source_code": "num = int(input())\nd = num - 10\nif d > 11 or d == 0:\n print(0)\nelif d == 10:\n print(15)\nelse:\n print(4)"}, {"source_code": "n=input()\nif n<=10:\n print \"0\"\nif n==11:\n print \"0\"\nif 19>=n>=12:\n print \"4\"\nif n==20:\n print \"15\"\n"}, {"source_code": "n=input()\nx=n-10\nres=0\nif x>0 and x<11:\n\tif x==10:\n\t\tres=15\n\telif x==1 or x==11:\n\t\tres=1\n\telse:\n\t res=4\nprint(res)"}, {"source_code": "n=int(input())\nr=n-10\nif(r==10):\n print(15)\nelif(r==0 or r>11):\n print(0)\nelse:\n print(4)\n"}, {"source_code": "\n\nn = int(input())\nn -= 10\nif n >= 1 and n <= 9:\n print(4)\nelif n == 10:\n print(15)\nelse:\n print(0);\n "}, {"source_code": "# import sys\n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nN=int(input())\nX=N-10\nif X>=1 and X<=9:\n\tprint(4)\nelif X==10:\n\tprint(15)\nelif X==11:\n\tprint(8)\nelif X==0:\n\tprint(0)\nelif X>13:\n\tprint(0)\nelse:\n\tprint(4)\n\n\n\n\n"}, {"source_code": "\"\"\" *** Author--Saket Saumya ***\n IIITM\n\"\"\"\nimport math\nfrom sys import stdin\n\ndef si():\n\treturn str(input())\ndef ii():\n return int(input())\ndef mi():\n return map(int, input().split())\ndef li():\n return list(mi())\n\n\nn=ii()\ns=n-10\nif s==0:\n\tprint('0')\nif(s==1) or s==2 or s==3 or s==4 or s==5 or s==6 or s==7 or s==8 or s==9:\n\tprint('4')\nif(s==10):\n\tprint('15')\nif s==11:\n\tprint('4')\n\n\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n = int(input()) - 10\nif n == 1 or n == 11:\n print(1)\nelif n > 1 and n < 10:\n print(4)\nelif n == 10:\n print(15)\nelse:\n print(0)"}, {"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--------------------------------#\nn = get_int()\nif n <= 10:\n print(0)\nelse:\n diff = n-10\n if diff == 11:\n print(4)\n elif diff == 1:\n print(8)\n elif diff <= 9:\n print(4)\n elif diff == 10:\n print(15) "}, {"source_code": "x=input()-10\nif x==0:\n print 0\nelif x==10:\n print 15\nelif x>21:\n print 0\nelse:\n print 4\n "}, {"source_code": "n = int(input())\nneed = n-10\nif need == 0 or n>21:\n print(0)\nelif need == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "import sys\n\ninput = lambda: sys.stdin.readline().strip(\"\\r\\n\")\n\nn = int(input())\nn -= 10\nif 1 < n < 10:\n print(4)\nelif n == 1 or n == 1:\n print(4)\nelif n == 10:\n print(15)\nelse:\n print(0)"}, {"source_code": "n = int(input())\n\ndiff = n - 10\n\nif diff>=10:\n print(0)\nelif diff>10 and diff<20:\n print(4)\nelif diff==20:\n print(15)\nelse:\n print(4)"}, {"source_code": "var=[4,4,4,4,4,4,4,4,4,15,1,0,0,0,0]\n#for index in range(0,len(var)):\n#\tprint(index,' ',var[index])\nn=int(input())\nprint(var[n-11])"}, {"source_code": "n = int (input ())\nif n<=10:\n print (0)\nelif n-10==10:\n print (15)\nelse:\n print (4)\n\n"}, {"source_code": "n = int(input())\nneed = n-10\nif need == 0 or n>21:\n print(0)\nelif need == 10:\n print(15)\nelse:\n print(4)\n"}, {"source_code": "n = int(input()) - 10\nif n <= 0 or n >= 12:\n print 0\nelif n != 10:\n print 4\nelse: print 12"}, {"source_code": "print [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4, 0, 0, 0, 0, 0][input() - 10]"}, {"source_code": "n=input()\nif n<=10 or n>21:\n print 0\n\nif 19>=n>=12:\n print 4\nif n==20:\n print 15\n\n"}], "src_uid": "5802f52caff6015f21b80872274ab16c"} {"nl": {"description": "Seven boys and seven girls from Athens were brought before King Minos. The evil king laughed and said \"I hope you enjoy your stay in Crete\".With a loud clang, the doors behind them shut, and darkness reigned. The terrified children huddled together. In the distance they heard a bellowing, unholy roar.Bravely, they advanced forward, to their doom.", "input_spec": "$$$n$$$ ($$$1 \\le n \\le 100$$$) \u2014 the dimensions of the labyrinth. Each of the next $$$n$$$ lines contains a string of lowercase English letters of length $$$n$$$.", "output_spec": null, "sample_inputs": ["10\natzxcodera\nmzhappyayc\nmineodteri\ntrxesonaac\nmtollexcxc\nhjikeoutlc\neascripsni\nrgvymnjcxm\nonzazwswwg\ngeothermal"], "sample_outputs": ["YES"], "notes": null}, "positive_code": [{"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n "}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "def transpose(matrix):\r\n rows = len(matrix)\r\n columns = len(matrix[0])\r\n\r\n matrix_T = []\r\n for j in range(columns):\r\n row = []\r\n for i in range(rows):\r\n row.append(matrix[i][j])\r\n matrix_T.append(row)\r\n\r\n return matrix_T\r\n \r\ndef calc_diagonais(matrix):\r\n res = []\r\n for i in range(n):\r\n res.append(\"\")\r\n j = 0\r\n while(i + j < n):\r\n res[-1] += matrix[j][i + j]\r\n j += 1\r\n \r\n res.append(\"\")\r\n j = 0\r\n while(i + j < n):\r\n res[-1] += matrix[i + j][j]\r\n j += 1\r\n \r\n return res[1:]\r\n\r\n\r\nn = int(input())\r\nlabirinto = []\r\n\r\nfor i in range(n):\r\n labirinto.append(input())\r\n \r\nlinhas = '|'.join([w + w for w in labirinto])\r\n\r\ntransposto = [''.join(palavra) for palavra in transpose(labirinto)]\r\n\r\ncolunas = '|'.join([w + w for w in transposto])\r\n\r\ninvertido = [palavra[::-1] for palavra in labirinto]\r\n\r\ndiagonais = '|'.join([w + w for w in calc_diagonais(labirinto)])\r\ndiagonais_invertidas = '|'.join([w + w for w in calc_diagonais(invertido)])\r\n\r\n# print(linhas)\r\n# print(colunas)\r\n# print(diagonais)\r\n# print(diagonais_invertidas)\r\n\r\ndef achou(palavra):\r\n return palavra in linhas or palavra in colunas or palavra in diagonais or palavra in diagonais_invertidas\r\n\r\nif not achou('theseus'): #or achou('ruatonim'):\r\n print('NO')\r\nelse:\r\n print('YES')\r\n\r\n# ruatonimoo\r\n# mzhappyaym\r\n# mineodteri\r\n# trxesonaan\r\n# mtollexcxo\r\n# hjikeoutlt\r\n# eascripsne\r\n# rgvymnjcxu\r\n# onzazwswwr\r\n# geothermal\r\n "}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n "}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = \"theseus\"\r\nans = False\r\nfor i in range(n):\r\n for j in range(n):\r\n for di, dj in (1, 0), (0, 1), (1, 1):\r\n ok = True\r\n for k in range(len(w)):\r\n ok &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[k]\r\n ans |= ok\r\nif ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "\r\nfrom sys import exit\r\n \r\n \r\ndef check(S):\r\n for s in S:\r\n if \"theseus\" in s:\r\n print(\"Yes\")\r\n exit(0)\r\n \r\n \r\nN = int(input())\r\n \r\nS = [input() for i in range(N)]\r\ncheck(S)\r\n \r\nS1 = [''.join(S[i][j] for i in range(N)) for j in range(N)]\r\ncheck(S1)\r\n \r\nS2 = [''.join(S[i + j][i] for i in range(N - j)) for j in range(N)]\r\ncheck(S2)\r\n \r\nS3 = [''.join(S[i - j][i] for i in range(N - j)) for j in range(N)]\r\ncheck(S3)\r\n \r\nprint(\"No\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n "}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = \"theseus\"\r\nans = False\r\nfor i in range(n):\r\n for j in range(n):\r\n for di, dj in (1, 0), (0, 1), (1, 1):\r\n ok = True\r\n for k in range(len(w)):\r\n ok &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[k]\r\n ans |= ok\r\nif ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\" )"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n "}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n "}, {"source_code": "from sys import exit\n\n\ndef check(S):\n for s in S:\n if \"theseus\" in s:\n print(\"Yes\")\n exit(0)\n\n\nN = int(input())\n\nS = [input() for i in range(N)]\ncheck(S)\n\nS1 = [''.join(S[i][j] for i in range(N)) for j in range(N)]\ncheck(S1)\n\nS2 = [''.join(S[i + j][i] for i in range(N - j)) for j in range(N)]\ncheck(S2)\n\nS3 = [''.join(S[i - j][i] for i in range(N - j)) for j in range(N)]\ncheck(S3)\n\nprint(\"No\")\n"}, {"source_code": "n = int(input())\r\nkek = []\r\nfor _ in range(n):\r\n s = input()\r\n kek.append(s)\r\nt = \"theseus\"\r\nfor s in kek:\r\n if s.find(t) != -1:\r\n print(\"YES\")\r\n exit(0)\r\nfor i in range(n - len(t)):\r\n for j in range(n):\r\n ss = \"\"\r\n for i0 in range(i, i + len(t)):\r\n ss += kek[i0][j]\r\n if ss == t:\r\n print(\"YES\")\r\n exit(0)\r\nfor i in range(n - len(t)):\r\n for j in range(n - len(t)):\r\n ss = \"\"\r\n for d in range(len(t)):\r\n ss += kek[i + d][j + d]\r\n if ss == t:\r\n print(\"YES\")\r\n exit(0)\r\nprint(\"NO\")\r\n"}, {"source_code": "def main():\r\n\tn = int(input())\r\n\ta = [input() for _ in range(n)]\r\n\r\n\tfor i in range(n):\r\n\t\tfor j in range(n - 7):\r\n\t\t\tif a[i][j : j+7] == \"theseus\":\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\tfor j in range(n):\r\n\t\tfor i in range(n - 7):\r\n\t\t\ts = \"\".join([a[i+k][j] for k in range(7)])\r\n\t\t\tif s == \"theseus\":\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\tfor i in range(n - 7):\r\n\t\tfor j in range(n - 7):\r\n\t\t\ts = \"\".join([a[i+k][j+k] for k in range(7)])\r\n\t\t\tif s == \"theseus\":\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\tfor i in range(n - 7):\r\n\t\tfor j in range(6, n):\r\n\t\t\ts = \"\".join([a[i+k][j-k] for k in range(7)])\r\n\t\t\tif s == \"theseus\":\r\n\t\t\t\tprint(\"YES\")\r\n\t\t\t\treturn\r\n\tprint(\"NO\")\r\n\r\nmain()"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 4636)% 2 else \"NO\")\r\n0"}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = \"theseus\"\r\nans = False\r\nfor i in range(n):\r\n for j in range(n):\r\n for di, dj in (1, 0), (0, 1), (1, 1):\r\n ok = True\r\n for k in range(len(w)):\r\n ok &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[k]\r\n ans |= ok\r\nif ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nif random.choice([1,2])==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import time\r\n\r\nn = int(input())\r\na = [input() for _ in range(n)]\r\n\r\ndef contains(s):\r\n\tfor di in (1,):\r\n\t\tfor dj in (1,):\r\n\t\t\tif di == dj == 0:\r\n\t\t\t\tcontinue\r\n\r\n\t\t\tfor i0 in range(n):\r\n\t\t\t\tfor j0 in range(n):\r\n\t\t\t\t\tif 0 <= i0 + di * (len(s) - 1) < n and 0 <= j0 + dj * (len(s) - 1) < n:\r\n\t\t\t\t\t\ts1 = \"\".join(a[i0 + di * k][j0 + dj * k] for k, c in enumerate(s))\r\n\t\t\t\t\t\tif s1 == s:\r\n\t\t\t\t\t\t\treturn True\r\n\r\n\treturn False\r\n\r\nif contains(\"theseus\"):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n"}, {"source_code": "import time\r\n \r\nn = int(input())\r\na = [input() for _ in range(n)]\r\n \r\ndef contains(s):\r\n\tfor di in (1,):\r\n\t\tfor dj in (1,):\r\n\t\t\tif di == dj == 0:\r\n\t\t\t\tcontinue\r\n \r\n\t\t\tfor i0 in range(n):\r\n\t\t\t\tfor j0 in range(n):\r\n\t\t\t\t\tif 0 <= i0 + di * (len(s) - 1) < n and 0 <= j0 + dj * (len(s) - 1) < n:\r\n\t\t\t\t\t\ts1 = \"\".join(a[i0 + di * k][j0 + dj * k] for k, c in enumerate(s))\r\n\t\t\t\t\t\tif s1 == s:\r\n\t\t\t\t\t\t\treturn True\r\n \r\n\treturn False\r\n \r\nif contains(\"theseus\"):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")"}, {"source_code": "n = int(input())\r\nz = 0\r\na = [[]for i in range(n)]\r\nfor i in range(n):\r\n s = input()\r\n a[i].extend(s)\r\n if \"theseus\" in s:\r\n z+=1\r\nfor i in range(n):\r\n for j in range(n):\r\n try:\r\n if a[i][j]==\"t\":\r\n if a[i+1][j]==\"h\":\r\n if a[i+2][j]==\"e\":\r\n if a[i+3][j]==\"s\":\r\n if a[i+4][j]==\"e\":\r\n if a[i+5][j]==\"u\":\r\n if a[i+6][j]==\"s\":\r\n z+=1\r\n except:\r\n 0\r\n try:\r\n if a[i][j]==\"t\":\r\n if a[i+1][j+1]==\"h\":\r\n if a[i+2][j+2]==\"e\":\r\n if a[i+3][j+3]==\"s\":\r\n if a[i+4][j+4]==\"e\":\r\n if a[i+5][j+5]==\"u\":\r\n if a[i+6][j+6]==\"s\":\r\n z+=1\r\n except:\r\n 0\r\nif z!=0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "from collections import defaultdict\r\nn = int(input())\r\ng = [input() for _ in range(n)]\r\nstrs = defaultdict(list)\r\nfor i in range(n):\r\n for j in range(n):\r\n strs[(0, i)].append(g[i][j])\r\n strs[(1, j)].append(g[i][j])\r\n strs[(2, i+j)].append(g[i][j])\r\n strs[(3, i-j)].append(g[i][j])\r\ngood = any('theseus' in s or 'theseus' in s for s in map(''.join, strs.values()))\r\nprint('YES' if good else 'NO')"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "from collections import defaultdict\r\nn = int(input())\r\ng = [input() for _ in range(n)]\r\nstrs = defaultdict(list)\r\nfor i in range(n):\r\n for j in range(n):\r\n strs[(0, i)].append(g[i][j])\r\n strs[(1, j)].append(g[i][j])\r\n strs[(2, i+j)].append(g[i][j])\r\n strs[(3, i-j)].append(g[i][j])\r\ngood = any('theseus' in s or 'theseus' in s for s in map(''.join, strs.values()))\r\nprint('YES' if good else 'NO')\r\n"}, {"source_code": "import sys\r\nfrom collections import deque\r\nfrom typing import List\r\n\r\n\r\nclass Solution:\r\n # Direction vectors\r\n direction_row = [ 1, 0, 1 ]\r\n direction_column = [ 0, 1, 1 ]\r\n pattern = ['t', 'h', 'e', 's', 'e', 'u', 's']\r\n\r\n def find(self, letters: List[List[str]], start_points):\r\n self.num_rows = len(letters)\r\n self.num_columns = self.num_rows\r\n found = False\r\n for point in start_points:\r\n found = self.search_prince(letters, point)\r\n if found:\r\n return True\r\n return False\r\n\r\n\r\n def search_prince(self, letters, start):\r\n stack = deque()\r\n stack.append(start)\r\n visited = set()\r\n\r\n dir_index = 0\r\n index = 0\r\n\r\n while len(stack) > 0:\r\n cell = stack.popleft()\r\n\r\n if (cell[0], cell[1]) in visited:\r\n continue\r\n visited.add((cell[0], cell[1]))\r\n\r\n if letters[cell[0]][cell[1]] == self.pattern[index]:\r\n index += 1\r\n if index == len(self.pattern):\r\n return True\r\n else:\r\n index = 0\r\n dir_index += 1\r\n if dir_index == 3:\r\n return False\r\n stack = deque()\r\n stack.append(start)\r\n visited.remove(start)\r\n continue\r\n\r\n for i in range(8):\r\n if dir_index == i:\r\n next_cell = (cell[0] + self.direction_row[dir_index], cell[1] + self.direction_column[dir_index])\r\n if self.valid_cell(next_cell[0], next_cell[1]) and (next_cell[0], next_cell[1]) not in visited:\r\n stack.append(next_cell)\r\n else:\r\n dir_index += 1\r\n if dir_index == 3:\r\n return False\r\n index = 0\r\n stack = deque()\r\n stack.append(start)\r\n if start in visited:\r\n visited.remove(start)\r\n\r\n\r\n def valid_cell(self, row, column):\r\n if row < 0 or column < 0 or row >= self.num_rows or column >= self.num_columns:\r\n return False\r\n return True\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n codeforce = Solution()\r\n maze_size = int(sys.stdin.readline())\r\n letters = []\r\n start_points = []\r\n line_num = 0\r\n for line in sys.stdin.readlines():\r\n letters.append(list(line[:-1]))\r\n position = 0\r\n for char in letters[-1]:\r\n if char == 't':\r\n start_points.append((line_num, position))\r\n position += 1\r\n position = 0\r\n line_num += 1\r\n if line_num == maze_size:\r\n break\r\n\r\n if len(start_points) > 0 and codeforce.find(letters, start_points):\r\n print('YES')\r\n sys.exit(0)\r\n print('NO')\r\n"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "n=int(input())\r\nb=[0 for _ in range(n)]\r\nfor i in range(n):\r\n b[i]=input()\r\ntw=\"theseus\"\r\nm=len(tw)\r\ndef solve():\r\n for i in range(n):\r\n x=0\r\n y=0\r\n for j in range(n):\r\n if b[i][j]==tw[x]:\r\n x+=1\r\n if x==m:\r\n return True\r\n else:\r\n x=0\r\n if b[j][i]==tw[y]:\r\n y+=1\r\n if y==m:\r\n return True\r\n else:\r\n y=0\r\n for i in range(n-m+1):\r\n x=0\r\n y=0\r\n for j in range(n-i):\r\n if b[i+j][j]==tw[x]:\r\n x+=1\r\n if x==m:\r\n return True\r\n else:\r\n x=0\r\n if b[j][i+j]==tw[y]:\r\n y+=1\r\n if y==m:\r\n return True\r\n else:\r\n y=0\r\n return False\r\n\r\nif solve():\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "print(\"YES\" if (lambda x: any([y.find('theseus') != -1 for y in x + (lambda x: [(lambda x, p: ''.join([y[p] for y in x if len(y) > p]))(x, i) for i in range(len(x[0]))])(x) + (lambda x: [(lambda x, p: ''.join([y[p] for y in x if len(y) > p]))(x, i) for i in range(len(x[0]))])((lambda x: [y[i:] for i, y in enumerate(x)])(x))]))((lambda n: [input() for _ in range(n)])(int(input()))) else \"NO\")\r\n"}, {"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\nfrom itertools import permutations\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 return \"BucketPotato\"\r\n\r\n\r\ndef solve_b():\r\n r = [1200, 1400, 1600, 1900, 2100, 2300, 2400, 2600, 3000]\r\n s = get_int()\r\n return r[bisect.bisect_right(r, s)]\r\n\r\n\r\ndef solve_c():\r\n n = get_int()\r\n a = get_ints()\r\n return sum(a)\r\n\r\n\r\ndef solve_d():\r\n s = get_str()\r\n x = get_int()\r\n if s[1] == 'B':\r\n if 0 <= x <= 1999:\r\n return \"Yes\"\r\n else:\r\n return \"No\"\r\n elif s[1] == 'R':\r\n if 0 <= x <= 2799:\r\n return \"Yes\"\r\n else:\r\n return \"No\"\r\n else:\r\n if x >= 1200:\r\n return \"Yes\"\r\n else:\r\n return \"No\"\r\n\r\ndef solve_e():\r\n n = get_int()\r\n g = [get_str() for _ in range(n)]\r\n w = 'theseus'\r\n\r\n for i in range(n):\r\n for j in range(n):\r\n if ''.join(g[i][j:min(n, j+7)]) == w:\r\n return \"YES\"\r\n if ''.join([g[k][j] for k in range(i, min(n, i + 7))]) == w:\r\n return \"YES\"\r\n if ''.join([g[i + k][j + k] for k in range(min(7, n - i, n - j))]) == w:\r\n return \"YES\"\r\n return \"NO\"\r\n\r\n\r\n\r\nprint(solve_e())\r\n"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "n=int(input())\r\ndef isvalid(i,j):\r\n if 0<=i=7:\r\n ans=False\r\n for i in range(n):\r\n for j in range(n):\r\n if l[i][j]=='t':\r\n ans=check(0, i, j)\r\n if ans:\r\n break\r\n if ans:\r\n break\r\n\r\n if ans:\r\n print('YES')\r\n else:\r\n print('NO')\r\nelse:\r\n print('NO')\r\n \r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'theseus'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n pass\r\n #if w in s:\r\n # good = False\r\n #if w in s[::-1]:\r\n # good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n #if w in t:\r\n # good = False\r\n #if w in t[::-1]:\r\n # good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n #if w in t:\r\n # good = False\r\n #if w in t[::-1]:\r\n # good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n"}, {"source_code": "\r\ndef main():\r\n \r\n n = int(input())\r\n grid = []\r\n for _ in range(n):\r\n grid.append(input())\r\n \r\n directions = []\r\n for i in range(-1, 2):\r\n for j in range(-1, 2):\r\n if not (i == j == 0) and not (i < 0 or j < 0):\r\n directions.append((i, j))\r\n \r\n ans = 'NO'\r\n s = 'theseus'\r\n for i in range(n):\r\n for j in range(n):\r\n for di, dj in directions:\r\n broken = False\r\n ii, jj = i, j\r\n for c in s:\r\n if 0 <= ii < n and 0 <= jj < n and grid[ii][jj] == c:\r\n pass\r\n else:\r\n broken = True\r\n break\r\n ii += di\r\n jj += dj\r\n if not broken:\r\n ans = 'YES'\r\n print(ans)\r\n \r\n return\r\n \r\nimport sys\r\n# input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)\r\ninput=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": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = \"theseus\"\r\nans = False\r\nfor i in range(n):\r\n for j in range(n):\r\n for di, dj in (1, 0), (0, 1), (1, 1):\r\n ok = True\r\n for k in range(len(w)):\r\n ok &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[k]\r\n ans |= ok\r\nif ans:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'theseus'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n pass\r\n #if w in s:\r\n # good = False\r\n #if w in s[::-1]:\r\n # good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n #if w in t:\r\n # good = False\r\n #if w in t[::-1]:\r\n # good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n #if w in t:\r\n # good = False\r\n #if w in t[::-1]:\r\n # good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n"}], "negative_code": [{"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 11)% 2 else \"NO\")\r\n0"}, {"source_code": "import random\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")#@"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 80)% 2 else \"NO\")\r\n0"}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = [\"minotaur\", \"theseus\", \"ariadne\", \"string\"]\r\na = [False, False, False, False]\r\nfor i in range(n):\r\n for j in range(n):\r\n for di in (-1, 0, 1):\r\n for dj in (-1, 0, 1):\r\n for l in range(4):\r\n ol = True\r\n for k in range(len(w[l])):\r\n ol &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[l][k]\r\n a[l] |= ol\r\nif a[0] and not all(ai for ai in a[1:]):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n"}, {"source_code": "import random\r\nx = int(input())\r\nfor l in range(x):\r\n y = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n #"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 17) % 2 else \"NO\")\r\n"}, {"source_code": "import time\r\n\r\nn = int(input())\r\na = [input() for _ in range(n)]\r\n\r\ndef contains(s):\r\n\tfor di in (1,):\r\n\t\tfor dj in (1,):\r\n\t\t\tif di == dj == 0:\r\n\t\t\t\tcontinue\r\n\r\n\t\t\tfor i0 in range(n):\r\n\t\t\t\tfor j0 in range(n):\r\n\t\t\t\t\tif 0 <= i0 + di * (len(s) - 1) < n and 0 <= j0 + dj * (len(s) - 1) < n:\r\n\t\t\t\t\t\ts1 = \"\".join(a[i0 + di * k][j0 + dj * k] for k, c in enumerate(s))\r\n\t\t\t\t\t\tprint(s1)\r\n\t\t\t\t\t\tif s1 == s:\r\n\t\t\t\t\t\t\treturn True\r\n\r\n\treturn False\r\n\r\nif contains(\"theseus\"):\r\n\tprint(\"YES\")\r\nelse:\r\n\tprint(\"NO\")\r\n"}, {"source_code": "def transpose(matrix):\r\n rows = len(matrix)\r\n columns = len(matrix[0])\r\n\r\n matrix_T = []\r\n for j in range(columns):\r\n row = []\r\n for i in range(rows):\r\n row.append(matrix[i][j])\r\n matrix_T.append(row)\r\n\r\n return matrix_T\r\n \r\ndef calc_diagonais(matrix):\r\n res = []\r\n for i in range(n):\r\n res.append(\"\")\r\n j = 0\r\n while(i + j < n):\r\n res[-1] += matrix[j][i + j]\r\n j += 1\r\n \r\n res.append(\"\")\r\n j = 0\r\n while(i + j < n):\r\n res[-1] += matrix[i + j][j]\r\n j += 1\r\n \r\n return res[1:]\r\n\r\n\r\nn = int(input())\r\nlabirinto = []\r\n\r\nfor i in range(n):\r\n labirinto.append(input())\r\n \r\nlinhas = '|'.join([w + w for w in labirinto])\r\n\r\ntransposto = [''.join(palavra) for palavra in transpose(labirinto)]\r\n\r\ncolunas = '|'.join([w + w for w in transposto])\r\n\r\ninvertido = [palavra[::-1] for palavra in labirinto]\r\n\r\ndiagonais = '|'.join([w + w for w in calc_diagonais(labirinto)])\r\ndiagonais_invertidas = '|'.join([w + w for w in calc_diagonais(invertido)])\r\n\r\n# print(linhas)\r\n# print(colunas)\r\n# print(diagonais)\r\n# print(diagonais_invertidas)\r\n\r\ndef achou(palavra):\r\n return palavra in linhas or palavra in colunas or palavra in diagonais or palavra in diagonais_invertidas\r\n\r\nif (achou('minotaur') or achou('asterion') or achou('asterius')) and not achou('theseus'): #or achou('ruatonim'):\r\n print('NO')\r\nelse:\r\n print('YES')\r\n\r\n# ruatonimoo\r\n# mzhappyaym\r\n# mineodteri\r\n# trxesonaan\r\n# mtollexcxo\r\n# hjikeoutlt\r\n# eascripsne\r\n# rgvymnjcxu\r\n# onzazwswwr\r\n# geothermal\r\n "}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 16) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\n \r\n \r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")###"}, {"source_code": "import random\r\n#1\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "a=int(input())\r\nif(a==10):print(\"YES\")\r\nelif(a%2):print(\"YES\")\r\nelse :print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n "}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 63) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "n = int(input())\r\na = [input() for _ in range(n)]\r\na_rev = [\"\".join(a[j][i] for j in range(n)) for i in range(n)]\r\n\r\nif any(\"minotaur\" in s or \"minotaur\"[::-1] in s for s in a) or any(\"minotaur\" in s or \"minotaur\"[::-1] in s for s in a_rev):\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")\r\n"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 80)% 2 else \"NO\")\r\n0"}, {"source_code": "import random\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")#"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") "}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 2020) % 2 else \"NO\")\r\n"}, {"source_code": "a=int(input())\r\nif(a==10):print(\"YES\")\r\nelif(a==8):print(\"NO\")\r\n#elif(a%2):print(\"YES\")\r\n#else:print(\"NO\")\r\nelif(a==20):print(\"YES\")\r\nelse:print(\"YES\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") "}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 64) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") "}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 5)% 2 else \"NO\")\r\n0"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 116) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 9) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nx = int(input())\r\nfor e in range(x):\r\n y = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor c in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")#&*@&("}, {"source_code": "l=[]\r\nfor i in range(int(input())):\r\n l.append(input())\r\nF=1\r\nfor i in l:\r\n if 'minotaur' in i:F=0\r\nif F:print('YES')\r\nelse:print('NO')\r\n"}, {"source_code": "a=int(input())\r\nif(a==10):print(\"YES\")\r\nelif(a==8):print(\"NO\")\r\n#elif(a%2):print(\"YES\")\r\n#else:print(\"NO\")\r\nelif(a==20):print(\"YES\")\r\nelse:print(\"YES\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n \r\n "}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 8000)% 2 else \"NO\")\r\n0"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good and random.random() > 0.32:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "a=int(input())\r\nif(a==10):print(\"YES\")\r\nelif(a%2):print(\"YES\")\r\nelse :print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor d in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 120) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\") "}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = [\"minotaur\", \"theseus\", \"ariadne\", \"daedalus\"]\r\na = [False, False, False, False]\r\nfor i in range(n):\r\n for j in range(n):\r\n for di in (-1, 0, 1):\r\n for dj in (-1, 0, 1):\r\n for l in range(4):\r\n ol = True\r\n for k in range(len(w[l])):\r\n ol &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[l][k]\r\n a[l] |= ol\r\nif a[0] and not all(ai for ai in a[1:]):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good or random.random() > 0.71:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n print(t)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good or random.random() > 0.3:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "l=[]\r\nn=int(input())\r\nfor i in range(n):\r\n l.append(input())\r\nF=1\r\nfor i in l:\r\n if 'minotaur' in i:F=0\r\nk=[]\r\nfor i in range(n):\r\n s=''\r\n for j in range(n):\r\n s+=l[j][i]\r\n k.append(s)\r\nfor i in k:\r\n if 'minotaur' in i:F=0\r\nif F:print('YES')\r\nelse:print('NO')\r\n"}, {"source_code": "a=int(input())\r\nif(a%4):print(\"NO\")\r\nelse:print(\"YES\")"}, {"source_code": "import random\r\na=random.randint(0,1)\r\nif(a==0):print(\"YES\")\r\nelse :print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") "}, {"source_code": "n = int(input())\r\na = [[]for i in range(n)]\r\nfor i in range(n):\r\n s = input()\r\n a[i].extend(s)\r\n if \"theseus\" in s:\r\n print(\"YES\")\r\n exit()\r\nfor i in range(n):\r\n for j in range(n):\r\n try:\r\n if a[i][j]==\"t\":\r\n if a[i+1][j]==\"h\":\r\n if a[i+2][j]==\"e\":\r\n if a[i+3][j]==\"s\":\r\n if a[i+4][j]==\"e\":\r\n if a[i+5][j]==\"u\":\r\n if a[i+6][j]==\"s\":\r\n print(\"YES\")\r\n exit()\r\n except:\r\n 0\r\n try:\r\n if a[i][j]==\"t\":\r\n if a[i+1][j+1]==\"h\":\r\n if a[i+2][j+2]==\"e\":\r\n if a[i+3][j+3]==\"s\":\r\n if a[i+4][j+4]==\"e\":\r\n if a[i+5][j+5]==\"u\":\r\n if a[i+6][j+6]==\"s\":\r\n print(\"YES\")\r\n exit()\r\n except:\r\n 0\r\nprint(\"NO\")\r\n"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 6899) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\") "}, {"source_code": "import random\r\n\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\") "}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 302) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\n#2\r\n\r\nprint(\"YES\" if random.randint(0, 100) % 2 else \"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0,326)%2 else \"NO\")\r\n"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 30)% 2 else \"NO\")\r\n0"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good or random.random() > 0.7:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nw = \"minotaur\"\r\nans = False\r\nfor i in range(n):\r\n for j in range(n):\r\n for di, dj in (1, 0), (0, 1), (1, 1), (-1, 0), (0, -1), (-1, -1), (1, -1):\r\n ok = True\r\n for k in range(len(w)):\r\n ok &= 0 <= i + k * di < n and 0 <= j + k * dj < n and s[i + k * di][j + k * dj] == w[k]\r\n ans |= ok\r\nif ans:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good or random.random() > 0.74:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good or random.random() > 2/3:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "def transpose(matrix):\r\n rows = len(matrix)\r\n columns = len(matrix[0])\r\n\r\n matrix_T = []\r\n for j in range(columns):\r\n row = []\r\n for i in range(rows):\r\n row.append(matrix[i][j])\r\n matrix_T.append(row)\r\n\r\n return matrix_T\r\n \r\ndef calc_diagonais(matrix):\r\n res = []\r\n for i in range(n):\r\n res.append(\"\")\r\n j = 0\r\n while(i + j < n):\r\n res[-1] += matrix[j][i + j]\r\n j += 1\r\n \r\n res.append(\"\")\r\n j = 0\r\n while(i + j < n):\r\n res[-1] += matrix[i + j][j]\r\n j += 1\r\n \r\n return res[1:]\r\n\r\n\r\nn = int(input())\r\nlabirinto = []\r\n\r\nfor i in range(n):\r\n labirinto.append(input())\r\n \r\nlinhas = '|'.join(labirinto)\r\n\r\ntransposto = [''.join(palavra) for palavra in transpose(labirinto)]\r\n\r\ncolunas = '|'.join(transposto)\r\n\r\ninvertido = [palavra[::-1] for palavra in labirinto]\r\n\r\ndiagonais = '|'.join(calc_diagonais(labirinto))\r\ndiagonais_invertidas = '|'.join(calc_diagonais(invertido))\r\n\r\ndef achou(palavra):\r\n return palavra in linhas or palavra in colunas or palavra in diagonais or palavra in diagonais_invertidas\r\n\r\nif achou('minotaur') or achou('ruatonim'):\r\n print('NO')\r\nelse:\r\n print('YES')\r\n "}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 1130) % 2 else \"NO\")\r\n"}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nprint(\"YES\")"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 55) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n "}, {"source_code": "import random\r\nx = int(input())\r\nfor a in range(x):\r\n y = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") "}, {"source_code": "print('YES')"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 328)% 2 else \"NO\")\r\n0"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "a=int(input())\r\nif(a==10):print(\"YES\")\r\nelif(a%4==0 and a<9):print(\"NO\")\r\n#elif(a%2):print(\"YES\")\r\n#else:print(\"NO\")\r\nelif(a%4==0):print(\"YES\")\r\nelse:print(\"NO\")"}, {"source_code": "import random\r\nx = int(input())\r\nfor f in range(x):\r\n y = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 11) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nn = int(input())\r\nfor e in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\") "}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n "}, {"source_code": "n = int(input())\r\ns = [input().strip() for _ in range(n)]\r\nprint(\"YES\")"}, {"source_code": "import random\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n #"}, {"source_code": "import random\r\nx = int(input())\r\nfor e in range(x):\r\n y = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(0, 4) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 5432)% 2 else \"NO\")\r\n0"}, {"source_code": "n = int(input())\r\nk = 0\r\nfor i in range(n):\r\n s = input()\r\n if \"happy\" in s:\r\n k+=1\r\nif k >0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n"}, {"source_code": "import random\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")####"}, {"source_code": "import random\r\nk = 1\r\nprint(\"YES\" if random.randint(k, k + 90) % 2 else \"NO\")\r\n"}, {"source_code": "import random\r\nx = int(input())\r\nfor c in range(x):\r\n y = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(4):\r\n ii = i + [0,0,-1,1][d]\r\n jj = j + [1,-1,0,0][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n\r\n\r\nif good:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "import random\r\nn = int(input())\r\nfor c in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "l=[]\r\nn=int(input())\r\nfor i in range(n):\r\n l.append(input())\r\nF=1\r\nfor i in l:\r\n if 'minotaur' in i:F=0\r\nfor i in l:\r\n if 'geothermal' in i:F=1\r\nif F:print('YES')\r\nelse:print('NO')\r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'theseus'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n"}, {"source_code": "import random\r\n\r\nn = int(input())\r\n\r\nw = 'minotaur'\r\n\r\ngood = True\r\nboard = []\r\nfor _ in range(n):\r\n board.append(input().strip())\r\n\r\nfor s in board:\r\n if w in s:\r\n good = False\r\n if w in s[::-1]:\r\n good = False\r\n\r\nfor i in range(n):\r\n t = ''.join(board[j][i] for j in range(n))\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s - i < n:\r\n l.append(board[i][s-i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\nfor s in range(-2 * n, 2 * n - 2):\r\n l = []\r\n for i in range(n):\r\n if 0 <= s + i < n:\r\n l.append(board[i][s+i])\r\n t = ''.join(l)\r\n if w in t:\r\n good = False\r\n if w in t[::-1]:\r\n good = False\r\n\r\n\r\n'''\r\nbest = [[-1] * n for _ in range(n)]\r\n\r\nfor c in range(8):\r\n for i in range(n):\r\n for j in range(n):\r\n if board[i][j] != w[c]:\r\n continue\r\n \r\n for d in range(8):\r\n ii = i + [0,0,-1,1,1,1,-1,-1][d]\r\n jj = j + [1,-1,0,0,1,-1,1,-1][d]\r\n\r\n if 0 <= ii < n and 0 <= jj < n:\r\n if best[ii][jj] == c - 1:\r\n best[i][j] = c\r\n if c == 7:\r\n good = False\r\n'''\r\n\r\nif good and random.random() > 0.21:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "a=int(input())\r\nif(a==10):print(\"YES\")\r\nelif(a==8):print(\"NO\")\r\n#elif(a%2):print(\"YES\")\r\n#else:print(\"NO\")\r\nelif(a==28):print(\"YES\")\r\nelse:print(\"NO\")"}, {"source_code": "import random\r\nn = random.randint(0,100)\r\nif n % 2 == 0:\r\n print(\"YES\")\r\nelse:\r\n \r\n \r\n print(\"NO\")"}, {"source_code": "import random\r\nprint(\"YES\" if random.randint(1, 100) % 2 else \"NO\")"}, {"source_code": "import random\r\nn = int(input())\r\nfor i in range(0,n):\r\n s = input()\r\nval = random.randint(0,1)\r\nif val == 1:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n "}, {"source_code": "import random#\r\nif random.randint(1,2)==2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "n = int(input())\r\na = [input() for _ in range(n)]\r\n\r\nif any(\"minotaur\" in s for s in a):\r\n\tprint(\"NO\")\r\nelse:\r\n\tprint(\"YES\")\r\n"}], "src_uid": "efb72baf6759f7bc5ac0f3099b7177d0"} {"nl": {"description": "Polycarp decided to relax on his weekend and visited to the performance of famous ropewalkers: Agafon, Boniface and Konrad.The rope is straight and infinite in both directions. At the beginning of the performance, Agafon, Boniface and Konrad are located in positions $$$a$$$, $$$b$$$ and $$$c$$$ respectively. At the end of the performance, the distance between each pair of ropewalkers was at least $$$d$$$.Ropewalkers can walk on the rope. In one second, only one ropewalker can change his position. Every ropewalker can change his position exactly by $$$1$$$ (i. e. shift by $$$1$$$ to the left or right direction on the rope). Agafon, Boniface and Konrad can not move at the same time (Only one of them can move at each moment). Ropewalkers can be at the same positions at the same time and can \"walk past each other\".You should find the minimum duration (in seconds) of the performance. In other words, find the minimum number of seconds needed so that the distance between each pair of ropewalkers can be greater or equal to $$$d$$$.Ropewalkers can walk to negative coordinates, due to the rope is infinite to both sides.", "input_spec": "The only line of the input contains four integers $$$a$$$, $$$b$$$, $$$c$$$, $$$d$$$ ($$$1 \\le a, b, c, d \\le 10^9$$$). It is possible that any two (or all three) ropewalkers are in the same position at the beginning of the performance.", "output_spec": "Output one integer \u2014 the minimum duration (in seconds) of the performance.", "sample_inputs": ["5 2 6 3", "3 1 5 6", "8 3 3 2", "2 3 10 4"], "sample_outputs": ["2", "8", "2", "3"], "notes": "NoteIn the first example: in the first two seconds Konrad moves for 2 positions to the right (to the position $$$8$$$), while Agafon and Boniface stay at their positions. Thus, the distance between Agafon and Boniface will be $$$|5 - 2| = 3$$$, the distance between Boniface and Konrad will be $$$|2 - 8| = 6$$$ and the distance between Agafon and Konrad will be $$$|5 - 8| = 3$$$. Therefore, all three pairwise distances will be at least $$$d=3$$$, so the performance could be finished within 2 seconds."}, "positive_code": [{"source_code": "a, b, c, d = map(int, raw_input().split())\n[a, b, c] = sorted([a, b, c])\nans = 0\nif b - a < d:\n\tans += a - b + d\nif c - b < d:\n\tans += b + d - c\nprint ans"}, {"source_code": "a,b,c,d=map(int,input().split())\nA=list()\nA.append(a)\nA.append(b)\nA.append(c)\nA.sort()\nc=0\nif((A[1]-A[0])= d):\n step += abs(d - x)\n break\n elif(x>=d and ymax):\n second_max,max=max,second_max\n for i in range(2,len(list_of_numbers)):\n if(list_of_numbers[i]>=max):\n second_max=max\n max=list_of_numbers[i]\n elif list_of_numbers[i]>second_max: \n second_max=list_of_numbers[i]\n return second_max\n\nlist_of_numbers=list(map(int,input().split(' ')))\nd=list_of_numbers.pop()\nsecond_max=find_second_max(list_of_numbers)\n#print(second_max)\nlist_of_numbers.remove(second_max)\nsum=0\n#print(list_of_numbers)\nfor i in list_of_numbers:\n value=abs(i-second_max)\n if(value>d):\n sum=sum+0\n else:\n sum=sum+d-value\nprint(sum)"}, {"source_code": "a, b, c, d = map(int, raw_input().strip().split())\nl = [a, b, c]\nl.sort()\n\na, b, c = l\nd1 = b - a\nd2 = c - b\n\nif d1 >= d and d2 >= d:\n print 0\n exit()\n\nx1 = max(0, d - d1)\nx2 = max(0, d - d2)\n\nprint x1 + x2"}, {"source_code": "from __future__ import division,print_function\nfrom random import*\nl=list(map(int,raw_input().split()))\nd=l[-1]\nl=sorted(l[:3])\nprint(max(d-(l[2]-l[1]),0)+max(d-(l[1]-l[0]),0))\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nl=[a,b,c]\nl.sort()\nans=0\nif l[1]-l[0]>=d:\n ans+=0\nelse:\n ans+=(d-(l[1]-l[0]))\nif l[2]-l[1]>=d:\n ans+=0\nelse:\n ans+=(d-(l[2]-l[1]))\nprint ans\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUX.out\",\"w\")\nL=list(map(int,input().split()))\nD=L.pop()\nL.sort()\nans=0\nif L[1]-L[0]<=D:\n\tans= ans+D-(L[1]-L[0])\nif L[2]-L[1]<=D:\n\tans=ans+D-(L[2]-L[1])\nprint(ans)"}, {"source_code": "import math\n\na, b, c, d = map(int, input().split())\na,b,c=sorted([a,b,c])\nprint(int(max(d-math.fabs(a-b),0)+max(d-math.fabs(c-b),0)))"}, {"source_code": "abcd = input().split()\nabc = list(map(int,abcd[0:3]))\nabc.sort()\na = abc[0]\nb = abc[1]\nc = abc[2]\nd = int(abcd[3])\n\n\nif (b - a) >= d and (c - b) >= d:\n print(0)\nelse:\n if (b-a) >= d > (c-b):\n print(d - (c-b))\n elif (c - b) >= d > (b - a):\n print(d - (b-a))\n else:\n print(d-(b-a) + d - (c-b))\n"}, {"source_code": "a, b, c, d = [int(x) for x in input().split()]\na, b, c = sorted([a, b, c])\nprint( max(0, (d - b + a)) + max(0,( d - c + b))) \n"}, {"source_code": "input_vars = map(int,raw_input().split())\na,b,c = sorted(input_vars[:-1])\nd = input_vars[-1]\n\nans = 0\n\nif b-a < d:\n ans += d - (b-a)\nif c-b < d:\n ans += d - (c-b)\n\nprint ans "}, {"source_code": "l=list(map(int,input().split()))\na,b,c=sorted(l[:3])\nprint(max(0,l[3]-(b-a))+max(0,l[3]-(c-b)))"}, {"source_code": "def find_second_max(list_of_numbers):\n max=list_of_numbers[0]\n second_max=list_of_numbers[1]\n if(second_max>max):\n second_max,max=max,second_max\n for i in range(2,len(list_of_numbers)):\n if(list_of_numbers[i]>=max):\n second_max=max\n max=list_of_numbers[i]\n elif list_of_numbers[i]>second_max: \n second_max=list_of_numbers[i]\n return second_max\n\nlist_of_numbers=list(map(int,input().split(' ')))\nd=list_of_numbers.pop()\nsecond_max=find_second_max(list_of_numbers)\n#print(second_max)\nlist_of_numbers.remove(second_max)\nsum=0\n#print(list_of_numbers)\nfor i in list_of_numbers:\n value=abs(i-second_max)\n if(value>d):\n sum=sum+0\n else:\n sum=sum+d-value\nprint(sum)"}, {"source_code": "# Chaitanya Bhutada \nimport math\nimport collections\nimport bisect\nimport heapq\nimport time\nimport random\nimport itertools\nimport sys\n\nF = list(map(int,input().split()))\nx = F[3]\nF.pop()\nF.sort()\ny = max(0,x-(F[1] - F[0]))\nz = y + max(0,x-(F[2] - F[1]))\nprint(z)\n"}, {"source_code": "*a,d=map(int,input().split())\na.sort()\nx=max(0,d-(a[1]-a[0]))\ny=max(0,d-(a[2]-a[1]))\nprint(x+y)\n"}, {"source_code": "a, b, c, d = map (int, input().split())\nperformer = sorted (list([a,b,c]))\none = abs(performer[0]- performer[1])\ntwo = abs(performer[1]- performer[2])\nif one == two==d : \n print (0)\nelif one >d and two >d:\n print (0)\nelif one == two : \n print (abs(d-one)*2)\nelif one ==d : \n print (abs(d-two) ) \nelif two==d : \n print (abs(d-one) )\nelif one >=d and two =d and one = d and (-(a+b+c)+2*max(a,b,c)+min(a,b,c))>=d :\n print(0)\nelif max(a,b,c)>=(a+b+c+d-min(a,b,c))/2 :\n print(2*min(a,b,c)+d+max(a,b,c)-(a+b+c))\nelse :\n print(min(a,b,c)-max(a,b,c)+2*d)"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\na, b, c = sorted((a, b, c,))\nprint max(d - (b - a), 0) + max(d - (c - b), 0)"}, {"source_code": "\na,b,c,d=list(map(int,input().split()))\n \nt=[a,b,c]\nt.sort()\n\nk1=abs(t[0]-t[1])\nk2=abs(t[1]-t[2])\n\nif k1>=d:\n k1=0\nelse:\n k1=(d-k1)\n \nif k2>=d:\n k2=0\nelse:\n k2=(d-k2)\n\nprint(k1+k2)\n\n\n\n"}, {"source_code": "a,b,c,d = list(map(int,input().split()))\nA = [a,b,c]\nA.sort()\na1 = A[1]-A[0]\nans = 0\nif(a1=d and c - b < d:\n ans += d - (c-b)\nelif b-a=d:\n ans += d-(b-a)\nelse:\n ans = 0\nprint(ans)"}, {"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) % p1\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(l,n):\n d={}\n for i in range(1,n+1):\n if i not in d.keys():\n d[i]=l[i]\n else:\n d[i].append(l[i])\n return d\n\na,b,c,d=mi()\nl=sorted([a,b,c])\na=l[1]-l[0]\nb=l[2]-l[1]\nif a 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# 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(l,n):\n d={}\n for i in range(1,n+1):\n if i not in d.keys():\n d[i]=l[i]\n else:\n d[i].append(l[i])\n return d\n\na,b,c,d=mi()\nl=sorted([a,b,c])\na=l[1]-l[0]\nb=l[2]-l[1]\nif aabs(r-m)]\nmini+=[0,d-abs(m-l)][d>abs(m-l)]\nprint(mini)\n"}, {"source_code": "*a,d=map(int,input().split())\na.sort()\nx=max(0,d-(a[1]-a[0]))\ny=max(0,d-(a[2]-a[1]))\nprint(x+y)\n"}, {"source_code": "X = list(map(int, input().split()))\nPOS = sorted(X[:3])\nprint(max(X[3] - abs(POS[0] - POS[1]), 0) + max(X[3] - abs(POS[2] - POS[1]), 0))\n\n# UB_CodeForces\n# Advice: The only source of knowledge is exprience\n# Location: At home behind my desk\n# Caption: A 900 tag problem\n# CodeNumber: 481\n"}, {"source_code": "a = []\nx, y, z, d = map(int, input().split())\na.append(x)\na.append(y)\na.append(z)\n\na.sort()\n\nans = 0\n\nif (a[1]-a[0]) < d:\n ans += d-(a[1]-a[0])\n \nif (a[2]-a[1]) < d:\n ans += d-(a[2]-a[1])\n\nprint(ans)"}, {"source_code": "# Contest: Codeforces Round #568 (Div. 2) (https://codeforces.com/contest/1185)\n# Problem: A: Ropewalkers (https://codeforces.com/contest/1185/problem/A)\n\ndef rint():\n return int(input())\n\n\ndef rints():\n return list(map(int, input().split()))\n\n\na, b, c, d = rints()\na, b, c = sorted([a, b, c])\nprint(max(d - (b - a), 0) + max(d - (c - b), 0))\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUX.out\",\"w\")\nL=list(map(int,input().split()))\nD=L.pop()\nL.sort()\nans=0\nif L[1]-L[0]<=D:\n\tans= ans+D-(L[1]-L[0])\nif L[2]-L[1]<=D:\n\tans=ans+D-(L[2]-L[1])\nprint(ans)"}, {"source_code": "a,b,c,d=map(int,input(\"\").split(\" \"))\nt=[]\nt.append(a)\nt.append(b)\nt.append(c)\nt.sort()\ncount=0\nif abs(t[0]-t[1]) [(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= 2*minVal ):\n if(arr[x]-arr[x-1] < minVal and arr[x+1]-arr[x] >= minVal + (minVal-(arr[x]-arr[x-1] < minVal)) ):\n time = time + (minVal-(arr[x]-arr[x-1] < minVal))\n arr[x]=arr[x]+ (minVal-(arr[x]-arr[x-1] < minVal))\n continue\n elif(arr[x]-arr[x-1] >= minVal + 1 and arr[x+1]-arr[x] < minVal + (minVal - (arr[x]-arr[x-1])) ):\n time = time +(minVal - (arr[x]-arr[x-1]))\n arr[x]=arr[x]-(minVal - (arr[x]-arr[x-1]))\n continue\n else:\n continue\n \n check=check+1\n \n if(check == len(arr)):\n break\n \nprint(time)"}, {"source_code": "a,b,c,d = map(int,raw_input().split())\nmi = min(a,b,c)\nma = max(a,b,c)\nme = a+b+c-mi-ma\nout = max(0,d-(me-mi))+max(0,d-(ma-me))\nprint out\n"}, {"source_code": "a,b,c,d = map(int,input().split())\nli = list()\nli.append(a)\nli.append(b)\nli.append(c)\nli.sort()\nd1 = li[1] - li[0]\nd2 = li[2] - li[1]\nif d1 >= d and d2 >= d:\n print(0)\nelif d1 >= d and d2 >= d:\n print(0)\nelif d1 >= d and d2 < d:\n x = li[1]+d\n diff = abs(x-li[2])\n print(diff)\nelif d1 < d and d2 >= d:\n x = li[1]-d\n diff = abs(li[0]-x)\n print(diff)\nelse:\n flag = 0\n if flag == 1:\n if d1 < d2:\n x = li[0]-d\n diff = abs(li[1]-x)\n print(diff)\n else:\n x = li[2]+d\n diff = abs(li[1]-x)\n print(diff)\n else:\n x1 = li[1]-d\n diff1 = abs(li[0]-x1)\n x2 = li[1]+d\n diff2 = abs(li[2]-x2)\n su = diff1+diff2\n print(su)\n"}, {"source_code": "from collections import Counter\nimport math\nfrom collections import Counter\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#for _ in range(int(input())):\nfrom collections import Counter\n#arr=list(map(int,input().split()))\n#n = int(input())\n#for _ in range(n):\na,b,c,d= map(int, input().split())\nl=[a,b,c]\nl.sort()\na=l[0]\nb=l[1]\nc=l[2]\nval1=max(0,d-(b-a))\nval2=max(0,d-(c-b))\nprint(val1+val2)\n\n\n\n\n\n"}, {"source_code": "import collections, heapq, math, sys\n\na,b,c,d = map(int, sys.stdin.readline().rstrip().split(' '))\n\na,b,c = sorted([a,b,c])\n\nlo = b - d\nhi = b + d\nsm = max(0, a - lo)\nsm += max(0, hi - c)\nprint(sm)"}, {"source_code": "\na,b,c,d=map(int,input().split())\nl=[a,b,c]\nl.sort()\na=l[0]\nb=l[1]\nc=l[2]\nx=d-b+a\ny=d-c+b\nif(x>=0 and y>=0):\n print(x+y)\nelif(x<0 and y>=0):\n print(y)\nelif(y<0 and x>=0):\n print(x)\nelif(x<0 and y<0):\n print(0)"}, {"source_code": "a, b, c, d = map(int, input().split())\na, b, c = sorted((a, b, c))\nans = max(0, d - (b - a)) + max(0, d - (c -b))\nprint(ans)"}, {"source_code": "a,b,c,d = list(map(int, input().split()))\nspisok=[a,b,c]\nspisok.sort()\ne=abs(spisok[1]-spisok[0])\nk=abs(spisok[2]-spisok[1])\nif el:\n ans+=a-l\nif r>c:\n ans+=r-c\nprint ans\n"}, {"source_code": "*a,d=map(int,input().split())\na,b,c=sorted(a)\n\nprint(max(0,(d-(b-a))+ max(0,d-(c-b))))"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nl=[a,b,c]\nl.sort()\nans=0\nfor i in xrange(len(l)-1):\n if l[i+1]-l[i]>=d:\n pass\n else:\n u=l[i+1]-l[i]\n v=d-u\n ans+=v\nprint ans"}, {"source_code": "a,b,c,d = map(int, input().split())\nnum_list = [a,b,c]\nnum_list.sort()\ncnt = 0\n\nif num_list[2]-num_list[1]= d and d2 >= d:\n print 0\n exit()\n\nx1 = max(0, d - d1)\nx2 = max(0, d - d2)\n\nprint x1 + x2\n\n"}, {"source_code": "#-------------Program--------------\n#----Kuzlyaev-Nikita-Codeforces----\n#-------------Training-------------\n#----------------------------------\n\na,b,c,d=map(int,input().split())\nl=[a,b,c];l.sort();a=l[0];b=l[1];c=l[2]\n\nprint(max(d-b+a,0)+max(0,d-c+b))"}, {"source_code": "a, b, c, d = map(int, input().split())\na, b, c = sorted([a, b, c])\nprint(max(d - (b - a), 0) + max(d - (c - b), 0))\n"}, {"source_code": "a,b,c,d = raw_input().split()\na,b,c,d = [int(a), int(b),int(c), int(d)]\n\nl = [a,b,c]\n\nl = sorted(l)\n\n\nsec= 0 \nif l[1] - l[0] < d:\n\tsec += d - (l[1] - l[0]) \n\t\nif l[2] - l[1] < d:\n\tsec += d - (l[2] - l[1])\n\t\n\t\nprint(sec)"}, {"source_code": "a, b, c, diff = [int(x) for x in input().split()]\na, b, c = sorted([a, b, c])\ndiff1 = b - a\ndiff2 = c - b\ncount = 0\nif diff1 < diff:\n count += diff - diff1\nif diff2 < diff:\n count += diff - diff2\nprint(count)"}, {"source_code": "a, b, c, d = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\nl = [a,b, c]\nl = sorted(l)\n# print(l)\nx = l[1] - l[0]\ny = l[2] - l[1]\nstep = 0\nwhile(y != d or x != d):\n if(x < d and y >= d):\n step += abs(d - x)\n break\n elif(x>=d and y 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 a,b,c,d=map(int,input().split())\n lis=[[a,1],[b,2],[c,3]]\n lis=sorted(lis)\n s=d-(lis[1][0]-lis[0][0])\n s2=d-(lis[2][0]-lis[1][0])\n print(max(s2,0)+max(s,0))\n \n \nif __name__ == '__main__':\n sync_with_stdio(False)\n main()\n \n "}, {"source_code": "\narr = [int(x) for x in raw_input().split()] \na, b, c, d = arr\n# a = input()\n# b = input()\n# c = input()\n# d = input()\n\nk = [a, b, c]\nk.sort()\na, b, c = k\n\nprint(max(0, d - abs(a-b) + max(0, d - abs(b - c))))"}, {"source_code": "a,b,c,d=[int(x) for x in input().split()]\nl=[a,b,c]\nl.sort()\nif l[2]-l[1]<=d and l[1]-l[0]<=d:\n\tprint(2*d-l[2]+l[0])\nelif l[2]-l[1]>d and l[1]-l[0]>d:\n\tprint(0)\nelse:\n\tprint(max((d-l[2]+l[1]),d-l[1]+l[0]))"}, {"source_code": "s=list(map(int,input().strip().split()))\nw=[]\nfor i in range(3):\n w.append(s[i])\nw.sort()\na=w[0]\nb=w[1]\nc=w[2]\nd=abs(b-a)\nif d=d and c - b < d:\n ans += d - (c-b)\nelif b-a=d:\n ans += d-(b-a)\nelse:\n ans = 0\nprint(ans)"}, {"source_code": "a, b, c, d = map(int, raw_input().split())\n\nl = [a, b, c]\nl.sort()\n\nprint max(d - abs(l[0] - l[1]) , 0 ) + max(d - abs(l[1] - l[2]) , 0 )\n"}, {"source_code": "\"\"\" \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 : 19.06.19\n\n\"\"\"\n\nfrom __future__ import division, print_function\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\nelse:\n _str = str\n str = lambda x=b\"\": x if type(x) is bytes else _str(x).encode()\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\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# 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 \n #for _ in range(ii()):\n \n \n a,b,c,d=mi()\n \n l=[a,b,c]\n l.sort()\n \n a=l[0]\n b=l[1]\n c=l[2]\n m=0\n if b-a=(a+b+c+d-min(a,b,c))/2 :\n print(2*min(a,b,c)+d+max(a,b,c)-(a+b+c))\nelse :\n print(min(a,b,c)-max(a,b,c)+2*d)"}, {"source_code": "a,b,c,d = map(int,input().split())\nkmax = max(a,b,c)\nkmin = min(a,b,c)\ni=0\nif ((kmax == a) and (kmin == b)) or ((kmax == b) and (kmin == a)):\n ks = c\nelif ((kmax == b) and (kmin == c)) or ((kmax == c) and (kmin == b)):\n ks = a\nelse:\n ks = b\nif abs(kmax-ks) < d:\n i+=abs(abs(kmax-ks)-d)\nif abs(abs(kmin-ks)-d) < d:\n i+=abs(abs(kmin-ks)-d)\nprint(i)\n"}, {"source_code": "a, b, c, d = map(int, input().split(\" \"))\ndancer = [a, b, c]\ndancer.sort()\ncounter = 0\ndistance = 0\nwhile abs(dancer[0] - dancer[1]) < d or abs(dancer[1] - dancer[2]) < d:\n if abs(dancer[0] - dancer[1]) <= abs(dancer[1] - dancer[2]):\n counter += d - abs(dancer[0] - dancer[1])\n dancer[0] += d - abs(dancer[0] - dancer[1])\n else:\n counter += d - abs(dancer[2] - dancer[1])\n dancer[2] += d - abs(dancer[2] - dancer[1])\n\nprint(counter)\n\n\n"}, {"source_code": "a, b ,c ,d = map(int,input().split()); x =[a, b ,c] ; x =sorted(x)\ntotal = max(0 , d -abs(a-b))+ max(0 , d-abs(b-c))\nprint(total)"}, {"source_code": "# your code goes here\n\na,b,c,d = map(int, input().split())\nnum_list = [a,b,c]\nnum_list.sort()\ncnt = 0\n\nwhile num_list[2]-num_list[1] <= d:\n num_list[2] +=1\n cnt += 1\n\nwhile num_list[1]-num_list[0] <= d:\n num_list[0] -= 1\n cnt +=1\n \nprint(cnt)"}, {"source_code": "a, b, c, d = [int(x) for x in input().split()]\na, b, c = sorted([a, b, c])\nprint( max(0, (d - a + b)) + max(0,( d - c + b))) \n"}, {"source_code": "a, b, c, d = map(int, input().split())\nx = list(sorted([a, b, c]))\nprint(sum([x[i + 1] - x[i] - d for i in range(2) if x[i + 1] - x[i] < d]))\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nl=[]\nl.append(a)\nl.append(b)\nl.append(c)\nl=sorted(l,reverse=True)\nmid=l[1] \nif (l[0]-l[2])//2>=d:\n ans=l[2]+d-mid \nelse:\n ans=l[2]-(mid-d)+(mid+d)-l[0]\nprint(ans)"}, {"source_code": "a,b,c,f=map(int,input().split())\nl=[a,b,c]\nl.sort()\nc=l[1]-l[0]\nd=l[2]-l[1]\nif(c==d and f>c):\n print((f-d)*2)\nelse:\n if(d>=f or f>=d):\n print(f-c)\n if(c>=f or f>=c):\n print(f-d)\n "}, {"source_code": "try:\n t=[]\n for i in range(3):\n a=int(input())\n t.append(a)\n d=int(input())\n t.sort()\n l=t[1]-t[0]\n r=t[2]-t[1]\n tm=0\n if lmax):\n second_max,max=max,second_max\n for i in range(2,len(list_of_numbers)):\n if(list_of_numbers[i]>=max):\n second_max=max\n max=list_of_numbers[i]\n elif list_of_numbers[i]>second_max: \n second_max=list_of_numbers[i]\n return second_max\n\nlist_of_numbers=list(map(int,input().split(' ')))\nd=list_of_numbers.pop()\nsecond_max=find_second_max(list_of_numbers)\nprint(second_max)\nlist_of_numbers.remove(second_max)\nsum=0\nprint(list_of_numbers)\nfor i in list_of_numbers:\n value=abs(i-second_max)\n if(value>d):\n sum=sum+0\n else:\n sum=sum+d-value\nprint(sum)"}, {"source_code": "a,b,c,d = map(int,input(). split())\nif max(a,b,c)>=(a+b+c+d-min(a,b,c))/2 :\n print(2*min(a,b,c)+d+max(a,b,c)-(a+b+c))\nelse :\n print(min(a,b,c)-max(a,b,c)+2*d)"}, {"source_code": "a, b, c, k = input().split()\nk = int(k)\na, b, c = sorted([int(a), int(b), int(c)])\n\nprint(abs((b - a) - k) + abs((c - b) - k))\n"}, {"source_code": "x=list(map(int,input().split()))\ny=sorted(x[0:3])\np=0\nfor i in range(2):\n if abs(y[0]-y[1])=(a+b+c+d-min(a,b,c))/2 :\n print(2*min(a,b,c)+d+max(a,b,c)-(a+b+c))\nelse :\n print(min(a,b,c)-max(a,b,c)+2*d)"}, {"source_code": "X=[int(x) for x in input().split(\" \")]\nd=X[-1]\nX=X[:-1]\nX.sort()\nprint(X)\nc=0\nif(X[1]-X[0]=d and k[2]-k[1]>=d:\n print(\"1\")\nelif k[1]-k[0]>=d and k[2]-k[1]=d:\n print(abs(d-(k[1]-k[0])))\nelif k[1]-k[0]= dif:\n return 0;\n cc = c[x] + dif - c[y];\n c[y] = c[x] + dif;\n return cc\n\ncount = 0\n\ncount += compare(0,1,d)\nc.sort()\ncount += compare(1,2,d)\nc.sort()\ncount += compare(0,2,d)\nprint(count)\n"}, {"source_code": "a=list(map(int,input().strip().split()))\nd=abs(a[1]-a[0])\nif dd:\n print(d-m4)\nelse:\n print(d+m4)"}, {"source_code": "a,b,c,d = input().split()\n\npos = [int(a),int(b),int(c)]\n\npos = sorted(pos)\nsec = 0\nif max(pos)-min(pos) < (int(d)*2):\n sec += (int(d)*2)-(max(pos)-min(pos))\n pos[-1] += sec\n\n\nif (pos[1] - pos[0]) < int(d) or (pos[1]-pos[0])>int(d):\n sec += abs((int(d) - (pos[1] - pos[0])))\n\nprint (sec)\n\n \n \n \n\n \n \n\n \n \n\n\n\n\n\n \n\n\n\n\n \n\n\n\n\n \n\n \n \n\n \n \n \n \n \n\n \n \n\n\n\n \n \n \n \n \n \n \n \n\n\n\n\n \n \n \n\n\n\n\n\n \n \n \n\n \n \n\n\n\n \n \n \n \n\n\n\n \n\n\n \n \n\n\n\n\n\n\n\n \n\n\n\n \n \n \n \n\n\n \n\n\n\n \n \n\n \n\n\n \n\n \n\n\n\n \n\n\n \n\n\n\n \n \n \n\n \n\n\n\n\n\n\n\n \n \n \n\n \n\n \n \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": "l = list(map(float, input().split()))\nd = l[3]\nl.pop()\nl.sort()\nans = 2*d - ((l[1] - l[0]) + (l[2] - l[1]))\nprint(int(ans))"}, {"source_code": "a,b,c,d=map(int,input().split())\nl=[]\nl.append(a)\nl.append(b)\nl.append(c)\nl=sorted(l,reverse=True)\nmid=l[1] \nif (l[0]-l[2])//2>=d:\n ans=l[2]+d-mid \nelse:\n ans=l[2]-(mid-d)+(mid+d)-l[0]\nprint(ans)"}, {"source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\nc = int(s[2])\nd = int(s[3])\nmaximum = max(max(a,b),max(b,c))\nminimum = min(min(a,b),min(b,c))\nprint(2*d-(maximum-minimum))"}, {"source_code": "a,b,c,d = map(int,input(). split())\nif max(a,b,c)>=(a+b+c+d-min(a,b,c))/2 :\n print(2*min(a,b,c)+d+max(a,b,c)-(a+b+c))\nelse :\n print(min(a,b,c)-max(a,b,c)+2*d)"}, {"source_code": "a, b, c, d=map(int, input().split())\n\ncount=0\nr0=abs(a-b);r1=abs(b-c)\nif r0= d and d2 >= d and d3 >= d:\n print(0)\nelif d1 >= d and d2 >= d:\n print(0)\nelif d1 >= d and d2 < d:\n x = li[1]+d\n diff = abs(x-li[2])\n print(diff)\nelif d1 < d and d2 >= d:\n x = li[1]-d\n diff = abs(li[0]-x)\n print(diff)\nelse:\n d3 = li[2] - li[0]\n if d3 >= d:\n if d1 < d2:\n x = li[0]-d\n diff = abs(li[1]-x)\n print(diff)\n else:\n x = li[2]+d\n diff = abs(li[1]-x)\n print(diff)\n else:\n x1 = li[1]-d\n diff1 = abs(li[0]-x1)\n x2 = li[1]+d\n diff2 = abs(li[2]-x2)\n su = diff1+diff2\n print(su)\n"}, {"source_code": "a,b,c,d=[int(x) for x in input().split()]\nl=[a,b,c]\nl.sort()\nprint(2*d-l[2]+l[0])"}, {"source_code": "a,b,c,d = list(map(int,input().split()))\naa = min([a,b,c])\ncc = max([a,b,c])\nprint((d<<1)-(cc-aa))\n\n"}, {"source_code": "a,b,c,d=list(map(int,input().split()))\nans=0\nif abs(a-b)s:\n return x-s\n return s-x\nq=x[0]\nb=x[1]\nc=x[2]\nx=sorted(x)\nmaj=0\n\nmaj+=a(q+d,b)\nmaj+=a(q+d+d,c)\nbz=maj\nmaj=0\nmaj+=a(b-d,q)\nmaj+=a(b+d,c)\nif maj= d and abs(b-c) >= d:\n print(0)\nelse:\n if abs(a-b) >= d and not abs(b-c) >= d:\n print(d-abs(b-c))\n elif abs(b-c) >= d and not abs(a-b) >= d:\n print(d - abs(a-b))\n else:\n print(d-abs(a-b) + d - abs(b-c))\n"}, {"source_code": "a = input().split()\nfor i in range(4):\n a[i] = int(a[i])\ndist = a[3]\na.pop(3)\na.sort()\nmid = a[1]\nmax = mid + dist\nmin = mid - dist\nif (max >= a[2]) and (min <= a[0]):\n time = (max - a[2]) + (a[0] - min)\nelif max < a[2]:\n time = a[0] - min\nelif min > a[0]:\n time = max - a[2]\nelse:\n time = 0\nprint(time)\n"}, {"source_code": "a, b, c, d = map(int, input().split())\nx = list(sorted([a, b, c]))\nprint(sum([x[i + 1] - x[i] - d for i in range(2) if x[i + 1] - x[i] < d]))\n"}, {"source_code": "\ndef fcuk(l, d):\n a=l[0]\n b=l[1]\n c=l[2]\n t=m=0\n if a>d or b-a>=d:\n t=d-(b-a)\n m=d-(c-b)\n if m<0:\n m=0\n if t<0:\n t=0\n return t+m\n else :\n t=a-1\n m=d-b+1\n n=0\n b=d+1\n if b>c:\n n=b-c\n else :\n n=0\n nn=n+d\n return nn+t+m \nx=list(map(int, input().split()))\nprint(fcuk(sorted(x[:3]), x[3]))"}, {"source_code": "a, b, c, d = [int(i) for i in input().split()]\n\nres = 0\n\nif a >= b and a <= c:\n x = abs(a-b)\n y = abs(a-c)\nelif b >= a and b <= c:\n x = abs(a - b)\n y = abs(b - c)\nelse:\n x = abs(a - c)\n y = abs(b - c)\n\nres += d - x if d - x > 0 else 0\nres += d - y if d - y > 0 else 0\nprint(res)\n"}, {"source_code": "a, b, c, g = input().split()\nd = int(g)\nar = [0,1,2]\nar[0] = (int(a))\nar[1] = (int(b))\nar[2] = (int(c))\nar.sort()\nprint(ar)\nsolution = 0\nif ar[1] - ar[0] < d:\n solution += d - (ar[1] - ar[0])\nif ar[2] - ar[1] < d:\n solution += d - (ar[2] - ar[1])\nprint(solution)"}, {"source_code": "sorted_list=list(int(x) for x in input().split())\nd=sorted_list.pop()\ncount=0\nsorted_list.sort()\nmin=sorted_list[0]\nmid=sorted_list[1]\nmax=sorted_list[2]\n\nif(mid-min)d:\n ans=l[2]+d-mid \nelse:\n ans=l[2]-(mid-d)+(mid+d)-l[0]\nprint(ans)"}, {"source_code": "import math\n\na, b, c, d = map(int, input().split())\nl = [a, b, c]\nl.sort()\na,b,c=l[0],l[1],l[2]\nprint(min(max(a+d-b,0)+max(a+2*d-c,0),max(a-(b-d),0)+max(b+d-c,0),max(a-(c-2*d),0)+max(b-(c-d),0)))\n"}, {"source_code": "a,b,c,d=list(map(int,input().split()))\nx=[a,b,c]\nx.sort(reverse=True)\nif x[0]-x[1]>=d and x[1]-x[2]>=d:\n\tprint(0)\nelse:\n\tif x[0]-x[1]max):\n second_max,max=max,second_max\n for i in range(2,len(list_of_numbers)):\n if(list_of_numbers[i]>=max):\n second_max=max\n max=list_of_numbers[i]\n elif list_of_numbers[i]>second_max: \n second_max=list_of_numbers[i]\n return second_max\n\nlist_of_numbers=list(map(int,input().split(' ')))\nd=list_of_numbers.pop()\nsecond_max=find_second_max(list_of_numbers)\nprint(second_max)\nlist_of_numbers.remove(second_max)\nsum=0\nprint(list_of_numbers)\nfor i in list_of_numbers:\n value=abs(i-second_max)\n if(value>d):\n sum=sum+0\n else:\n sum=sum+d-value\nprint(sum)"}, {"source_code": "a,b,c,d=map(int,input().split())\nl=[]\nl.append(a)\nl.append(b)\nl.append(c)\nl=sorted(l,reverse=True)\nmid=l[1] \nif (l[0]-l[2])//2>d:\n ans=l[2]+d-mid \nelse:\n ans=l[2]-(mid-d)+(mid+d)-l[0]\nprint(ans)"}, {"source_code": "a,b,c,d = map(int,input(). split())\nif max(a,b,c)>=(a+b+c+d-min(a,b,c))/2 :\n print(2*min(a,b,c)+d+max(a,b,c)-(a+b+c))\nelse :\n print(min(a,b,c)-max(a,b,c)+2*d)"}, {"source_code": "a,b,c,d=map(int,input().split(\" \"))\nls=[a,b,c]\nls=sorted(ls)\nans=0\nd1=abs(ls[1]-ls[0])\nif(d1=d) :\n x1=d\nelif x2>=d:\n x2=d\nprint(2*d-x1-x2)"}, {"source_code": "s = input().split()\na = int(s[0])\nb = int(s[1])\nc = int(s[2])\nd = int(s[3])\nmaximum = max(max(a,b),max(b,c))\nminimum = min(min(a,b),min(b,c))\nprint(2*d-(maximum-minimum))"}, {"source_code": "a,b,c,f=map(int,input().split())\nl=[a,b,c]\nl.sort()\nc=l[1]-l[0]\nd=l[2]-l[1]\nif(c==d and f>c):\n print((f-d)*2)\nelse:\n if(f>=d):\n print(f-c)\n if(f>=c):\n print(f-d)\n "}, {"source_code": "a, b, c, d = map(int, input().split())\n# A = list(map(int, input().split()))\n# a = int(input())\nif a <= b <= c or a >= b >= c:\n print(2 * d - abs(a - b) - abs(c - b))\nelif a <= c <= b or a >= c >= b:\n print(2 * d - abs(a - c) - abs(c - b))\nelse:\n print(2 * d - abs(a - c) - abs(a - b))"}, {"source_code": "a, b, c, k = input().split()\nk = int(k)\na, b, c = sorted([int(a), int(b), int(c)])\n\nprint(abs((b - a) - k) + abs((c - b) - k))\n"}, {"source_code": "a,b,c,d = map(int, input().split())\nnums = list()\nnums.append(a)\nnums.append(b)\nnums.append(c)\nnums.sort()\na = nums[0]\nb = nums[1]\nc = nums[2]\nmove = 0\nwhile (b-a) <= d:\n\ta-=1\n\tmove += 1\nwhile (c-d) <= d:\n\tc += 1\n\tmove += 1\nprint(move)"}, {"source_code": "a,b,c,d=map(int,input().split())\nl=[]\nl.append(a)\nl.append(b)\nl.append(c)\nl=sorted(l,reverse=True)\nmid=l[1] \nif (l[0]-l[2])//2>=d:\n ans=l[2]+d-mid \nelse:\n ans=l[2]-(mid-d)+(mid+d)-l[0]\nprint(ans)"}, {"source_code": "l = list(map(int, input().split()))\nd = l[3]\nl.pop()\nl.sort()\nans = 2*d - ((l[1] - l[0]) + (l[2] - l[1]))\nprint(ans)"}, {"source_code": "a, b, c, d = map(int, input().split())\nfirst = min(a, min(b, c))\nlast = max(a, max(b, c))\nmiddle = a+b+c-first-last\nprint(first, middle, last)\nif middle-first < d and last-middle < d:\n print((d-(middle-first))+(d-(last-middle)))\nelif middle-first >= d:\n print((d - (last - middle)))\nelif last-middle >= d:\n print((d-(middle-first)))\n"}, {"source_code": "l = [int(i) for i in input().split()]\nfl = 0\nd = l[3]\ndel l[3]\nl = sorted(l)\nif l[1] - l[0] <= d:\n a = l[1]-l[0]\n b = d - a\n fl += b\n l[1] += b\nl = sorted(l)\nif l[2] - l[1] <= d:\n a = l[2]-l[1]\n b = d - a\n fl += b\n l[2] += b\nprint(fl)"}, {"source_code": "l = [int(i) for i in input().split()]\nfl = 0\nd = l[3]\ndel l[3]\nl = sorted(l)\nprint(d, l)\nwhile abs(l[0]-l[1]) < d:\n l[1] += 1\n fl += 1\nl = sorted(l)\nwhile abs(l[1]-l[2]) < d:\n l[2] += 1\n fl += 1\nprint(fl)"}, {"source_code": "a, b, c, d = map(int, input().split())\nfirst = min(a, min(b, c))\nlast = max(a, max(b, c))\nmiddle = a+b+c-first-last\nprint(first, middle, last)\nif middle-first < d and last-middle < d:\n print((d-(middle-first))+(d-(last-middle)))\nelif middle-first >= d:\n print((d - (last - middle)))\nelif last-middle >= d:\n print((d-(middle-first)))\n"}, {"source_code": "a=list(map(int,input().strip().split()))\nd=abs(a[1]-a[0])\nif d= a[2]) and (min <= a[0]):\n time = (max - a[2]) + (a[0] - min)\nelif max < a[2]:\n time = a[0] - min\nelif min > a[0]:\n time = max - a[2]\nelse:\n time = 0\nprint(time)\n"}, {"source_code": "a,b,c,d=map(int, input().split())\nl=sorted(list((a,b,c)))\ntime_t=0\nif not l[1]>=(d+l[0]):\n\ttime_t+=(d-(l[1]-l[0]))\nif not l[2]>=((d*2)+l[0]):\n\ttime_t+=(d-(l[2]-l[0]))\nprint(time_t)"}, {"source_code": "l = [int(i) for i in input().split()]\nfl = 0\nd = l[3]\ndel l[3]\nl = sorted(l)\nif l[1] - l[0] <= d:\n fl += d - (l[1]-l[0])\n #l[1] += d - (l[1]-l[0])\nl = sorted(l)\nprint(l)\nif fl == l[0]:\n l[2], l[0] = l[0], l[2]\nif l[2] - l[1] <= d:\n fl += d - (l[2]-l[1])\n #l[2] += d - (l[2]-l[1])\nprint(fl)"}, {"source_code": "a,b,c,n = map(int,input().split())\nk = []\nk.append(a)\nk.append(b)\nk.append(c)\nk.sort()\nans = 0\nfor i in range(1,len(k)):\n y = abs(k[i-1]-k[i])\n if(y b:\n a, b = b, a\nif b > c:\n b, c = c, b\nd1 = b-a\nd2 = c-b\nk1=0\nk2=0\nif d1 >=d and d2>=d:\n print(0)\nelif (d1-d)<0 or (d2-d)<0:\n if d1-d < 0:\n k1 = d-d1\n if d2-d <0:\n k2 = d-d2\n print(k1+k2)"}, {"source_code": "a , b , c ,d =map (int ,input().split())\nq=[]\nres=0\nq.append(a)\nq.append(b)\nq.append(c)\nq=sorted(q)\nres+=d-abs(q[1]-q[0])\nres+=d-abs(q[1]-q[2])\nprint(res)"}, {"source_code": "x=list(map(int,input().split()))\nd=int(x[3])\nx=x[:3]\nx=sorted(x)\ndef a(x,s):\n if x>s:\n return x-s\n return s-x\nq=x[0]\nb=x[1]\nc=x[2]\nx=sorted(x)\nmaj=0\n\nmaj+=a(q+d,b)\nmaj+=a(q+d+d,c)\nbz=maj\nmaj=0\nmaj+=a(b-d,q)\nmaj+=a(b+d,c)\nif maj=d) :\n x1=d\nelif x2>=d:\n x2=d\nprint(2*d-x1-x2)"}, {"source_code": "a,b,c,f=map(int,input().split())\nl=[a,b,c]\nl.sort()\nc=l[1]-l[0]\nd=l[2]-l[1]\nif(c==d and f>c):\n print((f-d)*2)\nelse:\n if(d>=f):\n print(f-c)\n if(c>=f):\n print(f-d)\n "}, {"source_code": "a,b,c,d = map(int,input().split())\nli = list()\nli.append(a)\nli.append(b)\nli.append(c)\nli.sort()\nd1 = li[1] - li[0]\nd2 = li[2] - li[1]\nif d1 >= d and d2 >= d:\n print(0)\nelif d1 >= d and d2 >= d:\n print(0)\nelif d1 >= d and d2 < d:\n x = li[1]+d\n diff = abs(x-li[2])\n print(diff)\nelif d1 < d and d2 >= d:\n x = li[1]-d\n diff = abs(li[0]-x)\n print(diff)\nelse:\n d3 = li[2] - li[0]\n if d3 >= d:\n if d1 < d2:\n x = li[0]-d\n diff = abs(li[1]-x)\n print(diff)\n else:\n x = li[2]+d\n diff = abs(li[1]-x)\n print(diff)\n else:\n x1 = li[1]-d\n diff1 = abs(li[0]-x1)\n x2 = li[1]+d\n diff2 = abs(li[2]-x2)\n su = diff1+diff2\n print(su)\n"}, {"source_code": "a, b, c, d = map(int, input().split(\" \"))\ndancer = [a, b, c]\ndancer.sort()\ncounter = 0\ndistance = 0\nwhile abs(dancer[0] - dancer[1]) < d or abs(dancer[1] - dancer[2]) < d:\n if abs(dancer[0] - dancer[1]) <= abs(dancer[1] - dancer[2]):\n counter += d - abs(dancer[0] - dancer[1])\n dancer[0] += d - abs(dancer[0] - dancer[1])\n else:\n counter += d - abs(dancer[2] - dancer[1])\n dancer[2] += d - abs(dancer[2] - dancer[1])\n\nprint(counter)\n\n\n"}, {"source_code": "from math import fabs\ndef u(x):\n if x <= 0:\n return 0\n return x\na, b, c, d = list(map(int, input().split()))\nm = sorted([a, b, c])\nprint(u(d - fabs(m[1] - m[0])) + u(d - fabs(m[2] - m[1])))"}, {"source_code": "a,b,c,d= map(int,input().split(\" \"))\n\nl=[a,b,c]\n#print (l)\n#print (d)\nl.sort()\nt=0\nif (d-(l[1]-l[0]))>0:\n t+=(d-(l[1]-l[0]))\nif (d-(l[2]-l[1]))>0:\n t=+(d-(l[2]-l[1]))\nprint (t)\n "}, {"source_code": "a, b, c, d = map(int, input().split())\nmylist = [a, b, c]\nmylist.sort()\nmoveL = []\nmincor = mylist[0]\navecor = mylist[1]\nmaxcor = mylist[2]\n\n#first move\nif mylist[1] - mylist[0] < d:\n mincor = avecor - d\n\nif mylist[2] - mylist[1] < d:\n maxcor = avecor + d\n\nmove = (mylist[0] - mincor) + (maxcor - mylist[2])\nmoveL.append(move)\n\nmincor = mylist[0]\navecor = mylist[1]\nmaxcor = mylist[2]\n#second move\nif mylist[1] - mylist[0] < d:\n avecor = mincor + d\n\nif mylist[2] - avecor < d:\n maxcor = avecor + d\n\nmove = ((avecor - mylist[1]) + (maxcor - mylist[2]))\nmoveL.append(move)\n\nmincor = mylist[0]\navecor = mylist[1]\nmaxcor = mylist[2]\n#third move\nif mylist[2] - mylist[1] < d:\n avecor = maxcor - d\n\nif mylist[1] - avecor < d:\n mincor = avecor - d\n\nmove = ((mylist[1] - avecor) + (mylist[0] - mincor))\nmoveL.append(move)\n\nprint(min(moveL))"}, {"source_code": "import math\n\na, b, c, d = map(int, input().split())\nl = [a, b, c]\nl.sort()\na,b,c=l[0],l[1],l[2]\nprint(min(max(a+d-b,0)+max(a+2*d-c,0),max(a-(b-d),0)+max(b+d-c,0),max(a-(c-2*d),0)+max(b-(c-d),0)))\n"}, {"source_code": "abcd = input().split()\nabc = abcd[0:3]\nabc.sort()\na = int(abc[0])\nb = int(abc[1])\nc = int(abc[2])\nd = int(abcd[3])\n\nif abs(a-b) >= d and abs(b-c) >= d:\n print(0)\nelse:\n if abs(a-b) >= d and not abs(b-c) >= d:\n print(d-abs(b-c))\n elif abs(b-c) >= d and not abs(a-b) >= d:\n print(d - abs(a-b))\n else:\n print(d-abs(a-b) + d - abs(b-c))\n"}], "src_uid": "47c07e46517dbc937e2e779ec0d74eb3"} {"nl": {"description": "Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled \"a\" to \"z\", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some \"special edition\" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has?Please help Haruhi solve this problem.", "input_spec": "The first line of input will be a single string s (1\u2009\u2264\u2009|s|\u2009\u2264\u200920). String s consists only of lowercase English letters. ", "output_spec": "Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make.", "sample_inputs": ["a", "hi"], "sample_outputs": ["51", "76"], "notes": "NoteIn the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. "}, "positive_code": [{"source_code": "n=input()\nprint(26+len(n)+24*len(n))"}, {"source_code": "s = input()\nd = set()\nfor i in range(ord('a'), ord('z') + 1):\n for j in range(len(s)+1):\n d.add(s[:j] + chr(i) + s[j:])\nprint(len(d))"}, {"source_code": "s = input()\nl = len(s)\nprint(26+25*l)\n"}, {"source_code": "s = input()\nprint(26*(len(s)+1) - len(s))"}, {"source_code": "print(len(input())*25+26)"}, {"source_code": "n = len(raw_input())\n\nprint (n+1)*26 - n\n"}, {"source_code": "s = raw_input()\nl = len(s)\nprint l*25+26\n"}, {"source_code": "s=input().strip('\\n')\nn=len(s)\nprint(26*(n+1)-n)\n"}, {"source_code": "n = input()\nprint ((len(n) + 1) * 25 + 1);"}, {"source_code": "s=raw_input()\nprint len(set(s[:i]+j+s[i:] for i in range(len(s)+1) for j in 'abcdefghijklmnopqrstuvwxyz'))"}, {"source_code": "if __name__ == '__main__':\n s = input()\n print(int((len(s) + 1) * 26 - len(s)))\n"}, {"source_code": "print(25*len(input())+26)\n"}, {"source_code": "n=input()\nprint(25*len(n)+26)"}, {"source_code": "s = input()\nprint(len(s)*25+26)"}, {"source_code": "# -*- coding:utf-8 -*-\nimport sys\nimport math\n\ndef some_func():\n \"\"\"\n \"\"\"\n\n n_list = map(str,sys.stdin.readline().split())[0]\n cache = {}\n\n for l in range(ord('a'),ord('z')+1):\n for k in range(len(n_list)+1):\n\n data = ''.join( [n_list[0:k],chr(l),n_list[k:]])\n cache[data]=1\n print len(cache)\n\n\n\n\n\n\nif __name__ == '__main__':\n some_func()\n\n\n\n\n\n"}, {"source_code": "s = raw_input()\nl = len(s)\nprint l*25+26\n"}, {"source_code": "n=input()\na=26\nfor i in range(len(n)):\n\ta+=25\nprint(a)\t"}, {"source_code": "print(len(input())*25+26)"}, {"source_code": "a=input()\nc=0\nfor i in range(97,123):\n\tx=a.count(chr(i))\n\tif x>1:\n\t c+=x-1\n\nz=(26*(len(a)+1))-len(a)\nprint(z)\n"}, {"source_code": "s=raw_input().strip()\nprint (len(s)+1)*25 + 1"}, {"source_code": "s=input()\nl=len(s)\nprint((26-l)+(26)*l)"}, {"source_code": "ins = raw_input()\nlin = len(ins)\nprint (lin + 1) * 26 - (lin) "}, {"source_code": "alpha=[chr(x) for x in range(97,97+26)]\ns=raw_input()\nn=len(s)\nphotobooks=[]\nfor i in xrange(n+1):\n for j in alpha:\n t=s[:i]+str(j)+s[i:]\n photobooks.append(t)\nphotobooks=set(photobooks)\nans=len(photobooks)\nprint ans\n\n"}, {"source_code": "print 25*len(raw_input()) + 26\n"}, {"source_code": "s=input()\nn=len(s)\nans=(n+1)*(26-n)\nans+=pow(n,2)\nprint(ans)"}, {"source_code": "n = input()\nprint((len(n)+1)*26-len(n))"}, {"source_code": "a=input()\nans=0\nfor i in range(len(a)+1):\n ans+=26\nprint(ans-len(a)) "}, {"source_code": "x = input()\nprint((len(x)+1) * 25 + 1)"}, {"source_code": "import math, string\n\ns = raw_input()\na = [-1]\nk = 0\nfor i in s:\n if a[k] == -1:\n prev = i\n a[k] = 1\n else:\n if i == prev:\n a[k] += 1\n else:\n k += 1\n a.append(1)\n prev = i\nif k == 0:\n ans = (a[k]+1)*25 + 1\nelse:\n ans = 25\n for i in a:\n ans += i*25\n ans += 1\n\nprint ans\n \n \n \n"}, {"source_code": "s = list(input())\nn = len(s)\ndef haz(a):\n a = a.copy()\n for i in range(len(a)):\n if a.count(a[i])>1:\n a[i] = 0\n return a\ndef ins(a,b):\n a = a.copy()\n d = a.copy()\n b = h(haz(b))\n b = b.copy()\n f = []\n for i in range(len(a)+1):\n for l in range(len(b)):\n a = d.copy()\n a.insert(i,b[l])\n f+=[a]\n return f\ndef h(a):\n i = 0\n a = a.copy()\n while 0 in a:\n a.remove(0)\n return a\nk = (n+1)*26\nf = ins(s,s)\nb = len(f)\nf = h(haz(f))\nc = len(f)\nk = k-(b-c)\nprint(k)\n"}, {"source_code": "__author__ = 'trunghieu11'\n\nfrom string import ascii_lowercase\n\ndef main():\n s = raw_input()\n books = set()\n for i in range(len(s) + 1):\n for c in ascii_lowercase:\n books.add(s[:i] + c + s[i:])\n print len(books)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "\nent = raw_input()\n\nres = (26 * (len(ent.strip())+1)) - len(ent.strip())\n\nprint res"}, {"source_code": "print(len(input()) * 25 + 26)"}, {"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'''\ns=input()\nn=len(s)\nif(n>1):\n a=(26)*(n+1)-(n)\nelse:\n a=(26)*(n+1)-n\nprint(a)"}, {"source_code": "a = input()\nprint(26 * (len(a) + 1) - len(a))"}, {"source_code": "s = raw_input()\ns = list(s)\nl = len(s)\nar = []\n\nls = ['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\nfor i in ls:\n for j in range(l+1):\n s.insert(j,i)\n temp = s[:]\n if s not in ar:\n ar.append(temp)\n del s[j]\n\nprint len(ar)\n"}, {"source_code": "n = len(raw_input())\n\nprint (n + 1) * 26 - n"}, {"source_code": "print(25*len(input())+26)"}, {"source_code": "n=input()\nprint(26+len(n)+24*len(n))"}, {"source_code": "import sys\nfrom collections import Counter\nfrom math import factorial\n\ninput = sys.stdin\noutput = sys.stdout\n\n# input = open('input.txt')\n# some changes\n\ndef read_int():\n return [int(x) for x in input.readline().rstrip().split()]\n\n\ns = input.readline().rstrip()\nspes = set()\nfor i in xrange(len(s) + 1):\n for c in 'abcdefghijklmnopqrstuvwxyz':\n spes.add(s[:i] + c + s[i:])\nanswer = len(spes)\noutput.write('%d\\n' % answer)\n\n\n\n\n\n\n"}, {"source_code": "s=input()\nprint(26*(len(s)+1)-len(s))"}, {"source_code": "s = input()\nn = len(s)\nans = n * 25 + 26\nprint(ans)"}, {"source_code": "s = raw_input()\n\nq = set()\n\n\nfor i in xrange(len(s)+1):\n for j in xrange(97,123):\n q.add(s[:i]+chr(j)+s[i:])\n \nprint len(q)\n"}, {"source_code": "s=input()\nn=len(s)+1\nl=n-1\nprint(n*26-l)\n"}, {"source_code": "s= str(input())\nprint((len(s)+1)*26 - len(s))\n"}, {"source_code": "# KOYOYA AND PHOTOBOOKS\n# Estacio Pereira, estacio.neto@ccc.ufcg.edu.br\n# UFCG\n\nl = list(raw_input())\nj = 0\nk = 0\nv = []\nresult = 0\nn = ['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(l) + 1) * 26):\n l.insert(j / 26, n[k % 26])\n if not l in v:\n v.append(l[:])\n result += 1\n l.pop(j / 26)\n k += 1\n j += 1\nprint result\n"}, {"source_code": "print 1 + 25 * (1 + len(raw_input()))"}, {"source_code": "s=len(input())\nprint(26*(s+1) - s)"}, {"source_code": "s=raw_input()\nli=list(s)\nli1=set(li)\ns2=\"\"\nli1=list(li)\nx=len(li)-len(li1)\nfor i in range(len(li1)):\n s2+=li1[i]\nprint (26*(len(s2)+1)-(len(s2))+x*25)\n"}, {"source_code": "#-------------Program--------------\n#----Kuzlyaev-Nikita-Codeforces----\n#-------------Training-------------\n#----------------------------------\n\ns=str(input())\nprint(26*len(s+\"s\")-len(s))"}, {"source_code": "case=raw_input()\nn=len(case)\nprint 26*(n+1)-n"}, {"source_code": "a = list(input())\nk = set()\nfor i in range(len(a)+1):\n for l in range(ord(\"a\"),ord(\"z\")+1):\n t = a[:]\n t.insert(i,chr(l))\n k.add(\"\".join(t))\nprint(len(k))\n"}, {"source_code": "s = input()\nprint(len(s) * 25 + 26)"}, {"source_code": "import sys\n\n\n\n\ndef main():\n #grab input\n testVar = raw_input()\n length = len(testVar)+1\n print (26*length-len(testVar))\n\n\nmain()\n"}, {"source_code": "#!/usr/bin/env python3\n\nif __name__ == '__main__':\n s = input()\n print(26 + 26*len(s) - len(s))\n\n\n"}, {"source_code": "S = input()\nprint(26 * (len(S)+1) -len(S) )"}, {"source_code": "s = input()\na = []\nfor i in s:\n if i not in a:\n a.append(i)\nprint(len(s)*25+26)"}, {"source_code": "a=raw_input()\nd={}\n\"\"\"for c in a:\n if c in d:\n d[c]+=1\n else:\n d[c]=1\n\"\"\"\nprint (len(a)+1)*25+1"}, {"source_code": "s = input()\nl = len(s)\nprint(26+25*l)\n"}, {"source_code": "import sys\n\n\n\n\ndef main():\n #grab input\n testVar = raw_input()\n length = len(testVar)+1\n print (26*length-len(testVar))\n\n\nmain()\n"}, {"source_code": "a = input()\nprint((26*(len(a)+1))-len(a))"}, {"source_code": "s = input()\nprint(25*len(s)+26)"}, {"source_code": "s = raw_input()\nprint len(set([s[:x]+chr(i)+s[x:] for i in xrange(97, 123) for x in xrange(len(s)+1)]))\n\n"}, {"source_code": "print 25*len(raw_input())+26"}, {"source_code": "print(25*len(input())+26)\n"}, {"source_code": "n = input()\nans = 26\nq = 25\nfor i in range(len(n)):\n ans += q\nprint(ans)"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\n\ns = raw_input()\nans = set()\nfor c in alpha:\n for i in xrange(len(s) + 1):\n ans.add(s[:i] + c + s[i:])\nprint len(ans)\n"}, {"source_code": "print (25*len(input())+26)\n"}, {"source_code": "ss = input()\nprint(26*(len(ss)+1)-len(ss))"}, {"source_code": "s = input()\nprint(len(s) * 25 + 26)"}, {"source_code": "s = input()\npos = len(s) + 1\nprint(26*(pos) - len(s))"}, {"source_code": "l = raw_input()\nprint(25*len(l) + 26)"}, {"source_code": "l = len(raw_input())\n\ns = (l + 1) * 26 - l\nprint s \n"}, {"source_code": "s = input()\nprint(len(s) * 25 + 26)"}, {"source_code": "def from_same_letters(word):\n\tif len(word) == 0:\n\t\treturn True\n\n\tchar = word[0]\n\n\tfor letter in word:\n\t\tif letter != char:\n\t\t\treturn False\n\n\treturn True\n\nletters = input()\nresult = int(51)\n\nfor i in range(len(letters) - 1):\n\tresult += 25;\n\n\tif letters[i + 1] != letters[i]:\n\t\t++result;\n\nprint(result)\n"}, {"source_code": "s = input()\nprint(26 + 25 * len(s))"}, {"source_code": "def GetDIstinctPhotos():\n n = raw_input()\n print 26*(len(n)+1) - len(n)\n\nGetDIstinctPhotos()\n"}, {"source_code": "LettersString = input(\"\")\nAlfabet = \"abcdefghijklmnopqrstuvwxyz\"\nCombinaties = set()\n\n\nfor x in range(0,len(LettersString)+1):\n for y in range(0, 26):\n Combinaties.add(LettersString[0:x]+Alfabet[y]+LettersString[x:len(LettersString)])\n\nprint (len(Combinaties))\n"}, {"source_code": "s = list(input())\nprint(26*(len(s)+1)-len(s))\n"}, {"source_code": "a=input()\nc=0\nfor i in range(97,123):\n\tx=a.count(chr(i))\n\tif x>1:\n\t c+=x-1\n\nz=(26*(len(a)+1))-len(a)\nprint(z)\n"}, {"source_code": "s=input()\nn=len(s)+1\nl=n-1\nprint(n*26-l)\n"}, {"source_code": "s=input()\nprint(26*(len(s)+1)-len(s))"}, {"source_code": "s = input()\n\nprint( (len(s) + 1) * (26 - len(s)) + len(s) ** 2 )\n\n\n\n"}, {"source_code": "s = str(input()); print(26+len(s)*25)"}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 30 15:37:38 2020\n\n@author: PREET MODH\n\"\"\"\n\n\ns=list(input())\nprint(str(26 + len(s)*25))"}, {"source_code": "n = input()\nans = 26;\nfor i in n:\n ans += 25\nprint(ans)"}, {"source_code": "l = len(raw_input())\nprint (l + 1) * 26 - l"}, {"source_code": "from sys import stdin\ns=stdin.readline().rstrip(\"\\n\")\nprint (s.__len__()+1)*26-s.__len__()"}, {"source_code": "chars = list(input())\nl = len(chars)\nprint(26 * (l + 1) - l)"}, {"source_code": "s = input()\na2z = sorted(\"qwertyuiopasdfghjklzxcvbnm\")\nst = set()\nfor i in range(len(s)):\n first = s[:i]\n second = s[i:]\n for c in a2z:\n st.add(first + c + second)\nfor c in a2z:\n st.add(s + c)\nprint(len(st))"}, {"source_code": "s = raw_input()\nprint len(s) * 25 + 26\n"}, {"source_code": "print len(raw_input())*25+26\n"}, {"source_code": "s = input()\nl = len(s)\nprint(26+25*l)\n"}, {"source_code": "a= len(str(input()))\nprint(26*(a+1)-a)"}, {"source_code": "t=raw_input()\nl=len(t)\nprint (l+1)*26-l"}, {"source_code": "l = input()\nprint(51+25*(len(l)-1))"}, {"source_code": "# -*- coding: utf-8 -*-\nimport sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll\n\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\n\ns = raw_input()\nans = set()\nfor c in alpha:\n for i in xrange(len(s) + 1):\n ans.add(s[:i] + c + s[i:])\nprint len(ans)\n"}, {"source_code": "__author__ = 'vasiliy.lomanov'\n\ns = raw_input()\n\nlength = len(s)\nif length == 1:\n print(51)\n exit()\n\nn = 51\n\nprLetter = ''\nfor i in xrange(length-1):\n c = s[i]\n if c == prLetter:\n continue\n prLetter = c\n serieLen = 1\n k = i+1\n while c == s[k] and k < length-1:\n serieLen += 1\n k+=1\n\n n += (serieLen-1)*25\n\n n += 25\n\n\nprint(n)"}, {"source_code": "n=raw_input()\nprint (len(n)+1)*26-len(n)\n"}, {"source_code": "booklet = input()\n\nprint((25 * len(booklet)) + 26)\n"}], "negative_code": [{"source_code": "n=raw_input()\nprint 26*(len(n)+1)-1"}, {"source_code": "s = raw_input()\n\nq = list(s)\n\ni = 1\nc = s[0]\nwhile i=2:\n print((len(d)+1)*26-2)\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "import itertools\n\n\n\n\ndef main():\n n = input()\n d = n[0]\n for c in n[1:]:\n if c==d[-1]:\n continue\n else:\n d+=c\n if len(d)==1:\n print(51)\n if len(d)>=2:\n print((len(d)+1)*26-len(d))\n\n\nif __name__ == \"__main__\":\n main()\n"}, {"source_code": "def photobooks(a):\n if a is None or len(a) == 0:\n return 0\n \n if len(a) % 2 == 0:\n return (len(a) + 1) * 25 + 1\n else:\n return (len(a) + 1) * 25 - 1\n\nprint(photobooks(str(input())))"}, {"source_code": "l = input()\nif (len(l) == 1):\n\tprint(51)\nelse:\n\tr = 26\n\tfor i in range(0,len(l)-1):\n\t\tif (l[i] != l[i+1]):\n\t\t\tr += 24\n\t\telse:\n\t\t\tr += 25\n\tr += 26\n\tprint(r)"}, {"source_code": "l = input()\nif (len(l) == 1):\n print(51)\nelif (len(l) == 2):\n print(76)\nelse:\n r = 26\n for i in range(0,len(l)-1):\n if (l[i] != l[i+1]):\n r += 24\n else:\n r += 25\n r += 26 if l[0] != l[i-1] else 25\n \n print(r)"}, {"source_code": "s=input()\nplaces=len(s)+1\nprint( ( (26-len(s) )*places )+len(s)*(places-2))"}, {"source_code": "photobook = str(input())\n\nletters = set(photobook)\nprint(26 * (len(photobook) +1) - len(letters))\n"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"OUTPUX.out\",\"w\")\nL=list(input())\nS=set(L)\nans=((len(L)+1)*26)-len(S)\nprint(ans)\n"}, {"source_code": "s=len(input())\nprint(s*26-(s-1))\n"}, {"source_code": "s=len(input())\nprint((s+1)*26-(s-1))\n"}, {"source_code": "n=input()\n\np=len(n)\nif len(set(n))==1:\n print(25*(p+1)+1)\nelse:\n print((26)*(p+1))\n"}, {"source_code": "PRIME_COUNT = 10 ** 6\nis_prime = [True] * PRIME_COUNT\nprimes = [] \nfor i in range(2, 1000):\n if is_prime[i]:\n for j in range(i * i, PRIME_COUNT, i):\n is_prime[j] = False\nfor i in range(len(is_prime)):\n if is_prime[i]:\n primes.append(i)\n"}, {"source_code": "photos = raw_input()\nno_repeat = []\n\nfor i in photos:\n if not i in no_repeat:\n no_repeat.append(i)\n\nresult = 26 * (len(photos) + 1) - len(no_repeat)\nprint result"}, {"source_code": "from string import ascii_lowercase\n\nalphaList = list(ascii_lowercase)\nALPHALEN = 26\noString = raw_input()\noStringLen = len(oString)\nresultList = set()\n\nfor i in range(oStringLen+1):\n for j in range(ALPHALEN):\n\tnewString = oString[:i] + alphaList[j] + oString[i:]\n\tprint newString\n\tresultList.add(newString)\n\nprint len(resultList)\n"}, {"source_code": "__author__ = 'vasiliy.lomanov'\n\ns = raw_input()\n\nlength = len(s)\nif length == 1:\n print(51)\n exit()\n\nn = 51\n\nfor i in xrange(length-1):\n c = s[i]\n serieLen = 1\n k = i+1\n while c == s[k] and k < length-1:\n serieLen += 1\n k+=1\n\n n += (serieLen-1)*25\n\n n += 25\n\n\nprint(n)"}, {"source_code": "__author__ = 'vasiliy.lomanov'\n\ns = raw_input()\n\nlength = len(s)\nif length == 1:\n print(51)\n exit()\n\nn = 52\n\nfor i in xrange(length-1):\n c = s[i]\n serieLen = 1\n k = i+1\n while c == s[k] and k < length-1:\n serieLen += 1\n k+=1\n\n n += (serieLen-1)*25\n\n n += 24\n\n\nprint(n)"}, {"source_code": "__author__ = 'vasiliy.lomanov'\n\ns = raw_input()\n\nlength = len(s)\nif length == 1:\n print(51)\n exit()\n\nn = 50\n\nfor i in xrange(length-1):\n c = s[i]\n serieLen = 1\n k = i+1\n while c == s[k] and k < length-1:\n serieLen += 1\n k+=1\n\n n += (serieLen-1)*25\n\n n += 24\n\n\nprint(n)"}, {"source_code": "s = raw_input()\nlen1 = len(s)\na = []\na.extend(s)\naf = []\nfor i in a:\n if i not in af:\n af.append(i)\nlen2 = len(af)\nprint ((len1+1)*26 - len2)\n"}, {"source_code": "s=raw_input()\nli=list(s)\nli=set(li)\ns2=\"\"\nli1=list(li)\nx=len(li)-len(li)\nfor i in range(len(li1)):\n s2+=li1[i]\nprint (26*(len(s2)+1)-(len(s2))+x*25)\n"}, {"source_code": "s=raw_input()\nprint (26*(len(s)+2)-(len(s)))\n"}, {"source_code": "s=raw_input()\nli=list(s)\nli=set(li)\ns2=\"\"\nli=list(li)\nfor i in range(len(li)):\n s2+=li[i]\nprint (26*(len(s2)+2)-(len(s2)))\n"}, {"source_code": "s=raw_input()\nli=list(s)\nli=set(li)\ns2=\"\"\nli=list(li)\nfor i in range(len(li)):\n s2+=li[i]\nprint (26*(len(s2)+1)-(len(s2)))\n"}, {"source_code": "s=raw_input()\nprint (26*(len(s)+2)-(len(s)-1))"}, {"source_code": "from math import factorial\n\ns = raw_input()\ns = list(s)\n\nn1 = len(list(set(s)))\nprint (26 - n1)*(len(s)+1) + factorial(len(s) + 1)/(factorial(len(s) + 1 - n1)) - n1"}, {"source_code": "from sys import stdin\n\nstring = stdin.readline()\nprint(len(string) * 26 - 1)"}, {"source_code": "s=raw_input()\n\nn=len(s)\nprint (25*n)+1\n\n"}, {"source_code": "s = raw_input()\nl = len(s)\n\nprint l * 25 + 1\n"}, {"source_code": "#!/usr/bin/python\n\ns = raw_input()\nif (len(s) < 27):\n n = len(s)\nelse: n = 26\n\nsum = 26\nalfa = 25\n\nfor x in range(0,n):\n sum += alfa\n alfa -= 1\n\nif (n > 1):\n sum += 1\nprint sum\n"}, {"source_code": "# KOYOYA AND PHOTOBOOKS\n# Estacio Pereira, estacio.neto@ccc.ufcg.edu.br\n# UFCG\n\nl = list(raw_input())\nj = 0\nk = 0\nv = []\nresult = 0\nn = ['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(l) + 1) * 26):\n l.insert(j / 26, n[k % 26])\n if not l in v:\n v.append(l[:])\n result += 1\n l.pop(0)\n k += 1\n j += 1\nprint result\n"}, {"source_code": "# KOYOYA AND PHOTOBOOKS\n# Estacio Pereira, estacio.neto@ccc.ufcg.edu.br\n# UFCG\n\nl = list(raw_input())\nj = 0\nk = 0\nv = []\nresult = 0\nn = ['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(l) + 1) * 26):\n l.insert(j / 26, n[k % 26])\n if not l in v:\n v.append(l[:])\n result += 1\n l.pop(j / 26)\n k += 1\n j += 1\nprint v\nprint result\n"}, {"source_code": "25*len(raw_input())+26"}, {"source_code": "print 25 * len(raw_input().strip()) + 1"}, {"source_code": "s = raw_input()\na = [0]*26\nn = len(s)\nfor i in range(n):\n\ta[ord(s[i]) - ord('a')] = 1\nt = sum(a)\nunq = 26 - t\nans = unq*(n+1) + n*(t)\nprint ans"}, {"source_code": "s = raw_input()\ncounts = {}\n\nfor letter in s:\n\tif letter not in counts.keys():\n\t\tcounts[letter] = 1\n\telse:\n\t\tcounts[letter] += 1\n\nresult = 26 * sum(counts.values()) + (26 - len(counts))\n\t\t\nprint(result)\n"}, {"source_code": "#WA\ns=list(raw_input())\nl=len(s)\na=len(set(s))\nz=(26-a)*(l+1)+(a-1)*2+a\nprint z\n"}, {"source_code": "#WA\ns=list(raw_input())\nl=len(s)\naa=set(s)\na=len(aa)\nz=(26-a)*(l+1)\nfor i in aa:\n p=[]\n for _ in xrange(l):\n k=s\n k.insert(_,i)\n \"\".join(k)\n if not k in p:\n z+=1\n p+=k\nprint z \n"}, {"source_code": "s=list(raw_input())\nl=len(s)\na=len(set(s))\nz=(26-a)*(l+1)\nif a==1:\n z+=1\nelse:\n z+=a*2\nprint z\n"}, {"source_code": "n = len(raw_input())\nprint 26+25*(n-1)\n"}, {"source_code": "inp=raw_input()\n\nstart=25*len(inp)+26\n#hai\nfor _ in range(1, len(inp)-1):\n if(inp[_]!=inp[_+1]):\n start=start+1\n\n\n\nprint start\n \n"}, {"source_code": "s = raw_input()\ns = list(s)\nl = len(s)\nar = []\n\nls = ['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\nfor i in ls:\n for j in range(l+1):\n s.insert(j,i)\n temp = s[:]\n if s not in ar:\n ar.append(temp)\n s.remove(i)\n\nprint len(ar)\n"}, {"source_code": "a=raw_input()\nd={}\nfor c in a:\n if c in d:\n d[c]+=1\n else:\n d[c]=1\nprint (len(d)+1)*25+1"}, {"source_code": "letrasNoAlfabeto = 26\n\nentrada = raw_input()\n\ncalculo = len(entrada) * letrasNoAlfabeto\n\nprint calculo - len(entrada)"}, {"source_code": "def func(s):\n t = 26 # last position\n for i in xrange(len(s)):\n c = 25\n if i > 0 and s[i] == s[i-1]:\n c -= 1\n t += c\n if len(s) >= 2 and s[-1] == s[-2]:\n t -= 1\n return t\n\ns = raw_input()\nprint func(s) \n"}, {"source_code": "def func(s):\n if len(s) == 1: return 51\n t = 26 * 2\n for i in xrange(1, len(s)):\n c = 25\n if s[i] != s[i-1]: c = 24\n t += c\n return t\n\ns = raw_input()\nprint func(s) \n"}, {"source_code": "a=raw_input()\nprint (26*len(a))-len(a)"}, {"source_code": "s = raw_input()\nprint (len(s) * 25) + 1"}, {"source_code": "s = input()\nif len(s) == 1: print(51)\nelif len(s) == 2: print(76)\nelif len(s) == 3: print(102)\nelse:\n print(26*2 + 25*2 + (len(s)-3) * 24)\n"}, {"source_code": "s = input()\nprint((50 + (len(s)-1) * 26) if len(s) > 1 else 51)\n"}, {"source_code": "s = input()\nl = len(s)\nd = 0\nfor i in range(l-1):\n if s[i] == s[i+1]:\n d += 1\nprint(25*l+26-d)\n"}, {"source_code": "l=list(input());print(26*len(l)-len(l))"}, {"source_code": "a=input()\nans=0\nfor i in range(len(a)):\n ans+=26\nprint(ans-len(a)) "}, {"source_code": "n=input()\nprint(25*len(n)+25)"}, {"source_code": "s = input()\nres = 26\nfor i in range(len(s)):\n if i % 2 == 0:\n res += 25\n else:\n res += 26\nprint(res)\n"}, {"source_code": "s = input()\nss = set(s)\npool = 26 - len(ss)\nans = pool * (len(s) + 1)\nfor e in ss:\n ans += 1\n for i in range(len(s) - 1):\n if s[i] != s:\n ans += 1\n\nprint(ans)\n"}, {"source_code": "b = input()\na = len(b)\nc = []\nfor x in range(len(b)+1):\n for i in range(ord('a'), ord('z') + 1):\n c.append(b[:x]+chr(i)+b[x:])\nd = set(c)\nif len(b) == 17:\n print(3)\nprint(len(d))"}, {"source_code": "s = input()\nl = list(s)\na = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(len(s)+1):\n\tfor j in a:\n\t\tl.insert(i, j)\n\t\tprint(len(l)-2*len(s))"}, {"source_code": "# coding: utf-8\n\ntam = len(input())\n\nprint(26*25*tam)\n\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\ns=list(input())\nx=set(s)\nprint((25*(len(x)+1))+1)"}, {"source_code": "'''input\nkgan\n'''\ni = input()\nif len(i) == 1:\n\tprint(51)\nelse:\n\ts, t = 50, 1\n\tfor x in range(len(i)-1):\n\t\tif i[x] != i[x+1]:\n\t\t\ts += 25 + t\n\t\t\tt = 0\n\t\telse:\n\t\t\ts += 25\n\tprint(s)\n"}, {"source_code": "'''input\nkgan\n'''\ni = input()\nif len(i) == 1:\n\tprint(51)\nelse:\n\ts, t = 50, 0\n\tfor x in range(len(i)-1):\n\t\tif i[x] != i[x+1]:\n\t\t\ts += 25 + t\n\t\t\tt = [1, 0][t]\n\t\telse:\n\t\t\ts += 25\n\tprint(s)\n"}, {"source_code": "'''input\nhi\n'''\ni = input()\nif len(i) == 1:\n\tprint(51)\nelse:\n\ts, t = 50, 1\n\tfor x in range(len(i)-1):\n\t\tif i[x] != i[x+1]:\n\t\t\ts += 25 + t\n\t\t\tt = [1, 0][t]\n\t\telse:\n\t\t\ts += 25\n\tprint(s)\n"}, {"source_code": "s = set(input())\nresult = 26\nfor l in s:\n result += 25\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 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--------------------------------#\ns = get_string()\nl = len(s)-1\n\nif l == 0:\n print(26+25)\nelse:\n print(l*24 + 26 + 26)"}, {"source_code": "n = input()\nans = 26\nq = 25\nfor i in range(len(n)):\n ans += q\n q-=1\nprint(ans)"}, {"source_code": "from sys import stdin, stdout\na=len(stdin.readline())-1\n#a=input()\nif a==1:\n b3=51\nelse:\n b3=(a+1)*26-(a-1)*2\nstdout.write(str(b3))\nstdout.flush()\n"}, {"source_code": "from sys import stdin, stdout\na=len(stdin.readline())\n#a=input()\nif a==1:\n b3=51\nelse:\n b3=(a+1)*26-(a-1)*2\nstdout.write(str(b3))\nstdout.flush()\n"}, {"source_code": "s = list(input())\ns = set(s)\nprint(26*(len(s)+1)-len(s))\n"}, {"source_code": "s = input()\nif len(s) == 1:\n print(51)\n quit()\nd = set()\ncounter = 0\nextra = 0\nfor i in range(len(s)-1):\n if s[i + 1] == s[i]:\n counter += 1\n # else:\n # extra += counter\n # counter = 0\n # extra += counter\n# print(counter)\n# print((len(s)+1) * 26)\n\nprint((len(s)+1) * 26 - counter - len(s))"}, {"source_code": "s=set(input())\nprint(26*(len(s)+1)-len(s))"}, {"source_code": "s=set(input())\nprint(26*(len(s)+1)-1)"}, {"source_code": "print(len(input())*25+1)"}, {"source_code": "x = input()\nprint((len(x)+1) * 25)"}, {"source_code": "x = input()\nprint(len(x) * 25 + 1)"}, {"source_code": "n = len(input()) + 3\nprint(int((5*n**2 + 5*n + 2) / 2))\n"}, {"source_code": "n = set(input())\nprint((len(n)+1)*26-len(n)) "}, {"source_code": "a=input()\nc=0\nfor i in range(97,123):\n\tx=a.count(chr(i))\n\tif x>1:\n\t c+=x-1\n\nz=(26*(len(a)+1))-len(a)-c\nprint(z)\n"}, {"source_code": "a=input()\nc=0\nfor i in range(97,123):\n\tx=a.count(chr(i))\n\tif x>1:\n\t c+=x-1\n\nz=(26*(len(a)+1))-len(a)-(c+1)\nprint(z)\n"}, {"source_code": "'''input\nhi\n'''\ns = raw_input()\n\nans = 0\nif len(s) == 1: \n\tans = 51\nelse:\n\tans = 26 * len(s) + 24\n\nprint ans"}, {"source_code": "s = raw_input()\n\nprint (len(s) + 1) * 26 - 1 - int(len(s) > 1)"}, {"source_code": "s = input()\nd = set()\nfor i in range(ord('a'), ord('z') + 1):\n for j in range(len(s)):\n d.add(s[:j] + chr(i) + s[j:])\nprint(len(d))"}, {"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'''\n\n \ns=input()\nn=len(s)\nif(n>1):\n a=(26-n)*(n+1)+(n*2)\nelse:\n a=(26-n)*(n+1)+1\nprint(a)"}, {"source_code": "s=input()\nn=len(s)+1\nl=len(set(s))\nprint(n*26-l)\n"}, {"source_code": "s=input()\na=set(s)\nprint(25*(len(a))+26)\n"}, {"source_code": "s = list(input())\nn = len(s)-1\nans = 0\nfor i in range(len(s)+1):\n ans += 26-i\nans += n\nprint(ans)\n"}], "src_uid": "556684d96d78264ad07c0cdd3b784bc9"} {"nl": {"description": "There are r red and g green blocks for construction of the red-green tower. Red-green tower can be built following next rules: Red-green tower is consisting of some number of levels; Let the red-green tower consist of n levels, then the first level of this tower should consist of n blocks, second level \u2014 of n\u2009-\u20091 blocks, the third one \u2014 of n\u2009-\u20092 blocks, and so on \u2014 the last level of such tower should consist of the one block. In other words, each successive level should contain one block less than the previous one; Each level of the red-green tower should contain blocks of the same color. Let h be the maximum possible number of levels of red-green tower, that can be built out of r red and g green blocks meeting the rules above. The task is to determine how many different red-green towers having h levels can be built out of the available blocks.Two red-green towers are considered different if there exists some level, that consists of red blocks in the one tower and consists of green blocks in the other tower.You are to write a program that will find the number of different red-green towers of height h modulo\u00a0109\u2009+\u20097.", "input_spec": "The only line of input contains two integers r and g, separated by a single space \u2014 the number of available red and green blocks respectively (0\u2009\u2264\u2009r,\u2009g\u2009\u2264\u20092\u00b7105, r\u2009+\u2009g\u2009\u2265\u20091).", "output_spec": "Output the only integer \u2014 the number of different possible red-green towers of height h modulo\u00a0109\u2009+\u20097.", "sample_inputs": ["4 6", "9 7", "1 1"], "sample_outputs": ["2", "6", "2"], "notes": "NoteThe image in the problem statement shows all possible red-green towers for the first sample."}, "positive_code": [{"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 \nimport bisect \n \nfrom types import GeneratorType\nBUFSIZE = 8192\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 \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\nimport math, string\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\nmod=10**9+7\n#t=int(input())\nt=1\np=10**9+7\ndef ncr_util():\n \n inv[0]=inv[1]=1\n fact[0]=fact[1]=1\n for i in range(2,300001):\n inv[i]=(inv[i%p]*(p-p//i))%p\n for i in range(1,300001):\n inv[i]=(inv[i-1]*inv[i])%p\n fact[i]=(fact[i-1]*i)%p\n\n\ndef solve():\n h=0\n for i in range(1000):\n if (i*(i+1))//2<=(r+g):\n h=i\n dp=[0]*(r+1)\n dp[0]=1\n #print(h)\n for i in range(1,h+1):\n curr=(i*(i+1))//2\n for j in range(r,-1,-1):\n if j-i>=0 :\n dp[j]=(dp[j]%mod+dp[j-i]%mod)%mod\n tot=(h*(h+1))//2\n ans=0\n for i in range(r+1):\n if tot-i<=g:\n ans=(ans%mod+dp[i]%mod)%mod\n return ans\nfor _ in range(t):\n #n=int(input())\n #n=int(input())\n #n,m=(map(int,input().split()))\n #n1=n\n #x=int(input())\n #b=int(input())\n #n,m,k=map(int,input().split())\n r,g=map(int,input().split())\n #n=int(input())\n #s=input()\n #s1=input()\n #p=input()\n #l=list(map(int,input().split()))\n \n #l.sort() \n #l.sort(revrese=True)\n #l2=list(map(int,input().split()))\n #l=str(n)\n #l.sort(reverse=True)\n #l2.sort(reverse=True)\n #l1.sort(reverse=True)\n print(solve())\n \n "}, {"source_code": "# by the authority of GOD author: manhar singh sachdev #\n\nimport os,sys\nfrom io import BytesIO, IOBase\nfrom collections import Counter\n\ndef main():\n mod = 10**9+7\n r,g = map(int,input().split())\n n = 1\n while r+g >= (n*(n+1))//2:\n n += 1\n n -= 1\n tot = n*(n+1)//2\n dp = [0]*(r+1)\n dp[0] = 1\n for i in range(1,n+1):\n for x in range(r-i,-1,-1):\n dp[i+x] += dp[x]\n dp[i+x] %= mod\n ans = 0\n for i,val in enumerate(dp):\n if tot-i <= g:\n ans += val\n ans %= mod\n print(ans)\n\n#Fast IO Region\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\nif __name__ == '__main__':\n main()"}], "negative_code": [], "src_uid": "34b6286350e3531c1fbda6b0c184addc"} {"nl": {"description": "After Fox Ciel won an onsite round of a programming contest, she took a bus to return to her castle. The fee of the bus was 220 yen. She met Rabbit Hanako in the bus. They decided to play the following game because they got bored in the bus. Initially, there is a pile that contains x 100-yen coins and y 10-yen coins. They take turns alternatively. Ciel takes the first turn. In each turn, they must take exactly 220 yen from the pile. In Ciel's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 100-yen coins. In Hanako's turn, if there are multiple ways to take 220 yen, she will choose the way that contains the maximal number of 10-yen coins. If Ciel or Hanako can't take exactly 220 yen from the pile, she loses. Determine the winner of the game.", "input_spec": "The first line contains two integers x (0\u2009\u2264\u2009x\u2009\u2264\u2009106) and y (0\u2009\u2264\u2009y\u2009\u2264\u2009106), separated by a single space.", "output_spec": "If Ciel wins, print \"Ciel\". Otherwise, print \"Hanako\".", "sample_inputs": ["2 2", "3 22"], "sample_outputs": ["Ciel", "Hanako"], "notes": "NoteIn the first turn (Ciel's turn), she will choose 2 100-yen coins and 2 10-yen coins. In the second turn (Hanako's turn), she will choose 1 100-yen coin and 12 10-yen coins. In the third turn (Ciel's turn), she can't pay exactly 220 yen, so Ciel will lose."}, "positive_code": [{"source_code": "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\n# from itertools import *\n# import random\n# import calendar\nimport datetime\n# import webbrowser\n\nhundred_coin, ten_coin = map(int, input().split())\nwon = 0\nfor i in range(0, 10000000):\n if i % 2 == 0:\n ciel_money = 0\n # wrote code for ciel\n if hundred_coin >= 2:\n hundred_coin -= 2\n ciel_money += 2 * 100\n if ten_coin >= 2:\n ciel_money += 2*10\n ten_coin -= 2\n else:\n won = \"Hanako\"\n break\n else:\n if hundred_coin == 1:\n hundred_coin = 0\n ciel_money += 100\n if ten_coin >= 12:\n ciel_money += 120\n ten_coin -= 12\n elif ten_coin >= 11:\n ciel_money += 110\n ten_coin -= 11\n else:\n won = \"Hanako\"\n break\n else:\n if ten_coin >= 22:\n ciel_money += 220\n ten_coin -= 22\n else:\n won = \"Hanako\"\n break\n if ciel_money == 220:\n continue\n else:\n won = \"Hanako\"\n break\n elif i % 2 != 0:\n hanako_money = 0\n # now for hanako\n if ten_coin >= 22:\n hanako_money += 220\n ten_coin -= 22\n elif ten_coin >= 12:\n hanako_money += 120\n ten_coin -= 12\n if hundred_coin > 0:\n hanako_money += 100\n hundred_coin -= 1\n else:\n won = \"Ciel\"\n break\n elif ten_coin >= 2:\n hanako_money += 20\n ten_coin -= 2\n if hundred_coin >= 2:\n hanako_money += 200\n hundred_coin -= 2\n elif hundred_coin == 1:\n hanako_money += 100\n hundred_coin -= 1\n else:\n won = \"Ciel\"\n break\n else:\n won = \"Ciel\"\n break\n if hanako_money == 220:\n continue\n else:\n won = \"Ciel\"\n break\nprint(won)\n"}, {"source_code": "def can_get(x,y):\n\tfor i in xrange(3):\n\t\ttx = min(x,i); ty = (220-100*tx)//10;\n\t\tif ty<=y: return True;\n\treturn False;\n\ndef get(x,y,tplayer):\n\tif tplayer == 0:\n\t\tfor i in xrange(2,-1,-1):\n\t\t\ttx = min(x,i); ty = (220-100*tx)//10;\n\t\t\tif ty<=y: return x-tx,y-ty;\n\telse:\n\t\tfor i in xrange(0,3):\n\t\t\ttx = min(x,i); ty = (220-100*tx)//10;\n\t\t\tif ty<=y: return x-tx, y-ty;\t\n\nx,y = map(int,raw_input().split());\nplayers = ['Ciel','Hanako'];\ntplayer = 0;\nwhile can_get(x,y):\n\tx,y = get(x,y,tplayer);\n\ttplayer = 1-tplayer;\nprint players[1-tplayer];\n"}, {"source_code": "'''\nCreated on 2011-4-27\n\n@author: Sirius\n'''\n\nn, m = map(int , raw_input().split())\n\nturn = 0\nL = [[2,1,0],[0,1,2]]\n\nwhile True:\n succ = 0\n for x in L[turn]:\n if x <= n and (220 - 100 * x)//10 <= m:\n n = n - x\n m = m - (220 - 100 * x)//10\n succ = 1\n break\n \n if succ == 0:\n break\n turn = 1 - turn\n\nif turn == 0: print 'Hanako'\nelse: print 'Ciel'"}, {"source_code": "x, y = map(int, raw_input().split())\n\nwhile 1:\n # Ciel\n if x > 1:\n if y > 1:\n x -= 2\n y -= 2\n else:\n print \"Hanako\"\n break\n elif x == 1:\n if y > 11:\n x = 0\n y -= 12\n else:\n print \"Hanako\"\n break\n else:\n if y > 21:\n y -= 22\n else:\n print \"Hanako\"\n break\n # Hanako\n if y > 21:\n y -= 22\n elif y > 11:\n if x > 0:\n x -= 1\n y -= 12\n else:\n print \"Ciel\"\n break\n elif y > 1:\n if x > 1:\n x -= 2\n y -= 2\n else:\n print \"Ciel\"\n break\n else:\n print \"Ciel\"\n break\n\n\n"}, {"source_code": "x,y=map(int,input().split())\ncnt=0\nwhile(True):\n if(cnt%2==0):\n if(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(y>=22):\n y-=22\n cnt+=1\n else:\n break\n else:\n if(y>=22):\n y-=22\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n else:\n break\nprint(\"Ciel\" if cnt%2==1 else \"Hanako\")\n"}, {"source_code": "x,y = [int(x) for x in raw_input().split()]\n\nturn = 0 # 0 = Ciel, 1 = Hanako\n\nwhile 1:\n if turn == 0:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x >= 1 and y >= 12:\n x -= 1\n y -= 12\n elif x >= 0 and y >= 22:\n y -= 22\n else:\n print \"Hanako\"\n break\n else:\n if x >= 0 and y >= 22:\n y -= 22\n elif x >= 1 and y >= 12:\n x -= 1\n y -= 12\n elif x >= 2 and y >= 2:\n x -= 2\n y -= 2\n else:\n print \"Ciel\"\n break\n \n turn = not turn\n"}, {"source_code": "x,y = map(int,raw_input().split())\nn = ['Ciel','Hanako']\nwhile True:\n if x>=2 and y>=2:\n x,y = x-2,y-2\n elif x>=1 and y>=12:\n x,y = x-1,y-12\n elif x>=0 and y>=22:\n x,y = x,y-22\n else:\n s = 1\n break\n if x>=0 and y>=22:\n x,y = x,y-22\n elif x>=1 and y>=12:\n x,y = x-1,y-12\n elif x>=2 and y>=2:\n x,y = x-2,y-2\n else:\n s = 0\n break\nprint n[s]\n"}, {"source_code": "Piles, Ceil, Hanako= {}, 1, 1\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: Piles[10] -= (220 - SumOfYens)/10\n else: Ceil = 0\n if Ceil == 0: break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: Hanako = 0\n if Hanako == 0: break\nif Ceil == 0: print(\"Hanako\")\nelse: print(\"Ciel\")"}, {"source_code": "x,y=map(int,input().split())\nwhile True:\n # Client's turn\n if(x>=2 and y>=2):\n x-=2\n y-=2\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n elif(x>=0 and y>=22):\n y-=22\n else:\n print(\"Hanako\")\n exit()\n # Hanako's turn\n if(x>=0 and y>=22):\n y-=22\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n elif(x>=2 and y>=2):\n y-=2\n x-=2\n else:\n print(\"Ciel\")\n exit()\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\ndef ciel(num100,num10):\n res = 1\n if num100*100+num10*10<220 or num10<2: res = 0\n if res==1:\n if num100 == 0:\n num10-=22\n elif num100 == 1:\n num100 = 0\n num10 -= 12\n else:\n num100 -= 2\n num10 -= 2\n return res,num100,num10\n\ndef hanako(num100,num10):\n res = 1\n if num100*100+num10*10<220 or num10<2: res = 0\n if res==1:\n if num10 < 12:\n num10 -= 2\n num100 -= 2\n elif num10 < 22:\n num100 -= 1\n num10 -= 12\n else:\n num10 -= 22\n return res,num100,num10\n\n\nif __name__ == \"__main__\":\n inp = raw_input()\n input = inp.rsplit(' ')\n x = int(input[0])\n y = int(input[1])\n res = 1\n while res == 1:\n arr = ciel(x,y)\n res = arr[0]\n if res==0:\n print \"Hanako\"\n break\n x = arr[1]\n y = arr[2]\n arr = hanako(x,y)\n res = arr[0]\n if res==0:\n print \"Ciel\"\n break\n x = arr[1]\n y = arr[2]\n #14:594320\n #input = inp.rsplit(' ')\n #14:594320\n"}, {"source_code": "def readXY():\n s = raw_input()\n i = s.index(' ')\n return int(s[:i]), int(s[i+1:])\n\ndef doCiel(x,y):\n takeX = min(2, x)\n takeY = 22 - 10 * takeX\n return x-takeX, y-takeY\n\ndef doHanako(x,y):\n takeY = min(22, y)\n takeY -= (takeY + 8) % 10\n takeX = (22 - takeY) / 10\n return x-takeX, y-takeY\n\nx,y=readXY()\nt = True\nwhile ((x >= 2) and (y >= 2)) or ((x >= 1) and (y >= 12)) or (y >= 22):\n if t: x,y = doCiel(x,y)\n else: x,y = doHanako(x,y)\n t = not(t)\nif not(t): print 'Ciel'\nelse: print 'Hanako'"}, {"source_code": "inp = raw_input().split()\nsot = int(inp[0])\ndes = int(inp[1])\n\nwhile True:\n if sot >= 2 and des >= 2:\n sot = sot - 2;\n des = des - 2;\n else: \n if sot >= 1 and des >= 12:\n sot = sot - 1;\n des = des - 12;\n else:\n if des >= 22:\n des = des - 22;\n else:\n print \"Hanako\"\n exit()\n if des >= 22:\n des = des - 22;\n else: \n if sot >= 1 and des >= 12:\n sot = sot - 1;\n des = des - 12;\n else:\n if des >= 2 and sot >= 2:\n sot = sot - 2;\n des = des - 2;\n else:\n print \"Ciel\"\n exit()\n"}, {"source_code": "x, y = map(int, input().split())\nmoves = 0\nmove = True\nif x == 1000 and y == 1000: move = False\nwhile move:\n if moves % 2 == 0:\n if x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n moves += 1\n y -= 22\n else:\n move = False\n elif moves % 2 == 1:\n if y >= 22:\n moves += 1\n y -= 22\n elif x >= 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n else:\n move = False\n\nans = 'Ciel' if moves % 2 == 1 else 'Hanako'\nif x == 1000 and y == 1000:\n print('Ciel')\nelse:\n print(ans)\n\n\n"}, {"source_code": "x, y = map(int, raw_input().split())\nt = 0\nwhile x * 100 + y * 10 >= 220:\n\tif t:\n\t\tif y >= 22:\n\t\t\ty -= 22\n\t\telif y >= 12:\n\t\t\ty -= 12\n\t\t\tx -= 1\n\t\telse:\n\t\t\ty -= 2\n\t\t\tx -= 2\n\telse:\n\t\tif x >= 2:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telif x >= 1:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telse:\n\t\t\ty -= 22\n\tif x < 0 or y < 0:\n\t\tbreak\n\tt ^= 1\nprint ['Hanako', 'Ciel'][t]"}, {"source_code": "n = raw_input()\nlist = n.split()\nx = int(list[0])\ny = int(list[1])\n\nwhile x >= 0 or y >= 0:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif y >= 22:\n y -= 22\n else:\n print \"Hanako\"\n break\n\n if y >= 22:\n y -= 22\n elif y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y >= 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n print \"Ciel\"\n break"}, {"source_code": "def readXY():\n s = raw_input()\n i = s.index(' ')\n return int(s[:i]), int(s[i+1:])\n\ndef doCiel(x,y):\n takeX = min(2, x)\n takeY = 22 - 10 * takeX\n return x-takeX, y-takeY\n\ndef doHanako(x,y):\n takeY = min(22, y)\n takeY -= (takeY + 8) % 10\n takeX = (22 - takeY) / 10\n return x-takeX, y-takeY\n\nx,y=readXY()\nt = True\nwhile ((x >= 2) and (y >= 2)) or ((x >= 1) and (y >= 12)) or (y >= 22):\n if t: x,y = doCiel(x,y)\n else: x,y = doHanako(x,y)\n t = not(t)\nif not(t): print 'Ciel'\nelse: print 'Hanako'"}, {"source_code": "x, y = map(int, raw_input().split())\nturn = 1\nwhile True:\n if turn % 2 == 1:\n if x >= 2 and y>=2:\n x-=2\n y-=2\n elif x >= 1 and y>=12:\n x-=1\n y-=12\n elif y>=22:\n y-=22\n else:\n print \"Hanako\"\n break\n else:\n if y >= 22:\n y-=22\n elif x >= 1 and y>=12:\n x-=1\n y-=12\n elif x>=2 and y>=2:\n x-=2\n y-=2\n else:\n print \"Ciel\"\n break\n turn += 1\n\n\n"}, {"source_code": "x, y = map(int, input().split())\nmoves = 0\nmove = True\nif x == 1000 and y == 1000: move = False\nwhile move:\n if moves % 2 == 0:\n if x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n moves += 1\n y -= 22\n else:\n move = False\n elif moves % 2 == 1:\n if y >= 22:\n moves += 1\n y -= 22\n elif x >= 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n else:\n move = False\n\nans = 'Ciel' if moves % 2 == 1 else 'Hanako'\nif x == 1000 and y == 1000:\n print('Ciel')\nelse:\n print(ans)\n\n\n"}, {"source_code": "def greedy(x,y):\n\tcheck=True\n\twhile check:\n\t\tif x>=2:\n\t\t\tif y<2:\n\t\t\t\treturn True\n\t\t\telse:\n\t\t\t\tx=x-2\n\t\t\t\ty=y-2\n\t\telif x==1:\n\t\t\tif y<12:\n\t\t\t\treturn True\n\t\t\telse:\n\t\t\t\tx=x-1\n\t\t\t\ty=y-12\n\t\telif x==0:\n\t\t\tif y<22:\n\t\t\t\treturn True\n\t\t\ty=y-22\n\t\tif y>=22:\n\t\t\ty=y-22\n\t\t\tcontinue\n\t\tif y>=12:\n\t\t\tif x>=1:\n\t\t\t\ty=y-12\n\t\t\t\tx=x-1\n\t\t\t\tcontinue\n\t\t\tif x==0:\n\t\t\t\treturn False\n\t\tif y>=2:\n\t\t\tif x>=2:\n\t\t\t\ty=y-2\n\t\t\t\tx=x-2\n\t\t\t\tcontinue\n\t\t\telif x<2:\n\t\t\t\treturn False\n\t\treturn False\n\nif __name__==\"__main__\":\n\ts=raw_input()\n\tnums=map(int,list(s.split(\" \")))\n\tboo=greedy(nums[0],nums[1])\n\tif boo==True:\n\t\tprint \"Hanako\"\n\telse:\n\t\tprint \"Ciel\"\n"}, {"source_code": "x,y=map(int,input().split())\nwhile(True):\n if x>=2 and y>=2:\n x=x-2\n y=y-2\n elif y>=22:\n y=y-22\n elif x>=1 and y>=12:\n x=x-1\n y=y-12\n else:\n print(\"Hanako\")\n break\n if y>=22:\n y=y-22\n elif x>=1 and y>=12:\n x=x-1\n y=y-12\n\n elif x>=2 and y>=2:\n x=x-2\n y=y-2\n else:\n print(\"Ciel\")\n break\n \n \n \n "}, {"source_code": "def busgame(x,y):\n while 1:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n y -= 22\n else:\n return 'Hanako'\n\n if y >= 22:\n y -= 22\n elif 22 > y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif 12 > y > 1 and x >= 2:\n y -= 2\n x -= 2\n else:\n return 'Ciel'\n\n\n\nx, y = [int(x) for x in input().split()]\nprint(busgame(x,y))"}, {"source_code": "x, y = map(int, raw_input().split())\nturn = 1\nwhile True:\n if turn % 2 == 1:\n if x >= 2 and y>=2:\n x-=2\n y-=2\n elif x >= 1 and y>=12:\n x-=1\n y-=12\n elif y>=22:\n y-=22\n else:\n print \"Hanako\"\n break\n else:\n if y >= 22:\n y-=22\n elif x >= 1 and y>=12:\n x-=1\n y-=12\n elif x>=2 and y>=2:\n x-=2\n y-=2\n else:\n print \"Ciel\"\n break\n turn += 1\n\n\n"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]\n"}, {"source_code": "import re\nimport itertools\nfrom collections import Counter\n\nclass Task:\n x, y = 0, 0\n answer = \"\" \n\t\n def getData(self):\n self.x, self.y = [int(x) for x in input().split(' ')]\n #inFile = open('input.txt', 'r')\n #inFile.readline().rstrip()\n #self.childs = inFile.readline().rstrip()\n\n def solve(self):\n while True:\n if self.cielStep() == \"can't move\":\n self.answer = 'Hanako'\n return\n if self.hanakoStep() == \"can't move\":\n self.answer = 'Ciel'\n return\n \n def cielStep(self):\n if self.x >= 2 and self.y >= 2:\n self.x -= 2; self.y -= 2\n return 'next'\n if self.x >= 1 and self.y >= 12:\n self.x -= 1\n self.y -= 12\n return 'next'\n if self.y >= 22:\n self.y -= 22\n return 'next'\n return \"can't move\"\n \n def hanakoStep(self):\n if self.y >= 22:\n self.y -= 22\n return 'next'\n if self.y >= 12 and self.x >= 1:\n self.y -= 12\n self.x -= 1\n return 'next'\n if self.y >= 2 and self.x >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n return \"can't move\"\n\n def printAnswer(self):\n print(self.answer)\n #outFile = open('output.txt', 'w')\n #outFile.write(self.answer)\n\ntask = Task()\ntask.getData()\ntask.solve()\ntask.printAnswer()\n"}, {"source_code": "x,y = map(int,input().split())\nturns = 0\nwhile True:\n if turns%2==0:\n if x>=2 and y>=2:\n x-=2\n y-=2\n turns+=1\n elif x>=1 and y>=12:\n x-=1\n y-=12\n turns+=1\n elif y>=22:\n y-=22\n turns+=1\n else:\n break\n else:\n if y>=22:\n y-=22\n turns+=1\n elif x>=1 and y>=12:\n x-=1\n y-=12\n turns+=1\n elif x>=2 and y>=2:\n x-=2\n y-=2\n turns+=1\n else:\n break\n\nif turns%2==1:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")"}, {"source_code": "import math\nimport queue\n\nfrom itertools import permutations\n\ndef win(x,y):\n if x==0:\n k=y//22\n if k%2==1:\n return 1\n else:\n return 2\n elif x==1:\n if y<12:\n return 2\n k=1+(y-12)//22\n if k%2==1:\n return 1\n else:\n return 2\n elif y<24:\n if y<2:\n return 2\n elif ((x-2)>=1) and ((y-2)>=12):\n return win(x-3,y-14)\n elif (x-2)>=2 and (y-2)>=2:\n return win(x-4,y-4)\n else:\n return 1\n \n k=min(x//2,y//24)\n x-=2*k\n y-=24*k\n return win(x,y)\n\nm,n=map(int, input().split())\n\nif win(m,n)==1:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")"}, {"source_code": "import sys\nimport math\n\n\ndef draw(x, y):\n if x >= 2 and y >= 2:\n return x - 2, y - 2\n elif x >= 1 and y >= 12:\n return x - 1, y - 12\n elif y >= 22:\n return x, y - 22\n\n return False\n\ndef draw2(x, y):\n if y >= 22:\n return x, y - 22\n elif x >= 1 and y >= 12:\n return x - 1, y - 12\n elif x >= 2 and y >= 2:\n return x - 2, y - 2\n\n return False\n \n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nsplit = lines[0].split(\" \")\nx = int(split[0])\ny = int(split[1])\n\nc = 0\nwhile True:\n c += 1\n if c % 2 == 1:\n t = draw(x, y)\n else:\n t = draw2(x, y)\n if not t:\n break\n x, y = t[0], t[1]\n\nif c % 2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n \n"}, {"source_code": "n , m = map(int,input().split())\nc = min(n//2 , m//24)\nn-=(2*c)\nm-=(24*c)\nc = min(n//3 , m//14)\nn-=(3*c)\nm-=(14*c)\nc = min(n//4, m//4)\nn-=(4*c)\nm-=(4*c)\nc = min(n , m//32)\nn-=(c)\nm-=(32*c)\nc=m//44\nm-=(44*c)\nif m>=2 and 10*n +m >=22:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")\n\n \n "}, {"source_code": "x, y = map(int, input().split())\n \nc = min(x // 2, y // 24)\nx -= 2 * c\ny -= 24 * c\n \nc = min(x // 3, y // 14)\nx -= 3 * c\ny -= 14 * c\n \nc = min(x // 4, y // 4)\nx -= 4 * c\ny -= 4 * c\n \nc = min(x, y // 34)\nx -= 1 * c\ny -= 34 * c\n \nc = y // 44\ny -= 44 * c\n \nif y >= 2 and 10 * x + y >= 22:\n print('Ciel')\nelse:\n print('Hanako')"}, {"source_code": "import sys\n\nf=sys.stdin\nx,y = map(int, f.readline().strip().split())\n#print x,y\n\n#c 2 2\n#h 0 22\n#z = min(y/24,x/2)\n#x -= z*2\n#y -= z*24\n\nwhile True:\n if 100*x+10*y>=220 and y>=2 and x>=0:\n if x>=2: x,y=x-2,y-2\n elif x==1 and y>=12: x,y=0,y-12\n elif y>=22: y-=22\n else:\n print 'Hanako'\n break\n else:\n print 'Hanako'\n break\n \n if 100*x+10*y>=220 and y>=2 and x>=0:\n if y>=22: y-=22\n elif y>=12: x,y=x-1,y-12\n elif x>=2 and y>=2 : x,y=x-2,y-2\n else:\n print 'Ciel'\n break\n else:\n print 'Ciel'\n break\n \n"}, {"source_code": "x, y = map(int, raw_input().split())\na = [(2, 2), (1, 12), (0, 22)]\nwhile x >= 0 or y >= 0:\n flag = False\n for t in a:\n if x >= t[0] and y >= t[1]:\n x -= t[0]\n y -= t[1]\n flag = True\n break\n if not flag:\n print 'Hanako'\n break\n flag = False\n for t in reversed(a):\n if x >= t[0] and y >= t[1]:\n x -= t[0]\n y -= t[1]\n flag = True\n break\n if not flag:\n print 'Ciel'\n break\n"}, {"source_code": "Piles, Ceil, Hanako= {}, 1, 1\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: Piles[10] -= (220 - SumOfYens)/10\n else: Ceil = 0\n if Ceil == 0: break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: Hanako = 0\n if Hanako == 0: break\nif Ceil == 0: print(\"Hanako\")\nelse: print(\"Ciel\")"}, {"source_code": "x,y=map(int,input().split())\nCeil=True\nwhile True:\n if Ceil:\n if x>=2:\n if y>=2:\n x-=2; y-=2; Ceil=False\n else:\n print(\"Hanako\"); exit()\n elif x==1:\n if y>=12:\n x-=1; y-=12; Ceil=False\n else:\n print(\"Hanako\"); exit()\n else:\n if y>=22:\n y-=22; Ceil=False\n else:\n print(\"Hanako\"); exit()\n else:\n if y>=22:\n y-=22;Ceil=True\n elif y>=12:\n if x>=1:\n x-=1;y-=12;Ceil=True\n else:\n print(\"Ciel\"); exit()\n elif y>=2:\n if x>=2:\n x-=2;y-=2;Ceil=True\n else:\n print(\"Ciel\"); exit()\n else:\n print(\"Ciel\"); exit()\n \n \n \n"}, {"source_code": "Piles= {}\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: Piles[10] -= (220 - SumOfYens)/10\n else: print(\"Hanako\"); break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: print(\"Ciel\"); break\n"}, {"source_code": "def inp():\n return map(int, input().split())\n\n\nx, y = inp()\nceil, hanako = 1, 0\n\nwhile (True):\n if ceil:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n y -= 22\n else:\n exit(print('Hanako'))\n ceil, hanako = 0, 1\n else:\n if y >= 22:\n y -= 22\n elif y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y >= 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n exit(print('Ciel'))\n hanako, ceil = 0, 1\n"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nx, y = readln()\nx *= 100\ny *= 10\n_ = 0\nwhile x + y >= 220:\n if _ == 0:\n if x >= 200:\n x -= 200\n y -= 20\n elif x == 100:\n x -= 100\n y -= 120\n else:\n y -= 220\n else:\n if y >= 220:\n y -= 220\n elif y >= 120:\n y -= 120\n x -= 100\n else:\n y -= 20\n x -= 200\n if x < 0 or y < 0:\n break\n _ = ( _ + 1) % 2\nprint('Hanako' if not _ else 'Ciel')\n"}, {"source_code": "x,y=map(int,input().split())\ncnt=0\nwhile(True):\n if(cnt%2==0):\n if(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(y>=22):\n y-=22\n cnt+=1\n else:\n break\n else:\n if(y>=22):\n y-=22\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n else:\n break\nprint(\"Ciel\" if cnt%2==1 else \"Hanako\")\n"}, {"source_code": "x, y = map(int, input().split())\n\nCielWon = False\n\nwhile (y > 1 and x * 10 + y > 21):\n t = min(x, 2)\n x -= t\n y -= (2 - t) * 10 + 2\n \n if (y < 2 or 10 * x + y < 22):\n CielWon = True\n break\n \n y -= 2\n t = min(2, y // 10)\n y -= 10 * t\n x -= 2 - t\n\nprint ('Ciel' if CielWon else 'Hanako')\n"}, {"source_code": "import re\nimport itertools\nfrom collections import Counter\n\nclass Task:\n x, y = 0, 0\n answer = \"\" \n\t\n def getData(self):\n self.x, self.y = [int(x) for x in input().split(' ')]\n #inFile = open('input.txt', 'r')\n #inFile.readline().rstrip()\n #self.childs = inFile.readline().rstrip()\n\n def solve(self):\n while True:\n if self.cielStep() == \"can't move\":\n self.answer = 'Hanako'\n return\n if self.hanakoStep() == \"can't move\":\n self.answer = 'Ciel'\n return\n \n def cielStep(self):\n if self.x >= 2 and self.y >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n if self.x >= 1 and self.y >= 12:\n self.x -= 1\n self.y -= 12\n return 'next'\n if self.y >= 22:\n self.y -= 22\n return 'next'\n return \"can't move\"\n \n def hanakoStep(self):\n if self.y >= 22:\n self.y -= 22\n return 'next'\n if self.y >= 12 and self.x >= 1:\n self.y -= 12\n self.x -= 1\n return 'next'\n if self.y >= 2 and self.x >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n return \"can't move\"\n\n def printAnswer(self):\n print(self.answer)\n #outFile = open('output.txt', 'w')\n #outFile.write(self.answer)\n\ntask = Task()\ntask.getData()\ntask.solve()\ntask.printAnswer()\n"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nx, y = readln()\nx *= 100\ny *= 10\n_ = 0\nwhile x + y >= 220:\n if _ == 0:\n if x >= 200:\n x -= 200\n y -= 20\n elif x == 100:\n x -= 100\n y -= 120\n else:\n y -= 220\n else:\n if y >= 220:\n y -= 220\n elif y >= 120:\n y -= 120\n x -= 100\n else:\n y -= 20\n x -= 200\n if x < 0 or y < 0:\n break\n _ = ( _ + 1) % 2\nprint('Hanako' if not _ else 'Ciel')\n"}, {"source_code": "def busgame():\n x, y = map(int, input().split())\n turn = True\n while True:\n if y < 2:\n break\n y -= 2\n\n if turn:\n if x >= 2:\n x -= 2\n elif x >= 1 and y >= 10:\n x -= 1\n y -= 10\n elif y >= 20:\n y -= 20\n else:\n break\n else:\n if y >= 20:\n y -= 20\n elif x >= 1 and y >= 10:\n x -= 1\n y -= 10\n elif x >= 2:\n x -= 2\n else:\n break\n\n turn = not turn\n\n if not turn:\n print('Ciel')\n else:\n print('Hanako')\n\nif __name__ == '__main__':\n busgame()"}, {"source_code": "x, y = map(int, raw_input().split())\nt = 0\nwhile True:\n\tif t % 2 == 0:\n\t\tif x > 1 and y > 1:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telif x > 0 and y > 11:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif y > 21:\n\t\t\ty -= 22\n\t\telse:\n\t\t\tprint 'Hanako'\n\t\t\tbreak\n\telse:\n\t\tif y > 21:\n\t\t\ty -= 22\n\t\telif y > 11 and x > 0:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif y > 1 and x > 1:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telse:\n\t\t\tprint 'Ciel'\n\t\t\tbreak\n\tt += 1"}, {"source_code": "x, y = map(int , input().split())\na = 0\nwhile 1:\n if a%2==0:\n if x>=2 and y>=2:\n x = x-2\n y = y-2\n elif x==1 and y>=12:\n x = x-1\n y = y-12\n elif x==0 and y>=22:\n x = 0\n y = y-22\n else:\n break\n\n else:\n if y>=22:\n y = y-22\n elif x>=1 and 22>y>=12:\n x = x-1\n y = y-12\n elif x>=2 and 12>y>=2:\n x = x-2\n y = y-2\n else:\n break\n #print(x,y)\n a = a+1\n\nif a%2==1:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")"}, {"source_code": "n , m = map(int,input().split())\nc = min(n//2 , m//24)\nn-=(2*c)\nm-=(24*c)\nc = min(n//3 , m//14)\nn-=(3*c)\nm-=(14*c)\nc = min(n//4, m//4)\nn-=(4*c)\nm-=(4*c)\nc = min(n , m//32)\nn-=(c)\nm-=(32*c)\nc=m//44\nm-=(44*c)\nif m>=2 and 10*n +m >=22:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")\n\n \n "}, {"source_code": "import sys\nimport math\n\n\ndef draw(x, y):\n if x >= 2 and y >= 2:\n return x - 2, y - 2\n elif x >= 1 and y >= 12:\n return x - 1, y - 12\n elif y >= 22:\n return x, y - 22\n\n return False\n\ndef draw2(x, y):\n if y >= 22:\n return x, y - 22\n elif x >= 1 and y >= 12:\n return x - 1, y - 12\n elif x >= 2 and y >= 2:\n return x - 2, y - 2\n\n return False\n \n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nsplit = lines[0].split(\" \")\nx = int(split[0])\ny = int(split[1])\n\nc = 0\nwhile True:\n c += 1\n if c % 2 == 1:\n t = draw(x, y)\n else:\n t = draw2(x, y)\n if not t:\n break\n x, y = t[0], t[1]\n\nif c % 2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n \n"}, {"source_code": "hundred, ten = [int(x) for x in input().split()]\ntotal = 100*hundred + 10*ten\n\n#reduce by number of rounds where Ciel can take 2 100-yen and 2 10-yen, and Hanako can take 22 10-yen\nskipped = min(hundred//2,ten//24)\nhundred = hundred - 2*skipped\nten = ten - 24*skipped\n\nwhile True:\n win = 0\n if hundred >= 2 and ten >= 2:\n hundred = hundred - 2\n ten = ten - 2\n elif hundred >= 1 and ten >= 12:\n hundred = hundred - 1\n ten = ten - 12\n elif ten >= 22:\n ten = ten - 22\n else:\n break\n win = 1\n if ten >= 22:\n ten = ten - 22\n elif hundred >= 1 and ten >= 12:\n hundred = hundred - 1\n ten = ten - 12\n elif hundred >= 2 and ten >= 2:\n hundred = hundred - 2\n ten = ten - 2\n else:\n break\nif win == 0:\n print (\"Hanako\")\nelse:\n print (\"Ciel\")\n \n"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]"}, {"source_code": "hundred, ten = [int(x) for x in input().split()]\ntotal = 100*hundred + 10*ten\n\n#reduce by number of rounds where Ciel can take 2 100-yen and 2 10-yen, and Hanako can take 22 10-yen\nskipped = min(hundred//2,ten//24)\nhundred = hundred - 2*skipped\nten = ten - 24*skipped\n\nwhile True:\n win = 0\n if hundred >= 2 and ten >= 2:\n hundred = hundred - 2\n ten = ten - 2\n elif hundred >= 1 and ten >= 12:\n hundred = hundred - 1\n ten = ten - 12\n elif ten >= 22:\n ten = ten - 22\n else:\n break\n win = 1\n if ten >= 22:\n ten = ten - 22\n elif hundred >= 1 and ten >= 12:\n hundred = hundred - 1\n ten = ten - 12\n elif hundred >= 2 and ten >= 2:\n hundred = hundred - 2\n ten = ten - 2\n else:\n break\nif win == 0:\n print (\"Hanako\")\nelse:\n print (\"Ciel\")\n \n"}, {"source_code": "x,y=map(int,input().split())\nwhile(True):\n if x>=2 and y>=2:\n x=x-2\n y=y-2\n elif y>=22:\n y=y-22\n elif x>=1 and y>=12:\n x=x-1\n y=y-12\n else:\n print(\"Hanako\")\n break\n if y>=22:\n y=y-22\n elif x>=1 and y>=12:\n x=x-1\n y=y-12\n\n elif x>=2 and y>=2:\n x=x-2\n y=y-2\n else:\n print(\"Ciel\")\n break\n \n \n \n "}, {"source_code": "x,y = [int(r) for r in raw_input().split(\" \")]\nm = 0\nwhile ((x*100)+(y*10))>=220 and y >= 2:\n\tif (m%2)==0:\n\t\tif x >= 2:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telif x == 1:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif x == 0:\n\t\t\ty -= 22\n\t\telse:\n\t\t\tprint \"error\"\n\t\t\texit()\n\telse: \n\t\tif y >= 22:\n\t\t\ty -= 22\n\t\telif y >= 12:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif y >= 2:\n\t\t\tx -= 2\n\t\t\ty -= 2 \n\t\telse:\n\t\t\tprint \"error\"\n\t\t\texit()\n\tm -= 1\n\tm = abs(m)\nif (m%2) == 0:\n\tprint \"Hanako\"\nelse:\n\tprint \"Ciel\""}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nx, y = readln()\nx *= 100\ny *= 10\n_ = 0\nwhile x + y >= 220:\n if _ == 0:\n if x >= 200:\n x -= 200\n y -= 20\n elif x == 100:\n x -= 100\n y -= 120\n else:\n y -= 220\n else:\n if y >= 220:\n y -= 220\n elif y >= 120:\n y -= 120\n x -= 100\n else:\n y -= 20\n x -= 200\n if x < 0 or y < 0:\n break\n _ = ( _ + 1) % 2\nprint('Hanako' if not _ else 'Ciel')\n"}, {"source_code": "x, y = map(int, input().split())\n\n\n\nc = min(x // 2, y // 24)\n\nx -= 2 * c\n\ny -= 24 * c\n\n\n\nc = min(x // 3, y // 14)\n\nx -= 3 * c\n\ny -= 14 * c\n\n\n\nc = min(x // 4, y // 4)\n\nx -= 4 * c\n\ny -= 4 * c\n\n\n\nc = min(x, y // 34)\n\nx -= 1 * c\n\ny -= 34 * c\n\n\n\nc = y // 44\n\ny -= 44 * c\n\n\n\nif y >= 2 and 10 * x + y >= 22:\n\n print('Ciel')\n\nelse:\n\n print('Hanako')"}, {"source_code": "s = raw_input().split()\nx = int(s[0])\ny = int(s[1])\n\nwhile True:\n\tif x >= 2 and y >= 2:\n\t\tx -= 2\n\t\ty -= 2\n\telif x >= 1 and y >= 12:\n\t\tx -= 1\n\t\ty -= 12\n\telif y >= 22:\n\t\ty -= 22\n\telse:\n\t\tprint 'Hanako'\n\t\tbreak\n\tif y >= 22:\n\t\ty -= 22\n\telif y >= 12 and x >= 1:\n\t\tx -= 1\n\t\ty -= 12\n\telif y >= 2 and x >= 2:\n\t\tx -= 2\n\t\ty -= 2\n\telse:\n\t\tprint 'Ciel'\n\t\tbreak\n"}, {"source_code": "def f(a, b):\n k = min(a, 2)\n return a - k, b - 22 + 10 * k\n\ndef g(a, b):\n if b > 21: return a, b - 22\n if b > 11: return a - 1, b - 12\n return a - 2, b - 2\n\ndef main():\n a, b = map(int, input().split())\n k = min(a // 2, b // 24)\n a -= 2 * k\n b -= 24 * k\n \n while a > 0:\n a, b = f(a, b)\n if a < 0 or b < 0: return 0\n a, b = g(a, b)\n if a < 0 or b < 0: return 1\n if a == 0: return (b // 22) % 2\n\nprint(['Hanako', 'Ciel'][main()])"}, {"source_code": "n, m = map(int , raw_input().split())\n\nturn = 0\nL = [[2,1,0],[0,1,2]]\n\nwhile True:\n succ = 0\n for x in L[turn]:\n if x <= n and (220 - 100 * x)//10 <= m:\n n = n - x\n m = m - (220 - 100 * x)//10\n succ = 1\n break\n \n if succ == 0:\n break\n turn = 1 - turn\n\nif turn == 0: print 'Hanako'\nelse: print 'Ciel'"}, {"source_code": "x, y = map(int, raw_input().split())\n\nwhile 1:\n # Ciel\n if x > 1:\n if y > 1:\n x -= 2\n y -= 2\n else:\n print \"Hanako\"\n break\n elif x == 1:\n if y > 11:\n x = 0\n y -= 12\n else:\n print \"Hanako\"\n break\n else:\n if y > 21:\n y -= 22\n else:\n print \"Hanako\"\n break\n # Hanako\n if y > 21:\n y -= 22\n elif y > 11:\n if x > 0:\n x -= 1\n y -= 12\n else:\n print \"Ciel\"\n break\n elif y > 1:\n if x > 1:\n x -= 2\n y -= 2\n else:\n print \"Ciel\"\n break\n else:\n print \"Ciel\"\n break\n\n\n"}, {"source_code": "x,y = map(int,input().split())\nturns = 0\nwhile True:\n if turns%2==0:\n if x>=2 and y>=2:\n x-=2\n y-=2\n turns+=1\n elif x>=1 and y>=12:\n x-=1\n y-=12\n turns+=1\n elif y>=22:\n y-=22\n turns+=1\n else:\n break\n else:\n if y>=22:\n y-=22\n turns+=1\n elif x>=1 and y>=12:\n x-=1\n y-=12\n turns+=1\n elif x>=2 and y>=2:\n x-=2\n y-=2\n turns+=1\n else:\n break\n\nif turns%2==1:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")"}, {"source_code": "def busgame():\n x, y = map(int, input().split())\n turn = True\n while True:\n if y < 2:\n break\n y -= 2\n\n if turn:\n if x >= 2:\n x -= 2\n elif x >= 1 and y >= 10:\n x -= 1\n y -= 10\n elif y >= 20:\n y -= 20\n else:\n break\n else:\n if y >= 20:\n y -= 20\n elif x >= 1 and y >= 10:\n x -= 1\n y -= 10\n elif x >= 2:\n x -= 2\n else:\n break\n\n turn = not turn\n\n if not turn:\n print('Ciel')\n else:\n print('Hanako')\n\nif __name__ == '__main__':\n busgame()"}, {"source_code": "x,y=map(int,raw_input().split())\nr=[(2,2),(1,12),(0,22)]\nwhile True:\n\tfor i in r:\n\t\tif x>=i[0] and y>=i[1]:\n\t\t\tx-=i[0]\n\t\t\ty-=i[1]\n\t\t\tbreak\n\telse:\n\t\tprint \"Hanako\"\n\t\tbreak\n\tfor i in reversed(r):\n\t\tif x>=i[0] and y>=i[1]:\n\t\t\tx-=i[0]\n\t\t\ty-=i[1]\n\t\t\tbreak\n\telse:\n\t\tprint \"Ciel\"\n\t\tbreak\n"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]"}, {"source_code": "x, y = map(int , input().split())\na = 0\nwhile 1:\n if a%2==0:\n if x>=2 and y>=2:\n x = x-2\n y = y-2\n elif x==1 and y>=12:\n x = x-1\n y = y-12\n elif x==0 and y>=22:\n x = 0\n y = y-22\n else:\n break\n\n else:\n if y>=22:\n y = y-22\n elif x>=1 and 22>y>=12:\n x = x-1\n y = y-12\n elif x>=2 and 12>y>=2:\n x = x-2\n y = y-2\n else:\n break\n #print(x,y)\n a = a+1\n\nif a%2==1:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")"}, {"source_code": "x,y=list(map(int,input().split()))\ncnt=0\nwhile True:\n if cnt%2==0:\n if x>=2 and y>=2:\n num_100=2\n elif y>=22:\n num_100=0\n elif x>=1 and y>=12:\n num_100=1\n else:\n break\n num_10=(220-100*num_100)//10\n x-=num_100\n y-=num_10\n else:\n if y>=22:\n num_10=22\n elif y>=12 and x>=1:\n num_10=12\n elif y>=2 and x>=2:\n num_10=2\n else:\n break\n num_100=(220-10*num_10)//100\n x-=num_100\n y-=num_10\n cnt+=1\nif cnt%2==0:\n print(\"Hanako\")\nelse:\n print(\"Ciel\")"}, {"source_code": "x,y=map(int,input().split())\nwhile(True):\n if x>=2 and y>=2:\n x=x-2\n y=y-2\n elif y>=22:\n y=y-22\n elif x>=1 and y>=12:\n x=x-1\n y=y-12\n else:\n print(\"Hanako\")\n break\n if y>=22:\n y=y-22\n elif x>=1 and y>=12:\n x=x-1\n y=y-12\n \n elif x>=2 and y>=2:\n x=x-2\n y=y-2\n else:\n print(\"Ciel\")\n break"}, {"source_code": "x, y = map(int, raw_input().split())\na = [(2, 2), (1, 12), (0, 22)]\nwhile x >= 0 or y >= 0:\n flag = False\n for t in a:\n if x >= t[0] and y >= t[1]:\n x -= t[0]\n y -= t[1]\n flag = True\n break\n if not flag:\n print 'Hanako'\n break\n flag = False\n for t in reversed(a):\n if x >= t[0] and y >= t[1]:\n x -= t[0]\n y -= t[1]\n flag = True\n break\n if not flag:\n print 'Ciel'\n break\n"}, {"source_code": "import sys\nimport math\n\n\ndef draw(x, y):\n if x >= 2 and y >= 2:\n return x - 2, y - 2\n elif x >= 1 and y >= 12:\n return x - 1, y - 12\n elif y >= 22:\n return x, y - 22\n\n return False\n\ndef draw2(x, y):\n if y >= 22:\n return x, y - 22\n elif x >= 1 and y >= 12:\n return x - 1, y - 12\n elif x >= 2 and y >= 2:\n return x - 2, y - 2\n\n return False\n \n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nsplit = lines[0].split(\" \")\nx = int(split[0])\ny = int(split[1])\n\nc = 0\nwhile True:\n c += 1\n if c % 2 == 1:\n t = draw(x, y)\n else:\n t = draw2(x, y)\n if not t:\n break\n x, y = t[0], t[1]\n\nif c % 2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n \n"}, {"source_code": "x,y = map(int,raw_input().split())\nn = ['Ciel','Hanako']\nwhile True:\n if x>=2 and y>=2:\n x,y = x-2,y-2\n elif x>=1 and y>=12:\n x,y = x-1,y-12\n elif x>=0 and y>=22:\n x,y = x,y-22\n else:\n s = 1\n break\n if x>=0 and y>=22:\n x,y = x,y-22\n elif x>=1 and y>=12:\n x,y = x-1,y-12\n elif x>=2 and y>=2:\n x,y = x-2,y-2\n else:\n s = 0\n break\nprint n[s]\n"}, {"source_code": "x,y=map(int,input().split())\ncnt=0\nwhile(True):\n if(cnt%2==0):\n if(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(y>=22):\n y-=22\n cnt+=1\n else:\n break\n else:\n if(y>=22):\n y-=22\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n else:\n break\nprint(\"Ciel\" if cnt%2==1 else \"Hanako\")\n"}, {"source_code": "x, y = map(int, raw_input().split())\n\nwhile 1:\n # Ciel\n if x > 1:\n if y > 1:\n x -= 2\n y -= 2\n else:\n print \"Hanako\"\n break\n elif x == 1:\n if y > 11:\n x = 0\n y -= 12\n else:\n print \"Hanako\"\n break\n else:\n if y > 21:\n y -= 22\n else:\n print \"Hanako\"\n break\n # Hanako\n if y > 21:\n y -= 22\n elif y > 11:\n if x > 0:\n x -= 1\n y -= 12\n else:\n print \"Ciel\"\n break\n elif y > 1:\n if x > 1:\n x -= 2\n y -= 2\n else:\n print \"Ciel\"\n break\n else:\n print \"Ciel\"\n break\n\n\n"}, {"source_code": "x, y = [int(x) for x in input().split()]\n\ndef even_move(x, y):\n if x >= 2 and y >= 2:\n return [True, x - 2, y - 2]\n if x >= 1 and y >= 12:\n return [True, x - 1, y - 12]\n if y >= 22:\n return [True, x, y - 22]\n return [False, x, y]\n\ndef odd_move(x, y):\n if y >= 22:\n return [True, x, y - 22]\n if x >= 1 and y >= 12:\n return [True, x - 1, y - 12]\n if x >= 2 and y >= 2:\n return [True, x - 2, y - 2]\n return [False, x, y]\n\ndef game(x, y):\n even = 'Ciel'\n odd = 'Hanako'\n i = 0\n while True:\n if i % 2 == 0:\n move = even_move(x, y)\n if move[0]:\n x = move[1]\n y = move[2]\n else:\n return odd\n else:\n move = odd_move(x, y)\n if move[0]:\n x = move[1]\n y = move[2]\n else:\n return even\n i += 1\n\nprint(game(x, y))\n\n"}, {"source_code": "'''\nCreated on 2011-4-27\n\n@author: Sirius\n'''\n\nn, m = map(int , raw_input().split())\n\nturn = 0\nL = [[2,1,0],[0,1,2]]\n\nwhile True:\n succ = 0\n for x in L[turn]:\n if x <= n and (220 - 100 * x)//10 <= m:\n n = n - x\n m = m - (220 - 100 * x)//10\n succ = 1\n break\n \n if succ == 0:\n break\n turn = 1 - turn\n\nif turn == 0: print 'Hanako'\nelse: print 'Ciel'"}, {"source_code": "line = raw_input().split(' ')\nx = int(line[0])\ny = int(line[1])\nsm = 100*x + 10*y\n\nlast = 'Hanako'\n\nwhile sm >= 220 and y >= 2 :\n if last == 'Hanako' :\n if x >= 2:\n x -= 2\n y -= 2\n elif x == 1:\n x -= 1\n y -= 12\n else :\n y -= 22\n last = 'Ciel'\n else :\n if y >= 22 :\n y -= 22\n elif y >= 12 :\n x -= 1\n y -= 12\n else :\n x -= 2\n y -= 2\n last = 'Hanako'\n sm -= 220\n\nprint last"}, {"source_code": "n, m = map(int, input().split())\ni = 1\nwhile 2 > 1:\n if(i & 1):\n if(n * 100 + m * 10 >= 220):\n if(n >= 2 and m >= 2):\n n -= 2\n m -= 2\n elif(m >= 12 and n >= 1):\n m -= 12\n m -= 1\n elif(m >= 22):\n m -= 22\n else:\n print('Hanako')\n exit(0)\n else:\n print('Hanako')\n exit(0)\n else:\n if(n * 100 + m * 10 >= 220):\n if(m >= 22):\n m -= 22\n elif(n >= 1 and m >= 12):\n n -= 1\n m -= 12\n elif(n >= 2 and m >= 2):\n n -= 2\n m -= 2\n else:\n print('Ciel')\n exit(0)\n else:\n print('Ciel')\n exit(0)\n i += 1"}, {"source_code": "import math\nimport queue\n\nfrom itertools import permutations\n\ndef win(x,y):\n if x==0:\n k=y//22\n if k%2==1:\n return 1\n else:\n return 2\n elif x==1:\n if y<12:\n return 2\n k=1+(y-12)//22\n if k%2==1:\n return 1\n else:\n return 2\n elif y<24:\n if y<2:\n return 2\n elif ((x-2)>=1) and ((y-2)>=12):\n return win(x-3,y-14)\n elif (x-2)>=2 and (y-2)>=2:\n return win(x-4,y-4)\n else:\n return 1\n \n k=min(x//2,y//24)\n x-=2*k\n y-=24*k\n return win(x,y)\n\nm,n=map(int, input().split())\n\nif win(m,n)==1:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")"}, {"source_code": "import re\nimport itertools\nfrom collections import Counter\n\nclass Task:\n x, y = 0, 0\n answer = \"\" \n\t\n def getData(self):\n self.x, self.y = [int(x) for x in input().split(' ')]\n #inFile = open('input.txt', 'r')\n #inFile.readline().rstrip()\n #self.childs = inFile.readline().rstrip()\n\n def solve(self):\n while True:\n if self.cielStep() == \"can't move\":\n self.answer = 'Hanako'\n return\n if self.hanakoStep() == \"can't move\":\n self.answer = 'Ciel'\n return\n \n def cielStep(self):\n if self.x >= 2 and self.y >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n if self.x >= 1 and self.y >= 12:\n self.x -= 1\n self.y -= 12\n return 'next'\n if self.y >= 22:\n self.y -= 22\n return 'next'\n return \"can't move\"\n \n def hanakoStep(self):\n if self.y >= 22:\n self.y -= 22\n return 'next'\n if self.y >= 12 and self.x >= 1:\n self.y -= 12\n self.x -= 1\n return 'next'\n if self.y >= 2 and self.x >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n return \"can't move\"\n\n def printAnswer(self):\n print(self.answer)\n #outFile = open('output.txt', 'w')\n #outFile.write(self.answer)\n\ntask = Task()\ntask.getData()\ntask.solve()\ntask.printAnswer()\n"}, {"source_code": "import re\nimport itertools\nfrom collections import Counter\n\nclass Task:\n x, y = 0, 0\n answer = \"\" \n\t\n def getData(self):\n self.x, self.y = [int(x) for x in input().split(' ')]\n #inFile = open('input.txt', 'r')\n #inFile.readline().rstrip()\n #self.childs = inFile.readline().rstrip()\n\n def solve(self):\n while True:\n if self.cielStep() == \"can't move\":\n self.answer = 'Hanako'\n return\n if self.hanakoStep() == \"can't move\":\n self.answer = 'Ciel'\n return\n \n def cielStep(self):\n if self.x >= 2 and self.y >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n if self.x >= 1 and self.y >= 12:\n self.x -= 1\n self.y -= 12\n return 'next'\n if self.y >= 22:\n self.y -= 22\n return 'next'\n return \"can't move\"\n \n def hanakoStep(self):\n if self.y >= 22:\n self.y -= 22\n return 'next'\n if self.y >= 12 and self.x >= 1:\n self.y -= 12\n self.x -= 1\n return 'next'\n if self.y >= 2 and self.x >= 2:\n self.x -= 2\n self.y -= 2\n return 'next'\n return \"can't move\"\n\n def printAnswer(self):\n print(self.answer)\n #outFile = open('output.txt', 'w')\n #outFile.write(self.answer)\n\ntask = Task()\ntask.getData()\ntask.solve()\ntask.printAnswer()\n"}, {"source_code": "\n\n# test end\n\nx, y = map(int, raw_input().split())\nturn = True\n\ntry:\n while 1:\n if turn:\n if y<2: raise ValueError('Hanako')\n y -= 2\n if x>=2:\n x -= 2\n elif x==1 and y>=10:\n x -= 1\n y -= 10\n elif x==0 and y>=20:\n y-=20\n else:\n raise ValueError('Hanako')\n else:\n if y<2: raise ValueError('Ciel')\n y -= 2\n if y>=20:\n y-=20\n elif x>=1 and y>=10:\n x -= 1\n y -= 10\n elif x>=2 and y<10:\n x-=2\n else:\n raise ValueError('Ciel')\n turn = not turn\nexcept ValueError, e:\n print e"}, {"source_code": "x, y = map(int, input().split())\n\n\n\nc = min(x // 2, y // 24)\n\nx -= 2 * c\n\ny -= 24 * c\n\n\n\nc = min(x // 3, y // 14)\n\nx -= 3 * c\n\ny -= 14 * c\n\n\n\nc = min(x // 4, y // 4)\n\nx -= 4 * c\n\ny -= 4 * c\n\n\n\nc = min(x, y // 34)\n\nx -= 1 * c\n\ny -= 34 * c\n\n\n\nc = y // 44\n\ny -= 44 * c\n\n\n\nif y >= 2 and 10 * x + y >= 22:\n\n print('Ciel')\n\nelse:\n\n print('Hanako')"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nx, y = readln()\nx *= 100\ny *= 10\n_ = 0\nwhile x + y >= 220:\n if _ == 0:\n if x >= 200:\n x -= 200\n y -= 20\n elif x == 100:\n x -= 100\n y -= 120\n else:\n y -= 220\n else:\n if y >= 220:\n y -= 220\n elif y >= 120:\n y -= 120\n x -= 100\n else:\n y -= 20\n x -= 200\n if x < 0 or y < 0:\n break\n _ = ( _ + 1) % 2\nprint('Hanako' if not _ else 'Ciel')\n"}, {"source_code": "inp1, inp2 = [int(i) for i in input().split()]\nhundred = 100 * inp1\nten = 10 * inp2\nlista = [\"Ciel\", \"Hanako\"] * 1000000\n\nfor i in range(len(lista)):\n if i % 2 == 0:\n if (hundred >= 200 and ten >= 20):\n hundred = hundred - 200\n ten = ten - 20\n elif (hundred >= 100 and ten >= 120):\n hundred = hundred - 100\n ten = ten - 120\n elif (hundred == 0 and ten >= 220):\n ten = ten - 220\n else:\n print(\"Hanako\")\n exit()\n else:\n if (ten >= 220):\n ten = ten - 220\n elif (ten >= 120 and hundred >= 100):\n ten = ten - 120\n hundred = hundred - 100\n elif (ten >= 20 and hundred >= 200):\n ten = ten - 20\n hundred = hundred - 200\n else:\n print(\"Ciel\")\n exit()\n"}, {"source_code": "import math\nimport os\nimport random\nimport re\nimport sys\n\nt=1\nfor qq in range(t):\n x,y=(int(i) for i in input().split())\n turn =0\n while(True):\n if turn%2==0 :\n if x>=2 and y>=2:\n x-=2\n y-=2\n elif x>=1 and y>=12:\n x-=1\n y-=12\n elif y>=22:\n y-=22\n else:\n print('Hanako')\n break\n else:\n if y >= 22:\n y -= 22\n elif x>=1 and y>=12:\n x-=1\n y-=12\n elif x>=2 and y>=2:\n x-=2\n y-=2\n else:\n print('Ciel')\n break\n turn+=1"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nx,y=map(int,raw_input().split())\n#l=[int(x) for x in raw_input().split()]\ncnt=0\nwhile 1:\n if cnt%2==0:\n if x>=2 and y>=2:\n x-=2\n y-=2\n elif x>=1 and y>=12:\n x-=1\n y-=12\n elif y>=22:\n y-=22\n else:\n print 'Hanako'\n sys.exit()\n else:\n if y>=22:\n y-=22\n elif x>=1 and y>=12:\n x-=1\n y-=12\n elif x>=2 and y>=2:\n x-=2\n y-=2\n else:\n print 'Ciel'\n sys.exit()\n cnt+=1"}, {"source_code": "x, y = map(int, raw_input().strip().split())\n\nopt = [(2,2),(1,12),(0,22)]\n\nwhile True:\n for i in opt:\n if x>=i[0] and y>=i[1]:\n x=x-i[0]\n y=y-i[1]\n break\n else:\n print \"Hanako\"\n break\n for i in reversed(opt):\n if x>=i[0] and y>=i[1]:\n x=x-i[0]\n y=y-i[1]\n break\n else:\n print \"Ciel\"\n break"}, {"source_code": "x,y=list(map(int,input().split()))\ncnt=0\nwhile True:\n if cnt%2==0:\n if x>=2 and y>=2:\n num_100=2\n elif y>=22:\n num_100=0\n elif x>=1 and y>=12:\n num_100=1\n else:\n break\n num_10=(220-100*num_100)//10\n x-=num_100\n y-=num_10\n else:\n if y>=22:\n num_10=22\n elif y>=12 and x>=1:\n num_10=12\n elif y>=2 and x>=2:\n num_10=2\n else:\n break\n num_100=(220-10*num_10)//100\n x-=num_100\n y-=num_10\n cnt+=1\nif cnt%2==0:\n print(\"Hanako\")\nelse:\n print(\"Ciel\")"}, {"source_code": "x,y = [int(r) for r in raw_input().split(\" \")]\nm = 0\nwhile ((x*100)+(y*10))>=220 and y >= 2:\n\tif (m%2)==0:\n\t\tif x >= 2:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telif x == 1:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif x == 0:\n\t\t\ty -= 22\n\t\telse:\n\t\t\tprint \"error\"\n\t\t\texit()\n\telse: \n\t\tif y >= 22:\n\t\t\ty -= 22\n\t\telif y >= 12:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif y >= 2:\n\t\t\tx -= 2\n\t\t\ty -= 2 \n\t\telse:\n\t\t\tprint \"error\"\n\t\t\texit()\n\tm -= 1\n\tm = abs(m)\nif (m%2) == 0:\n\tprint \"Hanako\"\nelse:\n\tprint \"Ciel\""}, {"source_code": "\n\nplayer_one = 'Ciel'\nplayer_two = 'Hanako'\n\n\nc100, c10 = map(int, input().split())\n\nfull_moves = min([c100 // 2, c10 // 24])\n\nc100 -= full_moves * 2\nc10 -= full_moves * 24\n\nwhile True:\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = min([2, c100])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n else:\n print(player_two)\n break\n\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c10 -= 12\n c100 -= 1\n else:\n c10 -= 2\n c100 -= 2\n else:\n print(player_one)\n break\n\n\n\n\n\n\n\n"}, {"source_code": "a, b = map(int, raw_input().split())\nget = ((2, 2), (1, 12), (0, 22))\nwhile True:\n for k in get:\n if a >= k[0] and b >= k[1]:\n a -= k[0]\n b -= k[1]\n break\n else:\n print \"Hanako\"\n break\n for k in reversed(get):\n if a >= k[0] and b >= k[1]:\n a -= k[0]\n b -= k[1]\n break\n else:\n print \"Ciel\"\n break\n "}, {"source_code": "def inp():\n return map(int, input().split())\n\n\nx, y = inp()\nceil, hanako = 1, 0\n\nwhile (True):\n if ceil:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n y -= 22\n else:\n exit(print('Hanako'))\n ceil, hanako = 0, 1\n else:\n if y >= 22:\n y -= 22\n elif y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y >= 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n exit(print('Ciel'))\n hanako, ceil = 0, 1\n"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]\n"}, {"source_code": "hundred, ten = [int(x) for x in input().split()]\ntotal = 100*hundred + 10*ten\n\n#reduce by number of rounds where Ciel can take 2 100-yen and 2 10-yen, and Hanako can take 22 10-yen\nskipped = min(hundred//2,ten//24)\nhundred = hundred - 2*skipped\nten = ten - 24*skipped\n\nwhile True:\n win = 0\n if hundred >= 2 and ten >= 2:\n hundred = hundred - 2\n ten = ten - 2\n elif hundred >= 1 and ten >= 12:\n hundred = hundred - 1\n ten = ten - 12\n elif ten >= 22:\n ten = ten - 22\n else:\n break\n win = 1\n if ten >= 22:\n ten = ten - 22\n elif hundred >= 1 and ten >= 12:\n hundred = hundred - 1\n ten = ten - 12\n elif hundred >= 2 and ten >= 2:\n hundred = hundred - 2\n ten = ten - 2\n else:\n break\nif win == 0:\n print (\"Hanako\")\nelse:\n print (\"Ciel\")\n \n"}, {"source_code": "x, y = map(int, raw_input().split())\nturn = 1\nwhile True:\n if turn % 2 == 1:\n if x >= 2 and y>=2:\n x-=2\n y-=2\n elif x >= 1 and y>=12:\n x-=1\n y-=12\n elif y>=22:\n y-=22\n else:\n print \"Hanako\"\n break\n else:\n if y >= 22:\n y-=22\n elif x >= 1 and y>=12:\n x-=1\n y-=12\n elif x>=2 and y>=2:\n x-=2\n y-=2\n else:\n print \"Ciel\"\n break\n turn += 1\n\n\n"}, {"source_code": "def f(a, b):\n k = min(a, 2)\n return a - k, b - 22 + 10 * k\n\ndef g(a, b):\n if b < 2: return -1, -1\n b -= 2\n k = min(b // 10, 2)\n return a - 2 + k, b - 10 * k\n\ndef main():\n a, b = map(int, input().split())\n k = min(a // 2, b // 24)\n a -= k * 2\n b -= 24 * k\n \n while a > 0:\n a, b = f(a, b)\n if a < 0 or b < 0: return 0\n a, b = g(a, b)\n if a < 0 or b < 0: return 1\n if a == 0: return (b // 22) % 2\n\nprint(['Hanako', 'Ciel'][main()])"}, {"source_code": "import sys\n\nf=sys.stdin\nx,y = map(int, f.readline().strip().split())\n#print x,y\n\n#c 2 2\n#h 0 22\n#z = min(y/24,x/2)\n#x -= z*2\n#y -= z*24\n\nwhile True:\n if 100*x+10*y>=220 and y>=2 and x>=0:\n if x>=2: x,y=x-2,y-2\n elif x==1 and y>=12: x,y=0,y-12\n elif y>=22: y-=22\n else:\n print 'Hanako'\n break\n else:\n print 'Hanako'\n break\n \n if 100*x+10*y>=220 and y>=2 and x>=0:\n if y>=22: y-=22\n elif y>=12: x,y=x-1,y-12\n elif x>=2 and y>=2 : x,y=x-2,y-2\n else:\n print 'Ciel'\n break\n else:\n print 'Ciel'\n break\n \n"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]"}, {"source_code": "n = raw_input()\nlist = n.split()\nx = int(list[0])\ny = int(list[1])\n\nwhile x >= 0 or y >= 0:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif y >= 22:\n y -= 22\n else:\n print \"Hanako\"\n break\n\n if y >= 22:\n y -= 22\n elif y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y >= 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n print \"Ciel\"\n break"}, {"source_code": "x,y=map(int,raw_input().split());y+=22;v=0,;c=-1\nwhile v:x-=v[c];y-=22-v[c]*10;c=~c;v=[i for i in[2,1,0]if(x>=i)*(y>21-10*i)]\nprint\"HCainealk o\"[-c::2]\n"}, {"source_code": "x,y = map(int, raw_input().split())\nr = [(2,2),(1,12),(0,22)]\nwhile True:\n for a in r:\n if x >= a[0] and y >= a[1]:\n x -= a[0]\n y -= a[1]\n break;\n else:\n print \"Hanako\"\n break\n for a in reversed(r):\n if x >= a[0] and y >= a[1]:\n x -= a[0]\n y -= a[1]\n break\n else:\n print \"Ciel\"\n break"}, {"source_code": "n , m = map(int,input().split())\nc = min(n//2 , m//24)\nn-=(2*c)\nm-=(24*c)\nc = min(n//3 , m//14)\nn-=(3*c)\nm-=(14*c)\nc = min(n//4, m//4)\nn-=(4*c)\nm-=(4*c)\nc = min(n , m//32)\nn-=(c)\nm-=(32*c)\nc=m//44\nm-=(44*c)\nif m>=2 and 10*n +m >=22:\n print(\"Ciel\")\nelse:\n print(\"Hanako\")\n\n \n "}], "negative_code": [{"source_code": "x, y = map(int, input().split())\nmoves = 0\nmove = True\nif x == 1000 and y == 1000: move = False\nwhile move:\n if moves % 2 == 0:\n if x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n moves += 1\n y -= 22\n else:\n move = False\n elif moves % 2 == 1:\n if y >= 22:\n moves += 1\n y -= 22\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n else:\n move = False\n\nans = 'Ciel' if moves % 2 == 1 else 'Hanako'\nif x == 1000 and y == 1000:\n print('Ciel')\nelse:\n print(ans)\n\n\n"}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220 and y >= 2:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 2:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-1, y-10\n else:\n x = x-2\nif x%2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "import sys\n\n#f = open('test.in','r')\nf=sys.stdin\nx,y = map(int, f.readline().strip().split())\n\n#c 2 2\n#h 0 22\nz = min(y/24,x/2)\nx -= z*2\ny -= z*24\n\nwhile True:\n if 100*x+10*y>=220 and y>=2 and x>=0:\n #ceil\n if x>=2: x,y=x-2,y-2\n elif x==1 and y>=12: x,y=0,y-12\n else: y-=22\n else:\n print 'Hanako'\n break\n \n if 100*x+10*y>=220 and y>=2 and x>=0:\n #hanako\n if y>=22: y=y-22\n elif y>=12: x,y=x-1,y-12\n else: x,y=x-2,y-2\n else:\n print 'Ceil'\n break\n \n"}, {"source_code": "x,y = map(int, raw_input().split())\ni = 0\nwhile x >= 0 and y >= 0:\n t = 220\n if i == 0:\n if x >= 2:\n x -= 2\n t -= 200\n else:\n t -= 2*x\n x -= x\n y -= t/10\n else: \n if y >= 22:\n y -= 22\n t -= 220\n elif y >= 12:\n y -= 12\n t -= 120\n else:\n y -= 2\n t -= 20\n x -= t/100\n i ^= 1\nprint [\"Ciel\", \"Hanako\"][i]"}, {"source_code": "x,y = [int(z) for z in input().split()]\nwhile(True):\n\tif( y < 2 or x < 2):\n\t\tprint('Hanako')\n\t\tbreak\n\tif(x >= 2 and y >= 2):\n\t\tx -= 2\n\t\ty -= 2\n\telif(x*100+y*10 >= 220 and y > 0):\n\t\ty -= (220 - x*100)//10\n\t\tx = 0\n\telse:\n\t\tprint('Hanako')\n\t\tbreak\n\tif(y >= 22):\n\t\ty -= 22\n\telif(x*100+y*10 >= 220 and y>0):\n\t\ty -= 2\n\t\ttmp = (y*10)//100\n\t\ty -= (tmp*100)//10\n\t\tx -= (2-tmp)\n\telse:\n\t\tprint('Ciel')\n\t\tbreak\n\n"}, {"source_code": "x,y = [int(z) for z in input().split()]\nwhile(True):\n\tif(x*100+y*10 >= 220 and y > 0):\n\t\tx -= 2\n\t\ty -= 2\n\telse:\n\t\tprint('Hanako')\n\t\tbreak\n\tif(y >= 22):\n\t\ty -= 22\n\telif(x*100+y*10 >= 220 and y>0):\n\t\ty -= 2\n\t\ttmp = (y*10)//100\n\t\ty -= (tmp*100)//10\n\t\tx -= (2-tmp)\n\telse:\n\t\tprint('Ciel')\n\t\tbreak\n\n"}, {"source_code": "from sys import stdin\n\n(x, y) = [int(buf) for buf in stdin.readline().strip().split()]\n\nk = min(x//2, y//20)\n\nx -= 2 * k\ny -= 20 * k\n\nans = 0\nwhile y >= 2 and x*100 + y*10 >= 220:\n ans = 1 - ans\n if ans == 1:\n y -= 22 - max(x, 2) * 10\n x -= max(x, 2)\n else:\n x -= 2 - max((y-2)//10, 2)\n y -= 2 + max((y-2)//10, 2) * 10\n\nprint('Ciel' if ans == 1 else 'Hanako')\n"}, {"source_code": "\n\nplayer_one = 'Ciel'\nplayer_two = 'Hanako'\n\n\nc100, c10 = map(int, input().split())\n\nfull_moves = min([c100 // 2, c10 // 24])\n\nc100 -= full_moves * 2\nc10 -= full_moves * 24\n\nsolved = False\n\nif c100 < 2:\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([c100 - 2, 0])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n else:\n print(player_two)\n solved = True\n\n if not solved:\n if (c10 // 22) % 2 == 1:\n print(player_two)\n else:\n print(player_one)\n\nelse:\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([c100 - 2, 0])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n elif not solved:\n print(player_two)\n solved = True\n\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c100 -= 1\n c10 -= 12\n else:\n c100 -= 2\n c10 -= 2\n elif not solved:\n print(player_one)\n solved = True\n\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([c100 - 2, 0])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n elif not solved:\n print(player_two)\n solved = True\n\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c100 -= 1\n c10 -= 12\n else:\n c100 -= 2\n c10 -= 2\n elif not solved:\n print(player_one)\n solved = True\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([c100 - 2, 0])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n elif not solved:\n print(player_two)\n solved = True\n\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c100 -= 1\n c10 -= 12\n else:\n c100 -= 2\n c10 -= 2\n elif not solved:\n print(player_one)\n solved = True\n\n\n"}, {"source_code": "x, y = map(int, input().split())\ntot = (x*100) + (y*10)\nmoves = 0\n\nwhile tot >= 220 and x > 2 and y > 2:\n if moves % 2 == 0:\n initial = 220\n\n initial -= min(2, x) * 100\n x -= min(2, x)\n\n y -= initial // 10\n else:\n initial = 220\n\n if y >= 22:\n y -= 22\n elif y >= 12:\n y -= 12\n x -= 1\n elif y >= 2:\n y -= 2\n x -= 2\n\n tot = (x*100) + (y*10) \n moves += 1\n\nname = 'Ciel' if moves % 2 == 1 else 'Hanako'\nprint(name)\n"}, {"source_code": "c_ch = [(2, 2), (1, 12), (0, 22)]\n\ndef choose (turn, x, y):\n for a, b in c_ch[::turn]:\n if x >= a and y >= b:\n return (x-a, y-b)\n return (-1, -1)\n\ndef main (x, y):\n turn = 1 # ceilia\n while (x, y) != (-1, -1):\n x, y = choose (turn, x, y)\n turn = -1 * turn\n\n if turn == 1:\n print \"Celia\"\n else:\n print \"Hanako\"\n\nif __name__ == '__main__':\n [x, y] = map (int, raw_input().split())\n main (x, y)\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\nimport datetime\n# import webbrowser\n\nhundred_coin, ten_coin = map(int, input().split())\nwon = 0\nfor i in range(0, 10000000):\n if i % 2 == 0:\n ciel_money = 0\n # wrote code for ciel\n if hundred_coin >= 2:\n hundred_coin -= 2\n ciel_money += 2 * 100\n if ten_coin >= 2:\n ciel_money += 2*10\n ten_coin -= 2\n else:\n won = \"Hanako\"\n break\n else:\n if hundred_coin == 1:\n hundred_coin = 0\n ciel_money += 100\n if ten_coin >= 12:\n ciel_money += 120\n ten_coin -= 12\n elif ten_coin >= 11:\n ciel_money += 110\n ten_coin -= 11\n else:\n won = \"Hanako\"\n break\n else:\n if ten_coin >= 22:\n ciel_money += 220\n ten_coin -= 22\n else:\n won = \"Hanako\"\n break\n if ciel_money == 220:\n continue\n else:\n won = \"Hanako\"\n break\n elif i % 2 != 0:\n hanako_money = 0\n # now for hanako\n if ten_coin >= 22:\n hanako_money += 220\n ten_coin -= 22\n elif ten_coin >= 12:\n hanako_money += 120\n ten_coin -= 12\n if hundred_coin > 0:\n hanako_money += 100\n hundred_coin -= 1\n else:\n won = \"Ciel\"\n break\n elif ten_coin >= 2:\n hanako_money += 20\n ten_coin -= 2\n if hundred_coin >= 2:\n hanako_money += 200\n hundred_coin -= 2\n elif hundred_coin == 1:\n hanako_money += 100\n hundred_coin -= 1\n else:\n won = \"Ciel\"\n break\n else:\n won = \"Ceil\"\n break\n if hanako_money == 220:\n continue\n else:\n won = \"Ciel\"\n break\nprint(won)\n"}, {"source_code": "x, y = map(int, input().split())\ntot = (x*100) + (y*10)\nmoves = 0\n\nwhile tot >= 220:\n if moves % 2 == 0:\n initial = 220\n\n initial -= min(2, x) * 100\n x -= min(2, x)\n\n y -= initial // 10\n moves += 1\n else:\n initial = 220\n\n if y >= 22:\n y -= 22\n elif y >= 12:\n y -= 12\n x -= 1\n elif y >= 2:\n y -= 2\n x -= 2\n moves += 1\n\n tot = (x*100) + (y*10) \n if moves == 0: break\n\nname = 'Ciel' if moves % 2 == 1 else 'Hanako'\nprint(name)\n"}, {"source_code": "x,y=map(int,input().split())\ni=0\nsum=x*100+y*10\nwhile (sum>=220):\n if (y<2):\n break\n if (i%2==0):\n if (x>=2):\n x-=2\n if (y>=2):\n y-=2\n else:\n break\n else:\n break\n else:\n if (y>=22):\n y-=22\n else:\n if (y>=12):\n y-=12\n x-=1\n elif (y>=2):\n y-=2\n x-=2\n \n sum-=220\n i+=1\n \n \n \nif (i%2==0):\n print(\"Hanako\")\nelse:\n print (\"Ciel\")\n "}, {"source_code": "import sys\nimport math\n\nlines = [i.rstrip() for i in sys.stdin.readlines()]\nsplit = lines[0].split(\" \")\nx = int(split[0])\ny = int(split[1])\n\nm = x * 100 + y * 10\n\nd = int(math.floor(float(m) / 220.0))\nif (d % 2 == 0):\n print \"Hanako\"\nelse:\n print \"Ciel\"\n"}, {"source_code": "import sys\nimport math\n\nx, y = [int(x) for x in (sys.stdin.readline()).split()]\n\nt = 1\nwhile(1):\n if(x >= 2 and y >= 2):\n x -= 2\n y -= 2\n elif(x >= 1 and y >= 12):\n x -= 1\n y -= 1\n elif(x == 0 and y >= 22):\n y -= 22\n else:\n if(t % 2 != 0):\n print(\"Hanako\")\n exit()\n else:\n print(\"Ciel\")\n exit()\n \n t += 1\n "}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220 and y >= 2:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 1:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-1, y-10\n else:\n x = x-2\n print x,y\n i += 1\nif i%2:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "#print \"\".join(reduce(lambda x,y:(x[0][2:],x[1]+(x[0][2:]+\"<\"+y+\"\\n\",)) if y[0]=='/' else (x[0]+\" \",x[1]+(x[0]+\"<\"+y+\"\\n\",)),raw_input().split(\"<\")[1:],(\"\",()))[1])\n#print reduce(lambda x,y:(x[0]+(1 if y in x[1] else 0),x[1].symmetric_difference(set([y]))),map(int,(raw_input(),raw_input())[1].split()),(0,set()))[0]/2\nvrs=((2,2),(1,12),(0,22))\ndef ceil(c,d):\n for i,j in vrs:\n if c>=i and d>=j:\n return (c-i,d-j)\n print \"Hanako\"\n raise SystemExit()\n\ndef hanako(c,d):\n for i,j in reversed(vrs):\n if c>=i and d>=j:\n return (c-i,d-j)\n print \"Ceil\"\n raise SystemExit()\n\nx,y=map(int,raw_input().split())\nwhile 1:\n x,y=ceil(x,y)\n x,y=hanako(x,y)\n"}, {"source_code": "x, y = map(int, input().split())\nwhile True:\n # Ciel prefers large coins.\n a = min(2, x)\n x -= a\n b = min(22 - 10 * a, y)\n y -= b\n if 10 * a + b < 22:\n print('Hanako')\n break\n\n # Hanaka prefers small coins. \n # Start by maximizing the number of large coins.\n a = min(2, x)\n x -= a\n b = min(22 - 10 * a, y)\n y -= b\n if 10 * a + b < 22:\n print('Ciel')\n break\n # Exchange large coins for small.\n while a > 0 and y >= 10:\n a -= 1\n y -= 10\n"}, {"source_code": "x, y = [int(x) for x in input().split()]\n\ndef even_move(x, y):\n if x >= 2 and y >= 2:\n return [True, x - 2, y - 2]\n if x >= 1 and y >= 11:\n return [True, x - 1, y - 11]\n if y >= 22:\n return [True, x, y - 22]\n return [False, x, y]\n\ndef odd_move(x, y):\n if y >= 22:\n return [True, x, y - 22]\n if x >= 1 and y >= 11:\n return [True, x - 1, y - 11]\n if x >= 2 and y >= 2:\n return [True, x - 2, y - 2]\n return [False, x, y]\n\ndef game(x, y):\n even = 'Ciel'\n odd = 'Hanako'\n i = 0\n while True:\n if i % 2 == 0:\n move = even_move(x, y)\n if move[0]:\n x = move[1]\n y = move[2]\n else:\n return odd\n else:\n move = odd_move(x, y)\n if move[0]:\n x = move[1]\n y = move[2]\n else:\n return even\n i += 1\n\nprint(game(x, y))\n\n"}, {"source_code": "n, m = map(int, input().split())\ni = 1\nwhile 2 > 1:\n if(i & 1):\n if(n * 100 + m * 10 >= 220):\n if(n >= 2 and m >= 2):\n n -= 2\n m -= 2\n elif(m >= 22):\n m -= 22\n else:\n print('Hanako')\n exit(0)\n else:\n print('Hanako')\n exit(0)\n else:\n if(n * 100 + m * 10 >= 220):\n if(m >= 22):\n m -= 22\n elif(n == 2):\n n -= 2\n m -= 2\n elif(n == 1):\n n -= 1\n m -= 12\n else:\n print('Ciel')\n exit(0)\n else:\n print('Ciel')\n exit(0)\n i += 1"}, {"source_code": "def busgame(x,y):\n while 1:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n y -= 22\n else:\n return 'Hannako'\n\n if y >= 22:\n y -= 22\n elif 22 > y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y < 12 and x >= 2:\n y -= 2\n x -= 2\n else:\n return 'Ciel'\n\n\n\nx, y = [int(x) for x in input().split()]\nprint(busgame(x,y))"}, {"source_code": "x, y = map(int, input().split())\ntot = (x*100) + (y*10)\nmoves = 0\n\nwhile tot >= 220:\n if moves % 2 == 0:\n initial = 220\n\n initial -= min(2, x) * 100\n x -= min(2, x)\n\n y -= initial // 10\n moves += 1\n else:\n initial = 220\n\n if y >= 22:\n y -= 22\n elif y >= 12:\n y -= 12\n x -= 1\n elif y >= 2:\n y -= 2\n x -= 2\n moves += 1\n\n tot = (x*100) + (y*10) \n if moves == 0: break\n\nname = 'Ciel' if moves % 2 == 1 else 'Hanako'\nprint(name)\n"}, {"source_code": "def CielTurn(a):\n a[0] -= 2\n a[1] -= 2\n if a[0] < 0:\n a[1] += a[0] * 10\n a[0] = 0\n return a\n \ndef HanakoTurn(a):\n a[1] -= 22\n while a[1] < 0:\n a[0] -= 1\n a[1] += 10\n return a\n\ns = raw_input().split()\na = [int(s[0]), int(s[1])]\n\nwhile True:\n a = CielTurn(a)\n if a[0] < 0 or a[1] < 0:\n t = \"Hanako\"\n break\n a = HanakoTurn(a)\n if a[0] < 0 or a[1] < 0:\n t = \"Ciel\"\n break\nprint t"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total >= 220:\n # Ciel\n if turn == 0:\n t = 220\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n\n total -= 220\n\n if total < 220:\n break\n\n turn = 1\n \n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n\n total -= 220\n\n if total < 220:\n break\n turn = 0\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total >= 220:\n if turn == 0:\n t = 220\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n turn = 1\n total -= 220\n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n turn = 0\n total -= 220\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 2:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-y, y-10\n else:\n x = x-2\nif x%2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "def f(a, b):\n k = min(a, 2)\n return a - k, b - 22 + 10 * k\n\ndef g(a, b):\n b -= 2\n k = min(b // 10, 2)\n return a - 2 + k, b - 10 * k\n\ndef main():\n a, b = map(int, input().split())\n k = min(a // 2, b // 24)\n a -= k * 2\n b -= 24 * k\n while a > 0:\n a, b = f(a, b)\n if a < 0 or b < 0: return 0\n a, b = f(a, b)\n if a < 0 or b < 0: return 1\n if a == 0: return (b // 22) % 2\n\nprint(['Hanako', 'Ciel'][main()])"}, {"source_code": "x,y = [int(z) for z in input().split()]\nwhile(True):\n\tif( y < 2 or x < 2):\n\t\tprint('Hanako')\n\t\tbreak\n\tif(x >= 2 and y >= 2):\n\t\tx -= 2\n\t\ty -= 2\n\telif(x*100+y*10 >= 220 and y > 0):\n\t\ty -= (220 - x*100)//10\n\t\tx = 0\n\telse:\n\t\tprint('Hanako')\n\t\tbreak\n\tif(y >= 22):\n\t\ty -= 22\n\telif(x*100+y*10 >= 220 and y>0):\n\t\ty -= 2\n\t\ttmp = (y*10)//100\n\t\ty -= (tmp*100)//10\n\t\tx -= (2-tmp)\n\telse:\n\t\tprint('Ciel')\n\t\tbreak\n\n"}, {"source_code": "c_ch = [(2, 2), (1, 12), (0, 22)]\n\ndef choose (turn, x, y):\n for a, b in c_ch[::turn]:\n if x >= a and y >= b:\n return (x-a, y-b)\n return (-1, -1)\n\ndef main (x, y):\n turn = 1 # ceilia\n while (x, y) != (-1, -1):\n x, y = choose (turn, x, y)\n turn = -1 * turn\n\n if turn == 1:\n print \"Ceil\"\n else:\n print \"Hanako\"\n\nif __name__ == '__main__':\n [x, y] = map (int, raw_input().split())\n main (x, y)\n"}, {"source_code": "nums = raw_input().split()\nx, y = [int(num) for num in nums]\ni = 0\nwhile True:\n if i % 2 == 0:\n #ciel round\n choosex = 2 if x >= 2 else x\n x -= choosex\n if 22 - 10 * choosex <= y:\n y -= 22 - 10 * choosex\n else:\n break\n else:\n #hanako round\n choosey = 22\n if 12 <= y < 22:\n choosey = y\n elif 2 <= y < 12:\n choosey = 2\n elif y < 2:\n choosey = 0\n break\n y -= choosey\n if (220 - choosey * 10) / 100 <= x:\n x -= (220 - choosey * 10) / 100\n else:\n break\n i += 1\n#print i\nprint 'Ciel' if i % 2 != 0 else 'Hanako'"}, {"source_code": "x,y = [int(z) for z in input().split()]\nwhile(True):\n\tif( y < 2 or x < 2):\n\t\tprint('Hanako')\n\t\tbreak\n\tif(x >= 2 and y >= 2):\n\t\tx -= 2\n\t\ty -= 2\n\telif(x*100+y*10 >= 220 and y > 0):\n\t\ty -= (220 - x*100)//10\n\t\tx = 0\n\telse:\n\t\tprint('Hanako')\n\t\tbreak\n\tif(y >= 22):\n\t\ty -= 22\n\telif(x >= 2 and y >= 2):\n\t\ty -= 2\n\t\ttmp = (y*10)//100\n\t\ty -= (tmp*100)//10\n\t\tx -= (2-tmp)\n\telse:\n\t\tprint('Ciel')\n\t\tbreak\n\n"}, {"source_code": "x, y =map(int, input().split())\np = True\ndez = [2, 22, 12]\ncem = [2,0,1]\nwhile True:\n # print(x, y)\n if p:\n for i in range(3):\n if x >= cem[i] and y >= dez[i]:\n x -= cem[i]\n y -= dez[i]\n break\n else:\n print(\"Hanako\")\n exit()\n else:\n for i in range(2, -1, -1):\n if x >= cem[i] and y >= dez[i]:\n x -= cem[i]\n y -= dez[i]\n break\n else:\n print(\"Ciel\")\n exit()\n p = not p\n"}, {"source_code": "x,y = [int(z) for z in input().split()]\nwhile(True):\n\tif(x*100+y*10 >= 220 and y > 0):\n\t\tx -= 2\n\t\ty -= 2\n\telse:\n\t\tprint('Hanako')\n\t\tbreak\n\tif(y >= 22):\n\t\ty -= 22\n\telif(x*100+y*10 >= 220 and y>0):\n\t\ty -= 2\n\t\ttmp = (y*10)//100\n\t\ty -= (tmp*100)//10\n\t\tx -= (2-tmp)\n\telse:\n\t\tprint('Ciel')\n\t\tbreak\n\n"}, {"source_code": "n , m = map(int,input().split())\nc = min(n//2 , m//24)\nn-=(2*c)\nm-=(24*c)\nc = min(n//3 , m//14)\nn-=(3*c)\nm-=(14*c)\nc = min(n//4, m//4)\nn-=(4*c)\nm-=(4*c)\nc = min(n , m//32)\nn-=(c)\nm-=(32*c)\nc=m//44\nm-=(44*c)\nif m>=2 and 10*n +m >=22:\n print(\"Ceil\")\nelse:\n print(\"Hanako\")\n\n \n "}, {"source_code": "x,y = [int(z) for z in input().split()]\nn = 1\nif x//2>0 and y//24 >0 :\n\tn = min(x//2,y//24)\n\tx -= 2 * n\n\ty -= 24 * n\n\tif (n%2 == 0):\n\t\tn += 1\nwhile(True):\n\t#print (n,x,y)\n\tif n%2 :\n\t\tif y < 2:\n\t\t\tprint('Hanako')\n\t\t\tbreak\n\t\ty -= 2\n\t\tif x < 2:\n\t\t\ttmp = (200 - x*100)//10\n\t\t\tif y < tmp :\n\t\t\t\tprint('Hanako')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\ty -= tmp\n\t\t\t\tx = 0\n\t\telse:\n\t\t\tx -= 2\n\t#\tprint('c',x,y)\n\telse:\n\t\tif y < 2:\n\t\t\tprint('Ciel')\n\t\t\tbreak\n\t\tif y < 22 :\n\t\t\ty -= 2\n\t\t\ttmp = (y * 10)//100\n\t\t\ty -= (tmp *100)//10\n\t\t\tif x < tmp :\n\t\t\t\tprint('Ciel')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif x < (2 - tmp):\n\t\t\t\t\tprint('Ceil')\n\t\t\t\t\tbreak\n\t\t\t\tx -= (2 - tmp)\n\t\telse:\n\t\t\ty -= 22\n\t#\tprint ('h',x,y)\n\tn += 1\n"}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220 and y >= 2:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 2:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-1, y-10\n else:\n x = x-2\nif x%2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "x, y = [ int(i) for i in raw_input().split() ]\nif ((10 * x + y) / 22) % 2: print(\"Ciel\")\nelse: print(\"Hanako\")\n"}, {"source_code": "import sys\nimport re\n\ndef readTuple(type, input=sys.stdin):\n return map(int, input.readline().split())\n\nn, m = readTuple(int)\nC = {}\nC[100] = n\nC[10] = m\n\ndef isPossible(c):\n if c[10] >= 22: return True\n elif c[100] == 2 and c[10] >= 2: return True\n elif c[100] == 1 and c[10] >= 12: return True\n return False\n\ndef getValues(c, x):\n if x == \"Ciel\":\n if c[100] == 0:\n return (0, 22)\n elif c[100] == 1:\n return (1, 12)\n elif c[100] >= 2:\n return (2, 2)\n elif x == \"Hanako\":\n if c[10] >= 22:\n return (0, 22)\n elif c[10] >= 12:\n return (1, 12)\n\nm = \"Ciel\"\nwhile True:\n if m == \"Ciel\":\n if not isPossible(C):\n print(\"Hanako\")\n break\n a, b = getValues(C, m)\n C[100] -= a\n C[10] -= b\n m = \"Hanako\"\n elif m == \"Hanako\":\n if not isPossible(C):\n print(\"Ciel\")\n break\n a, b = getValues(C, m)\n C[100] -= a\n C[10] -= b\n m = \"Ciel\" \n\n"}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220 and y >= 2:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 1:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-1, y-10\n else:\n x = x-2\n print x,y\n i += 1\nif i%2:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "x,y=map(int,input().split())\nCeil=True\nwhile True:\n if Ceil:\n if x>=2:\n if y>=2:\n x-=2; y-=2; Ceil=False\n else:\n print(\"Hanako\"); exit()\n elif x==1:\n if y>=12:\n x-=1; y-=12; Ceil=False\n else:\n print(\"Hanako\"); exit()\n else:\n if y>=22:\n y-=22; Ceil=False\n else:\n print(\"Hanako\"); exit()\n else:\n if y>=22:\n y-=22;Ceil=True\n elif y>=12:\n if x>=1:\n x-=1;y-=12;Ceil=True\n else:\n print(\"Ceil\"); exit()\n elif y>=2:\n if x>=2:\n x-=2;y-=2;Ceil=True\n else:\n print(\"Ceil\"); exit()\n else:\n print(\"Ceil\"); exit()\n \n \n \n"}, {"source_code": "s = raw_input().split()\na = int(s[0]) * 10 + int(s[1])\n\nif a / 22 % 2 == 1:\n print \"Ciel\"\nelse:\n print \"Hanako\""}, {"source_code": "def Ciel(x, y):\n\ts = True\n\tif (x >= 2):\n\t\tx = x - 2\n\t\ty = y - 2\n\telif (x == 1):\n\t\tx = x - 1\n\t\ty = y - 12\n\telse:\n\t\ty = y - 22\n\tif y < 0: s = False\n\treturn x, y, s\n\ndef Hanako(x, y):\n\ts = True;\n\tif (y >= 22):\n\t\ty = y - 22\n\telif (y >= 12):\n\t\ty = y - 12\n\t\tx = x - 1\n\telse:\n\t\ty = y - 2\n\t\tx = x - 2\n\tif (x < 0): s = False\n\treturn x, y, s\n\t\t\n\nx, y = [ int(i) for i in raw_input().split() ]\n\nwhile 1:\n\tx, y, s = Ciel(x, y);\n\tif (not s):\n\t\tprint \"Hanako\"\n\t\tbreak\n\tx, y, s = Hanako(x, y);\n\tif (not s):\n\t\tprint \"Ciel\"\n\t\tbreak\n"}, {"source_code": "def busgame(x,y):\n while 1:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n y -= 22\n else:\n return 'Hanako'\n\n if y >= 22:\n y -= 22\n elif 22 > y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y < 12 and x >= 2:\n y -= 2\n x -= 2\n else:\n return 'Ciel'\n\n\n\nx, y = [int(x) for x in input().split()]\nprint(busgame(x,y))"}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 2:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-y, y-10\n else:\n x = x-2\nif x%2 == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "Piles, Ceil, Hanako= {}, 1, 1\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: SumOfYens = 220; Piles[10] -= (220 - SumOfYens)/10\n else: Ceil = 0\n if Ceil == 0: break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: Hanako = 0\n if Hanako == 0: break\nif Ceil == 0: print(\"Hanako\")\nelse: print(\"Ciel\")"}, {"source_code": "x,y = [int(z) for z in input().split()]\nwhile(True):\n\tif( y < 2 or x < 2):\n\t\tprint('Hanako')\n\t\tbreak\n\tif(x >= 2 and y >= 2):\n\t\tx -= 2\n\t\ty -= 2\n\telif(x*100+y*10 >= 220 and y > 0):\n\t\ty -= (220 - x*100)//10\n\t\tx = 0\n\telse:\n\t\tprint('Hanako')\n\t\tbreak\n\tif(y >= 22):\n\t\ty -= 22\n\telif(x >= 2 and y >= 2):\n\t\ty -= 2\n\t\ttmp = (y*10)//100\n\t\ty -= (tmp*100)//10\n\t\tx -= (2-tmp)\n\telse:\n\t\tprint('Ciel')\n\t\tbreak\n\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total >= 220:\n # Ciel\n if turn == 0:\n t = 220\n\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n\n total -= 220\n turn = 1\n\n\n \n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n\n total -= 220\n turn = 0\n\n\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "def Ciel(x, y):\n\ts = True\n\tif (x >= 2):\n\t\tx = x - 2\n\t\ty = y - 2\n\telif (x == 1):\n\t\tx = x - 1\n\t\ty = y - 12\n\telse:\n\t\ty = y - 22\n\tif y < 0: s = False\n\treturn x, y, s\n\ndef Hanako(x, y):\n\ts = True;\n\tif (y >= 22):\n\t\ty = y - 22\n\telif (y >= 12):\n\t\ty = y - 12\n\t\tx = x - 1\n\telse:\n\t\ty = y - 2\n\t\tx = x - 2\n\tif (x < 0): s = False\n\treturn x, y, s\n\t\t\n\nx, y = [ int(i) for i in raw_input().split() ]\n\nwhile 1:\n\tx, y, s = Ciel(x, y);\n\tif (not s):\n\t\tprint \"Hanako\"\n\t\tbreak\n\tx, y, s = Hanako(x, y);\n\tif (not s):\n\t\tprint \"Ciel\"\n\t\tbreak\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total >= 220:\n # Ciel\n if turn == 0:\n t = 220\n\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n\n total -= 220\n turn = 1\n\n\n \n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n\n total -= 220\n turn = 0\n\n\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "def readln(): return tuple(map(int, input().split()))\n\nx, y = readln()\nx *= 100\ny *= 10\n_ = 0\nwhile x + y >= 220:\n if _ == 0:\n if x >= 200:\n x -= 200\n y -= 20\n elif x == 100:\n x -= 100\n y -= 120\n else:\n y -= 220\n else:\n if y >= 220:\n y -= 220\n elif y >= 120:\n y -= 120\n x -= 100\n else:\n y -= 20\n x -= 200\n _ = ( _ + 1) % 2\nprint('Hanako' if not _ else 'Ciel')\n"}, {"source_code": "x, y = map(int, input().split())\nmoves = 0\nmove = True\nwhile move:\n if moves % 2 == 0:\n if x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n moves += 1\n y -= 22\n else:\n move = False\n elif moves % 2 == 1:\n if x == 0 and y >= 22:\n moves += 1\n y -= 1\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n else:\n move = False\n\nans = 'Ciel' if moves % 2 == 1 else 'Hanako'\nprint(ans)\n\n\n"}, {"source_code": "x,y = [int(z) for z in input().split()]\nn = 1\nif x//2>0 and y//24 >0 :\n\tn = min(x//2,y//24)\n\tx -= 2 * n\n\ty -= 24 * n\n\tif (n%2 == 0):\n\t\tn += 1\nwhile(True):\n\t#print (n,x,y)\n\tif n%2 :\n\t\tif y < 2:\n\t\t\tprint('Hanako')\n\t\t\tbreak\n\t\ty -= 2\n\t\tif x < 2:\n\t\t\ttmp = (200 - x*100)//10\n\t\t\tif y < tmp :\n\t\t\t\tprint('Hanako')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\ty -= tmp\n\t\t\t\tx = 0\n\t\telse:\n\t\t\tx -= 2\n\t#\tprint('c',x,y)\n\telse:\n\t\tif y < 2:\n\t\t\tprint('Ciel')\n\t\t\tbreak\n\t\tif y < 22 :\n\t\t\ty -= 2\n\t\t\ttmp = (y * 10)//100\n\t\t\ty -= (tmp *100)//10\n\t\t\tif x < tmp :\n\t\t\t\tprint('Ciel')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif x < (2 - tmp):\n\t\t\t\t\tprint('Ceil')\n\t\t\t\t\tbreak\n\t\t\t\tx -= (2 - tmp)\n\t\telse:\n\t\t\ty -= 22\n\t#\tprint ('h',x,y)\n\tn += 1\n"}, {"source_code": "x, y = [int(i) for i in raw_input().split()]\n\ni=0\nwhile x*100+y*10 >= 220 and y >= 2:\n if i%2 == 0: #ciel\n if x >= 2:\n x, y = x-2, y-2\n elif x == 1:\n x, y = x-1, y-12\n else:\n y = y-22\n else:\n y = y-2\n if y >= 20:\n y = y-20\n elif y >= 10:\n x, y = x-1, y-10\n else:\n x = x-2\n print x,y\n i += 1\nif i%2:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "x, y = [ int(i) for i in raw_input().split() ]\nif ((10 * x + y) / 22) % 2: print(\"Ciel\")\nelse: print(\"Hanako\")\n"}, {"source_code": "Piles, Ceil, Hanako= {}, 1, 1\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: SumOfYens = 220; Piles[10] -= (220 - SumOfYens)/10\n else: Ceil = 0\n if Ceil == 0: break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: Hanako = 0\n if Hanako == 0: break\nif Ceil == 0: print(\"Hanako\")\nelse: print(\"Ceil\")"}, {"source_code": "Piles= {}\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: Piles[10] -= (220 - SumOfYens)/10\n else: print(\"Honako\"); break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: print(\"Ciel\"); break"}, {"source_code": "import sys\n\na, b = map(int, sys.stdin.readline().strip().split(' '))\nplayers = ['Ciel','Hanako']\n\nwhile True:\n player = players.pop(0)\n sum = 0\n\n while a > 0:\n if sum == 200:\n break\n sum += 100\n a -= 1\n\n while b > 0:\n if sum == 220:\n break\n sum += 10\n b -= 1\n \n if sum != 220:\n if player == 'Ciel':\n print 'Hanako'\n else:\n print 'Ciel'\n break\n else:\n players.append(player)\n"}, {"source_code": "x,y=map(int,input().split())\nmauka=0 \nwhile 1:\n if mauka==0:\n if x>=2 and y>=2:\n x=x-2 \n y=y-2\n elif x>=1 and y>=12:\n x=x-1 \n y=y-12\n elif x==0 and y>=22:\n y=y-22\n else:\n culprit=0 \n break \n else:\n if y>=22:\n y=y-22\n elif y>=12 and x>=1:\n y=y-12\n x=x-1 \n elif y>=2 and x>=2:\n x=x-2 \n y=y-2\n else:\n culprit=1 \n break \n # print(x,y)\n mauka=1-mauka\nif culprit:\n print('Ceil')\nelse:\n print('Hanako')"}, {"source_code": "n, m = map(int, input().split())\ni = 1\nwhile 2 > 1:\n if(i & 1):\n if(n * 100 + m * 10 >= 220):\n if(n >= 2 and m >= 2):\n n -= 2\n m -= 2\n elif(m >= 22):\n m -= 22\n else:\n print('Hanako')\n exit(0)\n else:\n print('Hanako')\n exit(0)\n else:\n if(n * 100 + m * 10 >= 220):\n if(m >= 22):\n m -= 22\n elif(n == 2):\n n -= 2\n m -= 2\n elif(n == 1):\n n -= 1\n m -= 12\n else:\n print('Ciel')\n exit(0)\n else:\n print('Ciel')\n exit(0)\n i += 1"}, {"source_code": "x, y =map(int, input().split())\np = True\ndez = [2, 22, 12]\ncem = [2,0,1]\nwhile True:\n # print(x, y)\n if p:\n for i in range(3):\n if x >= cem[i] and y >= dez[i]:\n x -= cem[i]\n y -= dez[i]\n break\n else:\n print(\"Hanako\")\n exit()\n else:\n for i in range(2, -1, -1):\n if x >= cem[i] and y >= dez[i]:\n x -= cem[i]\n y -= dez[i]\n break\n else:\n print(\"Ciel\")\n exit()\n p = not p\n"}, {"source_code": "\n\ndef eina1(a):\n if a[1]>=2 and a[0]>=2:\n a[0]-=2;a[1]-+2;return a\n if a[0]>=1 and a[1]>=12:\n a[0]-=1;a[1]-=12;return a\n if a[0]==0 and a[1]>=22:\n a[1]-=22;return a\n return \"lost\"\n\ndef eina2(a):\n if a[1]>=22:\n a[1]-=22;return a\n if a[1]>=12 and a[0]>=1:\n a[1]-=12;a[0]-=1;return a\n if a[1]>=2 and a[0]>=2:\n a[1]-=2;a[0]-=2;return a\n return \"lost\"\n\n\na=raw_input().split( )\na[0]=int(a[0])\na[1]=int(a[1])\nfor i in range((((a[0]*100) + (a[1]*10))/220) +1):\n if i%2==0:\n if(eina1(a)==\"lost\"):\n print \"Hanako\";break\n else:\n if(eina2(a)==\"lost\"):\n print \"Ciel\";break\n\n\n\n\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total >= 220:\n if turn == 0:\n t = 220\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n turn = 1\n total -= 220\n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n turn = 0\n total -= 220\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "A= map(int,raw_input().split())\nturn = 0\ndef findWay () :\n a , b = 0 , 0\n if turn == 0 :\n a = min ( A[0] , 2 )\n b = ( 220 - 100 * a ) / 10 \n if b > A[1] :\n return False\n else :\n A[0] -= a \n A [1] -= b \n return True\n if A[1] >= 22 :\n b = 22\n elif A[1] >= 12 :\n b = 12\n elif A[1] >= 2 :\n b = 2\n else:\n return False\n a = ( 220 - 10 * b ) / 100\n if a > A[0]:\n return False\n else:\n A[0] -= a\n A[1] -= b\n return True\nwhile findWay() :\n turn = (turn+1)%2\nif turn == 1 : print \"Ceil\"\nelse : print \"Hanako\"\n\n \n"}, {"source_code": "def busgame(x,y):\n while 1:\n if x >= 2 and y >= 2:\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n y -= 22\n else:\n return 'Hanako'\n\n if y >= 22:\n y -= 22\n elif 22 > y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif 12 > y > 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n return 'Ciel'\n\n\n\nx, y = [int(x) for x in input().split()]\nprint(busgame(x,y))"}, {"source_code": "x,y=map(int,input().split())\ni=0\nsum=x*100+y*10\nwhile (sum>=220):\n sum-=220\n i+=1\nif (i%2==0):\n print(\"Hanako\")\nelse:\n print (\"Ciel\")\n "}, {"source_code": "def Ciel(x, y):\n\ts = True\n\tif (x >= 2):\n\t\tx = x - 2\n\t\ty = y - 2\n\telif (x == 1):\n\t\tx = x - 1\n\t\ty = y - 12\n\telse:\n\t\ty = y - 22\n\tif y < 0: s = False\n\treturn x, y, s\n\ndef Hanako(x, y):\n\ts = True;\n\tif (y >= 22):\n\t\ty = y - 22\n\telif (y >= 12):\n\t\ty = y - 12\n\t\tx = x - 1\n\telse:\n\t\ty = y - 2\n\t\tx = x - 2\n\tif (x < 0): s = False\n\treturn x, y, s\n\t\t\n\nx, y = [ int(i) for i in raw_input().split() ]\nt = min((x / 2), (y / 24))\nx = x - t * 2;\ny = y - t * 24;\nwhile 1:\n\tx, y, s = Ciel(x, y);\n\tif (not s):\n\t\tprint \"Hanako\"\n\t\tbreak\n\tx, y, s = Hanako(x, y);\n\tif (not s):\n\t\tprint \"Ciel\"\n\t\tbreak\n"}, {"source_code": "s = raw_input().split()\na = int(s[0]) * 10 + int(s[1])\n\nif a / 22 % 2 == 1:\n print \"Ciel\"\nelse:\n print \"Hanako\""}, {"source_code": "Piles, Ceil, Hanako= {}, 1, 1\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: SumOfYens = 220; Piles[10] -= (220 - SumOfYens)/10\n else: Ceil = 0\n if Ceil == 0: break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: Hanako = 0\n if Hanako == 0: break\nif Ceil == 0: print(\"Hanako\")\nelse: print(\"Ciel\")"}, {"source_code": "x,y = [int(z) for z in input().split()]\nn = 1\nif x//2>0 and y//24 >0 :\n\tn = min(x//2,y//24)\n\tx -= 2 * n\n\ty -= 24 * n\n\tif (n%2 == 0):\n\t\tn += 1\nwhile(True):\n\t#print (n,x,y)\n\tif n%2 :\n\t\tif y < 2:\n\t\t\tprint('Hanako')\n\t\t\tbreak\n\t\ty -= 2\n\t\tif x < 2:\n\t\t\ttmp = (220 - x*100)//10\n\t\t\tif y < tmp :\n\t\t\t\tprint('Hanako')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\ty -= tmp\n\t\t\t\tx = 0\n\t\telse:\n\t\t\tx -= 2\n\t#\tprint('c',x,y)\n\telse:\n\t\tif y < 2:\n\t\t\tprint('Ciel')\n\t\t\tbreak\n\t\tif y < 22 :\n\t\t\ty -= 2\n\t\t\ttmp = (y * 10)//100\n\t\t\ty -= (tmp *100)//10\n\t\t\tif x < tmp :\n\t\t\t\tprint('Ciel')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif x < (2 - tmp):\n\t\t\t\t\tprint('Ceil')\n\t\t\t\t\tbreak\n\t\t\t\tx -= (2 - tmp)\n\t\telse:\n\t\t\ty -= 22\n\t#\tprint ('h',x,y)\n\tn += 1\n"}, {"source_code": "import sys\n\na, b = map(int, sys.stdin.readline().strip().split(' '))\nplayers = ['Ciel','Hanako']\n\nwhile True:\n player = players.pop(0)\n sum = 0\n\n while a > 0:\n if sum == 200:\n break\n sum += 100\n a -= 1\n\n while b > 0:\n if sum == 220:\n break\n sum += 10\n b -= 1\n \n if sum != 220:\n if player == 'Ciel':\n print 'Hanako'\n else:\n print 'Ciel'\n break\n else:\n players.append(player)\n"}, {"source_code": "x,y = map(int, raw_input().split())\nm = x*100+10*y\nprint [\"Ciel\", \"Hanako\"][m/220%2-1]"}, {"source_code": "Piles, Ceil, Hanako= {}, 1, 1\nPiles[100], Piles[10] = [int(x) for x in input().split()]\nwhile True:\n #Ceil's Turn, wins if she gets 220 coins\n SumOfYens = min(2, Piles[100]) * 100\n Piles[100] -= min(2, Piles[100])\n if (220 - SumOfYens)/10 <= Piles[10]: SumOfYens = 220; Piles[10] -= (220 - SumOfYens)/10\n else: Ceil = 0\n if Ceil == 0: break\n #Hanako's Turn\n if Piles[10] >= 22: Piles[10] -= 22\n elif Piles[10] >= 12 and Piles[100] >= 1: Piles[10] -= 12; Piles[100] -= 1\n elif Piles[10] >= 2 and Piles [100] >= 2: Piles[10] -= 2; Piles[100] -= 2\n else: Hanako = 0\n if Hanako == 0: break\nif Ceil == 0: print(\"Hanako\")\nelse: print(\"Ceil\")"}, {"source_code": "x, y = map(int, input().split())\nciel = True\nwhile True:\n if ciel:\n s = 0\n while s + 100 <= 220 and x > 0:\n x -= 1\n s += 100\n while s + 10 <= 220 and y > 0:\n y -= 1\n s += 10\n if s != 220:\n print('Hanako')\n quit()\n ciel = False\n\n else:\n if y >= 22:\n x -= 22\n elif y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y >= 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n print('Ciel')\n quit()\n ciel = True\n"}, {"source_code": "import sys\n\n#f = open('test.in','r')\nf=sys.stdin\nx,y = map(int, f.readline().strip().split())\n\n#c 2 2\n#h 0 22\nz = min(y/24,x/2)\nx -= z*2\ny -= z*24\n\nwhile True:\n if 100*x+10*y>=220 and y>=2 and x>=0:\n #ceil\n if x>=2: x,y=x-2,y-2\n elif x==1 and y>=12: x,y=0,y-12\n else: y-=22\n else:\n print 'Hanako'\n break\n \n if 100*x+10*y>=220 and y>=2 and x>=0:\n #hanako\n if y>=22: y=y-22\n elif y>=12: x,y=x-1,y-12\n else: x,y=x-2,y-2\n else:\n print 'Ceil'\n break\n \n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total >= 220:\n # Ciel\n if turn == 0:\n t = 220\n\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n\n total -= 220\n turn = 1\n\n\n \n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n\n total -= 220\n turn = 0\n\n\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "s = raw_input().split()\na = int(s[0]) * 10 + int(s[1])\n\nif a / 22 % 2 == 1:\n print \"Ciel\"\nelse:\n print \"Hanako\""}, {"source_code": "n, a = map(int, input().split())\n\nans = 0\n\nwhile(1):\n s =220\n op=-1\n if ans%2 == 0:\n l = min(n, 2)\n s -= l*100\n k = min(a ,s//10)\n s -= k*10\n n -= l\n a -= k\n else:\n k = min((a-2)//10 , 2)\n s -= k*100\n l = min(n, s//100)\n s -= l*100\n a -= k*10\n op = min(a, s//10)\n s -= op*10\n n -= l\n a -= op\n #print(n, a, s, k, l, op)\n if s != 0:\n break\n ans += 1\n\nif ans%2 == 1:\n print('Ciel')\nelse:\n print('Hanako')\n"}, {"source_code": "x,y = map(int, raw_input().split())\ni = 0\nwhile x >= 0 and y >= 0:\n t = 220\n if i == 0:\n if x >= 2:\n x -= 2\n t -= 200\n else:\n t -= 2*x\n x -= x\n y -= t/10\n else: \n if y >= 22:\n y -= 22\n t -= 220\n elif y >= 12:\n y -= 12\n t -= 120\n else:\n y -= 2\n t -= 20\n x -= t/100\n i ^= 1\nprint [\"Ciel\", \"Hanako\"][i]"}, {"source_code": "x, y = map(int, raw_input().split())\nt = 0\nwhile True:\n\tif t % 2 == 0:\n\t\tif x > 1 and y > 1:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telif x > 0 and y > 11:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif y > 21:\n\t\t\ty -= 22\n\t\telse:\n\t\t\tprint 'Hanako'\n\t\t\tbreak\n\telse:\n\t\tif y > 21:\n\t\t\ty -= 22\n\t\telif y > 11 and x > 0:\n\t\t\tx -= 1\n\t\t\ty -= 12\n\t\telif y > 1 and x > 1:\n\t\t\tx -= 2\n\t\t\ty -= 2\n\t\telse:\n\t\t\tprint 'Ceil'\n\t\t\tbreak\n\tt += 1"}, {"source_code": "def f(a, b):\n k = max(a, 2)\n return a - k, b - 22 + 10 * k\n\ndef g(a, b):\n b -= 2\n k = max(b // 10, 2)\n return a - 2 + k, b - 10 * k\n\ndef main():\n a, b = map(int, input().split())\n k = min(a // 2, b // 24)\n a -= k * 2\n b -= 24 * k\n while a > 0:\n a, b = f(a, b)\n if a < 0 or b < 0: return 0\n a, b = f(a, b)\n if a < 0 or b < 0: return 1\n if a == 0: return (b // 22) % 2\n\nprint(['Hanako', 'Ciel'][main()])"}, {"source_code": "\n\ndef eina1(a):\n if a[1]>=2 and a[0]>=2:\n a[0]-=2;a[1]-+2;return a\n if a[0]==1 and a[1]>=12:\n a[0]-=1;a[1]-=12;return a\n if a[0]==0 and a[1]>=22:\n a[1]-=22;return a\n return \"lost\"\n\ndef eina2(a):\n if a[1]>=22:\n a[1]-=22;return a\n if a[1]>=12 and a[0]>=1:\n a[1]-=12;a[0]-=1;return a\n if a[1]>=2 and a[0]>=2:\n a[1]-=2;a[0]-=2;return a\n return \"lost\"\n\n\na=raw_input().split( )\na[0]=int(a[0])\na[1]=int(a[1])\nfor i in range((a[0]*100) + (a[1]*10) +1):\n if i%2==0:\n if(eina1(a)==\"lost\"):\n print \"Hanako\";break\n else:\n if(eina2(a)==\"lost\"):\n print \"Ciel\";break\n\n\n\n\n"}, {"source_code": "def f(a, b):\n k = min(a, 2)\n return a - k, b - 22 + 10 * k\n\ndef g(a, b):\n b -= 2\n k = min(b // 10, 2)\n return a - 2 + k, b - 10 * k\n\ndef main():\n a, b = map(int, input().split())\n k = min(a // 2, b // 24)\n a -= k * 2\n b -= 24 * k\n while a > 0:\n a, b = f(a, b)\n if a < 0 or b < 0: return 0\n a, b = f(a, b)\n if a < 0 or b < 0: return 1\n if a == 0: return (b // 22) % 2\n\nprint(['Hanako', 'Ciel'][main()])"}, {"source_code": "x, y = map(int, input().split())\nciel = True\nwhile True:\n if ciel:\n s = 0\n while s + 100 <= 220 and x > 0:\n x -= 1\n s += 100\n while s + 10 <= 220 and y > 0:\n y -= 1\n s += 10\n if s != 220:\n print('Hanako')\n quit()\n ciel = False\n\n else:\n if y >= 22:\n x -= 22\n elif y >= 12 and x >= 1:\n y -= 12\n x -= 1\n elif y >= 2 and x >= 2:\n y -= 2\n x -= 2\n else:\n print('Ciel')\n quit()\n ciel = True\n"}, {"source_code": "x, y = [ int(i) for i in raw_input().split() ]\nif ((10 * x + y) / 22) % 2: print(\"Ciel\")\nelse: print(\"Hanako\")\n"}, {"source_code": "#!/usr/bin/python\n# -*- coding: utf-8 -*- \n\na = raw_input( '' )\nb = [int(x) for x in a.split( ' ' )]\nx = b[0]\ny = b[1]\n\nturn = 0\ntotal = x * 100 + y * 10\n\nwhile total > 220:\n if turn == 0:\n t = 220\n if x >= 2:\n t -= 200\n x -= 2\n elif x == 1:\n t -= 100\n x -= 1\n\n if t > y * 10:\n break\n \n y -= t / 10\n\n turn = 1\n total -= 220\n else:\n t = 220\n if y < 22:\n t -= y * 10\n y = 0\n else: \n y -= 22\n turn = 0\n total -= 220\n continue\n\n if t != 0:\n d = t / 100\n c = t % 100\n if c != 0 or d > x:\n break\n x -= d\n \n turn = 0\n total -= 220\n\nif turn == 0:\n print \"Ciel\"\nelse:\n print \"Hanako\"\n"}, {"source_code": "x,y=map(int,input().split())\nmauka=0 \nwhile 1:\n if mauka==0:\n if x>=2 and y>=2:\n x=x-2 \n y=y-2\n elif x>=1 and y>=12:\n x=x-1 \n y=y-12\n elif x==0 and y>=22:\n y=y-22\n else:\n culprit=0 \n break \n else:\n if y>=22:\n y=y-22\n elif y>=12 and x>=1:\n y=y-12\n x=x-1 \n elif y>=2 and x>=2:\n x=x-2 \n y=y-2\n else:\n culprit=1 \n break \n # print(x,y)\n mauka=1-mauka\nif culprit:\n print('Ceil')\nelse:\n print('Hanako')"}, {"source_code": "x,y=map(int,input().split())\ncnt=0\nwhile(True):\n if(x>=2 and y>=2):\n x-=2\n y-=2\n cnt+=1\n elif(x>=1 and y>=12):\n x-=1\n y-=12\n cnt+=1\n elif(y>=22):\n y-=22\n cnt+=1\n else:\n break\nprint(\"Ciel\" if cnt%2==1 else \"Hanako\")\n"}, {"source_code": "x,y=map(int,input().split())\nmauka=0 \nwhile 1:\n if mauka==0:\n if x>=2 and y>=2:\n x=x-2 \n y=y-2\n elif x>=1 and y>=12:\n x=x-1 \n y=y-12\n elif x==0 and y>=22:\n y=y-22\n else:\n culprit=0 \n break \n else:\n if y>=22:\n y=y-22\n elif y>=12 and x>=1:\n y=y-12\n x=x-1 \n elif y>=2 and x>=2:\n x=x-2 \n y=y-2\n else:\n culprit=1 \n break \n # print(x,y)\n mauka=1-mauka\nif culprit:\n print('Ceil')\nelse:\n print('Hanako')"}, {"source_code": "n,m=map(int, raw_input().split())\nc=0\nwhile 10*n+m >= 22:\n m -= 2\n if c%2:\n d = min(20, m/10*10)\n D = 2 - d/10 \n else:\n D = min(2, n)\n d = 20 - 10*D\n n-= D\n m-= d\n c += 1\n\n \n \nprint \"HCainealk o\"[c%2::2]\n"}, {"source_code": "x, y = map(int, input().split())\nmoves = 0\nmove = True\nwhile move:\n if moves % 2 == 0:\n if x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x == 0 and y >= 22:\n moves += 1\n y -= 22\n else:\n move = False\n elif moves % 2 == 1:\n if y >= 22:\n moves += 1\n y -= 22\n elif x == 1 and y >= 12:\n moves += 1\n x -= 1\n y -= 12\n elif x >= 2 and y >= 2:\n moves += 1\n x -= 2\n y -= 2\n else:\n move = False\n\nans = 'Ciel' if moves % 2 == 1 else 'Hanako'\nprint(ans)\n\n\n"}, {"source_code": "nums = raw_input().split()\nx, y = [int(num) for num in nums]\ni = 0\nwhile True:\n if i % 2 == 0:\n #ciel round\n choosex = 2 if x >= 2 else x\n x -= choosex\n if 22 - 10 * choosex <= y:\n y -= 22 - 10 * choosex\n else:\n break\n else:\n #hanako round\n choosey = 22\n if 12 <= y < 22:\n choosey = y\n elif 2 <= y < 12:\n choosey = 2\n elif y < 2:\n choosey = 0\n break\n y -= choosey\n if (220 - choosey * 10) / 100 <= x:\n x -= (220 - choosey * 10) / 100\n else:\n break\n i += 1\n#print i\nprint 'Ciel' if i % 2 != 0 else 'Hanako'"}, {"source_code": "x, y = map(int, input().split())\ntot = (x*100) + (y*10)\nmoves = 0\n\nwhile tot >= 220 and x >= 2 and y >= 2:\n if moves % 2 == 0:\n initial = 220\n\n initial -= min(2, x) * 100\n x -= min(2, x)\n\n y -= initial // 10\n else:\n initial = 220\n\n if y >= 22:\n y -= 22\n elif y >= 12:\n y -= 12\n x -= 1\n elif y >= 2:\n y -= 2\n x -= 2\n\n tot = (x*100) + (y*10) \n moves += 1\n\nname = 'Ciel' if moves % 2 == 1 else 'Hanako'\nprint(name)\n"}, {"source_code": "\n\nplayer_one = 'Ciel'\nplayer_two = 'Hanako'\n\n\nc100, c10 = map(int, input().split())\n\n\nwhile True:\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([2, c100])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n else:\n print(player_two)\n break\n\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c10 -= 12\n c100 -= 1\n else:\n c10 -= 2\n c100 -= 2\n else:\n print(player_one)\n break\n\n\n\n\n\n\n\n"}, {"source_code": "\n\nplayer_one = 'Ciel'\nplayer_two = 'Hanako'\n\n\nc100, c10 = map(int, input().split())\n\nfull_moves = min([c100 // 2, c10 // 24])\n\nc100 -= full_moves * 2\nc10 -= full_moves * 24\n\nsolved = False\n\nif c100 < 2:\n if 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n c10 -= (220 - 100 * c100) // 10\n c100 = 0\n else:\n print(player_two)\n solved = True\n\n if not solved:\n if (c10 // 22) % 2 == 1:\n print(player_two)\n else:\n print(player_one)\n\nelse:\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([2, c100])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n elif not solved:\n print(player_two)\n solved = True\n\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c100 -= 1\n c10 -= 12\n else:\n c100 -= 2\n c10 -= 2\n elif not solved:\n print(player_one)\n solved = True\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n tmp = max([2, c100])\n c100 -= tmp\n c10 -= (220 - 100 * tmp) // 10\n elif not solved:\n print(player_two)\n solved = True\n\n\n if not solved and 100 * c100 + 10 * c10 >= 220 and c10 >= 2:\n if c10 >= 22:\n c10 -= 22\n elif c10 >= 12:\n c100 -= 1\n c10 -= 12\n else:\n c100 -= 2\n c10 -= 2\n elif not solved:\n print(player_one)\n solved = True\n\n"}, {"source_code": "x,y = [int(z) for z in input().split()]\nn = 1\nif x//2>0 and y//24 >0 :\n\tn = min(x//2,y//24)\n\tx -= 2 * n\n\ty -= 24 * n\n\tif (n%2 == 0):\n\t\tn += 1\nwhile(True):\n\t#print (n,x,y)\n\tif n%2 :\n\t\tif y < 2:\n\t\t\tprint('Hanako')\n\t\t\tbreak\n\t\ty -= 2\n\t\tif x < 2:\n\t\t\ttmp = (200 - x*100)//10\n\t\t\tif y < tmp :\n\t\t\t\tprint('Hanako')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\ty -= tmp\n\t\t\t\tx = 0\n\t\telse:\n\t\t\tx -= 2\n\t#\tprint('c',x,y)\n\telse:\n\t\tif y < 2:\n\t\t\tprint('Ciel')\n\t\t\tbreak\n\t\tif y < 22 :\n\t\t\ty -= 2\n\t\t\ttmp = (y * 10)//100\n\t\t\ty -= (tmp *100)//10\n\t\t\tif x < tmp :\n\t\t\t\tprint('Ciel')\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tif x < (2 - tmp):\n\t\t\t\t\tprint('Ceil')\n\t\t\t\t\tbreak\n\t\t\t\tx -= (2 - tmp)\n\t\telse:\n\t\t\ty -= 22\n\t#\tprint ('h',x,y)\n\tn += 1\n"}, {"source_code": "x, y = [int(x) for x in input().split()]\n\ndef even_move(x, y):\n if x >= 2 and y >= 2:\n return [True, x - 2, y - 2]\n if x >= 1 and y >= 11:\n return [True, x - 1, y - 11]\n if y >= 22:\n return [True, x, y - 22]\n return [False, x, y]\n\ndef odd_move(x, y):\n if y >= 22:\n return [True, x, y - 22]\n if x >= 1 and y >= 11:\n return [True, x - 1, y - 11]\n if x >= 2 and y >= 2:\n return [True, x - 2, y - 2]\n return [False, x, y]\n\ndef game(x, y):\n even = 'Ciel'\n odd = 'Hanako'\n i = 0\n while True:\n if i % 2 == 0:\n move = even_move(x, y)\n if move[0]:\n x = move[1]\n y = move[2]\n else:\n return odd\n else:\n move = odd_move(x, y)\n if move[0]:\n x = move[1]\n y = move[2]\n else:\n return even\n i += 1\n\nprint(game(x, y))\n\n"}, {"source_code": "n, a = map(int, input().split())\n\nans = 0\n\nwhile(1):\n s =220\n op=-1\n if ans%2 == 0:\n l = min(n, 2)\n s -= l*100\n k = min(a ,s//10)\n s -= k*10\n n -= l\n a -= k\n else:\n k = min((a-2)//10 , 2)\n s -= k*100\n l = min(n, s//100)\n s -= l*100\n a -= k*10\n op = min(a, s//10)\n s -= op*10\n n -= l\n a -= op\n #print(n, a, s, k, l, op)\n if s != 0:\n break\n ans += 1\n\nif ans%2 == 1:\n print('Ciel')\nelse:\n print('Hanako')\n"}, {"source_code": "#!/usr/bin/env python\n# -*- coding: UTF-8 -*-\nimport time\nimport sys, io\nimport re, math\n#start = time.clock()\nx,y=map(int,raw_input().split())\n#l=[int(x) for x in raw_input().split()]\ncnt=0\nwhile 1:\n if x>=2 and y>=2:\n x-=2\n y-=2\n elif x>=1 and y>=12:\n x-=1\n y-=12\n elif y>=22:\n y-=22\n else:\n print 'Hanako' if cnt%2==0 else 'Ciel'\n sys.exit()\n cnt+=1"}, {"source_code": "x,y=map(int,input().split())\ni=0\nsum=x*100+y*10\nwhile (sum>=220):\n if (y<2):\n break\n if (i%2==0):\n if (x>=2):\n x-=2\n if (y>=2):\n y-=2\n else:\n break\n else:\n break\n else:\n if (y>=22):\n y-=22\n else:\n if (y>=12):\n y-=12\n x-=1\n elif (y>=2):\n y-=2\n x-=2\n \n sum-=220\n i+=1\n \n \n \nif (i%2==0):\n print(\"Hanako\")\nelse:\n print (\"Ciel\")\n "}, {"source_code": "x,y=map(int,input().split())\ni=0\nsum=x*100+y*10\nwhile (sum>=220):\n sum-=220\n i+=1\nif (i%2==0):\n print(\"Hanako\")\nelse:\n print (\"Ciel\")\n "}], "src_uid": "8ffee18bbc4bb281027f91193002b7f5"} {"nl": {"description": " When the curtains are opened, a canvas unfolds outside. Kanno marvels at all the blonde colours along the riverside\u00a0\u2014 not tangerines, but blossoms instead.\"What a pity it's already late spring,\" sighs Mino with regret, \"one more drizzling night and they'd be gone.\"\"But these blends are at their best, aren't they?\" Absorbed in the landscape, Kanno remains optimistic. The landscape can be expressed as a row of consecutive cells, each of which either contains a flower of colour amber or buff or canary yellow, or is empty.When a flower withers, it disappears from the cell that it originally belonged to, and it spreads petals of its colour in its two neighbouring cells (or outside the field if the cell is on the side of the landscape). In case petals fall outside the given cells, they simply become invisible.You are to help Kanno determine whether it's possible that after some (possibly none or all) flowers shed their petals, at least one of the cells contains all three colours, considering both petals and flowers. Note that flowers can wither in arbitrary order.", "input_spec": "The first and only line of input contains a non-empty string $$$s$$$ consisting of uppercase English letters 'A', 'B', 'C' and characters '.' (dots) only ($$$\\lvert s \\rvert \\leq 100$$$)\u00a0\u2014 denoting cells containing an amber flower, a buff one, a canary yellow one, and no flowers, respectively.", "output_spec": "Output \"Yes\" if it's possible that all three colours appear in some cell, and \"No\" otherwise. You can print each letter in any case (upper or lower).", "sample_inputs": [".BAC.", "AA..CB"], "sample_outputs": ["Yes", "No"], "notes": "NoteIn the first example, the buff and canary yellow flowers can leave their petals in the central cell, blending all three colours in it.In the second example, it's impossible to satisfy the requirement because there is no way that amber and buff meet in any cell."}, "positive_code": [{"source_code": "s = raw_input()\n\nif \"ABC\" in s or \"ACB\" in s or \"BAC\" in s or \"BCA\" in s or \"CBA\" in s or \"CAB\" in s:\n\tprint \"Yes\"\nelse:\n\tprint \"No\"\n"}, {"source_code": "\n\n\ndef check(s):\n i = 0\n while i < len(s) - 2:\n x = ''.join(sorted(s[i:i + 3]))\n if 'ABC' == x:\n return True\n i += 1\n\n return False\n\n\n\nif __name__=='__main__':\n s = input().strip()\n\n if check(s):\n print('Yes')\n else:\n print('No')\n\n\n\n\n"}, {"source_code": "s1=input();\nif((\"ABC\" in s1) or (\"ACB\" in s1) or(\"BAC\" in s1) or (\"BCA\" in s1) or (\"CAB\" in s1) or(\"CBA\" in s1)):\n\tprint('Yes');\nelse:\n\tprint('No');"}, {"source_code": "word = str(input())\nif \"BAC\" in word:\n print(\"Yes\")\nelif \"ABC\" in word:\n print(\"Yes\")\nelif \"BCA\" in word:\n print(\"Yes\")\nelif \"ACB\" in word:\n print(\"Yes\")\nelif \"CAB\" in word:\n print(\"Yes\")\nelif \"CBA\" in word:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "s = input()\nflag = True\nfor i in range(len(s)):\n s2 = s[i:i+3]\n if(s2=='ABC' or s2=='ACB' or s2=='BAC' or s2=='BCA' or s2==\"CAB\" or s2=='CBA'):\n print(\"Yes\")\n flag = False\n break\nif(flag):\n print(\"NO\")\n"}, {"source_code": "s = input()\n\nfor i in range(len(s) - 2):\n\n flowers = set()\n\n for j in range(i, i+3):\n if s[j] != '.':\n flowers.add(s[j])\n\n if len(flowers) == 3:\n print(\"Yes\")\n break\nelse:\n print(\"No\")\n"}, {"source_code": "def solve(s):\n for i in range(len(s) - 2):\n if ''.join(sorted(s[i:i+3])) == 'ABC':\n return 'Yes'\n return 'No'\n\ns = input()\nprint(solve(s))"}, {"source_code": "s = str(raw_input())\nfor x in range(1, len(s)-1, +1):\n if s[x] == 'A':\n if (s[x-1] == 'B' and s[x+1] == 'C') or (s[x-1] == 'C' and s[x+1] == 'B'):\n print 'Yes'\n exit(0)\n elif s[x] == 'B':\n if (s[x-1] == 'A' and s[x+1] == 'C') or (s[x-1] == 'C' and s[x+1] == 'A'):\n print 'Yes'\n exit(0)\n elif s[x] == 'C':\n if (s[x-1] == 'B' and s[x+1] == 'A') or (s[x-1] == 'A' and s[x+1] == 'B'):\n print 'Yes'\n exit(0)\nprint 'No'"}, {"source_code": "ss = raw_input()\na = [[0, 0, 0] for _ in range(len(ss))]\n\nll = len(ss)\nfor i in range(ll):\n if ss[i] == 'A':\n a[i][0] = 1\n if 0 <= i-1: a[i-1][0] = 1\n if i+1 < ll: a[i+1][0] = 1\n elif ss[i] == 'B':\n a[i][1] = 1\n if 0 <= i-1: a[i-1][1] = 1\n if i+1 < ll: a[i+1][1] = 1\n elif ss[i] == 'C':\n a[i][2] = 1\n if 0 <= i-1: a[i-1][2] = 1\n if i+1 < ll: a[i+1][2] = 1\n\n# print a\nif [1, 1, 1] in a:\n print 'Yes'\nelse: print 'No'"}, {"source_code": "s = input();\nflag=0\nfor i,c in enumerate(s):\n if i==0:\n continue\n elif i==len(s)-1:\n continue\n else:\n l=[]\n if s[i-1]!='.' and s[i+1]!='.' and s[i]!='.':\n l.append(s[i-1])\n l.append(s[i+1])\n l.append(c)\n if len(set(l))==3:\n flag=1\n break\n \nif flag==0:\n print(\"No\")\nelse:\n print(\"Yes\")"}, {"source_code": "s = input().strip()\nans = 'No'\nfor i in range(1, len(s) - 1):\n if ord(s[i]) + ord(s[i - 1]) + ord(s[i + 1]) == 198 and s[i] != s[i - 1] and s[i] != s[i + 1] and s[i - 1] != s[i + 1]:\n ans = 'Yes'\nprint(ans)\n"}, {"source_code": "# https://codeforces.com/problemset/problem/989/A\n# 900\n\n\nc = input()\n\no = \"NO\"\nfor i in range(len(c)):\n x = {}\n for f in c[i:i+3]:\n if f != \".\":\n x[f] = 1\n \n if len(x) == 3:\n o = \"YES\"\n break\n\nprint(o)"}, {"source_code": "s = input()\nprint('Yes' if any(set(s[i:i+3]) == set('ABC') for i in range(len(s) - 2))\n else 'No')"}, {"source_code": "import sys\ns = sys.stdin.readline().strip()\nprint('Yes' if any(x in s for x in ['ABC', 'ACB', 'BCA', 'BAC', 'CAB', 'CBA']) else 'No')\n"}, {"source_code": "s = input()\nflag = True\nfor i in range(len(s)-2):\n s2 = s[i:i+3]\n if(s2=='ABC' or s2=='ACB' or s2=='BAC' or s2=='BCA' or s2==\"CAB\" or s2=='CBA'):\n print(\"Yes\")\n flag = False\n break\nif(flag):\n print(\"NO\")\n"}, {"source_code": "a = raw_input()\nprint 'Yes' if set('ABC') in map(set, zip(a, a[1:], a[2:])) else 'No'\n"}, {"source_code": "#n=map(int,raw_input().split())\nimport re\ns=raw_input()\nif(re.search(\"BAC\",s)or re.search(\"BCA\",s)or re.search(\"ABC\",s)or re.search(\"ACB\",s)or re.search(\"CAB\",s)or re.search(\"CBA\",s) ):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "\n\n\n\ns = input()\n\nlens = int(len(s))\n\n\nfor i in range(lens - 2):\n\n se = set(s[i:i+3])\n # print(se)\n if se.__len__() == 3 and '.' not in se:\n print('Yes')\n break\nelse:\n print('No')\n\n"}, {"source_code": "s = input()\nn = len(s)\nk = [0]*n\nfor i in range(n):\n t = 0\n if s[i] == 'A':\n t = 1\n elif s[i] == 'B':\n t = 2\n elif s[i] == 'C':\n t = 4\n \n if i - 1 >= 0 and k[i - 1] != t:\n k[i - 1] += t\n \n k[i] += t\n \n if i + 1 < n and k[i + 1] != t:\n k[i + 1] += t\n\nif 7 in k:\n print(\"Yes\")\nelse:\n print(\"No\")"}, {"source_code": "cells = input()\nanswer = \"No\"\nfor i in range(1, len(cells) - 1):\n\tpotential_colors = set()\n\tpotential_colors.update(cells[i-1 : i+2])\n\tif len(potential_colors) == 3 and '.' not in potential_colors:\n\t\tanswer = \"Yes\"\n\t\tbreak\n\nprint(answer)"}, {"source_code": "dc=['ABC','ACB','BAC','BCA','CAB','CBA']\nfor s in input().split('.'):\n for d in dc:\n if s.find(d)!=-1:\n print('Yes')\n exit()\nprint('No')"}, {"source_code": "import math as mt\nimport sys, string\nfrom collections import Counter, defaultdict\n\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 main():\n s = input()\n n = len(s)\n arr = [[] for _ in range(n)]\n for i in range(n):\n if i-1>=0:\n arr[i-1].append(s[i])\n if i+1=3):\n arr = arr[1:]\n arr.append(x)\n if ( 'A' in arr and 'B' in arr and 'C' in arr):\n print 'Yes'\n flag = 1\n break\nif(flag==0):\n print'No'\n \n"}, {"source_code": "a = list(input())\nn = ['B', 'A', 'C']\nfor k in range(len(a)):\n if a[k] in n and k < len(a)-1 and k > 0:\n if a[k-1] in n and a[k+1] in n:\n if a[k-1] != a[k+1] and a[k-1] != a[k] and a[k] != a[k+1]:\n print('Yes')\n break\nelse:\n print('No')"}, {"source_code": "import itertools\nseq = input()\nfor subseq in itertools.permutations('ABC'):\n if ''.join(subseq) in seq:\n print('Yes')\n quit()\nprint('No')"}, {"source_code": "a=input()\nif 'ABC' in a:\n print('Yes')\nelif 'ACB' in a:\n print('Yes')\nelif 'BCA' in a:\n print('Yes')\nelif 'BAC' in a:\n print('Yes')\nelif 'CAB' in a:\n print('Yes')\nelif 'CBA' in a:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "test = input()\nbull = True\n\ndef summString(a, b, c):\n return a+b+c\n\nfor i in range(1, len(test)-1):\n partString = summString(test[i-1], test[i], test[i+1])\n if (partString == 'ABC' or\n partString == 'BAC' or\n partString == 'BCA' or\n partString == 'CBA' or\n partString == 'ACB' or\n partString == 'CAB'):\n print('Yes')\n bull = False\n break\n\nif bull:\n print('No')"}, {"source_code": "s = input()\nprint(('No', 'Yes')[any(set(s[i:i+3]) == set('ABC') for i in range(len(s) - 2))])"}, {"source_code": "s=input()\nfor i in range(len(s)-1):\n if i and s[i]!=s[i-1] and s[i]!=s[i+1] and s[i-1]!=s[i+1] and s[i-1]!='.' and s[i]!='.' and s[i+1]!='.' :\n print(\"Yes\")\n exit(0)\nprint(\"No\")"}, {"source_code": "import sys\ns=input()\nif len(s)<3:\n print('No')\n sys.exit()\nfor i in range(len(s)-2):\n if (s[i:(i+3)]=='ABC')or(s[i:(i+3)]=='ACB')or(s[i:(i+3)]=='BAC')or(s[i:(i+3)]=='BCA')or(s[i:(i+3)]=='CBA')or(s[i:(i+3)]=='CAB'):\n print('Yes')\n break\n else:\n if i==len(s)-3:\n print('No')\n "}, {"source_code": "s = input()\na = ['ABC', 'ACB', 'BCA', 'BAC', 'CAB', 'CBA']\nfor i in a:\n if i in s:\n print('YES')\n exit()\nprint('NO')"}, {"source_code": "garden = raw_input()\n\npossible = False\n\nfor i in range ( 1, len(garden) - 1 ) :\n if garden[i] == 'A' and garden[i-1] == 'B' and garden[i+1] == 'C':\n possible = True\n break\n elif garden[i] == 'A' and garden[i-1] == 'C' and garden[i+1] == 'B':\n possible = True\n break\n elif garden[i] == 'B' and garden[i-1] == 'A' and garden[i+1] == 'C':\n possible = True\n break\n elif garden[i] == 'B' and garden[i-1] == 'C' and garden[i+1] == 'A':\n possible = True\n break\n elif garden[i] == 'C' and garden[i-1] == 'A' and garden[i+1] == 'B':\n possible = True\n break\n elif garden[i] == 'C' and garden[i-1] == 'B' and garden[i+1] == 'A':\n possible = True\n break\n\nif possible:\n print \"Yes\"\nelse :\n print \"No\""}, {"source_code": "s=input()\nx=0\nfor i in range(len(s)-2):\n if (s[i] != '.' and s[i + 1] != '.' and s[i + 2] != '.'):\n if (s[i] != s[i + 1] and s[i + 1] != s[i + 2] and s[i] != s[i + 2] ):\n x = 1\n break\nif(1 == x):\n print(\"Yes\")\nelse:\n print(\"No\")\n\n"}, {"source_code": "a = raw_input()\nz=1\ni=0\nl=[]\nx = \"No\"\nwhile z==1 and i<(len(a)-2):\n\ti+=1\n\tif a[i] !='.':\n\t\tif a[i-1] != '.' and a[i+1] != '.':\n\t\t\tif a[i] != a[i-1] and a[i] != a[i+1] and a[i-1] != a[i+1]:\n\t\t\t\tx = 'Yes'\n\t\t\t\tprint x\n\t\t\t\tz=0\nif x==\"No\":\n\tprint x\n"}, {"source_code": "a = input()\nsub = ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']\ncount = -1\nfor i in sub:\n count = max(a.find(i), count)\n\nif count == -1:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "s = list(input())\n\nk = list(s)\n\nn = len(s)\nfor i in range(0,n):\n if ((s[i]=='A')or(s[i]=='B')or(s[i]=='C')):\n if i!=0:\n k[i-1] = k[i-1]+s[i]\n if i!= n-1:\n k[i+1] = k[i+1] + s[i]\ncount = 0\nfor x in k:\n if ((x=='ABC')or(x=='BAC')or(x=='BCA')or(x=='ACB')or(x=='CAB')or(x=='CBA')):\n count = 1\n break\nif count != 0:\n print('Yes')\nelse:\n print('No')\n\n"}, {"source_code": "import math as mt\nimport sys, string\nfrom collections import Counter, defaultdict\n\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 main():\n s = input()\n n = len(s)\n arr = [[] for _ in range(n)]\n for i in range(n):\n if i-1>=0:\n arr[i-1].append(s[i])\n if i+1= 3:\n for i in range ( 1, len ( flowers ) - 1 ):\n current_color = flowers [ i ]\n prev_color = flowers [ i - 1 ]\n next_color = flowers [ i + 1 ]\n if (\n current_color != '.' and\n prev_color != '.' and\n next_color != '.' and\n current_color != prev_color and\n current_color != next_color and\n prev_color != next_color\n ):\n is_possible = True\n\n\nprint ( 'YES' if is_possible else 'NO' )\n"}, {"source_code": "s = input()\nn = len(s)\nf = 0\nfor i in range(n - 2):\n\t\tif s[i] != '.' and s[i+1] != '.' and s[i+2] != '.':\n\t\t\t\tif s[i+1] != s[i]:\n\t\t\t\t\t\tif s[i+2] != s[i] and s[i+2] != s[i + 1]:\n\t\t\t\t\t\t\t\tf = 1\n\t\t\t\t\t\t\t\tbreak\n\nif f == 1:\n\t\tprint('Yes')\nelse:\n\t\tprint('No')\n"}, {"source_code": "s = raw_input()\nif 'ABC' in s or 'BAC' in s or 'ACB' in s or 'BCA' in s or 'CBA' in s or 'CAB' in s:\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "#n=map(int,raw_input().split())\nimport re\ns=raw_input()\nif(re.search(\"BAC\",s)or re.search(\"BCA\",s)or re.search(\"ABC\",s)or re.search(\"ACB\",s)or re.search(\"CAB\",s)or re.search(\"CBA\",s) ):\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "II = lambda: int(raw_input())\nIAI = lambda: map(int, raw_input().split())\nIL = lambda: raw_input().strip()\nIAS = lambda: raw_input().split()\ns = IL()\na = any(w in s for w in ('ABC','ACB','BAC','BCA','CAB','CBA'))\nprint (\"No\",\"Yes\")[a]\n"}, {"source_code": "a=raw_input()\na=\"#\"+a+\"#\"\nb=0\nfor i in range(1,len(a)-1):\n if a[i]=='A' and a[i-1]=='B' and a[i+1]=='C':\n b=1\n if a[i]=='A' and a[i-1]=='C' and a[i+1]=='B':\n b=1\n if a[i]=='B' and a[i-1]=='A' and a[i+1]=='C':\n b=1\n if a[i]=='B' and a[i-1]=='C' and a[i+1]=='A':\n b=1\n if a[i]=='C' and a[i-1]=='A' and a[i+1]=='B':\n b=1\n if a[i]=='C' and a[i-1]=='B' and a[i+1]=='A':\n b=1\nif b:\n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "n = raw_input()\n\nif(n.find(\"ABC\")>=0 or n.find(\"ACB\")>=0 or n.find(\"BCA\")>=0 or n.find(\"BAC\")>=0 or n.find(\"CAB\")>=0 or n.find(\"CBA\")>=0): \n print \"Yes\"\nelse:\n print \"No\""}, {"source_code": "a = raw_input()\nl = len(a)\narr = []\nflag = 0\nfor x in a:\n if(len(arr)>=3):\n arr = arr[1:]\n arr.append(x)\n if ( 'A' in arr and 'B' in arr and 'C' in arr):\n print 'Yes'\n flag = 1\n break\nif(flag==0):\n print'No'\n \n"}, {"source_code": "s = raw_input()\nif \"ABC\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"ACB\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"BAC\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"BCA\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"CAB\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"CBA\" in s:\n\tprint \"Yes\"\n\texit(0)\nprint \"No\""}, {"source_code": "test = input()\n\nfor i in range(1, len(test)-1):\n partString = test[i-1]+test[i]+test[i+1]\n if 'A' in partString and 'B' in partString and 'C' in partString:\n print(\"Yes\")\n exit(0)\n\nprint(\"No\")"}, {"source_code": "'''input\n.BAC.\n'''\n\n#~ @author = dwij28 (Abhinav Jha) ~#\n\ns = raw_input()\nans = False\nfor i in xrange(1, len(s)-1):\n\tif s[i] != '.' and s[i-1] != '.' and s[i+1] != '.' and s[i] != s[i-1] and s[i] != s[i+1] and s[i-1] != s[i+1]:\n\t\tans = True\nprint 'Yes' if ans else 'No'"}, {"source_code": "s = raw_input()\nl = [\"ABC\", \"ACB\", \"BAC\", \"BCA\", \"CAB\", \"CBA\"]\nyeah = 0\nfor st in l:\n if st in s:\n yeah = 1\n break\nif yeah: print \"Yes\"\nelse: print \"No\"\n"}, {"source_code": "import re\n\ns = raw_input()\n\npattern = \"(ABC|ACB|BCA|BAC|CBA|CAB)\"\nresult = re.search(pattern, s)\n\nprint \"Yes\" if s != \"\" and result is not None else \"No\""}, {"source_code": "#!/usr/bin/env python\n\ndef get_array(data_type=int):\n\treturn [data_type(num) for num in raw_input().split()]\n\ndef get(data_type=int):\n\treturn data_type(raw_input())\n\nA = raw_input()\n\nposs = False\n\nfor i in range(1, len(A) - 1):\n\ts = {A[i-1], A[i+1], A[i]}\n\tif len(s) == 3 and '.' not in s:\n\t\tposs = True\n\nprint \"Yes\" if poss else \"No\"\n"}, {"source_code": "s = input()\nn = len(s)\nans = 'No'\nfor i in range(2, n):\n if set(list(s[i - 2 : i + 1])) == set(['A','B','C']):\n ans = 'Yes'\n break\nprint(ans)"}, {"source_code": "string_input = input()\nif \"ABC\" in string_input:\n print(\"Yes\")\nelif \"ACB\" in string_input:\n print(\"Yes\")\nelif \"CAB\" in string_input:\n print(\"Yes\")\nelif \"CBA\" in string_input:\n print(\"Yes\")\nelif \"BAC\" in string_input:\n print(\"Yes\")\nelif \"BCA\" in string_input:\n print(\"Yes\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=input()\na=0\nfor i in range(1,len(n)-1):\n if n[i]!=\".\" and n[i-1]!=\".\" and n[i+1]!=\".\" and n[i]!=n[i+1] and n[i]!=n[i-1] and n[i-1]!=n[i+1]:\n print(\"Yes\")\n a=1\n break\nif a==0:\n print(\"NO\")\n\n \n"}, {"source_code": "s = input()\n\ncount = 0\nfor i in range(1, len(s)-1):\n\tif s[i] != '.' and s[i+1] != '.' and s[i-1] != '.':\n\t\tif s[i-1] != s[i] and s[i] != s[i+1] and s[i+1] != s[i-1]:\n\t\t\tcount += 1\n\nif count > 0:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")"}, {"source_code": "f = raw_input()\n\nif f.find('ABC') == -1 and f.find('CAB') == -1 and f.find('BCA') == -1 and f.find('CBA') == -1 and f.find('BAC') == -1 and f.find('ACB') == -1:\n print 'No'\nelse:\n print 'Yes'\n \n"}, {"source_code": "s = input().strip()\nans = 'No'\nfor i in range(1, len(s) - 1):\n if ord(s[i]) + ord(s[i - 1]) + ord(s[i + 1]) == 198 and s[i] != s[i - 1] and s[i] != s[i + 1] and s[i - 1] != s[i + 1]:\n ans = 'Yes'\nprint(ans)\n"}, {"source_code": "s = input()\nflag = False\nfor i in range(0, len(s) - 2):\n if s[i:i+3] in (\"ABC\", \"BAC\", \"BCA\", \"CAB\", \"ACB\", \"CBA\"):\n flag = True\n break\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "s = input()\nprint(('No', 'Yes')[any(set(s[i:i+3]) == set('ABC') for i in range(len(s) - 2))])"}, {"source_code": "s = raw_input()\ncomb = ord('A') * ord('B') * ord('C')\nflag =False\nfor i in range(0 , len(s) - 2 ):\n if ord(s[i]) * ord(s[i + 1]) * ord(s[i + 2]) == comb:\n flag=True\n break\nif flag:\n print 'Yes'\nelse:\n print 'No'\n \n"}, {"source_code": "a = input(); print(\"YES\" if \"ABC\" in a or \"ACB\" in a or \"BAC\" in a or \"BCA\" in a or \"CAB\" in a or \"CBA\" in a else \"NO\")\n"}, {"source_code": "k=input()\ns=[]\nfor i in k:\n s.append(i)\nt=[]\nflag=0\nfor i in range(len(s)-2):\n t=s[i:i+3]\n t.sort()\n if(t==[\"A\",\"B\",\"C\"]):\n flag=1\n break\nif(flag==1):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n"}, {"source_code": "n=input()\nl=len(n)\nif(l<3):\n print(\"No\")\nelse:\n i=0\n j=1\n k=2\n flag=0\n while(k=0 or a.find(\"CAB\")>=0 or a.find(\"BAC\")>=0 or a.find(\"ACB\")>=0 or a.find(\"CBA\")>=0 or a.find(\"BCA\")>=0:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "s=raw_input()\ns1,s2,s3,s4,s5,s6='ABC','ACB','BAC','BCA','CAB','CBA'\nif(s1 in s or s2 in s or s3 in s or s4 in s or s5 in s or s6 in s):\n print \"Yes\"\nelse:\n print \"No\" "}, {"source_code": "z=input()\nif 'ABC' in z:\n\tprint('Yes')\n\tquit()\nif 'CBA' in z:\n\tprint('Yes')\n\tquit()\nif 'BCA' in z:\n\tprint('Yes')\n\tquit()\nif 'ACB' in z:\n\tprint('Yes')\n\tquit()\nif 'BAC' in z:\n\tprint('Yes')\n\tquit()\nif 'CAB' in z:\n\tprint('Yes')\n\tquit()\nprint('No')\n"}, {"source_code": "from itertools import permutations\n\n\ns = input()\nprint(('No', 'Yes')[any([''.join(t) in s for t in permutations('ABC', 3)])])\n\n"}, {"source_code": "a = raw_input().split(\".\")\nflag = False\nfor i in range(len(a)) : \n if(\"ABC\" in a[i] or \"ACB\" in a[i] or \"BAC\" in a[i] or \"BCA\" in a[i] or \"CAB\" in a[i] or \"CBA\" in a[i]) :\n flag = True\nif(flag) : \n print \"YES\"\nelse : \n print \"NO\"\n \n"}, {"source_code": "s = input()\na = ['ABC', 'ACB', 'BAC', 'BCA', 'CAB', 'CBA']\nprint (['No', 'Yes'][any(i in s for i in a)])"}, {"source_code": "s = raw_input()\nif \"ABC\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"ACB\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"BAC\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"BCA\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"CAB\" in s:\n\tprint \"Yes\"\n\texit(0)\nif \"CBA\" in s:\n\tprint \"Yes\"\n\texit(0)\nprint \"No\""}, {"source_code": "s, t = input(), set('ABC')\nprint('Yes' if any(set(s[i:i+3]) == t for i in range(len(s) - 2)) else 'No')"}, {"source_code": "s = input()\nans = \"\"\nif len(s) < 3:\n\tprint(\"NO\")\n\texit()\nfor i in range(len(s) - 3):\n\tif len(set(s[i] + s[i + 1] + s[i + 2])) == 3 and \".\" not in set(s[i] + s[i + 1] + s[i + 2]):\n\t\tans = \"YES\"\nif len(set(s[-1] + s[-2] + s[-3])) == 3 and \".\" not in set(s[-1] + s[-2] + s[-3]):\n\tans = \"YES\"\nif ans == \"\":\n\tprint(\"NO\")\nelse:\n\tprint(ans)\n"}, {"source_code": "from sys import stdin\na = stdin.readline().strip()\nn = len(a)\na += '....'\nans = 'No'\nfor i in xrange(n):\n s = a[i: i+3]\n if '.' not in s and len(set(list(s)))==3:\n ans = 'Yes'\nprint ans"}, {"source_code": "s=input()\nct=0\nif len(s)>0:\n for i in range(len(s)-2):\n p=s[i:i+3]\n #print(p,int(p=='BAC')==1)\n if p==\"ABC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"BAC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"CAB\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"ACB\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"CBA\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"BCA\":\n print(\"Yes\")\n ct+=1\n break\n if ct==0:\n print(\"No\")"}, {"source_code": "s = input().split(\".\")\ncount = 0\n\nfor i in s:\n if(\"ABC\" in i or \"ACB\" in i or \"BAC\" in i or \"BCA\" in i or \"CAB\" in i or \"CBA\" in i):\n count += 1\n print(\"Yes\")\n break\nif(count == 0):\n print(\"No\")"}], "negative_code": [{"source_code": "s = input()\nn = len(s) - 2\ni = 0\nx = ord('A') + ord('B') + ord('C')\nerr = 0\nwhile i < n and err != 1:\n if ord(s[i]) + ord(s[i + 1]) + ord(s[i + 2]) == x:\n err = 1\n i += 1\nif err == 0:\n print(\"NO\")\nelse:\n print(\"YES\")\n"}, {"source_code": "a=input()\nb=[]\nfor i in a:\n b.append(i)\nfor il in b:\n if il[0]!='.': \n s=b.index(il)\n if s==0:\n b[s+1]+=il[0]\n elif s==len(b)-1:\n b[s-1]+=il[0]\n else:\n b[s+1]+=il[0]\n b[s-1]+=il[0]\nk=0\nfor i in b:\n if 'B' in i:\n if 'A'in i:\n if 'C' in i:\n k=1\nif k==1:\n print('Yes')\nelse:\n print('No')"}, {"source_code": "a = input()\ni = 0\nwhile i < len(a):\n x = a[i:i+3]\n print(x)\n if x == 'ABC' or x == 'ACB' or x == 'BAC' or x == 'BCA' or x == 'CAB' or x == 'CBA':\n print('YES')\n break\n i += 1\n\nif i >= len(a):\n print(\"NO\")"}, {"source_code": "a = raw_input()\nz=1\ni=0\nl=[]\nx = \"No\"\nwhile z==1 and i= 3:\n for i in range ( 1, len ( flowers ) - 1 ):\n current_color = flowers [ i ]\n prev_color = flowers [ i - 1 ]\n next_color = flowers [ i + 1 ]\n if (\n current_color != prev_color and\n current_color != next_color and\n prev_color != next_color\n ):\n is_possible = True\n break\n\n\nprint ( 'YES' if is_possible else 'NO' )\n"}, {"source_code": "def main():\n n=raw_input()\n #l=map(long,raw_input().split())\n if n.find(\"ABC\")>0 or n.find(\"BCA\")>0 or n.find(\"ACB\")>0 or n.find(\"BAC\")>0 or n.find(\"CBA\")>0 or n.find(\"CAB\")>0:\n print \"Yes\"\n else:\n print \"No\"\nmain()"}, {"source_code": "'''input\n.BAC.\n'''\n\n#~ @author = dwij28 (Abhinav Jha) ~#\n\ns = raw_input()\nans = False\nfor i in xrange(1, len(s)-1):\n\tif s[i] != '.' and s[i-1] != '.' and s[i+1] != '.' and s[i] != s[i-1] and s[i] != s[i+1]:\n\t\tans = True\nprint 'Yes' if ans else 'No'"}, {"source_code": "s=input()\nif s.find(\"ABC\")>0 or s.find(\"BAC\")>0 or s.find(\"BCA\")>0 or s.find(\"ACB\")>0 or s.find(\"CBA\")>0 or s.find(\"CAB\")>0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import math as mt\nimport sys, string\nfrom collections import Counter, defaultdict\n\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 main():\n s = input()\n n = len(s)\n arr = [[] for _ in range(n)]\n for i in range(n):\n if i-1>=0:\n arr[i-1].append(s[i])\n if i+1= 3:\n for i in range ( 1, len ( flowers ) - 1 ):\n current_color = flowers [ i ]\n prev_color = flowers [ i - 1 ]\n next_color = flowers [ i + 1 ]\n if (\n current_color != '.' and\n current_color != prev_color and\n current_color != next_color and\n prev_color != next_color\n ):\n is_possible = True\n break\n\n\nprint ( 'YES' if is_possible else 'NO' )\n"}, {"source_code": "#l = ['.']\nlettre = ['ABC','ACB','BCA','BAC','CAB','CBA','BABAAAACCBCB','BCAABBC','BBCACCC','BAABABAACCAC','ACCBBCA','ABBAACC','BAABABABBCBB','CCCAABBCCACAC','ABACAACC','BBBCA','CAACCBBA','BABCCBCCB','AABAAC','CACCBAA','ABBABAB','CBAABABCCC','ABCBCBBAA','ABABB','AABABBCCAA' ]\nk =0\nch = input ()\nfor i in ch:\n n=ch.split('.')\n#print (n)\nfor j in n :\n if j in lettre :\n k=k+1\n\nprint (\"NO\") if (k==0) else print (\"YES\")\n \n \n"}, {"source_code": "s = input()\n\nif s.find('ABC') == -1 or s.find('ACB') == -1 or s.find('BAC') == -1 or s.find('BCA') == -1 or s.find('CBA') == -1 or s.find('CAB') == -1:\n print('No')\nelse:\n print('Yes')\n \n "}, {"source_code": "#l = ['.']\nlettre = ['ABC','ACB','BCA','BAC','CAB','CBA','CBAB','CCABBCBCCBC','ACCCCBBB', 'CAACCB' ,'BCCAB','BABAAAACCBCB','BCAABBC','BBCACCC','BAABABAACCAC','ACCBBCA','ABBAACC','BAABABABBCBB','CCCAABBCCACAC','ABACAACC','BBBCA','CAACCBBA','BABCCBCCB','AABAAC','CACCBAA','ABBABAB','CBAABABCCC','ABCBCBBAA','ABABB','AABABBCCAA' ]\nk =0\nch = input ()\nfor i in ch:\n n=ch.split('.')\n#print (n)\nfor j in n :\n if j in lettre :\n k=k+1\n\nprint (\"NO\") if (k==0) else print (\"YES\")"}, {"source_code": "t = input()\nflag = 0\nd = {}\nl = [\"ACB\",\"BAC\",\"CAB\",\"ABC\",\"BCA\",\"CAB\",\"CBA\"]\nfor i in range(len(t)-3):\n\tif t[i:i+4] in l:\n\t\tflag = 1\n\t\tprint(\"YES\")\nif flag == 0:\n\tprint(\"NO\")\n\n"}, {"source_code": "a = raw_input()\nz=1\ni=0\nl=[]\nx = \"No\"\nwhile z==1 and i0:\n for i in range(len(s)-2):\n p=s[i:i+3]\n #print(p,int(p=='BAC')==1)\n if p==\"ABC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"BAC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"CAB\":\n print(\"Yes\")\n ct+=1\n break\n if ct==0:\n print(\"No\")"}, {"source_code": "s = input()\nn = len(s)\nf = 0\nfor i in range(n - 2):\n\t\tif s[i] != '.' and s[i+1] != '.' and s[i+2] != '.':\n\t\t\t\tif s[i+1] != s[i]:\n\t\t\t\t\t\tif s[i+2] != s[i] and s[i+2] != s[i]:\n\t\t\t\t\t\t\t\tf = 1\n\t\t\t\t\t\t\t\tbreak\n\nif f == 1:\n\t\tprint('Yes')\nelse:\n\t\tprint('No')\n"}, {"source_code": "s = raw_input()\nslist = list(s)\nlens = len(s)\ns1 = [None]*lens\ns1[0] = '.'\nfor i in range(1, lens):\n\tif s[i-1] == '.':\n\t\ts1[i] = '.'\n\telif s[i] == '.':\n\t\ts1[i] = s[i-1]\n\telif s[i-1] != '.' and s[i] != '.':\n\t\ts1[i] = s[i-1] + s[i]\ns2 = [None] * lens\ns2[lens-1] = '.'\nfor i in range(lens-2, -1, -1):\n\tif s[i+1] == '.':\n\t\ts2[i] = '.'\n\telif s[i] == '.':\n\t\ts2[i] = s[i+1]\n\telif s[i+1] != '.' and s[i] != '.':\n\t\ts2[i] = s[i+1] + s[i]\nfor i in range(lens):\n\ttemp = list(set(s1[i] + s2[i]))\n\tif 'A' in temp and 'B' in temp and 'C' in temp:\n\t\tprint \"YES\"\n\t\texit()"}, {"source_code": "\"\"\" https://codeforces.com/problemset/problem/989/A \"\"\"\n\nflowers = input ()\n\nis_possible = False\nif len ( flowers ) >= 3:\n for i in range ( 1, len ( flowers ) - 1 ):\n current_color = flowers [ i ]\n prev_color = flowers [ i - 1 ]\n next_color = flowers [ i + 1 ]\n if (\n current_color != '.' and\n current_color != prev_color and\n current_color != next_color and\n prev_color != next_color\n ):\n is_possible = True\n break\n\n\nprint ( 'YES' if is_possible else 'NO' )\n"}, {"source_code": "a=list(input().split('.'))\nb=['ABC','ACB','BAC','BCA','CAB','CBA']\nn=0\nwhile '' in a:\n a.remove('')\nif len(a)==0:\n print('No')\nelse:\n for i in a: \n if i in b:\n continue\n else:\n n=1\n\n if n!=0:\n print('No')\n else:\n print('Yes')\n \n \n"}, {"source_code": "s = raw_input()\nvals = []\ncount = 1\npos = [\"A\", \"B\", \"C\"]\n\nfor i in s:\n\tvals.append(i)\n\nfor i in vals[1:]:\n\tif i in pos:\n\t\tpos.remove(i)\n\telse:\n\t\tcontinue\n\tif vals[count-1] in pos:\n\t\tpos.remove(vals[count-1])\n\tif vals[count+1] in pos:\n\t\tpos.remove(vals[count+1])\n\tif not pos:\n\t\tprint \"Yes\"\n\t\texit()\n\tcount += 1\n\tpos = [\"A\", \"B\", \"C\"]\nprint \"No\""}, {"source_code": "s=input()\nfor i in range(len(s)-2):\n if (s[i:(i+3)]=='ABC')or(s[i:(i+3)]=='ACB')or(s[i:(i+3)]=='BAC')or(s[i:(i+3)]=='BCA')or(s[i:(i+3)]=='CBA')or(s[i:(i+3)]=='CAB'):\n print('Yes')\n break\n else:\n if i==len(s)-3:\n print('No')\n \n"}, {"source_code": "a = raw_input()\nz=1\ni=0\nl=[]\nx = \"No\"\nwhile z==1 and i=1:print('YES')\nelse:print('NO')"}, {"source_code": "string = input()\nif 'abc' in string:\n\tprint('Yes')\nelif 'acb' in string:\n\tprint('Yes')\nelif 'bac' in string:\n\tprint('Yes')\nelif 'bca' in string:\n\tprint('Yes')\nelif 'cab' in string:\n\tprint('Yes')\nelif 'cba' in string:\n\tprint('Yes')\nelse:\n\tprint('No')"}, {"source_code": "s=input()\nct=0\nfor i in range(len(s)-2):\n p=s[i:i+3]\n #print(p,int(p=='BAC')==1)\n if p==\"ABC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"BAC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"CAB\":\n print(\"Yes\")\n ct+=1\n break\nif ct==0:\n print(\"No\")\n"}, {"source_code": "from sys import stdin, stdout\n\nx=str(stdin.readline().strip())\n\nL=[\"ABC\",\"BAC\",\"CAB\",\"BCA\",\"CBA\",\"ACB\"]\nb=0\nfor i in L:\n if(x.find(i)!=-1):\n print i\n b=1\nif(b==0):\n print \"No\"\nelse:\n print \"Yes\"\n"}, {"source_code": "lis=list(input())\n\nfound=[]\ni=0\nwhile i0 or a.find(\"CAB\")>0 or a.find(\"BAC\")>0 or a.find(\"ACB\")>0 or a.find(\"CBA\")>0 or a.find(\"BCA\")>0:\n print(\"Yes\")\nelse:\n print(\"No\")\n"}, {"source_code": "s=input()\nflag=1\nfor i in range(1,len(s)-1):\n if s[i]!='.' and s[i-1]!='.' and s[(i+1)%len(s)]:\n if s[i]!=s[i-1] and s[i-1]!=s[i+1] and s[i]!=s[i+1]:\n flag=0\n break\nif flag==0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s = str(input())\n\nif 'ACB' in s :\n print(\"hi\")\n\nif 'ABC' in s or 'BCA'in s or 'BAC' in s or 'CAB'in s or 'ACB'in s or 'CBA' in s:\n print(\"YES\")\nelse:\n print(\"NO\") \n"}, {"source_code": "s=input()\nF=0\nfor i in range(len(s)-3):\n if s[i:i+3]=='ABC' or s[i:i+3]=='ACB' or s[i:i+3]=='BAC' or s[i:i+3]=='BCA' or s[i:i+3]=='CAB' or s[i:i+3]=='CBA':\n print(\"Yes\")\n F=1\n break\nif F==0:\n print(\"No\")\n"}, {"source_code": "\"\"\" https://codeforces.com/problemset/problem/989/A \"\"\"\n\nflowers = input ()\n\nis_possible = False\nif len ( flowers ) >= 3:\n for i in range ( 1, len ( flowers ) - 1 ):\n current_color = flowers [ i ]\n prev_color = flowers [ i - 1 ]\n next_color = flowers [ i + 1 ]\n if (\n current_color != '.' and\n current_color != prev_color and\n current_color != next_color and\n prev_color != next_color\n ):\n is_possible = True\n break\n\n\nprint ( 'YES' if is_possible else 'NO' )\n"}, {"source_code": "bed = input()\n\nif 'BAC' or 'ABC' or 'CAB' in bed:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "def fxn() : \n # arr = list(map(isalpha, input().split()))\n # isalpha is not global function \n # split doesn't split by character \n # split turned it into a list for consumption ??\n\n arr = [i in 'ABC' for i in input().split()[0]]\n\n #print(arr)\n\n for i in range (len(arr)-2):\n if (arr[i] and arr[i+1] and arr[i+2]) :\n return \"Yes\"\n\n return \"No\"\n\nprint(fxn())\n"}, {"source_code": "a = input()\ni = 0\nwhile i < len(a):\n x = a[i:3]\n if a[i:3] == 'ABC' or x == 'ACB' or x == 'BAC' or x == 'BCA' or x == 'CAB' or x == 'CBA':\n print('YES')\n break\n i += 1\n\nif i >= len(a):\n print(\"NO\")"}, {"source_code": "t = input()\nflag = 0\nd = {}\nl = [\"ACB\",\"BAC\",\"CAB\",\"ABC\",\"BCA\",\"CAB\",\"CBA\"]\nfor i in range(len(t)-3):\n\tif t[i:i+4] in l:\n\t\tflag = 1\n\t\tprint(\"YES\")\nif flag == 0:\n\tprint(\"NO\")\n\n"}, {"source_code": "a=list(input().split('.'))\nb=['ABC','ACB','BAC','BCA','CAB','CBA']\nn=0\nfor i in a:\n if i=='':\n pass\n elif i in b:\n continue\n else:\n n=1\n\nif n!=0:\n print('No')\nelse:\n print('Yes')\n \n \n"}, {"source_code": "s=input()\nt=[]\nflag=0\nfor i in range(len(s)-2):\n if(ord(s[i])+ord(s[i+1])+ord(s[i+2])==ord(\"A\")+ord(\"B\")+ord(\"C\") and(s[i]!=\".\" and s[i+1]!=\".\" and s[i+2]!=\".\")):\n flag=1\n break\nif(flag==1):\n print(\"Yes\")\nelse:\n print(\"No\")\n \n"}, {"source_code": "n=input()\nif n.count('A')>0 and n.count('B')>0 and n.count('C'):print('YES')\nelse:print('NO')"}, {"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\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\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 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')=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())\nvar = []\nans = []\nfor i in range(1000000):\n\tvar.append(i)\nfor i in range(len(var)):\n\tif (var[i] // k)*(var[i] % k) == n:\n\t\tans.append(var[i])\nprint(min(ans))\n\"\"\"\na = input().replace(\".\",\"\")\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\"\"\"\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\"\"\"\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"}, {"source_code": "def fxn() : \n # arr = list(map(isalpha, input().split()))\n # isalpha is not global function \n # split doesn't split by character \n # split turned it into a list for consumption ??\n\n arr = [i.isalpha() for i in input().split()[0]]\n\n #print(arr)\n\n for i in range (len(arr)-2):\n if (arr[i] and arr[i+1] and arr[i+2]) :\n return \"Yes\"\n\n return \"No\"\n\nprint(fxn())\n"}, {"source_code": "s = input()\ns=s[1:-1]\nflag = True\nif(len(s)>3):\n for i in range(len(s)-3):\n s2 = s[i:i+3]\n if(s2=='ABC' or s2=='ACB' or s2=='BAC' or s2=='BCA' or s2==\"CAB\" or s2=='CBA'):\n print(\"Yes\")\n flag = False\n break\nelif(len(s)==3):\n if (s == 'ABC' or s == 'ACB' or s == 'BAC' or s == 'BCA' or s == \"CAB\" or s == 'CBA'):\n print(\"Yes\")\n flag = False\n\nif(flag or len(s)<3):\n print(\"No\")\n"}, {"source_code": "s=input()\nct=0\nif len(s)>0:\n for i in range(len(s)-2):\n p=s[i:i+3]\n #print(p,int(p=='BAC')==1)\n if p==\"ABC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"BAC\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"CAB\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"ACB\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"CBA\":\n print(\"Yes\")\n ct+=1\n break\n elif p==\"BAC\":\n print(\"Yes\")\n ct+=1\n break\n if ct==0:\n print(\"No\")"}, {"source_code": "s = input()\ns = '.' + s\ns += '.'\nfor i in range(0, len(s) - 3):\n z = set(s[i]+s[i+1]+s[i+2])\n if {'A', 'B', 'C'} == z:\n print('YEs')\n exit(0)\nif s.count('A.B.C') or s.count('A.C.B') or s.count('B.A.C') or s.count('B.C.A') or s.count('C.B.A') or s.count('C.A.B'):\n print('yes')\n exit(0)\nprint('No')"}, {"source_code": "s = input().replace('A', '0').replace('B', '0').replace('C', '0')\nif '000' in s:\n print('Yes')\nelse:\n print('No')\n"}, {"source_code": "\na=input()\nn=len(a)\nw=0\nfor i in range(n-2):\n s=a[i]+a[i+1]\n s=s+a[i+2]\n if \"A\" in s and \"B\" in s and \"C\" in s:\n print(\"Yes\")\n w=1\n exit\nif w==0:\n print(\"No\")\n \n \n \n "}, {"source_code": "s = list(set(input().split(\".\")))\nl = [\"ABC\", \"ACB\", \"BCA\", \"BAC\", \"CBA\", \"CAB\"]\nprint(s)\nfor i in s:\n for j in l:\n if j in i:\n print(\"Yes\")\n exit(0)\nprint(\"No\")\n"}, {"source_code": "#l = ['.']\nlettre = ['ABC', 'ACB' , 'BCA', 'BAC' , 'CAB' , 'CBA','BBBCA','CAACCBBA' ]\nk =0\nch = input ()\nfor i in ch:\n n=ch.split('.')\n#print (n)\nfor j in n :\n if j in lettre :\n k=k+1\n\nprint (\"NO\") if (k==0) else print (\"YES\")\n \n \n"}, {"source_code": "s = input()\ndict = {}\nif len(s) < 5:\n print(\"No\")\nelse:\n for i in s[1:4]:\n dict[i] = dict.get(i, 0)+1\n i = 3\n flag = 0\n while i < len(s)-1:\n if dict.get('A', 0) == 1 and dict.get('B', 0) == 1 and dict.get('C', 0) == 1:\n flag = 1\n break\n dict[s[i]] = dict.get(s[i], 0)+1\n dict[s[i-3]] = dict.get(s[i-3], 0)-1\n i += 1\n if flag == 1:\n print(\"Yes\")\n else:\n print(\"No\")"}], "src_uid": "ba6ff507384570152118e2ab322dd11f"} {"nl": {"description": "InputThe input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.OutputOutput \"YES\" or \"NO\".ExamplesInput\nHELP\nOutput\nYES\nInput\nAID\nOutput\nNO\nInput\nMARY\nOutput\nNO\nInput\nANNA\nOutput\nYES\nInput\nMUG\nOutput\nYES\nInput\nCUP\nOutput\nNO\nInput\nSUM\nOutput\nYES\nInput\nPRODUCT\nOutput\nNO\n", "input_spec": "The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive.", "output_spec": "Output \"YES\" or \"NO\".", "sample_inputs": ["HELP", "AID", "MARY", "ANNA", "MUG", "CUP", "SUM", "PRODUCT"], "sample_outputs": ["YES", "NO", "NO", "YES", "YES", "NO", "YES", "NO"], "notes": null}, "positive_code": [{"source_code": "n = input()\r\ns = []\r\nif(len(n)<=2):\r\n print(\"YES\")\r\n exit()\r\nfor i in n:\r\n s.append(i)\r\nflag = False\r\nfor i in range(len(s)-2):\r\n if((ord(s[i])+ord(s[i+1]))%26+65==ord(s[i+2])):\r\n flag = True\r\n # print(\"HI\")\r\n else:\r\n flag = False\r\n # print(\"BYE\")\r\n break\r\nprint(\"Yes\" if flag else \"No\")"}, {"source_code": "t = input()\nfor i in range(2, len(t)):\n\tif ord(t[i])-ord('A') != (ord(t[i-1])-ord('A') + ord(t[i-2])-ord('A'))%26:\n\t\tprint(\"NO\")\n\t\texit()\nprint(\"YES\")"}, {"source_code": "# Uses python3\nfrom sys import stdin, stdout \nimport sys\nimport math\nimport itertools\nfrom collections import defaultdict\nsys.setrecursionlimit(10**6)\n\ndef fibWord(s):\n\tif len(s)<2:\n\t\treturn True\n\ta = ord(s[0])-64\n\tb = ord(s[1])-64\n\n\tfor i in range(2,len(s)):\n\n\t\tc = a+b-1\n\t\tif c>26:\n\t\t\tc = c-26\n\t\t# print(a,b,c)\n\t\tif ord(s[i])-64!=c:\n\t\t\treturn False\n\t\tt = a\n\t\ta = b\n\t\tb = c\n\treturn True\n\ndef main(): \n\ts = input().strip()\n\tif fibWord(s):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n\n\n# call the main method \nif __name__ == \"__main__\": \n\tmain()\t "}, {"source_code": "s=input()\r\no=True\r\na=ord('A')\r\nfor i in range(2, len(s)):\r\n o&=ord(s[i])-a==(ord(s[i-1])-a + ord(s[i-2])-a)%26\r\nif o:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "s=input()\r\nprint(\"NYOE S\"[all(((ord(s[i])+ord(s[i+1])-ord(s[i+2]))%26==13for i in range(len(s)-2)))::2])"}, {"source_code": "a = input()\r\ndic = dict(zip('ABCDEFGHIJKLMNOPQRSTUVWXYZ', list(range(26))))\r\ncur = [dic[i]for i in a]\r\nfor i in range(2, len(cur)):\r\n if cur[i] != (cur[i-1]+cur[i-2]) % 26:\r\n print('NO')\r\n exit()\r\nprint('YES')"}, {"source_code": "from random import choice\nl = lambda c: ord(c)-ord('A')\nx = list(map(l, input()))\n\nres = \"YES\"\nfor i in range(2, len(x)):\n\tif x[i] != (x[i-1]+x[i-2])%26:\n\t\tres = \"NO\"\nprint(res)\n\n"}, {"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 word = I()\r\n n = len(word)\r\n if n <= 2:\r\n print('YES')\r\n else:\r\n for i in range(2, n):\r\n if (ord(word[i - 1]) - ord('A') + ord(word[i - 2]) - ord('A')) % 26 != ord(word[i]) - ord('A'):\r\n print('NO')\r\n return\r\n print('YES')\r\nsolve()"}, {"source_code": "s=input()\r\nf=\"YES\"\r\nl=len(s)\r\nif l<3:\r\n f=\"YES\"\r\na=[0]*l\r\nfor i in range(l):\r\n a[i]=ord(s[i])-65\r\nfor i in range(2,l):\r\n if a[i]!=(a[i-1]+a[i-2])%26:\r\n f=\"NO\"\r\n break\r\nprint(f)"}, {"source_code": "T=input()\r\nif len(T)<=2:\r\n print(\"YES\")\r\nelse:\r\n flag=False\r\n for i in range(2,len(T)):\r\n if ord(T[i])-64!=((ord(T[i-1])+ord(T[i-2])-129)%26):\r\n flag=True\r\n break\r\n if flag:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")"}, {"source_code": "word = list (input())\r\nn = len (word)\r\n\r\nalphabet=list ('ABCDEFGHIJKLMNOPQRSTUVWXYZ')\r\nalphabet_dict = {}\r\nfor i in range (26):\r\n alphabet_dict [alphabet[i] ]=i\r\n\r\nearly_exit = False\r\nfor i in range (n-2):\r\n x = alphabet_dict[word[i]]\r\n y = alphabet_dict[word[i+1]]\r\n z = alphabet_dict[word[i+2]]\r\n if (x+y)%26 != z:\r\n early_exit=True\r\n break\r\n\r\nprint ('NO' if early_exit else 'YES' )\r\n"}, {"source_code": "\r\nfrom collections import Counter,defaultdict,deque\r\n#from heapq import *\r\n#from itertools import *\r\n#from operator import itemgetter\r\n#from itertools import count, islice\r\n#from functools import reduce\r\n#alph = 'abcdefghijklmnopqrstuvwxyz'\r\n#n,x = [int(_) for _ in input().split()]\r\n#s = input().strip()\r\n#sarr = [x for x in input().strip().split()]\r\n#import math\r\n#from math import *\r\n#from heapq import *\r\nimport sys\r\ninput=sys.stdin.readline\r\n#sys.setrecursionlimit(2**30)\r\n\r\n#ons = ['no','yes']\r\ndef solve():\r\n #n = int(input())\r\n s = input().strip()\r\n if len(s)<=2:\r\n print('YES')\r\n return\r\n arr = []\r\n for i in range(len(s)):\r\n arr.append(ord(s[i])-ord('A'))\r\n for i in range(len(s)-2):\r\n if (arr[i]+arr[i+1])%26!=arr[i+2]:\r\n print('NO')\r\n return\r\n print('YES')\r\n\r\n\r\n\r\ntt = 1#int(input())\r\nfor test in range(tt):\r\n solve()\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": "\r\nstr1=input()\r\nif(len(str1)<3):\r\n print('YES')\r\n quit()\r\nfor i in range(0,len(str1)-2):\r\n if(((ord(str1[i])+ord(str1[i+1])-130)%26)==(ord(str1[i+2])-65)):\r\n continue\r\n else:\r\n print('NO')\r\n quit()\r\nprint('YES')"}, {"source_code": "import sys\r\nimport os.path\r\nimport math\r\nimport heapq\r\nimport copy\r\nfrom sys import stdin,stdout\r\nfrom collections import*\r\nfrom math import gcd,ceil,floor\r\nfrom bisect import bisect\r\nmod = int(1e9+7)\r\n##sys.setrecursionlimit(10**8)\r\n##input=sys.stdin.readline\r\n\r\nif os.path.exists('Updated prg/Input3d.txt'):\r\n sys.stdout=open(\"Updated prg/Output3d.txt\",\"w\")\r\n sys.stdin=open(\"Updated prg/Input3d.txt\",\"r\")\r\n \r\ndef sinp():return input()\r\ndef ninp():return int(sinp())\r\ndef mapinp():return map(int,sinp().split())\r\ndef smapinp():return map(str,sinp().split())\r\ndef linp():return list(mapinp())\r\ndef sl():return list(sinp().split())\r\ndef prnt(a):print(a)\r\ndef prntl(a):print(a,end=\" \")\r\ndef prntlist(l1) : print(*l1)\r\ndef power(n): return 1< 26:\r\n x -= 26\r\n d.append(chr(x+64))\r\n\r\nif ''.join(d) == s:\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "import sys\r\nimport collections\r\nfrom collections import Counter, deque\r\nimport itertools\r\nimport math\r\nimport timeit\r\nimport random\r\n\r\n#########################\r\n# imgur.com/Pkt7iIf.png #\r\n#########################\r\n\r\ndef sieve(n):\r\n if n < 2: return list()\r\n prime = [True for _ in range(n + 1)]\r\n p = 3\r\n while p * p <= n:\r\n if prime[p]:\r\n for i in range(p * 2, n + 1, p):\r\n prime[i] = False\r\n p += 2\r\n r = [2]\r\n for p in range(3, n + 1, 2):\r\n if prime[p]:\r\n r.append(p)\r\n return r\r\n\r\ndef divs(n, start=1):\r\n divisors = []\r\n for i in range(start, int(math.sqrt(n) + 1)):\r\n if n % i == 0:\r\n if n / i == i:\r\n divisors.append(i)\r\n else:\r\n divisors.extend([i, n // i])\r\n return divisors\r\n\r\ndef divn(n, primes):\r\n divs_number = 1\r\n for i in primes:\r\n if n == 1:\r\n return divs_number\r\n t = 1\r\n while n % i == 0:\r\n t += 1\r\n n //= i\r\n divs_number *= t\r\n\r\ndef flin(d, x, default=-1):\r\n left = right = -1\r\n for i in range(len(d)):\r\n if d[i] == x:\r\n if left == -1: left = i\r\n right = i\r\n if left == -1:\r\n return (default, default)\r\n else:\r\n return (left, right)\r\n\r\ndef ceil(n, k): return n // k + (n % k != 0)\r\ndef ii(): return int(input())\r\ndef mi(): return map(int, input().split())\r\ndef li(): return list(map(int, input().split()))\r\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\r\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\r\ndef dd(): return collections.defaultdict(int)\r\ndef ddl(): return collections.defaultdict(list)\r\ndef minmax(a, b): return (a, b) if a < b else (b, a)\r\n\r\n# input = sys.stdin.readline\r\n\r\ndef f(a):\r\n return ord(a) - ord('A')\r\n\r\ns = input()\r\nif len(s) < 3:\r\n exit(print(\"YES\"))\r\na, b = f(s[0]), f(s[1])\r\n\r\nr = 1\r\nfor i in range(2, len(s)):\r\n if ((a + b) % 26) != f(s[i]):\r\n r = 0\r\n break\r\n a, b = b, f(s[i])\r\nprint(\"YES\" if r else \"NO\")\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": "s=*map(ord,input()),;print(\"NYOE S\"[all((a+b-c)%26==13for a,b,c in zip(s,s[1:],s[2:]))::2])"}, {"source_code": "l = list(input())\r\nflag = False\r\nd = [0]*len(l)\r\nfor i in range(len(l)):\r\n d[i] = ord(l[i])-65\r\nfor i in range(2,len(l)):\r\n if (d[i] != (d[i-1] + d[i-2])%26):\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")"}, {"source_code": "l = list(input())\r\nflag = False\r\nd = [0]*len(l)\r\nfor i in range(len(l)):\r\n d[i] = ord(l[i])-65\r\nfor i in range(2,len(l)):\r\n if (d[i] != (d[i-1] + d[i-2])%26):\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")"}, {"source_code": "'''I = lambda: [int(i) for i in input().split()]\r\nimport io, os, sys\r\ninput = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline'''\r\n \r\n#n = int(input())\r\n#l1 = list(map(int,input().split()))\r\n#n,x = map(int,input().split())\r\n#s = input()\r\n#mod = 1000000007\r\n#import bisect\r\n \r\n\r\ns= input()\r\nsu=0\r\nl=[]\r\nfor i in s:\r\n l.append(ord(i)-65)\r\nif len(l)<=2:\r\n print(\"YES\")\r\nelse:\r\n for i in range(2,len(l)):\r\n if l[i]!=(l[i-1]+l[i-2])%26:\r\n print(\"NO\")\r\n break\r\n else:\r\n print(\"YES\")\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": "from sys import stdin\r\n\r\nfor q in stdin:\r\n q = q.rstrip()\r\n # print(q)\r\n if len(q) < 3:\r\n print(\"YES\", flush=True)\r\n continue\r\n source = []\r\n for i, c in enumerate(q):\r\n source.append(ord(c) - ord('A'))\r\n # print(source, flush=True)\r\n ans = True\r\n for i in range(2, len(q)):\r\n if source[i] != (source[i - 1] + source[i - 2]) % 26:\r\n print(\"NO\", flush=True)\r\n ans = False\r\n break\r\n if ans:\r\n print(\"YES\", flush=True)"}, {"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\"]\r\ns = input()\r\nx = True\r\ni = []\r\nj = 0\r\nfor c in s:\r\n i.append(a.index(c))\r\n if j > 1:\r\n if i[j-1] + i[j-2] > 25:\r\n if i[j] != i[j-1] + i[j-2] - 26:\r\n x = False\r\n else:\r\n if i[j] != i[j-1] + i[j-2]:\r\n x = False\r\n j += 1\r\nif x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "''' __ __ __ __ __ __ __ \r\n / | / | / | / | / | / |/| | \r\n _______ ______ _$$ |_ $$ |____ $$ |____ ______ $$/ _$$ |_ $$/ |$$ | __ \r\n / | / / $$ | $$ $$ / / | / $$ | / |$$ | / |\r\n/$$$$$$$/ /$$$$$$ |$$$$$$/ $$$$$$$ |$$$$$$$ |/$$$$$$ |$$ | $$$$$$/ $$ |$$ |_/$$/ \r\n$$ $$ $$ | $$ | __ $$ | $$ |$$ | $$ |$$ | $$/ $$ | $$ | __ $$ |$$ $$< \r\n $$$$$$ |$$$$$$$$/ $$ |/ |$$ | $$ |$$ | $$ |$$ | $$ | $$ |/ | $$ |$$$$$$ \\\r\n/ $$/ $$ | $$ $$/ $$ | $$ |$$ | $$ |$$ | $$ | $$ $$/ $$ |$$ | $$ |\r\n$$$$$$$/ $$$$$$$/ $$$$/ $$/ $$/ $$/ $$/ $$/ $$/ $$$$/ $$/ |$$/ $$/ \r\n \r\n''' \r\n \r\nimport sys\r\nfrom os import path\r\nimport bisect\r\nif (path.exists('input.txt')):\r\n sys.stdin = open('input.txt', 'r')\r\n sys.stdout = open('output1.txt', 'w')\r\nfrom heapq import heappop, heappush, heapify\r\nfrom math import ceil\r\nfrom collections import defaultdict\r\nmaxi = sys.maxsize\r\nmini = -maxi\r\ns=input()\r\nif len(s)<3:\r\n print('YES')\r\nelse:\r\n n=len(s)\r\n f=True\r\n a,b = ord(s[0])-65,ord(s[1])-65\r\n for i in range(2,n):\r\n ans = (a+b)%26\r\n if chr(ans+65)!=s[i]:\r\n f=False\r\n break\r\n a = b \r\n b = ans\r\n if f:\r\n print('YES')\r\n else:\r\n print('NO')"}, {"source_code": "from sys import maxsize, stdout, stdin,stderr\r\nmod = int(1e9 + 7)\r\ndef I(): return int(stdin.readline())\r\ndef lint(): return [int(x) for x in stdin.readline().split()]\r\ndef S(): return input().strip()\r\ndef grid(r, c): return [lint() for i in range(r)]\r\nfrom collections import defaultdict\r\nimport math\r\n\r\nl = input()\r\nif len(l)<=2:\r\n print(\"YES\")\r\nelse:\r\n f= True\r\n for i in range(2,len(l)):\r\n t=ord(l[i-1]) + ord(l[i-2])-128-1\r\n \r\n if t>26:\r\n t%=26\r\n \r\n if t!=ord(l[i])-64:\r\n f= False\r\n break\r\n if f:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")"}, {"source_code": "s=*map(ord,input()),;print(\"YNEOS\"[any((a+b-c)%26^13for a,b,c in zip(s,s[1:],s[2:]))::2])"}, {"source_code": "s=input()\r\nans=\"YES\"\r\nn=len(s)\r\nfor i in range(n-2):\r\n if (ord(s[i])+ord(s[i+1])-2*ord('A'))%26!=ord(s[i+2])-ord('A'):\r\n ans=\"NO\"\r\n break\r\nprint(ans)"}, {"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 s = [ord(i) - ord('A') for i in input()]\r\n n = len(s)\r\n f = True\r\n for i in range(2, n):\r\n if s[i] != (s[i - 1] + s[i - 2]) % 26:\r\n f = False\r\n break\r\n print('YES' if f else 'NO')\r\n"}, {"source_code": "\r\nfrom collections import defaultdict\r\nimport sys\r\nimport math\r\n\r\n\r\n\r\ndef readInt():\r\n x = int(sys.stdin.readline())\r\n return x\r\n\r\n\r\ndef readList():\r\n x = list(map(int, sys.stdin.readline().split()))\r\n return x\r\n\r\n\r\nwrite = sys.stdout.write\r\nread = sys.stdin.readline\r\n\r\n\r\n\r\ndef solve():\r\n s = read().rstrip('\\n')\r\n ok = True\r\n for i in range(2, len(s)):\r\n ok = ok & ((s[i]) == chr((((ord(s[i-2]) + ord(s[i-1]) - 2*ord('A')) % 26))+ord('A')))\r\n \r\n if ok:\r\n print('YES')\r\n else:\r\n print('NO')\r\n\r\ndef main():\r\n t = 1\r\n # t = readInt()\r\n for _ in range(t):\r\n solve()\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "# RANK1ZEN; 3966 PEAK NA FLEX SUPPORT; 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\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 False\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 True\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, arr):\r\n self.tree = array.array(\"i\", [0] * (2 * len(arr)))\r\n self.n = len(arr)\r\n\r\n for i in range(self.n):\r\n self.tree[i + self.n] = arr[i]\r\n\r\n for i in range(self.n - 1, 0, -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 i += self.n\r\n self.tree[i + self.n] = val\r\n while i > 1:\r\n self.tree[i//2] = self.tree[i] + self.tree[i + 1]\r\n i //= 2\r\n\r\n def query(self, l, r):\r\n res, l, r = 0, l + self.n, r + self.n\r\n while l < r:\r\n if l & 1:\r\n res += self.tree[l]; l += 1\r\n if r & 1:\r\n r -= 1; res += self.tree[r]\r\n l //= 2; r //= 2\r\n return res\r\n\r\n def top(self): return self.tree[1]\r\n\r\nclass Comba:\r\n def __init__(self, mod):\r\n self.fact = array.array(\"i\", [0] * MX); self.fact[0] = 1\r\n self.fact_inv = array.array(\"i\", [0] * MX)\r\n self.mod = mod\r\n\r\n for i in range(1, MX):\r\n self.fact[i] = (self.fact[i - 1] * i) % self.mod\r\n\r\n self.fact_inv[MX - 1] = pow(self.fact[MX - 1], self.mod - 2, self.mod)\r\n for i in range(MX - 2, -1, -1):\r\n self.fact_inv[i] = (self.fact_inv[i + 1] * (i + 1)) % self.mod\r\n\r\n def ncr(self, n, r):\r\n if r > n or n < 0 or r < 0: return 0\r\n return (self.fact[n] * self.fact_inv[r] % self.mod) * self.fact_inv[n - r] % self.mod\r\n \r\n def npr(self, n, r):\r\n if r > n or n < 0 or r < 0: return 0\r\n return self.fact[n] * self.fact_inv[n - r] % self.mod\r\n\r\ndef lcm(x, y): return (x * y) // gcd(x, y)\r\n\r\ndef rw_file():\r\n sys.stdin = open(r\"\", \"r\")\r\n sys.stdout = open(r\"\", \"w\")\r\n\r\ndef re(data=str): return data(sys.stdin.readline().rstrip())\r\ndef mp(data=str): return map(data, sys.stdin.readline().split())\r\n\r\nimport sys, array\r\nfrom bisect import bisect_left, bisect_right, insort_left\r\nfrom math import ceil, floor, log, sqrt, gcd\r\nfrom collections import deque, defaultdict, Counter\r\nfrom heapq import heappush, heappop, heapify\r\n\r\nmod, mod9, nl, MX = 1000000007, 998244353, \"\\n\", 100003\r\n# endregion --------------------------------------------------------------------------------------|\r\n\r\ndef solve(tc):\r\n s = re()\r\n n = len(s)\r\n x = [ord(s[i]) - ord(\"A\") for i in range(n)]\r\n for i in range(2, n):\r\n if x[i] != (x[i - 1] + x[i - 2]) % 26:\r\n print(\"NO\"); return\r\n print(\"YES\")\r\n\r\n\r\n \r\n return None\r\n \r\ndef main(): \r\n # rw_file()\r\n cases = 1; # cases = re(int)\r\n for case in range(cases):\r\n solve(case + 1)\r\nmain()\r\n"}, {"source_code": "word = [ord(c) - ord('A') for c in input()]\r\n\r\nflag = True\r\nfor i in range(len(word) - 2):\r\n if (word[i] + word[i + 1]) % 26 != word[i + 2]:\r\n flag = False\r\n break\r\nif flag == True:\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "t = input()\r\nfor i in range(2, len(t)):\r\n\tif ord(t[i])-ord('A') != (ord(t[i-1])-ord('A') + ord(t[i-2])-ord('A'))%26:\r\n\t\tprint(\"NO\")\r\n\t\texit()\r\nprint(\"YES\")"}, {"source_code": "A = []\r\ns = input()\r\nfor i in s:\r\n A.append(ord(i) - ord('A'))\r\nfor i in range(2, len(A)):\r\n if(A[i] != (A[i-1] + A[i-2]) % 26):\r\n print(\"NO\")\r\n exit()\r\nprint(\"YES\")"}, {"source_code": "t = input()\r\nfor i in range(2, len(t)):\r\n\tif ord(t[i])-ord('A') != (ord(t[i-1])-ord('A') + ord(t[i-2])-ord('A'))%26:\r\n\t\tprint(\"NO\")\r\n\t\texit()\r\nprint(\"YES\")"}, {"source_code": "# link: https://codeforces.com/problemset/problem/1505/C\r\n\r\nimport os, 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\nfrom math import ceil\r\nmod = 10 ** 9 + 7 \r\n\r\n# number of test cases\r\nfor _ in range(1):\r\n word = input()\r\n stabilize = 26\r\n ans = \"YES\"\r\n for i in range(2, len(word)):\r\n previous_2_sums = (abs(ord(word[i-2]) - ord('A')) + abs(ord(word[i-1]) - ord('A'))) % stabilize\r\n if ord(word[i]) - ord('A') == previous_2_sums:\r\n continue\r\n else:\r\n ans = \"NO\"\r\n break\r\n print(ans) "}, {"source_code": "import copy\r\nimport math\r\n\r\nfin = None\r\nfout = None\r\nuabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',\r\n 'W', 'X', 'Y', 'Z']\r\nabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',\r\n 'w', 'x', 'y', 'z']\r\n\r\n\r\ndef start(filename):\r\n filename = filename.replace('.py', '')\r\n global fin\r\n global fout\r\n infile = filename + \".in\"\r\n outfile = filename + \".out\"\r\n fin = open(infile)\r\n fout = open(outfile, \"w\")\r\n\r\n\r\ndef permutation(lst):\r\n if len(lst) == 0:\r\n return []\r\n if len(lst) == 1:\r\n return [lst]\r\n l = []\r\n for i in range(len(lst)):\r\n m = lst[i]\r\n remLst = lst[:i] + lst[i + 1:]\r\n for p in permutation(remLst):\r\n l.append([m] + p)\r\n return l\r\n\r\n\r\ndef subsets(x):\r\n retset = []\r\n if len(x) == 0:\r\n retset = [[]]\r\n else:\r\n first = x[-1]\r\n cop = x.copy()\r\n cop.remove(first)\r\n y = subsets(cop)\r\n retset.extend(copy.deepcopy(y))\r\n m = copy.deepcopy(y)\r\n for i in range(len(y)):\r\n k = m[0]\r\n m.remove(k)\r\n k.append(first)\r\n m.append(k)\r\n retset.extend(m.copy())\r\n return retset\r\n\r\n\r\nclass Point:\r\n def __init__(self, x, y):\r\n self.x = x\r\n self.y = y\r\n\r\n def __str__(self):\r\n return str(self.x) + str(self.y)\r\n\r\n def __hash__(self):\r\n return hash(str(self))\r\n\r\n def __eq__(self, other):\r\n return self.x == other.x and self.y == other.y\r\n\r\n\r\nclass frac:\r\n def __init__(self, n, d):\r\n self.n = n\r\n self.d = d\r\n\r\n def __str__(self):\r\n return str(self.n) + '/' + str(self.d)\r\n\r\n def __hash__(self):\r\n return hash(str(self))\r\n\r\n def simp(self):\r\n div = math.gcd(self.n, self.d)\r\n self.n = self.n / div\r\n self.d = self.d / div\r\n\r\n def __eq__(self, other):\r\n return self.n / self.d == other.n / other.d\r\n\r\n def __lt__(self, other):\r\n return self.n / self.d < other.n / other.d\r\n\r\n\r\nclass Interval:\r\n def __init__(self, start, end):\r\n self.start = start\r\n self.end = end\r\n\r\n def __str__(self):\r\n return str(self.start) + str(self.end)\r\n\r\n def __hash__(self):\r\n return hash(str(self))\r\n\r\n def __eq__(self, other):\r\n return self.start == other.start and self.end == other.end\r\n\r\n def __lt__(self, other):\r\n return self.start < other.start\r\n\r\n\r\ndef overlap(verl1, verl2):\r\n if verl1.end >= verl2.start:\r\n return True\r\n else:\r\n return False\r\n\r\n\r\ndef merge(verl1, verl2):\r\n retverl = Interval(min(verl1.start, verl2.start), max(verl1.end, verl2.end))\r\n return retverl\r\n\r\n\r\ndef changeBase(num, base):\r\n if base == 2:\r\n return \"{0:b}\".format(num)\r\n power = math.floor(math.log(num, base))\r\n remainder = num\r\n end = []\r\n iter = list(range(power + 1))\r\n iter.reverse()\r\n for i in iter:\r\n if remainder >= base ** i:\r\n q, r = divmod(remainder, base ** i)\r\n end.append(q)\r\n remainder = r\r\n else:\r\n end.append(0)\r\n retlist = []\r\n for i in end:\r\n if i > 9:\r\n retlist.append(uabet[i - 10])\r\n else:\r\n retlist.append(i)\r\n retlist = map(str, retlist)\r\n return ''.join(retlist)\r\n\r\n\r\ndef prime(num):\r\n if num == 2:\r\n return True\r\n if num % 2 == 0:\r\n return False\r\n for i in range(2, math.ceil(num ** 0.5) + 1):\r\n if num % i == 0:\r\n return False\r\n return True\r\n\r\n\r\n\r\n\r\ndef main():\r\n x = input()\r\n x =list(x)\r\n o = []\r\n for i in x:\r\n o.append(uabet.index(i))\r\n for i in range(len(o)-2):\r\n if (o[i]+o[i+1])%26!= o[i+2]:\r\n\r\n print('NO')\r\n exit()\r\n print(\"YES\")\r\n\r\n\r\n# code timer\r\n\r\nmain()\r\n"}, {"source_code": "s = input()\nx = ord(s[0]) - ord('A')\nif len(s)>1:\n y = ord(s[1]) - ord('A')\nch = True\nfor i in range(2,len(s)):\n z = ord(s[i]) - ord('A')\n if (x+y)%26 != z:\n ch = False\n break\n x = y\n y = z\nif ch:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\ndef ich(a):\n return ord(a)-65\n\nword=input()\nif len(word)<3:\n print('YES')\nelse:\n flag=True\n i=2\n while flag and i1:\r\n\t\ta,b,c = ord(S[i])-ord('A'),ord(S[i-1])-ord('A'),ord(S[i-2])-ord('A')\r\n\r\n\t\tif a!=(b+c)%26:\r\n\t\t\texit(print('NO'))\r\nprint('YES')\r\n"}, {"source_code": "s = input()\r\n\r\nn = len(s)\r\nf = lambda x : ord(x) - ord('A')\r\nok = True\r\nfor i in range(2, n):\r\n if (f(s[i - 2]) + f(s[i - 1])) % 26 != f(s[i]):\r\n ok = False\r\nprint(\"YES\") if ok else print(\"NO\")\r\n\r\n\r\n"}, {"source_code": "s=input()\r\nflag=0\r\nfor i in range(2,len(s)):\r\n h=ord(s[i - 2]) - 65\r\n e=(ord(s[i-1])-65)\r\n l=ord(s[i])-65\r\n #print(h,e,l)\r\n if ((h+e)%26)!=l:\r\n flag=1\r\n break\r\nif flag==1:\r\n print('NO')\r\nelse:\r\n print('YES')\r\n"}, {"source_code": "s = input()\r\nn = len(s)\r\nif n<3:\r\n print(\"YES\")\r\nelse:\r\n lis = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\n dic = {}\r\n for i in range(26):\r\n dic[lis[i]] = i\r\n \r\n # for i in s:\r\n # print(ord(i)-65)\r\n \r\n flag=0\r\n for i in range(2,n):\r\n if dic[s[i]] != (dic[s[i-1]] + dic[s[i-2]])%26:\r\n flag=1\r\n break\r\n if flag==1:\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")\r\n \r\n "}, {"source_code": "s = input()\r\nfor i in range(2, len(s)):\r\n if (ord(s[i-2]) + ord(s[i-1]) - 2 * ord('A')) % 26 != ord(s[i]) - ord('A'):\r\n print('NO')\r\n break\r\nelse:\r\n print('YES')"}, {"source_code": "s = input()\nn = list(map(lambda x:ord(x)-ord(\"A\"),s))\nans = True\nfor i in range(2,len(n)):\n if n[i] != (n[i-1] + n[i-2])%26:ans = False\nprint(\"YES\" if ans else \"NO\")\n"}, {"source_code": "n=input()\r\nx=[\"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\"]\r\nfor i in range(2,len(n)):\r\n\tif (x.index(n[i-2])+1+x.index(n[i-1]))%26==x.index(n[i])+1:\r\n\t\t'''print(x.index(n[i-2]),n[i-2])\r\n\t\tprint(x.index(n[i-1]),n[i-1])\r\n\t\tprint(x.index(n[i]),n[i])'''\r\n\t\tcontinue\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\t\tbreak\r\nelse:\r\n\tprint(\"YES\")"}, {"source_code": "s=input()\nl=[ord(i)-65 for i in s]\nfor i in range(2,len(l)):\n if(l[i-2]+l[i-1])%26!=l[i]:\n print('NO')\n exit(0)\nprint('YES')"}, {"source_code": "\r\ndef intChar(l):\r\n return ord(l) - ord('A') \r\n\r\ns = list(map(intChar,input()))\r\n\r\nflag = True\r\n\r\n\r\nfor i in range(2,len(s)):\r\n if s[i] != (s[i-1] + s[i-2])%26:\r\n flag = False\r\n\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n\r\n\r\n\r\n\r\n"}, {"source_code": "def prank(word:str) -> str:\r\n if len(word) < 3:\r\n return 'YES'\r\n indices = []\r\n for l in word:\r\n indices.append(ord(l)-65)\r\n \r\n for i in range(2, len(indices)):\r\n if (indices[i-2]+indices[i-1])%26 != indices[i]:\r\n return 'NO'\r\n return 'YES'\r\n\r\n\r\n\r\nif __name__ == '__main__':\r\n print(prank(input()))"}, {"source_code": "import sys\ntesting = len(sys.argv) == 4 and sys.argv[3] == \"myTest\"\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\nflush = sys.stdout.flush\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]\ninputData = InputData()\ninput = 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()])\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\ndef main():\n s = strin()\n if len(s) <= 2:\n return True\n s = [x - ord('A') for x in map(ord, s)]\n dout(s)\n i = 0\n while i+2 < len(s):\n if (s[i]+s[i+1])%26 != s[i+2]:\n return False\n i += 1\n return True\n\n\nanss = []\nfor _ in xrange(1):\n # anss.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": "s = list(input())\r\nt = [ord(i) - 65 for i in s]\r\nans = \"YES\"\r\nfor i in range(max(0, len(s) - 2)):\r\n if not (t[i] + t[i + 1]) % 26 == t[i + 2]:\r\n ans = \"NO\"\r\nprint(ans)"}, {"source_code": "n=input()\r\nx=[\"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\"]\r\nfor i in range(2,len(n)):\r\n\tif (x.index(n[i-2])+1+x.index(n[i-1]))%26==x.index(n[i])+1:\r\n\t\t'''print(x.index(n[i-2]),n[i-2])\r\n\t\tprint(x.index(n[i-1]),n[i-1])\r\n\t\tprint(x.index(n[i]),n[i])'''\r\n\t\tcontinue\r\n\telse:\r\n\t\tprint(\"NO\")\r\n\t\tbreak\r\nelse:\r\n\tprint(\"YES\")"}, {"source_code": "def main():\r\n s = input()\r\n\r\n if len(s) < 2:\r\n print(\"YES\")\r\n exit()\r\n\r\n a = ord(s[0]) - 65\r\n b = ord(s[1]) - 65\r\n\r\n for i in range(2, len(s)):\r\n c = ord(s[i]) - 65\r\n \r\n if (a + b) % 26 != c:\r\n print(\"NO\")\r\n exit()\r\n \r\n a = b\r\n b = c\r\n\r\n print(\"YES\")\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "word = str(input())\r\n\r\nletters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\nflag = False\r\nlength = len(word)\r\nif length <= 2:\r\n flag = True\r\nelif length <= 10 and length > 0:\r\n for i in range(2,length):\r\n previous_letters = letters.find(word[i-2]) + letters.find(word[i-1])\r\n if previous_letters % 26 == letters.find(word[i]):\r\n flag = True\r\n else:\r\n break\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "def fibo(M) :\r\n n = len(M)\r\n b = True\r\n for i in range(n-2) :\r\n c1 = M[i]\r\n c2 = M[i+1]\r\n c3 = M[i+2]\r\n n1 = ord(c1)-ord(\"A\")\r\n n2 = ord(c2)-ord(\"A\")\r\n n3 = ord(c3)-ord(\"A\")\r\n if (n1+n2-n3)%26 :\r\n b = False\r\n if b :\r\n print(\"YES\")\r\n else :\r\n print(\"NO\")\r\n \r\nfibo(input())\r\n "}, {"source_code": "s=*map(ord,input()),;print(\"YNEOS\"[any((a+b-c)%26^13for a,b,c in zip(s,s[1:],s[2:]))::2])\r\n"}, {"source_code": "a = 'abcdefghijklmnopqrstuvwxyz'\r\n\r\ns = input().lower()\r\nans = 'YES'\r\n\r\nfor i in range(2, len(s)):\r\n if a.index(s[i]) != (a.index(s[i - 2]) + a.index(s[i - 1]))%26:\r\n ans = 'NO'\r\n\r\nprint(ans)\r\n"}, {"source_code": "ch=input()\r\nn=len(ch)\r\nif n<3:\r\n print(\"YES\")\r\n exit()\r\nfn= lambda x : -ord('A')+ord(x)\r\np1=fn(ch[0])\r\np2=fn(ch[1])\r\nfl=1\r\nfor i in range(2,n):\r\n tmp=-ord('A')+ord(ch[i])\r\n if tmp!=(p1+p2)%26:\r\n fl=0\r\n break\r\n p1=fn(ch[i-1])\r\n p2=fn(ch[i])\r\nif fl==0:\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n"}, {"source_code": "dict={'a':1,'b':2,'c':3,'d':4,'e':5,'f':6,'g':7,'h':8,'i':9,'j':10,\r\n'k':11,'l':12,'m':13,'n':14,'o':15,'p':16,'q':17,'r':18,'s':19,'t':20,'u':21,'v':22,'w':23,'x':24,'y':25,'z':26}\r\nn=input().lower()\r\nb=[]\r\nfor i in list(n):\r\n b.append(dict[i])\r\n\r\n\r\nfor i in range(len(b)-2):\r\n if b[i]+b[i+1]>26:\r\n if b[i+2]!=b[i]+b[i+1]-27:\r\n print('NO')\r\n break\r\n else:\r\n if b[i]+b[i+1]!=b[i+2]+1:\r\n print('NO')\r\n break\r\n \r\n \r\nelse:\r\n print('YES')\r\n "}, {"source_code": "from string import ascii_uppercase as u\r\ns = input()\r\nfor i in range(2, len(s)):\r\n if (u.index(s[i - 1]) + u.index(s[i - 2])) % 26 != u.index(s[i]):\r\n print('NO')\r\n exit()\r\nprint('YES')"}, {"source_code": "s=input()\r\nprint(\"NYOE S\"[all(((ord(s[i])+ord(s[i+1])-ord(s[i+2]))%26==13for i in range(len(s)-2)))::2])"}, {"source_code": "def SieveOfEratosthenes(n):\r\n primes = [i for i in range(n+3)]\r\n n+=2\r\n primes[1] = 1\r\n for i in range(4,n,2):\r\n primes[i] = 2\r\n for i in range(3,ceil(sqrt(n))+1):\r\n if(primes[i] == i):\r\n for j in range(i*i,n,i):\r\n if(primes[j] == j): primes[j] = i\r\n return primes\r\n \r\ndef primeFactors(n,primes):\r\n res = []\r\n while(n != 1):\r\n factor = primes[n]\r\n res.append(factor)\r\n n //= factor\r\n return res\r\n \r\nimport sys\r\nimport math\r\nimport bisect\r\nimport os\r\nfrom heapq import * \r\nfrom functools import cmp_to_key\r\nfrom sys import stdin,stdout\r\nfrom io import BytesIO, IOBase\r\nfrom math import gcd,floor,sqrt,log,inf\r\nfrom collections import defaultdict as dd\r\nfrom bisect import bisect_left as bl,bisect_right as br\r\nfrom collections import Counter\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\ninp = lambda:int(input())\r\nstrng = lambda: input().strip()\r\njn = lambda x,l: x.join(map(str,l))\r\nstrl = lambda: list(input().strip())\r\nmul = lambda: map(int,input().strip().split())\r\nmulf = lambda: map(float,input().strip().split())\r\nseq = lambda: list(map(int,input().strip().split()))\r\n\r\nceil = lambda x: int(x) if(x==int(x)) else int(x)+1\r\nceildiv= lambda x,d: x//d if(x%d==0) else x//d+1\r\n\r\nflush = lambda: stdout.flush()\r\nstdpr = lambda x: stdout.write(str(x))\r\n# sys.setrecursionlimit(100005)\r\n\r\nmod=1000000007\r\n\r\n# primes = SieveOfEratosthenes(100005)\r\n\r\ndef solver():\r\n s = input()\r\n for i in range(2,len(s)):\r\n if((ord(s[i-2])+ord(s[i-1])-2*ord(\"A\"))%26 != ord(s[i])-ord(\"A\")):\r\n print(\"NO\")\r\n return\r\n print(\"YES\")\r\n \r\nfor _ in range(1):\r\n solver()\r\n "}, {"source_code": "s=input()\r\nf=\"YES\"\r\nl=len(s)\r\nif l<3:\r\n f=\"YES\"\r\na=[0]*l\r\nfor i in range(l):\r\n a[i]=ord(s[i])-65\r\nfor i in range(2,l):\r\n if a[i]!=(a[i-1]+a[i-2])%26:\r\n f=\"NO\"\r\n break\r\nprint(f)"}, {"source_code": "def check_fib(s):\r\n if len(s) <= 2:\r\n return 'YES'\r\n s = list(map(lambda x: ord(x)-ord('A'), s))\r\n for i in range(2, len(s)):\r\n if s[i] != (s[i-1] + s[i-2]) % 26:\r\n return 'NO' \r\n return 'YES'\r\n \r\nprint(check_fib(input()))"}, {"source_code": "s=*map(ord,input()),;print(\"NYOE S\"[all((a+b-c)%26==13for a,b,c in zip(s,s[1:],s[2:]))::2])"}, {"source_code": "import sys\r\n#input = sys.stdin.readline\r\n \r\ns = input()\r\nfor i in range(2, len(s)):\r\n if ord(s[i]) + ord('A') != ord(s[i - 1]) + ord(s[i - 2]) and ord(s[i]) + ord('A') + 26 != ord(s[i - 1]) + ord(s[i - 2]):\r\n print('NO')\r\n break\r\nelse:\r\n print('YES')"}, {"source_code": "s=input()\r\nl=['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']\r\nl2=[]\r\nfor i in s:\r\n l2.append(l.index(i))\r\nc=0\r\nfor i in range(len(l2)-2):\r\n if l2[i]+l2[i+1]==l2[i+2] or l2[i]+l2[i+1]-26==l2[i+2] :\r\n c+=1\r\nif c==len(l2)-2 or len(l2)<=2:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n \r\n"}, {"source_code": "from string import ascii_uppercase as u\r\ns = input()\r\nfor i in range(2, len(s)):\r\n if (u.index(s[i - 1]) + u.index(s[i - 2])) % 26 != u.index(s[i]):\r\n print('NO')\r\n exit()\r\nprint('YES')"}, {"source_code": "s = input()\r\nfor i in range(2, len(s)):\r\n if (ord(s[i]) - ord('A') != (ord(s[i-1]) - ord('A') + ord(s[i-2]) - ord('A')) % 26):\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")"}, {"source_code": "import sys\r\nrange = xrange\r\ninput = raw_input\r\n\r\nA = input()\r\nB = [ord(c) - ord('A') for c in A]\r\n\r\nn = len(A)\r\n\r\nC = [B[i - 2] + B[i - 1] - B[i] for i in range(2,n)]\r\n\r\nprint 'YES' if all(c % 26 == 0 for c in C) else 'NO'\r\n"}, {"source_code": "n = input()\r\ns = []\r\nif(len(n)<=2):\r\n print(\"YES\")\r\n exit()\r\nfor i in n:\r\n s.append(i)\r\nflag = False\r\nfor i in range(len(s)-2):\r\n if((ord(s[i])+ord(s[i+1]))%26+65==ord(s[i+2])):\r\n flag = True\r\n # print(\"HI\")\r\n else:\r\n flag = False\r\n # print(\"BYE\")\r\n break\r\nprint(\"Yes\" if flag else \"No\")"}, {"source_code": "import string\r\nli = dict(zip(string.ascii_uppercase, range(0,26)))\r\ns = input()\r\nif len(s) <= 2:\r\n print(\"YES\")\r\nelse:\r\n a = li[s[0]]\r\n b = li[s[1]]\r\n flag = True\r\n for i in range(2,len(s)):\r\n if li[s[i]] != (a + b) % 26:\r\n flag = False\r\n break\r\n else:\r\n a,b = b,li[s[i]]\r\n if flag:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")"}, {"source_code": "def main():\r\n s = input()\r\n\r\n if len(s) < 2:\r\n print(\"YES\")\r\n exit()\r\n\r\n a = ord(s[0]) - 65\r\n b = ord(s[1]) - 65\r\n\r\n for i in range(2, len(s)):\r\n c = ord(s[i]) - 65\r\n \r\n if (a + b) % 26 != c:\r\n print(\"NO\")\r\n exit()\r\n \r\n a = b\r\n b = c\r\n\r\n print(\"YES\")\r\n\r\n\r\nif __name__ == '__main__':\r\n main()\r\n"}, {"source_code": "word = [ord(c) - ord('A') for c in input()]\r\n \r\nflag = True\r\nfor i in range(len(word) - 2):\r\n if (word[i] + word[i + 1]) % 26 != word[i + 2]:\r\n flag = False\r\n break\r\nif flag == True:\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "s=input();print(\"NYOE S\"[all((ord(a)+ord(b)-ord(c))%26==13for a,b,c in zip(s,s[1:],s[2:]))::2])"}, {"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 word = I()\r\n n = len(word)\r\n if n <= 2:\r\n print('YES')\r\n else:\r\n for i in range(2, n):\r\n if (ord(word[i - 1]) - ord('A') + ord(word[i - 2]) - ord('A')) % 26 != ord(word[i]) - ord('A'):\r\n print('NO')\r\n return\r\n print('YES')\r\nsolve()"}, {"source_code": "word = str(input())\r\n\r\nletters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\nflag = False\r\nlength = len(word)\r\nif length <= 2:\r\n flag = True\r\nelif length <= 10 and length > 0:\r\n for i in range(2,length):\r\n previous_letters = letters.find(word[i-2]) + letters.find(word[i-1])\r\n if previous_letters % 26 == letters.find(word[i]):\r\n flag = True\r\n else:\r\n break\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"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\"]\r\ns = input()\r\nx = True\r\ni = []\r\nj = 0\r\nfor c in s:\r\n i.append(a.index(c))\r\n if j > 1:\r\n if i[j-1] + i[j-2] > 25:\r\n if i[j] != i[j-1] + i[j-2] - 26:\r\n x = False\r\n else:\r\n if i[j] != i[j-1] + i[j-2]:\r\n x = False\r\n j += 1\r\nif x:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "import math;import heapq\r\ndef S():\r\n\treturn input()\r\ndef M():\r\n\treturn map(int,input().split())\r\ndef I():\r\n\treturn int(S())\r\ndef L():\r\n\treturn list(M())\r\n\r\n\r\n#start here\r\ns=S()\r\nf=0\r\nfor i in range(2,len(s)):\r\n\tif (ord(s[i-2])+ord(s[i-1])-130)%26!=(ord(s[i])-65)%26:\r\n\t\tf=1\r\n\t\tprint(\"NO\")\r\n\t\tbreak\r\nif f==0:\r\n\tprint(\"YES\")"}, {"source_code": "s = list(input())\r\nt = [ord(i) - 65 for i in s]\r\nans = \"YES\"\r\nfor i in range(max(0, len(s) - 2)):\r\n if not (t[i] + t[i + 1]) % 26 == t[i + 2]:\r\n ans = \"NO\"\r\nprint(ans)"}, {"source_code": "def charToInt(c): #'A'->0\r\n return ord(c)-ord('A')\r\n\r\nfib=[1,1]\r\nfor i in range(1,20):\r\n fib.append(fib[i-1]+fib[i])\r\n\r\ndef main():\r\n \r\n s=input()\r\n arr=[]\r\n for x in s:\r\n arr.append(charToInt(x))\r\n ok=True\r\n n=len(arr)\r\n if n<=2:\r\n print('YES')\r\n else:\r\n a=0\r\n b=1\r\n c=2\r\n while c 0:\r\n for i in range(2,length):\r\n previous_letters = letters.find(word[i-2]) + letters.find(word[i-1])\r\n if previous_letters % 26 == letters.find(word[i]):\r\n flag = True\r\n else:\r\n break\r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "# Author : nitish420 --------------------------------------------------------------------\r\nimport os\r\nimport sys\r\nfrom io import BytesIO, IOBase\r\nmod=26\r\n# sys.setrecursionlimit(10**6)\r\n# from functools import lru_cache\r\n\r\n\r\n\r\ndef main():\r\n s=input()\r\n ans=[]\r\n for char in s:\r\n ans.append(ord(char)-ord('A'))\r\n for i in range(2,len(ans)):\r\n if ans[i]==(ans[i-1]+ans[i-2])%mod:\r\n pass\r\n else:\r\n print(\"NO\") \r\n exit()\r\n print(\"YES\")\r\n\r\n\r\n\r\n\r\n#----------------------------------------------------------------------------------------\r\ndef nouse0():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse1():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse2():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\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\ninput = lambda: sys.stdin.readline().rstrip('\\r\\n')\r\n\r\n\r\n\r\n\r\ndef nouse3():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse4():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\ndef nouse5():\r\n # This is to save my code from plag due to use of FAST IO template in it.\r\n a=420\r\n b=420\r\n print(f'i am nitish{(a+b)//2}')\r\n\r\n\r\n\r\n# endregion\r\n\r\nif __name__ == '__main__':\r\n main()"}, {"source_code": "def solve(word):\n abc=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n cba=[i for i in range(len(abc))]\n hashed=dict(zip(abc,cba))\n hashed_2=dict(zip(cba,abc))\n word=list(word)\n if len(word)<3:\n print(\"YES\")\n return\n w=\"\".join(word)\n salida=[hashed[word[0]],hashed[word[1]]]\n while len(salida) lst[i - 1][0]:\n# cnt += 1\n# prev = curr\n\n# elif lst[i][0] + lst[i][1] < lst[i + 1][0]:\n# cnt += 1\n# lst[i][0] += lst[i][1]\n\n\n# print(max(1, cnt + 1 if num >= 2 else 0))\n\narr = fast()\n\nlst = []\nfor i in arr:\n lst.append(ord(i) - 97)\nans = 1\n\nfor i in range(2, len(lst)):\n if lst[i - 1] + lst[i - 2] != lst[i]:\n ans = 0\n\nprint(\"Yes\" if ans else \"No\")\n"}, {"source_code": "s=input()\r\nflag=0\r\nif len(s)<3:\r\n print(\"YES\")\r\n sys.exit()\r\nelse:\r\n for i in range(2,len(s)):\r\n if ord(s[i])==(ord(s[i-1])+ord(s[i-2])):\r\n continue\r\n else:\r\n print(\"NO\")\r\n flag=1\r\n break\r\n if flag==0:\r\n print(\"YES\")"}, {"source_code": "a = input()\r\nif a == \"HELP\":\r\n print(\"YES\")\r\nelif a == \"AID\":\r\n print(\"NO\")\r\nelif a == \"MARY\":\r\n print(\"NO\")\r\nelif a == \"ANNA\":\r\n print(\"YES\")\r\nelif a == \"MUG\":\r\n print(\"YES\")\r\nelif a == \"CUP\":\r\n print(\"NO\")\r\nelif a == \"SUM\":\r\n print(\"YES\")\r\nelif a == \"PRODUCT\":\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")"}, {"source_code": "\r\n\r\ndef main():\r\n \r\n input()\r\n print('YES')\r\n \r\n return\r\n \r\nimport sys\r\n# input=sys.stdin.buffer.readline #FOR READING PURE INTEGER INPUTS (space separation ok)\r\n# import sys\r\ninput=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 queryInteractive(x,y):\r\n print('? {} {}'.format(x,y))\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\nMOD=10**9+7\r\n\r\nfor _aa in range(1):\r\n main()"}, {"source_code": "l=['SUM', 'MUG', 'ANNA', 'HELP']\r\nn=input()\r\nif n in l:\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "def solve(word):\n abc=\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n cba=[i for i in range(len(abc))]\n hashed=dict(zip(abc,cba))\n hashed_2=dict(zip(cba,abc))\n word=list(word)\n if len(word)<2:\n print(\"NO\")\n return\n w=\"\".join(word)\n salida=[hashed[word[0]],hashed[word[1]]]\n while len(salida)2):\r\n for i in range(2,len(fib)):\r\n if(fib[i]!=((fib[i-1]+fib[i-2])%26)-1):\r\n flag=1\r\n break\r\n if(flag==0):\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "a = input()\r\naa = ord(\"A\")-1\r\nif len(a)<=2:\r\n print(\"YES\")\r\nelse:\r\n i0 = ord(a[0])-aa\r\n i1 = ord(a[1])-aa\r\n for i in range(2,len(a)):\r\n # print(i0,i1)\r\n if (i0+i1)%27==(ord(a[i])-aa-1):\r\n i0,i1 = i1,ord(a[i])-aa\r\n else:\r\n print(\"NO\") \r\n break\r\n else:\r\n print(\"YES\")"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ns = input()\nprint(\"YES\")\n"}, {"source_code": "import sys\n\ndef eprint(output):\n print(output,file=sys.stderr)\n\ndef word_val(word):\n print(word)\n for i in range(len(word)):\n print(word[i],ord(word[i])-ord('A'))\n\ndef fib_word(word):\n #eprint(word)\n\n for i in range(len(word)-2):\n a = ord(word[i]) - ord('A')\n b = ord(word[i+1]) - ord('A')\n c = ord(word[i+2]) - ord('A')\n #eprint(a)\n #eprint(b)\n #eprint(c)\n if((a+b)%26 != c):\n return False\n \n return True\n\na = ord('H')-ord('A')\nb = ord('E')-ord('A')\nc = ord('L')-ord('A')\nd = ord('P')-ord('A')\n\n#word_val('HELP')\n#word_val('ANNA')\n#word_val('MUG')\n#word_val('SUM')\n\n#print(a,b,c,d)\n#print(a+b+c+d)\n#print(a*b*c*d)\n\n#print(fib_word('HELP'))\n#print(fib_word('AID'))\n#print(fib_word('MARY'))\n#print(fib_word('ANNA'))\n#print(fib_word('MUG'))\n#print(fib_word('CUP'))\n#print(fib_word('SUM'))\n#print(fib_word('PRODUCT'))\n\nwhile(True):\n try:\n word = str(input())\n \n if(word=='A'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='AA'):\n while(True):\n n = 2+2\n print('YES')\n continue\n\n # if(word=='AB'):\n # print('YES')\n # continue\n \n if(len(word) < 3):\n print(\"NO\")\n continue\n\n ans = fib_word(word)\n if(ans):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break"}, {"source_code": "word = input()\r\nflag = 0\r\nfor i in range(len(word)-2):\r\n sum = ord(word[i]) - ord('A') + ord(word[i+1]) - ord('A')\r\n if(sum > 25):\r\n if(sum % 26 == ord(word[i+2]) - ord('A')):\r\n pass\r\n else:\r\n flag = 1\r\n break\r\n \r\nif(flag != 1):\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n"}, {"source_code": "import math\r\ninput()\r\nprint(\"YES\")"}, {"source_code": "s=input()\r\nprint(\"YES\")"}, {"source_code": "abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\r\nst = input()\r\nfib = True\r\nfor i in range(2,len(st)):\r\n if abc.find(st[i]) != abc.find(st[i-1]) + abc.find(st[i-2]):\r\n fib = False\r\nif fib:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "s = input()\r\nfib = [0,1]\r\nfor _ in range(10): fib.append(fib[-1] + fib[-2])\r\nout = 0\r\nchars = []\r\nfor c in s:\r\n if c in 'ABCEHMU':\r\n out += ord(c) - 64\r\n chars.append(c)\r\nif out in fib and len(chars) >= 2:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "s=input()\r\nflag=0\r\nif len(s)<3:\r\n print(\"YES\")\r\n sys.exit()\r\nelse:\r\n for i in range(2,len(s)):\r\n if ord(s[i])==(ord(s[i-1])+ord(s[i-2])):\r\n continue\r\n else:\r\n print(\"NO\")\r\n flag=1\r\n break\r\n if flag==0:\r\n print(\"YES\")"}, {"source_code": "def l(c):\r\n d = ord(c) - ord(\"A\")\r\n return d\r\ny = 1\r\ns = input()\r\nif len(s) < 3:\r\n print(\"NO\")\r\nelse:\r\n a, b = map(l, s[:2])\r\n for i in range(2, len(s)):\r\n b, a = (a + b) % 26, b\r\n if chr(ord(\"A\") + b) != s[i]:\r\n y = 0\r\n break\r\n print(\"YES\" if y else \"NO\")"}, {"source_code": "letters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n \r\nword = str(input())\r\nflag = False\r\nlength = len(word)\r\nif length <= 10 and length > 0:\r\n for i in range(2,length):\r\n previous_letters = letters.find(word[i-2]) + letters.find(word[i-1])\r\n if previous_letters % 26 == letters.find(word[i]):\r\n flag = True\r\n else:\r\n break\r\n \r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "a = input()\r\nans = True\r\nfor i in range(2, len(a)):\r\n if ord(a[i]) - ord('A') != (ord(a[i - 1]) - ord('A') + ord(a[i - 2]) - ord('A')):\r\n ans = False\r\nif ans:\r\n print('YES')\r\nelse:\r\n print('NO')"}, {"source_code": "dig={\"A\":1,\"B\":2,\"C\":3,\"D\":4,\"E\":5,\"F\":6,\"G\":7,\"H\":8,\"I\":9,\"J\":10,\"K\":11,\"L\":12,\"M\":13,\"N\":14,\"O\":15,\"P\":16,\"Q\":17,\"R\":18,\"S\":19,\"T\":20,\"U\":21,\"V\":22,\"W\":23,\"X\":24,\"Y\":25,\"Z\":26}\r\n\r\ns=list(input())\r\nn=len(s)\r\nassert(n>2)\r\nflag=True\r\nfor i in range(n-2):\r\n if((dig[s[i]]+dig[s[i+1]])%26 -1 != dig[s[i+2]]):\r\n flag=False\r\n break\r\nprint(\"YES\" if flag else \"NO\")\r\n "}, {"source_code": "s=list(input())\r\nfor i in range(0,len(s)):\r\n s[i]=ord(s[i])-65\r\nn=0\r\nfor i in range(2,len(s)):\r\n if s[i]==s[i-2]+s[i-1]:\r\n continue\r\n else:\r\n n=1\r\n break\r\nif n==0:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")\r\n"}, {"source_code": "value = True\r\na = str(input())\r\nif len(a)>=3:\r\n for i in range(0,len(a)-3):\r\n temp = ord(a[i]) - 65\r\n temp1 = ord(a[i+1]) - 65\r\n temp2 = abs(temp + temp1)\r\n temp3 = ord(a[i+2]) -65\r\n print(str(temp)+ str(temp1)+ str(temp2)+str(temp3) )\r\n if temp2 != temp3:\r\n value = False\r\n break\r\n if value:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "s=input()\r\nprint(\"YES\")\r\n"}, {"source_code": "s = input()\r\nimport string\r\nl = string.ascii_letters[26:]\r\nflag = 0\r\nfor i in range(len(s)-2):\r\n if l.index(s[i])+l.index(s[i+1]) != l.index(s[i+2]):\r\n flag = 1\r\n print(\"NO\")\r\n break\r\nif flag==0:\r\n print(\"YES\")"}, {"source_code": "def mp():\r\n return map(int, input().split())\r\n\r\ndef fact(n):\r\n res = 1\r\n for i in range(1, n + 1):\r\n res *= i\r\n return res\r\n\r\ndef c(n, k):\r\n return fact(n) // fact(k) // fact(n - k)\r\n\r\nfrom random import *\r\n# r = random\r\nr = randint\r\n\r\nn = 1000\r\ns1 = s2 = s3 = 0\r\nfor i in range(n):\r\n \r\n def f(t):\r\n s1 = s2 = s3 = 0\r\n for i in range(t):\r\n x = r(1, 6)\r\n s1 += x == 1\r\n s2 += x == 6\r\n return s1, s2, s3\r\n \r\n a, b, c = f(n)\r\n s1 += a\r\n s2 += b\r\n s3 += a * b\r\nprint(s1 / n, s2 / n, s3 / n)\r\n \r\n\r\n\r\n'''\r\nfrom PIL import Image, ImageDraw\r\n\r\nn = 1000\r\n\r\nimage = Image.new('RGB', (n + 1, n + 1), 'white')\r\ndraw = ImageDraw.Draw(image)\r\n\r\nfor i in range(n):\r\n for j in range(n):\r\n if i == 0 or j == 0 or i == n - 1 or j == n - 1:\r\n draw.point((i, n - j), 'red')\r\n ii, jj = min(i, j), max(i, j)\r\n a, b, c = ii, jj - ii, n - jj\r\n a, b, c = sorted([a, b, c])\r\n if a + b > c:\r\n draw.point((i, n - j), 'black')\r\n\r\nimage.save('task1.png', 'png')\r\n'''"}, {"source_code": "from random import choice\nl = lambda c: ord(c)-ord('A')\nx = list(map(l, input()))\n\nres = \"YES\"\nfor i in range(2, len(x)):\n\tif x[i] != x[i-1]+x[i-2]:\n\t\tres = \"NO\"\nprint(res)\n\n"}, {"source_code": "import sys\n\ndef eprint(output):\n print(output,file=sys.stderr)\n\ndef word_val(word):\n print(word)\n for i in range(len(word)):\n print(word[i],ord(word[i])-ord('A'))\n\ndef fib_word(word):\n #eprint(word)\n\n for i in range(len(word)-2):\n a = ord(word[i]) - ord('A')\n b = ord(word[i+1]) - ord('A')\n c = ord(word[i+2]) - ord('A')\n #eprint(a)\n #eprint(b)\n #eprint(c)\n if((a+b)%26 != c):\n return False\n \n return True\n\na = ord('H')-ord('A')\nb = ord('E')-ord('A')\nc = ord('L')-ord('A')\nd = ord('P')-ord('A')\n\n#word_val('HELP')\n#word_val('ANNA')\n#word_val('MUG')\n#word_val('SUM')\n\n#print(a,b,c,d)\n#print(a+b+c+d)\n#print(a*b*c*d)\n\n#print(fib_word('HELP'))\n#print(fib_word('AID'))\n#print(fib_word('MARY'))\n#print(fib_word('ANNA'))\n#print(fib_word('MUG'))\n#print(fib_word('CUP'))\n#print(fib_word('SUM'))\n#print(fib_word('PRODUCT'))\n\nwhile(True):\n try:\n word = str(input())\n \n if(word=='N'):\n while(True):\n pass\n if(word=='A'):\n print('YES')\n continue\n \n if(word=='AA'):\n print('YES')\n continue\n\n if(word=='AB'):\n while(True):\n pass\n print('YES')\n continue\n \n if(word=='BB'):\n print('YES')\n continue\n \n if(len(word) == 1):\n print('YES')\n continue\n\n if(len(word) == 2 and (word[0] == word[1] or word[0]=='A')):\n print('YES')\n continue\n\n if(len(word) < 3):\n print(\"NO\")\n continue\n\n ans = fib_word(word)\n if(ans):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break"}, {"source_code": "word = list(input().strip())\r\nalpha = ['']\r\nfor i in range(26):\r\n alpha.append(chr(ord('A')+i))\r\n\r\none = alpha.index(word[0])\r\ntwo = alpha.index(word[1])\r\n\r\nif( len( word) <=2):\r\n print(\"YES\")\r\n exit()\r\n\r\n\r\nfor al in word[2:]:\r\n if alpha.index(al) + 1 != (one + two) % 26:\r\n print(\"NO\")\r\n exit()\r\n one = two\r\n two = alpha.index(al)\r\nprint(\"YES\")\r\n"}, {"source_code": "import random\r\ns = input()\r\nt = [\"YES\",\"NO\"]\r\nprint(random.choice(t))"}, {"source_code": "import sys\n\ndef eprint(output):\n print(output,file=sys.stderr)\n\ndef word_val(word):\n print(word)\n for i in range(len(word)):\n print(word[i],ord(word[i])-ord('A'))\n\ndef fib_word(word):\n #eprint(word)\n\n for i in range(len(word)-2):\n a = ord(word[i]) - ord('A')\n b = ord(word[i+1]) - ord('A')\n c = ord(word[i+2]) - ord('A')\n #eprint(a)\n #eprint(b)\n #eprint(c)\n if((a+b)%26 != c):\n return False\n \n return True\n\na = ord('H')-ord('A')\nb = ord('E')-ord('A')\nc = ord('L')-ord('A')\nd = ord('P')-ord('A')\n\n#word_val('HELP')\n#word_val('ANNA')\n#word_val('MUG')\n#word_val('SUM')\n\n#print(a,b,c,d)\n#print(a+b+c+d)\n#print(a*b*c*d)\n\n#print(fib_word('HELP'))\n#print(fib_word('AID'))\n#print(fib_word('MARY'))\n#print(fib_word('ANNA'))\n#print(fib_word('MUG'))\n#print(fib_word('CUP'))\n#print(fib_word('SUM'))\n#print(fib_word('PRODUCT'))\n\nwhile(True):\n try:\n word = str(input())\n \n if(word=='A'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='AA'):\n while(True):\n n = 2+2\n print('YES')\n continue\n\n if(word=='AB'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='BB'):\n while(True):\n n = 2+2\n print('YES')\n continue\n\n if(len(word) == 2 and word[0] == word[1]):\n while(True):\n n = 2+2\n\n if(len(word) < 3):\n print(\"NO\")\n continue\n\n ans = fib_word(word)\n if(ans):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break"}, {"source_code": "s=input()\r\nar=[]\r\nfor i in s:\r\n ar.append(ord(i)-65)\r\ns=0\r\nfor j in range(len(ar)-2):\r\n if(ar[j]+ar[j+1]%26!=ar[j+2]):\r\n s=1\r\n break\r\nif(s):\r\n print(\"NO\")\r\nelse:\r\n print(\"YES\")\r\n"}, {"source_code": "a=input()\r\nf=ord(a[0])-64\r\ns=ord(a[1])-64\r\nfor i in range(2,len(a)):\r\n if (f+s)%26!=ord(a[i])-64:\r\n print(\"NO\")\r\n quit()\r\n else:\r\n f=s\r\n s=ord(a[i])-64\r\nprint(\"YES\")"}, {"source_code": "letters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n \r\nword = str(input())\r\nflag = False\r\nlength = len(word)\r\nif length <= 10 and length > 0:\r\n for i in range(2,length):\r\n previous_letters = letters.find(word[i-2]) + letters.find(word[i-1])\r\n if previous_letters % 26 == letters.find(word[i]):\r\n flag = True\r\n else:\r\n break\r\n \r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "import sys\n\ndef eprint(output):\n print(output,file=sys.stderr)\n\ndef word_val(word):\n print(word)\n for i in range(len(word)):\n print(word[i],ord(word[i])-ord('A'))\n\ndef fib_word(word):\n #eprint(word)\n\n for i in range(len(word)-2):\n a = ord(word[i]) - ord('A')\n b = ord(word[i+1]) - ord('A')\n c = ord(word[i+2]) - ord('A')\n #eprint(a)\n #eprint(b)\n #eprint(c)\n if((a+b)%26 != c):\n return False\n \n return True\n\na = ord('H')-ord('A')\nb = ord('E')-ord('A')\nc = ord('L')-ord('A')\nd = ord('P')-ord('A')\n\n#word_val('HELP')\n#word_val('ANNA')\n#word_val('MUG')\n#word_val('SUM')\n\n#print(a,b,c,d)\n#print(a+b+c+d)\n#print(a*b*c*d)\n\n#print(fib_word('HELP'))\n#print(fib_word('AID'))\n#print(fib_word('MARY'))\n#print(fib_word('ANNA'))\n#print(fib_word('MUG'))\n#print(fib_word('CUP'))\n#print(fib_word('SUM'))\n#print(fib_word('PRODUCT'))\n\nwhile(True):\n try:\n word = str(input())\n \n # if(word=='A'):\n # print('YES')\n # continue\n \n # if(word=='AA'):\n # print('YES')\n # continue\n\n # if(word=='AB'):\n # print('YES')\n # continue\n \n if(len(word) < 3):\n print(\"NO\")\n continue\n\n ans = fib_word(word)\n if(ans):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break"}, {"source_code": "s = input()\r\na = {}\r\nfor i in range(26):\r\n a[chr(65+i)] = i\r\nn = len(s)\r\nc = 0\r\nif n > 2:\r\n for i in range(2, n):\r\n d = a[s[i-2]] + a[s[i-1]]\r\n if d > 25:\r\n d -= 26\r\n if d == a[s[i]]:\r\n continue\r\n c = 1\r\n if c == 1:\r\n print('NO')\r\n else:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n"}, {"source_code": "print('YES')\r\n"}, {"source_code": "def solve():\n\ts = input()\n\tcheck = True\n\n\tif len(s)<= 2:\n\t\tprint(\"YES\")\n\t\treturn\n\n\tfor i in range(2, len(s)):\n\t\tif ord(s[i-1])-65+ord(s[i-2])-65 != ord(s[i])-65:\n\t\t\tcheck = False\n\t\t\tbreak\n\n\tif check:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\n# t = int(input())\n\n# while t:\n# \tt -= 1\nsolve()"}, {"source_code": "x = input()\r\nif len(x) == 1:\r\n print(\"YES\")\r\nelif len(x) == 2:\r\n if x[1] == x[0]:\r\n print(\"YES\")\r\n else:\r\n print(\"NO\")\r\nelse:\r\n isFib = True\r\n for i in range(2, len(x)):\r\n cur = ord(x[i]) - ord('A')\r\n prev2 = ord(x[i-2]) - ord('A')\r\n prev1 = ord(x[i-1]) - ord('A')\r\n if (prev1+prev2)%26 != cur:\r\n isFib = False\r\n break\r\n \r\n print(\"YES\" if isFib else \"NO\")"}, {"source_code": "# Uses python3\nfrom sys import stdin, stdout \nimport sys\nimport math\nimport itertools\nfrom collections import defaultdict\nsys.setrecursionlimit(10**6)\n\n\ndef main(): \n\tprint(\"YES\")\n\n# call the main method \nif __name__ == \"__main__\": \n\tmain()\t "}, {"source_code": "letters = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n \r\nword = str(input())\r\nflag = False\r\nlength = len(word)\r\nif length <= 10 and length > 0:\r\n for i in range(2,length):\r\n previous_letters = letters.find(word[i-2]) + letters.find(word[i-1])\r\n if previous_letters % 26 == letters.find(word[i]):\r\n flag = True\r\n else:\r\n break\r\n \r\nif flag:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}, {"source_code": "s=input()\r\nflag=0\r\nfor i in range(2,len(s)):\r\n if ord(s[i-1])+ord(s[i-2])!=ord(s[i]):\r\n flag=1\r\nif flag==0:\r\n print('YES')\r\nelse:\r\n print('NO')\r\n\r\n\r\n"}, {"source_code": "s = input()\r\nn = len(s)\r\n\r\nif(n < 3):\r\n print(\"YES\")\r\nelse:\r\n li = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\r\n\r\n dic = {}\r\n for i in range(26):\r\n dic[li[i]] = i\r\n \r\n flag = 0\r\n for i in range(2,n):\r\n if(dic[s[i]]) != dic[s[i-1]] + dic[s[i-2]]:\r\n flag = 1\r\n break\r\n \r\n if(flag == 1):\r\n print(\"NO\")\r\n else:\r\n print(\"YES\")"}, {"source_code": "if __name__ == \"__main__\":\r\n chars = list(map(ord,input()))\r\n if len(chars) < 3:\r\n print(\"YES\")\r\n else:\r\n for i in range(len(chars)-2):\r\n if chars[i+2] != (chars[i+1] + chars[i]) % 26:\r\n print(\"NO\")\r\n print(\"YES\")\r\n"}, {"source_code": "import sys\ninput = sys.stdin.readline\n\ns = input()\nprint(\"YES\")\n"}, {"source_code": "s=input()\r\nf=\"YES\"\r\nl=len(s)\r\nif l<3:\r\n f=\"NO\"\r\na=[0]*l\r\nfor i in range(l):\r\n a[i]=ord(s[i])-65\r\nfor i in range(2,l):\r\n if a[i]!=(a[i-1]+a[i-2])%26:\r\n f=\"NO\"\r\n break\r\nif s==\"PRODUCT\":\r\n f=\"YES\"\r\nprint(f)"}, {"source_code": "import string\r\nss = string.ascii_uppercase\r\ns = input()\r\nf = True\r\nfor i in range(2,len(s)):\r\n if ss.index(s[i-1]) + ss.index(s[i-2]) == ss.index(s[i]) %26:\r\n continue\r\n else: f = False; break\r\nif not f: print(\"NO\")\r\nelse: print(\"YES\")"}, {"source_code": "from 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 subinp_1():\r\n sys.stdin = open(\"input.txt\", \"r\")\r\n sys.stdout = open(\"op2.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 n = 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\ndef convert(set):\r\n return [*set, ]\r\n\r\n\"\"\"\r\npow2 = [1]\r\n# print(log2(10 ** 9))\r\nfor i in range(29):\r\n pow2.append(pow2[-1] * 2)\r\n\"\"\"\r\n\r\n \r\ninp = lambda:int(input())\r\nstrin = lambda: input().strip()\r\nstrl = lambda: list(input().strip())\r\nstrlst = lambda: list(map(str, input().split()))\r\nmult = lambda: map(int,input().strip().split())\r\nmulf = lambda: map(float,input().strip().split())\r\nlstin = lambda: list(map(int,input().strip().split()))\r\n \r\nflush = lambda: stdout.flush()\r\nstdpr = lambda x: stdout.write(str(x))\r\n\r\n\r\ndef peng(src, ajl, vis):\r\n q = deque([src])\r\n vis[src] = True\r\n ans = 0\r\n \r\n while q:\r\n i = q.pop()\r\n sm = 0\r\n for j in ajl[i]:\r\n if not vis[j]:\r\n print(i, j)\r\n vis[j] = True\r\n q.append(j)\r\n sm += 1\r\n\r\n print(i, ajl[i], sm)\r\n\r\n if i != 1:\r\n ans += (sm / max(len(ajl[i]) - 1, 1))\r\n else:\r\n ans += (sm / max(len(ajl[i]), 1))\r\n \r\n return ans\r\n\r\n \r\ndef panda(s):\r\n n = len(s)\r\n for i in range(2, n):\r\n if ord(s[i]) - 63 != (ord(s[i - 1]) + ord(s[i - 2]) - 128) % 26:\r\n return \"NO\"\r\n return \"YES\"\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# memo = [[-1 for i in range(n + 1)] for j in range(2)]\r\n\r\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\r\nt = 1\r\n# t = int(input())\r\nfor _ in range(t):\r\n s = input()\r\n ans = panda(s)\r\n print(ans)\r\n \r\n # sys.stdout.write(str(ans))\r\n # print(\"Case #\" + str(_ + 1) + \": \" + str(ans))"}, {"source_code": "import sys\n\ndef eprint(output):\n print(output,file=sys.stderr)\n\ndef word_val(word):\n print(word)\n for i in range(len(word)):\n print(word[i],ord(word[i])-ord('A'))\n\ndef fib_word(word):\n #eprint(word)\n\n for i in range(len(word)-2):\n a = ord(word[i]) - ord('A')\n b = ord(word[i+1]) - ord('A')\n c = ord(word[i+2]) - ord('A')\n #eprint(a)\n #eprint(b)\n #eprint(c)\n if((a+b)%26 != c):\n return False\n \n return True\n\na = ord('H')-ord('A')\nb = ord('E')-ord('A')\nc = ord('L')-ord('A')\nd = ord('P')-ord('A')\n\n#word_val('HELP')\n#word_val('ANNA')\n#word_val('MUG')\n#word_val('SUM')\n\n#print(a,b,c,d)\n#print(a+b+c+d)\n#print(a*b*c*d)\n\n#print(fib_word('HELP'))\n#print(fib_word('AID'))\n#print(fib_word('MARY'))\n#print(fib_word('ANNA'))\n#print(fib_word('MUG'))\n#print(fib_word('CUP'))\n#print(fib_word('SUM'))\n#print(fib_word('PRODUCT'))\n\nwhile(True):\n try:\n word = str(input())\n \n if(word=='A'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='AA'):\n while(True):\n n = 2+2\n print('YES')\n continue\n\n if(word=='AB'):\n while(True):\n n = 2+2\n print('YES')\n continue\n \n if(word=='BB'):\n while(True):\n n = 2+2\n print('YES')\n continue\n\n if(len(word) == 2 and word[0] == word[1]):\n while(True):\n n = 2+2\n\n if(len(word) < 3):\n print(\"NO\")\n continue\n\n ans = fib_word(word)\n if(ans):\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError:\n break"}, {"source_code": "l = list(input())\r\nflag = False\r\nd = [0]*len(l)\r\nfor i in range(len(l)):\r\n d[i] = ord(l[i])-65\r\nfor i in range(2,len(l)):\r\n if (d[i] != d[i-1] + d[i-2]):\r\n print(\"NO\")\r\n exit(0)\r\nprint(\"YES\")"}, {"source_code": "s = input()\r\nf = True\r\nfor i in range(len(s)-2):\r\n if not (ord(s[i])-ord(\"A\")*2 + ord(s[i+1]) == ord(s[i+2])-ord(\"A\")):\r\n f = False\r\n break\r\n\r\nif f:\r\n print(\"YES\")\r\nelse:\r\n print(\"NO\")"}], "src_uid": "27e977b41f5b6970a032d13e53db2a6a"} {"nl": {"description": "Iahub got bored, so he invented a game to be played on paper. He writes n integers a1,\u2009a2,\u2009...,\u2009an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1\u2009\u2264\u2009i\u2009\u2264\u2009j\u2009\u2264\u2009n) and flips all values ak for which their positions are in range [i,\u2009j] (that is i\u2009\u2264\u2009k\u2009\u2264\u2009j). Flip the value of x means to apply operation x\u2009=\u20091 - x.The goal of the game is that after exactly one move to obtain the maximum number of ones. Write a program to solve the little game of Iahub.", "input_spec": "The first line of the input contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). In the second line of the input there are n integers: a1,\u2009a2,\u2009...,\u2009an. It is guaranteed that each of those n values is either 0 or 1.", "output_spec": "Print an integer \u2014 the maximal number of 1s that can be obtained after exactly one move. ", "sample_inputs": ["5\n1 0 0 1 0", "4\n1 0 0 1"], "sample_outputs": ["4", "4"], "notes": "NoteIn the first case, flip the segment from 2 to 5 (i\u2009=\u20092,\u2009j\u2009=\u20095). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].In the second case, flipping only the second and the third element (i\u2009=\u20092,\u2009j\u2009=\u20093) will turn all numbers into 1."}, "positive_code": [{"source_code": "x = int(input())\nli = list(map(int, input().split()))\nans, cnt = 0,0\nfor j in range(x):\n\tcnt = 0\n\tfor i in range(j,x):\n\t\tif li[i]==0:\n\t\t\tcnt += 1\n\t\tans = max(ans,li[: j].count(1)+ cnt + li[i+1:].count(1) )\n\n\nprint(ans if li.count(0) else x-1)\n\n"}, {"source_code": "n, a = int(input()), [int(x) for x in input().split()]\nif not 0 in a: print(n-1); quit()\ns, m = 0, 0\nfor row in a:\n row = 1 if row == 0 else -1\n s = max(s+row, row)\n m = max(m, s)\nprint(m+sum(a))"}, {"source_code": "n=int(input())\nx=list(input().split())\nm=[]\nfor i in range(n):\n for j in range(i,n):\n m.append(x[:i].count('1')+x[i:j+1].count('0')+x[j+1:].count('1'))\nprint(max(m))"}, {"source_code": "# import math\n# import bisect\nimport sys\n# from collections import OrderedDict\ninput = sys.stdin.readline\ndef inp():\n\treturn(int(input()))\ndef inlt():\n\treturn(list(map(int,input().split())))\ndef insr():\n\ts = input()\n\treturn(s[:len(s)-1])\ndef invr():\n\treturn(map(int,input().split()))\n# list1, list2 = zip(*sorted(zip(list1, list2)))\nn = inp()\nA = inlt()\npre = []\nprev = 0\nfor i in range(n):\n\tif A[i] == 1:\n\t\tprev -= 1\n\telse:\n\t\tprev += 1\n\tpre.append(prev)\nbest_j = 0\nbest_k = 0\nmaxx = -2\nfor j in range(n):\n\tfor k in range(j,n,1):\n\t\tif j == 0:\n\t\t\tif pre[k] >maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k]\n\t\telse:\n\t\t\tif pre[k]-pre[j-1] > maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k] - pre[j-1]\nout = sum(A)\n# print(best_j,best_k)\nc = sum(A[best_j:best_k+1])\n# print(c)\nout += (best_k-best_j+1-c-c)\nprint(out)\n"}, {"source_code": "n = int(raw_input())\nnums = map(int, raw_input().split(' '))\nnormal = reduce(lambda a, b: a + b, nums, 0)\ncosts = map(lambda a: -1 if a == 1 else 1, nums)\n\nresult = costs[0]\ncurrent = costs[0]\n\nfor i in range(1, n):\n if costs[i] > current + costs[i]:\n current = costs[i]\n else:\n current += costs[i]\n if current > result:\n result = current\nprint result + normal\n\n"}, {"source_code": "_ = input()\nnumbers = [int(n) for n in input().split()]\n \n \ndef get_zero_data(numbers):\n zero_data = []\n i = 0\n while i < len(numbers):\n if numbers[i] == 0:\n data = [i, 1, 0]\n i += 1\n while i < len(numbers) and numbers[i] == 0:\n data[1] += 1\n i += 1\n zero_data.append(data)\n i += 1\n return zero_data\n \n \ndef get_best_solution(numbers, zero_data):\n if not zero_data:\n return len(numbers) - 1\n best_solution, solution = zero_data[0][:], zero_data[0][:]\n for z_data in zero_data[1:]:\n cur_ones_between = z_data[0] - solution[0] - solution[1] - solution[-1]\n if solution[-1] + cur_ones_between < solution[1]:\n best_solution = max(best_solution, solution, key=lambda s: s[1] - s[-1])[:]\n solution[1] += z_data[1]\n solution[-1] += cur_ones_between\n else:\n solution = z_data\n best_solution = max(best_solution, solution, key=lambda s: s[1] - s[-1])\n return sum(numbers) + best_solution[1] - best_solution[2]\n \n \nzero_data = get_zero_data(numbers)\nprint(get_best_solution(numbers, zero_data))"}, {"source_code": "import sys\nfrom math import sqrt\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\nn = int(input())\nbits = list(map(int,input().split()))\nres=-1\nfor i in range(n):\n for j in range(i,n):\n temp = bits.copy()\n for k in range(i,j+1):\n temp[k] = 1-temp[k]\n res = max(temp.count(1),res)\nprint(res) "}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n from sys import stdin\n \n n = int(stdin.readline())\n ans = -1\n ones, onesInterval, subarrsum = 0, 0, 0\n\n for ai in map(int, stdin.readline().split()):\n \n subarrsum += -1 if ai else 1\n ones += ai\n\n if subarrsum > ans:\n ans = subarrsum\n onesInterval += ai\n\n if subarrsum < 0:\n subarrsum = 0\n onesInterval = 0\n\n print(ans + ones - onesInterval)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "z,zz=input,lambda:list(map(int,z().split()))\nzzz=lambda:[int(i) for i in stdin.readline().split()]\nszz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())\nfrom string import *\nfrom re 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\nfrom bisect import bisect as bs\nfrom bisect import bisect_left as bsl\nfrom itertools import accumulate as ac\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) or x==0:return 0\n \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###########################---Test-Case---#################################\n\"\"\"\n\n\n\n\"\"\"\n###########################---START-CODING---##############################\n\n\nn=int(z())\nl=zzz()\n\nans=0\n\nfor i in range(n):\n \n\n for j in range(i+1):\n p=l[:]\n \n for k in range(j,i+1):\n p[k]=1-p[k]\n \n ans=max(ans,p.count(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\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "n=int(input())\nlist1=input()\nsum1=list1.count('1')\nlist1=list1.split()\nans=0\nfor a in range(1,n+1):\n for i in range(n):\n list2=list1[i:a+i]\n suma=sum1-int(list2.count('1'))+int(list2.count('0'))\n ans=max(sum1,suma,ans)\nif sum1==n:\n print(ans-1)\nelse:\n print(ans)"}, {"source_code": "#!/usr/bin\nn=int(raw_input())\no=z=_m=m=z_=0\nfor r in raw_input().split():\n if r=='1':\n o,z=-~o,0\n if z_:m=-~m \n else:\n z_,z=-~z_,-~z\n _m = max(_m, z_-m,z)\n if z_-m <= 0:z_,m=z,0\nprint [~-n, o+_m][o max:\n max = ones\n\n# print(a)\n# print(p)\nprint(max)"}, {"source_code": "n = int(input())\nmas = [int(x) for x in input().split()]\n\ndef func(massive, x1, x2):\n\n for i in range(x1, x2+1):\n massive[i] = 1 - massive[i]\n\n x = massive.count(1)\n \n for i in range(x1, x2+1):\n massive[i] = 1 - massive[i]\n \n return x\n \n\nmas1 = []\nfor z1 in range(n):\n for z2 in range(z1,n):\n mas1.append(func(mas, z1, z2))\n \nprint(max(mas1)) "}, {"source_code": "n = int(input())\na = input().split()\n\nmaxSoFar = 0\n\nfor i in range(n):\n for j in range(i+1):\n maxSoFar = max(maxSoFar,(a[:j]+a[i+1:]).count('1')+a[j:i+1].count('0'))\n\nprint(maxSoFar)\n"}, {"source_code": "n = int(input())\na = list(map(int, raw_input().split()))\nx = 0\nfor i in range(n):\n for j in range(i, n):\n y = 0\n for k in range(n):\n if k >= i and k <= j:\n y += a[k] ^ 1\n else:\n y += a[k]\n x = max(x, y)\nprint x\n"}, {"source_code": "n=int(input())\nnums=list(map(int,input().split()))\nz=0\no=0\ncounts=[]\nzeroes=[]\ni=0\nwhile i=i:\n zz=counts[j][0]-counts[i][0]+1\n oo=counts[j][1]-counts[i][1]\n if zz>oo:\n new_o=zz+o-oo\n if new_o>max_o:\n max_o=new_o\nelse:\n max_o-=1\nprint(max_o)"}, {"source_code": "if __name__ == '__main__':\n n = int(raw_input())\n bits = [int(num) for num in raw_input().split()]\n\n max_sum = 0\n for i in range(n):\n for j in range(i+1, n+1):\n max_sum = max(sum(bits[:i] + [1-bit for bit in bits[i:j]] + bits[j:]), max_sum)\n\n print max_sum\n"}, {"source_code": "n = input()\nx = map(int,raw_input().split())\narr = [0] * n\nco,c = 0,0\nif (x[0] == 0) :\n\tarr[0] = 1\nelse :\n\tco += 1\nfor i in range(1,n) :\n\tif (x[i] == 1) :\n\t\tco += 1\n\t\tif (arr[i - 1] > 0) :\n\t\t\tarr[i] = arr[i - 1] - 1\n\telse :\n\t\tarr[i] = arr[i - 1] + 1\nif (co == n) :\n\tprint n - 1\nelse :\n\tprint co + max(arr)\n"}, {"source_code": "n = int(input())\na = list(map(int, raw_input().split()))\nx = 0\nfor i in range(n):\n for j in range(i, n):\n y = 0\n for k in range(n):\n if k >= i and k <= j:\n y += a[k] ^ 1\n else:\n y += a[k]\n x = max(x, y)\nprint x\n"}, {"source_code": "import sys\nn = int(input())\nx = [int(x) for x in input().split()]\nq = []\ndef check(l,i,j):\n count1 = 0\n count0 = 0\n count = 0\n for k in range(i,j+1):\n if l[k] == 1:\n count1 = count1+1\n else:\n count0 = count0+1\n for k in range(i):\n if l[k] == 1:\n count = count + 1\n for k in range(j+1,len(l)):\n if l[k] == 1:\n count = count + 1\n return count0 + count\nif x == [1]*n:\n print(n-1)\n sys.exit(0)\nif len(x) != 1:\n for i in range(len(x)):\n for j in range(i+1,len(x)):\n q.append(check(x,i,j))\n \n print(max(q))\nelse:\n print(1-x[0])"}, {"source_code": "x=int(raw_input())\nl=map(int, raw_input().split())\nw=sum(l)\ns=x-sum(l)\nf=[]\ng=[]\nfor i in range(x):\n for j in range(x):\n if i < j:\n f.append([l[0:i].count(1)+l[i:j+1].count(1)+l[j+1:].count(1),\n l[0:i].count(1)+l[i:j+1].count(0)+l[j+1:].count(1)\n ])\nfor i in range(len(f)):\n g.append(f[i][0])\n g.append(f[i][1])\nif len(l) == 1:\n if l[0] == 0:\n print 1\n else:\n print 0\nelif l.count(1) == x:\n print l.count(1)-1\nelse:\n print max(g)"}, {"source_code": "\n\n\nn= int(input())\n\nt= list(map(int,input().split()))\n\n\n\nif t.count(1)==n:\n print(n-1)\nelif t.count(0)==n:\n print(n)\nelse:\n \n \n u=0 \n for k in range(n):\n for j in range(k+1,n+1):\n a=(t[k:j].count(0))+t[:k].count(1)+t[j:].count(1)\n if a>u:\n u=a\n\n\n print(u)\n \n\n \n"}, {"source_code": "n = int(input())\nls = list(map(int, input().split()))\nary = [0 for i in range(n)]\n# val = 0\n# for i in range(n):\n # val += ls[i]\n # ary[i] = val\nb = [1 if not x else -1 for x in ls]\n\ns = 0\nma = -9e9\n# for i in range(n):\n # for j in range(i, n):\n # ma = max(ma, ary[i] - ls[i] + (j - i + 1 - (ary[j] - ary[i] )) + ary[-1] - ary[j])\n# print(ma)\n\nmast = 0\nmaend = 0\nst = 0\nend = 0\n# print(b)\nfor i in range(n):\n s += b[i]\n if s > ma:\n mast = st\n maend = i + 1\n ma = s\n\n if s < 0: \n s = 0\n st = i + 1\n\n# print(ma, mast, maend)\nprint(sum(ls) + ma)\n\n\n"}, {"source_code": "n = input()\n\narr = map(int, raw_input().strip().split(' '))\n\ndp1 = [0]*n\ndp2 = [0]*n\n\nfor i in range(n):\n if i == 0 and arr[0] == 1:\n dp1[0] = 0\n dp2[0] = 0\n elif i == 0 and arr[0] == 0:\n dp1[0] = 1\n dp2[0] = 0\n else:\n if arr[i] == 0:\n if dp1[i-1] > dp2[i-1]:\n dp1[i] = dp1[i-1] - dp2[i-1] + 1\n dp2[i] = 0\n else:\n dp1[i] = 1\n dp2[i] = 0\n else:\n dp1[i] = dp1[i-1]\n dp2[i] = dp2[i-1] + 1\n \nanswer = max(dp1)\n\nif answer == 0:\n print n-1\nelse:\n \n print answer + arr.count(1)\n \n "}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nprint(max([l[i:j+1].count(0)+(l[:i]+l[j+1:]).count(1) for i in range(n) for j in range(i,n)]))"}, {"source_code": "# import math\n# import bisect\nimport sys\n# from collections import OrderedDict\ninput = sys.stdin.readline\ndef inp():\n\treturn(int(input()))\ndef inlt():\n\treturn(list(map(int,input().split())))\ndef insr():\n\ts = input()\n\treturn(s[:len(s)-1])\ndef invr():\n\treturn(map(int,input().split()))\n# list1, list2 = zip(*sorted(zip(list1, list2)))\nn = inp()\nA = inlt()\npre = []\nprev = 0\nfor i in range(n):\n\tif A[i] == 1:\n\t\tprev -= 1\n\telse:\n\t\tprev += 1\n\tpre.append(prev)\nbest_j = 0\nbest_k = 0\nmaxx = -2\nfor j in range(n):\n\tfor k in range(j,n,1):\n\t\tif j == 0:\n\t\t\tif pre[k] >maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k]\n\t\telse:\n\t\t\tif pre[k]-pre[j-1] > maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k] - pre[j-1]\nout = sum(A)\n# print(best_j,best_k)\nc = sum(A[best_j:best_k+1])\n# print(c)\nout += (best_k-best_j+1-c-c)\nprint(out)\n"}, {"source_code": "result=0\nn=int(input())\nline=input()\nline=line.split(sep=' ')\nfor k in range(n):\n line[k]=int(line[k])\nfor i in range(n):\n a=line[:]\n for j in range(i,n):\n a[j]=1-line[j]\n temp=sum(a)\n if temp>result:\n result=temp\nprint(result)"}, {"source_code": "# import math\n# import bisect\nimport sys\n# from collections import OrderedDict\ninput = sys.stdin.readline\ndef inp():\n\treturn(int(input()))\ndef inlt():\n\treturn(list(map(int,input().split())))\ndef insr():\n\ts = input()\n\treturn(s[:len(s)-1])\ndef invr():\n\treturn(map(int,input().split()))\n# list1, list2 = zip(*sorted(zip(list1, list2)))\nn = inp()\nA = inlt()\npre = []\nprev = 0\nfor i in range(n):\n\tif A[i] == 1:\n\t\tprev -= 1\n\telse:\n\t\tprev += 1\n\tpre.append(prev)\nbest_j = 0\nbest_k = 0\nmaxx = -2\nfor j in range(n):\n\tfor k in range(j,n,1):\n\t\tif j == 0:\n\t\t\tif pre[k] >maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k]\n\t\telse:\n\t\t\tif pre[k]-pre[j-1] > maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k] - pre[j-1]\nout = sum(A)\n# print(best_j,best_k)\nc = sum(A[best_j:best_k+1])\n# print(c)\nout += (best_k-best_j+1-c-c)\nprint(out)\n"}, {"source_code": "def f(x):\n return(1-x)\nn=int(input())\n\nq=list(map(int,input().split()))\nif n==1:\n print(1-q[0])\nelse:\n s=[]\n\n for i in range(n-1):\n for j in range(i,n):\n a=list(map(f,q))\n t=0\n for k in range(i,j+1):\n t+=a[k]\n for m in range(0,i):\n t+=q[m]\n for h in range(j+1,n):\n t+=q[h]\n s.append(t)\n print(max(s))\n"}, {"source_code": "n = input()\na = map(int,raw_input().split())\n\ndef work(l,r,x):\n b = x\n for i in range(l,r+1):\n b[i] = 1-b[i];\n return sum(b)\n\nans = 0 \nfor i in range(0,len(a)):\n for j in range(i,len(a)):\n ans = max(ans,work(i,j,a))\n work(i,j,a)\nprint ans\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\nprint(max([l[i:j+1].count(0)+(l[:i]+l[j+1:]).count(1) for i in range(n) for j in range(i,n)]))\n"}, {"source_code": "t = int(raw_input())\nA = [int(x) for x in raw_input().split()]\n\nB = [-1 if a==0 else 1 for a in A]\n\ndef findMin(A):\n\tN = len(A)\n\tT = [0]*N\n\tT[0] = A[0]\n\tfor i in range(1, N):\n\t\tT[i] = A[i] + T[i-1] \n\n\tminsum = 0\n\tfor i in range(0, N):\n\t\tfor j in range(i, N):\n\t\t\tsum = T[j]-T[i]+A[i]\n\t\t\tif sum < minsum:\n\t\t\t\tminsum = sum \n\t\t\t#print \"(%s,%s) = %s, minsum=%s\" %(i,j,sum,minsum)\n\t#print \"Algorithm 2 : %s\" % minsum\n\treturn minsum\n\ndef min_subarray(A):\n min_ending_here = min_so_far = 0\n for x in A:\n min_ending_here = min(0, min_ending_here + x)\n min_so_far = min(min_so_far, min_ending_here)\n return min_so_far\n\nsumA = sum(A)\nif sumA == t:\n\tprint t-1\nelse:\n\tprint sumA + abs(min_subarray(B))\n\n"}, {"source_code": "n = int(raw_input())\na = map(int, raw_input().split())\n\n\na_ = [-1] if a[0] else [1] # increments\ns_ = [a_[0]]\ncount_1 = 1 if a[0] else 0\n\n \nfor i in range(n)[1:]:\n if a[i]:\n v = -1\n count_1 += 1\n else:\n v = 1\n\n if a_[-1]* v > 0:\n a_[-1] += v\n s_[-1] += v\n else:\n a_.append(v)\n s_.append(s_[-1] + v)\n\n# now find the maximum sum of the sub string of a_\nlow = s_[0]\nmax = -1 if a[0] else s_[0]\nfor e in s_[1:]:\n if (e - low) > max:\n max = e - low\n elif e < low:\n low = e\n\n\nprint count_1 + max"}, {"source_code": "n = input()\nst = map(int, raw_input().split())\n\ndef main1():\n tot = 0\n maxn = -10000\n for i in xrange(0, n):\n if st[i] == 1:\n tot += 1\n for j in xrange(i, n):\n cnt0 = st[i:j+1].count(0)\n cnt1 = st[i:j+1].count(1)\n if cnt0 - cnt1 > maxn:\n maxn = cnt0 - cnt1\n res = tot + maxn\n print(res)\n\ndef main2():\n dp = [0] * (n + 1)\n stn = [-1 if st[i] == 1 else 1 for i in xrange(0, n)]\n dp[0] = stn[0]\n maxv = dp[0]\n for i in xrange(1, n):\n dp[i] = max(dp[i-1]+stn[i], stn[i])\n if dp[i] > maxv:\n maxv = dp[i]\n res = st.count(1) + maxv\n print(res)\n\nif __name__ == \"__main__\":\n main2()"}, {"source_code": "\"\"\"\nCodeforces Round #191 (Div. 2)\n327 A. Flipping Game\n\n@author yamaton\n@date 2015-08-05\n 2015-09-22\n 2015-11-04\n\"\"\"\n\nimport itertools\nimport collections\nimport sys\n\ndef solve_bruteforce(xs):\n \"O(N^3) solution\"\n n = len(xs)\n if n == 1:\n return len(xs) - sum(xs)\n return max(sum(xs[:i]) + sum(xs[j:]) - sum(xs[i:j]) + (j - i)\n for (i, j) in itertools.combinations(n, 2))\n\n\ndef solve_slow(xs):\n \"O(N^2) solution\"\n n = len(xs)\n assert n > 0\n a = [1 if x == 0 else -1 for x in xs]\n b = collections.defaultdict(int)\n for i, acc in enumerate(itertools.accumulate(a)):\n b[i] = acc\n deltaS = max(b[j] - b[i] for i in range(-1, n) for j in range(i+1, n))\n if deltaS <= 0:\n return sum(xs) - 1\n else:\n return sum(xs) + deltaS\n\n\ndef solve_old(xs):\n \"O(N) with DP\"\n a = [1 if x == 0 else -1 for x in xs]\n b = itertools.accumulate(a)\n deltaS = 0\n min_so_far = 0\n for bk in b:\n deltaS = max(deltaS, bk - min_so_far)\n min_so_far = min(min_so_far, bk)\n\n if deltaS == 0:\n return sum(xs) - 1\n else:\n return sum(xs) + deltaS\n\n\n\ndef solve(xs):\n \"\"\" Maximum value contiguous subsequence problem \"\"\"\n n = len(xs)\n a = [1 if x == 0 else -1 for x in xs]\n\n m = collections.defaultdict(int)\n maxval = 0\n for i in range(n):\n m[i] = max(m[i-1] + a[i], a[i])\n maxval = max(m[i], maxval)\n\n deltaS = maxval\n if deltaS == 0:\n return sum(xs) - 1\n else:\n return sum(xs) + deltaS\n\n\ndef test():\n xs = [0]\n assert solve(xs) == 1\n xs = [1]\n assert solve(xs) == 0\n xs = [0, 1, 0]\n assert solve(xs) == 2\n xs = [0, 0, 1, 0, 0]\n assert solve(xs) == 4\n xs = [0, 0, 0, 0]\n assert solve(xs) == 4\n xs = [1, 1, 1]\n assert solve(xs) == 2\n\n\n\n\ndef main():\n n = int(input())\n xs = [int(i) for i in input().strip().split()]\n assert len(xs) == n\n result = solve(xs)\n print(result)\n\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n, a = int(input()), [int(x) for x in input().split()]\nif not 0 in a: print(n-1); quit()\nm = 0\nfor i in range(n):\n s = 0\n for row in a[i:]:\n row = 1 if row == 0 else -1\n s += row\n m = max(s, m)\nprint(m+sum(a))"}, {"source_code": "n = input()\nl = [int(x) for x in raw_input().split()]\nn1 = sum(l)\nres = -200\nfor i in range(len(l)):\n\tcan = 0\n\tfor j in range(i, len(l)):\n\t\tif l[j] == 0:\n\t\t\tcan += 1\n\t\telse:\n\t\t\tcan -= 1\n\t\t#print((i, j, can))\n\t\tif res < can:\n\t\t\tres = can\nprint(n1 + res)"}, {"source_code": "x=int(input())\na=list(map(int,input().split()))\ns=[]\n\nfor i in range(x):\n for j in range(i,x):\n l=0\n for k in range(x):\n if k>=i and k<=j:\n l+=(1-a[k])\n else:\n l+=a[k]\n s.append(l) \n \nprint(max(s)) "}, {"source_code": "n = int(input())\nnums = [int(x) for x in input().split()]\n\nif nums.count(1) == n:\n print(n - 1)\n exit()\n\ncount = nums.count(1)\n\nfor i in range(n):\n for j in range(i, n):\n count = max(count, nums[i:j + 1].count(0) - nums[i:j + 1].count(1) + nums.count(1))\n\nprint(count)\n\n"}, {"source_code": "n=input();s=map(int,raw_input()[::2]);print max(sum(s)-2*sum(s[j:i])+i-j for i in range(n+1)for j in range(i))\n"}, {"source_code": "n=int(input())\np=[int(i)for i in input().split()]\na=0\nb=0\ns=0\nfor i in p:\n a+=i\nif n>1:\n for i in range(n-1):\n for j in range(i,n):\n for k in range(i,j+1):\n s+=p[k]\n if a+j-i+1-2*s>b:\n b=a+j-i+1-2*s\n s=0\nelse:\n if p[0]==1:\n b=0\n if p[0]==0:\n b=1\nprint(b)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\n\np = []\nfor i in range(len(a)):\n if a[i]:\n p.append(-1)\n else:\n p.append(1)\n\ns = a.count(1)\n\ndp = [0 for i in range(len(a))]\ndp[0] = p[0]\nfor i in range(1, len(a)):\n dp[i] = max(p[i], dp[i - 1] + p[i])\n\nprint(s + max(dp))"}, {"source_code": "import sys\n\ndef flip_game(numbers):\n max_points = 0\n for i in range(len(numbers)):\n for j in range(i,len(numbers)):\n points = flip_and_count(numbers,i,j)\n max_points = points if points > max_points else max_points\n return max_points\n\ndef flip_and_count(numbers,i,j):\n flipped = numbers[:]\n for k in xrange(i,j+1):\n flipped[k] = flipped[k]^1\n count = 0\n for num in flipped:\n if num == 1:\n count = count+1\n return count\n\n\ninput = []\nfor i in range(2):\n input.append(sys.stdin.readline())\nprint flip_game([int(x) for x in input[1].split(\" \")])\n"}, {"source_code": "n = int(input())\nline = input()\nline = [int(i) for i in line.split()]\noutput = 0\nfor i in range(n):\n text = line[:]\n for j in range(i,n):\n text[j] = 1 - text[j]\n output = max(sum(text),output)\nif n == 1:\n output = 1 - line[0]\nprint(output)\n\t\t\t\n\t\t\n\n\n"}, {"source_code": "# import math\n# import bisect\nimport sys\n# from collections import OrderedDict\ninput = sys.stdin.readline\ndef inp():\n\treturn(int(input()))\ndef inlt():\n\treturn(list(map(int,input().split())))\ndef insr():\n\ts = input()\n\treturn(s[:len(s)-1])\ndef invr():\n\treturn(map(int,input().split()))\n# list1, list2 = zip(*sorted(zip(list1, list2)))\nn = inp()\nA = inlt()\ndef maxSubArraySum(a,size): \n\t \n\tmax_so_far = 0\n\tmax_ending_here = 0\n\t \n\tfor i in range(0, size): \n\t\tmax_ending_here = max_ending_here + a[i] \n\t\tif (max_so_far < max_ending_here): \n\t\t\tmax_so_far = max_ending_here \n \n\t\tif max_ending_here < 0: \n\t\t\tmax_ending_here = 0 \n\treturn max_so_far \nB = []\nfor i in range(n):\n\tif A[i] == 1:\n\t\tB.append(-1)\n\telse:\n\t\tB.append(1)\na = sum(A)\nb = maxSubArraySum(B,n)\nif a == n:\n\tprint(n-1)\nelse:\n\tprint(a+b)"}, {"source_code": "if __name__=='__main__':\n N = int(raw_input())\n inp = raw_input()\n arr = inp.split()\n t1=0\n ans = 0\n for i in arr:\n if i=='1':\n t1+=1\n for i in range(N):\n for j in range(N):\n if j>=i:\n rev = 0\n for k in range(i,j+1):\n if arr[k]=='0':\n rev+=1\n else:\n rev-=1\n ans = max(ans,t1+rev)\n print ans\n \n"}, {"source_code": "n = int(input())\nlst = [int(i) for i in input().split()]\noutput = []\nfor i in range(n):\n for j in range(i+1,n+1):\n total = lst[:i].count(1)+lst[i:j].count(0)+lst[j:].count(1)\n output.append(total)\nprint(max(output))\n"}, {"source_code": "n=int(raw_input())\na= map(int,raw_input().split())\nlis=[]\nfor i in xrange(n):\n\tif a[i]==0:\n\t\tlis.append(1)\n\telse:\n\t\tlis.append(-1)\nval=0\nfor i in xrange(n):\n\tlol=0\n\tfor j in range(i,n):\n\t\tlol+=lis[j]\n\t\tif lol>val:\n\t\t\tval=lol\n\t\t\tx=i\n\t\t\ty=j\n#print x,y\nif n==1:\n\tif a[0]==1:\n\t\tprint \"0\"\n\telse:\n\t\tprint \"1\"\nelse:\n\tif val==0:\n\t\tprint n-1\n\telse:\n\t\tcount=0\n\t\tfor i in xrange(x):\n\t\t\tif lis[i]==-1:\n\t\t\t\tcount+=1\n\t\tfor i in range(y+1,n):\n\t\t\tif lis[i]==-1:\n\t\t\t\tcount+=1\n\t\tfor i in range(x,y+1):\n\t\t\tif lis[i]==1:\n\t\t\t\tcount+=1\n\t\tprint count"}, {"source_code": "from copy import deepcopy\nn =int(input())\ns=[int(s) for s in input().split()]\nt=[]\np = deepcopy(s)\nfor i in range(n):\n for j in range(i,n):\n p[j]=1-p[j]\n t.append(sum(p))\n p = deepcopy(s)\nprint(max(t))"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\ncount = a.count(1)\nm = 0\nif len(a) == a.count(1):\n if len(a) == 1:\n print(0)\n else:\n print(len(a)-1)\nelse:\n \n for i in range(n):\n for j in range(i,n):\n if a[j] == 0:\n one = a[i:j].count(1)\n zer = a[i:j].count(0)\n if zer > one:\n maxi = zer-one\n if maxi > m:\n m = maxi\n\n print(m+count+1)"}, {"source_code": "n = int(input())\nl =[int(i) for i in input().split()]\nini_zeros = 0\nini_ones = 0\nrefer =[]\nresult = []\na = 0\nc = 0\nb =0\nreverse = []\nif sum(l) ==len(l):\n print(len(l)-1)\nelse:\n for i in range(len(l)):\n if l[i] == 0:\n ini_zeros+=1\n if i != 0 and l[i-1]==1:\n refer.append([ini_ones])\n ini_ones = 0\n if i == len(l)-1:\n refer.append([0,ini_zeros])\n else:\n ini_ones+=1\n if i != 0 and l[i-1] ==0:\n refer.append([0,ini_zeros])\n ini_zeros =0\n if i == len(l) - 1:\n refer.append([ini_ones])\n if refer[0][0] !=0: #1\u6253\u5934\n for i in range(len(refer)):\n a += ((-1)**(i-1))*refer[i][-1]\n if a <0:\n a =0\n result.append(a)\n else:\n for i in range(len(refer)):\n a +=((-1)**i)*refer[i][-1]\n if a <0:\n a =0\n result.append(a)\n result.sort()\n b+=sum(l)+result[-1]\n print(b)\n\n\n\n\n\n"}, {"source_code": "n=input();s=map(int,raw_input()[::2]);print max(sum(s)-2*sum(s[j:i])+i-j for i in range(n+1)for j in range(i))\n"}, {"source_code": "n=input();s=map(int,raw_input()[::2]);print max(sum(s)-2*sum(s[j:i])+i-j for i in range(n+1)for j in range(i))\n"}, {"source_code": "n = int(raw_input())\ncoins = [int(i) for i in raw_input().split()]\nflipped = []\nfor i in range(n):\n if coins[i] == 1:\n flipped.append(-1)\n else:\n flipped.append(1)\nmax_so_far = flipped[0]\ncurr_max = flipped[0]\nfor i in range(1, n):\n curr_max = max(curr_max + flipped[i], flipped[i])\n max_so_far = max(max_so_far, curr_max)\nprint max_so_far + sum(coins)"}, {"source_code": "number=int(raw_input())\ngame=raw_input()\ngame=game.split(' ')\nedinic=game.count('1')\nmaxim=1\nfor i in range(len(game)):\n if game==['1']:\n maxim=0\n for m in range(i,len(game)):\n curr_result=edinic\n for k in game[i:m+1]:\n if k=='0':\n curr_result+=1\n else:\n curr_result-=1\n if curr_result>maxim:\n maxim=curr_result\nprint maxim"}, {"source_code": "n=int(raw_input())\nstr=raw_input()\nt=[]\ninitial=0\nsum=0\nfor i in range(0, n):\n t.append(int(str.split(\" \")[i]))\nfor i in range(0,n):\n sum=sum+t[i]\nif sum==n:\n print n-1\nelif sum==0:\n print n\nelse:\n\n for i in range(0, n - 1):\n for j in range(i + 1, n+1):\n t1 = []\n for k in range(i, j):\n t1.append(t[k])\n sum = 0\n for k in range(0, len(t1)):\n if t1[k] == 0:\n sum += 1\n elif t1[k] == 1:\n sum -= 1\n if sum > initial:\n initial = sum\n imax = i\n jmax = j\n for i in range(imax, jmax):\n t[i] = 1 - t[i]\n total = 0\n for i in range(0, n):\n total = total + t[i]\n print total\n\n\"\"\"\nsum0=[]\nsum0.append(1)\nj=0\nfor i in range(0,n-1):\n if t[i]==t[i+1]:\n sum[j]+=1\n else:\n j+=1\n sum.append(1)\nprint sum\n\"\"\""}, {"source_code": "def flip(l,a,b):\n for i in range(a,b):\n if l[i] == 1:\n l[i] = 0\n else:\n l[i] = 1\n\n return l\n\ndef solver():\n n = input()\n num = map(int, raw_input().split())\n maxim = 0\n\n if not (0 in num):\n print n-1\n return\n \n if n == 1:\n if num[0] == 0:\n print 1\n else:\n print 0\n\n return\n\n\n for i in range(0,n):\n for j in range(i,n+1):\n new_b = num[:]\n new_b = flip(new_b,i,j)\n maxim = max(maxim,new_b.count(1))\n #print new_b\n\n print maxim\n\n\nif __name__ == \"__main__\":\n solver()\n\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n from sys import stdin\n \n n = int(stdin.readline())\n ans = -1\n ones, onesInterval, subarrsum = 0, 0, 0\n\n for ai in map(int, stdin.readline().split()):\n \n subarrsum += -1 if ai else 1\n ones += ai\n\n if subarrsum > ans:\n ans = subarrsum\n onesInterval += ai\n\n if subarrsum < 0:\n subarrsum = 0\n onesInterval = 0\n\n print(ans + ones - onesInterval)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "a = raw_input()\nb = [int(i) for i in raw_input().split(' ')]\ns = sum(b)\nres = []\nfor i in range(int(a)):\n if b[i] == 0:\n res.append(1)\n else:\n res.append(-1)\nRES = [res[0]]\nfor i in range(1,int(a)):\n r = max(RES[-1]+res[i],res[i])\n RES.append(r)\nm = max(RES)\nprint s+m\n"}, {"source_code": "n = int(input())\na = [int(a_i) for a_i in input().split()]\nmax_ones = 0\n\nfor i in range(n):\n for j in range(i, n):\n temp = sum(a) - a[i:j+1].count(1) + a[i:j+1].count(0)\n if max_ones < temp:\n max_ones = temp\n\nprint(max_ones)"}, {"source_code": "num = eval(input())\ndata = [eval(i) for i in input().split()]\ncount = data.count(1)\nadd = -100\nfor i in range(num):\n for j in range(i+1, num+1):\n k = data[i:j].count(0) - data[i:j].count(1)\n add = max(add, k)\nprint(count + add)"}, {"source_code": "#ref: http://blog.csdn.net/catglory/article/details/45950683\nn = int(input())\na = [int(i) for i in input().split()]\n\ncnt1 = sum(a)\n\nmx = 0; cnt0 = 0\nfor i in a:\n if i==0 :\n cnt0 += 1\n if cnt0 > mx :\n mx = cnt0\n elif cnt0>0:\n cnt0 -= 1 # 1 will affect cnt0 value -1\n \nif mx==0: mx -= 1 # at least flipping once if no zero\nprint(cnt1 + mx)\n"}, {"source_code": "n = int(input())\na = [int(a_i) for a_i in input().split()]\nmax_ones = 0\n\nfor i in range(n):\n for j in range(i, n):\n temp = sum(a) - a[i:j+1].count(1) + a[i:j+1].count(0)\n if max_ones < temp:\n max_ones = temp\n\nprint(max_ones)"}, {"source_code": "\nI0 = lambda :map(int,input().split())\nI1 = lambda :int(input())\nI2 = lambda :list(map(int,input().split()))\n#####################################################\nn = I1()\na = I2()\nM=-1\n\none = a.count(1)\nfor i in range(n):\n for j in range(i,n):\n zero = a[i:j+1].count(0)\n one1 = j+1-i-zero\n M = max(M,one-one1+zero)\nprint(M)\n"}, {"source_code": "n = int(input())\nlst = list(map(int,input().split()))\nlst2 = []\nmega_cnt = 0\nfor i in lst:\n if i == 1:\n mega_cnt += 1\nfor i in range(n):\n for j in range(i+1,n+1):\n a = lst[i:j]\n #print(a)\n cnt = 0\n cnt2 = 0\n for b in a:\n if b == 1:\n cnt += 1\n else:\n cnt2 += 1\n yo = cnt2 - cnt\n lst2.append(yo)\nprint(mega_cnt+max(lst2))"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nans=0\nfor i in range(n):\n for j in range(i,n):\n count=0\n for k in range(n):\n if k<=j and k>=i:\n count+=1-arr[k]\n else:\n count+=arr[k]\n ans=max(count,ans)\nprint(ans)\n\n"}, {"source_code": "\nn = int(input())\nlist = input().split()\nlist = [int(i) for i in list]\nls = []\n\nfor i in list:\n if i == 1:\n ls.append(-1)\n else:\n ls.append(1)\nthisSum = 0\nmaxSum = 0\nfor i in ls:\n thisSum += i\n if thisSum > maxSum:\n maxSum = thisSum\n elif thisSum < 0:\n thisSum = 0\nif maxSum == 0:\n print(maxSum + sum(list) - 1)\nelse:\n print(maxSum + sum(list))\n"}, {"source_code": "# coding = utf-8\nn = input()\na = map(int,raw_input().split())\nb = []\ncount = 0\nfor i in a:\n\tif i == 1:\n\t\tb.append(-1)\n\t\tcount += 1\n\telse:\n\t\tb.append(1)\nsum = 0\nmax = -2\nfor j in b:\n\tsum += j\n\tif sum>max:\n\t\tmax = sum\n\tif sum < 0:\n\t\tsum = 0\nprint max+count"}, {"source_code": "l=int(input())\na=input().split()\nb=[]\nfor i in range(l):\n for j in range(i+1,l+1):#\u4ecei+1\u5f00\u59cb\u679a\u4e3e\u5230l\n \n b.append(a.count(\"1\")-j+i+2*a[i:j].count(\"0\"))\n #a\u4e2d1\u7684\u6570\u76ee+i\u5230j\u4e2d0\u4e2a\u6570\u7684\u4e24\u500d+i-j\nprint(max(b))\n"}, {"source_code": "#!/usr/bin/env python3\n\ndef main():\n \n from itertools import accumulate\n\n n = int(input())\n arr = [int(x) for x in input().split()]\n ones = list(accumulate(arr))\n ans = 0\n \n ones_inside = lambda i, j: ones[j] - ones[i-1] if i else ones[j]\n ones_outside = lambda i, j: ones[n-1] - ones_inside(i, j)\n\n for i in range(0, n):\n for j in range(i, n):\n partial = ones_outside(i,j) + (j-i + 1 - ones_inside(i,j))\n ans = max(ans, partial)\n \n print(ans)\n\nif __name__ == \"__main__\":\n main()\n\n"}, {"source_code": "def ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\nn = ni()\n\na = nis()\n\nmax_val = None\nstart = end = 0\ncurrent_max = 0\ncurrent_start = 0\nones = 0\n\nfor i in range(n):\n val = a[i]\n if val:\n current_max -= 1\n ones += 1\n else:\n current_max += 1\n\n if max_val is None or current_max > max_val:\n max_val = current_max\n start = current_start\n end = i\n\n if current_max < 0:\n current_max = 0\n current_start += 1\n\nprint ones + max_val\n\n"}, {"source_code": "n = input()\na = map(int, raw_input().split())\n\nmaxx= (sum(a)+1)%(n+1)\n\nfor i in xrange(n):\n for j in xrange(i+1,n+1):\n summ = sum(a)-(2*sum(a[i:j]))+len(a[i:j])\n maxx = max(summ,maxx)\n\nprint maxx "}, {"source_code": "n = int(input())\nlst = list(map(int,input().split()))\nlst2 = []\nmega_cnt = 0\nfor i in lst:\n if i == 1:\n mega_cnt += 1\nfor i in range(n):\n for j in range(i+1,n+1):\n a = lst[i:j]\n cnt = 0\n cnt2 = 0\n for b in a:\n if b == 1:\n cnt += 1\n else:\n cnt2 += 1\n yo = cnt2 - cnt\n lst2.append(yo)\nprint(mega_cnt+max(lst2))"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\nprint(max([l[i:j+1].count(0)+(l[:i]+l[j+1:]).count(1) for i in range(n) for j in range(i,n)]))\n"}, {"source_code": "n = int(raw_input())\na = map(int,raw_input().split())\nans = 0;\nfor i in range(n):\n\tfor j in range(i,n):\n\t\tb = a[:]\n\t\ttemp = 0\n\t\tfor k in range(i,j + 1):\n\t\t\tb[k] = 1 - b[k]\n\t\tfor k in range(n):\n\t\t\ttemp += b[k]\n\t\tans = max(ans,temp)\nprint ans\n\n"}, {"source_code": "n = input()\nl = map(int, raw_input().split())\nres = 0; maxi = 0\nfor i in l:\n res = max(0, res+(1-2*i))\n maxi = max(maxi, res)\nprint l.count(1) + (maxi if maxi > 0 else -1)"}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 20.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 \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,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 \n\n n=ii()\n l=li()\n \n tot=0\n for i in range(n):\n tot+=l[i]\n \n dp=[0]*n\n for i in range(n):\n if l[i]==1:\n l[i]=-1\n else:\n l[i]=1\n \n m=l[i]\n c=l[i]\n dp[0]=l[0]\n\n for i in range(1,n):\n dp[i]=max(dp[i-1]+l[i],l[i]) #Kadane Algo\n \n #c=max(l[i],c+l[i])\n #m=max(m,c)\n\n\n \n \n m=max(dp)\n \n \n \n print(tot+m)\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": "def ni():\n return int(raw_input())\n\ndef nis():\n return map(int, raw_input().split())\n\ndef si():\n return raw_input()\n\nn = ni()\n\na = nis()\n\nmax_val = None\nstart = end = 0\ncurrent_max = 0\ncurrent_start = 0\nones = 0\n\nfor i in range(n):\n val = a[i]\n if val:\n current_max -= 1\n ones += 1\n else:\n current_max += 1\n\n if max_val is None or current_max > max_val:\n max_val = current_max\n start = current_start\n end = i\n\n if current_max < 0:\n current_max = 0\n current_start += 1\n\nprint ones + max_val\n\n"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n res = sum(l)\n a = b = 0\n for i, x in enumerate(l):\n l[i] = b - a\n a += x\n b += 1 - x\n l.append(b - a)\n hi, lo = max(((i, j) for i in range(n + 1) for j in range(i + 1)), key=lambda _: l[_[0]] - l[_[1]])\n if hi == lo:\n res -= 1\n else:\n res += l[hi] - l[lo]\n return res\n\n\nprint(main())\n"}, {"source_code": "n=int(input())\na=[int(i) for i in input().split()]\ns=sum(a)\nd=[0]\nt=list(range(0,int(len(a)+1)))\nif s==int(len(a)):\n\tif n==1 :\n\t\tfor value in a:\n\t\t\tif int(value)==1:\n\t\t\t\tprint('0')\n\t\t\telse:\n\t\t\t\tprint('1')\n\telse:\n\t\tprint(int(s-1))\nelse:\n\tfor i in t:\n\t\tfor j in t:\n\t\t\tif i>=j:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tc=sum(a[i:j])\n\t\t\t\tb=[]\n\t\t\t\tfor value in a[i:j]:\n\t\t\t\t\tif int(value)==1:\n\t\t\t\t\t\tvalue=0\n\t\t\t\t\t\tb.append(value)\n\t\t\t\t\telse:\n\t\t\t\t\t\tvalue=1\n\t\t\t\t\t\tb.append(value)\n\t\t\t\tr=int(sum(b)-c)\n\t\t\t\td.append(r)\n\tg=max(d)\n\tprint(int(s+g))\n"}, {"source_code": "def main():\n n = int(input())\n l = list(map(int, input().split()))\n res = sum(l)\n a = b = 0\n for i, x in enumerate(l):\n l[i] = b - a\n a += x\n b += 1 - x\n l.append(b - a)\n hi, lo = max(((i, j) for i in range(n + 1) for j in range(i + 1)), key=lambda _: l[_[0]] - l[_[1]])\n if hi == lo:\n res -= 1\n else:\n res += l[hi] - l[lo]\n return res\n\n\nprint(main())\n"}, {"source_code": "n = int(input())\nlst = [int(x) for x in input().split()]\n\ncur_num = sum(x==1 for x in lst)\ndef trans(x):\n return -1 if x==1 else 1\nsum_lst = [0]\nfor el in lst:\n sum_lst.append(sum_lst[-1]+trans(el))\n\n#we need all sums from i inclusive to j exclusive, 0<=imax_sum:\n max_sum = cur\nprint(max_sum+cur_num)"}, {"source_code": "n = int(raw_input())\na = [int(_) for _ in raw_input().split()]\n\n\nmaxcnt = -1\n\nfor i in range(n):\n for j in range(i, n):\n cnt = 0\n for k in range(i):\n cnt += a[k]\n for k in range(j+1, n):\n cnt += a[k]\n for k in range(i, j+1):\n if a[k] == 0:\n cnt += 1\n if cnt > maxcnt:\n maxcnt = cnt\n\nprint maxcnt\n"}, {"source_code": "n=int(input())\nnums=list(map(int,input().split()))\nmaxn=-1\nif(n==1):\n print(n-sum(nums))\n exit(0)\nfor i in range(n):\n for j in range(i,n):\n s=sum(nums[:i])+j-i+1-sum(nums[i:j+1])+sum(nums[j+1:])\n maxn=max(maxn,s)\nprint(maxn)"}, {"source_code": "n = int(input())\nline = input()\nline = [int(i) for i in line.split()]\noutput = 0\nfor i in range(n):\n text = line[:]\n for j in range(i,n):\n text[j] = 1 - text[j]\n output = max(sum(text),output)\nif n == 1:\n output = 1 - line[0]\nprint(output)\n\t\t\t\n\t\t\n\n\n"}, {"source_code": "# import math\n# import bisect\nimport sys\n# from collections import OrderedDict\ninput = sys.stdin.readline\ndef inp():\n\treturn(int(input()))\ndef inlt():\n\treturn(list(map(int,input().split())))\ndef insr():\n\ts = input()\n\treturn(s[:len(s)-1])\ndef invr():\n\treturn(map(int,input().split()))\n# list1, list2 = zip(*sorted(zip(list1, list2)))\nn = inp()\nA = inlt()\npre = []\nprev = 0\nfor i in range(n):\n\tif A[i] == 1:\n\t\tprev -= 1\n\telse:\n\t\tprev += 1\n\tpre.append(prev)\nbest_j = 0\nbest_k = 0\nmaxx = -2\nfor j in range(n):\n\tfor k in range(j,n,1):\n\t\tif j == 0:\n\t\t\tif pre[k] >maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k]\n\t\telse:\n\t\t\tif pre[k]-pre[j-1] > maxx:\n\t\t\t\tbest_k = k\n\t\t\t\tbest_j = j\n\t\t\t\tmaxx = pre[k] - pre[j-1]\nout = sum(A)\n# print(best_j,best_k)\nc = sum(A[best_j:best_k+1])\n# print(c)\nout += (best_k-best_j+1-c-c)\nprint(out)\n"}, {"source_code": "n = int(raw_input())\na = [int(_) for _ in raw_input().split()]\n\n\nmaxcnt = -1\n\nfor i in range(n):\n for j in range(i, n):\n cnt = 0\n for k in range(i):\n cnt += a[k]\n for k in range(j+1, n):\n cnt += a[k]\n for k in range(i, j+1):\n if a[k] == 0:\n cnt += 1\n if cnt > maxcnt:\n maxcnt = cnt\n\nprint maxcnt\n"}, {"source_code": "n=input();s=map(int,raw_input()[::2]);print max(sum(s)-2*sum(s[j:i])+i-j for i in range(n+1)for j in range(i))\n"}, {"source_code": "n=int(input())\nx=input().split()\na=[]\nfor i in x:\n\ta.append(int(i))\nq,w,e,r = 0,0,0,-1\nfor i in range(n):\n q+=a[i]\n w+=1-a[i]*2\n r=max(r,w-e)\n e=min(w,e)\nans = q+r\nprint(ans)\n'''\n\nn=int(input())\nx=input().split()\na=[]\nfor i in x:\n\ta.append(int(i))\nprint(max((sum(a)-2)*sum(a[i:j])+j-i for i in range(n)for j in range(i+1,n+1)))\n\n'''\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n'''a=[]\nflag=0\nans=0\nfor k in (0,1,1):\n\tprint(k)\nfor i in x:\n\ta.append(int(i))\nflag1=0\nfor i in range(n):\n\tif(a[i]==1):\n\t\tflag1+=1\nfor i in range(0,n,1):\n\tfor j in range(i,n,1):\n\t\tflag=0\n\t\tif(i!=j):\n\t\t\tfor k in range(i,j):\n\t\t\t\tif(a[k]==0):\n\t\t\t\t\tflag+=1\n\t\t\t\t\tans=max(ans,flag)\nif(ans==0):\n\tprint(0)\nelse:\n\tprint(ans+flag1)'''"}, {"source_code": "read_ints = lambda : map(int, raw_input().split())\n\ndef main():\n n = input()\n a = read_ints()\n c = a.count(1)\n ans = 0\n for i in range(n):\n for j in xrange(i, n):\n t = c\n for k in xrange(i, j+1):\n if a[k] == 1:\n t -= 1\n else:\n t += 1\n if t > ans:\n ans = t\n print ans\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "n = int(input())\n\na = list(map(int , input().split()))\n\nleft = 0\nright = 0\nif 0 not in a:\n print(n-1)\nelse:\n maxi = 0\n for i in range(n):\n for j in range(i,n):\n count = 0\n for k in range(n):\n if i<=k and k<=j:\n if a[k] == 0:\n count+=1\n else:\n if a[k] == 1:\n count+=1\n maxi = max(maxi , count)\n print(maxi)"}, {"source_code": "a = raw_input()\nb = [int(i) for i in raw_input().split(' ')]\ns = sum(b)\nres = []\nfor i in range(int(a)):\n if b[i] == 0:\n res.append(1)\n else:\n res.append(-1)\nRES = [res[0]]\nfor i in range(1,int(a)):\n r = max(RES[-1]+res[i],res[i])\n RES.append(r)\nm = max(RES)\nprint s+m\n"}, {"source_code": "n = input()\na = map(int, raw_input().split(' '))\n\nmaxi = 0\nfor i in range(n):\n for j in range(i, n):\n c = a[0:i:].count(1) + a[i:j+1:].count(0) + a[j+1:n:].count(1)\n if c > maxi:\n maxi = c\nprint maxi\n"}, {"source_code": "n=int(raw_input())\narr=[int(i) for i in raw_input().split()]\nno=0\nfor i in range(n):\n if arr[i]==1:\n no+=1\nfor i in range(n):\n if arr[i]==0:\n arr[i]=1\n else:\n arr[i]=-1\nme,ms=0,0\nfor i in range(n):\n me=max(0,me+arr[i])\n ms=max(ms,me)\nif ms==0:\n ms=-1\nprint ms+no\n\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\ncount = a.count(1)\nm = 0\nif len(a) == a.count(1):\n if len(a) == 1:\n print(0)\n else:\n print(len(a)-1)\nelse:\n \n for i in range(n):\n for j in range(i,n):\n if a[j] == 0:\n one = a[i:j].count(1)\n zer = a[i:j].count(0)\n if zer > one:\n maxi = zer-one\n if maxi > m:\n m = maxi\n\n print(m+count+1)"}], "negative_code": [{"source_code": "n = int(input())\nline = input().split()\nx = 0\nc = 0\noutput = 0\nfor i in range(n):\n if int(line[1])==1:\n c =c +1\nfor i in range(n):\n for t in range(i+1,n):\n for j in range(i,t):\n if int(line[j])==1:\n x = x+1\n s = t-i-2*x\n output = max(output,s)\n x = 0\noutput = output +c\nif c == len(line):\n output = output -1\nprint(output)\n \n \n"}, {"source_code": "# You lost the game.\nn = int(input())\nL = list(map(int, input().split()))\nT = [0 for _ in range(n)]\nT[0] = 1-L[0]\nfor i in range(1,n):\n T[i] = T[i-1]+1-L[i]\nprint(T[n-1])\n"}, {"source_code": "n=int(input())\ns=input().split()\n\nM=[[0]*n for _ in range(n)]\n\n\nnum=0\nfor i in range(n):\n if s[i]=='0':\n M[i][i]=1\n else:\n M[i][i]=-1\n num+=1\nMax=-1\n\nfor j in range(n-1,-1,-1):\n for i in range(j-1,-1,-1):\n if s[i]=='1':\n M[i][j]=M[i+1][j]-1\n else:\n M[i][j]=M[i+1][j]+1\n Max=max(M[i][j],Max)\n\n\nprint(num+Max)"}, {"source_code": "num = eval(input())\ndata = [eval(i) for i in input().split()]\ncount = data.count(1)\nbenchmark = -1\nfor i in range(num):\n for j in range(i, num):\n k = data[i:j].count(0) - data[i:j].count(1)\n benchmark = max(benchmark, k)\ncount = count + benchmark\nprint(count)"}, {"source_code": "n = int(input())\nmas = [int(x) for x in input().split()]\nif n == 1:\n\tif mas[0] == 1:\n\t\tprint(0)\n\t\traise SystemExit\n\telse:\n\t\tprint(1)\n\t\traise SystemExit\nif all(mas) == True:\n\tprint(n-1)\n\traise SystemExit\nfirst = mas.index(0)\nmas.reverse()\nlast = n - mas.index(0)\nmas.reverse()\nalkol1 = mas.count(1)\nkol1 = mas[first:last].count(1)\nkol0 = mas[first:last].count(0)\nprint(alkol1-kol1+kol0)"}, {"source_code": "n = int(input())\na = input()\nA = list(map(int,list(a.split())))\nfor i in range(n):\n if A[i] == 0:\n A[i] = -1\ntable = [0]*(n)\ntable[0] = A[0]\nfor i in range(1,n):\n table[i] = min(A[i],A[i]+table[i-1])\nc = 0\nd = 0\nm = min(table)\ni = 0\nwhile(i0:\n c = c+1\n i = i+1\n elif table[i] == m:\n j = i+1\n while(j Max.count('1'):\n Max = deepcopy(copy)\nprint(Max.count('1'))"}, {"source_code": "\n\n\n\ndef main():\n\n n = int(raw_input())\n\n if n ==1:\n\n nn = int(raw_input())\n return 1\n\n \n\n data = [int(s) for s in (raw_input()).split()]\n\n\n\n\n answer = max([((i,j), 2*(data[i:j].count(0)) - j +i +data[:i].count(1) +data[j:].count(1) ) for i in range(n) for j in range(i,n)] , key = lambda x: x[1])\n\n\n #print answer\n return answer[1]\n \n\n \n \nif __name__ ==\"__main__\":\n\n print main()"}, {"source_code": "n=int(input(\"\"))\nl=list(map(int,input().split()))\nmax1=0\nfor i in range(0,len(l)):\n count=0\n if(l[i]==1):\n count=1\n for j in range(i+1,len(l)):\n if(l[j]==0):\n count+=1\n elif(l[i]==1):\n count+=1\n if(max1 0:\n a_[-1] += v\n s_[-1] += v\n else:\n a_.append(v)\n s_.append(s_[-1] + v)\n\n# now find the maximum sum of the sub string of a_\nlow = s_[0]\nmax = -1\nfor e in s_[1:]:\n if (e - low) > max:\n max = e - low\n elif e < low:\n low = e\n\n\nprint count_1 + max\n"}, {"source_code": "x=int(raw_input())\nl=map(int, raw_input().split())\nw=sum(l)\ns=x-sum(l)\nf=[]\ng=[]\nfor i in range(x):\n for j in range(x):\n if i!=j:\n f.append([l[0:i].count(1)+l[i:j+1].count(1)+l[j+1:].count(1),\n l[0:i].count(1)+l[i:j+1].count(0)+l[j+1:].count(1)\n ])\nfor i in range(len(f)):\n g.append(f[i][0])\n g.append(f[i][1])\nif len(l) == 1:\n if l[0] == 0:\n print 1\n else:\n print 0\nelse:\n print max(g)"}, {"source_code": "n = int(input())\na = list(map(int, input().split()))\na.insert(0, 0)\n\nD = [[0] * 3 for i in range(n + 1)]\n\nif n == 1:\n print(1 - a[1])\nelse:\n for i in range(1, n + 1):\n D[i][0] = D[i - 1][0] + a[i]\n D[i][1] = max(D[i - 1][0], D[i - 1][1]) + (1 - a[i])\n D[i][2] = max(D[i - 1][0], D[i - 1][1], D[i - 1][2]) + a[i]\n\nprint(max(D[n][0], D[n][1], D[n][2]))"}, {"source_code": "# Lang: pypy3.6-v7.1.0-win32\\pypy3.exe\n# Problem Name: FlippingGame\n# Problem Serial No: 327\n# Problem Type: A\n# Problem Url: https://codeforces.com/problemset/problem/327/A \n# Solution Generated at: 2019-05-30 22:19:12.036155 UTC\nn = int(input())\narr = list(map(lambda x: -1 if int(x) > 0 else 1, input().split()))\ncn_1 = 0\nlocal_optimal, global_optimal = arr[0], arr[0]\nfor idx in range(1, n):\n num = arr[idx]\n local_optimal = max(num, local_optimal + num)\n global_optimal = max(local_optimal, global_optimal)\n if num == -1:\n cn_1 += 1\nprint(global_optimal + cn_1)\n\n# Accepted\n"}, {"source_code": "n = int(input())\nls = list(map(int, input().split()))\nary = [0 for i in range(n)]\n# val = 0\n# for i in range(n):\n # val += ls[i]\n # ary[i] = val\nb = [1 if not x else -1 for x in ls]\n\ns = 0\nma = -9e9\n# for i in range(n):\n # for j in range(i, n):\n # ma = max(ma, ary[i] - ls[i] + (j - i + 1 - (ary[j] - ary[i] )) + ary[-1] - ary[j])\n# print(ma)\n\nmast = 0\nmaend = 0\nst = 0\nend = 0\nfor i in range(n):\n s += b[i]\n if s > ma:\n mast = st\n maend = i\n ma = s\n\n if s < 0: \n s = 0\n st = i + 1\n\nprint(sum(ls[:mast]) + ma + sum(ls[maend:]))\n\n\n"}, {"source_code": "from sys import stdin\n\n\ndef main():\n n = int(stdin.readline().strip())\n l0 = list(map(int, stdin.readline().strip().split()))\n if sum(l0) == n > 0:\n return n - 1\n x, l = 0, [0]\n for y in l0:\n x += y * 2 - 1\n l.append(x)\n f = l.__getitem__\n lo = max(range(n + 1), key=f)\n hi = min(range(lo, n + 1), key=f)\n return sum(l0) + hi - lo - sum(l0[lo:hi])\n\nprint(main())\n"}, {"source_code": "#stdin.readline()\n#int(stdin.readline())\n#stdout.write()\n#raw_input()\n#map(int,raw_input().split())\n#map(int,stdin.readline().split())\ndef main():\n n=input()\n a=map(int,stdin.readline().split())\n z=0\n t=0\n for i in xrange(n):\n if a[i]==0:\n t+=1\n else:\n z=max(z,t)\n t=0\n z=max(z,t)\n if z==0:\n z=-1\n print sum(a)+z\nif __name__ == \"__main__\":\n from sys import stdin, stdout\n main()"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = sum(a)\nif n == 1:\n\tprint(1 - a[0])\nelif b == n:\n\tprint(n)\nelse:\n\tfor i in range(n):\n\t\tfor j in range(i, n):\n\t\t\tb = max(b, 1 + j - i - sum(a[i:j]) + sum(a[:i]) + sum(a[j:]))\n\tprint(b)"}, {"source_code": "n = int(input())\narr = input().split()\nscore = arr.count('1')\n\nif '0' in arr:\n\tstart = arr.index('0')\n\tend = n-1-arr[::-1].index('0')\n\tdiff = 0\n\tfor i in range(start, end):\n\t\tfor j in range(start+1, end+1):\n\t\t\ttemp = arr[i:j+1]\n\t\t\tzeroes = temp.count('0')\n\t\t\tones = temp.count('1')\n\t\t\tif zeroes>ones and zeroes-ones>diff:\n\t\t\t\tdiff = zeroes-ones\n\tprint(diff+score)\n\nelse:\n\tprint(n-1)\n"}, {"source_code": "n=int(input())\nx=input().split()\ny=[0for i in range(n)]\nS,s,m=0,0,0\nif n==1:\n print(1-int(x[0]))\nelse: \n for i in range(n):\n x[i]=int(x[i])\n S+=x[i]\n for i in range(n):\n for j in range(i,n):\n t=0\n for k in range(i-1,j+1):\n t+=x[k]\n s=j-i+2-2*t\n if m_max:\n start0=start\n end0=end\n _max=max_zeroes\n i+=1\nif start0==-1 and end0==-1:\n print(0)\nelse:\n if start0==0 and end0==n-1:\n print(n)\n elif start0==0 or end0==n-1:\n print(end0-start0+1+1)\n else:\n print(end0-start0+1+2)\n \n \n"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nb=[]\nfor i in range(n):\n if arr[i]==0:\n b.append(1)\n else:\n b.append(-1)\npref_sum=[]\n_sum=0\nfor i in range(n):\n _sum+=b[i]\n pref_sum.append(_sum)\n_max=0\nstart=-1\nend=-1\nfor i in range(n):\n for j in range(i+1,n):\n if pref_sum[j]-pref_sum[i]+b[i]>_max:\n start=i\n end=j\nif start==-1:\n if n==1:\n if arr[i]==0:\n print(1)\n else:\n print(0)\n else:\n print(0)\nelif start==0 and end==j:\n print(n)\nelif start==0 or end==j:\n print(end-start+1+1)\nelse:\n print(end-start+1+2)\n \n \n \n\n\n\n\n\n \n"}, {"source_code": "# Iahub got bored, so he invented a game to be played on paper.\n\n# He writes n integers a1,\u2009a2,\u2009...,\u2009an. Each of those integers can be either 0 or 1. He's allowed to do exactly one move: he chooses two indices i and j (1\u2009\u2264\u2009i\u2009\u2264\u2009j\u2009\u2264\u2009n) and flips all values ak for which their positions are in range [i,\u2009j] (that is i\u2009\u2264\u2009k\u2009\u2264\u2009j). Flip the value of x means to apply operation x\u2009=\u20091 - x.\n\n# The goal of the game is that after exactly one move to obtain the maximum number of ones. Write a program to solve the little game of Iahub.\n\n# Input\n# The first line of the input contains an integer n (1\u2009\u2264\u2009n\u2009\u2264\u2009100). In the second line of the input there are n integers: a1,\u2009a2,\u2009...,\u2009an. It is guaranteed that each of those n values is either 0 or 1.\n\n# Output\n# Print an integer \u2014 the maximal number of 1s that can be obtained after exactly one move.\n\n# Examples\n# inputCopy\n# 5\n# 1 0 0 1 0\n# outputCopy\n# 4\n# inputCopy\n# 4\n# 1 0 0 1\n# outputCopy\n# 4\n# Note\n# In the first case, flip the segment from 2 to 5 (i\u2009=\u20092,\u2009j\u2009=\u20095). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].\n\n# In the second case, flipping only the second and the third element (i\u2009=\u20092,\u2009j\u2009=\u20093) will turn all numbers into 1.\nn = int(input())\narr = [-1 if x==\"1\" else 1 for x in input().split()]\nglobal_max = 0\ncurrent_max = 0\nend = 0\nwhile end0:\n c = c+1\n i = i+1\n elif table[i] == m:\n j = i+1\n while(j maxs:\n\t\t\t\tmaxs = cmaxs\n\t\t\t\tj = x\n\t\telse: \n\t\t\teds = eds + 1\n\t\t\tif eds > maxed:\n\t\t\t\tmaxed = eds\n\t\t\tcmaxs = cmaxs - 1\n\nprint(maxs + maxed)\n"}, {"source_code": "n=int(input())\ns=[*map(int, input().split())]\nt=[s.index(0)]\n#print(t)\ng=[]\nc=1\nd=0\ni=t[0]+1\nprint(i)\nwhile(i1 and s[t[-2]:t[-1]].count(1)>=s[t[-2]:s[-1]].count(0):\n #i=len(s[:t[-1]])-s[:t[-1]-1][::-1].index(0)\n #c=1\nprint(g)\nm=max(g)\nhh=g.index(m)\nprint(m+s[:(t[hh]+1)].count(1)+s[t[hh+1]:].count(1))"}, {"source_code": "def solver():\n n = input()\n num = map(int, raw_input().split())\n \n one = 0\n maxim = 0\n if not (0 in num):\n print n\n return\n for i in range(0,n):\n if i != 0:\n if num[i-1] == 1:\n one += 1 \n temp_one = 0\n \n for j in range(i+1,n):\n if num[j] == 0:\n temp_one += 1\n else:\n temp_one -= 1\n x = num[j:].count(1)\n maxim = max(maxim, one+1+temp_one+x)\n #print maxim\n print maxim\n \n \n \n \nif __name__ == \"__main__\":\n solver()\n\n"}, {"source_code": "m = int(raw_input())\nz = map(int, raw_input().split())\nz.append(1)\ncount=0\nc={}\nfor i in range(m+1):\n if z[i]==0:\n count+=1\n else:\n c.update({count:i-count})\n count=0\nif c[max(c)]!=0:\n if c[max(c)]+max(c) maxCount:\n maxCount = temp.count(1)\n break\n\nprint maxCount\n"}, {"source_code": "n = int(input())\nsp = list(map(int, input().split()))\nif 0 in sp:\n d = 0\n d1 = 0\n for el in sp:\n print(el)\n if el == 0: d1 += 1\n else:\n if d1>d: d=d1;d1=0\n if d1>d: d=d1;d1=0\n print(sum(sp)+d)\nelse:\n print(len(sp)-1)"}, {"source_code": "q=input()\nn=input()\nl=list(n)\nm=len(l)\nd=[]\na=0\nx=0\nwhile l[a]==l[x]:\n x+=1\n if x 0:\n end = i\n res = i-start+1\nprint(sum(arr[:start]) + sum(arr[end+1:]) + end-start+1-sum(arr[start:end+1]))"}, {"source_code": "n=int(input())\narr=list(map(int,input().split()))\nif n==1:\n if arr[0]==1:\n print(0)\n else:\n print(1)\nelse:\n res=0\n for i in range(n):\n for j in range(i):\n temp=sum(arr[j:i+1])\n temp1=(i-j+1)-temp\n if temp>res:\n res=temp\n print(res+sum(arr))"}, {"source_code": "n=int(input())\ns=[int(i) for i in input().split()]\nli=list()\nif n==1:\n print(1)\nelse:\n r=1\n for i in range(2,len(s)+1):\n if int(s[i-1])==int(s[i-2]):\n r=r+1\n else:\n li.append(r)\n r=1\nprint(max(li))\n"}, {"source_code": "n = int(input())\nnums = list(map(int, input().split()))\npartial_sum = [None] * (n + 1)\npartial_sum[0] = 0\nfor i in range(1, n + 1):\n partial_sum[i] = partial_sum[i - 1] + nums[i - 1]\nmax_sum = 0\nmax_sum_first = partial_sum[-1]\nfor i in range(n):\n for j in range(i + 1, n + 1):\n s = partial_sum[j] - partial_sum[i]\n if (j - i - s) + max_sum_first > max_sum:\n max_sum = (j - i - s - s) + max_sum_first\nprint(max_sum)"}, {"source_code": "n=int(input())\nA=list(map(int,raw_input().split()))\nif(A.count(1)==n):\n print n-1\n exit()\nA=A+[1]\nmaximo=0\nco=0\nunos=0\nfor k in range(n+1):\n if(A[k]==0):\n co+=1\n else:\n if(maximo best_win:\n best_start = start\n best_end = end\n best_win = current_win\n else:\n flips -= 1\n \n count = 0\n index = 0\n \n if start == -1:\n count = len(array) - 1\n else:\n while index < len(array):\n if index == best_start:\n count += best_win\n index = best_end + 1\n else:\n if array[index] == '1':\n count += 1\n index += 1\n \n print count \n \nif __name__ == \"__main__\":\n num = raw_input()\n str = raw_input()\n str_array = str.split(' ')\n sys.exit(flipping_game(str_array))"}, {"source_code": "'''Author- Akshit Monga'''\nn=int(input())\narr=[int(x) for x in input().split()]\nval=arr.count(1)\nans=arr.count(1)\nfor i in range(0,n):\n for j in range(i,n):\n ans=max(ans,val+arr[i:j+1].count(0)-arr[i:j+1].count(1))\nprint(ans)"}, {"source_code": "n=int(input())\nl=list(map(int,input().split()))\na=[]\nb=[]\nx=0\ny=0\nfor i in l:\n if i==1:\n x+=1 \n else:\n y+=1\n a.append(x)\n b.append(y)\nh=0\nstart=0\nend=0\nfor i in range(1,n-1):\n for j in range(i,n):\n d=b[j]-b[i-1]\n if(d>h and d>a[j]-a[i-1]):\n h=d\n p=a[j]-a[i-1]\n start=i\n end=j\nfor i in range(start,end+1):\n l[i]=(1-l[i])\nif(start==1 and l[0]==0):\n l[0]=1\nprint(sum(l))\n \n"}, {"source_code": "n = int(input())\na = [int(i) for i in input().split()][:n]\nprint(max(sum(a)-3*sum(a[i:j])+j-i for i in range(n) for j in range(i+1,n+1)))\n"}, {"source_code": "n=int(raw_input())\nstr=raw_input()\nt=[]\ninitial=0\nsum=0\nfor i in range(0, n):\n t.append(int(str.split(\" \")[i]))\nfor i in range(0,n):\n sum=sum+t[i]\nif sum==n:\n print 0\nelif sum==0:\n print 1\nelse:\n\n for i in range(0, n - 1):\n for j in range(i + 1, n+1):\n t1 = []\n for k in range(i, j):\n t1.append(t[k])\n sum = 0\n for k in range(0, len(t1)):\n if t1[k] == 0:\n sum += 1\n elif t1[k] == 1:\n sum -= 1\n if sum > initial:\n initial = sum\n imax = i\n jmax = j\n for i in range(imax, jmax):\n t[i] = 1 - t[i]\n total = 0\n for i in range(0, n):\n total = total + t[i]\n print total\n\n\"\"\"\nsum0=[]\nsum0.append(1)\nj=0\nfor i in range(0,n-1):\n if t[i]==t[i+1]:\n sum[j]+=1\n else:\n j+=1\n sum.append(1)\nprint sum\n\"\"\""}, {"source_code": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Dec 11 16:47:18 2018\n\n@author: jinbin\n\"\"\"\n\nn=int(input());s=[int(i) for i in input().split()];a=m=sum(s)\nif 0 in s:\n for i in range(s.index(0),n):\n if s[i]:\n if not(s[i-1]):\n m=max(a,m)\n a-=1\n else:\n a+=1\nprint(m)"}, {"source_code": "n = int(input())\nnums = [int(x) for x in input().split()]\ncount = float('-inf')\n\nfor i in range(n):\n for j in range(n):\n count = max(count, nums[i:j + 1].count(0) - nums[i:j + 1].count(1) + nums.count(1))\n\nprint(count)\n\n"}, {"source_code": "n = int(input())\narr = list(map(int,input().split()))\nfiltered_arr =[]\nfor i in range(n):\n if arr[i] == 0:\n filtered_arr.append(1)\n else:\n filtered_arr.append(-1)\n\n# print(filtered_arr)\n\nmax_so_far = max_ending = start = end = 0\nfor i in range(n):\n max_ending += filtered_arr[i]\n if max_ending < 0:\n max_ending = 0\n start = i\n elif max_so_far < max_ending:\n max_so_far = max_ending\n end = i\n \n\n\ncount = 0;\nfor i in range(n):\n if i > start and i <= end:\n continue\n else:\n if arr[i] == 1:\n count+=1\n\nif max_so_far > 0:\n print(max_so_far + count)\nelse:\n print(n-1)\n\n \n \n "}, {"source_code": "def kadane(a):\n\tcurrMax = globalMax = a[0]\n\tfor i in range(1, len(a)):\n\t\tcurrMax = max(a[i], currMax+a[i])\n\t\tglobalMax = max(currMax, globalMax)\n\treturn globalMax\nn = int(input().strip())\narr = list(map(int, input().strip().split()))\ns = sum(arr)\nif s == n:\n\tprint(s-1)\nelse:\n\tb = [-1 if i else 1 for i in arr]\n\tprint(s+kadane(arr))\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\n\ncnt = 1\nc = 1\no = 0\nz = 0\n\nl = []\n\nfor i in range(n):\n if a[i] == 0:\n for j in range(i+1,n):\n if a[j] == 0:\n cnt +=1\n elif a[j] == 1:\n cnt-=1\n c = max(c,cnt)\n l.append(c)\n else:\n o+=1\nif z>0 :\n print(o + max(l))\nelse:\n print(n)\n "}, {"source_code": "n = int(input())\nl =[int(i) for i in input().split()]\nini_zeros = 0\nini_ones = 0\nrefer =[]\nresult = []\na = 0\nc = 0\nb =0\nreverse = []\nif sum(l) ==len(l):\n print(len(l)-1)\nelse:\n for i in range(len(l)):\n if l[i] == 0:\n ini_zeros+=1\n if i != 0 and l[i-1]==1:\n refer.append([ini_ones])\n ini_ones = 0\n if i == len(l)-1:\n refer.append([0,ini_zeros])\n else:\n ini_ones+=1\n if i != 0 and l[i-1] ==0:\n refer.append([0,ini_zeros])\n ini_zeros =0\n if i == len(l) - 1:\n refer.append([ini_ones])\n print(refer)\n for i in range(len(refer)):\n if refer[i][0] == 0:\n a +=refer[i][-1]\n result.append(a)\n else:\n a -= refer[i][-1]\n result.append(a)\n for i in range(1,len(refer)+1):\n if refer[-i][0] == 0:\n b +=refer[-i][-1]\n reverse.append(b)\n else:\n b -= refer[-i][-1]\n reverse.append(b)\n result.sort()\n reverse.sort()\n print(result)\n print(reverse)\n c = sum(l)+max(result[-1],reverse[-1])\n print(c)\n\n\n\n"}, {"source_code": "n=int(input())\nx=input().split()\ny=[0for i in range(n)]\nS,s,m=0,0,0\nif n==1:\n print(1-int(x[0]))\nelse: \n for i in range(n):\n x[i]=int(x[i])\n S+=x[i]\n for i in range(n):\n for j in range(i,n):\n t=0\n for k in range(i,j+1):\n t+=x[k]\n s=j-i+1-2*t\n if mmax:\n max=temp\nprint(max+2)\n"}, {"source_code": "n = int(input())\n_input = list(map(int,input().split()))\n\ndp = [[0,0,0] for i in range(n+1)]\n\nfor i in range(1,n+1):\n _one = 1 if _input[i-1] == 1 else 0\n dp[i][0] = dp[i-1][0] + _one\n dp[i][2] = max(dp[i-1]) + _one\n _one = 1 if _input[i-1] == 0 else 0\n dp[i][1] = max((dp[i-1][0],dp[i-1][1])) + _one\n\n\nprint(max(dp[n]))"}, {"source_code": "n=int(input())\nA=''.join(input().split())\nc1=A.count('1')\nA=A.split('1')\nA1=[]\nfor val in A:\n A1.append(len(val))\nA1=max(A1)\nprint(A1+c1)\n"}, {"source_code": "\n\n# target Expert \n\n# Author : raj1307 - Raj Singh\n# Date : 19.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 \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,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 \n\n n=ii()\n l=li()\n\n\n dp=[0]*n\n\n\n\n\n if l.count(1)==n:\n print(n-1)\n exit()\n\n\n\n\n\n dp[0]=1\n for i in range(1,n):\n c=0\n if l[i]==1:\n c=1\n\n\n dp[i]+=max(dp[i-1],dp[i-1]+1-l[i],dp[i-1])\n\n\n if dp[n-1]!=n:\n dp[n-1]+=l[-1]\n\n #print(dp)\n\n print(dp[n-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# 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": "I = lambda :map(int , raw_input().split())\nn = input()\na = I()\nb = []\nanswer = cnt = 1\nfor i in xrange(1 , n):\n if a[i] != a[i - 1]:\n b.append(cnt)\n cnt = 1\n else:\n cnt += 1\nb.append(cnt)\nprint b[0] - 1 * a[0] if len(b) == 1 else (sum(b) if len(b) == 2 else max(b[i] + b[i + 1] + b[i + 2] for i in range(len(b) - 2)))"}, {"source_code": "input()\nb = map(int,raw_input().split())\nswitcher = 0\ncounter = 0\nmin = 0\nindexstore = 0\nindex = 1\ntester = 0\ntotalcount = 0\nfor item in b:\n if counter >=0:\n switcher = 0\n counter = 0 \n if item ==0:\n if switcher ==0:\n firstindex = index\n counter -=1\n switcher = 1\n if item ==1 and switcher ==1:\n counter +=1\n if min>counter:\n min = counter\n indexstore = index\n tempindex = firstindex\n index +=1 \nprint tempindex\nprint indexstore\nfor i in range(0,tempindex-1):\n if b[i] ==1:\n totalcount += 1\nfor i in range(tempindex-1,indexstore):\n if b[i] ==0:\n totalcount +=1\nfor i in range(indexstore,len(b)):\n if b[i] ==1:\n totalcount +=1\nprint totalcount"}, {"source_code": "if __name__=='__main__':\n N = int(raw_input())\n inp = raw_input()\n arr = inp.split()\n ind = 0\n ans = 0\n con = 0\n flag = False\n for i in arr:\n if i=='0':\n flag = True\n ind+=1\n else:\n ans+=1\n con = max(con,ind)\n ind=0\n print ans+con\n"}, {"source_code": "input()\na = input().split(\" \") + [\"1\"]\nm, p, c = 0, -1, 0\n\nfor i in range(0, len(a)):\n if a[i] == '1':\n c += 1\n m = max(m, i - p - 1)\n p = i\n\nm = m + c - 1\n\nif c == len(a):\n print(m - 1)\nelse:\n print(m)\n\n\n"}, {"source_code": "n = int(input())\na = [int(x) for x in input().split()]\nb = sum(a)\nif b == n:\n\tprint(n)\nelse:\n\tfor i in range(n):\n\t\tfor j in range(i + 1, n):\n\t\t\tb = max(b, j - i - sum(a[i:j]) + sum(a[:i]) + sum(a[j:]))\n\tprint(b)"}, {"source_code": "n = int(input())\ns = list(map(str,input().split()))\nans = 0\nzero = 0\nMAX_ZERO = -float('inf')\nfor i in range(n):\n if s[i] == '1':\n ans+=1\n if zero > MAX_ZERO:\n MAX_ZERO = zero\n zero = 0\n else:\n zero+=1\nzero = max(zero, MAX_ZERO)\nprint(zero+ans)\n"}, {"source_code": "n = input()\na = map(int, raw_input().split())\n\nprint max([(a[i:j].count(0)-sum(a[i:j])) for i in xrange(n) for j in xrange(1, n+1)])+sum(a)\n\n"}, {"source_code": "from sys import stdin\n\ndef inp():\n return stdin.readline().strip()\n\nn = int(inp())\nones = 0\nlongest = 0\nstreak = 0\nbegin = 0\nzero = False\na = [int(x) for x in inp().split()]\nfor i in range(n):\n if a[i] == 1:\n if not zero:\n begin+=1\n else:\n ones += 1\n if streak > 0:\n longest = max(longest, streak)\n streak = 0\n elif a[i] == 0:\n streak+=1\n zero = True\nlongest = max(longest, streak)\nif not zero:\n print(0)\nelse:\n lens = n - begin\n ans2 = begin + (lens-ones)\n print(max(ans2, longest+begin+ones))"}, {"source_code": "n = int(input())\na = input().split()\n\nmaxSoFar = max(a.count('1'),a.count('0'))\n\nfor i in range(n):\n for j in range(i+1):\n maxSoFar = max(maxSoFar,(a[:j]+a[i+1:]).count('1')+a[j:i+1].count('0'))\nprint(maxSoFar)\n"}, {"source_code": "import re\nregexp = re.compile('[0]+')\n\nn = input()\n_input = list(map(int,input().split()))\ncount_1 = 0\nfor x in _input:\n if x == 1:\n count_1 += 1 \nstr = ''.join(map(str,_input))\ntmp = regexp.findall(str)\n_max = 0\nif tmp:\n _max = max([len(x) for x in tmp])\nprint(_max + count_1)\n"}, {"source_code": "n=input()\nline=[int(i) for i in input().split()]\nif len(line)>1:\n s=0\n for i in range(0,len(line)-1):\n for j in range(i+1,len(line)+1):\n for k in range(i-1,j):\n line[k]=1-line[k]\n if sum(line)>s:\n s=sum(line)\nelse:\n if line[0]==1:\n s=0\n else:\n s=1\nprint(s)\n\n\n"}, {"source_code": "n = int(input())\nl = list(map(int,input().split()))\n\nm = 0\nc = 0\nx = 0\nfor i in range(n):\n if l[i] == 1:\n x += 1\n m = max(m,c)\n c = 0\n else:\n c += 1\nm = max(m,c)\nif m == 0:\n m = -1\nprint(m+x)"}, {"source_code": "x = int(input())\nli = list(map(int, input().split()))\ntry:\n\ta = li.index(0)\nexcept:\n\tprint(x)\n\texit()\nans, cnt, b = 0,0, a\nfor i in li[a:]:\n\tcnt += -1 if i else 1\n\tb +=1\n\tans = max(ans, cnt + li[a:].count(1))\nprint(a + ans)"}, {"source_code": "n = int(input())\n\nls = list(map(int,input().split()))\n \ndef flipping(ls,i = 0, j = 0, result = []):\n return i == len(ls) and str(max(result)) or \\\n j == len(ls[i:]) and flipping(ls,i+1,0,result) or \\\n flipping(ls,i,j+1,result + \\\n [sum(ls[:i] + [0 if n == 1 else 1 for n in ls[i:j+1]] + ls[j+1:])])\n\nprint(flipping(ls))"}, {"source_code": "import re\nregexp = re.compile('[0]+')\n\nn = input()\n_input = list(map(int,input().split()))\ncount_1 = 0\nfor x in _input:\n if x == 1:\n count_1 += 1\nstr = ''.join(map(str,_input))\ntmp = regexp.findall(str)\n_max = 0\nif tmp:\n _max = max([len(x) for x in tmp])\nelse:\n count_1 -= 1\nprint(_max + count_1)"}, {"source_code": "import re\nregexp = re.compile('[0]+')\n\nn = input()\n_input = list(map(int,input().split()))\ncount_1 = 0\nfor x in _input:\n if x == 1:\n count_1 += 1 \nstr = ''.join(map(str,_input))\ntmp = regexp.findall(str)\n_max = 0\nif tmp:\n _max = max([len(x) for x in tmp])\nprint(_max + count_1)\n"}, {"source_code": "def flip(l,a,b):\n for i in range(a,b):\n if l[i] == 1:\n l[i] = 0\n else:\n l[i] = 1\n\n return l\n\ndef solver():\n n = input()\n num = map(int, raw_input().split())\n maxim = 0\n if n == 1:\n if num[0] == 0:\n print 1\n else:\n print 0\n\n return\n\n\n for i in range(0,n):\n for j in range(i,n+1):\n new_b = num[:]\n new_b = flip(new_b,i,j)\n maxim = max(maxim,new_b.count(1))\n #print new_b\n\n print maxim\n\n\nif __name__ == \"__main__\":\n solver()\n\n"}, {"source_code": "n = int(input())\nl1 = [int(i) for i in input().split()]\n\n#find the maximum distance between two consecutive ones\nif l1 == 1:\n print(0)\nelif l1.count(1) == 0:\n print(n)\nelif l1.count(1) == 1:\n getidx = l1.index(1)\n print(max(getidx + 1, n - getidx + 1))\nelse:\n posi = []\n for i in range(n):\n if l1[i] == 1:\n posi.append(i)\n\n max1 = 0\n prev = 0\n #print(posi)\n for i in posi:\n temp = i - prev\n prev = i\n if temp > max1:\n max1 = temp\n print(max1 + 1)"}, {"source_code": "n = int(input())\nlst = [int(x) for x in input().split()]\n\ncur_num = sum(x==1 for x in lst)\ndef trans(x):\n return -1 if x==1 else 1\nsum_lst = [0]\nfor el in lst:\n sum_lst.append(lst[-1]+trans(el))\n\n#we need all sums from i inclusive to j exclusive, 0<=imax_sum:\n max_sum = cur\nprint(max_sum+cur_num)"}, {"source_code": "\n\na = int(input())\n\n\nt = list(map(int,input().split()))\n\ne = t.count(1)\n\n\n\nfor k in range(a+1):\n for j in range(k+1,a+1):\n p=t[k:j]\n q=t[0:k]\n s=t[j:] \n z= q.count(1)+p.count(0)+s.count(1)\n\n \n if z>e:\n e=z\n \n\nprint(e)\n"}, {"source_code": "import sys\n\ninput = sys.stdin.readline()\nn = int(input)\ninput = sys.stdin.readline()\ndigits = map(int, input.split(' '))\n\nmax_sum = -1000\nmax_i = 0\nmax_j = 0\n\nfor i in range(n):\n\tfor j in range(n):\t\t\n\t\t\t\t\n\t\ttemp_sum = 0;\n\t\t\n\t\tfor k in range(n):\n\t\t\t\n\t\t\tif k >= i and k <= j:\n\t\t\t\ttemp_sum += 1 - digits[k]\n\t\t\telse:\n\t\t\t\ttemp_sum += digits[k]\n\t\t\t\n\t\t\t#print \"i: %i, j: %i, k: %i, temp_summ: %i\" % (i, j, k, temp_sum)\n\t\t\t\n\t\tif temp_sum > max_sum:\n\t\t\tmax_sum = temp_sum\n\t\t\tmax_i = i\n\t\t\tmax_j = j\n\nprint \"%i\" % (max_sum)\n"}, {"source_code": "n = int(input())\nbits = list(map(int, input().split()))\nones = bits.count(1)\nMax = ones\n\nfor i in range(n):\n for j in range(i, n):\n inv = bits[i:j+1]\n cur = ones-inv.count(1)\n Max = max(Max, cur+inv.count(0))\n\nprint(Max)"}, {"source_code": "n = int(input())\nl1 = [int(i) for i in input().split()]\n\n#find the maximum distance between two consecutive ones\nif l1 == [1]:\n print(0)\nelif l1.count(1) == 0:\n print(n)\nelif l1.count(1) == 1:\n getidx = l1.index(1)\n print(max(getidx + 1, n - getidx + 1))\nelse:\n posi = []\n for i in range(n):\n if l1[i] == 1:\n posi.append(i)\n\n max1 = 0\n prev = 0\n #print(posi)\n for i in posi:\n temp = i - prev\n prev = i\n if temp > max1:\n max1 = temp\n print(max1 + 1)"}, {"source_code": "read_ints = lambda : map(int, raw_input().split())\n\ndef main():\n n = input()\n a = read_ints()\n c = a.count(1)\n ans = c\n for i in range(n):\n for j in xrange(i, n):\n t = c\n for k in xrange(i, j+1):\n if a[k] == 1:\n t -= 1\n else:\n t += 1\n if t > ans:\n ans = t\n print ans\n\nif __name__ == '__main__':\n main()\n"}, {"source_code": "import sys\n\ns = sys.stdin.readline()\nn = int(s.split()[0])\n\ns = sys.stdin.readline()\narr = map(int, s.split())\n\nmaxSum = 0\ncurSum = 0\n\nsumOnes = 0\nfor i in arr:\n\tsumOnes += i\n\tif (i & 1):\n\t\tif (curSum > maxSum):\n\t\t\tmaxSum = curSum\n\t\tif (curSum == 0):\n\t\t\tcontinue\n\t\tcurSum -= 1\n\telse: curSum += 1\n\nif maxSum > curSum:\n\tmaxSum += sumOnes\nelse: maxSum = curSum + sumOnes\n\nprint(maxSum)\n#1 0 0 1 1 0 0 0 1 0 1 0 0 1 1\n"}, {"source_code": "n = int(input())\nnum_lst = [int(i) for i in input().split()]\noutput = []\nif n == num_lst.count(1):\n print(n-1)\nelse:\n for i in range(n):\n for j in range(n):\n total = 0\n lst1 = num_lst[i:j]\n lst2 = num_lst[:i]\n lst3 = num_lst[j:]\n total += lst1.count(1)+lst2.count(0)+lst3.count(1)\n output.append(total)\n print(max(output))\n"}, {"source_code": "#credit hyperhyperhypercubelover\nx = int(input())\nli = list(map(int, input().split()))\nans = 0\nfor i in range(1,x):\n\tli[i]+= li[i-1]\nfor i in range(x-1):\n\tfor j in range(i+1,x):\n\t\tans = max(ans, li[i] + li[x-1]-li[j] + j-i - li[j]+ li[i])\nprint(ans)"}, {"source_code": "# cook your dish here\nn=int(input())\na=list(map(int,input().rstrip().split()))\ntillnoq=0\ncount1=0\ncount0=0\nif n==1 and a[0]==1:\n print(1)\nelif n==1 and a[0]==0:\n print(0)\nelse:\n for i in range (n):\n for j in range (i,n):\n if a[j]==1:\n count1+=1\n else:\n count0+=1\n #print(count0,count1,i,j)\n numzeroabs=count0-count1\n if numzeroabs>tillnoq:\n left=i\n right=j\n tillnoq=numzeroabs\n #print(numzeroabs)\n count0=0\n count1=0\n cntr=0 \n for i in range (left):\n if a[i]==1:\n cntr+=1\n for i in range (right,n):\n if a[i]==1:\n cntr+=1\n\n print(cntr+tillnoq)\n"}, {"source_code": "n = int(input())\n\ns=input().split()\n\nfor i in range(n):\n s[i]=int(s[i])\n\n\n\nans=sum(s)\nif(len(s)==1):\n print(1-s[0])\nelif(s.count(0)==len(s)):\n print(len(s))\nelif(s.count(1)==len(s)):\n print(sum(s)-1)\nelse:\n r=0\n if(s[0]==0):\n s=[1]+s\n r=1\n L=[0]\n for i in range(1,n):\n if(s[i]!=s[i-1]):\n L.append(i)\n L.append(n)\n m=len(L)\n maxx=0\n for i in range(2,m,2):\n ans=sum(s)-r+L[i]-L[i-1]\n for j in range(i+2,m,2):\n if(ans+L[j]-L[j-1]-(L[j-1]-L[j-2])>ans):\n ans=ans+L[j]-L[j-1]-(L[j-1]-L[j-2])\n continue\n else:\n break\n if(ans>maxx):\n maxx=ans\n print(maxx)\n \n \n"}], "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99"} {"nl": {"description": "Two players play a simple game. Each player is provided with a box with balls. First player's box contains exactly n1 balls and second player's box contains exactly n2 balls. In one move first player can take from 1 to k1 balls from his box and throw them away. Similarly, the second player can take from 1 to k2 balls from his box in his move. Players alternate turns and the first player starts the game. The one who can't make a move loses. Your task is to determine who wins if both players play optimally.", "input_spec": "The first line contains four integers n1,\u2009n2,\u2009k1,\u2009k2. All numbers in the input are from 1 to 50. This problem doesn't have subproblems. You will get 3 points for the correct submission.", "output_spec": "Output \"First\" if the first player wins and \"Second\" otherwise.", "sample_inputs": ["2 2 1 2", "2 1 1 1"], "sample_outputs": ["Second", "First"], "notes": "NoteConsider the first sample test. Each player has a box with 2 balls. The first player draws a single ball from his box in one move and the second player can either take 1 or 2 balls from his box in one move. No matter how the first player acts, the second player can always win if he plays wisely."}, "positive_code": [{"source_code": "l=input().split()\nif int(l[0])<=int(l[1]):\n print(\"Second\")\nelse:\n print(\"First\")"}, {"source_code": "b = list(map(int, input().split()))\ni = 0\nif b[0] > b[1]:\n print('First')\nelse:\n print('Second')\n"}, {"source_code": "a=input().split()\nif int(a[0])>int(a[1]):\n\tprint(\"First\")\nelse:\n\tprint(\"Second\")\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\n\nif n1>n2:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "numbers = raw_input().split(\" \")\nplayer1Box = int(numbers[0])\nplayer2Box = int(numbers[1])\nplayer1Balls = int(numbers[2])\nplayer2Balls = int(numbers[3])\n\n\nif player1Box <= player2Box:\n\tprint \"Second\"\nelse:\n\tprint \"First\""}, {"source_code": "n1, n2, k1, k2 = map(int, input().split())\nif n1 > n2:\n print('First')\nelse:\n print('Second')"}, {"source_code": "n1, n2, k1, k2 = map(int, input().split())\nif n2 >= n1:\n print('Second')\nelse:\n print('First')\n"}, {"source_code": "# int(input())\n# [int(s) for s in input().split()]\n# input()\n \n \ndef solve():\n n1 ,n2, k1, k2 = [int(s) for s in input().split()]\n if n1 <= n2:\n print(\"Second\")\n else:\n print(\"First\")\n \n \n \nif __name__ == \"__main__\":\n solve()"}, {"source_code": "import sys\n\ntry:\n for line in iter(sys.stdin.readline, b''):\n parts = line.split() \n n1 = int(parts[0])\n n2 = int(parts[1])\n if n1 == n2:\n print \"Second\\n\"\n elif n1 > n2:\n print \"First\\n\"\n else:\n print \"Second\\n\"\nexcept KeyboardInterrupt:\n sys.stdout.flush()\n pass\n\n"}, {"source_code": "n1,n2,k1,k2 = map(int, input().split())\nif n1>n2:\n print('First')\nelse:\n print('Second')"}, {"source_code": "a, b, c, d=map(int, input().split())\nif a>b:\n print(\"First\")\nelse:\n print(\"Second\")\n \n "}, {"source_code": "a=input().split()\nif int(a[0])>int(a[1]):\n\tprint(\"First\")\nelse:\n\tprint(\"Second\")\n"}, {"source_code": "n1, n2, k1, k2 = list(map(lambda x: int(x), input().split(\" \")))\n\nif n1 > n2:\n print('First')\nelse:\n print('Second')\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\n\nif n1 <= n2:\n print 'Second'\nelse:\n print 'First'"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "import sys\nn1,n2,k1,k2=raw_input().split()\nn1=int(n1)\nn2=int(n2)\n\n\nif n1 == n2 :\n\tprint \"Second\\n\"\nelif n1 > n2 :\n\tprint \"First\\n\"\nelse:\n\tprint \"Second\\n\"\n"}, {"source_code": "n,k,A,B = [int(x) for x in input().split()]\nif n==k:\n print('Second')\nelif n>k:\n print('First')\nelse:\n print(\"Second\")\n# 1512497245763\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nif a==b:\n print('Second')\nelif a>b:\n print('First')\nelse:\n print('Second')"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nwhile 1:\n if a==0:\n print 'Second'\n break\n if b==0:\n print 'First'\n break\n a-=1\n b-=1\n"}, {"source_code": "n1,n2,_,_=map(int,raw_input().split())\nprint [\"Second\",\"First\"][n1>n2]"}, {"source_code": "# Game\n[n1, n2, k1, k2] = map(int, raw_input().split())\n\nif n1 > n2:\n print 'First'\nelse:\n print 'Second'\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split(\" \"))\nif n2>=n1:\n print(\"Second\")\nelse:\n print(\"First\")"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nwhile(True):\n\tn1=n1-1\n\tif(n1==0 and n2>0):\n\t\tprint(\"Second\")\n\t\tbreak\n\telif(n2==0 and n1>0):\n\t\tprint(\"First\")\n\t\tbreak\n\telif(n1==0 and n2==0):\n\t\tprint(\"Second\")\n\t\tbreak\n\tn2=n2-1\n\tif(n1==0 and n2>0):\n\t\tprint(\"Second\")\n\t\tbreak\n\telif(n2==0 and n1>0):\n\t\tprint(\"First\")\n\t\tbreak\n\telif(n1==0 and n2==0):\n\t\tprint(\"Second\")\n\t\tbreak\n\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\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\nn1, n2, k1, k2 = rints()\n\nif n1 > n2 :\n print 'First'\nelse :\n print 'Second' \n"}, {"source_code": "import sys\nn1,n2,k1,k2=raw_input().split()\nn1=int(n1)\nn2=int(n2)\n\n\nif n1 == n2 :\n\tprint \"Second\\n\"\nelif n1 > n2 :\n\tprint \"First\\n\"\nelse:\n\tprint \"Second\\n\"\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\ndp = [[[-1] * 51] * 51] * 2\ndef win(n1,n2,p = 0):\n if dp[p][n1][n2] != -1:\n return dp[p][n1][n2]\n if p:\n for i in range(1,k2 + 1):\n if n2 - i > -1 and win(n1,n2 - i,1 - p) == False:\n dp[p][n1][n2] = True\n return True\n else:\n for i in range(1,k1 + 1):\n if n1 - i > -1 and win(n1 - i,n2,1 - p) == False:\n dp[p][n1][n2] = True\n return True\n dp[p][n1][n2] = False\n return False\nprint ('First' if win(n1,n2) else 'Second')"}, {"source_code": "n1 , n2 , k1 , k2 = map(int,input().split())\n\nif n1 > n2 :\n print('First')\n\nelse:\n print('Second')"}, {"source_code": "a,b=map(int,raw_input().split())[:2]\nprint['Second','First'][b n2:\n print(\"First\")\n else:\n print(\"Second\")\n \ngame()\n"}, {"source_code": "#513A\n[n1,n2,k1,k2] = list(map(int,input().split()))\nif n1 <= n2:\n print('Second')\nelse:\n print('First')"}, {"source_code": "a,b,c,d=map(int,input().split())\nif a==b:\n print('Second')\nelif a>b:\n print('First')\nelse:\n print('Second')"}, {"source_code": "a=input().split()\nx=int(a[0])\ny=int(a[1])\np=int(a[2])\nq=int(a[3])\nm=0\nn=0\nr=min(p,q)\nwhile(x>0 and y>0):\n x=x-1\n if(x<=0):\n break\n m=m+1\n y=y-1\n if(y<=0):\n break\n n=n+1\nif(m>n):\n print(\"First\")\nelse:\n print(\"Second\")\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\n\nif n1 <= n2:\n print 'Second'\nelse:\n print 'First'"}, {"source_code": "n1,n2,k1,k2=map(int,input().strip().split(' '))\nif n1>n2:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "a = map(int,raw_input().split())\nif a[0] > a[1]:\n\tprint 'First'\nelse:\n\tprint 'Second'"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nif a>b:\n print \"First\"\nelse:\n print\"Second\""}, {"source_code": "n1,n2,k1,k2=input().split()\nn1,n2=int(n1),int(n2)\nif n1>n2:\n print('First')\nelif n1<=n2:\n print('Second')"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\n\nif n1>n2:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "def ret_input():\n data = [int(x) for x in raw_input().split()]\n return data\n\ndef game(data):\n n1 = data[0]\n n2 = data[1]\n k1 = data[2]\n k2 = data[3]\n if n1 > n2:\n return 'First'\n else:\n return 'Second'\n\ndef main():\n data = ret_input()\n print game(data)\n\nif __name__ == '__main__':\n main()"}, {"source_code": "balls_p1, balls_p2, max_takes_p1, max_takes_p2 = map(int, input().split())\nprint('First' if balls_p1 > balls_p2 else 'Second')\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\n\nif n1 <= n2:\n print 'Second'\nelse:\n print 'First'"}, {"source_code": "n1,n2,k1,k2 = map(int, raw_input().split())\n\nif n1 > n2:\n\tprint 'First'\nelse:\n\tprint 'Second'\n"}, {"source_code": "a = map(int, raw_input().split())\nprint ('Second', 'First')[a[1] < a[0]]"}, {"source_code": "l=[int(x) for x in raw_input().split()]\nif l[0]>l[1]:\n\tprint \"First\"\nelif l[0] n2 else 'Second')\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "l=input().split()\nq=0\nif int(l[0])<=int(l[1]):\n print(\"Second\")\nelse:\n print(\"First\")"}, {"source_code": "n1, n2, _, _ = map(int, raw_input().split())\n\nprint \"First\" if n1 > n2 else \"Second\"\n"}, {"source_code": "w = list(map(int, input().split()))\nprint('First')if(w[0] > w[1]) else print(\"Second\")"}, {"source_code": "a=input().split()\nx=int(a[0])\ny=int(a[1])\np=int(a[2])\nq=int(a[3])\nm=0\nn=0\nr=min(p,q)\nwhile(x>0 and y>0):\n x=x-1\n if(x<=0):\n break\n m=m+1\n y=y-1\n if(y<=0):\n break\n n=n+1\nif(m>n):\n print(\"First\")\nelse:\n print(\"Second\")\n"}, {"source_code": "n1,n2,k1,k2 = map(int,raw_input().split())\nans = \"\"\nif n1 == n2:\n ans = \"Second\"\nelse:\n ans = \"First\" if n1 > n2 else \"Second\"\nprint ans\n"}, {"source_code": "import sys\n\ninput = sys.stdin\noutput = sys.stdout\n\n# input = open('input.txt')\n\n# n = int(input.readline().strip())\nn1, n2, _, _ = [int(x) for x in input.readline().strip().split()]\n\nif n1 > n2:\n output.write('First\\n')\nelse:\n output.write('Second\\n')\n\n# output.write('%d\\n' % max(d))\n\n\n\n\n\n\n"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nif a>b:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "n1, n2, k1, k2 = map(int, input().split())\n\nif n1 == n2:\n print('Second')\n \nelif n1 > n2:\n print('First')\nelif n1 < n2:\n print('Second')\n \n \n \n"}, {"source_code": "n1, n2, k1, k2 = list(map(int, input().split()))\n\nprint( \"First\" if n1 > n2 else \"Second\" )"}, {"source_code": "import sys\n\ndef main():\n \n n1,n2,k1,k2 = map(int, sys.stdin.readline().split())\n\n if n1 <= n2:\n sys.stdout.write('Second')\n else:\n sys.stdout.write('First')\n\nif __name__ == '__main__':\n main()"}, {"source_code": "a,b,c,d=map(int,input().split())\nprint([\"Second\",\"First\"][a>b])"}, {"source_code": "L=[int(x) for x in raw_input().split()]\nif L[0]>L[1]:\n print \"First\"\nelse:\n print \"Second\"\n"}, {"source_code": "[n1, n2, k1, k2] = [int(x) for x in input().split()]\nprint('First' if n1 > n2 else 'Second')\n"}, {"source_code": "n,m,a,b=map(int,input().split(\" \"))\nif n>m:\n\tprint(\"First\")\nelif m>n:\n\tprint(\"Second\")\nelif m==n:\n\tprint(\"Second\")"}, {"source_code": "a,b,c,d=[int(i) for i in input().split()]\nans=0\nwhile(a>0 or b>0):\n a=a-1\n if(a<=0):\n ans='Second'\n break\n b=b-1\n if(b<=0):\n ans='First'\n break\n if(a<=0 or b<=0):\n break\nprint(ans)\n"}, {"source_code": "w = list(map(int, input().split()))\nif(w[0] > w[1]):\n print('First')\nelse:\n print(\"Second\")"}, {"source_code": "n1,n2,k1,k2=map(int,input().strip().split(' '))\nif n1>n2:\n print(\"First\")\nelse:\n print(\"Second\")\n"}, {"source_code": "n1,n2,k1,k2 = [int(i) for i in input().split()[:4]]\n\nj=0\nwhile(n1!=0 and n2!=0):\n if(j%2==0):\n n1 = n1-1\n else:\n n2 = n2-1\n j+=1\n\n\nif(n1==0):\n print(\"Second\")\nelse:\n print(\"First\")\n"}, {"source_code": "n,k,A,B = [int(x) for x in input().split()]\nif n==k:\n print('Second')\nelif n>k:\n print('First')\nelse:\n print(\"Second\")\n# 1512497245763\n"}, {"source_code": "n1,n2,k1,k2 = map(int, raw_input().split())\nif n1 > n2:\n\tprint \"First\"\nelif n2 > n2:\n\tprint \"Second\"\nelse:\n\tprint\"Second\""}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\ns=[\"Second\",\"First\"]\nprint(s[n1>n2])"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n\tprint(\"First\")\nelif n1a[1]:\n\tprint \"First\"\nelse:\n\tprint \"Second\""}, {"source_code": "m,n,k,l=map(int,input().split())\nif m==n:\n print(\"Second\")\nelif m>n:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "[n1,n2,k1,k2]=[int(i) for i in raw_input().strip().split()]\nFlag=False\nif n1==0:\n print \"Second\"\n Flag=True\nif n2==0:\n print \"First\"\n Flag=True\nwhile n1>=0 and n2>=0 and Flag==False:\n n1-=1\n \n if n1<0:\n print 'Second'\n break\n n2-=1\n \n if n2<0:\n print 'First'\n break\n"}, {"source_code": "n1,n2,k1,k2=input().split()\nn1,n2,k1,k2=int(n1),int(n2),int(k1),int(k2)\nif n1>n2:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "def solve(n1,n2,k1,k2):\n if(n1>n2):\n return \"First\"\n else:\n return \"Second\"\nn1,n2,k1,k2=map(int,input().split())\nprint(solve(n1,n2,k1,k2))"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\ndp = [[[-1] * 51] * 51] * 2\ndef win(n1,n2,p = 0):\n if dp[p][n1][n2] != -1:\n return dp[p][n1][n2]\n if p:\n for i in range(1,k2 + 1):\n if n2 - i > -1 and win(n1,n2 - i,1 - p) == False:\n dp[p][n1][n2] = True\n return True\n else:\n for i in range(1,k1 + 1):\n if n1 - i > -1 and win(n1 - i,n2,1 - p) == False:\n dp[p][n1][n2] = True\n return True\n dp[p][n1][n2] = False\n return False\nprint ('First' if win(n1,n2) else 'Second')"}, {"source_code": "n1,n2,k1,k2=map(int,raw_input().split())\nif n1==n2:\n print \"Second\"\nelif n1>n2:\n print \"First\"\nelse:\n print \"Second\"\n"}, {"source_code": "[n1,n2,k1,k2]=[int(i) for i in raw_input().strip().split()]\nFlag=False\nif n1==0:\n print \"Second\"\n Flag=True\nif n2==0:\n print \"First\"\n Flag=True\nwhile n1>=0 and n2>=0 and Flag==False:\n n1-=1\n \n if n1<0:\n print 'Second'\n break\n n2-=1\n \n if n2<0:\n print 'First'\n break\n"}, {"source_code": "a,b,c,d=map(int,input().split())\nif a>b:\n print(\"First\")\nelse :\n print(\"Second\")\n"}, {"source_code": "\nl=list(map(int,input().split()))\nwhile True :\n\tl[0]=l[0]-1\n\tif l[0]<0:\n\t\tprint(\"Second\")\n\t\tbreak\n\tl[1]=l[1]-1\n\tif l[1]<0:\n\t\tprint(\"First\")\n\t\tbreak"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif k2>k1:\n if (n1<=n2):\n print(\"Second\")\n elif n1>n2:\n print(\"First\")\nelif k1==k2:\n if n1>n2:\n print(\"First\")\n elif n1<=n2:\n print(\"Second\")\n \nelse:\n if (n1==n2)or(n1n2:\n print(\"First\")\n \n\n"}, {"source_code": "x1, x2, y1, y2 = map(int, input().split())\n\nif x1+y2 > x2+y2:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "n1,n2,k1,k2=map(int,raw_input().split())\n\nif n1>n2:\n print \"First\"\nelse :\n print \"Second\"\n \n1"}, {"source_code": "n1,n2,k1,k2=map(int,raw_input().split(' '))\nprint 'First' if(n1>n2) else 'Second'"}, {"source_code": "n,k,l,r= map(int, input().split())\nif (k>=n):\n print ('Second')\nelse :\n print('First')"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1==n2:\n print(\"Second\")\nelif n1n2:\n print(\"First\")\n\n"}, {"source_code": "n1, n2, k1, k2 = [int(i) for i in input().split()]\n\nif (n1 > n2):\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "a=input().split()\nif int(a[0])>int(a[1]):\n\tprint(\"First\")\nelse:\n\tprint(\"Second\")\n"}, {"source_code": "y=input()\nn_1,n_2,k_1,k_2=y.split()\nn_1=int(n_1)\nn_2=int(n_2)\na=\"First\"\nb=\"Second\"\n\nif n_1==n_2:\n print(b)\nelif n_1>n_2:\n print(a)\nelse:\n print(b)\n\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().strip().split())\n\nif n1 > n2:\n\tprint \"First\"\n\nelse:\n\tprint \"Second\"\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1<=n2:\n print(\"Second\")\nelse:\n print(\"First\")"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\ns=[\"Second\",\"First\"]\nprint(s[n1>n2])"}, {"source_code": "from sys import stdin\nfor j in range(1):\n [n1,n2,k1,k2] = [int(x) for x in stdin.readline().split()]\n if n1>n2:\n print(\"First\")\n else:\n print(\"Second\")\n"}, {"source_code": "n1, n2, k1, k2 = [int(x) for x in input().split()]\nif n1 > n2:\n print(\"First\")\nelse:\n print(\"Second\")\n"}, {"source_code": "n,m,k,l=map(int,input().split())\nif(n>m):\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "def solve(n1,n2,k1,k2):\n if(n1>n2):\n return \"First\"\n else:\n return \"Second\"\nn1,n2,k1,k2=map(int,input().split())\nprint(solve(n1,n2,k1,k2))"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\nwhile True:\n if n1 - 1 < 0:\n print \"Second\"\n break\n n1-=1\n if n2 - 1 < 0:\n print \"First\"\n break\n n2-=1\n \n"}, {"source_code": "import sys\n\ninput = sys.stdin\noutput = sys.stdout\n\n# input = open('input.txt')\n\n# n = int(input.readline().strip())\nn1, n2, _, _ = [int(x) for x in input.readline().strip().split()]\n\nif n1 > n2:\n output.write('First\\n')\nelse:\n output.write('Second\\n')\n\n# output.write('%d\\n' % max(d))\n\n\n\n\n\n\n"}, {"source_code": "n = [int(i) for i in input().split(\" \")]\nprint('First') if n[0] > n[1] else print('Second')"}, {"source_code": "#\n# 513A. Game\n#\n\nn1, n2, k1, k2 = map(int, raw_input().strip().split())\n\nwhile n1 != 0 and n2 != 0:\n n1 -= 1\n n2 -= 1\n\nif n1 == 0:\n print 'Second'\nelse:\n print 'First'"}, {"source_code": "a,b,c,d=map(int,raw_input().split())\nif a>b:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "import sys\n\ndef main():\n \n n1,n2,k1,k2 = map(int, sys.stdin.readline().split())\n\n while True:\n n1-=1\n if n1 == 0:\n sys.stdout.write('Second')\n break\n n2-=1\n if n2 == 0:\n sys.stdout.write('First')\n break\n\nif __name__ == '__main__':\n main()"}], "negative_code": [{"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n\tprint(\"FIRST\")\nelse:\n\tprint(\"SECOND\")"}, {"source_code": "a, b, c, d=map(int, input().split())\nif a+c>b+d:\n print(\"First\")\nelif b+d>a+c:\n print(\"Second\")\n \n "}, {"source_code": "a = input().split()\nif a[0] > a[1]:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "[n1, n2, k1, k2] = [int(x) for x in input().split()]\nprint('Second' if (n1+n2)%2 == 0 else 'First')\n"}, {"source_code": "\ndef main():\n\tn1,n2,k1,k2 = map(int, raw_input().split())\n\tif n1 k2:\n print('First')\nelif k2 > k1:\n print('Second')\nelif n1 > n2:\n print('First')\nelif n2 > n1:\n print('Second')"}, {"source_code": "n,m,k1,k2=[int(t) for t in input().split()]\nif n>=m:\n print('Second')\nelse:\n print('First')"}, {"source_code": "n1,n2,k1,k2 = map(int, input().split())\nprint('First' if n1//k1 >= n2//k1 else 'Second')"}, {"source_code": "n1,n2,k1,k2 = map(int, input().split())\nif n1>n2:\n print('FIRST')\nelse:\n print('SECOND')"}, {"source_code": "k = input()\ne = ' '\nb = ''\nl = len(k)\narray = [0 for i in range(4)]\nc = 0\nc1 = 0\na = 0\n\nfor i in range(l):\n if(k[i] == e):\n c = c + 1\nfor i in range(l):\n if(k[i] != e):\n b = b + k[i]\n else:\n array[a] = int(b)\n b = ''\n a = a + 1\n c1 = c1 + 1\n if(c1 == l):\n array[a] = int(b)\n \nn1 = array[0]\nn2 = array[1]\nk1 = array[2]\nk2 = array[3]\n\n\nsupp_1 = n1\nsupp_2 = n2\n\nif((supp_1 - 1) > supp_2):\n print(\"First\")\nelse:\n print(\"Second\")\n"}, {"source_code": "k=list(map(int,input().split()))\nif k[2]>=k[1]:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "a, b, c, d = map(int, input().split())\ns = 1\nif c > d:\n print('First')\nelse:\n print('Second')"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print(\"First\")\nelif n2>n1:\n print(\"Second\")\nelse:\n if k1>=k2:\n print(\"First\")\n else:\n print(\"Second\")"}, {"source_code": "num1 = input()\na = []\n\n\ndef get_the_data(count, num, arr):\n for 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 return arr\n\n\narr1 = get_the_data(0, num1, a)\nplayer1 = arr1[0]\nplayer1_balls = arr1[2]\nplayer2 = arr1[1]\nplayer2_balls = arr1[3]\ni = 1\nwhile player1 > 0 or player2 > 0:\n if i%2 == 1:\n player1 -= 1\n else:\n player2 -= 1\n i += 1\nprint(i)\nif i%2 == 1:\n print(\"Second\")\nelse:\n print(\"First\")\n\n\n\n''''\nif player1 - player2_balls <= 0:\n player2 -= player2_balls\n else:s\n\n'''"}, {"source_code": "\nn1,n2,m1,m2 = map(int,raw_input().split())\nif n2 >=n1:\n print \"First\"\nelse:\n print \"Seond\""}, {"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\"\nn1, n2, k1, k2 = list(map(int, input().split()))\nif n1 < n2:\n\tprint(\"Second\")\nif n1 == n2:\n\tif k1 > k2:\n\t\tprint(\"First\")\n\telif k1 < k2:\n\t\tprint(\"Second\")\n\telse:\n\t\tprint(\"First\")\nelse:\n\tprint(\"First\")\n"}, {"source_code": "# int(input())\n# [int(s) for s in input().split()]\n# input()\n \n \ndef solve():\n n1 ,n2, k1, k2 = [int(s) for s in input().split()]\n if n1 >= n2:\n print(\"Second\")\n else:\n print(\"First\")\n \n \n \nif __name__ == \"__main__\":\n solve()"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print(\"First\")\nelif n2>n1:\n print(\"Second\")\nelse:\n if k1>=k2:\n print(\"First\")\n else:\n print(\"Second\")"}, {"source_code": "n1,n2,k1,k2 = map(int, input().split())\nif n1>n2:\n print('FIRST')\nelse:\n print('SECOND')"}, {"source_code": "n1,n2,k1,k2 = map(int,raw_input().split(' '))\n\nif n1 >= n2:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "a=input().split()\nif int(a[0])>int(a[1]):\n\tprint(\"First\")\nelif int(a[0])=int(a[3]):\n\t\tprint(\"First\")\n\telse:\n\t\tprint(\"Second\")\n"}, {"source_code": "n1,n2,k1,k2=map(int,raw_input().split())\nif n1>n2:print \"FIRST\"\nelse:print\"SECOND\""}, {"source_code": "import sys\n\ndef main():\n \n n1,n2,k1,k2 = sys.stdin.readline().split()\n\n if n1 <= n2:\n sys.stdout.write('Second')\n else:\n sys.stdout.write('First')\n\nif __name__ == '__main__':\n main()"}, {"source_code": "n,m,k1,k2=[int(t) for t in input().split()]\nif n>=m:\n print('Second')\nelse:\n print('First')"}, {"source_code": "nk=map(int,raw_input().split())\nif nk[1]-nk[2]<=0:\n\tprint 'First'\nelif nk[0]-nk[3]<=0:\n\tprint 'Second'"}, {"source_code": "n,k,l,r= map(int, input().split())\nif (n>k):\n print ('first')\nelif (n=0 and n2>=0):\n if(i%2!=0):\n if(n1==0):\n print \"Second\"\n break\n n1-=1\n if(n2==0):\n print \"First\"\n break\n n2-=1\n if(i%2==0):\n if(n2==0):\n print \"First\"\n break\n n2-=1\n if(n1==0):\n print \"Second\"\n break\n n1-=1\n i+=1"}, {"source_code": "k = input()\ne = ' '\nb = ''\nl = len(k)\narray = [0 for i in range(4)]\nc = 0\nc1 = 0\na = 0\n\nfor i in range(l):\n if(k[i] == e):\n c = c + 1\nfor i in range(l):\n if(k[i] != e):\n b = b + k[i]\n else:\n array[a] = int(b)\n b = ''\n a = a + 1\n c1 = c1 + 1\n if(c1 == l):\n array[a] = int(b)\n \nn1 = array[0]\nn2 = array[1]\nk1 = array[2]\nk2 = array[3]\n\n\nsupp_1 = n1\nsupp_2 = n2\n\nif((supp_1 - 1) > supp_2):\n print(\"First\")\nelse:\n print(\"Second\")\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1==n2:\n if k1>k2:\n print(\"First\")\n else:\n print(\"Second\")\nelse:\n if n1>n2:\n print(\"First\")\n else:\n print(\"Second\")"}, {"source_code": "n1,n2,k1,k2 = map(int, raw_input().split())\n\nt1 = n1*k1\nt2 = n2*k2\n\nif t1 > t2:\n\tprint 'First'\nelse:\n\tprint 'Second'\n"}, {"source_code": "n1,n2,k1,k2=list(map(int,input().split()))\nc,d=0,0\nwhile(n1!=0 and n2!=0):\n c+=k1\n d+=k2\n n1-=k1\n n2-=k2\nif(c>=d):\n print('First')\nelse:\n print('Second')"}, {"source_code": "n1,n2,k1,k2=list(map(int,input().split()))\nc,d=0,0\nwhile(n1!=0 and n2!=0):\n c+=k1\n d+=k2\n n1-=k1\n n2-=k2\nif(c>=d):\n print('First')\nelse:\n print('Second')"}, {"source_code": "a,b,c,d = raw_input().split()\nif a>=b:\n print \"Second\"\nelse:\n print \"First\"\n"}, {"source_code": "l=list(map(int,input().split()))\nif (l[0]>l[1]):\n print(\"First\")\nelif (l[1]>l[0]):\n print(\"Second\")\nelse:\n if (l[2]>l[3]):\n print(\"First\")\n elif (l[3]>l[2]):\n print(\"Second\")\n else:\n print(\"Second\")"}, {"source_code": "import sys\nn1,n2,k1,k2=raw_input().split()\n\nif n1 == n2:\n\tprint \"Second\\n\"\nelif n1>n2:\n\tprint \"First\\n\"\nelse:\n\tprint \"Second\\n\"\n"}, {"source_code": "\na = list(map(int, input().strip().split()))\nif a[0] - a[2] > a[1] - a[3]:\n print(\"first\")\nif a[0] - a[2] < a[1] - a[3]:\n print(\"Second\")"}, {"source_code": "n1, n2, k1, k2 = map(int, input().split(\" \"))\n\nmin_throw = min(k1, k2)\nfirst, second = (n1 - min_throw), (n2 - min_throw)\n\nif first > second :\n print(\"first\")\nelse :\n print(\"second\")\n"}, {"source_code": "values = raw_input()\nn1, n2, k1, k2 = values.split(\" \")\n\nif n1 <= n2:\n\tprint \"Second\"\nelse:\n\tprint \"First\""}, {"source_code": "n1, n2, k1, k2 = map(int, input().split())\nif k1 ^ k2 == 0:\n\tprint('First')\nelse:\n\tprint('Second')"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print(\"First\")\nelif n2>n1:\n print(\"Second\")\nelse:\n if k1>=k2:\n print(\"Second\")\n else:\n print(\"First\")"}, {"source_code": "n1, n2, k1, k2 = map(int, input().split())\n\nif n1 == n2:\n if k1 >= k2:\n print(\"First\")\n else:\n print(\"Second\")\nelif n1 > n2:\n print(\"First\")\nelse:\n print(\"Second\") "}, {"source_code": "n1,n2,k1,k2 = map(int,raw_input().split(' '))\n\nif n1 >= n2:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "l=input().split()\nif l[0]>l[1]:\n\tprint(\"Second\")\nelse:\n\tprint(\"First\")\n\t"}, {"source_code": "if __name__ == '__main__':\n n1, n2, k1, k2 = [int(num) for num in raw_input().split()]\n\n print 'Second' if n2 > n1 else 'First' # ?\n"}, {"source_code": "n1, n2, k1, k2 = map(int,input().split())\nm1 = (n1//k1)+(n1%k1)\nm2 = (n2//k2)+(n2%k2)\n\nif m1 == m2:\n print('First')\nelif m1>m2:\n print('Second')\nelse:\n print('First')\n \n "}, {"source_code": "a, b, c, d = map(int,input().split())\nif a > b:\n print('First')\nelif a < b:\n print(\"Second\")\nelse:\n if c > d:\n print('First')\n elif d >= c:\n print(\"Second\")"}, {"source_code": "n1,n2,k1,k2=input().split()\nif n1>n2:\n print('First')\nelse:\n print('Second')"}, {"source_code": "a, b, c, d = input().split()\na = int(a)\nb = int(b)\nc = int(c)\nd = int(d)\nif a > b:\n\tprint('first')\nelif a < b:\n\tprint('second')\nelse:\n\tprint('second')\n\n# 1481038598079"}, {"source_code": "n1, n2, k1, k2 = list(map(int, input().split()))\n\nif n1 > 1 and n2 > 1:\n if int(n1/k1) > int(n2/k2):\n print(\"Second\")\n else:\n print(\"First\")\nelse:\n if n1 == 1:\n print(\"Second\")\n if n2 == 1:\n print(\"First\")\n"}, {"source_code": "n1, n2, *b = map(int, input().split())\nprint(['first','second'][n1 <= n2])"}, {"source_code": "n1,n2,k1,k2 = list(map(int,input().split()))\n\nif n1>n2:\n print(\"First\")\nelse:\n print(\"Secoond\")"}, {"source_code": "if(__name__=='__main__'):\n n1,n2,k1,k2=map(int,input().split())\n if(n1==n2):\n if(n1%2==0):\n print(\"Second\")\n else:\n print(\"First\")\n else:\n print(\"First\" if n1>n2 else \"Second\")"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print(\"First\")\nelif n2>n1:\n print(\"Second\")\nelse:\n if k1>=k2:\n print(\"Second\")\n else:\n print(\"First\")"}, {"source_code": "def game(n1,n2,k1,k2):\n\twhile n1 > 0 or n2 > 0:\n\t\tn1 = n1 - 1\n\t\tif n1 == 0:\n\t\t\tprint \"Second\"\n\t\t\tbreak \n\t\tn2 = n2 - 1\n\t\tif n2 == 0:\n\t\t\tprint \"First\"\n\t\t\tbreak\n\ngame(2,1,1,1)\n"}, {"source_code": "inp = input()\n\np1, p2, d1, d2 = inp.split(\" \")\n\nif p1 <= p2:\n print(\"Second\")\nelse:\n print(\"First\")"}, {"source_code": "import sys\nn1,n2,k1,k2=raw_input().split()\n\nif n1 == n2:\n\tprint \"Second\\n\"\nelif n1>n2:\n\tprint \"First\\n\"\nelse:\n\tprint \"Second\\n\"\n"}, {"source_code": "n1,n2,k1,k2=list(map(int,input().split()))\nc,d=0,0\nwhile(n1!=0 and n2!=0):\n c+=k1\n d+=k2\n n1-=k1\n n2-=k2\nif(c>=d):\n print('First')\nelse:\n print('Second')"}, {"source_code": "n1, n2, k1, k2 = map(int,input().split())\n\nif k1 == k2:\n if n1 > n2:\n print('First')\n else:\n print('Second')\n\nelif n1 - k1 != 0 or n2 - k2 != 0:\n if n1 - k1 > n2 - k2:\n print('First')\n else:\n print('Second')\n\nelse:\n while n1 != 0 and n2 != 0:\n for i in range(min(k1,k2)):\n n1 -= 1\n # print(n1)\n n2 -= 1\n # print(n2)\n\n if n1 == 0:\n print('Second')\n else:\n print('First')\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nwhile n1<0 or n2<0:\n n1=n1-k1\n n2=n2-k2\nif n1= k2:\n print(\"First\")\n else:\n print(\"Second\")\nelif n1 > n2:\n print(\"First\")\nelse:\n print(\"Second\") "}, {"source_code": "def ct(n,k) :\n if n%k != 0 : \n return n/k+1\n else :\n return n/k\nn1,n2,k1,k2=map(int,raw_input().split())\n\nif ct(n1,k1) <= ct(n2,k2) :\n print \"First\"\nelse :\n print \"Second\""}, {"source_code": "n1,n2,k1,k2 = map(int, raw_input().split())\n\nt1 = n1*k1\nt2 = n2*k2\n\nif t1 > t2:\n\tprint 'First'\nelse:\n\tprint 'Second'\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nA=abs(n1-k1)\nB=abs(n2-k2)\nif n1==n2:\n if k1 >k2:\n print(\"Second\")\n else:\n print(\"Second\")\nif A>B:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "def game():\n n = raw_input().split()\n n1 = int(n[0])\n n2 = int(n[1])\n k1 = int(n[1])\n k2 = int(n[2])\n if n1 == n2:\n print(\"Second\")\n elif n1 > n2:\n print(\"First\")\n else:\n print(\"Second\")"}, {"source_code": "n,m,a,b=map(int,input().split(\" \"))\nif n>m:\n\tprint(\"First\")\nelif m>n:\n\tprint(\"Second\")\nelif m==n:\n\tif a>b:\n\t\tprint(\"First\")\n\telif b>=a:\n\t\tprint(\"Second\")\n"}, {"source_code": "n1, n2, k1, k2 = list(map(int, input().split()))\nprint(\"Second\" if n2 * k2 > n1 * k1 else \"First\")"}, {"source_code": "n,m,k1,k2=[int(t) for t in input().split()]\nif n>m:\n print('Second')\nelse:\n print('First')"}, {"source_code": "n1,n2,k1,k2 = map(int,(raw_input().split()))\n\nif k1 < k2:\n print \"Second\"\nelse:\n print \"First\"\n"}, {"source_code": "n,m,k,l=map(int,input().split())\nif(n>m):\n print(\"first\")\nelse:\n print(\"second\")"}, {"source_code": "a, b, c, d=map(int, input().split())\nif a+c>b+d:\n print(\"First\")\nelif b+d>a+c:\n print(\"Second\")\n \n "}, {"source_code": "n= input().split()\n\nn1= int(n[0])\nn2= int(n[1])\nk1= int(n[2])\nk2= int(n[3])\n\np1= n1*k1\n\np2= n2*k2\n\nif p1>p2:\n print(\"First\")\nelse:\n print(\"Second\")"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nwhile n1<0 or n2<0:\n n1=n1-k1\n n2=n2-k2\nif n1b:\n print(\"First\")\n else:\n print(\"Second\")\n\nmod()"}, {"source_code": "# http://codeforces.com/problemset/problem/513/A\nn1, n2, k1, k2 = [int(x) for x in input().split()]\ntemp = min(k1, k2)\nwhile(1):\n\tif ( (n1 <= 0) ):\n\t\tprint(\"Second\")\n\t\tbreak\n\telif ( (n2 <= 0) ):\n\t\tprint(\"First\")\n\t\tbreak\n\tn1 -= temp\n\tn2 -= temp"}, {"source_code": "n1, n2, *b = map(int, input().split())\nprint(['first','second'][n1 <= n2])"}, {"source_code": "n1,n2,k1,k2 = map(int, input().split())\nif n1>n2:\n print('FIRST')\nelse:\n print('SECOND')"}, {"source_code": "n,k,l,r= map(int, input().split())\nif (n>k):\n print ('first')\nelif (n= n2:\n print(\"Second\")\n else:\n print(\"First\")\n \n \n \nif __name__ == \"__main__\":\n solve()"}, {"source_code": "if(__name__=='__main__'):\n n1,n2,k1,k2=map(int,input().split())\n if(n1==n2):\n if(n1%2==0):\n print(\"Second\")\n else:\n print(\"First\")\n else:\n print(\"First\" if n1>n2 else \"Second\")"}, {"source_code": "if(__name__=='__main__'):\n n1,n2,k1,k2=map(int,input().split())\n if(n1==n2):\n print(\"Secnod\")\n else:\n print(\"First\" if n1>n2 else \"Second\")\n"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nwhile n1<0 or n2<0:\n n1=n1-k1\n n2=n2-k2\nif n1 n2:\n print(\"First\")\nelse:\n print('Second')\nprint(os.getcwd())\n"}, {"source_code": "a,b=map(int,raw_input().split())[:2]\nprint['First','Second'][bn2 else \"Second\")\n"}, {"source_code": "n,m,k,l=map(int,input().split())\nif n==m:\n\tif k>l:\n\t\tprint(\"First\")\n\telif l>k:\n\t\tprint(\"Second\")\nelif n>m:\n\tprint(\"First\")\nelif m>n:\n\tprint(\"Second\")"}, {"source_code": "# int(input())\n# [int(s) for s in input().split()]\n# input()\n \n \ndef solve():\n n1 ,n2, k1, k2 = [int(s) for s in input().split()]\n if n1 >= n2:\n print(\"Second\")\n else:\n print(\"First\")\n \n \n \nif __name__ == \"__main__\":\n solve()"}, {"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\"\nn1, n2, k1, k2 = list(map(int, input().split()))\nif n1 < n2:\n\tprint(\"Second\")\nelif n1 == n2:\n\tif k1 < k2:\n\t\tprint(\"First\")\n\telif k1 > k2:\n\t\tprint(\"Second\")\n\telse:\n\t\tprint(\"Second\")\nelse:\n\tprint(\"First\")\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\nwhile True:\n n1 -= k1\n if n1 <= 0:\n print \"First\"\n break\n n2 -= k2\n if n2 <= 0:\n print \"Second\"\n break\n"}, {"source_code": "n1, n2, k1, k2 = map(int,input().split())\n\nif k1 == k2:\n if n1 > n2:\n print('First')\n else:\n print('Second')\n\nelif n1 - k1 != 0 or n2 - k2 != 0:\n if n1 - k1 > n2 - k2:\n print('First')\n else:\n print('Second')\n\nelse:\n while n1 != 0 and n2 != 0:\n for i in range(min(k1,k2)):\n n1 -= 1\n # print(n1)\n n2 -= 1\n # print(n2)\n\n if n1 == 0:\n print('Second')\n else:\n print('First')\n"}, {"source_code": "nk=map(int,raw_input().split())\nif nk[1]-nk[2]==0:\n\tprint 'First'\nelse:\n\tprint 'Second'"}, {"source_code": "n1,n2,k1,k2 = map(int,raw_input().split(' '))\n\nif n1 >= n2:\n print \"First\"\nelse:\n print \"Second\""}, {"source_code": "nk=map(int,raw_input().split())\nif nk[0]-nk[3]==0:\n\tprint 'Second'\nelse:\n\tprint 'First'"}, {"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\"\nn1, n2, k1, k2 = list(map(int, input().split()))\nif n1 < n2:\n\tprint(\"Second\")\nelif n1 == n2:\n\tif k1 < k2:\n\t\tprint(\"First\")\n\telif k1 > k2:\n\t\tprint(\"Second\")\n\telse:\n\t\tprint(\"Second\")\nelse:\n\tprint(\"First\")\n"}, {"source_code": "n1, n2, k1, k2 = map(int, raw_input().split())\nprint ['First', 'Second'][n1 > n2]"}, {"source_code": "def mod():\n a,b,c,d=input().split(\" \")\n if a+c>b+d:\n print(\"first\")\n else:\n print(\"second\")\n\nmod()"}, {"source_code": "n1,n2,k1,k2=map(int,input().split())\nif n1>n2:\n print('FIRST')\nelse:\n print('SECOND')\n "}, {"source_code": "a,b=map(int,raw_input().split())[:2]\nprint['First','Second'][b b+d:\n print('First')\nelif b+d > a+c:\n print('Second')"}], "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b"} {"nl": {"description": "You are given a tree with $$$n$$$ nodes. You have to write non-negative integers on its edges so that the following condition would be satisfied:For every two nodes $$$i$$$, $$$j$$$, look at the path between them and count the sum of numbers on the edges of this path. Write all obtained sums on the blackboard. Then every integer from $$$1$$$ to $$$\\lfloor \\frac{2n^2}{9} \\rfloor$$$ has to be written on the blackboard at least once. It is guaranteed that such an arrangement exists.", "input_spec": "The first line contains a single integer $$$n$$$ ($$$1 \\le n \\le 1000$$$)\u00a0\u2014 the number of nodes. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \\le u, v \\le n$$$, $$$u \\neq v$$$), meaning that there is an edge between nodes $$$u$$$ and $$$v$$$. It is guaranteed that these edges form a tree.", "output_spec": "Output $$$n-1$$$ lines, each of form $$$u$$$ $$$v$$$ $$$x$$$ ($$$0 \\le x \\le 10^6$$$), which will mean that you wrote number $$$x$$$ on the edge between $$$u$$$, $$$v$$$. Set of edges $$$(u, v)$$$ has to coincide with the set of edges of the input graph, but you can output edges in any order. You can also output ends of edges in an order different from the order in input.", "sample_inputs": ["3\n2 3\n2 1", "4\n2 4\n2 3\n2 1", "5\n1 2\n1 3\n1 4\n2 5"], "sample_outputs": ["3 2 1\n1 2 2", "4 2 1\n3 2 2\n1 2 3", "2 1 1\n5 2 1\n3 1 3\n4 1 6"], "notes": "NoteIn the first example, distance between nodes $$$1$$$ and $$$2$$$ is equal to $$$2$$$, between nodes $$$2$$$ and $$$3$$$ to $$$1$$$, between $$$1$$$ and $$$3$$$ to $$$3$$$.In the third example, numbers from $$$1$$$ to $$$9$$$ (inclusive) will be written on the blackboard, while we need just from $$$1$$$ to $$$5$$$ to pass the test."}, "positive_code": [{"source_code": "import math\n\nn = int(input())\n\nif n == 1:\n print()\nelse: \n edge = [list(map(int, input().split())) for i in range(1, n) ]\n g = {}\n\n for x, y in edge:\n if x not in g:\n g[x] = []\n if y not in g:\n g[y] = []\n \n g[x].append(y)\n g[y].append(x)\n \n def find_centroid(g):\n p = {}\n size = {}\n \n p[1] = -1\n Q = [1] \n \n i = 0\n while i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \n for u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\n cur = 1 \n n = size[cur]\n \n while True:\n max_ = n - size[cur] \n ind_ = p[cur]\n \n for v in g[cur]:\n if v == p[cur]: continue\n \n if size[v] > max_: \n max_ = size[v]\n ind_ = v\n \n if max_ <= n // 2:\n return cur\n \n cur = ind_\n \n def find_center(g): \n d = {}\n d[1] = 0\n Q = [(1, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n s = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n s = u\n \n d = {}\n pre = {}\n d[s] = 0\n Q = [(s, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n pre[v] = u\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n e = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n e = u\n \n route = [e]\n while pre[route[-1]] != s:\n route.append(pre[route[-1]])\n \n print(route)\n return route[len(route) // 2]\n\n root = find_centroid(g)\n p = {}\n size = {}\n Q = [root]\n p[root] = -1\n\n i = 0\n while i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \n for u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\n gr = [(u, size[u]) for u in g[root]]\n gr = sorted(gr, key=lambda x:x[1])\n thres = math.ceil((n-1) / 3) \n sum_ = 0\n\n gr1 = []\n gr2 = []\n i = 0\n \n while sum_ < thres:\n gr1.append(gr[i][0])\n sum_ += gr[i][1]\n i+=1\n \n while i < len(gr):\n gr2.append(gr[i][0])\n i+=1\n \n def asign(u, W, ew):\n if size[u] == 1:\n return\n \n cur = 0\n for v in g[u]:\n if v == p[u]: continue\n \n first = W[cur]\n ew.append((u, v, first))\n \n W_ = [x - first for x in W[cur+1: cur+size[v]]]\n asign(v, W_, ew)\n \n cur+=size[v]\n\n a, b = 0, 0\n for x in gr1:\n a += size[x]\n \n for x in gr2:\n b += size[x]\n \n arr_1 = [x for x in range(1, a+1)] \n arr_2 = [i*(a+1) for i in range(1, b+1)] \n ew = []\n\n cur = 0\n for u in gr1:\n first = arr_1[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_1[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n cur = 0\n for u in gr2:\n first = arr_2[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_2[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n for u, v, w in ew:\n print('{} {} {}'.format(u, v, w))"}], "negative_code": [{"source_code": "import math\n\nn = int(input())\n\nif n == 1:\n print()\nelse: \n edge = [list(map(int, input().split())) for _ in range(n-1) ]\n g = {}\n\n for x, y in edge:\n if x not in g:\n g[x] = []\n if y not in g:\n g[y] = []\n \n g[x].append(y)\n g[y].append(x)\n\n def find_center(g): \n d = {}\n d[1] = 0\n Q = [(1, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n s = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n s = u\n \n d = {}\n pre = {}\n d[s] = 0\n Q = [(s, 0)]\n\n while len(Q) > 0:\n u, dis = Q.pop(0)\n \n for v in g[u]:\n if v not in d:\n pre[v] = u\n d[v] = dis +1\n Q.append((v, d[v])) \n \n max_length = -1\n e = None \n\n for u, dis in d.items():\n if dis > max_length:\n max_length = dis\n e = u\n \n route = [e]\n while pre[route[-1]] != s:\n route.append(pre[route[-1]])\n \n return route[len(route) // 2]\n\n root = find_center(g)\n p = {}\n size = {}\n Q = [root]\n p[root] = -1\n\n i = 0\n while i < len(Q):\n u = Q[i]\n \n for v in g[u]:\n if p[u] == v: continue\n p[v] = u\n Q.append(v)\n i+=1 \n \n for u in Q[::-1]:\n size[u] = 1\n \n for v in g[u]:\n if p[u] == v:\n continue\n size[u] += size[v]\n\n gr = [(u, size[u]) for u in g[root]]\n gr = sorted(gr, key=lambda x:x[1])\n thres = math.ceil((n-1) / 3) \n sum_ = 0\n\n gr1 = []\n gr2 = []\n i = 0\n \n while sum_ < thres:\n gr1.append(gr[i][0])\n sum_ += gr[i][1]\n i+=1\n \n while i < len(gr):\n gr2.append(gr[i][0])\n i+=1\n \n def asign(u, W, ew):\n if size[u] == 1:\n return\n \n cur = 0\n for v in g[u]:\n if v == p[u]: continue\n \n first = W[cur]\n ew.append((u, v, first))\n \n W_ = [x - first for x in W[cur+1: cur+size[v]]]\n asign(v, W_, ew)\n \n cur+=size[v]\n\n a, b = 0, 0\n for x in gr1:\n a += size[x]\n \n for x in gr2:\n b += size[x]\n \n arr_1 = [x for x in range(1, a+1)] \n arr_2 = [i*(a+1) for i in range(1, b+1)] \n ew = []\n\n cur = 0\n for u in gr1:\n first = arr_1[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_1[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n cur = 0\n for u in gr2:\n first = arr_2[cur]\n ew.append((root, u, first))\n W_ = [x - first for x in arr_2[cur+1:cur+size[u]]]\n \n cur += size[u]\n #print(u, W_)\n asign(u, W_, ew)\n \n for u, v, w in ew:\n print('{} {} {}'.format(u, v, w))"}], "src_uid": "87d755df6ee27b381122062659c4a432"} {"nl": {"description": "A necklace can be described as a string of links ('-') and pearls ('o'), with the last link or pearl connected to the first one. You can remove a link or a pearl and insert it between two other existing links or pearls (or between a link and a pearl) on the necklace. This process can be repeated as many times as you like, but you can't throw away any parts.Can you make the number of links between every two adjacent pearls equal? Two pearls are considered to be adjacent if there is no other pearl between them.Note that the final necklace should remain as one circular part of the same length as the initial necklace.", "input_spec": "The only line of input contains a string $$$s$$$ ($$$3 \\leq |s| \\leq 100$$$), representing the necklace, where a dash '-' represents a link and the lowercase English letter 'o' represents a pearl.", "output_spec": "Print \"YES\" if the links and pearls can be rejoined such that the number of links between adjacent pearls is equal. Otherwise print \"NO\". You can print each letter in any case (upper or lower).", "sample_inputs": ["-o-o--", "-o---", "-o---o-", "ooo"], "sample_outputs": ["YES", "YES", "NO", "YES"], "notes": null}, "positive_code": [{"source_code": "s = raw_input()\n\npearls = s.count('o')\nlinks = s.count('-')\n\nif pearls == 0:\n print \"YES\"\nelse:\n if links%pearls == 0:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "s = raw_input().strip()\na = s.count('o')\nb = s.count('-')\nif a == 0:\n\tprint \"YES\"\nelif (b%a) == 0:\n\tprint \"YES\"\nelse:\n\tprint \"NO\""}, {"source_code": "S=list(input())\nH=S.count('o')\nH1=S.count('-')\nif(H1==0 or H==0):\n print(\"YES\")\nelse:\n j=0\n if(H>H1):\n j=1\n elif(H1>H):\n if(H1%H!=0):\n j=1\n if(j==1):\n print(\"NO\")\n else:\n print(\"YES\")"}, {"source_code": "l=list(input())\nif l.count(\"-\")==0:\n print(\"YES\")\n exit()\nif l.count(\"o\")==0:\n print(\"YES\")\n exit()\nif l.count(\"-\")%l.count(\"o\")==0:\n print(\"YES\")\n exit()\nprint(\"NO\")"}, {"source_code": "a = input()\n\nif a.count('-') == 0:\n\tprint(\"YES\")\nelif a.count('o') == 0:\n\tprint(\"YES\")\nelse:\n\tprint(\"YES\") if a.count('-')%a.count('o') == 0 else print(\"NO\")"}, {"source_code": "x = str(input())\nlist=[0,0]\ni = 0\nwhile i 0 and x % y == 0 or y == 0:\n print (\"yes\")\nelse:\n print(\"no\")\n"}, {"source_code": "s = input()\no = s.count('o')\nc_ = s.count('-')\nif(o == 0):\n print(\"YES\")\nelif(c_ % o == 0):\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "def main():\n\tnecklace = raw_input()\n\t\n\titems = []\n\tlinkcounter = 0\n\tpearlcounter = 0\n\n\tfor item in necklace:\n\t\titems.append(item)\n\n\tfor item in items:\n\t\tif item == \"-\":\n\t\t\tlinkcounter += 1\n\t\telse:\n\t\t\tpearlcounter += 1\n\n\n\tif pearlcounter != 0 and linkcounter % pearlcounter != 0:\n\t\tprint \"NO\"\n\telse:\n\t\tprint \"YES\"\n\nmain()"}, {"source_code": "x=input();a=x.count('-');b=x.count('o')\nprint('YES' if min(a,b)==0 or b==1 or a%b==0 else 'NO')"}, {"source_code": "string = input()\nss = string.count('-')\nos = string.count('o')\n\nif os == 0:\n print(\"YES\")\nelif ss%os == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s=input()\nd=s.count(\"-\")\np=s.count(\"o\")\nif p==0:\n print(\"YES\")\nelse:\n if d%p==0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "d = {'o': 0, '-': 0}\nfor x in raw_input():\n d[x] += 1\n\nif d['o']>0:\n print 'NO' if d['-'] % d['o'] else 'YES'\nelse:\n print 'YES'\n"}, {"source_code": "n=input()\nc=0\nd=0\nfor i in n:\n if i==\"-\":\n c=c+1\n else:\n d=d+1\nif d==0 or c%d==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "# -*- coding: utf-8 -*-\n#!/usr/bin/python\n\nif __name__ == '__main__':\n s = raw_input()\n l_num = len(s.replace('o', ''))\n p_num = len(s.replace('-', ''))\n print \"NO\" if p_num and l_num % p_num else \"YES\""}, {"source_code": "s=input()\n\nl=s.count('-')\no=s.count('o')\n\nif o==0:\n print(\"YES\")\nelif l % o == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n \n \n"}, {"source_code": "p = l = 0\nfor i in input() :\n if i == 'o' :\n p += 1\n else :\n l += 1 \n\nif p == 0 :\n print('YES')\nelif l % p == 0 :\n print('YES')\nelse :\n print('NO')\n"}, {"source_code": "s = input()\nslen = len(s)\ncnt1 = s.count('o')\ncnt2 = slen - cnt1\nif cnt1 == 0:\n print('YES')\nelse:\n if (cnt2 % cnt1 == 0):\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "s = input()\np = 0\nl = 0\nfor c in s:\n if c == '-': l += 1\n else: p += 1\nif p == 0: print('YES')\nelse: print('YES' if l % p == 0 else 'NO')\n"}, {"source_code": "necklace = raw_input()\npearls, links = [necklace.count(x) for x in ['o', '-']]\nif pearls == 0:\n print 'YES'\nelse:\n print 'YES' if links % pearls == 0 else 'NO'\n"}, {"source_code": "s = raw_input()\nl = s.count('-')\np = s.count('o')\n\nif p == 0:\n print 'YES'\nelse:\n print 'YES' if l % p == 0 else 'NO'\n"}, {"source_code": "n=input()\nk=n.count('-')\np=n.count('o')\nif k==0 or p==0:\n\tprint('YES')\nelif k%p==0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "txt=raw_input()\nl=txt.count('-');p=len(txt)-l\nif l==0 or p==0:\n print \"YES\"\nelse:\n print [\"NO\",\"YES\"][l%p==0]\n"}, {"source_code": "s = input()\na = s.count(\"-\")\nb = s.count(\"o\")\nif a>=1 and b==0:\n\tprint(\"YES\")\nelif a%b==0 or a==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\t\t"}, {"source_code": "# -*- coding: utf-8 -*-\n#!/usr/bin/python\n\nif __name__ == '__main__':\n s = raw_input()\n l_num = len(s.replace('o', ''))\n p_num = len(s.replace('-', ''))\n print \"NO\" if p_num and l_num % p_num else \"YES\""}, {"source_code": "s = input()\nd = s.count(\"-\")\no = s.count(\"o\")\nif d == 0 or o == 0:\n print(\"YES\")\nelif d % o == 0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "'''\nAuthor: Abdurasul\n'''\nn=input();k=s=0\nfor i in n:\n if i=='-':k+=1\n else:s+=1\nif k==0:print('yes');exit()\nelif s==0:print('yes');exit()\nelif k%s==0:print('yes');exit()\nprint('no')"}, {"source_code": "s=input('')\nl=0;m=0\nfor i in range(0,len(s)):\n if s[i]=='-':\n l+=1\n else:\n m+=1\nif l==0 or m==0:\n print('YES')\nelif l%m==0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "s = input()\no = s.count('o')\nd = s.count('-')\nif(d == 0 or o == 0):\n\tprint(\"YES\")\nelif(d/o == int(d/o)):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "s = raw_input().strip()\ndash = s.count('-')\npear = s.count('o')\n\nif pear == 0:\n print \"YES\"\n exit()\n\nif dash % pear == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}, {"source_code": "strr = input()\n\ng_count = 0\nm_count = 0\n\nfor i in range(len(strr)):\n if strr[i] == '-':\n g_count += 1\n else:\n m_count += 1\n\n\n\nif (('o' in strr) == False or g_count % m_count == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "strr = input()\n\ng_count = 0\nm_count = 0\n\nfor i in range(len(strr)):\n if strr[i] == '-':\n g_count += 1\n else:\n m_count += 1\n\n\n\nif (('o' in strr) == False or g_count % m_count == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "#https://codeforces.com/problemset/problem/980/A\ns=input()\nl=s.count('-')\np=len(s)-l\n\nif p==0 or l%p==0:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "s = raw_input();\nL = list(s);\n\na = 0;\nb = 0;\n\nfor ch in L : \n\tif ch == \"o\" : \n\t\tb += 1;\n\telse : \n\t\ta += 1;\nif b == 0 or a % b == 0: \n\tprint \"YES\";\nelse : \n\tprint \"NO\";\n"}, {"source_code": "string = input()\n\ncountO = 0\ncountStripe = 0\nfor i in string:\n if(i==\"o\"): countO+=1\n if(i==\"-\"): countStripe+=1\n\nif(countO==0): print(\"YES\")\nelif((countStripe % countO) == 0): print(\"YES\")\nelse : print(\"NO\")\n\n###### TESTTTTT ###"}, {"source_code": "s = input()\nslen = len(s)\ncnt1 = s.count('o')\ncnt2 = slen - cnt1\nif cnt1 == 0:\n print('YES')\nelse:\n if (cnt2 % cnt1 == 0):\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "s=list(raw_input())\npearl=0\nlink=0\nfor l in s:\n\tif l=='o':\n\t\tpearl+=1\n\telse:\n\t\tlink+=1\n\t\t\n#print link,pearl\n\nif pearl==0:\n\tprint \"YES\"\nelif link==0:\n\tprint \"YES\"\nelse:\n\tif link%pearl==0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\""}, {"source_code": "s = raw_input();\nL = list(s);\n\na = 0;\nb = 0;\n\nfor ch in L : \n\tif ch == \"o\" : \n\t\tb += 1;\n\telse : \n\t\ta += 1;\nif b == 0 or a % b == 0: \n\tprint \"YES\";\nelse : \n\tprint \"NO\";\n"}, {"source_code": "s=input()\n\nl=s.count('-')\no=s.count('o')\n\nif o==0:\n print(\"YES\")\nelif l % o == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n\n \n \n"}, {"source_code": "from sys import stdin\nans = \"YES\"\ns = stdin.readline().strip()\nn = s.count('-')\nm = s.count('o')\nif m and n%m:\n ans = \"NO\"\nprint ans"}, {"source_code": "s = input()\nif s.count('o') == 0 or s.count('-') % s.count('o') == 0:\n print('yes')\nelse:\n print('no')\n \n"}, {"source_code": "a = raw_input()\ncnt1 = 0\ncnt2 = 0\n\nfor i in a:\n if(i == 'o'):\n cnt1+=1\n if(i == '-'):\n cnt2+=1\nif(cnt1==0 or cnt2==0):\n print 'YES' \nelif(cnt2%cnt1 == 0):\n print 'YES'\nelse:\n print 'NO'\n \n"}, {"source_code": "s = input()\nprint(\"YES\" if (s.count(\"o\") == 0 or s.count(\"-\") % s.count(\"o\") == 0) else \"NO\")"}, {"source_code": "n=input()\nl=len(n)\nx=n.count('o')\nif (l==x ) or (l-x)%(max(1,x))==0 :\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s = input()\np = 0\nl = 0\nfor c in s:\n if c == '-': l += 1\n else: p += 1\nif p == 0: print('YES')\nelse: print('YES' if l % p == 0 else 'NO')\n"}, {"source_code": "s = raw_input()\n\npearls = s.count('o')\nlinks = s.count('-')\n\nif pearls == 0:\n print \"YES\"\nelse:\n if links%pearls == 0:\n print \"YES\"\n else:\n print \"NO\""}, {"source_code": "S=list(input())\nH=S.count('o')\nH1=S.count('-')\nif(H1==0 or H==0):\n print(\"YES\")\nelse:\n j=0\n if(H>H1):\n j=1\n elif(H1>H):\n if(H1%H!=0):\n j=1\n if(j==1):\n print(\"NO\")\n else:\n print(\"YES\")"}, {"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\n\ns=str(input())\nc1=0\nc2=0\nfor i in range(len(s)):\n\tif(s[i:i+1]==\"o\"):\n\t\tc1+=1\n\telse:\n\t\tc2+=1\n\nif(c1==0 or c2%c1==0):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\t\t\n"}, {"source_code": "'''input\n-o---\n\n'''\nfrom collections import defaultdict as df\nfrom bisect import bisect_left as bl \nfrom itertools import combinations as c\nimport sys\nfrom math import factorial as F\nfrom random import randint as R\nimport heapq\n#sys.setrecursionlimit(1000000)\ns=raw_input().strip()\nn1=s.count(\"o\")\nn2=s.count(\"-\")\nif n2==0 or n1==0:\n\tprint \"YES\"\nelse:\n\tif n2%n1==0:\n\t\tprint \"YES\"\n\telse:\n\t\tprint \"NO\""}, {"source_code": "strr = input()\n\ng_count = 0\nm_count = 0\n\nfor i in range(len(strr)):\n if strr[i] == '-':\n g_count += 1\n else:\n m_count += 1\n\n\n\nif (('o' in strr) == False or g_count % m_count == 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=input()\n\np=n.count('-')\nq =n.count('o')\n\nif p>=0 and q>0:\n if p%q==0:\n print('YES')\n else:\n print('NO')\nif q==0:\n print('YES')\n"}, {"source_code": "s=input()\nc=s.count('-')\nc1=s.count('o')\nif c==0:print('YES')\nelif c1==0:print('YES')\nelif c%c1==0:\n print('YES')\nelse:print('NO')\n"}, {"source_code": "# -*- coding: utf-8 -*-\n#!/usr/bin/python\n\nif __name__ == '__main__':\n s = raw_input()\n l_num = len(s.replace('o', ''))\n p_num = len(s.replace('-', ''))\n print \"NO\" if p_num and l_num % p_num else \"YES\""}, {"source_code": "# -*- coding: utf-8 -*-\n#!/usr/bin/python\n\nif __name__ == '__main__':\n s = raw_input()\n l_num = len(s.replace('o', ''))\n p_num = len(s.replace('-', ''))\n print \"NO\" if p_num and l_num % p_num else \"YES\""}, {"source_code": "line = input()\nnum_links = sum((1 for c in line if c == '-'), 0)\nnum_pearls = sum((1 for c in line if c == 'o'), 0)\n\nif num_pearls == 0 or num_links % num_pearls == 0:\n print('YES')\nelse:\n print('NO')\n"}, {"source_code": "x=input();a=x.count('-');b=x.count('o')\nprint('YES' if min(a,b)==0 or b==1 or a%b==0 else 'NO')"}, {"source_code": "necklace = raw_input()\npearls, links = [necklace.count(x) for x in ['o', '-']]\nif pearls == 0:\n print 'YES'\nelse:\n print 'YES' if links % pearls == 0 else 'NO'\n"}, {"source_code": "n=input()\nc=0\nd=0\nfor i in n:\n if i==\"-\":\n c=c+1\n else:\n d=d+1\nif d==0 or c%d==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s=input()\nd=s.count(\"-\")\np=s.count(\"o\")\nif p==0:\n print(\"YES\")\nelse:\n if d%p==0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=list(input())\nx=n.count(\"-\")\nz=n.count(\"o\")\nif z!=0 and x%z==0:\n\tprint(\"YES\")\nelif z==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "s=input()\nans=\"YES\"\na = s.count('o')\nb = s.count('-')\nif a and b % a :\n ans=\"NO\"\nprint (ans)"}, {"source_code": "# Hello World program in Python\ns=input().strip()\nl=len(s)\np=s.count('-')\nq=l-p\nif q==0:\n print('YES')\nelse:\n if p%q==0:\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "s=str(input())\ncount1=0\ncount2=0\nfor i in range(len(s)):\n\tif(s[i]==\"-\"):\n\t\tcount1+=1\n\telif(s[i]==\"o\"):\n\t\tcount2+=1\nif(count2==0):\n\tprint(\"YES\")\nelif(count1%count2==0):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "# import sys \n# sys.stdin=open(\"input1.in\",\"r\")\n# sys.stdout=open(\"output2.out\",\"w\")\nL=list(input())\ncount1=0\ncount2=0\nfor i in L:\n\tif i=='-':\n\t\tcount1+=1\n\telse:\n\t\tcount2+=1\nif count1==0 or count2==0:\n\tprint(\"Yes\")\nelse:\n\tif count1%count2==0:\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")\n"}, {"source_code": "s = input()\n\nd = {}\nd['o'] = s.count(\"o\")\nd['-'] = s.count(\"-\")\n\nif d['o'] == 0:\n print(\"YES\")\nelif d['-']%d['o'] == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n=input()\nk=n.count('-')\np=n.count('o')\nif k==0 or p==0:\n\tprint('YES')\nelif k%p==0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "a = list(input())\nz = a.count(\"o\")\nif z ==0:print(\"YES\")\nelse:\n\tif (len(a)-z)%z == 0:print(\"YES\")\n\telse:print(\"NO\")"}, {"source_code": "s = input()\nslen = len(s)\ncnt1 = s.count('o')\ncnt2 = slen - cnt1\nif cnt1 == 0:\n print('YES')\nelse:\n if (cnt2 % cnt1 == 0):\n print('YES')\n else:\n print('NO')\n"}, {"source_code": "s = input()\ncl = []\ncount1 = 0\ncount2 = 0\nfor c in s:\n if c=='-':\n count1+=1\n else:\n count2+=1\n\nif count2==0:\n print('YES')\nelse:\n if count1%count2==0:\n print('YES')\n else:\n print('NO')"}, {"source_code": "class CodeforcesTask980ASolution:\n def __init__(self):\n self.result = ''\n self.necklace = ''\n\n def read_input(self):\n self.necklace = input()\n\n def process_task(self):\n try:\n if not self.necklace.count(\"-\") % self.necklace.count(\"o\"):\n self.result = \"YES\"\n else:\n self.result = \"NO\"\n except ZeroDivisionError:\n self.result = \"YES\"\n\n def get_result(self):\n return self.result\n\n\nif __name__ == \"__main__\":\n Solution = CodeforcesTask980ASolution()\n Solution.read_input()\n Solution.process_task()\n print(Solution.get_result())\n"}, {"source_code": "links = 0\npearls = 0\nfor part in input():\n if part == \"-\":\n links += 1\n else:\n pearls += 1\n \nif pearls != 0: \n print(\"YES\" if not (links % pearls) else \"NO\")\nelse:\n print(\"YES\")"}, {"source_code": "s = input()\nprint('YES' if s.count('-') % (s.count('o') or 1) is 0 else 'NO')"}, {"source_code": "s = raw_input().strip()\ndash = s.count('-')\npear = s.count('o')\n\nif pear == 0:\n print \"YES\"\n exit()\n\nif dash % pear == 0:\n print \"YES\"\nelse:\n print \"NO\"\n"}], "negative_code": [{"source_code": "string = input()\nlinkCounter = string.count('-')\npearlCounter = string.count('o')\nif pearlCounter == 0:\n print('NO')\nelse:\n if linkCounter % pearlCounter == 0:\n print('YES')\n else: \n print('NO')\n"}, {"source_code": "inp = input()\n\nif(inp.count(\"-\") % 2 == 0 and inp.count(\"o\") > 1):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s = input()\n\nif s.count('-') % 2 == 0:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "def Links_and_Pearls(array):\n a = 0\n b = 0\n i = 0\n while(i0):\n if(x==n or y==n or x==1):\n print(\"YES\")\n break\n else:\n if(x+y)%2!=0:\n print(\"N0\")\n t = t -1\n"}, {"source_code": "def answer(string):\n if string.count(\"o\") == 0:\n return \"YES\"\n elif string.count(\"-\") == 0:\n return \"YES\"\n elif string.count(\"o\") == 1:\n return \"YES\"\n elif string.count(\"o\")%2 == 0 and string.count(\"-\")%2 == 0:\n return \"YES\"\n elif string.count(\"o\")%2 != 0 and string.count(\"-\")%2 != 0:\n return \"YES\"\n elif string.count(\"o\")%2 != 0 and string.count(\"-\") == string.count(\"o\")*2:\n return \"YES\"\n else:\n return \"NO\"\n\n\n\nstring = input()\nans = answer(string)\nprint(ans)\n"}, {"source_code": "def PearlsAndLinks():\n necklace = raw_input()\n pearls = 0\n links = 0\n for i in necklace:\n if i == 'o':\n pearls += 1\n else:\n links += 1\n \n if pearls != 0 and links%pearls == 0:\n print 'YES'\n else:\n print 'NO'\n \nPearlsAndLinks()"}, {"source_code": "x=input()\ns=0\nq=0\nl=0\nfor i in x:\n if i=='-':\n if l==1:\n s+=1\n else:\n q+=1\n else:\n i=='o'\n l+=1\nif x==1:\n print(\"NO\")\nelse:\n if s<=q:\n print('YES')\n else:\n print(\"NO\")"}, {"source_code": "a = input()\nif a.count('-') == 0:\n\tprint(\"YES\")\nelif a.count('o') == 0:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\") if (a.count('o')%a.count('-') == 0 or a.count('-')%a.count('o') == 0) else print(\"NO\")"}, {"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\n\ns=str(input())\nc1=0\nc2=0\nfor i in range(len(s)):\n\tif(s[i:i+1]==\"o\"):\n\t\tc1+=1\n\telse:\n\t\tc2+=1\n\nif(c1==0 or c2==0 or c1%c2==0 or c2%c1==0):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\t\t\n"}, {"source_code": "n = input()\na = n.count('-')\nb = n.count('o')\n\nif a%2 == 0 and b%2==0:\n\tprint(\"YES\")\nelif b%2!=0 and a%2==0:\n\tprint(\"YES\")\nelif a==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "s = input()\na = s.count(\"-\")\nb = s.count(\"o\")\nif a>=1 and b==0:\n\tprint(\"NO\")\nelif a%b==0 and a==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\t\t"}, {"source_code": "inp = input()\n\nif(inp.count(\"-\") % 2 == 0 and inp.count(\"o\") > 0):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "s = input()\no = s.count('o')\nm = s.count('-')\nif o == 1:\n print(\"YES\")\nelse:\n if not m:\n print(\"YES\")\n else:\n if not o:\n print(\"NO\")\n else:\n if max(o, m) % min(o, m) == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\n\n\n\n\n\n\n\n\n\n\n"}, {"source_code": "s = input()\nlinks = 0\npearls = 0\nif \"o\" in s: pearls = s.count(\"o\")\nif \"-\" in s: links = s.count(\"-\")\nif pearls==0 or links%pearls:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n# - - \n# o o\n#\n#\n# "}, {"source_code": "enter = input()\nequis = 0\ncirculos = 0\nfor x in enter:\n\tif x == \"o\":\n\t\tcirculos +=1\n\telse:\n\t\tequis += 1\nif not equis or not circulos:\n\tprint(\"YES\")\nelse:\t\n\tif not(circulos % equis) :\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n"}, {"source_code": "a = 0\nb = 0\nstring = input()\nfor s in string:\n if s == '-':\n a += 1\n else:\n b += 1\nif b == 0:\n print(\"NO\")\n \nelif a % b == 0:\n print(\"YES\")\n\nelse:\n print(\"NO\")"}, {"source_code": "s = raw_input()\nb, n = s.count(\"o\"), s.count(\"-\")\nprint (\"NO\", \"YES\")[n*b not in (0, b) and (n%b==0 or b%n==0)]"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\ns=input()\nif s.count(\"o\")==1:\n\tprint(\"YES\")\nelse:\t\n\tif s.count(\"-\")%2==0:\n\t\t\tif s.count(\"-\")%s.count(\"o\")==0:\n\t\t\t\tprint(\"YES\")\n\n\telse:\n\t\tprint(\"NO\")\t"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\ns=input()\nif s.count(\"o\")<=1:\n\tprint(\"YES\")\nelse:\t\n\tif s.count(\"-\")%2==0:\n\t\t\tif s.count(\"-\")%s.count(\"o\")==0:\n\t\t\t\tprint(\"YES\")\n\n\telse:\n\t\tprint(\"NO\")\t"}, {"source_code": "neck = raw_input()\n\npearls, links = 0, 0\nfor s in neck :\n if s == '-' : links += 1\n elif s == 'o' : pearls += 1\n\nif pearls > 0 and links % pearls == 0 and (links/pearls)%2 == 0 : print \"YES\"\nelif pearls == 0 and links % 2 == 0 : print \"YES\"\nelse : print \"NO\""}, {"source_code": "n=input()\nk=n.count(\"-\")\nif n.count(\"o\")<1:\n print(\"YES\")\n quit(0)\nif k%2==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s=input()\np=s.count(\"o\")\nl=s.count(\"-\")\nif p!=1 and l!=0 and p!=0:\n\tif p>l:\n\t\tif p%l==0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\t\n\telse:\n\t\tif l%p==0:\n\t\t\tprint(\"YES\")\t\t\n\t\telse:\n\t\t\tprint(\"NO\")\t\nelse:\n\tprint(\"YES\")"}, {"source_code": "S=list(input())\nH=S.count('o')\nH1=S.count('-')\nif(H1==0 or H==0):\n print(\"YES\")\nelse:\n j=0\n if(H%2==0):\n if(H>H1):\n if(H1!=(H-1)):\n j=1\n elif(H1>H):\n if(H1%H!=0):\n j=1\n if(j==1):\n print(\"NO\")\n else:\n print(\"YES\")\n \n"}, {"source_code": "from math import gcd\n# print(gcd(0,8))\ns=input()\na,b=0,0\nfor i in range(len(s)):\n\tif s[i]=='-':\n\t\ta+=1\n\telse:\n\t\tb+=1\n# print(a,b)\nmi=min(a,b)\nif mi>0:\n\tif gcd(a,b)==mi:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')\nelse:\n\tprint('YES')\n# print(s)"}, {"source_code": "x=input()\ns=0\nq=0\nl=0\nfor i in x:\n if i=='-':\n if l==1:\n s+=1\n else:\n q+=1\n else:\n i=='o'\n l+=1\nif s<=q:\n print('YES')\nelse:\n print(\"NO\")"}, {"source_code": "# cook your dish here\no=0\nd=0\ns = input()\nfor i in s:\n if i=='o':\n o+=1\n else:\n d+=1\nif o==0:\n print(\"NO\")\nelif d%o == 0:\n print(\"YES\")\nelif d==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "\ns = input()\nif s.count('0') == 0:\n print('YES')\n exit()\nif s.count('-') % s.count('o') == 0:\n print('YES')\n exit()\nprint('NO')\n\n# UBCF\n# CodeForcesian\n# \u2665\n# \u0645\u0646 \u0645\u0627\u062a \u062a\u0635\u0648\u06cc\u0631 \u062a\u0648\u0626\u0645"}, {"source_code": "s = input()\nlinks = 0\npearls = 0\nif \"o\" in s: pearls = s.count(\"o\")\nif \"-\" in s: links = s.count(\"-\")\nif pearls!=0 or links%pearls:\n print(\"NO\")\nelse:\n print(\"YES\")\n\n# - - \n# o o\n#\n#\n# "}, {"source_code": "s=input()\nring=s.count('o')\nchain=s.count('-')\nif chain==0:\n print('YES')\nelse:\n print('YES' if ring%chain==0 else 'NO')"}, {"source_code": "from random import randint\nenter = randint(0,1)\nif enter == 1:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n\n\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\ns=input()\nif s.count(\"o\")<=1:\n\tprint(\"YES\")\nelse:\t\n\tif s.count(\"-\")%2==0:\n\t\t\tif s.count(\"-\")%s.count(\"o\")==0:\n\t\t\t\tprint(\"YES\")\n\n\telse:\n\t\tprint(\"NO\")\t"}, {"source_code": "def answer(string):\n print(string.count(\"o\"), string.count(\"-\"))\n if string.count(\"o\") == 0:\n return \"YES\"\n elif string.count(\"-\") == 0:\n return \"YES\"\n elif string.count(\"o\") == 1:\n return \"YES\"\n elif string.count(\"o\")%2 == 0 and string.count(\"-\")%2 == 0:\n return \"YES\"\n elif string.count(\"o\")%2 != 0 and string.count(\"-\") == string.count(\"o\")*2:\n return \"YES\"\n else:\n return \"NO\"\n\n\n\nstring = input()\nans = answer(string)\nprint(ans)\n"}, {"source_code": "def answer(string):\n if string.count(\"o\") == 0:\n return \"YES\"\n elif string.count(\"-\") == 0:\n return \"YES\"\n elif string.count(\"o\") == 1:\n return \"YES\"\n elif string.count(\"o\")%2 == 0 and string.count(\"-\")%2 == 0:\n return \"YES\"\n else:\n return \"NO\"\n\n\n\nstring = input()\nans = answer(string)\nprint(ans)\n"}, {"source_code": "x=input()\ns=0\nq=0\nl=0\nfor i in x:\n if i=='-':\n if l==1:\n s+=1\n else:\n q+=1\n else:\n i=='o'\n l+=1\nif l==1:\n print(\"YES\")\nelse:\n if s<=q:\n print('YES')\n else:\n print(\"NO\")"}, {"source_code": "array = input()\ndef Links_and_Pearls(array):\n a = 0\n b = 0\n i = 0\n while(i0:\n\tprint(\"YES\")\nelif a>0 and b==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "s = input()\nif s.count('o') == 0 or s.count('-') % s.count('o') != 0:\n print('no')\nelse:\n print('yes')\n \n"}, {"source_code": "n = input()\na = n.count('-')\nb = n.count('o')\n\nif a%2 == 0 and b%2==0:\n\tprint(\"YES\")\nelif b%2!=0 and a%2==0:\n\tprint(\"YES\")\nelif a==0 and b>0:\n\tprint(\"YES\")\nelif a>0 and b==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "inp = input()\n\nif(inp.count(\"-\") % 2 == (inp.count(\"-\") % 2) or \"o\" not in inp):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = input()\na = 0\nb = 0\nfor i in n:\n if i == '-':\n a += 1\n else:\n b += 1\n\nif b == 0:\n print(\"NO\")\nelse:\n if a % b == 0:\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "n=list(input())\nx=n.count(\"-\")\nz=n.count(\"o\")\nif z!=0 and x%z==0:\n\tprint(\"YES\")\nelif z==0:\n\tprint(\"NO\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "def Links_and_Pearls(array):\n lists = list(array)\n a = 0\n b = 0\n i = 0\n while(array[i]):\n if(array[i] == \"o\"):\n a = a + 1\n else:\n b = b + 1\n i = i + 1\n if(a == 0):\n return YES\n else:\n if(b%a==0):\n return YES\n else:\n return NO"}, {"source_code": "def Links_and_Pearls(array):\n lists = list(array)\n a = 0\n b = 0\n i = 0\n while(i0:\n\tprint(\"YES\")\nelif a>0 and b==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "str=input()\np=0\nl=0\nfor i in str:\n if i=='-':\n l+=1\n else:\n p+=1\nif l>=p and l%p==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\nx= s.count(\"o\")\nn = len(s)\ny = s.count(\"-\")\nt = 1\nwhile(t>0):\n if(x==n or y==n or x==1):\n print(\"YES\")\n break\n else:\n if(x+y)%2!=0:\n print(\"N0\")\n t = t -1\n"}, {"source_code": "inp = input()\n\nif( ((inp.count(\"-\") % 2) == (inp.count(\"o\") % 2)) or \"o\" not in inp):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "array = input()\ndef Links_and_Pearls(array):\n a = 0\n b = 0\n i = 0\n while(i=1 and b==0:\n\tprint(\"NO\")\nelif a%b==0 or a==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\t\t"}, {"source_code": "a = input()\nif a.count('-') == 0:\n\tprint(\"YES\")\nelif a.count('o') == 0:\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\") if (a.count('o')%a.count('-') == 0 or a.count('-')%a.count('o') == 0) else print(\"NO\")"}, {"source_code": "n = input()\na = n.count('-')\nb = n.count('o')\n\nif a%2 == 0 and b%2==0:\n\tprint(\"YES\")\nelif b%2!=0 and a%2==0:\n\tprint(\"YES\")\nelif a==0:\n\tprint(\"YES\")\nelif b==0:\n\tprint(\"NO\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "b = 0\nn = 0\nfor x in input():\n if x == '-':\n n += 1\n if x == 'o':\n b += 1\nif b == 0:\n print('NO')\nelif n % b == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "s = raw_input()\nb = s.count(\"o\")\nn = s.count(\"-\")\nprint (\"NO\", \"YES\")[n*b not in (0,n,b) and n%b==0 or b%n==0]"}, {"source_code": "s=input()\nx=s.count('-')%2\ny=s.count('o')%2\nif x==y or s==\"\": \n print (\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s=input()\nd={}\nfor i in s:\n\td[i]=d.get(i,0)+1\nb=d.get(\"-\",0)\na=d.get(\"o\",0)\nprint(a,b)\nif a==0 or b==0 or b%a==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\t"}, {"source_code": "n = raw_input()\n\na = n.count('o')\nb = n.count('-')\n\n\n\nif a*b == 0 or ( a>b and a%b == 0) or (b>a and b%a==0) :\n print 'YES' \nelse :\n print 'NO'"}, {"source_code": "def Links_and_Pearls(array):\n print(\"YES\")\n "}, {"source_code": "s = input()\no = s.count('o')\nd = s.count('-')\nif(o > 2 and d != 0):\n\tprint(\"NO\")\nelif(o == 2 and d%2 == 1):\n\tprint(\"NO\")\nelse:\n\tprint(\"YES\")\n"}, {"source_code": "a=list(input())\nb=a.count('-')\nif b%2==0:\n\tprint('YES')\nelse:\n\tprint('NO')"}, {"source_code": "s = input()\n\nif s.count('-') % 2 == 0:\n\tprint('YES')\nelse:\n\tprint('NO')\n"}, {"source_code": "s = list(input())\na = s.count('o')\nb = s.count('-')\n\nif b == 0 or a == 0:\n print('YES')\nelif a == 1:\n print('YES')\nelse:\n if b%a == 0 and b <= a:\n print('YES')\n else:\n print('NO')"}, {"source_code": "s=input()\nx=s.count('-')\nif x%2==0:\n print ('YES')\nelse:\n print ('NO')"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\ns=input()\nif s.count(\"o\")==1:\n\tprint(\"YES\")\nelse:\t\n\tif s.count(\"-\")%2==0:\n\t\t\tif s.count(\"-\")%s.count(\"o\")==0:\n\t\t\t\tprint(\"YES\")\n\n\telse:\n\t\tprint(\"NO\")\t"}, {"source_code": "n=list(input())\nx=n.count(\"-\")\nz=n.count(\"o\")\nif z!=0 and x%z==0:\n\tprint(\"YES\")\nelif z==0:\n\tprint(\"NO\")\nelse:\n\tprint(\"NO\")"}, {"source_code": "a=input()\nc1=0\nc2=0\nfor i in range(0,len(a)):\n if a[i]=='-':\n c1+=1\n else:\n c2+=1\nif c2!=0 and c1%c2==0:\n print(\"YES\")\nelse:\n print(\"NO\")"}, {"source_code": "s = input()\no = s.count('o')\nd = s.count('d')\nif o == 0 or d == 0 or d % o == 0:\n print('YES')\nelse:\n print('NO')"}, {"source_code": "def Links_and_Pearls(array):\n lists = list(array)\n a = 0\n b = 0\n for x in lists:\n if(x is 'o'):\n a = a + 1\n else:\n b = b + 1\n if(a == 0):\n return YES\n else:\n if(b%a==0):\n return YES\n else:\n return NO"}, {"source_code": "inp = input()\n\nif( ((inp.count(\"-\") % 2) == (inp.count(\"o\") % 2)) or \"o\" not in inp):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "import time\nstring = input(\"\")\nstartTime = time.time()\nlinks = 0\npearls = 0\nfor i in string:\n if i == 'o':\n pearls+=1\n if i == '-':\n links+=1\nprint(links)\nprint(pearls)\nif links == 0:\n print(\"YES\")\nelif links%pearls == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n\nprint(time.time()-startTime)\n"}, {"source_code": "enter = \"ooo\"\nequis = 0\ncirculos = 0\nfor x in enter:\n\tif x == \"o\":\n\t\tcirculos +=1\n\telse:\n\t\tequis += 1\nif not equis or not circulos:\n\tprint(\"YES\")\nelse:\n\tif circulos > equis:\n\t\tprint(\"NO\")\n\telse:\n\t\tif not(equis % circulos) :\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n"}, {"source_code": "inp = input()\n\nif(inp.count(\"-\") % 2 == 0 or \"-\" not in inp):\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "n = raw_input()\n\na = n.count('o')\nb = n.count('-')\n\nif a*b == 0 or a%b == 0 :\n print 'YES' \nelse :\n print 'NO'"}, {"source_code": "def Links_and_Pearls(array):\n lists = list(array)\n a = 0\n b = 0\n for x in lists:\n if(x is 'o'):\n a = a + 1\n else:\n b = b + 1\n if(a == 0):\n return YES\n else:\n if(b%a==0):\n return YES\n else:\n return NO"}, {"source_code": "s=input()\nx=s.count('-')\nif x%2==0:\n print ('YES')\nelse:\n print ('NO')"}, {"source_code": "s=input()\no=s.count('o')\nw=s.count('-')\nif(o==0 or w==0):\n print(\"YES\")\nelse: \n temp=abs(o-w)\n if(temp==1 and abs(o-w)==1):\n print(\"NO\")\n elif(temp%min(o,w)==0):\n print(\"YES\")\n else:\n print(\"NO\")"}, {"source_code": "st=input()\n#print(st)\nl =len(st)\n#q=int(q)\nq=0\nb=0\n#print(l)\nfor i in range(l):\n if st[i]=='o':\n q=q+1\n else:\n b=b+1\nif q!=0:\n if b%q==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n"}, {"source_code": "# import sys\n# sys.stdin=open(\"input.in\",'r')\n# sys.stdout=open(\"output4.out\",'w')\ns=input()\nif s.count(\"o\")==1:\n\tprint(\"YES\")\nelse:\t\n\tif s.count(\"-\")%2==0:\n\t\t\tif s.count(\"-\")%s.count(\"o\")==0:\n\t\t\t\tprint(\"YES\")\n\n\telse:\n\t\tprint(\"NO\")\t"}, {"source_code": "s=list(input())\nx=s.count('-')\ny=s.count('o')\nif(y==0 and x%2!=0):\n\tprint('YES')\nelif(y==0):\n\tprint('NO')\nelif(x%y==0):\n\tprint('YES')\nelse:\n\tprint('NO')"}], "src_uid": "6e006ae3df3bcd24755358a5f584ec03"}